documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362
  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. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @param mimeType defines the optional mime type of the file being loaded
  1067. * @returns true if the loader can load the specified file
  1068. */
  1069. canLoad(extension: string, mimeType?: string): boolean;
  1070. /**
  1071. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param createPolynomials will be true if polynomials have been requested
  1075. * @param onLoad defines the callback to trigger once the texture is ready
  1076. * @param onError defines the callback to trigger in case of error
  1077. */
  1078. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1079. /**
  1080. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1081. * @param data contains the texture data
  1082. * @param texture defines the BabylonJS internal texture
  1083. * @param callback defines the method to call once ready to upload
  1084. */
  1085. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1086. }
  1087. }
  1088. declare module BABYLON {
  1089. /**
  1090. * Class used to store and describe the pipeline context associated with an effect
  1091. */
  1092. export interface IPipelineContext {
  1093. /**
  1094. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1095. */
  1096. isAsync: boolean;
  1097. /**
  1098. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1099. */
  1100. isReady: boolean;
  1101. /** @hidden */
  1102. _getVertexShaderCode(): string | null;
  1103. /** @hidden */
  1104. _getFragmentShaderCode(): string | null;
  1105. /** @hidden */
  1106. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1107. }
  1108. }
  1109. declare module BABYLON {
  1110. /**
  1111. * Class used to store gfx data (like WebGLBuffer)
  1112. */
  1113. export class DataBuffer {
  1114. /**
  1115. * Gets or sets the number of objects referencing this buffer
  1116. */
  1117. references: number;
  1118. /** Gets or sets the size of the underlying buffer */
  1119. capacity: number;
  1120. /**
  1121. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1122. */
  1123. is32Bits: boolean;
  1124. /**
  1125. * Gets the underlying buffer
  1126. */
  1127. get underlyingResource(): any;
  1128. }
  1129. }
  1130. declare module BABYLON {
  1131. /** @hidden */
  1132. export interface IShaderProcessor {
  1133. attributeProcessor?: (attribute: string) => string;
  1134. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1135. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1136. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1137. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1138. lineProcessor?: (line: string, isFragment: boolean) => string;
  1139. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1141. }
  1142. }
  1143. declare module BABYLON {
  1144. /** @hidden */
  1145. export interface ProcessingOptions {
  1146. defines: string[];
  1147. indexParameters: any;
  1148. isFragment: boolean;
  1149. shouldUseHighPrecisionShader: boolean;
  1150. supportsUniformBuffers: boolean;
  1151. shadersRepository: string;
  1152. includesShadersStore: {
  1153. [key: string]: string;
  1154. };
  1155. processor?: IShaderProcessor;
  1156. version: string;
  1157. platformName: string;
  1158. lookForClosingBracketForUniformBuffer?: boolean;
  1159. }
  1160. }
  1161. declare module BABYLON {
  1162. /** @hidden */
  1163. export class ShaderCodeNode {
  1164. line: string;
  1165. children: ShaderCodeNode[];
  1166. additionalDefineKey?: string;
  1167. additionalDefineValue?: string;
  1168. isValid(preprocessors: {
  1169. [key: string]: string;
  1170. }): boolean;
  1171. process(preprocessors: {
  1172. [key: string]: string;
  1173. }, options: ProcessingOptions): string;
  1174. }
  1175. }
  1176. declare module BABYLON {
  1177. /** @hidden */
  1178. export class ShaderCodeCursor {
  1179. private _lines;
  1180. lineIndex: number;
  1181. get currentLine(): string;
  1182. get canRead(): boolean;
  1183. set lines(value: string[]);
  1184. }
  1185. }
  1186. declare module BABYLON {
  1187. /** @hidden */
  1188. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1189. process(preprocessors: {
  1190. [key: string]: string;
  1191. }, options: ProcessingOptions): string;
  1192. }
  1193. }
  1194. declare module BABYLON {
  1195. /** @hidden */
  1196. export class ShaderDefineExpression {
  1197. isTrue(preprocessors: {
  1198. [key: string]: string;
  1199. }): boolean;
  1200. private static _OperatorPriority;
  1201. private static _Stack;
  1202. static postfixToInfix(postfix: string[]): string;
  1203. static infixToPostfix(infix: string): string[];
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. 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>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. 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;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. 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;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. /**
  1465. * Loads a file from a url
  1466. * @param url url to load
  1467. * @param onSuccess callback called when the file successfully loads
  1468. * @param onProgress callback called while file is loading (if the server supports this mode)
  1469. * @param offlineProvider defines the offline provider for caching
  1470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1471. * @param onError callback called when the file fails to load
  1472. * @returns a file request object
  1473. * @hidden
  1474. */
  1475. 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;
  1476. }
  1477. }
  1478. declare module BABYLON {
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor4Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. a: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IColor3Like {
  1492. r: float;
  1493. g: float;
  1494. b: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector4Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. w: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IVector3Like {
  1509. x: float;
  1510. y: float;
  1511. z: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector2Like {
  1517. x: float;
  1518. y: float;
  1519. }
  1520. /**
  1521. * @hidden
  1522. */
  1523. export interface IMatrixLike {
  1524. toArray(): DeepImmutable<Float32Array>;
  1525. updateFlag: int;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IViewportLike {
  1531. x: float;
  1532. y: float;
  1533. width: float;
  1534. height: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IPlaneLike {
  1540. normal: IVector3Like;
  1541. d: float;
  1542. normalize(): void;
  1543. }
  1544. }
  1545. declare module BABYLON {
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. }
  1850. declare module BABYLON {
  1851. /**
  1852. * Class used to represent a viewport on screen
  1853. */
  1854. export class Viewport {
  1855. /** viewport left coordinate */
  1856. x: number;
  1857. /** viewport top coordinate */
  1858. y: number;
  1859. /**viewport width */
  1860. width: number;
  1861. /** viewport height */
  1862. height: number;
  1863. /**
  1864. * Creates a Viewport object located at (x, y) and sized (width, height)
  1865. * @param x defines viewport left coordinate
  1866. * @param y defines viewport top coordinate
  1867. * @param width defines the viewport width
  1868. * @param height defines the viewport height
  1869. */
  1870. constructor(
  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 new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1881. * @param renderWidth defines the rendering width
  1882. * @param renderHeight defines the rendering height
  1883. * @returns a new Viewport
  1884. */
  1885. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1886. /**
  1887. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1888. * @param renderWidth defines the rendering width
  1889. * @param renderHeight defines the rendering height
  1890. * @param ref defines the target viewport
  1891. * @returns the current viewport
  1892. */
  1893. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1894. /**
  1895. * Returns a new Viewport copied from the current one
  1896. * @returns a new Viewport
  1897. */
  1898. clone(): Viewport;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class containing a set of static utilities functions for arrays.
  1904. */
  1905. export class ArrayTools {
  1906. /**
  1907. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1908. * @param size the number of element to construct and put in the array
  1909. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1910. * @returns a new array filled with new objects
  1911. */
  1912. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1913. }
  1914. }
  1915. declare module BABYLON {
  1916. /**
  1917. * Represents a plane by the equation ax + by + cz + d = 0
  1918. */
  1919. export class Plane {
  1920. private static _TmpMatrix;
  1921. /**
  1922. * Normal of the plane (a,b,c)
  1923. */
  1924. normal: Vector3;
  1925. /**
  1926. * d component of the plane
  1927. */
  1928. d: number;
  1929. /**
  1930. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1931. * @param a a component of the plane
  1932. * @param b b component of the plane
  1933. * @param c c component of the plane
  1934. * @param d d component of the plane
  1935. */
  1936. constructor(a: number, b: number, c: number, d: number);
  1937. /**
  1938. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1939. */
  1940. asArray(): number[];
  1941. /**
  1942. * @returns a new plane copied from the current Plane.
  1943. */
  1944. clone(): Plane;
  1945. /**
  1946. * @returns the string "Plane".
  1947. */
  1948. getClassName(): string;
  1949. /**
  1950. * @returns the Plane hash code.
  1951. */
  1952. getHashCode(): number;
  1953. /**
  1954. * Normalize the current Plane in place.
  1955. * @returns the updated Plane.
  1956. */
  1957. normalize(): Plane;
  1958. /**
  1959. * Applies a transformation the plane and returns the result
  1960. * @param transformation the transformation matrix to be applied to the plane
  1961. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1962. */
  1963. transform(transformation: DeepImmutable<Matrix>): Plane;
  1964. /**
  1965. * Compute the dot product between the point and the plane normal
  1966. * @param point point to calculate the dot product with
  1967. * @returns the dot product (float) of the point coordinates and the plane normal.
  1968. */
  1969. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1970. /**
  1971. * Updates the current Plane from the plane defined by the three given points.
  1972. * @param point1 one of the points used to contruct the plane
  1973. * @param point2 one of the points used to contruct the plane
  1974. * @param point3 one of the points used to contruct the plane
  1975. * @returns the updated Plane.
  1976. */
  1977. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1978. /**
  1979. * Checks if the plane is facing a given direction
  1980. * @param direction the direction to check if the plane is facing
  1981. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1982. * @returns True is the vector "direction" is the same side than the plane normal.
  1983. */
  1984. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1985. /**
  1986. * Calculates the distance to a point
  1987. * @param point point to calculate distance to
  1988. * @returns the signed distance (float) from the given point to the Plane.
  1989. */
  1990. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1991. /**
  1992. * Creates a plane from an array
  1993. * @param array the array to create a plane from
  1994. * @returns a new Plane from the given array.
  1995. */
  1996. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1997. /**
  1998. * Creates a plane from three points
  1999. * @param point1 point used to create the plane
  2000. * @param point2 point used to create the plane
  2001. * @param point3 point used to create the plane
  2002. * @returns a new Plane defined by the three given points.
  2003. */
  2004. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2005. /**
  2006. * Creates a plane from an origin point and a normal
  2007. * @param origin origin of the plane to be constructed
  2008. * @param normal normal of the plane to be constructed
  2009. * @returns a new Plane the normal vector to this plane at the given origin point.
  2010. * Note : the vector "normal" is updated because normalized.
  2011. */
  2012. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2013. /**
  2014. * Calculates the distance from a plane and a point
  2015. * @param origin origin of the plane to be constructed
  2016. * @param normal normal of the plane to be constructed
  2017. * @param point point to calculate distance to
  2018. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2019. */
  2020. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2021. }
  2022. }
  2023. declare module BABYLON {
  2024. /**
  2025. * Class representing a vector containing 2 coordinates
  2026. */
  2027. export class Vector2 {
  2028. /** defines the first coordinate */
  2029. x: number;
  2030. /** defines the second coordinate */
  2031. y: number;
  2032. /**
  2033. * Creates a new Vector2 from the given x and y coordinates
  2034. * @param x defines the first coordinate
  2035. * @param y defines the second coordinate
  2036. */
  2037. constructor(
  2038. /** defines the first coordinate */
  2039. x?: number,
  2040. /** defines the second coordinate */
  2041. y?: number);
  2042. /**
  2043. * Gets a string with the Vector2 coordinates
  2044. * @returns a string with the Vector2 coordinates
  2045. */
  2046. toString(): string;
  2047. /**
  2048. * Gets class name
  2049. * @returns the string "Vector2"
  2050. */
  2051. getClassName(): string;
  2052. /**
  2053. * Gets current vector hash code
  2054. * @returns the Vector2 hash code as a number
  2055. */
  2056. getHashCode(): number;
  2057. /**
  2058. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2059. * @param array defines the source array
  2060. * @param index defines the offset in source array
  2061. * @returns the current Vector2
  2062. */
  2063. toArray(array: FloatArray, index?: number): Vector2;
  2064. /**
  2065. * Copy the current vector to an array
  2066. * @returns a new array with 2 elements: the Vector2 coordinates.
  2067. */
  2068. asArray(): number[];
  2069. /**
  2070. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2071. * @param source defines the source Vector2
  2072. * @returns the current updated Vector2
  2073. */
  2074. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2075. /**
  2076. * Sets the Vector2 coordinates with the given floats
  2077. * @param x defines the first coordinate
  2078. * @param y defines the second coordinate
  2079. * @returns the current updated Vector2
  2080. */
  2081. copyFromFloats(x: number, y: number): Vector2;
  2082. /**
  2083. * Sets the Vector2 coordinates with the given floats
  2084. * @param x defines the first coordinate
  2085. * @param y defines the second coordinate
  2086. * @returns the current updated Vector2
  2087. */
  2088. set(x: number, y: number): Vector2;
  2089. /**
  2090. * Add another vector with the current one
  2091. * @param otherVector defines the other vector
  2092. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2093. */
  2094. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2095. /**
  2096. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2097. * @param otherVector defines the other vector
  2098. * @param result defines the target vector
  2099. * @returns the unmodified current Vector2
  2100. */
  2101. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2102. /**
  2103. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2104. * @param otherVector defines the other vector
  2105. * @returns the current updated Vector2
  2106. */
  2107. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2108. /**
  2109. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2110. * @param otherVector defines the other vector
  2111. * @returns a new Vector2
  2112. */
  2113. addVector3(otherVector: Vector3): Vector2;
  2114. /**
  2115. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2116. * @param otherVector defines the other vector
  2117. * @returns a new Vector2
  2118. */
  2119. subtract(otherVector: Vector2): Vector2;
  2120. /**
  2121. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2122. * @param otherVector defines the other vector
  2123. * @param result defines the target vector
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2127. /**
  2128. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2129. * @param otherVector defines the other vector
  2130. * @returns the current updated Vector2
  2131. */
  2132. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Multiplies in place the current Vector2 coordinates by the given ones
  2135. * @param otherVector defines the other vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2139. /**
  2140. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2141. * @param otherVector defines the other vector
  2142. * @returns a new Vector2
  2143. */
  2144. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2145. /**
  2146. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2147. * @param otherVector defines the other vector
  2148. * @param result defines the target vector
  2149. * @returns the unmodified current Vector2
  2150. */
  2151. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2154. * @param x defines the first coordinate
  2155. * @param y defines the second coordinate
  2156. * @returns a new Vector2
  2157. */
  2158. multiplyByFloats(x: number, y: number): Vector2;
  2159. /**
  2160. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2161. * @param otherVector defines the other vector
  2162. * @returns a new Vector2
  2163. */
  2164. divide(otherVector: Vector2): Vector2;
  2165. /**
  2166. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @param result defines the target vector
  2169. * @returns the unmodified current Vector2
  2170. */
  2171. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2172. /**
  2173. * Divides the current Vector2 coordinates by the given ones
  2174. * @param otherVector defines the other vector
  2175. * @returns the current updated Vector2
  2176. */
  2177. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2178. /**
  2179. * Gets a new Vector2 with current Vector2 negated coordinates
  2180. * @returns a new Vector2
  2181. */
  2182. negate(): Vector2;
  2183. /**
  2184. * Negate this vector in place
  2185. * @returns this
  2186. */
  2187. negateInPlace(): Vector2;
  2188. /**
  2189. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2190. * @param result defines the Vector3 object where to store the result
  2191. * @returns the current Vector2
  2192. */
  2193. negateToRef(result: Vector2): Vector2;
  2194. /**
  2195. * Multiply the Vector2 coordinates by scale
  2196. * @param scale defines the scaling factor
  2197. * @returns the current updated Vector2
  2198. */
  2199. scaleInPlace(scale: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2202. * @param scale defines the scaling factor
  2203. * @returns a new Vector2
  2204. */
  2205. scale(scale: number): Vector2;
  2206. /**
  2207. * Scale the current Vector2 values by a factor to a given Vector2
  2208. * @param scale defines the scale factor
  2209. * @param result defines the Vector2 object where to store the result
  2210. * @returns the unmodified current Vector2
  2211. */
  2212. scaleToRef(scale: number, result: Vector2): Vector2;
  2213. /**
  2214. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2215. * @param scale defines the scale factor
  2216. * @param result defines the Vector2 object where to store the result
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2220. /**
  2221. * Gets a boolean if two vectors are equals
  2222. * @param otherVector defines the other vector
  2223. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2224. */
  2225. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2226. /**
  2227. * Gets a boolean if two vectors are equals (using an epsilon value)
  2228. * @param otherVector defines the other vector
  2229. * @param epsilon defines the minimal distance to consider equality
  2230. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2231. */
  2232. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2233. /**
  2234. * Gets a new Vector2 from current Vector2 floored values
  2235. * @returns a new Vector2
  2236. */
  2237. floor(): Vector2;
  2238. /**
  2239. * Gets a new Vector2 from current Vector2 floored values
  2240. * @returns a new Vector2
  2241. */
  2242. fract(): Vector2;
  2243. /**
  2244. * Gets the length of the vector
  2245. * @returns the vector length (float)
  2246. */
  2247. length(): number;
  2248. /**
  2249. * Gets the vector squared length
  2250. * @returns the vector squared length (float)
  2251. */
  2252. lengthSquared(): number;
  2253. /**
  2254. * Normalize the vector
  2255. * @returns the current updated Vector2
  2256. */
  2257. normalize(): Vector2;
  2258. /**
  2259. * Gets a new Vector2 copied from the Vector2
  2260. * @returns a new Vector2
  2261. */
  2262. clone(): Vector2;
  2263. /**
  2264. * Gets a new Vector2(0, 0)
  2265. * @returns a new Vector2
  2266. */
  2267. static Zero(): Vector2;
  2268. /**
  2269. * Gets a new Vector2(1, 1)
  2270. * @returns a new Vector2
  2271. */
  2272. static One(): Vector2;
  2273. /**
  2274. * Gets a new Vector2 set from the given index element of the given array
  2275. * @param array defines the data source
  2276. * @param offset defines the offset in the data source
  2277. * @returns a new Vector2
  2278. */
  2279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2280. /**
  2281. * Sets "result" from the given index element of the given array
  2282. * @param array defines the data source
  2283. * @param offset defines the offset in the data source
  2284. * @param result defines the target vector
  2285. */
  2286. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2287. /**
  2288. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2289. * @param value1 defines 1st point of control
  2290. * @param value2 defines 2nd point of control
  2291. * @param value3 defines 3rd point of control
  2292. * @param value4 defines 4th point of control
  2293. * @param amount defines the interpolation factor
  2294. * @returns a new Vector2
  2295. */
  2296. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2297. /**
  2298. * 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".
  2299. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2300. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2301. * @param value defines the value to clamp
  2302. * @param min defines the lower limit
  2303. * @param max defines the upper limit
  2304. * @returns a new Vector2
  2305. */
  2306. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2307. /**
  2308. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2309. * @param value1 defines the 1st control point
  2310. * @param tangent1 defines the outgoing tangent
  2311. * @param value2 defines the 2nd control point
  2312. * @param tangent2 defines the incoming tangent
  2313. * @param amount defines the interpolation factor
  2314. * @returns a new Vector2
  2315. */
  2316. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2317. /**
  2318. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2319. * @param start defines the start vector
  2320. * @param end defines the end vector
  2321. * @param amount defines the interpolation factor
  2322. * @returns a new Vector2
  2323. */
  2324. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2325. /**
  2326. * Gets the dot product of the vector "left" and the vector "right"
  2327. * @param left defines first vector
  2328. * @param right defines second vector
  2329. * @returns the dot product (float)
  2330. */
  2331. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2332. /**
  2333. * Returns a new Vector2 equal to the normalized given vector
  2334. * @param vector defines the vector to normalize
  2335. * @returns a new Vector2
  2336. */
  2337. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2338. /**
  2339. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2340. * @param left defines 1st vector
  2341. * @param right defines 2nd vector
  2342. * @returns a new Vector2
  2343. */
  2344. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2347. * @param left defines 1st vector
  2348. * @param right defines 2nd vector
  2349. * @returns a new Vector2
  2350. */
  2351. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2352. /**
  2353. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2354. * @param vector defines the vector to transform
  2355. * @param transformation defines the matrix to apply
  2356. * @returns a new Vector2
  2357. */
  2358. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2359. /**
  2360. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2361. * @param vector defines the vector to transform
  2362. * @param transformation defines the matrix to apply
  2363. * @param result defines the target vector
  2364. */
  2365. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2366. /**
  2367. * Determines if a given vector is included in a triangle
  2368. * @param p defines the vector to test
  2369. * @param p0 defines 1st triangle point
  2370. * @param p1 defines 2nd triangle point
  2371. * @param p2 defines 3rd triangle point
  2372. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2373. */
  2374. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2375. /**
  2376. * Gets the distance between the vectors "value1" and "value2"
  2377. * @param value1 defines first vector
  2378. * @param value2 defines second vector
  2379. * @returns the distance between vectors
  2380. */
  2381. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2382. /**
  2383. * Returns the squared distance between the vectors "value1" and "value2"
  2384. * @param value1 defines first vector
  2385. * @param value2 defines second vector
  2386. * @returns the squared distance between vectors
  2387. */
  2388. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2389. /**
  2390. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2391. * @param value1 defines first vector
  2392. * @param value2 defines second vector
  2393. * @returns a new Vector2
  2394. */
  2395. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2396. /**
  2397. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2398. * @param p defines the middle point
  2399. * @param segA defines one point of the segment
  2400. * @param segB defines the other point of the segment
  2401. * @returns the shortest distance
  2402. */
  2403. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2404. }
  2405. /**
  2406. * Class used to store (x,y,z) vector representation
  2407. * A Vector3 is the main object used in 3D geometry
  2408. * It can represent etiher the coordinates of a point the space, either a direction
  2409. * Reminder: js uses a left handed forward facing system
  2410. */
  2411. export class Vector3 {
  2412. private static _UpReadOnly;
  2413. private static _ZeroReadOnly;
  2414. /** @hidden */
  2415. _x: number;
  2416. /** @hidden */
  2417. _y: number;
  2418. /** @hidden */
  2419. _z: number;
  2420. /** @hidden */
  2421. _isDirty: boolean;
  2422. /** Gets or sets the x coordinate */
  2423. get x(): number;
  2424. set x(value: number);
  2425. /** Gets or sets the y coordinate */
  2426. get y(): number;
  2427. set y(value: number);
  2428. /** Gets or sets the z coordinate */
  2429. get z(): number;
  2430. set z(value: number);
  2431. /**
  2432. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2433. * @param x defines the first coordinates (on X axis)
  2434. * @param y defines the second coordinates (on Y axis)
  2435. * @param z defines the third coordinates (on Z axis)
  2436. */
  2437. constructor(x?: number, y?: number, z?: number);
  2438. /**
  2439. * Creates a string representation of the Vector3
  2440. * @returns a string with the Vector3 coordinates.
  2441. */
  2442. toString(): string;
  2443. /**
  2444. * Gets the class name
  2445. * @returns the string "Vector3"
  2446. */
  2447. getClassName(): string;
  2448. /**
  2449. * Creates the Vector3 hash code
  2450. * @returns a number which tends to be unique between Vector3 instances
  2451. */
  2452. getHashCode(): number;
  2453. /**
  2454. * Creates an array containing three elements : the coordinates of the Vector3
  2455. * @returns a new array of numbers
  2456. */
  2457. asArray(): number[];
  2458. /**
  2459. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2460. * @param array defines the destination array
  2461. * @param index defines the offset in the destination array
  2462. * @returns the current Vector3
  2463. */
  2464. toArray(array: FloatArray, index?: number): Vector3;
  2465. /**
  2466. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2467. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2468. */
  2469. toQuaternion(): Quaternion;
  2470. /**
  2471. * Adds the given vector to the current Vector3
  2472. * @param otherVector defines the second operand
  2473. * @returns the current updated Vector3
  2474. */
  2475. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2476. /**
  2477. * Adds the given coordinates to the current Vector3
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns the current updated Vector3
  2482. */
  2483. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2484. /**
  2485. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2486. * @param otherVector defines the second operand
  2487. * @returns the resulting Vector3
  2488. */
  2489. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2492. * @param otherVector defines the second operand
  2493. * @param result defines the Vector3 object where to store the result
  2494. * @returns the current Vector3
  2495. */
  2496. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2497. /**
  2498. * Subtract the given vector from the current Vector3
  2499. * @param otherVector defines the second operand
  2500. * @returns the current updated Vector3
  2501. */
  2502. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2503. /**
  2504. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the resulting Vector3
  2507. */
  2508. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2511. * @param otherVector defines the second operand
  2512. * @param result defines the Vector3 object where to store the result
  2513. * @returns the current Vector3
  2514. */
  2515. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2516. /**
  2517. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2518. * @param x defines the x coordinate of the operand
  2519. * @param y defines the y coordinate of the operand
  2520. * @param z defines the z coordinate of the operand
  2521. * @returns the resulting Vector3
  2522. */
  2523. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2524. /**
  2525. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2526. * @param x defines the x coordinate of the operand
  2527. * @param y defines the y coordinate of the operand
  2528. * @param z defines the z coordinate of the operand
  2529. * @param result defines the Vector3 object where to store the result
  2530. * @returns the current Vector3
  2531. */
  2532. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2533. /**
  2534. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2535. * @returns a new Vector3
  2536. */
  2537. negate(): Vector3;
  2538. /**
  2539. * Negate this vector in place
  2540. * @returns this
  2541. */
  2542. negateInPlace(): Vector3;
  2543. /**
  2544. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2545. * @param result defines the Vector3 object where to store the result
  2546. * @returns the current Vector3
  2547. */
  2548. negateToRef(result: Vector3): Vector3;
  2549. /**
  2550. * Multiplies the Vector3 coordinates by the float "scale"
  2551. * @param scale defines the multiplier factor
  2552. * @returns the current updated Vector3
  2553. */
  2554. scaleInPlace(scale: number): Vector3;
  2555. /**
  2556. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns a new Vector3
  2559. */
  2560. scale(scale: number): Vector3;
  2561. /**
  2562. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2563. * @param scale defines the multiplier factor
  2564. * @param result defines the Vector3 object where to store the result
  2565. * @returns the current Vector3
  2566. */
  2567. scaleToRef(scale: number, result: Vector3): Vector3;
  2568. /**
  2569. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2570. * @param scale defines the scale factor
  2571. * @param result defines the Vector3 object where to store the result
  2572. * @returns the unmodified current Vector3
  2573. */
  2574. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2575. /**
  2576. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2577. * @param origin defines the origin of the projection ray
  2578. * @param plane defines the plane to project to
  2579. * @returns the projected vector3
  2580. */
  2581. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2582. /**
  2583. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2584. * @param origin defines the origin of the projection ray
  2585. * @param plane defines the plane to project to
  2586. * @param result defines the Vector3 where to store the result
  2587. */
  2588. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2589. /**
  2590. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2591. * @param otherVector defines the second operand
  2592. * @returns true if both vectors are equals
  2593. */
  2594. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2597. * @param otherVector defines the second operand
  2598. * @param epsilon defines the minimal distance to define values as equals
  2599. * @returns true if both vectors are distant less than epsilon
  2600. */
  2601. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2602. /**
  2603. * Returns true if the current Vector3 coordinates equals the given floats
  2604. * @param x defines the x coordinate of the operand
  2605. * @param y defines the y coordinate of the operand
  2606. * @param z defines the z coordinate of the operand
  2607. * @returns true if both vectors are equals
  2608. */
  2609. equalsToFloats(x: number, y: number, z: number): boolean;
  2610. /**
  2611. * Multiplies the current Vector3 coordinates by the given ones
  2612. * @param otherVector defines the second operand
  2613. * @returns the current updated Vector3
  2614. */
  2615. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2616. /**
  2617. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2618. * @param otherVector defines the second operand
  2619. * @returns the new Vector3
  2620. */
  2621. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2624. * @param otherVector defines the second operand
  2625. * @param result defines the Vector3 object where to store the result
  2626. * @returns the current Vector3
  2627. */
  2628. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2629. /**
  2630. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2631. * @param x defines the x coordinate of the operand
  2632. * @param y defines the y coordinate of the operand
  2633. * @param z defines the z coordinate of the operand
  2634. * @returns the new Vector3
  2635. */
  2636. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2637. /**
  2638. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2639. * @param otherVector defines the second operand
  2640. * @returns the new Vector3
  2641. */
  2642. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2645. * @param otherVector defines the second operand
  2646. * @param result defines the Vector3 object where to store the result
  2647. * @returns the current Vector3
  2648. */
  2649. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2650. /**
  2651. * Divides the current Vector3 coordinates by the given ones.
  2652. * @param otherVector defines the second operand
  2653. * @returns the current updated Vector3
  2654. */
  2655. divideInPlace(otherVector: Vector3): Vector3;
  2656. /**
  2657. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2658. * @param other defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2670. * @param x defines the x coordinate of the operand
  2671. * @param y defines the y coordinate of the operand
  2672. * @param z defines the z coordinate of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2676. /**
  2677. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2678. * @param x defines the x coordinate of the operand
  2679. * @param y defines the y coordinate of the operand
  2680. * @param z defines the z coordinate of the operand
  2681. * @returns the current updated Vector3
  2682. */
  2683. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2684. /**
  2685. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2686. * Check if is non uniform within a certain amount of decimal places to account for this
  2687. * @param epsilon the amount the values can differ
  2688. * @returns if the the vector is non uniform to a certain number of decimal places
  2689. */
  2690. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2691. /**
  2692. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2693. */
  2694. get isNonUniform(): boolean;
  2695. /**
  2696. * Gets a new Vector3 from current Vector3 floored values
  2697. * @returns a new Vector3
  2698. */
  2699. floor(): Vector3;
  2700. /**
  2701. * Gets a new Vector3 from current Vector3 floored values
  2702. * @returns a new Vector3
  2703. */
  2704. fract(): Vector3;
  2705. /**
  2706. * Gets the length of the Vector3
  2707. * @returns the length of the Vector3
  2708. */
  2709. length(): number;
  2710. /**
  2711. * Gets the squared length of the Vector3
  2712. * @returns squared length of the Vector3
  2713. */
  2714. lengthSquared(): number;
  2715. /**
  2716. * Normalize the current Vector3.
  2717. * Please note that this is an in place operation.
  2718. * @returns the current updated Vector3
  2719. */
  2720. normalize(): Vector3;
  2721. /**
  2722. * Reorders the x y z properties of the vector in place
  2723. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2724. * @returns the current updated vector
  2725. */
  2726. reorderInPlace(order: string): this;
  2727. /**
  2728. * Rotates the vector around 0,0,0 by a quaternion
  2729. * @param quaternion the rotation quaternion
  2730. * @param result vector to store the result
  2731. * @returns the resulting vector
  2732. */
  2733. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2734. /**
  2735. * Rotates a vector around a given point
  2736. * @param quaternion the rotation quaternion
  2737. * @param point the point to rotate around
  2738. * @param result vector to store the result
  2739. * @returns the resulting vector
  2740. */
  2741. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2742. /**
  2743. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2744. * The cross product is then orthogonal to both current and "other"
  2745. * @param other defines the right operand
  2746. * @returns the cross product
  2747. */
  2748. cross(other: Vector3): Vector3;
  2749. /**
  2750. * Normalize the current Vector3 with the given input length.
  2751. * Please note that this is an in place operation.
  2752. * @param len the length of the vector
  2753. * @returns the current updated Vector3
  2754. */
  2755. normalizeFromLength(len: number): Vector3;
  2756. /**
  2757. * Normalize the current Vector3 to a new vector
  2758. * @returns the new Vector3
  2759. */
  2760. normalizeToNew(): Vector3;
  2761. /**
  2762. * Normalize the current Vector3 to the reference
  2763. * @param reference define the Vector3 to update
  2764. * @returns the updated Vector3
  2765. */
  2766. normalizeToRef(reference: Vector3): Vector3;
  2767. /**
  2768. * Creates a new Vector3 copied from the current Vector3
  2769. * @returns the new Vector3
  2770. */
  2771. clone(): Vector3;
  2772. /**
  2773. * Copies the given vector coordinates to the current Vector3 ones
  2774. * @param source defines the source Vector3
  2775. * @returns the current updated Vector3
  2776. */
  2777. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2778. /**
  2779. * Copies the given floats to the current Vector3 coordinates
  2780. * @param x defines the x coordinate of the operand
  2781. * @param y defines the y coordinate of the operand
  2782. * @param z defines the z coordinate of the operand
  2783. * @returns the current updated Vector3
  2784. */
  2785. copyFromFloats(x: number, y: number, z: number): Vector3;
  2786. /**
  2787. * Copies the given floats to the current Vector3 coordinates
  2788. * @param x defines the x coordinate of the operand
  2789. * @param y defines the y coordinate of the operand
  2790. * @param z defines the z coordinate of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. set(x: number, y: number, z: number): Vector3;
  2794. /**
  2795. * Copies the given float to the current Vector3 coordinates
  2796. * @param v defines the x, y and z coordinates of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. setAll(v: number): Vector3;
  2800. /**
  2801. * Get the clip factor between two vectors
  2802. * @param vector0 defines the first operand
  2803. * @param vector1 defines the second operand
  2804. * @param axis defines the axis to use
  2805. * @param size defines the size along the axis
  2806. * @returns the clip factor
  2807. */
  2808. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2809. /**
  2810. * Get angle between two vectors
  2811. * @param vector0 angle between vector0 and vector1
  2812. * @param vector1 angle between vector0 and vector1
  2813. * @param normal direction of the normal
  2814. * @return the angle between vector0 and vector1
  2815. */
  2816. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2817. /**
  2818. * Returns a new Vector3 set from the index "offset" of the given array
  2819. * @param array defines the source array
  2820. * @param offset defines the offset in the source array
  2821. * @returns the new Vector3
  2822. */
  2823. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2824. /**
  2825. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2826. * @param array defines the source array
  2827. * @param offset defines the offset in the source array
  2828. * @returns the new Vector3
  2829. * @deprecated Please use FromArray instead.
  2830. */
  2831. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2832. /**
  2833. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2834. * @param array defines the source array
  2835. * @param offset defines the offset in the source array
  2836. * @param result defines the Vector3 where to store the result
  2837. */
  2838. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2839. /**
  2840. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2841. * @param array defines the source array
  2842. * @param offset defines the offset in the source array
  2843. * @param result defines the Vector3 where to store the result
  2844. * @deprecated Please use FromArrayToRef instead.
  2845. */
  2846. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2847. /**
  2848. * Sets the given vector "result" with the given floats.
  2849. * @param x defines the x coordinate of the source
  2850. * @param y defines the y coordinate of the source
  2851. * @param z defines the z coordinate of the source
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2857. * @returns a new empty Vector3
  2858. */
  2859. static Zero(): Vector3;
  2860. /**
  2861. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2862. * @returns a new unit Vector3
  2863. */
  2864. static One(): Vector3;
  2865. /**
  2866. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2867. * @returns a new up Vector3
  2868. */
  2869. static Up(): Vector3;
  2870. /**
  2871. * Gets a up Vector3 that must not be updated
  2872. */
  2873. static get UpReadOnly(): DeepImmutable<Vector3>;
  2874. /**
  2875. * Gets a zero Vector3 that must not be updated
  2876. */
  2877. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2878. /**
  2879. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2880. * @returns a new down Vector3
  2881. */
  2882. static Down(): Vector3;
  2883. /**
  2884. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2885. * @param rightHandedSystem is the scene right-handed (negative z)
  2886. * @returns a new forward Vector3
  2887. */
  2888. static Forward(rightHandedSystem?: boolean): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative-z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Backward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2897. * @returns a new right Vector3
  2898. */
  2899. static Right(): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2902. * @returns a new left Vector3
  2903. */
  2904. static Left(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2907. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2908. * @param vector defines the Vector3 to transform
  2909. * @param transformation defines the transformation matrix
  2910. * @returns the transformed Vector3
  2911. */
  2912. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2913. /**
  2914. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2915. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2916. * @param vector defines the Vector3 to transform
  2917. * @param transformation defines the transformation matrix
  2918. * @param result defines the Vector3 where to store the result
  2919. */
  2920. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2921. /**
  2922. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2923. * This method computes tranformed coordinates only, not transformed direction vectors
  2924. * @param x define the x coordinate of the source vector
  2925. * @param y define the y coordinate of the source vector
  2926. * @param z define the z coordinate of the source vector
  2927. * @param transformation defines the transformation matrix
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2933. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2934. * @param vector defines the Vector3 to transform
  2935. * @param transformation defines the transformation matrix
  2936. * @returns the new Vector3
  2937. */
  2938. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2939. /**
  2940. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2941. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2942. * @param vector defines the Vector3 to transform
  2943. * @param transformation defines the transformation matrix
  2944. * @param result defines the Vector3 where to store the result
  2945. */
  2946. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2949. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2950. * @param x define the x coordinate of the source vector
  2951. * @param y define the y coordinate of the source vector
  2952. * @param z define the z coordinate of the source vector
  2953. * @param transformation defines the transformation matrix
  2954. * @param result defines the Vector3 where to store the result
  2955. */
  2956. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2957. /**
  2958. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2959. * @param value1 defines the first control point
  2960. * @param value2 defines the second control point
  2961. * @param value3 defines the third control point
  2962. * @param value4 defines the fourth control point
  2963. * @param amount defines the amount on the spline to use
  2964. * @returns the new Vector3
  2965. */
  2966. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2967. /**
  2968. * 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"
  2969. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2970. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2971. * @param value defines the current value
  2972. * @param min defines the lower range value
  2973. * @param max defines the upper range value
  2974. * @returns the new Vector3
  2975. */
  2976. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2977. /**
  2978. * 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"
  2979. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2980. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2981. * @param value defines the current value
  2982. * @param min defines the lower range value
  2983. * @param max defines the upper range value
  2984. * @param result defines the Vector3 where to store the result
  2985. */
  2986. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2987. /**
  2988. * Checks if a given vector is inside a specific range
  2989. * @param v defines the vector to test
  2990. * @param min defines the minimum range
  2991. * @param max defines the maximum range
  2992. */
  2993. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2994. /**
  2995. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2996. * @param value1 defines the first control point
  2997. * @param tangent1 defines the first tangent vector
  2998. * @param value2 defines the second control point
  2999. * @param tangent2 defines the second tangent vector
  3000. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3001. * @returns the new Vector3
  3002. */
  3003. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3004. /**
  3005. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3006. * @param start defines the start value
  3007. * @param end defines the end value
  3008. * @param amount max defines amount between both (between 0 and 1)
  3009. * @returns the new Vector3
  3010. */
  3011. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3014. * @param start defines the start value
  3015. * @param end defines the end value
  3016. * @param amount max defines amount between both (between 0 and 1)
  3017. * @param result defines the Vector3 where to store the result
  3018. */
  3019. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3020. /**
  3021. * Returns the dot product (float) between the vectors "left" and "right"
  3022. * @param left defines the left operand
  3023. * @param right defines the right operand
  3024. * @returns the dot product
  3025. */
  3026. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3027. /**
  3028. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3029. * The cross product is then orthogonal to both "left" and "right"
  3030. * @param left defines the left operand
  3031. * @param right defines the right operand
  3032. * @returns the cross product
  3033. */
  3034. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3035. /**
  3036. * Sets the given vector "result" with the cross product of "left" and "right"
  3037. * The cross product is then orthogonal to both "left" and "right"
  3038. * @param left defines the left operand
  3039. * @param right defines the right operand
  3040. * @param result defines the Vector3 where to store the result
  3041. */
  3042. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3043. /**
  3044. * Returns a new Vector3 as the normalization of the given vector
  3045. * @param vector defines the Vector3 to normalize
  3046. * @returns the new Vector3
  3047. */
  3048. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3049. /**
  3050. * Sets the given vector "result" with the normalization of the given first vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @param result defines the Vector3 where to store the result
  3053. */
  3054. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3055. /**
  3056. * Project a Vector3 onto screen space
  3057. * @param vector defines the Vector3 to project
  3058. * @param world defines the world matrix to use
  3059. * @param transform defines the transform (view x projection) matrix to use
  3060. * @param viewport defines the screen viewport to use
  3061. * @returns the new Vector3
  3062. */
  3063. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3064. /** @hidden */
  3065. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3066. /**
  3067. * Unproject from screen space to object space
  3068. * @param source defines the screen space Vector3 to use
  3069. * @param viewportWidth defines the current width of the viewport
  3070. * @param viewportHeight defines the current height of the viewport
  3071. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3072. * @param transform defines the transform (view x projection) matrix to use
  3073. * @returns the new Vector3
  3074. */
  3075. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3076. /**
  3077. * Unproject from screen space to object space
  3078. * @param source defines the screen space Vector3 to use
  3079. * @param viewportWidth defines the current width of the viewport
  3080. * @param viewportHeight defines the current height of the viewport
  3081. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3082. * @param view defines the view matrix to use
  3083. * @param projection defines the projection matrix to use
  3084. * @returns the new Vector3
  3085. */
  3086. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3087. /**
  3088. * Unproject from screen space to object space
  3089. * @param source defines the screen space Vector3 to use
  3090. * @param viewportWidth defines the current width of the viewport
  3091. * @param viewportHeight defines the current height of the viewport
  3092. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3093. * @param view defines the view matrix to use
  3094. * @param projection defines the projection matrix to use
  3095. * @param result defines the Vector3 where to store the result
  3096. */
  3097. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3098. /**
  3099. * Unproject from screen space to object space
  3100. * @param sourceX defines the screen space x coordinate to use
  3101. * @param sourceY defines the screen space y coordinate to use
  3102. * @param sourceZ defines the screen space z coordinate to use
  3103. * @param viewportWidth defines the current width of the viewport
  3104. * @param viewportHeight defines the current height of the viewport
  3105. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3106. * @param view defines the view matrix to use
  3107. * @param projection defines the projection matrix to use
  3108. * @param result defines the Vector3 where to store the result
  3109. */
  3110. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Gets the minimal coordinate values between two Vector3
  3113. * @param left defines the first operand
  3114. * @param right defines the second operand
  3115. * @returns the new Vector3
  3116. */
  3117. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3118. /**
  3119. * Gets the maximal coordinate values between two Vector3
  3120. * @param left defines the first operand
  3121. * @param right defines the second operand
  3122. * @returns the new Vector3
  3123. */
  3124. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Returns the distance between the vectors "value1" and "value2"
  3127. * @param value1 defines the first operand
  3128. * @param value2 defines the second operand
  3129. * @returns the distance
  3130. */
  3131. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3132. /**
  3133. * Returns the squared distance between the vectors "value1" and "value2"
  3134. * @param value1 defines the first operand
  3135. * @param value2 defines the second operand
  3136. * @returns the squared distance
  3137. */
  3138. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3139. /**
  3140. * Returns a new Vector3 located at the center between "value1" and "value2"
  3141. * @param value1 defines the first operand
  3142. * @param value2 defines the second operand
  3143. * @returns the new Vector3
  3144. */
  3145. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3146. /**
  3147. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3148. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3149. * to something in order to rotate it from its local system to the given target system
  3150. * Note: axis1, axis2 and axis3 are normalized during this operation
  3151. * @param axis1 defines the first axis
  3152. * @param axis2 defines the second axis
  3153. * @param axis3 defines the third axis
  3154. * @returns a new Vector3
  3155. */
  3156. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3157. /**
  3158. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3159. * @param axis1 defines the first axis
  3160. * @param axis2 defines the second axis
  3161. * @param axis3 defines the third axis
  3162. * @param ref defines the Vector3 where to store the result
  3163. */
  3164. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3165. }
  3166. /**
  3167. * Vector4 class created for EulerAngle class conversion to Quaternion
  3168. */
  3169. export class Vector4 {
  3170. /** x value of the vector */
  3171. x: number;
  3172. /** y value of the vector */
  3173. y: number;
  3174. /** z value of the vector */
  3175. z: number;
  3176. /** w value of the vector */
  3177. w: number;
  3178. /**
  3179. * Creates a Vector4 object from the given floats.
  3180. * @param x x value of the vector
  3181. * @param y y value of the vector
  3182. * @param z z value of the vector
  3183. * @param w w value of the vector
  3184. */
  3185. constructor(
  3186. /** x value of the vector */
  3187. x: number,
  3188. /** y value of the vector */
  3189. y: number,
  3190. /** z value of the vector */
  3191. z: number,
  3192. /** w value of the vector */
  3193. w: number);
  3194. /**
  3195. * Returns the string with the Vector4 coordinates.
  3196. * @returns a string containing all the vector values
  3197. */
  3198. toString(): string;
  3199. /**
  3200. * Returns the string "Vector4".
  3201. * @returns "Vector4"
  3202. */
  3203. getClassName(): string;
  3204. /**
  3205. * Returns the Vector4 hash code.
  3206. * @returns a unique hash code
  3207. */
  3208. getHashCode(): number;
  3209. /**
  3210. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3211. * @returns the resulting array
  3212. */
  3213. asArray(): number[];
  3214. /**
  3215. * Populates the given array from the given index with the Vector4 coordinates.
  3216. * @param array array to populate
  3217. * @param index index of the array to start at (default: 0)
  3218. * @returns the Vector4.
  3219. */
  3220. toArray(array: FloatArray, index?: number): Vector4;
  3221. /**
  3222. * Adds the given vector to the current Vector4.
  3223. * @param otherVector the vector to add
  3224. * @returns the updated Vector4.
  3225. */
  3226. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3227. /**
  3228. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3229. * @param otherVector the vector to add
  3230. * @returns the resulting vector
  3231. */
  3232. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @param result the vector to store the result
  3237. * @returns the current Vector4.
  3238. */
  3239. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3240. /**
  3241. * Subtract in place the given vector from the current Vector4.
  3242. * @param otherVector the vector to subtract
  3243. * @returns the updated Vector4.
  3244. */
  3245. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3248. * @param otherVector the vector to add
  3249. * @returns the new vector with the result
  3250. */
  3251. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to subtract
  3255. * @param result the vector to store the result
  3256. * @returns the current Vector4.
  3257. */
  3258. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3259. /**
  3260. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3261. */
  3262. /**
  3263. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3264. * @param x value to subtract
  3265. * @param y value to subtract
  3266. * @param z value to subtract
  3267. * @param w value to subtract
  3268. * @returns new vector containing the result
  3269. */
  3270. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3271. /**
  3272. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3273. * @param x value to subtract
  3274. * @param y value to subtract
  3275. * @param z value to subtract
  3276. * @param w value to subtract
  3277. * @param result the vector to store the result in
  3278. * @returns the current Vector4.
  3279. */
  3280. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3281. /**
  3282. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3283. * @returns a new vector with the negated values
  3284. */
  3285. negate(): Vector4;
  3286. /**
  3287. * Negate this vector in place
  3288. * @returns this
  3289. */
  3290. negateInPlace(): Vector4;
  3291. /**
  3292. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3293. * @param result defines the Vector3 object where to store the result
  3294. * @returns the current Vector4
  3295. */
  3296. negateToRef(result: Vector4): Vector4;
  3297. /**
  3298. * Multiplies the current Vector4 coordinates by scale (float).
  3299. * @param scale the number to scale with
  3300. * @returns the updated Vector4.
  3301. */
  3302. scaleInPlace(scale: number): Vector4;
  3303. /**
  3304. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns a new vector with the result
  3307. */
  3308. scale(scale: number): Vector4;
  3309. /**
  3310. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @param result a vector to store the result in
  3313. * @returns the current Vector4.
  3314. */
  3315. scaleToRef(scale: number, result: Vector4): Vector4;
  3316. /**
  3317. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3318. * @param scale defines the scale factor
  3319. * @param result defines the Vector4 object where to store the result
  3320. * @returns the unmodified current Vector4
  3321. */
  3322. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3323. /**
  3324. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3325. * @param otherVector the vector to compare against
  3326. * @returns true if they are equal
  3327. */
  3328. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3331. * @param otherVector vector to compare against
  3332. * @param epsilon (Default: very small number)
  3333. * @returns true if they are equal
  3334. */
  3335. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3336. /**
  3337. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3338. * @param x x value to compare against
  3339. * @param y y value to compare against
  3340. * @param z z value to compare against
  3341. * @param w w value to compare against
  3342. * @returns true if equal
  3343. */
  3344. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3345. /**
  3346. * Multiplies in place the current Vector4 by the given one.
  3347. * @param otherVector vector to multiple with
  3348. * @returns the updated Vector4.
  3349. */
  3350. multiplyInPlace(otherVector: Vector4): Vector4;
  3351. /**
  3352. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns resulting new vector
  3355. */
  3356. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @param result vector to store the result
  3361. * @returns the current Vector4.
  3362. */
  3363. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3364. /**
  3365. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3366. * @param x x value multiply with
  3367. * @param y y value multiply with
  3368. * @param z z value multiply with
  3369. * @param w w value multiply with
  3370. * @returns resulting new vector
  3371. */
  3372. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3373. /**
  3374. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3375. * @param otherVector vector to devide with
  3376. * @returns resulting new vector
  3377. */
  3378. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3379. /**
  3380. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @param result vector to store the result
  3383. * @returns the current Vector4.
  3384. */
  3385. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3386. /**
  3387. * Divides the current Vector3 coordinates by the given ones.
  3388. * @param otherVector vector to devide with
  3389. * @returns the updated Vector3.
  3390. */
  3391. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3392. /**
  3393. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3394. * @param other defines the second operand
  3395. * @returns the current updated Vector4
  3396. */
  3397. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Gets a new Vector4 from current Vector4 floored values
  3406. * @returns a new Vector4
  3407. */
  3408. floor(): Vector4;
  3409. /**
  3410. * Gets a new Vector4 from current Vector3 floored values
  3411. * @returns a new Vector4
  3412. */
  3413. fract(): Vector4;
  3414. /**
  3415. * Returns the Vector4 length (float).
  3416. * @returns the length
  3417. */
  3418. length(): number;
  3419. /**
  3420. * Returns the Vector4 squared length (float).
  3421. * @returns the length squared
  3422. */
  3423. lengthSquared(): number;
  3424. /**
  3425. * Normalizes in place the Vector4.
  3426. * @returns the updated Vector4.
  3427. */
  3428. normalize(): Vector4;
  3429. /**
  3430. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3431. * @returns this converted to a new vector3
  3432. */
  3433. toVector3(): Vector3;
  3434. /**
  3435. * Returns a new Vector4 copied from the current one.
  3436. * @returns the new cloned vector
  3437. */
  3438. clone(): Vector4;
  3439. /**
  3440. * Updates the current Vector4 with the given one coordinates.
  3441. * @param source the source vector to copy from
  3442. * @returns the updated Vector4.
  3443. */
  3444. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the current Vector4 coordinates with the given floats.
  3447. * @param x float to copy from
  3448. * @param y float to copy from
  3449. * @param z float to copy from
  3450. * @param w float to copy from
  3451. * @returns the updated Vector4.
  3452. */
  3453. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3454. /**
  3455. * Updates the current Vector4 coordinates with the given floats.
  3456. * @param x float to set from
  3457. * @param y float to set from
  3458. * @param z float to set from
  3459. * @param w float to set from
  3460. * @returns the updated Vector4.
  3461. */
  3462. set(x: number, y: number, z: number, w: number): Vector4;
  3463. /**
  3464. * Copies the given float to the current Vector3 coordinates
  3465. * @param v defines the x, y, z and w coordinates of the operand
  3466. * @returns the current updated Vector3
  3467. */
  3468. setAll(v: number): Vector4;
  3469. /**
  3470. * Returns a new Vector4 set from the starting index of the given array.
  3471. * @param array the array to pull values from
  3472. * @param offset the offset into the array to start at
  3473. * @returns the new vector
  3474. */
  3475. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3476. /**
  3477. * Updates the given vector "result" from the starting index of the given array.
  3478. * @param array the array to pull values from
  3479. * @param offset the offset into the array to start at
  3480. * @param result the vector to store the result in
  3481. */
  3482. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3483. /**
  3484. * Updates the given vector "result" from the starting index of the given Float32Array.
  3485. * @param array the array to pull values from
  3486. * @param offset the offset into the array to start at
  3487. * @param result the vector to store the result in
  3488. */
  3489. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3490. /**
  3491. * Updates the given vector "result" coordinates from the given floats.
  3492. * @param x float to set from
  3493. * @param y float to set from
  3494. * @param z float to set from
  3495. * @param w float to set from
  3496. * @param result the vector to the floats in
  3497. */
  3498. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3499. /**
  3500. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3501. * @returns the new vector
  3502. */
  3503. static Zero(): Vector4;
  3504. /**
  3505. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3506. * @returns the new vector
  3507. */
  3508. static One(): Vector4;
  3509. /**
  3510. * Returns a new normalized Vector4 from the given one.
  3511. * @param vector the vector to normalize
  3512. * @returns the vector
  3513. */
  3514. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Updates the given vector "result" from the normalization of the given one.
  3517. * @param vector the vector to normalize
  3518. * @param result the vector to store the result in
  3519. */
  3520. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3521. /**
  3522. * Returns a vector with the minimum values from the left and right vectors
  3523. * @param left left vector to minimize
  3524. * @param right right vector to minimize
  3525. * @returns a new vector with the minimum of the left and right vector values
  3526. */
  3527. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3528. /**
  3529. * Returns a vector with the maximum values from the left and right vectors
  3530. * @param left left vector to maximize
  3531. * @param right right vector to maximize
  3532. * @returns a new vector with the maximum of the left and right vector values
  3533. */
  3534. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3535. /**
  3536. * Returns the distance (float) between the vectors "value1" and "value2".
  3537. * @param value1 value to calulate the distance between
  3538. * @param value2 value to calulate the distance between
  3539. * @return the distance between the two vectors
  3540. */
  3541. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3542. /**
  3543. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3544. * @param value1 value to calulate the distance between
  3545. * @param value2 value to calulate the distance between
  3546. * @return the distance between the two vectors squared
  3547. */
  3548. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3549. /**
  3550. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3551. * @param value1 value to calulate the center between
  3552. * @param value2 value to calulate the center between
  3553. * @return the center between the two vectors
  3554. */
  3555. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3558. * This methods computes transformed normalized direction vectors only.
  3559. * @param vector the vector to transform
  3560. * @param transformation the transformation matrix to apply
  3561. * @returns the new vector
  3562. */
  3563. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3564. /**
  3565. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3566. * This methods computes transformed normalized direction vectors only.
  3567. * @param vector the vector to transform
  3568. * @param transformation the transformation matrix to apply
  3569. * @param result the vector to store the result in
  3570. */
  3571. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3572. /**
  3573. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3574. * This methods computes transformed normalized direction vectors only.
  3575. * @param x value to transform
  3576. * @param y value to transform
  3577. * @param z value to transform
  3578. * @param w value to transform
  3579. * @param transformation the transformation matrix to apply
  3580. * @param result the vector to store the results in
  3581. */
  3582. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3583. /**
  3584. * Creates a new Vector4 from a Vector3
  3585. * @param source defines the source data
  3586. * @param w defines the 4th component (default is 0)
  3587. * @returns a new Vector4
  3588. */
  3589. static FromVector3(source: Vector3, w?: number): Vector4;
  3590. }
  3591. /**
  3592. * Class used to store quaternion data
  3593. * @see https://en.wikipedia.org/wiki/Quaternion
  3594. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3595. */
  3596. export class Quaternion {
  3597. /** @hidden */
  3598. _x: number;
  3599. /** @hidden */
  3600. _y: number;
  3601. /** @hidden */
  3602. _z: number;
  3603. /** @hidden */
  3604. _w: number;
  3605. /** @hidden */
  3606. _isDirty: boolean;
  3607. /** Gets or sets the x coordinate */
  3608. get x(): number;
  3609. set x(value: number);
  3610. /** Gets or sets the y coordinate */
  3611. get y(): number;
  3612. set y(value: number);
  3613. /** Gets or sets the z coordinate */
  3614. get z(): number;
  3615. set z(value: number);
  3616. /** Gets or sets the w coordinate */
  3617. get w(): number;
  3618. set w(value: number);
  3619. /**
  3620. * Creates a new Quaternion from the given floats
  3621. * @param x defines the first component (0 by default)
  3622. * @param y defines the second component (0 by default)
  3623. * @param z defines the third component (0 by default)
  3624. * @param w defines the fourth component (1.0 by default)
  3625. */
  3626. constructor(x?: number, y?: number, z?: number, w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * 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)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * 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
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. 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;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. 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;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * 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"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * 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".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * 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"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * 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".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * 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.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * 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)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @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
  5064. * @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
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. 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);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. 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;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /**
  7757. * Creates a cube texture from an array of image urls
  7758. * @param files defines an array of image urls
  7759. * @param scene defines the hosting scene
  7760. * @param noMipmap specifies if mip maps are not used
  7761. * @returns a cube texture
  7762. */
  7763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7764. /**
  7765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7766. * @param url defines the url of the prefiltered texture
  7767. * @param scene defines the scene the texture is attached to
  7768. * @param forcedExtension defines the extension of the file if different from the url
  7769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7770. * @return the prefiltered texture
  7771. */
  7772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7773. /**
  7774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7775. * as prefiltered data.
  7776. * @param rootUrl defines the url of the texture or the root name of the six images
  7777. * @param null defines the scene or engine the texture is attached to
  7778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7779. * @param noMipmap defines if mipmaps should be created or not
  7780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7782. * @param onError defines a callback triggered in case of error during load
  7783. * @param format defines the internal format to use for the texture once loaded
  7784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @return the cube texture
  7790. */
  7791. 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);
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7803. */
  7804. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7805. /**
  7806. * Delays loading of the cube texture
  7807. * @param forcedExtension defines the extension to use
  7808. */
  7809. delayLoad(forcedExtension?: string): void;
  7810. /**
  7811. * Returns the reflection texture matrix
  7812. * @returns the reflection texture matrix
  7813. */
  7814. getReflectionTextureMatrix(): Matrix;
  7815. /**
  7816. * Sets the reflection texture matrix
  7817. * @param value Reflection texture matrix
  7818. */
  7819. setReflectionTextureMatrix(value: Matrix): void;
  7820. /**
  7821. * Parses text to create a cube texture
  7822. * @param parsedTexture define the serialized text to read from
  7823. * @param scene defines the hosting scene
  7824. * @param rootUrl defines the root url of the cube texture
  7825. * @returns a cube texture
  7826. */
  7827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7828. /**
  7829. * Makes a clone, or deep copy, of the cube texture
  7830. * @returns a new cube texture
  7831. */
  7832. clone(): CubeTexture;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * 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).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * 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.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets the global Density value.
  7973. * 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.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * 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.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * 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.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * 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.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * 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.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets the highlights Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * 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.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * 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.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * 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.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * 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.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * 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).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * 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).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets the midtones Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * 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.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * 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.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * 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.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * 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.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * 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).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * 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).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets the shadows Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * 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.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * 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.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * 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.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * 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.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /**
  8519. * Defines the kind of connection point for node based material
  8520. */
  8521. export enum NodeMaterialBlockConnectionPointTypes {
  8522. /** Float */
  8523. Float = 1,
  8524. /** Int */
  8525. Int = 2,
  8526. /** Vector2 */
  8527. Vector2 = 4,
  8528. /** Vector3 */
  8529. Vector3 = 8,
  8530. /** Vector4 */
  8531. Vector4 = 16,
  8532. /** Color3 */
  8533. Color3 = 32,
  8534. /** Color4 */
  8535. Color4 = 64,
  8536. /** Matrix */
  8537. Matrix = 128,
  8538. /** Custom object */
  8539. Object = 256,
  8540. /** Detect type based on connection */
  8541. AutoDetect = 1024,
  8542. /** Output type that will be defined by input type */
  8543. BasedOnInput = 2048
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * Enum used to define the target of a block
  8549. */
  8550. export enum NodeMaterialBlockTargets {
  8551. /** Vertex shader */
  8552. Vertex = 1,
  8553. /** Fragment shader */
  8554. Fragment = 2,
  8555. /** Neutral */
  8556. Neutral = 4,
  8557. /** Vertex and Fragment */
  8558. VertexAndFragment = 3
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8564. */
  8565. export enum NodeMaterialBlockConnectionPointMode {
  8566. /** Value is an uniform */
  8567. Uniform = 0,
  8568. /** Value is a mesh attribute */
  8569. Attribute = 1,
  8570. /** Value is a varying between vertex and fragment shaders */
  8571. Varying = 2,
  8572. /** Mode is undefined */
  8573. Undefined = 3
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Enum used to define system values e.g. values automatically provided by the system
  8579. */
  8580. export enum NodeMaterialSystemValues {
  8581. /** World */
  8582. World = 1,
  8583. /** View */
  8584. View = 2,
  8585. /** Projection */
  8586. Projection = 3,
  8587. /** ViewProjection */
  8588. ViewProjection = 4,
  8589. /** WorldView */
  8590. WorldView = 5,
  8591. /** WorldViewProjection */
  8592. WorldViewProjection = 6,
  8593. /** CameraPosition */
  8594. CameraPosition = 7,
  8595. /** Fog Color */
  8596. FogColor = 8,
  8597. /** Delta time */
  8598. DeltaTime = 9
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Represents a camera frustum
  8624. */
  8625. export class Frustum {
  8626. /**
  8627. * Gets the planes representing the frustum
  8628. * @param transform matrix to be applied to the returned planes
  8629. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8630. */
  8631. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8632. /**
  8633. * Gets the near frustum plane transformed by the transform matrix
  8634. * @param transform transformation matrix to be applied to the resulting frustum plane
  8635. * @param frustumPlane the resuling frustum plane
  8636. */
  8637. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8638. /**
  8639. * Gets the far frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the left frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the right frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the top frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the bottom frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8670. * @param transform transformation matrix to be applied to the resulting frustum planes
  8671. * @param frustumPlanes the resuling frustum planes
  8672. */
  8673. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Interface for the size containing width and height
  8679. */
  8680. export interface ISize {
  8681. /**
  8682. * Width
  8683. */
  8684. width: number;
  8685. /**
  8686. * Heighht
  8687. */
  8688. height: number;
  8689. }
  8690. /**
  8691. * Size containing widht and height
  8692. */
  8693. export class Size implements ISize {
  8694. /**
  8695. * Width
  8696. */
  8697. width: number;
  8698. /**
  8699. * Height
  8700. */
  8701. height: number;
  8702. /**
  8703. * Creates a Size object from the given width and height (floats).
  8704. * @param width width of the new size
  8705. * @param height height of the new size
  8706. */
  8707. constructor(width: number, height: number);
  8708. /**
  8709. * Returns a string with the Size width and height
  8710. * @returns a string with the Size width and height
  8711. */
  8712. toString(): string;
  8713. /**
  8714. * "Size"
  8715. * @returns the string "Size"
  8716. */
  8717. getClassName(): string;
  8718. /**
  8719. * Returns the Size hash code.
  8720. * @returns a hash code for a unique width and height
  8721. */
  8722. getHashCode(): number;
  8723. /**
  8724. * Updates the current size from the given one.
  8725. * @param src the given size
  8726. */
  8727. copyFrom(src: Size): void;
  8728. /**
  8729. * Updates in place the current Size from the given floats.
  8730. * @param width width of the new size
  8731. * @param height height of the new size
  8732. * @returns the updated Size.
  8733. */
  8734. copyFromFloats(width: number, height: number): Size;
  8735. /**
  8736. * Updates in place the current Size from the given floats.
  8737. * @param width width to set
  8738. * @param height height to set
  8739. * @returns the updated Size.
  8740. */
  8741. set(width: number, height: number): Size;
  8742. /**
  8743. * Multiplies the width and height by numbers
  8744. * @param w factor to multiple the width by
  8745. * @param h factor to multiple the height by
  8746. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8747. */
  8748. multiplyByFloats(w: number, h: number): Size;
  8749. /**
  8750. * Clones the size
  8751. * @returns a new Size copied from the given one.
  8752. */
  8753. clone(): Size;
  8754. /**
  8755. * True if the current Size and the given one width and height are strictly equal.
  8756. * @param other the other size to compare against
  8757. * @returns True if the current Size and the given one width and height are strictly equal.
  8758. */
  8759. equals(other: Size): boolean;
  8760. /**
  8761. * The surface of the Size : width * height (float).
  8762. */
  8763. get surface(): number;
  8764. /**
  8765. * Create a new size of zero
  8766. * @returns a new Size set to (0.0, 0.0)
  8767. */
  8768. static Zero(): Size;
  8769. /**
  8770. * Sums the width and height of two sizes
  8771. * @param otherSize size to add to this size
  8772. * @returns a new Size set as the addition result of the current Size and the given one.
  8773. */
  8774. add(otherSize: Size): Size;
  8775. /**
  8776. * Subtracts the width and height of two
  8777. * @param otherSize size to subtract to this size
  8778. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8779. */
  8780. subtract(otherSize: Size): Size;
  8781. /**
  8782. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8783. * @param start starting size to lerp between
  8784. * @param end end size to lerp between
  8785. * @param amount amount to lerp between the start and end values
  8786. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8787. */
  8788. static Lerp(start: Size, end: Size, amount: number): Size;
  8789. }
  8790. }
  8791. declare module BABYLON {
  8792. /**
  8793. * Contains position and normal vectors for a vertex
  8794. */
  8795. export class PositionNormalVertex {
  8796. /** the position of the vertex (defaut: 0,0,0) */
  8797. position: Vector3;
  8798. /** the normal of the vertex (defaut: 0,1,0) */
  8799. normal: Vector3;
  8800. /**
  8801. * Creates a PositionNormalVertex
  8802. * @param position the position of the vertex (defaut: 0,0,0)
  8803. * @param normal the normal of the vertex (defaut: 0,1,0)
  8804. */
  8805. constructor(
  8806. /** the position of the vertex (defaut: 0,0,0) */
  8807. position?: Vector3,
  8808. /** the normal of the vertex (defaut: 0,1,0) */
  8809. normal?: Vector3);
  8810. /**
  8811. * Clones the PositionNormalVertex
  8812. * @returns the cloned PositionNormalVertex
  8813. */
  8814. clone(): PositionNormalVertex;
  8815. }
  8816. /**
  8817. * Contains position, normal and uv vectors for a vertex
  8818. */
  8819. export class PositionNormalTextureVertex {
  8820. /** the position of the vertex (defaut: 0,0,0) */
  8821. position: Vector3;
  8822. /** the normal of the vertex (defaut: 0,1,0) */
  8823. normal: Vector3;
  8824. /** the uv of the vertex (default: 0,0) */
  8825. uv: Vector2;
  8826. /**
  8827. * Creates a PositionNormalTextureVertex
  8828. * @param position the position of the vertex (defaut: 0,0,0)
  8829. * @param normal the normal of the vertex (defaut: 0,1,0)
  8830. * @param uv the uv of the vertex (default: 0,0)
  8831. */
  8832. constructor(
  8833. /** the position of the vertex (defaut: 0,0,0) */
  8834. position?: Vector3,
  8835. /** the normal of the vertex (defaut: 0,1,0) */
  8836. normal?: Vector3,
  8837. /** the uv of the vertex (default: 0,0) */
  8838. uv?: Vector2);
  8839. /**
  8840. * Clones the PositionNormalTextureVertex
  8841. * @returns the cloned PositionNormalTextureVertex
  8842. */
  8843. clone(): PositionNormalTextureVertex;
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Enum defining the type of animations supported by InputBlock
  8849. */
  8850. export enum AnimatedInputBlockTypes {
  8851. /** No animation */
  8852. None = 0,
  8853. /** Time based animation. Will only work for floats */
  8854. Time = 1
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * Interface describing all the common properties and methods a shadow light needs to implement.
  8860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8861. * as well as binding the different shadow properties to the effects.
  8862. */
  8863. export interface IShadowLight extends Light {
  8864. /**
  8865. * The light id in the scene (used in scene.findLighById for instance)
  8866. */
  8867. id: string;
  8868. /**
  8869. * The position the shdow will be casted from.
  8870. */
  8871. position: Vector3;
  8872. /**
  8873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8874. */
  8875. direction: Vector3;
  8876. /**
  8877. * The transformed position. Position of the light in world space taking parenting in account.
  8878. */
  8879. transformedPosition: Vector3;
  8880. /**
  8881. * The transformed direction. Direction of the light in world space taking parenting in account.
  8882. */
  8883. transformedDirection: Vector3;
  8884. /**
  8885. * The friendly name of the light in the scene.
  8886. */
  8887. name: string;
  8888. /**
  8889. * Defines the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. /**
  8893. * Defines the shadow projection clipping maximum z value.
  8894. */
  8895. shadowMaxZ: number;
  8896. /**
  8897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8899. */
  8900. computeTransformedInformation(): boolean;
  8901. /**
  8902. * Gets the scene the light belongs to.
  8903. * @returns The scene
  8904. */
  8905. getScene(): Scene;
  8906. /**
  8907. * Callback defining a custom Projection Matrix Builder.
  8908. * This can be used to override the default projection matrix computation.
  8909. */
  8910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. /**
  8920. * Gets the current depth scale used in ESM.
  8921. * @returns The scale
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /**
  8939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8942. */
  8943. getShadowDirection(faceIndex?: number): Vector3;
  8944. /**
  8945. * Gets the minZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the min for
  8947. * @returns the depth min z
  8948. */
  8949. getDepthMinZ(activeCamera: Camera): number;
  8950. /**
  8951. * Gets the maxZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the max for
  8953. * @returns the depth max z
  8954. */
  8955. getDepthMaxZ(activeCamera: Camera): number;
  8956. }
  8957. /**
  8958. * Base implementation IShadowLight
  8959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8960. */
  8961. export abstract class ShadowLight extends Light implements IShadowLight {
  8962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8963. protected _position: Vector3;
  8964. protected _setPosition(value: Vector3): void;
  8965. /**
  8966. * Sets the position the shadow will be casted from. Also use as the light position for both
  8967. * point and spot lights.
  8968. */
  8969. get position(): Vector3;
  8970. /**
  8971. * Sets the position the shadow will be casted from. Also use as the light position for both
  8972. * point and spot lights.
  8973. */
  8974. set position(value: Vector3);
  8975. protected _direction: Vector3;
  8976. protected _setDirection(value: Vector3): void;
  8977. /**
  8978. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8979. * Also use as the light direction on spot and directional lights.
  8980. */
  8981. get direction(): Vector3;
  8982. /**
  8983. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8984. * Also use as the light direction on spot and directional lights.
  8985. */
  8986. set direction(value: Vector3);
  8987. protected _shadowMinZ: number;
  8988. /**
  8989. * Gets the shadow projection clipping minimum z value.
  8990. */
  8991. get shadowMinZ(): number;
  8992. /**
  8993. * Sets the shadow projection clipping minimum z value.
  8994. */
  8995. set shadowMinZ(value: number);
  8996. protected _shadowMaxZ: number;
  8997. /**
  8998. * Sets the shadow projection clipping maximum z value.
  8999. */
  9000. get shadowMaxZ(): number;
  9001. /**
  9002. * Gets the shadow projection clipping maximum z value.
  9003. */
  9004. set shadowMaxZ(value: number);
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * The transformed position. Position of the light in world space taking parenting in account.
  9012. */
  9013. transformedPosition: Vector3;
  9014. /**
  9015. * The transformed direction. Direction of the light in world space taking parenting in account.
  9016. */
  9017. transformedDirection: Vector3;
  9018. private _needProjectionMatrixCompute;
  9019. /**
  9020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9022. */
  9023. computeTransformedInformation(): boolean;
  9024. /**
  9025. * Return the depth scale used for the shadow map.
  9026. * @returns the depth scale.
  9027. */
  9028. getDepthScale(): number;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Returns the ShadowLight absolute position in the World.
  9037. * @returns the position vector in world space
  9038. */
  9039. getAbsolutePosition(): Vector3;
  9040. /**
  9041. * Sets the ShadowLight direction toward the passed target.
  9042. * @param target The point to target in local space
  9043. * @returns the updated ShadowLight direction
  9044. */
  9045. setDirectionToTarget(target: Vector3): Vector3;
  9046. /**
  9047. * Returns the light rotation in euler definition.
  9048. * @returns the x y z rotation in local space.
  9049. */
  9050. getRotation(): Vector3;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /** @hidden */
  9066. _initCache(): void;
  9067. /** @hidden */
  9068. _isSynchronized(): boolean;
  9069. /**
  9070. * Computes the world matrix of the node
  9071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9072. * @returns the world matrix
  9073. */
  9074. computeWorldMatrix(force?: boolean): Matrix;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. /**
  9088. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9089. * @param matrix The materix to updated with the projection information
  9090. * @param viewMatrix The transform matrix of the light
  9091. * @param renderList The list of mesh to render in the map
  9092. * @returns The current light
  9093. */
  9094. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var packingFunctions: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var bayerDitherFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var shadowMapFragmentDeclaration: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var clipPlaneFragmentDeclaration: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var clipPlaneFragment: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapFragment: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var shadowMapVertexDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var clipPlaneVertexDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexNormalBias: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapVertexMetric: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var clipPlaneVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var shadowMapVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var depthBoxBlurPixelShader: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapFragmentSoftTransparentShadow: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /**
  9260. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9261. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9262. */
  9263. export class EffectFallbacks implements IEffectFallbacks {
  9264. private _defines;
  9265. private _currentRank;
  9266. private _maxRank;
  9267. private _mesh;
  9268. /**
  9269. * Removes the fallback from the bound mesh.
  9270. */
  9271. unBindMesh(): void;
  9272. /**
  9273. * Adds a fallback on the specified property.
  9274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9275. * @param define The name of the define in the shader
  9276. */
  9277. addFallback(rank: number, define: string): void;
  9278. /**
  9279. * Sets the mesh to use CPU skinning when needing to fallback.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param mesh The mesh to use the fallbacks.
  9282. */
  9283. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9284. /**
  9285. * Checks to see if more fallbacks are still availible.
  9286. */
  9287. get hasMoreFallbacks(): boolean;
  9288. /**
  9289. * Removes the defines that should be removed when falling back.
  9290. * @param currentDefines defines the current define statements for the shader.
  9291. * @param effect defines the current effect we try to compile
  9292. * @returns The resulting defines with defines of the current rank removed.
  9293. */
  9294. reduce(currentDefines: string, effect: Effect): string;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /**
  9299. * Interface used to define Action
  9300. */
  9301. export interface IAction {
  9302. /**
  9303. * Trigger for the action
  9304. */
  9305. trigger: number;
  9306. /** Options of the trigger */
  9307. triggerOptions: any;
  9308. /**
  9309. * Gets the trigger parameters
  9310. * @returns the trigger parameters
  9311. */
  9312. getTriggerParameter(): any;
  9313. /**
  9314. * Internal only - executes current action event
  9315. * @hidden
  9316. */
  9317. _executeCurrent(evt?: ActionEvent): void;
  9318. /**
  9319. * Serialize placeholder for child classes
  9320. * @param parent of child
  9321. * @returns the serialized object
  9322. */
  9323. serialize(parent: any): any;
  9324. /**
  9325. * Internal only
  9326. * @hidden
  9327. */
  9328. _prepare(): void;
  9329. /**
  9330. * Internal only - manager for action
  9331. * @hidden
  9332. */
  9333. _actionManager: AbstractActionManager;
  9334. /**
  9335. * Adds action to chain of actions, may be a DoNothingAction
  9336. * @param action defines the next action to execute
  9337. * @returns The action passed in
  9338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9339. */
  9340. then(action: IAction): IAction;
  9341. }
  9342. /**
  9343. * The action to be carried out following a trigger
  9344. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9345. */
  9346. export class Action implements IAction {
  9347. /** the trigger, with or without parameters, for the action */
  9348. triggerOptions: any;
  9349. /**
  9350. * Trigger for the action
  9351. */
  9352. trigger: number;
  9353. /**
  9354. * Internal only - manager for action
  9355. * @hidden
  9356. */
  9357. _actionManager: ActionManager;
  9358. private _nextActiveAction;
  9359. private _child;
  9360. private _condition?;
  9361. private _triggerParameter;
  9362. /**
  9363. * An event triggered prior to action being executed.
  9364. */
  9365. onBeforeExecuteObservable: Observable<Action>;
  9366. /**
  9367. * Creates a new Action
  9368. * @param triggerOptions the trigger, with or without parameters, for the action
  9369. * @param condition an optional determinant of action
  9370. */
  9371. constructor(
  9372. /** the trigger, with or without parameters, for the action */
  9373. triggerOptions: any, condition?: Condition);
  9374. /**
  9375. * Internal only
  9376. * @hidden
  9377. */
  9378. _prepare(): void;
  9379. /**
  9380. * Gets the trigger parameters
  9381. * @returns the trigger parameters
  9382. */
  9383. getTriggerParameter(): any;
  9384. /**
  9385. * Internal only - executes current action event
  9386. * @hidden
  9387. */
  9388. _executeCurrent(evt?: ActionEvent): void;
  9389. /**
  9390. * Execute placeholder for child classes
  9391. * @param evt optional action event
  9392. */
  9393. execute(evt?: ActionEvent): void;
  9394. /**
  9395. * Skips to next active action
  9396. */
  9397. skipToNextActiveAction(): void;
  9398. /**
  9399. * Adds action to chain of actions, may be a DoNothingAction
  9400. * @param action defines the next action to execute
  9401. * @returns The action passed in
  9402. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9403. */
  9404. then(action: Action): Action;
  9405. /**
  9406. * Internal only
  9407. * @hidden
  9408. */
  9409. _getProperty(propertyPath: string): string;
  9410. /**
  9411. * Internal only
  9412. * @hidden
  9413. */
  9414. _getEffectiveTarget(target: any, propertyPath: string): any;
  9415. /**
  9416. * Serialize placeholder for child classes
  9417. * @param parent of child
  9418. * @returns the serialized object
  9419. */
  9420. serialize(parent: any): any;
  9421. /**
  9422. * Internal only called by serialize
  9423. * @hidden
  9424. */
  9425. protected _serialize(serializedAction: any, parent?: any): any;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. static _SerializeValueAsString: (value: any) => string;
  9431. /**
  9432. * Internal only
  9433. * @hidden
  9434. */
  9435. static _GetTargetProperty: (target: Scene | Node) => {
  9436. name: string;
  9437. targetType: string;
  9438. value: string;
  9439. };
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * A Condition applied to an Action
  9445. */
  9446. export class Condition {
  9447. /**
  9448. * Internal only - manager for action
  9449. * @hidden
  9450. */
  9451. _actionManager: ActionManager;
  9452. /**
  9453. * Internal only
  9454. * @hidden
  9455. */
  9456. _evaluationId: number;
  9457. /**
  9458. * Internal only
  9459. * @hidden
  9460. */
  9461. _currentResult: boolean;
  9462. /**
  9463. * Creates a new Condition
  9464. * @param actionManager the manager of the action the condition is applied to
  9465. */
  9466. constructor(actionManager: ActionManager);
  9467. /**
  9468. * Check if the current condition is valid
  9469. * @returns a boolean
  9470. */
  9471. isValid(): boolean;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _getProperty(propertyPath: string): string;
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _getEffectiveTarget(target: any, propertyPath: string): any;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @returns the serialized object
  9485. */
  9486. serialize(): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. protected _serialize(serializedCondition: any): any;
  9492. }
  9493. /**
  9494. * Defines specific conditional operators as extensions of Condition
  9495. */
  9496. export class ValueCondition extends Condition {
  9497. /** path to specify the property of the target the conditional operator uses */
  9498. propertyPath: string;
  9499. /** the value compared by the conditional operator against the current value of the property */
  9500. value: any;
  9501. /** the conditional operator, default ValueCondition.IsEqual */
  9502. operator: number;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. private static _IsEqual;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. private static _IsDifferent;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. private static _IsGreater;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. private static _IsLesser;
  9523. /**
  9524. * returns the number for IsEqual
  9525. */
  9526. static get IsEqual(): number;
  9527. /**
  9528. * Returns the number for IsDifferent
  9529. */
  9530. static get IsDifferent(): number;
  9531. /**
  9532. * Returns the number for IsGreater
  9533. */
  9534. static get IsGreater(): number;
  9535. /**
  9536. * Returns the number for IsLesser
  9537. */
  9538. static get IsLesser(): number;
  9539. /**
  9540. * Internal only The action manager for the condition
  9541. * @hidden
  9542. */
  9543. _actionManager: ActionManager;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. private _target;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. private _effectiveTarget;
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. private _property;
  9559. /**
  9560. * Creates a new ValueCondition
  9561. * @param actionManager manager for the action the condition applies to
  9562. * @param target for the action
  9563. * @param propertyPath path to specify the property of the target the conditional operator uses
  9564. * @param value the value compared by the conditional operator against the current value of the property
  9565. * @param operator the conditional operator, default ValueCondition.IsEqual
  9566. */
  9567. constructor(actionManager: ActionManager, target: any,
  9568. /** path to specify the property of the target the conditional operator uses */
  9569. propertyPath: string,
  9570. /** the value compared by the conditional operator against the current value of the property */
  9571. value: any,
  9572. /** the conditional operator, default ValueCondition.IsEqual */
  9573. operator?: number);
  9574. /**
  9575. * Compares the given value with the property value for the specified conditional operator
  9576. * @returns the result of the comparison
  9577. */
  9578. isValid(): boolean;
  9579. /**
  9580. * Serialize the ValueCondition into a JSON compatible object
  9581. * @returns serialization object
  9582. */
  9583. serialize(): any;
  9584. /**
  9585. * Gets the name of the conditional operator for the ValueCondition
  9586. * @param operator the conditional operator
  9587. * @returns the name
  9588. */
  9589. static GetOperatorName(operator: number): string;
  9590. }
  9591. /**
  9592. * Defines a predicate condition as an extension of Condition
  9593. */
  9594. export class PredicateCondition extends Condition {
  9595. /** defines the predicate function used to validate the condition */
  9596. predicate: () => boolean;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. /**
  9603. * Creates a new PredicateCondition
  9604. * @param actionManager manager for the action the condition applies to
  9605. * @param predicate defines the predicate function used to validate the condition
  9606. */
  9607. constructor(actionManager: ActionManager,
  9608. /** defines the predicate function used to validate the condition */
  9609. predicate: () => boolean);
  9610. /**
  9611. * @returns the validity of the predicate condition
  9612. */
  9613. isValid(): boolean;
  9614. }
  9615. /**
  9616. * Defines a state condition as an extension of Condition
  9617. */
  9618. export class StateCondition extends Condition {
  9619. /** Value to compare with target state */
  9620. value: string;
  9621. /**
  9622. * Internal only - manager for action
  9623. * @hidden
  9624. */
  9625. _actionManager: ActionManager;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. private _target;
  9631. /**
  9632. * Creates a new StateCondition
  9633. * @param actionManager manager for the action the condition applies to
  9634. * @param target of the condition
  9635. * @param value to compare with target state
  9636. */
  9637. constructor(actionManager: ActionManager, target: any,
  9638. /** Value to compare with target state */
  9639. value: string);
  9640. /**
  9641. * Gets a boolean indicating if the current condition is met
  9642. * @returns the validity of the state
  9643. */
  9644. isValid(): boolean;
  9645. /**
  9646. * Serialize the StateCondition into a JSON compatible object
  9647. * @returns serialization object
  9648. */
  9649. serialize(): any;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. /**
  9654. * This defines an action responsible to toggle a boolean once triggered.
  9655. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9656. */
  9657. export class SwitchBooleanAction extends Action {
  9658. /**
  9659. * The path to the boolean property in the target object
  9660. */
  9661. propertyPath: string;
  9662. private _target;
  9663. private _effectiveTarget;
  9664. private _property;
  9665. /**
  9666. * Instantiate the action
  9667. * @param triggerOptions defines the trigger options
  9668. * @param target defines the object containing the boolean
  9669. * @param propertyPath defines the path to the boolean property in the target object
  9670. * @param condition defines the trigger related conditions
  9671. */
  9672. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9673. /** @hidden */
  9674. _prepare(): void;
  9675. /**
  9676. * Execute the action toggle the boolean value.
  9677. */
  9678. execute(): void;
  9679. /**
  9680. * Serializes the actions and its related information.
  9681. * @param parent defines the object to serialize in
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. }
  9686. /**
  9687. * This defines an action responsible to set a the state field of the target
  9688. * to a desired value once triggered.
  9689. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9690. */
  9691. export class SetStateAction extends Action {
  9692. /**
  9693. * The value to store in the state field.
  9694. */
  9695. value: string;
  9696. private _target;
  9697. /**
  9698. * Instantiate the action
  9699. * @param triggerOptions defines the trigger options
  9700. * @param target defines the object containing the state property
  9701. * @param value defines the value to store in the state field
  9702. * @param condition defines the trigger related conditions
  9703. */
  9704. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9705. /**
  9706. * Execute the action and store the value on the target state property.
  9707. */
  9708. execute(): void;
  9709. /**
  9710. * Serializes the actions and its related information.
  9711. * @param parent defines the object to serialize in
  9712. * @returns the serialized object
  9713. */
  9714. serialize(parent: any): any;
  9715. }
  9716. /**
  9717. * This defines an action responsible to set a property of the target
  9718. * to a desired value once triggered.
  9719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9720. */
  9721. export class SetValueAction extends Action {
  9722. /**
  9723. * The path of the property to set in the target.
  9724. */
  9725. propertyPath: string;
  9726. /**
  9727. * The value to set in the property
  9728. */
  9729. value: any;
  9730. private _target;
  9731. private _effectiveTarget;
  9732. private _property;
  9733. /**
  9734. * Instantiate the action
  9735. * @param triggerOptions defines the trigger options
  9736. * @param target defines the object containing the property
  9737. * @param propertyPath defines the path of the property to set in the target
  9738. * @param value defines the value to set in the property
  9739. * @param condition defines the trigger related conditions
  9740. */
  9741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9742. /** @hidden */
  9743. _prepare(): void;
  9744. /**
  9745. * Execute the action and set the targetted property to the desired value.
  9746. */
  9747. execute(): void;
  9748. /**
  9749. * Serializes the actions and its related information.
  9750. * @param parent defines the object to serialize in
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. }
  9755. /**
  9756. * This defines an action responsible to increment the target value
  9757. * to a desired value once triggered.
  9758. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class IncrementValueAction extends Action {
  9761. /**
  9762. * The path of the property to increment in the target.
  9763. */
  9764. propertyPath: string;
  9765. /**
  9766. * The value we should increment the property by.
  9767. */
  9768. value: any;
  9769. private _target;
  9770. private _effectiveTarget;
  9771. private _property;
  9772. /**
  9773. * Instantiate the action
  9774. * @param triggerOptions defines the trigger options
  9775. * @param target defines the object containing the property
  9776. * @param propertyPath defines the path of the property to increment in the target
  9777. * @param value defines the value value we should increment the property by
  9778. * @param condition defines the trigger related conditions
  9779. */
  9780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9781. /** @hidden */
  9782. _prepare(): void;
  9783. /**
  9784. * Execute the action and increment the target of the value amount.
  9785. */
  9786. execute(): void;
  9787. /**
  9788. * Serializes the actions and its related information.
  9789. * @param parent defines the object to serialize in
  9790. * @returns the serialized object
  9791. */
  9792. serialize(parent: any): any;
  9793. }
  9794. /**
  9795. * This defines an action responsible to start an animation once triggered.
  9796. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9797. */
  9798. export class PlayAnimationAction extends Action {
  9799. /**
  9800. * Where the animation should start (animation frame)
  9801. */
  9802. from: number;
  9803. /**
  9804. * Where the animation should stop (animation frame)
  9805. */
  9806. to: number;
  9807. /**
  9808. * Define if the animation should loop or stop after the first play.
  9809. */
  9810. loop?: boolean;
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param from defines from where the animation should start (animation frame)
  9817. * @param end defines where the animation should stop (animation frame)
  9818. * @param loop defines if the animation should loop or stop after the first play
  9819. * @param condition defines the trigger related conditions
  9820. */
  9821. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9822. /** @hidden */
  9823. _prepare(): void;
  9824. /**
  9825. * Execute the action and play the animation.
  9826. */
  9827. execute(): void;
  9828. /**
  9829. * Serializes the actions and its related information.
  9830. * @param parent defines the object to serialize in
  9831. * @returns the serialized object
  9832. */
  9833. serialize(parent: any): any;
  9834. }
  9835. /**
  9836. * This defines an action responsible to stop an animation once triggered.
  9837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class StopAnimationAction extends Action {
  9840. private _target;
  9841. /**
  9842. * Instantiate the action
  9843. * @param triggerOptions defines the trigger options
  9844. * @param target defines the target animation or animation name
  9845. * @param condition defines the trigger related conditions
  9846. */
  9847. constructor(triggerOptions: any, target: any, condition?: Condition);
  9848. /** @hidden */
  9849. _prepare(): void;
  9850. /**
  9851. * Execute the action and stop the animation.
  9852. */
  9853. execute(): void;
  9854. /**
  9855. * Serializes the actions and its related information.
  9856. * @param parent defines the object to serialize in
  9857. * @returns the serialized object
  9858. */
  9859. serialize(parent: any): any;
  9860. }
  9861. /**
  9862. * This defines an action responsible that does nothing once triggered.
  9863. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9864. */
  9865. export class DoNothingAction extends Action {
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions?: any, condition?: Condition);
  9872. /**
  9873. * Execute the action and do nothing.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to trigger several actions once triggered.
  9885. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class CombineAction extends Action {
  9888. /**
  9889. * The list of aggregated animations to run.
  9890. */
  9891. children: Action[];
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param children defines the list of aggregated animations to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9899. /** @hidden */
  9900. _prepare(): void;
  9901. /**
  9902. * Execute the action and executes all the aggregated actions.
  9903. */
  9904. execute(evt: ActionEvent): void;
  9905. /**
  9906. * Serializes the actions and its related information.
  9907. * @param parent defines the object to serialize in
  9908. * @returns the serialized object
  9909. */
  9910. serialize(parent: any): any;
  9911. }
  9912. /**
  9913. * This defines an action responsible to run code (external event) once triggered.
  9914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9915. */
  9916. export class ExecuteCodeAction extends Action {
  9917. /**
  9918. * The callback function to run.
  9919. */
  9920. func: (evt: ActionEvent) => void;
  9921. /**
  9922. * Instantiate the action
  9923. * @param triggerOptions defines the trigger options
  9924. * @param func defines the callback function to run
  9925. * @param condition defines the trigger related conditions
  9926. */
  9927. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9928. /**
  9929. * Execute the action and run the attached code.
  9930. */
  9931. execute(evt: ActionEvent): void;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set the parent property of the target once triggered.
  9935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class SetParentAction extends Action {
  9938. private _parent;
  9939. private _target;
  9940. /**
  9941. * Instantiate the action
  9942. * @param triggerOptions defines the trigger options
  9943. * @param target defines the target containing the parent property
  9944. * @param parent defines from where the animation should start (animation frame)
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and set the parent property.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9965. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class ActionManager extends AbstractActionManager {
  9969. /**
  9970. * Nothing
  9971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9972. */
  9973. static readonly NothingTrigger: number;
  9974. /**
  9975. * On pick
  9976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9977. */
  9978. static readonly OnPickTrigger: number;
  9979. /**
  9980. * On left pick
  9981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9982. */
  9983. static readonly OnLeftPickTrigger: number;
  9984. /**
  9985. * On right pick
  9986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9987. */
  9988. static readonly OnRightPickTrigger: number;
  9989. /**
  9990. * On center pick
  9991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9992. */
  9993. static readonly OnCenterPickTrigger: number;
  9994. /**
  9995. * On pick down
  9996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9997. */
  9998. static readonly OnPickDownTrigger: number;
  9999. /**
  10000. * On double pick
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10002. */
  10003. static readonly OnDoublePickTrigger: number;
  10004. /**
  10005. * On pick up
  10006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly OnPickUpTrigger: number;
  10009. /**
  10010. * On pick out.
  10011. * This trigger will only be raised if you also declared a OnPickDown
  10012. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickOutTrigger: number;
  10015. /**
  10016. * On long press
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnLongPressTrigger: number;
  10020. /**
  10021. * On pointer over
  10022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPointerOverTrigger: number;
  10025. /**
  10026. * On pointer out
  10027. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10028. */
  10029. static readonly OnPointerOutTrigger: number;
  10030. /**
  10031. * On every frame
  10032. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10033. */
  10034. static readonly OnEveryFrameTrigger: number;
  10035. /**
  10036. * On intersection enter
  10037. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10038. */
  10039. static readonly OnIntersectionEnterTrigger: number;
  10040. /**
  10041. * On intersection exit
  10042. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10043. */
  10044. static readonly OnIntersectionExitTrigger: number;
  10045. /**
  10046. * On key down
  10047. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnKeyDownTrigger: number;
  10050. /**
  10051. * On key up
  10052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnKeyUpTrigger: number;
  10055. private _scene;
  10056. /**
  10057. * Creates a new action manager
  10058. * @param scene defines the hosting scene
  10059. */
  10060. constructor(scene: Scene);
  10061. /**
  10062. * Releases all associated resources
  10063. */
  10064. dispose(): void;
  10065. /**
  10066. * Gets hosting scene
  10067. * @returns the hosting scene
  10068. */
  10069. getScene(): Scene;
  10070. /**
  10071. * Does this action manager handles actions of any of the given triggers
  10072. * @param triggers defines the triggers to be tested
  10073. * @return a boolean indicating whether one (or more) of the triggers is handled
  10074. */
  10075. hasSpecificTriggers(triggers: number[]): boolean;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10078. * speed.
  10079. * @param triggerA defines the trigger to be tested
  10080. * @param triggerB defines the trigger to be tested
  10081. * @return a boolean indicating whether one (or more) of the triggers is handled
  10082. */
  10083. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10084. /**
  10085. * Does this action manager handles actions of a given trigger
  10086. * @param trigger defines the trigger to be tested
  10087. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10088. * @return whether the trigger is handled
  10089. */
  10090. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10091. /**
  10092. * Does this action manager has pointer triggers
  10093. */
  10094. get hasPointerTriggers(): boolean;
  10095. /**
  10096. * Does this action manager has pick triggers
  10097. */
  10098. get hasPickTriggers(): boolean;
  10099. /**
  10100. * Registers an action to this action manager
  10101. * @param action defines the action to be registered
  10102. * @return the action amended (prepared) after registration
  10103. */
  10104. registerAction(action: IAction): Nullable<IAction>;
  10105. /**
  10106. * Unregisters an action to this action manager
  10107. * @param action defines the action to be unregistered
  10108. * @return a boolean indicating whether the action has been unregistered
  10109. */
  10110. unregisterAction(action: IAction): Boolean;
  10111. /**
  10112. * Process a specific trigger
  10113. * @param trigger defines the trigger to process
  10114. * @param evt defines the event details to be processed
  10115. */
  10116. processTrigger(trigger: number, evt?: IActionEvent): void;
  10117. /** @hidden */
  10118. _getEffectiveTarget(target: any, propertyPath: string): any;
  10119. /** @hidden */
  10120. _getProperty(propertyPath: string): string;
  10121. /**
  10122. * Serialize this manager to a JSON object
  10123. * @param name defines the property name to store this manager
  10124. * @returns a JSON representation of this manager
  10125. */
  10126. serialize(name: string): any;
  10127. /**
  10128. * Creates a new ActionManager from a JSON data
  10129. * @param parsedActions defines the JSON data to read from
  10130. * @param object defines the hosting mesh
  10131. * @param scene defines the hosting scene
  10132. */
  10133. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10134. /**
  10135. * Get a trigger name by index
  10136. * @param trigger defines the trigger index
  10137. * @returns a trigger name
  10138. */
  10139. static GetTriggerName(trigger: number): string;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Class used to represent a sprite
  10145. * @see https://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class Sprite implements IAnimatable {
  10148. /** defines the name */
  10149. name: string;
  10150. /** Gets or sets the current world position */
  10151. position: Vector3;
  10152. /** Gets or sets the main color */
  10153. color: Color4;
  10154. /** Gets or sets the width */
  10155. width: number;
  10156. /** Gets or sets the height */
  10157. height: number;
  10158. /** Gets or sets rotation angle */
  10159. angle: number;
  10160. /** Gets or sets the cell index in the sprite sheet */
  10161. cellIndex: number;
  10162. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10163. cellRef: string;
  10164. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10165. invertU: boolean;
  10166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10167. invertV: boolean;
  10168. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10169. disposeWhenFinishedAnimating: boolean;
  10170. /** Gets the list of attached animations */
  10171. animations: Nullable<Array<Animation>>;
  10172. /** Gets or sets a boolean indicating if the sprite can be picked */
  10173. isPickable: boolean;
  10174. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10175. useAlphaForPicking: boolean;
  10176. /** @hidden */
  10177. _xOffset: number;
  10178. /** @hidden */
  10179. _yOffset: number;
  10180. /** @hidden */
  10181. _xSize: number;
  10182. /** @hidden */
  10183. _ySize: number;
  10184. /**
  10185. * Gets or sets the associated action manager
  10186. */
  10187. actionManager: Nullable<ActionManager>;
  10188. /**
  10189. * An event triggered when the control has been disposed
  10190. */
  10191. onDisposeObservable: Observable<Sprite>;
  10192. private _animationStarted;
  10193. private _loopAnimation;
  10194. private _fromIndex;
  10195. private _toIndex;
  10196. private _delay;
  10197. private _direction;
  10198. private _manager;
  10199. private _time;
  10200. private _onAnimationEnd;
  10201. /**
  10202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10203. */
  10204. isVisible: boolean;
  10205. /**
  10206. * Gets or sets the sprite size
  10207. */
  10208. get size(): number;
  10209. set size(value: number);
  10210. /**
  10211. * Returns a boolean indicating if the animation is started
  10212. */
  10213. get animationStarted(): boolean;
  10214. /**
  10215. * Gets or sets the unique id of the sprite
  10216. */
  10217. uniqueId: number;
  10218. /**
  10219. * Gets the manager of this sprite
  10220. */
  10221. get manager(): ISpriteManager;
  10222. /**
  10223. * Creates a new Sprite
  10224. * @param name defines the name
  10225. * @param manager defines the manager
  10226. */
  10227. constructor(
  10228. /** defines the name */
  10229. name: string, manager: ISpriteManager);
  10230. /**
  10231. * Returns the string "Sprite"
  10232. * @returns "Sprite"
  10233. */
  10234. getClassName(): string;
  10235. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10236. get fromIndex(): number;
  10237. set fromIndex(value: number);
  10238. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10239. get toIndex(): number;
  10240. set toIndex(value: number);
  10241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10242. get loopAnimation(): boolean;
  10243. set loopAnimation(value: boolean);
  10244. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10245. get delay(): number;
  10246. set delay(value: number);
  10247. /**
  10248. * Starts an animation
  10249. * @param from defines the initial key
  10250. * @param to defines the end key
  10251. * @param loop defines if the animation must loop
  10252. * @param delay defines the start delay (in ms)
  10253. * @param onAnimationEnd defines a callback to call when animation ends
  10254. */
  10255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10256. /** Stops current animation (if any) */
  10257. stopAnimation(): void;
  10258. /** @hidden */
  10259. _animate(deltaTime: number): void;
  10260. /** Release associated resources */
  10261. dispose(): void;
  10262. /**
  10263. * Serializes the sprite to a JSON object
  10264. * @returns the JSON object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Parses a JSON object to create a new sprite
  10269. * @param parsedSprite The JSON object to parse
  10270. * @param manager defines the hosting manager
  10271. * @returns the new sprite
  10272. */
  10273. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Information about the result of picking within a scene
  10279. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10280. */
  10281. export class PickingInfo {
  10282. /** @hidden */
  10283. _pickingUnavailable: boolean;
  10284. /**
  10285. * If the pick collided with an object
  10286. */
  10287. hit: boolean;
  10288. /**
  10289. * Distance away where the pick collided
  10290. */
  10291. distance: number;
  10292. /**
  10293. * The location of pick collision
  10294. */
  10295. pickedPoint: Nullable<Vector3>;
  10296. /**
  10297. * The mesh corresponding the the pick collision
  10298. */
  10299. pickedMesh: Nullable<AbstractMesh>;
  10300. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10301. bu: number;
  10302. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10303. bv: number;
  10304. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10305. faceId: number;
  10306. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10307. subMeshFaceId: number;
  10308. /** Id of the the submesh that was picked */
  10309. subMeshId: number;
  10310. /** If a sprite was picked, this will be the sprite the pick collided with */
  10311. pickedSprite: Nullable<Sprite>;
  10312. /**
  10313. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10314. */
  10315. originMesh: Nullable<AbstractMesh>;
  10316. /**
  10317. * The ray that was used to perform the picking.
  10318. */
  10319. ray: Nullable<Ray>;
  10320. /**
  10321. * Gets the normal correspodning to the face the pick collided with
  10322. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10323. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10324. * @returns The normal correspodning to the face the pick collided with
  10325. */
  10326. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10327. /**
  10328. * Gets the texture coordinates of where the pick occured
  10329. * @returns the vector containing the coordnates of the texture
  10330. */
  10331. getTextureCoordinates(): Nullable<Vector2>;
  10332. }
  10333. }
  10334. declare module BABYLON {
  10335. /**
  10336. * Class representing a ray with position and direction
  10337. */
  10338. export class Ray {
  10339. /** origin point */
  10340. origin: Vector3;
  10341. /** direction */
  10342. direction: Vector3;
  10343. /** length of the ray */
  10344. length: number;
  10345. private static readonly TmpVector3;
  10346. private _tmpRay;
  10347. /**
  10348. * Creates a new ray
  10349. * @param origin origin point
  10350. * @param direction direction
  10351. * @param length length of the ray
  10352. */
  10353. constructor(
  10354. /** origin point */
  10355. origin: Vector3,
  10356. /** direction */
  10357. direction: Vector3,
  10358. /** length of the ray */
  10359. length?: number);
  10360. /**
  10361. * Checks if the ray intersects a box
  10362. * This does not account for the ray lenght by design to improve perfs.
  10363. * @param minimum bound of the box
  10364. * @param maximum bound of the box
  10365. * @param intersectionTreshold extra extend to be added to the box in all direction
  10366. * @returns if the box was hit
  10367. */
  10368. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10369. /**
  10370. * Checks if the ray intersects a box
  10371. * This does not account for the ray lenght by design to improve perfs.
  10372. * @param box the bounding box to check
  10373. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10374. * @returns if the box was hit
  10375. */
  10376. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10377. /**
  10378. * If the ray hits a sphere
  10379. * @param sphere the bounding sphere to check
  10380. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10381. * @returns true if it hits the sphere
  10382. */
  10383. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10384. /**
  10385. * If the ray hits a triange
  10386. * @param vertex0 triangle vertex
  10387. * @param vertex1 triangle vertex
  10388. * @param vertex2 triangle vertex
  10389. * @returns intersection information if hit
  10390. */
  10391. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10392. /**
  10393. * Checks if ray intersects a plane
  10394. * @param plane the plane to check
  10395. * @returns the distance away it was hit
  10396. */
  10397. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10398. /**
  10399. * Calculate the intercept of a ray on a given axis
  10400. * @param axis to check 'x' | 'y' | 'z'
  10401. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10402. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10403. */
  10404. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10405. /**
  10406. * Checks if ray intersects a mesh
  10407. * @param mesh the mesh to check
  10408. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10409. * @returns picking info of the intersecton
  10410. */
  10411. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10412. /**
  10413. * Checks if ray intersects a mesh
  10414. * @param meshes the meshes to check
  10415. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10416. * @param results array to store result in
  10417. * @returns Array of picking infos
  10418. */
  10419. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10420. private _comparePickingInfo;
  10421. private static smallnum;
  10422. private static rayl;
  10423. /**
  10424. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10425. * @param sega the first point of the segment to test the intersection against
  10426. * @param segb the second point of the segment to test the intersection against
  10427. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10428. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10429. */
  10430. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10431. /**
  10432. * Update the ray from viewport position
  10433. * @param x position
  10434. * @param y y position
  10435. * @param viewportWidth viewport width
  10436. * @param viewportHeight viewport height
  10437. * @param world world matrix
  10438. * @param view view matrix
  10439. * @param projection projection matrix
  10440. * @returns this ray updated
  10441. */
  10442. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10443. /**
  10444. * Creates a ray with origin and direction of 0,0,0
  10445. * @returns the new ray
  10446. */
  10447. static Zero(): Ray;
  10448. /**
  10449. * Creates a new ray from screen space and viewport
  10450. * @param x position
  10451. * @param y y position
  10452. * @param viewportWidth viewport width
  10453. * @param viewportHeight viewport height
  10454. * @param world world matrix
  10455. * @param view view matrix
  10456. * @param projection projection matrix
  10457. * @returns new ray
  10458. */
  10459. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10460. /**
  10461. * 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
  10462. * transformed to the given world matrix.
  10463. * @param origin The origin point
  10464. * @param end The end point
  10465. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10466. * @returns the new ray
  10467. */
  10468. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10469. /**
  10470. * Transforms a ray by a matrix
  10471. * @param ray ray to transform
  10472. * @param matrix matrix to apply
  10473. * @returns the resulting new ray
  10474. */
  10475. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10476. /**
  10477. * Transforms a ray by a matrix
  10478. * @param ray ray to transform
  10479. * @param matrix matrix to apply
  10480. * @param result ray to store result in
  10481. */
  10482. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10483. /**
  10484. * Unproject a ray from screen space to object space
  10485. * @param sourceX defines the screen space x coordinate to use
  10486. * @param sourceY defines the screen space y coordinate to use
  10487. * @param viewportWidth defines the current width of the viewport
  10488. * @param viewportHeight defines the current height of the viewport
  10489. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10490. * @param view defines the view matrix to use
  10491. * @param projection defines the projection matrix to use
  10492. */
  10493. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10494. }
  10495. /**
  10496. * Type used to define predicate used to select faces when a mesh intersection is detected
  10497. */
  10498. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10499. interface Scene {
  10500. /** @hidden */
  10501. _tempPickingRay: Nullable<Ray>;
  10502. /** @hidden */
  10503. _cachedRayForTransform: Ray;
  10504. /** @hidden */
  10505. _pickWithRayInverseMatrix: Matrix;
  10506. /** @hidden */
  10507. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10508. /** @hidden */
  10509. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10510. }
  10511. }
  10512. declare module BABYLON {
  10513. /**
  10514. * Groups all the scene component constants in one place to ease maintenance.
  10515. * @hidden
  10516. */
  10517. export class SceneComponentConstants {
  10518. static readonly NAME_EFFECTLAYER: string;
  10519. static readonly NAME_LAYER: string;
  10520. static readonly NAME_LENSFLARESYSTEM: string;
  10521. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10522. static readonly NAME_PARTICLESYSTEM: string;
  10523. static readonly NAME_GAMEPAD: string;
  10524. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10525. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10526. static readonly NAME_PREPASSRENDERER: string;
  10527. static readonly NAME_DEPTHRENDERER: string;
  10528. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10529. static readonly NAME_SPRITE: string;
  10530. static readonly NAME_OUTLINERENDERER: string;
  10531. static readonly NAME_PROCEDURALTEXTURE: string;
  10532. static readonly NAME_SHADOWGENERATOR: string;
  10533. static readonly NAME_OCTREE: string;
  10534. static readonly NAME_PHYSICSENGINE: string;
  10535. static readonly NAME_AUDIO: string;
  10536. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10537. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10539. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10540. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10541. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10542. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10543. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10544. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10545. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10546. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10547. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10548. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10549. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10550. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10551. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10552. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10553. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10554. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10555. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10556. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10557. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10558. static readonly STEP_AFTERRENDER_AUDIO: number;
  10559. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10560. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10561. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10562. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10563. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10564. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10565. static readonly STEP_POINTERMOVE_SPRITE: number;
  10566. static readonly STEP_POINTERDOWN_SPRITE: number;
  10567. static readonly STEP_POINTERUP_SPRITE: number;
  10568. }
  10569. /**
  10570. * This represents a scene component.
  10571. *
  10572. * This is used to decouple the dependency the scene is having on the different workloads like
  10573. * layers, post processes...
  10574. */
  10575. export interface ISceneComponent {
  10576. /**
  10577. * The name of the component. Each component must have a unique name.
  10578. */
  10579. name: string;
  10580. /**
  10581. * The scene the component belongs to.
  10582. */
  10583. scene: Scene;
  10584. /**
  10585. * Register the component to one instance of a scene.
  10586. */
  10587. register(): void;
  10588. /**
  10589. * Rebuilds the elements related to this component in case of
  10590. * context lost for instance.
  10591. */
  10592. rebuild(): void;
  10593. /**
  10594. * Disposes the component and the associated ressources.
  10595. */
  10596. dispose(): void;
  10597. }
  10598. /**
  10599. * This represents a SERIALIZABLE scene component.
  10600. *
  10601. * This extends Scene Component to add Serialization methods on top.
  10602. */
  10603. export interface ISceneSerializableComponent extends ISceneComponent {
  10604. /**
  10605. * Adds all the elements from the container to the scene
  10606. * @param container the container holding the elements
  10607. */
  10608. addFromContainer(container: AbstractScene): void;
  10609. /**
  10610. * Removes all the elements in the container from the scene
  10611. * @param container contains the elements to remove
  10612. * @param dispose if the removed element should be disposed (default: false)
  10613. */
  10614. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10615. /**
  10616. * Serializes the component data to the specified json object
  10617. * @param serializationObject The object to serialize to
  10618. */
  10619. serialize(serializationObject: any): void;
  10620. }
  10621. /**
  10622. * Strong typing of a Mesh related stage step action
  10623. */
  10624. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10625. /**
  10626. * Strong typing of a Evaluate Sub Mesh related stage step action
  10627. */
  10628. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10629. /**
  10630. * Strong typing of a Active Mesh related stage step action
  10631. */
  10632. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10633. /**
  10634. * Strong typing of a Camera related stage step action
  10635. */
  10636. export type CameraStageAction = (camera: Camera) => void;
  10637. /**
  10638. * Strong typing of a Camera Frame buffer related stage step action
  10639. */
  10640. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10641. /**
  10642. * Strong typing of a Render Target related stage step action
  10643. */
  10644. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10645. /**
  10646. * Strong typing of a RenderingGroup related stage step action
  10647. */
  10648. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10649. /**
  10650. * Strong typing of a Mesh Render related stage step action
  10651. */
  10652. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10653. /**
  10654. * Strong typing of a simple stage step action
  10655. */
  10656. export type SimpleStageAction = () => void;
  10657. /**
  10658. * Strong typing of a render target action.
  10659. */
  10660. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10661. /**
  10662. * Strong typing of a pointer move action.
  10663. */
  10664. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10665. /**
  10666. * Strong typing of a pointer up/down action.
  10667. */
  10668. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10669. /**
  10670. * Representation of a stage in the scene (Basically a list of ordered steps)
  10671. * @hidden
  10672. */
  10673. export class Stage<T extends Function> extends Array<{
  10674. index: number;
  10675. component: ISceneComponent;
  10676. action: T;
  10677. }> {
  10678. /**
  10679. * Hide ctor from the rest of the world.
  10680. * @param items The items to add.
  10681. */
  10682. private constructor();
  10683. /**
  10684. * Creates a new Stage.
  10685. * @returns A new instance of a Stage
  10686. */
  10687. static Create<T extends Function>(): Stage<T>;
  10688. /**
  10689. * Registers a step in an ordered way in the targeted stage.
  10690. * @param index Defines the position to register the step in
  10691. * @param component Defines the component attached to the step
  10692. * @param action Defines the action to launch during the step
  10693. */
  10694. registerStep(index: number, component: ISceneComponent, action: T): void;
  10695. /**
  10696. * Clears all the steps from the stage.
  10697. */
  10698. clear(): void;
  10699. }
  10700. }
  10701. declare module BABYLON {
  10702. interface Scene {
  10703. /** @hidden */
  10704. _pointerOverSprite: Nullable<Sprite>;
  10705. /** @hidden */
  10706. _pickedDownSprite: Nullable<Sprite>;
  10707. /** @hidden */
  10708. _tempSpritePickingRay: Nullable<Ray>;
  10709. /**
  10710. * All of the sprite managers added to this scene
  10711. * @see https://doc.babylonjs.com/babylon101/sprites
  10712. */
  10713. spriteManagers: Array<ISpriteManager>;
  10714. /**
  10715. * An event triggered when sprites rendering is about to start
  10716. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10717. */
  10718. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10719. /**
  10720. * An event triggered when sprites rendering is done
  10721. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10722. */
  10723. onAfterSpritesRenderingObservable: Observable<Scene>;
  10724. /** @hidden */
  10725. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10726. /** Launch a ray to try to pick a sprite in the scene
  10727. * @param x position on screen
  10728. * @param y position on screen
  10729. * @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
  10730. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10731. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10732. * @returns a PickingInfo
  10733. */
  10734. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10735. /** Use the given ray to pick a sprite in the scene
  10736. * @param ray The ray (in world space) to use to pick meshes
  10737. * @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
  10738. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10739. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10740. * @returns a PickingInfo
  10741. */
  10742. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10743. /** @hidden */
  10744. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10745. /** Launch a ray to try to pick sprites in the scene
  10746. * @param x position on screen
  10747. * @param y position on screen
  10748. * @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
  10749. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10750. * @returns a PickingInfo array
  10751. */
  10752. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10753. /** Use the given ray to pick sprites in the scene
  10754. * @param ray The ray (in world space) to use to pick meshes
  10755. * @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
  10756. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10757. * @returns a PickingInfo array
  10758. */
  10759. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10760. /**
  10761. * Force the sprite under the pointer
  10762. * @param sprite defines the sprite to use
  10763. */
  10764. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10765. /**
  10766. * Gets the sprite under the pointer
  10767. * @returns a Sprite or null if no sprite is under the pointer
  10768. */
  10769. getPointerOverSprite(): Nullable<Sprite>;
  10770. }
  10771. /**
  10772. * Defines the sprite scene component responsible to manage sprites
  10773. * in a given scene.
  10774. */
  10775. export class SpriteSceneComponent implements ISceneComponent {
  10776. /**
  10777. * The component name helpfull to identify the component in the list of scene components.
  10778. */
  10779. readonly name: string;
  10780. /**
  10781. * The scene the component belongs to.
  10782. */
  10783. scene: Scene;
  10784. /** @hidden */
  10785. private _spritePredicate;
  10786. /**
  10787. * Creates a new instance of the component for the given scene
  10788. * @param scene Defines the scene to register the component in
  10789. */
  10790. constructor(scene: Scene);
  10791. /**
  10792. * Registers the component in a given scene
  10793. */
  10794. register(): void;
  10795. /**
  10796. * Rebuilds the elements related to this component in case of
  10797. * context lost for instance.
  10798. */
  10799. rebuild(): void;
  10800. /**
  10801. * Disposes the component and the associated ressources.
  10802. */
  10803. dispose(): void;
  10804. private _pickSpriteButKeepRay;
  10805. private _pointerMove;
  10806. private _pointerDown;
  10807. private _pointerUp;
  10808. }
  10809. }
  10810. declare module BABYLON {
  10811. /** @hidden */
  10812. export var fogFragmentDeclaration: {
  10813. name: string;
  10814. shader: string;
  10815. };
  10816. }
  10817. declare module BABYLON {
  10818. /** @hidden */
  10819. export var fogFragment: {
  10820. name: string;
  10821. shader: string;
  10822. };
  10823. }
  10824. declare module BABYLON {
  10825. /** @hidden */
  10826. export var spritesPixelShader: {
  10827. name: string;
  10828. shader: string;
  10829. };
  10830. }
  10831. declare module BABYLON {
  10832. /** @hidden */
  10833. export var fogVertexDeclaration: {
  10834. name: string;
  10835. shader: string;
  10836. };
  10837. }
  10838. declare module BABYLON {
  10839. /** @hidden */
  10840. export var spritesVertexShader: {
  10841. name: string;
  10842. shader: string;
  10843. };
  10844. }
  10845. declare module BABYLON {
  10846. /**
  10847. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10848. */
  10849. export interface ISpriteManager extends IDisposable {
  10850. /**
  10851. * Gets manager's name
  10852. */
  10853. name: string;
  10854. /**
  10855. * Restricts the camera to viewing objects with the same layerMask.
  10856. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10857. */
  10858. layerMask: number;
  10859. /**
  10860. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10861. */
  10862. isPickable: boolean;
  10863. /**
  10864. * Gets the hosting scene
  10865. */
  10866. scene: Scene;
  10867. /**
  10868. * Specifies the rendering group id for this mesh (0 by default)
  10869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10870. */
  10871. renderingGroupId: number;
  10872. /**
  10873. * Defines the list of sprites managed by the manager.
  10874. */
  10875. sprites: Array<Sprite>;
  10876. /**
  10877. * Gets or sets the spritesheet texture
  10878. */
  10879. texture: Texture;
  10880. /** Defines the default width of a cell in the spritesheet */
  10881. cellWidth: number;
  10882. /** Defines the default height of a cell in the spritesheet */
  10883. cellHeight: number;
  10884. /**
  10885. * Tests the intersection of a sprite with a specific ray.
  10886. * @param ray The ray we are sending to test the collision
  10887. * @param camera The camera space we are sending rays in
  10888. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10889. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10890. * @returns picking info or null.
  10891. */
  10892. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10893. /**
  10894. * Intersects the sprites with a ray
  10895. * @param ray defines the ray to intersect with
  10896. * @param camera defines the current active camera
  10897. * @param predicate defines a predicate used to select candidate sprites
  10898. * @returns null if no hit or a PickingInfo array
  10899. */
  10900. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10901. /**
  10902. * Renders the list of sprites on screen.
  10903. */
  10904. render(): void;
  10905. }
  10906. /**
  10907. * Class used to manage multiple sprites on the same spritesheet
  10908. * @see https://doc.babylonjs.com/babylon101/sprites
  10909. */
  10910. export class SpriteManager implements ISpriteManager {
  10911. /** defines the manager's name */
  10912. name: string;
  10913. /** Define the Url to load snippets */
  10914. static SnippetUrl: string;
  10915. /** Snippet ID if the manager was created from the snippet server */
  10916. snippetId: string;
  10917. /** Gets the list of sprites */
  10918. sprites: Sprite[];
  10919. /** Gets or sets the rendering group id (0 by default) */
  10920. renderingGroupId: number;
  10921. /** Gets or sets camera layer mask */
  10922. layerMask: number;
  10923. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10924. fogEnabled: boolean;
  10925. /** Gets or sets a boolean indicating if the sprites are pickable */
  10926. isPickable: boolean;
  10927. /** Defines the default width of a cell in the spritesheet */
  10928. cellWidth: number;
  10929. /** Defines the default height of a cell in the spritesheet */
  10930. cellHeight: number;
  10931. /** Associative array from JSON sprite data file */
  10932. private _cellData;
  10933. /** Array of sprite names from JSON sprite data file */
  10934. private _spriteMap;
  10935. /** True when packed cell data from JSON file is ready*/
  10936. private _packedAndReady;
  10937. private _textureContent;
  10938. /**
  10939. * An event triggered when the manager is disposed.
  10940. */
  10941. onDisposeObservable: Observable<SpriteManager>;
  10942. private _onDisposeObserver;
  10943. /**
  10944. * Callback called when the manager is disposed
  10945. */
  10946. set onDispose(callback: () => void);
  10947. private _capacity;
  10948. private _fromPacked;
  10949. private _spriteTexture;
  10950. private _epsilon;
  10951. private _scene;
  10952. private _vertexData;
  10953. private _buffer;
  10954. private _vertexBuffers;
  10955. private _indexBuffer;
  10956. private _effectBase;
  10957. private _effectFog;
  10958. /**
  10959. * Gets or sets the unique id of the sprite
  10960. */
  10961. uniqueId: number;
  10962. /**
  10963. * Gets the array of sprites
  10964. */
  10965. get children(): Sprite[];
  10966. /**
  10967. * Gets the hosting scene
  10968. */
  10969. get scene(): Scene;
  10970. /**
  10971. * Gets the capacity of the manager
  10972. */
  10973. get capacity(): number;
  10974. /**
  10975. * Gets or sets the spritesheet texture
  10976. */
  10977. get texture(): Texture;
  10978. set texture(value: Texture);
  10979. private _blendMode;
  10980. /**
  10981. * Blend mode use to render the particle, it can be any of
  10982. * the static Constants.ALPHA_x properties provided in this class.
  10983. * Default value is Constants.ALPHA_COMBINE
  10984. */
  10985. get blendMode(): number;
  10986. set blendMode(blendMode: number);
  10987. /** Disables writing to the depth buffer when rendering the sprites.
  10988. * It can be handy to disable depth writing when using textures without alpha channel
  10989. * and setting some specific blend modes.
  10990. */
  10991. disableDepthWrite: boolean;
  10992. /**
  10993. * Creates a new sprite manager
  10994. * @param name defines the manager's name
  10995. * @param imgUrl defines the sprite sheet url
  10996. * @param capacity defines the maximum allowed number of sprites
  10997. * @param cellSize defines the size of a sprite cell
  10998. * @param scene defines the hosting scene
  10999. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11000. * @param samplingMode defines the smapling mode to use with spritesheet
  11001. * @param fromPacked set to false; do not alter
  11002. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11003. */
  11004. constructor(
  11005. /** defines the manager's name */
  11006. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11007. /**
  11008. * Returns the string "SpriteManager"
  11009. * @returns "SpriteManager"
  11010. */
  11011. getClassName(): string;
  11012. private _makePacked;
  11013. private _appendSpriteVertex;
  11014. private _checkTextureAlpha;
  11015. /**
  11016. * Intersects the sprites with a ray
  11017. * @param ray defines the ray to intersect with
  11018. * @param camera defines the current active camera
  11019. * @param predicate defines a predicate used to select candidate sprites
  11020. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11021. * @returns null if no hit or a PickingInfo
  11022. */
  11023. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11024. /**
  11025. * Intersects the sprites with a ray
  11026. * @param ray defines the ray to intersect with
  11027. * @param camera defines the current active camera
  11028. * @param predicate defines a predicate used to select candidate sprites
  11029. * @returns null if no hit or a PickingInfo array
  11030. */
  11031. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11032. /**
  11033. * Render all child sprites
  11034. */
  11035. render(): void;
  11036. /**
  11037. * Release associated resources
  11038. */
  11039. dispose(): void;
  11040. /**
  11041. * Serializes the sprite manager to a JSON object
  11042. * @param serializeTexture defines if the texture must be serialized as well
  11043. * @returns the JSON object
  11044. */
  11045. serialize(serializeTexture?: boolean): any;
  11046. /**
  11047. * Parses a JSON object to create a new sprite manager.
  11048. * @param parsedManager The JSON object to parse
  11049. * @param scene The scene to create the sprite managerin
  11050. * @param rootUrl The root url to use to load external dependencies like texture
  11051. * @returns the new sprite manager
  11052. */
  11053. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11054. /**
  11055. * Creates a sprite manager from a snippet saved in a remote file
  11056. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11057. * @param url defines the url to load from
  11058. * @param scene defines the hosting scene
  11059. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11060. * @returns a promise that will resolve to the new sprite manager
  11061. */
  11062. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11063. /**
  11064. * Creates a sprite manager from a snippet saved by the sprite editor
  11065. * @param snippetId defines the snippet to load
  11066. * @param scene defines the hosting scene
  11067. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11068. * @returns a promise that will resolve to the new sprite manager
  11069. */
  11070. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11071. }
  11072. }
  11073. declare module BABYLON {
  11074. /** Interface used by value gradients (color, factor, ...) */
  11075. export interface IValueGradient {
  11076. /**
  11077. * Gets or sets the gradient value (between 0 and 1)
  11078. */
  11079. gradient: number;
  11080. }
  11081. /** Class used to store color4 gradient */
  11082. export class ColorGradient implements IValueGradient {
  11083. /**
  11084. * Gets or sets the gradient value (between 0 and 1)
  11085. */
  11086. gradient: number;
  11087. /**
  11088. * Gets or sets first associated color
  11089. */
  11090. color1: Color4;
  11091. /**
  11092. * Gets or sets second associated color
  11093. */
  11094. color2?: Color4 | undefined;
  11095. /**
  11096. * Creates a new color4 gradient
  11097. * @param gradient gets or sets the gradient value (between 0 and 1)
  11098. * @param color1 gets or sets first associated color
  11099. * @param color2 gets or sets first second color
  11100. */
  11101. constructor(
  11102. /**
  11103. * Gets or sets the gradient value (between 0 and 1)
  11104. */
  11105. gradient: number,
  11106. /**
  11107. * Gets or sets first associated color
  11108. */
  11109. color1: Color4,
  11110. /**
  11111. * Gets or sets second associated color
  11112. */
  11113. color2?: Color4 | undefined);
  11114. /**
  11115. * Will get a color picked randomly between color1 and color2.
  11116. * If color2 is undefined then color1 will be used
  11117. * @param result defines the target Color4 to store the result in
  11118. */
  11119. getColorToRef(result: Color4): void;
  11120. }
  11121. /** Class used to store color 3 gradient */
  11122. export class Color3Gradient implements IValueGradient {
  11123. /**
  11124. * Gets or sets the gradient value (between 0 and 1)
  11125. */
  11126. gradient: number;
  11127. /**
  11128. * Gets or sets the associated color
  11129. */
  11130. color: Color3;
  11131. /**
  11132. * Creates a new color3 gradient
  11133. * @param gradient gets or sets the gradient value (between 0 and 1)
  11134. * @param color gets or sets associated color
  11135. */
  11136. constructor(
  11137. /**
  11138. * Gets or sets the gradient value (between 0 and 1)
  11139. */
  11140. gradient: number,
  11141. /**
  11142. * Gets or sets the associated color
  11143. */
  11144. color: Color3);
  11145. }
  11146. /** Class used to store factor gradient */
  11147. export class FactorGradient implements IValueGradient {
  11148. /**
  11149. * Gets or sets the gradient value (between 0 and 1)
  11150. */
  11151. gradient: number;
  11152. /**
  11153. * Gets or sets first associated factor
  11154. */
  11155. factor1: number;
  11156. /**
  11157. * Gets or sets second associated factor
  11158. */
  11159. factor2?: number | undefined;
  11160. /**
  11161. * Creates a new factor gradient
  11162. * @param gradient gets or sets the gradient value (between 0 and 1)
  11163. * @param factor1 gets or sets first associated factor
  11164. * @param factor2 gets or sets second associated factor
  11165. */
  11166. constructor(
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number,
  11171. /**
  11172. * Gets or sets first associated factor
  11173. */
  11174. factor1: number,
  11175. /**
  11176. * Gets or sets second associated factor
  11177. */
  11178. factor2?: number | undefined);
  11179. /**
  11180. * Will get a number picked randomly between factor1 and factor2.
  11181. * If factor2 is undefined then factor1 will be used
  11182. * @returns the picked number
  11183. */
  11184. getFactor(): number;
  11185. }
  11186. /**
  11187. * Helper used to simplify some generic gradient tasks
  11188. */
  11189. export class GradientHelper {
  11190. /**
  11191. * Gets the current gradient from an array of IValueGradient
  11192. * @param ratio defines the current ratio to get
  11193. * @param gradients defines the array of IValueGradient
  11194. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11195. */
  11196. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11197. }
  11198. }
  11199. declare module BABYLON {
  11200. interface ThinEngine {
  11201. /**
  11202. * Creates a raw texture
  11203. * @param data defines the data to store in the texture
  11204. * @param width defines the width of the texture
  11205. * @param height defines the height of the texture
  11206. * @param format defines the format of the data
  11207. * @param generateMipMaps defines if the engine should generate the mip levels
  11208. * @param invertY defines if data must be stored with Y axis inverted
  11209. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11210. * @param compression defines the compression used (null by default)
  11211. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11212. * @returns the raw texture inside an InternalTexture
  11213. */
  11214. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11215. /**
  11216. * Update a raw texture
  11217. * @param texture defines the texture to update
  11218. * @param data defines the data to store in the texture
  11219. * @param format defines the format of the data
  11220. * @param invertY defines if data must be stored with Y axis inverted
  11221. */
  11222. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11223. /**
  11224. * Update a raw texture
  11225. * @param texture defines the texture to update
  11226. * @param data defines the data to store in the texture
  11227. * @param format defines the format of the data
  11228. * @param invertY defines if data must be stored with Y axis inverted
  11229. * @param compression defines the compression used (null by default)
  11230. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11231. */
  11232. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11233. /**
  11234. * Creates a new raw cube texture
  11235. * @param data defines the array of data to use to create each face
  11236. * @param size defines the size of the textures
  11237. * @param format defines the format of the data
  11238. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11239. * @param generateMipMaps defines if the engine should generate the mip levels
  11240. * @param invertY defines if data must be stored with Y axis inverted
  11241. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11242. * @param compression defines the compression used (null by default)
  11243. * @returns the cube texture as an InternalTexture
  11244. */
  11245. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11246. /**
  11247. * Update a raw cube texture
  11248. * @param texture defines the texture to udpdate
  11249. * @param data defines the data to store
  11250. * @param format defines the data format
  11251. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11252. * @param invertY defines if data must be stored with Y axis inverted
  11253. */
  11254. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11255. /**
  11256. * Update a raw cube texture
  11257. * @param texture defines the texture to udpdate
  11258. * @param data defines the data to store
  11259. * @param format defines the data format
  11260. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11261. * @param invertY defines if data must be stored with Y axis inverted
  11262. * @param compression defines the compression used (null by default)
  11263. */
  11264. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11265. /**
  11266. * Update a raw cube texture
  11267. * @param texture defines the texture to udpdate
  11268. * @param data defines the data to store
  11269. * @param format defines the data format
  11270. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11271. * @param invertY defines if data must be stored with Y axis inverted
  11272. * @param compression defines the compression used (null by default)
  11273. * @param level defines which level of the texture to update
  11274. */
  11275. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11276. /**
  11277. * Creates a new raw cube texture from a specified url
  11278. * @param url defines the url where the data is located
  11279. * @param scene defines the current scene
  11280. * @param size defines the size of the textures
  11281. * @param format defines the format of the data
  11282. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11283. * @param noMipmap defines if the engine should avoid generating the mip levels
  11284. * @param callback defines a callback used to extract texture data from loaded data
  11285. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11286. * @param onLoad defines a callback called when texture is loaded
  11287. * @param onError defines a callback called if there is an error
  11288. * @returns the cube texture as an InternalTexture
  11289. */
  11290. 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;
  11291. /**
  11292. * Creates a new raw cube texture from a specified url
  11293. * @param url defines the url where the data is located
  11294. * @param scene defines the current scene
  11295. * @param size defines the size of the textures
  11296. * @param format defines the format of the data
  11297. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11298. * @param noMipmap defines if the engine should avoid generating the mip levels
  11299. * @param callback defines a callback used to extract texture data from loaded data
  11300. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11301. * @param onLoad defines a callback called when texture is loaded
  11302. * @param onError defines a callback called if there is an error
  11303. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11304. * @param invertY defines if data must be stored with Y axis inverted
  11305. * @returns the cube texture as an InternalTexture
  11306. */
  11307. 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;
  11308. /**
  11309. * Creates a new raw 3D texture
  11310. * @param data defines the data used to create the texture
  11311. * @param width defines the width of the texture
  11312. * @param height defines the height of the texture
  11313. * @param depth defines the depth of the texture
  11314. * @param format defines the format of the texture
  11315. * @param generateMipMaps defines if the engine must generate mip levels
  11316. * @param invertY defines if data must be stored with Y axis inverted
  11317. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11318. * @param compression defines the compressed used (can be null)
  11319. * @param textureType defines the compressed used (can be null)
  11320. * @returns a new raw 3D texture (stored in an InternalTexture)
  11321. */
  11322. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11323. /**
  11324. * Update a raw 3D texture
  11325. * @param texture defines the texture to update
  11326. * @param data defines the data to store
  11327. * @param format defines the data format
  11328. * @param invertY defines if data must be stored with Y axis inverted
  11329. */
  11330. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11331. /**
  11332. * Update a raw 3D texture
  11333. * @param texture defines the texture to update
  11334. * @param data defines the data to store
  11335. * @param format defines the data format
  11336. * @param invertY defines if data must be stored with Y axis inverted
  11337. * @param compression defines the used compression (can be null)
  11338. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11339. */
  11340. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11341. /**
  11342. * Creates a new raw 2D array texture
  11343. * @param data defines the data used to create the texture
  11344. * @param width defines the width of the texture
  11345. * @param height defines the height of the texture
  11346. * @param depth defines the number of layers of the texture
  11347. * @param format defines the format of the texture
  11348. * @param generateMipMaps defines if the engine must generate mip levels
  11349. * @param invertY defines if data must be stored with Y axis inverted
  11350. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11351. * @param compression defines the compressed used (can be null)
  11352. * @param textureType defines the compressed used (can be null)
  11353. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11354. */
  11355. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11356. /**
  11357. * Update a raw 2D array texture
  11358. * @param texture defines the texture to update
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param invertY defines if data must be stored with Y axis inverted
  11362. */
  11363. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11364. /**
  11365. * Update a raw 2D array texture
  11366. * @param texture defines the texture to update
  11367. * @param data defines the data to store
  11368. * @param format defines the data format
  11369. * @param invertY defines if data must be stored with Y axis inverted
  11370. * @param compression defines the used compression (can be null)
  11371. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11372. */
  11373. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11374. }
  11375. }
  11376. declare module BABYLON {
  11377. /**
  11378. * Raw texture can help creating a texture directly from an array of data.
  11379. * This can be super useful if you either get the data from an uncompressed source or
  11380. * if you wish to create your texture pixel by pixel.
  11381. */
  11382. export class RawTexture extends Texture {
  11383. /**
  11384. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11385. */
  11386. format: number;
  11387. /**
  11388. * Instantiates a new RawTexture.
  11389. * Raw texture can help creating a texture directly from an array of data.
  11390. * This can be super useful if you either get the data from an uncompressed source or
  11391. * if you wish to create your texture pixel by pixel.
  11392. * @param data define the array of data to use to create the texture
  11393. * @param width define the width of the texture
  11394. * @param height define the height of the texture
  11395. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11396. * @param scene define the scene the texture belongs to
  11397. * @param generateMipMaps define whether mip maps should be generated or not
  11398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11400. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11401. */
  11402. constructor(data: ArrayBufferView, width: number, height: number,
  11403. /**
  11404. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11405. */
  11406. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11407. /**
  11408. * Updates the texture underlying data.
  11409. * @param data Define the new data of the texture
  11410. */
  11411. update(data: ArrayBufferView): void;
  11412. /**
  11413. * Creates a luminance texture from some data.
  11414. * @param data Define the texture data
  11415. * @param width Define the width of the texture
  11416. * @param height Define the height of the texture
  11417. * @param scene Define the scene the texture belongs to
  11418. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11419. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11420. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11421. * @returns the luminance texture
  11422. */
  11423. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11424. /**
  11425. * Creates a luminance alpha texture from some data.
  11426. * @param data Define the texture data
  11427. * @param width Define the width of the texture
  11428. * @param height Define the height of the texture
  11429. * @param scene Define the scene the texture belongs to
  11430. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11431. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11432. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11433. * @returns the luminance alpha texture
  11434. */
  11435. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11436. /**
  11437. * Creates an alpha texture from some data.
  11438. * @param data Define the texture data
  11439. * @param width Define the width of the texture
  11440. * @param height Define the height of the texture
  11441. * @param scene Define the scene the texture belongs to
  11442. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11443. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11444. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11445. * @returns the alpha texture
  11446. */
  11447. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11448. /**
  11449. * Creates a RGB texture from some data.
  11450. * @param data Define the texture data
  11451. * @param width Define the width of the texture
  11452. * @param height Define the height of the texture
  11453. * @param scene Define the scene the texture belongs to
  11454. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11455. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11456. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11457. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11458. * @returns the RGB alpha texture
  11459. */
  11460. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11461. /**
  11462. * Creates a RGBA texture from some data.
  11463. * @param data Define the texture data
  11464. * @param width Define the width of the texture
  11465. * @param height Define the height of the texture
  11466. * @param scene Define the scene the texture belongs to
  11467. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11468. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11469. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11470. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11471. * @returns the RGBA texture
  11472. */
  11473. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11474. /**
  11475. * Creates a R texture from some data.
  11476. * @param data Define the texture data
  11477. * @param width Define the width of the texture
  11478. * @param height Define the height of the texture
  11479. * @param scene Define the scene the texture belongs to
  11480. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11483. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11484. * @returns the R texture
  11485. */
  11486. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11487. }
  11488. }
  11489. declare module BABYLON {
  11490. interface AbstractScene {
  11491. /**
  11492. * The list of procedural textures added to the scene
  11493. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11494. */
  11495. proceduralTextures: Array<ProceduralTexture>;
  11496. }
  11497. /**
  11498. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11499. * in a given scene.
  11500. */
  11501. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11502. /**
  11503. * The component name helpfull to identify the component in the list of scene components.
  11504. */
  11505. readonly name: string;
  11506. /**
  11507. * The scene the component belongs to.
  11508. */
  11509. scene: Scene;
  11510. /**
  11511. * Creates a new instance of the component for the given scene
  11512. * @param scene Defines the scene to register the component in
  11513. */
  11514. constructor(scene: Scene);
  11515. /**
  11516. * Registers the component in a given scene
  11517. */
  11518. register(): void;
  11519. /**
  11520. * Rebuilds the elements related to this component in case of
  11521. * context lost for instance.
  11522. */
  11523. rebuild(): void;
  11524. /**
  11525. * Disposes the component and the associated ressources.
  11526. */
  11527. dispose(): void;
  11528. private _beforeClear;
  11529. }
  11530. }
  11531. declare module BABYLON {
  11532. interface ThinEngine {
  11533. /**
  11534. * Creates a new render target cube texture
  11535. * @param size defines the size of the texture
  11536. * @param options defines the options used to create the texture
  11537. * @returns a new render target cube texture stored in an InternalTexture
  11538. */
  11539. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11540. }
  11541. }
  11542. declare module BABYLON {
  11543. /** @hidden */
  11544. export var proceduralVertexShader: {
  11545. name: string;
  11546. shader: string;
  11547. };
  11548. }
  11549. declare module BABYLON {
  11550. /**
  11551. * 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.
  11552. * This is the base class of any Procedural texture and contains most of the shareable code.
  11553. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11554. */
  11555. export class ProceduralTexture extends Texture {
  11556. isCube: boolean;
  11557. /**
  11558. * Define if the texture is enabled or not (disabled texture will not render)
  11559. */
  11560. isEnabled: boolean;
  11561. /**
  11562. * Define if the texture must be cleared before rendering (default is true)
  11563. */
  11564. autoClear: boolean;
  11565. /**
  11566. * Callback called when the texture is generated
  11567. */
  11568. onGenerated: () => void;
  11569. /**
  11570. * Event raised when the texture is generated
  11571. */
  11572. onGeneratedObservable: Observable<ProceduralTexture>;
  11573. /** @hidden */
  11574. _generateMipMaps: boolean;
  11575. /** @hidden **/
  11576. _effect: Effect;
  11577. /** @hidden */
  11578. _textures: {
  11579. [key: string]: Texture;
  11580. };
  11581. /** @hidden */
  11582. protected _fallbackTexture: Nullable<Texture>;
  11583. private _size;
  11584. private _currentRefreshId;
  11585. private _frameId;
  11586. private _refreshRate;
  11587. private _vertexBuffers;
  11588. private _indexBuffer;
  11589. private _uniforms;
  11590. private _samplers;
  11591. private _fragment;
  11592. private _floats;
  11593. private _ints;
  11594. private _floatsArrays;
  11595. private _colors3;
  11596. private _colors4;
  11597. private _vectors2;
  11598. private _vectors3;
  11599. private _matrices;
  11600. private _fallbackTextureUsed;
  11601. private _fullEngine;
  11602. private _cachedDefines;
  11603. private _contentUpdateId;
  11604. private _contentData;
  11605. /**
  11606. * Instantiates a new procedural texture.
  11607. * 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.
  11608. * This is the base class of any Procedural texture and contains most of the shareable code.
  11609. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11610. * @param name Define the name of the texture
  11611. * @param size Define the size of the texture to create
  11612. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11613. * @param scene Define the scene the texture belongs to
  11614. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11615. * @param generateMipMaps Define if the texture should creates mip maps or not
  11616. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11617. */
  11618. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11619. /**
  11620. * The effect that is created when initializing the post process.
  11621. * @returns The created effect corresponding the the postprocess.
  11622. */
  11623. getEffect(): Effect;
  11624. /**
  11625. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11626. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11627. */
  11628. getContent(): Nullable<ArrayBufferView>;
  11629. private _createIndexBuffer;
  11630. /** @hidden */
  11631. _rebuild(): void;
  11632. /**
  11633. * Resets the texture in order to recreate its associated resources.
  11634. * This can be called in case of context loss
  11635. */
  11636. reset(): void;
  11637. protected _getDefines(): string;
  11638. /**
  11639. * Is the texture ready to be used ? (rendered at least once)
  11640. * @returns true if ready, otherwise, false.
  11641. */
  11642. isReady(): boolean;
  11643. /**
  11644. * Resets the refresh counter of the texture and start bak from scratch.
  11645. * Could be useful to regenerate the texture if it is setup to render only once.
  11646. */
  11647. resetRefreshCounter(): void;
  11648. /**
  11649. * Set the fragment shader to use in order to render the texture.
  11650. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11651. */
  11652. setFragment(fragment: any): void;
  11653. /**
  11654. * Define the refresh rate of the texture or the rendering frequency.
  11655. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11656. */
  11657. get refreshRate(): number;
  11658. set refreshRate(value: number);
  11659. /** @hidden */
  11660. _shouldRender(): boolean;
  11661. /**
  11662. * Get the size the texture is rendering at.
  11663. * @returns the size (texture is always squared)
  11664. */
  11665. getRenderSize(): number;
  11666. /**
  11667. * Resize the texture to new value.
  11668. * @param size Define the new size the texture should have
  11669. * @param generateMipMaps Define whether the new texture should create mip maps
  11670. */
  11671. resize(size: number, generateMipMaps: boolean): void;
  11672. private _checkUniform;
  11673. /**
  11674. * Set a texture in the shader program used to render.
  11675. * @param name Define the name of the uniform samplers as defined in the shader
  11676. * @param texture Define the texture to bind to this sampler
  11677. * @return the texture itself allowing "fluent" like uniform updates
  11678. */
  11679. setTexture(name: string, texture: Texture): ProceduralTexture;
  11680. /**
  11681. * Set a float in the shader.
  11682. * @param name Define the name of the uniform as defined in the shader
  11683. * @param value Define the value to give to the uniform
  11684. * @return the texture itself allowing "fluent" like uniform updates
  11685. */
  11686. setFloat(name: string, value: number): ProceduralTexture;
  11687. /**
  11688. * Set a int in the shader.
  11689. * @param name Define the name of the uniform as defined in the shader
  11690. * @param value Define the value to give to the uniform
  11691. * @return the texture itself allowing "fluent" like uniform updates
  11692. */
  11693. setInt(name: string, value: number): ProceduralTexture;
  11694. /**
  11695. * Set an array of floats in the shader.
  11696. * @param name Define the name of the uniform as defined in the shader
  11697. * @param value Define the value to give to the uniform
  11698. * @return the texture itself allowing "fluent" like uniform updates
  11699. */
  11700. setFloats(name: string, value: number[]): ProceduralTexture;
  11701. /**
  11702. * Set a vec3 in the shader from a Color3.
  11703. * @param name Define the name of the uniform as defined in the shader
  11704. * @param value Define the value to give to the uniform
  11705. * @return the texture itself allowing "fluent" like uniform updates
  11706. */
  11707. setColor3(name: string, value: Color3): ProceduralTexture;
  11708. /**
  11709. * Set a vec4 in the shader from a Color4.
  11710. * @param name Define the name of the uniform as defined in the shader
  11711. * @param value Define the value to give to the uniform
  11712. * @return the texture itself allowing "fluent" like uniform updates
  11713. */
  11714. setColor4(name: string, value: Color4): ProceduralTexture;
  11715. /**
  11716. * Set a vec2 in the shader from a Vector2.
  11717. * @param name Define the name of the uniform as defined in the shader
  11718. * @param value Define the value to give to the uniform
  11719. * @return the texture itself allowing "fluent" like uniform updates
  11720. */
  11721. setVector2(name: string, value: Vector2): ProceduralTexture;
  11722. /**
  11723. * Set a vec3 in the shader from a Vector3.
  11724. * @param name Define the name of the uniform as defined in the shader
  11725. * @param value Define the value to give to the uniform
  11726. * @return the texture itself allowing "fluent" like uniform updates
  11727. */
  11728. setVector3(name: string, value: Vector3): ProceduralTexture;
  11729. /**
  11730. * Set a mat4 in the shader from a MAtrix.
  11731. * @param name Define the name of the uniform as defined in the shader
  11732. * @param value Define the value to give to the uniform
  11733. * @return the texture itself allowing "fluent" like uniform updates
  11734. */
  11735. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11736. /**
  11737. * Render the texture to its associated render target.
  11738. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11739. */
  11740. render(useCameraPostProcess?: boolean): void;
  11741. /**
  11742. * Clone the texture.
  11743. * @returns the cloned texture
  11744. */
  11745. clone(): ProceduralTexture;
  11746. /**
  11747. * Dispose the texture and release its asoociated resources.
  11748. */
  11749. dispose(): void;
  11750. }
  11751. }
  11752. declare module BABYLON {
  11753. /**
  11754. * This represents the base class for particle system in Babylon.
  11755. * 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.
  11756. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11757. * @example https://doc.babylonjs.com/babylon101/particles
  11758. */
  11759. export class BaseParticleSystem {
  11760. /**
  11761. * Source color is added to the destination color without alpha affecting the result
  11762. */
  11763. static BLENDMODE_ONEONE: number;
  11764. /**
  11765. * Blend current color and particle color using particle’s alpha
  11766. */
  11767. static BLENDMODE_STANDARD: number;
  11768. /**
  11769. * Add current color and particle color multiplied by particle’s alpha
  11770. */
  11771. static BLENDMODE_ADD: number;
  11772. /**
  11773. * Multiply current color with particle color
  11774. */
  11775. static BLENDMODE_MULTIPLY: number;
  11776. /**
  11777. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11778. */
  11779. static BLENDMODE_MULTIPLYADD: number;
  11780. /**
  11781. * List of animations used by the particle system.
  11782. */
  11783. animations: Animation[];
  11784. /**
  11785. * Gets or sets the unique id of the particle system
  11786. */
  11787. uniqueId: number;
  11788. /**
  11789. * The id of the Particle system.
  11790. */
  11791. id: string;
  11792. /**
  11793. * The friendly name of the Particle system.
  11794. */
  11795. name: string;
  11796. /**
  11797. * Snippet ID if the particle system was created from the snippet server
  11798. */
  11799. snippetId: string;
  11800. /**
  11801. * The rendering group used by the Particle system to chose when to render.
  11802. */
  11803. renderingGroupId: number;
  11804. /**
  11805. * The emitter represents the Mesh or position we are attaching the particle system to.
  11806. */
  11807. emitter: Nullable<AbstractMesh | Vector3>;
  11808. /**
  11809. * The maximum number of particles to emit per frame
  11810. */
  11811. emitRate: number;
  11812. /**
  11813. * If you want to launch only a few particles at once, that can be done, as well.
  11814. */
  11815. manualEmitCount: number;
  11816. /**
  11817. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11818. */
  11819. updateSpeed: number;
  11820. /**
  11821. * The amount of time the particle system is running (depends of the overall update speed).
  11822. */
  11823. targetStopDuration: number;
  11824. /**
  11825. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11826. */
  11827. disposeOnStop: boolean;
  11828. /**
  11829. * Minimum power of emitting particles.
  11830. */
  11831. minEmitPower: number;
  11832. /**
  11833. * Maximum power of emitting particles.
  11834. */
  11835. maxEmitPower: number;
  11836. /**
  11837. * Minimum life time of emitting particles.
  11838. */
  11839. minLifeTime: number;
  11840. /**
  11841. * Maximum life time of emitting particles.
  11842. */
  11843. maxLifeTime: number;
  11844. /**
  11845. * Minimum Size of emitting particles.
  11846. */
  11847. minSize: number;
  11848. /**
  11849. * Maximum Size of emitting particles.
  11850. */
  11851. maxSize: number;
  11852. /**
  11853. * Minimum scale of emitting particles on X axis.
  11854. */
  11855. minScaleX: number;
  11856. /**
  11857. * Maximum scale of emitting particles on X axis.
  11858. */
  11859. maxScaleX: number;
  11860. /**
  11861. * Minimum scale of emitting particles on Y axis.
  11862. */
  11863. minScaleY: number;
  11864. /**
  11865. * Maximum scale of emitting particles on Y axis.
  11866. */
  11867. maxScaleY: number;
  11868. /**
  11869. * Gets or sets the minimal initial rotation in radians.
  11870. */
  11871. minInitialRotation: number;
  11872. /**
  11873. * Gets or sets the maximal initial rotation in radians.
  11874. */
  11875. maxInitialRotation: number;
  11876. /**
  11877. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11878. */
  11879. minAngularSpeed: number;
  11880. /**
  11881. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11882. */
  11883. maxAngularSpeed: number;
  11884. /**
  11885. * The texture used to render each particle. (this can be a spritesheet)
  11886. */
  11887. particleTexture: Nullable<Texture>;
  11888. /**
  11889. * The layer mask we are rendering the particles through.
  11890. */
  11891. layerMask: number;
  11892. /**
  11893. * This can help using your own shader to render the particle system.
  11894. * The according effect will be created
  11895. */
  11896. customShader: any;
  11897. /**
  11898. * By default particle system starts as soon as they are created. This prevents the
  11899. * automatic start to happen and let you decide when to start emitting particles.
  11900. */
  11901. preventAutoStart: boolean;
  11902. private _noiseTexture;
  11903. /**
  11904. * Gets or sets a texture used to add random noise to particle positions
  11905. */
  11906. get noiseTexture(): Nullable<ProceduralTexture>;
  11907. set noiseTexture(value: Nullable<ProceduralTexture>);
  11908. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11909. noiseStrength: Vector3;
  11910. /**
  11911. * Callback triggered when the particle animation is ending.
  11912. */
  11913. onAnimationEnd: Nullable<() => void>;
  11914. /**
  11915. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11916. */
  11917. blendMode: number;
  11918. /**
  11919. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11920. * to override the particles.
  11921. */
  11922. forceDepthWrite: boolean;
  11923. /** 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 */
  11924. preWarmCycles: number;
  11925. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11926. preWarmStepOffset: number;
  11927. /**
  11928. * 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)
  11929. */
  11930. spriteCellChangeSpeed: number;
  11931. /**
  11932. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11933. */
  11934. startSpriteCellID: number;
  11935. /**
  11936. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11937. */
  11938. endSpriteCellID: number;
  11939. /**
  11940. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11941. */
  11942. spriteCellWidth: number;
  11943. /**
  11944. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11945. */
  11946. spriteCellHeight: number;
  11947. /**
  11948. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11949. */
  11950. spriteRandomStartCell: boolean;
  11951. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11952. translationPivot: Vector2;
  11953. /** @hidden */
  11954. protected _isAnimationSheetEnabled: boolean;
  11955. /**
  11956. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11957. */
  11958. beginAnimationOnStart: boolean;
  11959. /**
  11960. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11961. */
  11962. beginAnimationFrom: number;
  11963. /**
  11964. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11965. */
  11966. beginAnimationTo: number;
  11967. /**
  11968. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11969. */
  11970. beginAnimationLoop: boolean;
  11971. /**
  11972. * Gets or sets a world offset applied to all particles
  11973. */
  11974. worldOffset: Vector3;
  11975. /**
  11976. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11977. */
  11978. get isAnimationSheetEnabled(): boolean;
  11979. set isAnimationSheetEnabled(value: boolean);
  11980. /**
  11981. * Get hosting scene
  11982. * @returns the scene
  11983. */
  11984. getScene(): Scene;
  11985. /**
  11986. * You can use gravity if you want to give an orientation to your particles.
  11987. */
  11988. gravity: Vector3;
  11989. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11990. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11991. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11992. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11993. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11994. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11995. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11996. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11997. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11998. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11999. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12000. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12001. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12002. /**
  12003. * Defines the delay in milliseconds before starting the system (0 by default)
  12004. */
  12005. startDelay: number;
  12006. /**
  12007. * Gets the current list of drag gradients.
  12008. * You must use addDragGradient and removeDragGradient to udpate this list
  12009. * @returns the list of drag gradients
  12010. */
  12011. getDragGradients(): Nullable<Array<FactorGradient>>;
  12012. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12013. limitVelocityDamping: number;
  12014. /**
  12015. * Gets the current list of limit velocity gradients.
  12016. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12017. * @returns the list of limit velocity gradients
  12018. */
  12019. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12020. /**
  12021. * Gets the current list of color gradients.
  12022. * You must use addColorGradient and removeColorGradient to udpate this list
  12023. * @returns the list of color gradients
  12024. */
  12025. getColorGradients(): Nullable<Array<ColorGradient>>;
  12026. /**
  12027. * Gets the current list of size gradients.
  12028. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12029. * @returns the list of size gradients
  12030. */
  12031. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12032. /**
  12033. * Gets the current list of color remap gradients.
  12034. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12035. * @returns the list of color remap gradients
  12036. */
  12037. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12038. /**
  12039. * Gets the current list of alpha remap gradients.
  12040. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12041. * @returns the list of alpha remap gradients
  12042. */
  12043. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12044. /**
  12045. * Gets the current list of life time gradients.
  12046. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12047. * @returns the list of life time gradients
  12048. */
  12049. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12050. /**
  12051. * Gets the current list of angular speed gradients.
  12052. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12053. * @returns the list of angular speed gradients
  12054. */
  12055. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12056. /**
  12057. * Gets the current list of velocity gradients.
  12058. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12059. * @returns the list of velocity gradients
  12060. */
  12061. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12062. /**
  12063. * Gets the current list of start size gradients.
  12064. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12065. * @returns the list of start size gradients
  12066. */
  12067. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12068. /**
  12069. * Gets the current list of emit rate gradients.
  12070. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12071. * @returns the list of emit rate gradients
  12072. */
  12073. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12074. /**
  12075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12076. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12077. */
  12078. get direction1(): Vector3;
  12079. set direction1(value: Vector3);
  12080. /**
  12081. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12082. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12083. */
  12084. get direction2(): Vector3;
  12085. set direction2(value: Vector3);
  12086. /**
  12087. * 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.
  12088. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12089. */
  12090. get minEmitBox(): Vector3;
  12091. set minEmitBox(value: Vector3);
  12092. /**
  12093. * 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.
  12094. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12095. */
  12096. get maxEmitBox(): Vector3;
  12097. set maxEmitBox(value: Vector3);
  12098. /**
  12099. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12100. */
  12101. color1: Color4;
  12102. /**
  12103. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12104. */
  12105. color2: Color4;
  12106. /**
  12107. * Color the particle will have at the end of its lifetime
  12108. */
  12109. colorDead: Color4;
  12110. /**
  12111. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12112. */
  12113. textureMask: Color4;
  12114. /**
  12115. * The particle emitter type defines the emitter used by the particle system.
  12116. * It can be for example box, sphere, or cone...
  12117. */
  12118. particleEmitterType: IParticleEmitterType;
  12119. /** @hidden */
  12120. _isSubEmitter: boolean;
  12121. /**
  12122. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12123. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12124. */
  12125. billboardMode: number;
  12126. protected _isBillboardBased: boolean;
  12127. /**
  12128. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12129. */
  12130. get isBillboardBased(): boolean;
  12131. set isBillboardBased(value: boolean);
  12132. /**
  12133. * The scene the particle system belongs to.
  12134. */
  12135. protected _scene: Scene;
  12136. /**
  12137. * Local cache of defines for image processing.
  12138. */
  12139. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12140. /**
  12141. * Default configuration related to image processing available in the standard Material.
  12142. */
  12143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12144. /**
  12145. * Gets the image processing configuration used either in this material.
  12146. */
  12147. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12148. /**
  12149. * Sets the Default image processing configuration used either in the this material.
  12150. *
  12151. * If sets to null, the scene one is in use.
  12152. */
  12153. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12154. /**
  12155. * Attaches a new image processing configuration to the Standard Material.
  12156. * @param configuration
  12157. */
  12158. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12159. /** @hidden */
  12160. protected _reset(): void;
  12161. /** @hidden */
  12162. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12163. /**
  12164. * Instantiates a particle system.
  12165. * 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.
  12166. * @param name The name of the particle system
  12167. */
  12168. constructor(name: string);
  12169. /**
  12170. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12171. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12172. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12173. * @returns the emitter
  12174. */
  12175. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12176. /**
  12177. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12178. * @param radius The radius of the hemisphere to emit from
  12179. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12180. * @returns the emitter
  12181. */
  12182. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12183. /**
  12184. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12185. * @param radius The radius of the sphere to emit from
  12186. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12187. * @returns the emitter
  12188. */
  12189. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12190. /**
  12191. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12192. * @param radius The radius of the sphere to emit from
  12193. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12194. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12195. * @returns the emitter
  12196. */
  12197. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12198. /**
  12199. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12200. * @param radius The radius of the emission cylinder
  12201. * @param height The height of the emission cylinder
  12202. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12203. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12204. * @returns the emitter
  12205. */
  12206. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12207. /**
  12208. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12209. * @param radius The radius of the cylinder to emit from
  12210. * @param height The height of the emission cylinder
  12211. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12212. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12213. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12214. * @returns the emitter
  12215. */
  12216. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12217. /**
  12218. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12219. * @param radius The radius of the cone to emit from
  12220. * @param angle The base angle of the cone
  12221. * @returns the emitter
  12222. */
  12223. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12224. /**
  12225. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12228. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12229. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12230. * @returns the emitter
  12231. */
  12232. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12233. }
  12234. }
  12235. declare module BABYLON {
  12236. /**
  12237. * Type of sub emitter
  12238. */
  12239. export enum SubEmitterType {
  12240. /**
  12241. * Attached to the particle over it's lifetime
  12242. */
  12243. ATTACHED = 0,
  12244. /**
  12245. * Created when the particle dies
  12246. */
  12247. END = 1
  12248. }
  12249. /**
  12250. * Sub emitter class used to emit particles from an existing particle
  12251. */
  12252. export class SubEmitter {
  12253. /**
  12254. * the particle system to be used by the sub emitter
  12255. */
  12256. particleSystem: ParticleSystem;
  12257. /**
  12258. * Type of the submitter (Default: END)
  12259. */
  12260. type: SubEmitterType;
  12261. /**
  12262. * 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)
  12263. * Note: This only is supported when using an emitter of type Mesh
  12264. */
  12265. inheritDirection: boolean;
  12266. /**
  12267. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12268. */
  12269. inheritedVelocityAmount: number;
  12270. /**
  12271. * Creates a sub emitter
  12272. * @param particleSystem the particle system to be used by the sub emitter
  12273. */
  12274. constructor(
  12275. /**
  12276. * the particle system to be used by the sub emitter
  12277. */
  12278. particleSystem: ParticleSystem);
  12279. /**
  12280. * Clones the sub emitter
  12281. * @returns the cloned sub emitter
  12282. */
  12283. clone(): SubEmitter;
  12284. /**
  12285. * Serialize current object to a JSON object
  12286. * @returns the serialized object
  12287. */
  12288. serialize(): any;
  12289. /** @hidden */
  12290. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12291. /**
  12292. * Creates a new SubEmitter from a serialized JSON version
  12293. * @param serializationObject defines the JSON object to read from
  12294. * @param scene defines the hosting scene
  12295. * @param rootUrl defines the rootUrl for data loading
  12296. * @returns a new SubEmitter
  12297. */
  12298. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12299. /** Release associated resources */
  12300. dispose(): void;
  12301. }
  12302. }
  12303. declare module BABYLON {
  12304. /** @hidden */
  12305. export var imageProcessingDeclaration: {
  12306. name: string;
  12307. shader: string;
  12308. };
  12309. }
  12310. declare module BABYLON {
  12311. /** @hidden */
  12312. export var imageProcessingFunctions: {
  12313. name: string;
  12314. shader: string;
  12315. };
  12316. }
  12317. declare module BABYLON {
  12318. /** @hidden */
  12319. export var particlesPixelShader: {
  12320. name: string;
  12321. shader: string;
  12322. };
  12323. }
  12324. declare module BABYLON {
  12325. /** @hidden */
  12326. export var particlesVertexShader: {
  12327. name: string;
  12328. shader: string;
  12329. };
  12330. }
  12331. declare module BABYLON {
  12332. /**
  12333. * This represents a particle system in Babylon.
  12334. * 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.
  12335. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12336. * @example https://doc.babylonjs.com/babylon101/particles
  12337. */
  12338. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12339. /**
  12340. * Billboard mode will only apply to Y axis
  12341. */
  12342. static readonly BILLBOARDMODE_Y: number;
  12343. /**
  12344. * Billboard mode will apply to all axes
  12345. */
  12346. static readonly BILLBOARDMODE_ALL: number;
  12347. /**
  12348. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12349. */
  12350. static readonly BILLBOARDMODE_STRETCHED: number;
  12351. /**
  12352. * This function can be defined to provide custom update for active particles.
  12353. * This function will be called instead of regular update (age, position, color, etc.).
  12354. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12355. */
  12356. updateFunction: (particles: Particle[]) => void;
  12357. private _emitterWorldMatrix;
  12358. /**
  12359. * This function can be defined to specify initial direction for every new particle.
  12360. * It by default use the emitterType defined function
  12361. */
  12362. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12363. /**
  12364. * This function can be defined to specify initial position for every new particle.
  12365. * It by default use the emitterType defined function
  12366. */
  12367. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12368. /**
  12369. * @hidden
  12370. */
  12371. _inheritedVelocityOffset: Vector3;
  12372. /**
  12373. * An event triggered when the system is disposed
  12374. */
  12375. onDisposeObservable: Observable<IParticleSystem>;
  12376. private _onDisposeObserver;
  12377. /**
  12378. * Sets a callback that will be triggered when the system is disposed
  12379. */
  12380. set onDispose(callback: () => void);
  12381. private _particles;
  12382. private _epsilon;
  12383. private _capacity;
  12384. private _stockParticles;
  12385. private _newPartsExcess;
  12386. private _vertexData;
  12387. private _vertexBuffer;
  12388. private _vertexBuffers;
  12389. private _spriteBuffer;
  12390. private _indexBuffer;
  12391. private _effect;
  12392. private _customEffect;
  12393. private _cachedDefines;
  12394. private _scaledColorStep;
  12395. private _colorDiff;
  12396. private _scaledDirection;
  12397. private _scaledGravity;
  12398. private _currentRenderId;
  12399. private _alive;
  12400. private _useInstancing;
  12401. private _started;
  12402. private _stopped;
  12403. private _actualFrame;
  12404. private _scaledUpdateSpeed;
  12405. private _vertexBufferSize;
  12406. /** @hidden */
  12407. _currentEmitRateGradient: Nullable<FactorGradient>;
  12408. /** @hidden */
  12409. _currentEmitRate1: number;
  12410. /** @hidden */
  12411. _currentEmitRate2: number;
  12412. /** @hidden */
  12413. _currentStartSizeGradient: Nullable<FactorGradient>;
  12414. /** @hidden */
  12415. _currentStartSize1: number;
  12416. /** @hidden */
  12417. _currentStartSize2: number;
  12418. private readonly _rawTextureWidth;
  12419. private _rampGradientsTexture;
  12420. private _useRampGradients;
  12421. /** Gets or sets a boolean indicating that ramp gradients must be used
  12422. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12423. */
  12424. get useRampGradients(): boolean;
  12425. set useRampGradients(value: boolean);
  12426. /**
  12427. * 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.
  12428. * 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: [])
  12429. */
  12430. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12431. private _subEmitters;
  12432. /**
  12433. * @hidden
  12434. * If the particle systems emitter should be disposed when the particle system is disposed
  12435. */
  12436. _disposeEmitterOnDispose: boolean;
  12437. /**
  12438. * The current active Sub-systems, this property is used by the root particle system only.
  12439. */
  12440. activeSubSystems: Array<ParticleSystem>;
  12441. /**
  12442. * Specifies if the particles are updated in emitter local space or world space
  12443. */
  12444. isLocal: boolean;
  12445. private _rootParticleSystem;
  12446. /**
  12447. * Gets the current list of active particles
  12448. */
  12449. get particles(): Particle[];
  12450. /**
  12451. * Gets the number of particles active at the same time.
  12452. * @returns The number of active particles.
  12453. */
  12454. getActiveCount(): number;
  12455. /**
  12456. * Returns the string "ParticleSystem"
  12457. * @returns a string containing the class name
  12458. */
  12459. getClassName(): string;
  12460. /**
  12461. * Gets a boolean indicating that the system is stopping
  12462. * @returns true if the system is currently stopping
  12463. */
  12464. isStopping(): boolean;
  12465. /**
  12466. * Gets the custom effect used to render the particles
  12467. * @param blendMode Blend mode for which the effect should be retrieved
  12468. * @returns The effect
  12469. */
  12470. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12471. /**
  12472. * Sets the custom effect used to render the particles
  12473. * @param effect The effect to set
  12474. * @param blendMode Blend mode for which the effect should be set
  12475. */
  12476. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12477. /** @hidden */
  12478. private _onBeforeDrawParticlesObservable;
  12479. /**
  12480. * Observable that will be called just before the particles are drawn
  12481. */
  12482. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12483. /**
  12484. * Gets the name of the particle vertex shader
  12485. */
  12486. get vertexShaderName(): string;
  12487. /**
  12488. * Instantiates a particle system.
  12489. * 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.
  12490. * @param name The name of the particle system
  12491. * @param capacity The max number of particles alive at the same time
  12492. * @param scene The scene the particle system belongs to
  12493. * @param customEffect a custom effect used to change the way particles are rendered by default
  12494. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12495. * @param epsilon Offset used to render the particles
  12496. */
  12497. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12498. private _addFactorGradient;
  12499. private _removeFactorGradient;
  12500. /**
  12501. * Adds a new life time gradient
  12502. * @param gradient defines the gradient to use (between 0 and 1)
  12503. * @param factor defines the life time factor to affect to the specified gradient
  12504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12505. * @returns the current particle system
  12506. */
  12507. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12508. /**
  12509. * Remove a specific life time gradient
  12510. * @param gradient defines the gradient to remove
  12511. * @returns the current particle system
  12512. */
  12513. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12514. /**
  12515. * Adds a new size gradient
  12516. * @param gradient defines the gradient to use (between 0 and 1)
  12517. * @param factor defines the size factor to affect to the specified gradient
  12518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12519. * @returns the current particle system
  12520. */
  12521. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12522. /**
  12523. * Remove a specific size gradient
  12524. * @param gradient defines the gradient to remove
  12525. * @returns the current particle system
  12526. */
  12527. removeSizeGradient(gradient: number): IParticleSystem;
  12528. /**
  12529. * Adds a new color remap gradient
  12530. * @param gradient defines the gradient to use (between 0 and 1)
  12531. * @param min defines the color remap minimal range
  12532. * @param max defines the color remap maximal range
  12533. * @returns the current particle system
  12534. */
  12535. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12536. /**
  12537. * Remove a specific color remap gradient
  12538. * @param gradient defines the gradient to remove
  12539. * @returns the current particle system
  12540. */
  12541. removeColorRemapGradient(gradient: number): IParticleSystem;
  12542. /**
  12543. * Adds a new alpha remap gradient
  12544. * @param gradient defines the gradient to use (between 0 and 1)
  12545. * @param min defines the alpha remap minimal range
  12546. * @param max defines the alpha remap maximal range
  12547. * @returns the current particle system
  12548. */
  12549. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12550. /**
  12551. * Remove a specific alpha remap gradient
  12552. * @param gradient defines the gradient to remove
  12553. * @returns the current particle system
  12554. */
  12555. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12556. /**
  12557. * Adds a new angular speed gradient
  12558. * @param gradient defines the gradient to use (between 0 and 1)
  12559. * @param factor defines the angular speed to affect to the specified gradient
  12560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12561. * @returns the current particle system
  12562. */
  12563. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12564. /**
  12565. * Remove a specific angular speed gradient
  12566. * @param gradient defines the gradient to remove
  12567. * @returns the current particle system
  12568. */
  12569. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12570. /**
  12571. * Adds a new velocity gradient
  12572. * @param gradient defines the gradient to use (between 0 and 1)
  12573. * @param factor defines the velocity to affect to the specified gradient
  12574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12575. * @returns the current particle system
  12576. */
  12577. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12578. /**
  12579. * Remove a specific velocity gradient
  12580. * @param gradient defines the gradient to remove
  12581. * @returns the current particle system
  12582. */
  12583. removeVelocityGradient(gradient: number): IParticleSystem;
  12584. /**
  12585. * Adds a new limit velocity gradient
  12586. * @param gradient defines the gradient to use (between 0 and 1)
  12587. * @param factor defines the limit velocity value to affect to the specified gradient
  12588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12589. * @returns the current particle system
  12590. */
  12591. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12592. /**
  12593. * Remove a specific limit velocity gradient
  12594. * @param gradient defines the gradient to remove
  12595. * @returns the current particle system
  12596. */
  12597. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12598. /**
  12599. * Adds a new drag gradient
  12600. * @param gradient defines the gradient to use (between 0 and 1)
  12601. * @param factor defines the drag value to affect to the specified gradient
  12602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12603. * @returns the current particle system
  12604. */
  12605. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12606. /**
  12607. * Remove a specific drag gradient
  12608. * @param gradient defines the gradient to remove
  12609. * @returns the current particle system
  12610. */
  12611. removeDragGradient(gradient: number): IParticleSystem;
  12612. /**
  12613. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12614. * @param gradient defines the gradient to use (between 0 and 1)
  12615. * @param factor defines the emit rate value to affect to the specified gradient
  12616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12617. * @returns the current particle system
  12618. */
  12619. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12620. /**
  12621. * Remove a specific emit rate gradient
  12622. * @param gradient defines the gradient to remove
  12623. * @returns the current particle system
  12624. */
  12625. removeEmitRateGradient(gradient: number): IParticleSystem;
  12626. /**
  12627. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12628. * @param gradient defines the gradient to use (between 0 and 1)
  12629. * @param factor defines the start size value to affect to the specified gradient
  12630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12631. * @returns the current particle system
  12632. */
  12633. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12634. /**
  12635. * Remove a specific start size gradient
  12636. * @param gradient defines the gradient to remove
  12637. * @returns the current particle system
  12638. */
  12639. removeStartSizeGradient(gradient: number): IParticleSystem;
  12640. private _createRampGradientTexture;
  12641. /**
  12642. * Gets the current list of ramp gradients.
  12643. * You must use addRampGradient and removeRampGradient to udpate this list
  12644. * @returns the list of ramp gradients
  12645. */
  12646. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12647. /** Force the system to rebuild all gradients that need to be resync */
  12648. forceRefreshGradients(): void;
  12649. private _syncRampGradientTexture;
  12650. /**
  12651. * Adds a new ramp gradient used to remap particle colors
  12652. * @param gradient defines the gradient to use (between 0 and 1)
  12653. * @param color defines the color to affect to the specified gradient
  12654. * @returns the current particle system
  12655. */
  12656. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12657. /**
  12658. * Remove a specific ramp gradient
  12659. * @param gradient defines the gradient to remove
  12660. * @returns the current particle system
  12661. */
  12662. removeRampGradient(gradient: number): ParticleSystem;
  12663. /**
  12664. * Adds a new color gradient
  12665. * @param gradient defines the gradient to use (between 0 and 1)
  12666. * @param color1 defines the color to affect to the specified gradient
  12667. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12668. * @returns this particle system
  12669. */
  12670. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12671. /**
  12672. * Remove a specific color gradient
  12673. * @param gradient defines the gradient to remove
  12674. * @returns this particle system
  12675. */
  12676. removeColorGradient(gradient: number): IParticleSystem;
  12677. private _fetchR;
  12678. protected _reset(): void;
  12679. private _resetEffect;
  12680. private _createVertexBuffers;
  12681. private _createIndexBuffer;
  12682. /**
  12683. * Gets the maximum number of particles active at the same time.
  12684. * @returns The max number of active particles.
  12685. */
  12686. getCapacity(): number;
  12687. /**
  12688. * Gets whether there are still active particles in the system.
  12689. * @returns True if it is alive, otherwise false.
  12690. */
  12691. isAlive(): boolean;
  12692. /**
  12693. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12694. * @returns True if it has been started, otherwise false.
  12695. */
  12696. isStarted(): boolean;
  12697. private _prepareSubEmitterInternalArray;
  12698. /**
  12699. * Starts the particle system and begins to emit
  12700. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12701. */
  12702. start(delay?: number): void;
  12703. /**
  12704. * Stops the particle system.
  12705. * @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.
  12706. */
  12707. stop(stopSubEmitters?: boolean): void;
  12708. /**
  12709. * Remove all active particles
  12710. */
  12711. reset(): void;
  12712. /**
  12713. * @hidden (for internal use only)
  12714. */
  12715. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12716. /**
  12717. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12718. * Its lifetime will start back at 0.
  12719. */
  12720. recycleParticle: (particle: Particle) => void;
  12721. private _stopSubEmitters;
  12722. private _createParticle;
  12723. private _removeFromRoot;
  12724. private _emitFromParticle;
  12725. private _update;
  12726. /** @hidden */
  12727. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12728. /** @hidden */
  12729. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12730. /**
  12731. * Fill the defines array according to the current settings of the particle system
  12732. * @param defines Array to be updated
  12733. * @param blendMode blend mode to take into account when updating the array
  12734. */
  12735. fillDefines(defines: Array<string>, blendMode: number): void;
  12736. /**
  12737. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12738. * @param uniforms Uniforms array to fill
  12739. * @param attributes Attributes array to fill
  12740. * @param samplers Samplers array to fill
  12741. */
  12742. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12743. /** @hidden */
  12744. private _getEffect;
  12745. /**
  12746. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12747. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12748. */
  12749. animate(preWarmOnly?: boolean): void;
  12750. private _appendParticleVertices;
  12751. /**
  12752. * Rebuilds the particle system.
  12753. */
  12754. rebuild(): void;
  12755. /**
  12756. * Is this system ready to be used/rendered
  12757. * @return true if the system is ready
  12758. */
  12759. isReady(): boolean;
  12760. private _render;
  12761. /**
  12762. * Renders the particle system in its current state.
  12763. * @returns the current number of particles
  12764. */
  12765. render(): number;
  12766. /**
  12767. * Disposes the particle system and free the associated resources
  12768. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12769. */
  12770. dispose(disposeTexture?: boolean): void;
  12771. /**
  12772. * Clones the particle system.
  12773. * @param name The name of the cloned object
  12774. * @param newEmitter The new emitter to use
  12775. * @returns the cloned particle system
  12776. */
  12777. clone(name: string, newEmitter: any): ParticleSystem;
  12778. /**
  12779. * Serializes the particle system to a JSON object
  12780. * @param serializeTexture defines if the texture must be serialized as well
  12781. * @returns the JSON object
  12782. */
  12783. serialize(serializeTexture?: boolean): any;
  12784. /** @hidden */
  12785. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12786. /** @hidden */
  12787. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12788. /**
  12789. * Parses a JSON object to create a particle system.
  12790. * @param parsedParticleSystem The JSON object to parse
  12791. * @param scene The scene to create the particle system in
  12792. * @param rootUrl The root url to use to load external dependencies like texture
  12793. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12794. * @returns the Parsed particle system
  12795. */
  12796. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12797. }
  12798. }
  12799. declare module BABYLON {
  12800. /**
  12801. * A particle represents one of the element emitted by a particle system.
  12802. * This is mainly define by its coordinates, direction, velocity and age.
  12803. */
  12804. export class Particle {
  12805. /**
  12806. * The particle system the particle belongs to.
  12807. */
  12808. particleSystem: ParticleSystem;
  12809. private static _Count;
  12810. /**
  12811. * Unique ID of the particle
  12812. */
  12813. id: number;
  12814. /**
  12815. * The world position of the particle in the scene.
  12816. */
  12817. position: Vector3;
  12818. /**
  12819. * The world direction of the particle in the scene.
  12820. */
  12821. direction: Vector3;
  12822. /**
  12823. * The color of the particle.
  12824. */
  12825. color: Color4;
  12826. /**
  12827. * The color change of the particle per step.
  12828. */
  12829. colorStep: Color4;
  12830. /**
  12831. * Defines how long will the life of the particle be.
  12832. */
  12833. lifeTime: number;
  12834. /**
  12835. * The current age of the particle.
  12836. */
  12837. age: number;
  12838. /**
  12839. * The current size of the particle.
  12840. */
  12841. size: number;
  12842. /**
  12843. * The current scale of the particle.
  12844. */
  12845. scale: Vector2;
  12846. /**
  12847. * The current angle of the particle.
  12848. */
  12849. angle: number;
  12850. /**
  12851. * Defines how fast is the angle changing.
  12852. */
  12853. angularSpeed: number;
  12854. /**
  12855. * Defines the cell index used by the particle to be rendered from a sprite.
  12856. */
  12857. cellIndex: number;
  12858. /**
  12859. * The information required to support color remapping
  12860. */
  12861. remapData: Vector4;
  12862. /** @hidden */
  12863. _randomCellOffset?: number;
  12864. /** @hidden */
  12865. _initialDirection: Nullable<Vector3>;
  12866. /** @hidden */
  12867. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12868. /** @hidden */
  12869. _initialStartSpriteCellID: number;
  12870. /** @hidden */
  12871. _initialEndSpriteCellID: number;
  12872. /** @hidden */
  12873. _currentColorGradient: Nullable<ColorGradient>;
  12874. /** @hidden */
  12875. _currentColor1: Color4;
  12876. /** @hidden */
  12877. _currentColor2: Color4;
  12878. /** @hidden */
  12879. _currentSizeGradient: Nullable<FactorGradient>;
  12880. /** @hidden */
  12881. _currentSize1: number;
  12882. /** @hidden */
  12883. _currentSize2: number;
  12884. /** @hidden */
  12885. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12886. /** @hidden */
  12887. _currentAngularSpeed1: number;
  12888. /** @hidden */
  12889. _currentAngularSpeed2: number;
  12890. /** @hidden */
  12891. _currentVelocityGradient: Nullable<FactorGradient>;
  12892. /** @hidden */
  12893. _currentVelocity1: number;
  12894. /** @hidden */
  12895. _currentVelocity2: number;
  12896. /** @hidden */
  12897. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12898. /** @hidden */
  12899. _currentLimitVelocity1: number;
  12900. /** @hidden */
  12901. _currentLimitVelocity2: number;
  12902. /** @hidden */
  12903. _currentDragGradient: Nullable<FactorGradient>;
  12904. /** @hidden */
  12905. _currentDrag1: number;
  12906. /** @hidden */
  12907. _currentDrag2: number;
  12908. /** @hidden */
  12909. _randomNoiseCoordinates1: Vector3;
  12910. /** @hidden */
  12911. _randomNoiseCoordinates2: Vector3;
  12912. /** @hidden */
  12913. _localPosition?: Vector3;
  12914. /**
  12915. * Creates a new instance Particle
  12916. * @param particleSystem the particle system the particle belongs to
  12917. */
  12918. constructor(
  12919. /**
  12920. * The particle system the particle belongs to.
  12921. */
  12922. particleSystem: ParticleSystem);
  12923. private updateCellInfoFromSystem;
  12924. /**
  12925. * Defines how the sprite cell index is updated for the particle
  12926. */
  12927. updateCellIndex(): void;
  12928. /** @hidden */
  12929. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12930. /** @hidden */
  12931. _inheritParticleInfoToSubEmitters(): void;
  12932. /** @hidden */
  12933. _reset(): void;
  12934. /**
  12935. * Copy the properties of particle to another one.
  12936. * @param other the particle to copy the information to.
  12937. */
  12938. copyTo(other: Particle): void;
  12939. }
  12940. }
  12941. declare module BABYLON {
  12942. /**
  12943. * Particle emitter represents a volume emitting particles.
  12944. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12945. */
  12946. export interface IParticleEmitterType {
  12947. /**
  12948. * Called by the particle System when the direction is computed for the created particle.
  12949. * @param worldMatrix is the world matrix of the particle system
  12950. * @param directionToUpdate is the direction vector to update with the result
  12951. * @param particle is the particle we are computed the direction for
  12952. * @param isLocal defines if the direction should be set in local space
  12953. */
  12954. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12955. /**
  12956. * Called by the particle System when the position is computed for the created particle.
  12957. * @param worldMatrix is the world matrix of the particle system
  12958. * @param positionToUpdate is the position vector to update with the result
  12959. * @param particle is the particle we are computed the position for
  12960. * @param isLocal defines if the position should be set in local space
  12961. */
  12962. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12963. /**
  12964. * Clones the current emitter and returns a copy of it
  12965. * @returns the new emitter
  12966. */
  12967. clone(): IParticleEmitterType;
  12968. /**
  12969. * Called by the GPUParticleSystem to setup the update shader
  12970. * @param effect defines the update shader
  12971. */
  12972. applyToShader(effect: Effect): void;
  12973. /**
  12974. * Returns a string to use to update the GPU particles update shader
  12975. * @returns the effect defines string
  12976. */
  12977. getEffectDefines(): string;
  12978. /**
  12979. * Returns a string representing the class name
  12980. * @returns a string containing the class name
  12981. */
  12982. getClassName(): string;
  12983. /**
  12984. * Serializes the particle system to a JSON object.
  12985. * @returns the JSON object
  12986. */
  12987. serialize(): any;
  12988. /**
  12989. * Parse properties from a JSON object
  12990. * @param serializationObject defines the JSON object
  12991. * @param scene defines the hosting scene
  12992. */
  12993. parse(serializationObject: any, scene: Scene): void;
  12994. }
  12995. }
  12996. declare module BABYLON {
  12997. /**
  12998. * Particle emitter emitting particles from the inside of a box.
  12999. * It emits the particles randomly between 2 given directions.
  13000. */
  13001. export class BoxParticleEmitter implements IParticleEmitterType {
  13002. /**
  13003. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13004. */
  13005. direction1: Vector3;
  13006. /**
  13007. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13008. */
  13009. direction2: Vector3;
  13010. /**
  13011. * 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.
  13012. */
  13013. minEmitBox: Vector3;
  13014. /**
  13015. * 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.
  13016. */
  13017. maxEmitBox: Vector3;
  13018. /**
  13019. * Creates a new instance BoxParticleEmitter
  13020. */
  13021. constructor();
  13022. /**
  13023. * Called by the particle System when the direction is computed for the created particle.
  13024. * @param worldMatrix is the world matrix of the particle system
  13025. * @param directionToUpdate is the direction vector to update with the result
  13026. * @param particle is the particle we are computed the direction for
  13027. * @param isLocal defines if the direction should be set in local space
  13028. */
  13029. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13030. /**
  13031. * Called by the particle System when the position is computed for the created particle.
  13032. * @param worldMatrix is the world matrix of the particle system
  13033. * @param positionToUpdate is the position vector to update with the result
  13034. * @param particle is the particle we are computed the position for
  13035. * @param isLocal defines if the position should be set in local space
  13036. */
  13037. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13038. /**
  13039. * Clones the current emitter and returns a copy of it
  13040. * @returns the new emitter
  13041. */
  13042. clone(): BoxParticleEmitter;
  13043. /**
  13044. * Called by the GPUParticleSystem to setup the update shader
  13045. * @param effect defines the update shader
  13046. */
  13047. applyToShader(effect: Effect): void;
  13048. /**
  13049. * Returns a string to use to update the GPU particles update shader
  13050. * @returns a string containng the defines string
  13051. */
  13052. getEffectDefines(): string;
  13053. /**
  13054. * Returns the string "BoxParticleEmitter"
  13055. * @returns a string containing the class name
  13056. */
  13057. getClassName(): string;
  13058. /**
  13059. * Serializes the particle system to a JSON object.
  13060. * @returns the JSON object
  13061. */
  13062. serialize(): any;
  13063. /**
  13064. * Parse properties from a JSON object
  13065. * @param serializationObject defines the JSON object
  13066. */
  13067. parse(serializationObject: any): void;
  13068. }
  13069. }
  13070. declare module BABYLON {
  13071. /**
  13072. * Particle emitter emitting particles from the inside of a cone.
  13073. * It emits the particles alongside the cone volume from the base to the particle.
  13074. * The emission direction might be randomized.
  13075. */
  13076. export class ConeParticleEmitter implements IParticleEmitterType {
  13077. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13078. directionRandomizer: number;
  13079. private _radius;
  13080. private _angle;
  13081. private _height;
  13082. /**
  13083. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13084. */
  13085. radiusRange: number;
  13086. /**
  13087. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13088. */
  13089. heightRange: number;
  13090. /**
  13091. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13092. */
  13093. emitFromSpawnPointOnly: boolean;
  13094. /**
  13095. * Gets or sets the radius of the emission cone
  13096. */
  13097. get radius(): number;
  13098. set radius(value: number);
  13099. /**
  13100. * Gets or sets the angle of the emission cone
  13101. */
  13102. get angle(): number;
  13103. set angle(value: number);
  13104. private _buildHeight;
  13105. /**
  13106. * Creates a new instance ConeParticleEmitter
  13107. * @param radius the radius of the emission cone (1 by default)
  13108. * @param angle the cone base angle (PI by default)
  13109. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13110. */
  13111. constructor(radius?: number, angle?: number,
  13112. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13113. directionRandomizer?: number);
  13114. /**
  13115. * Called by the particle System when the direction is computed for the created particle.
  13116. * @param worldMatrix is the world matrix of the particle system
  13117. * @param directionToUpdate is the direction vector to update with the result
  13118. * @param particle is the particle we are computed the direction for
  13119. * @param isLocal defines if the direction should be set in local space
  13120. */
  13121. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13122. /**
  13123. * Called by the particle System when the position is computed for the created particle.
  13124. * @param worldMatrix is the world matrix of the particle system
  13125. * @param positionToUpdate is the position vector to update with the result
  13126. * @param particle is the particle we are computed the position for
  13127. * @param isLocal defines if the position should be set in local space
  13128. */
  13129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13130. /**
  13131. * Clones the current emitter and returns a copy of it
  13132. * @returns the new emitter
  13133. */
  13134. clone(): ConeParticleEmitter;
  13135. /**
  13136. * Called by the GPUParticleSystem to setup the update shader
  13137. * @param effect defines the update shader
  13138. */
  13139. applyToShader(effect: Effect): void;
  13140. /**
  13141. * Returns a string to use to update the GPU particles update shader
  13142. * @returns a string containng the defines string
  13143. */
  13144. getEffectDefines(): string;
  13145. /**
  13146. * Returns the string "ConeParticleEmitter"
  13147. * @returns a string containing the class name
  13148. */
  13149. getClassName(): string;
  13150. /**
  13151. * Serializes the particle system to a JSON object.
  13152. * @returns the JSON object
  13153. */
  13154. serialize(): any;
  13155. /**
  13156. * Parse properties from a JSON object
  13157. * @param serializationObject defines the JSON object
  13158. */
  13159. parse(serializationObject: any): void;
  13160. }
  13161. }
  13162. declare module BABYLON {
  13163. /**
  13164. * Particle emitter emitting particles from the inside of a cylinder.
  13165. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13166. */
  13167. export class CylinderParticleEmitter implements IParticleEmitterType {
  13168. /**
  13169. * The radius of the emission cylinder.
  13170. */
  13171. radius: number;
  13172. /**
  13173. * The height of the emission cylinder.
  13174. */
  13175. height: number;
  13176. /**
  13177. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13178. */
  13179. radiusRange: number;
  13180. /**
  13181. * How much to randomize the particle direction [0-1].
  13182. */
  13183. directionRandomizer: number;
  13184. /**
  13185. * Creates a new instance CylinderParticleEmitter
  13186. * @param radius the radius of the emission cylinder (1 by default)
  13187. * @param height the height of the emission cylinder (1 by default)
  13188. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13189. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13190. */
  13191. constructor(
  13192. /**
  13193. * The radius of the emission cylinder.
  13194. */
  13195. radius?: number,
  13196. /**
  13197. * The height of the emission cylinder.
  13198. */
  13199. height?: number,
  13200. /**
  13201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13202. */
  13203. radiusRange?: number,
  13204. /**
  13205. * How much to randomize the particle direction [0-1].
  13206. */
  13207. directionRandomizer?: number);
  13208. /**
  13209. * Called by the particle System when the direction is computed for the created particle.
  13210. * @param worldMatrix is the world matrix of the particle system
  13211. * @param directionToUpdate is the direction vector to update with the result
  13212. * @param particle is the particle we are computed the direction for
  13213. * @param isLocal defines if the direction should be set in local space
  13214. */
  13215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13216. /**
  13217. * Called by the particle System when the position is computed for the created particle.
  13218. * @param worldMatrix is the world matrix of the particle system
  13219. * @param positionToUpdate is the position vector to update with the result
  13220. * @param particle is the particle we are computed the position for
  13221. * @param isLocal defines if the position should be set in local space
  13222. */
  13223. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13224. /**
  13225. * Clones the current emitter and returns a copy of it
  13226. * @returns the new emitter
  13227. */
  13228. clone(): CylinderParticleEmitter;
  13229. /**
  13230. * Called by the GPUParticleSystem to setup the update shader
  13231. * @param effect defines the update shader
  13232. */
  13233. applyToShader(effect: Effect): void;
  13234. /**
  13235. * Returns a string to use to update the GPU particles update shader
  13236. * @returns a string containng the defines string
  13237. */
  13238. getEffectDefines(): string;
  13239. /**
  13240. * Returns the string "CylinderParticleEmitter"
  13241. * @returns a string containing the class name
  13242. */
  13243. getClassName(): string;
  13244. /**
  13245. * Serializes the particle system to a JSON object.
  13246. * @returns the JSON object
  13247. */
  13248. serialize(): any;
  13249. /**
  13250. * Parse properties from a JSON object
  13251. * @param serializationObject defines the JSON object
  13252. */
  13253. parse(serializationObject: any): void;
  13254. }
  13255. /**
  13256. * Particle emitter emitting particles from the inside of a cylinder.
  13257. * It emits the particles randomly between two vectors.
  13258. */
  13259. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13260. /**
  13261. * The min limit of the emission direction.
  13262. */
  13263. direction1: Vector3;
  13264. /**
  13265. * The max limit of the emission direction.
  13266. */
  13267. direction2: Vector3;
  13268. /**
  13269. * Creates a new instance CylinderDirectedParticleEmitter
  13270. * @param radius the radius of the emission cylinder (1 by default)
  13271. * @param height the height of the emission cylinder (1 by default)
  13272. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13273. * @param direction1 the min limit of the emission direction (up vector by default)
  13274. * @param direction2 the max limit of the emission direction (up vector by default)
  13275. */
  13276. constructor(radius?: number, height?: number, radiusRange?: number,
  13277. /**
  13278. * The min limit of the emission direction.
  13279. */
  13280. direction1?: Vector3,
  13281. /**
  13282. * The max limit of the emission direction.
  13283. */
  13284. direction2?: Vector3);
  13285. /**
  13286. * Called by the particle System when the direction is computed for the created particle.
  13287. * @param worldMatrix is the world matrix of the particle system
  13288. * @param directionToUpdate is the direction vector to update with the result
  13289. * @param particle is the particle we are computed the direction for
  13290. */
  13291. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13292. /**
  13293. * Clones the current emitter and returns a copy of it
  13294. * @returns the new emitter
  13295. */
  13296. clone(): CylinderDirectedParticleEmitter;
  13297. /**
  13298. * Called by the GPUParticleSystem to setup the update shader
  13299. * @param effect defines the update shader
  13300. */
  13301. applyToShader(effect: Effect): void;
  13302. /**
  13303. * Returns a string to use to update the GPU particles update shader
  13304. * @returns a string containng the defines string
  13305. */
  13306. getEffectDefines(): string;
  13307. /**
  13308. * Returns the string "CylinderDirectedParticleEmitter"
  13309. * @returns a string containing the class name
  13310. */
  13311. getClassName(): string;
  13312. /**
  13313. * Serializes the particle system to a JSON object.
  13314. * @returns the JSON object
  13315. */
  13316. serialize(): any;
  13317. /**
  13318. * Parse properties from a JSON object
  13319. * @param serializationObject defines the JSON object
  13320. */
  13321. parse(serializationObject: any): void;
  13322. }
  13323. }
  13324. declare module BABYLON {
  13325. /**
  13326. * Particle emitter emitting particles from the inside of a hemisphere.
  13327. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13328. */
  13329. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13330. /**
  13331. * The radius of the emission hemisphere.
  13332. */
  13333. radius: number;
  13334. /**
  13335. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13336. */
  13337. radiusRange: number;
  13338. /**
  13339. * How much to randomize the particle direction [0-1].
  13340. */
  13341. directionRandomizer: number;
  13342. /**
  13343. * Creates a new instance HemisphericParticleEmitter
  13344. * @param radius the radius of the emission hemisphere (1 by default)
  13345. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13346. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13347. */
  13348. constructor(
  13349. /**
  13350. * The radius of the emission hemisphere.
  13351. */
  13352. radius?: number,
  13353. /**
  13354. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13355. */
  13356. radiusRange?: number,
  13357. /**
  13358. * How much to randomize the particle direction [0-1].
  13359. */
  13360. directionRandomizer?: number);
  13361. /**
  13362. * Called by the particle System when the direction is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param directionToUpdate is the direction vector to update with the result
  13365. * @param particle is the particle we are computed the direction for
  13366. * @param isLocal defines if the direction should be set in local space
  13367. */
  13368. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Called by the particle System when the position is computed for the created particle.
  13371. * @param worldMatrix is the world matrix of the particle system
  13372. * @param positionToUpdate is the position vector to update with the result
  13373. * @param particle is the particle we are computed the position for
  13374. * @param isLocal defines if the position should be set in local space
  13375. */
  13376. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13377. /**
  13378. * Clones the current emitter and returns a copy of it
  13379. * @returns the new emitter
  13380. */
  13381. clone(): HemisphericParticleEmitter;
  13382. /**
  13383. * Called by the GPUParticleSystem to setup the update shader
  13384. * @param effect defines the update shader
  13385. */
  13386. applyToShader(effect: Effect): void;
  13387. /**
  13388. * Returns a string to use to update the GPU particles update shader
  13389. * @returns a string containng the defines string
  13390. */
  13391. getEffectDefines(): string;
  13392. /**
  13393. * Returns the string "HemisphericParticleEmitter"
  13394. * @returns a string containing the class name
  13395. */
  13396. getClassName(): string;
  13397. /**
  13398. * Serializes the particle system to a JSON object.
  13399. * @returns the JSON object
  13400. */
  13401. serialize(): any;
  13402. /**
  13403. * Parse properties from a JSON object
  13404. * @param serializationObject defines the JSON object
  13405. */
  13406. parse(serializationObject: any): void;
  13407. }
  13408. }
  13409. declare module BABYLON {
  13410. /**
  13411. * Particle emitter emitting particles from a point.
  13412. * It emits the particles randomly between 2 given directions.
  13413. */
  13414. export class PointParticleEmitter implements IParticleEmitterType {
  13415. /**
  13416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13417. */
  13418. direction1: Vector3;
  13419. /**
  13420. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13421. */
  13422. direction2: Vector3;
  13423. /**
  13424. * Creates a new instance PointParticleEmitter
  13425. */
  13426. constructor();
  13427. /**
  13428. * Called by the particle System when the direction is computed for the created particle.
  13429. * @param worldMatrix is the world matrix of the particle system
  13430. * @param directionToUpdate is the direction vector to update with the result
  13431. * @param particle is the particle we are computed the direction for
  13432. * @param isLocal defines if the direction should be set in local space
  13433. */
  13434. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13435. /**
  13436. * Called by the particle System when the position is computed for the created particle.
  13437. * @param worldMatrix is the world matrix of the particle system
  13438. * @param positionToUpdate is the position vector to update with the result
  13439. * @param particle is the particle we are computed the position for
  13440. * @param isLocal defines if the position should be set in local space
  13441. */
  13442. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13443. /**
  13444. * Clones the current emitter and returns a copy of it
  13445. * @returns the new emitter
  13446. */
  13447. clone(): PointParticleEmitter;
  13448. /**
  13449. * Called by the GPUParticleSystem to setup the update shader
  13450. * @param effect defines the update shader
  13451. */
  13452. applyToShader(effect: Effect): void;
  13453. /**
  13454. * Returns a string to use to update the GPU particles update shader
  13455. * @returns a string containng the defines string
  13456. */
  13457. getEffectDefines(): string;
  13458. /**
  13459. * Returns the string "PointParticleEmitter"
  13460. * @returns a string containing the class name
  13461. */
  13462. getClassName(): string;
  13463. /**
  13464. * Serializes the particle system to a JSON object.
  13465. * @returns the JSON object
  13466. */
  13467. serialize(): any;
  13468. /**
  13469. * Parse properties from a JSON object
  13470. * @param serializationObject defines the JSON object
  13471. */
  13472. parse(serializationObject: any): void;
  13473. }
  13474. }
  13475. declare module BABYLON {
  13476. /**
  13477. * Particle emitter emitting particles from the inside of a sphere.
  13478. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13479. */
  13480. export class SphereParticleEmitter implements IParticleEmitterType {
  13481. /**
  13482. * The radius of the emission sphere.
  13483. */
  13484. radius: number;
  13485. /**
  13486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13487. */
  13488. radiusRange: number;
  13489. /**
  13490. * How much to randomize the particle direction [0-1].
  13491. */
  13492. directionRandomizer: number;
  13493. /**
  13494. * Creates a new instance SphereParticleEmitter
  13495. * @param radius the radius of the emission sphere (1 by default)
  13496. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13498. */
  13499. constructor(
  13500. /**
  13501. * The radius of the emission sphere.
  13502. */
  13503. radius?: number,
  13504. /**
  13505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13506. */
  13507. radiusRange?: number,
  13508. /**
  13509. * How much to randomize the particle direction [0-1].
  13510. */
  13511. directionRandomizer?: number);
  13512. /**
  13513. * Called by the particle System when the direction is computed for the created particle.
  13514. * @param worldMatrix is the world matrix of the particle system
  13515. * @param directionToUpdate is the direction vector to update with the result
  13516. * @param particle is the particle we are computed the direction for
  13517. * @param isLocal defines if the direction should be set in local space
  13518. */
  13519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13520. /**
  13521. * Called by the particle System when the position is computed for the created particle.
  13522. * @param worldMatrix is the world matrix of the particle system
  13523. * @param positionToUpdate is the position vector to update with the result
  13524. * @param particle is the particle we are computed the position for
  13525. * @param isLocal defines if the position should be set in local space
  13526. */
  13527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13528. /**
  13529. * Clones the current emitter and returns a copy of it
  13530. * @returns the new emitter
  13531. */
  13532. clone(): SphereParticleEmitter;
  13533. /**
  13534. * Called by the GPUParticleSystem to setup the update shader
  13535. * @param effect defines the update shader
  13536. */
  13537. applyToShader(effect: Effect): void;
  13538. /**
  13539. * Returns a string to use to update the GPU particles update shader
  13540. * @returns a string containng the defines string
  13541. */
  13542. getEffectDefines(): string;
  13543. /**
  13544. * Returns the string "SphereParticleEmitter"
  13545. * @returns a string containing the class name
  13546. */
  13547. getClassName(): string;
  13548. /**
  13549. * Serializes the particle system to a JSON object.
  13550. * @returns the JSON object
  13551. */
  13552. serialize(): any;
  13553. /**
  13554. * Parse properties from a JSON object
  13555. * @param serializationObject defines the JSON object
  13556. */
  13557. parse(serializationObject: any): void;
  13558. }
  13559. /**
  13560. * Particle emitter emitting particles from the inside of a sphere.
  13561. * It emits the particles randomly between two vectors.
  13562. */
  13563. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13564. /**
  13565. * The min limit of the emission direction.
  13566. */
  13567. direction1: Vector3;
  13568. /**
  13569. * The max limit of the emission direction.
  13570. */
  13571. direction2: Vector3;
  13572. /**
  13573. * Creates a new instance SphereDirectedParticleEmitter
  13574. * @param radius the radius of the emission sphere (1 by default)
  13575. * @param direction1 the min limit of the emission direction (up vector by default)
  13576. * @param direction2 the max limit of the emission direction (up vector by default)
  13577. */
  13578. constructor(radius?: number,
  13579. /**
  13580. * The min limit of the emission direction.
  13581. */
  13582. direction1?: Vector3,
  13583. /**
  13584. * The max limit of the emission direction.
  13585. */
  13586. direction2?: Vector3);
  13587. /**
  13588. * Called by the particle System when the direction is computed for the created particle.
  13589. * @param worldMatrix is the world matrix of the particle system
  13590. * @param directionToUpdate is the direction vector to update with the result
  13591. * @param particle is the particle we are computed the direction for
  13592. */
  13593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13594. /**
  13595. * Clones the current emitter and returns a copy of it
  13596. * @returns the new emitter
  13597. */
  13598. clone(): SphereDirectedParticleEmitter;
  13599. /**
  13600. * Called by the GPUParticleSystem to setup the update shader
  13601. * @param effect defines the update shader
  13602. */
  13603. applyToShader(effect: Effect): void;
  13604. /**
  13605. * Returns a string to use to update the GPU particles update shader
  13606. * @returns a string containng the defines string
  13607. */
  13608. getEffectDefines(): string;
  13609. /**
  13610. * Returns the string "SphereDirectedParticleEmitter"
  13611. * @returns a string containing the class name
  13612. */
  13613. getClassName(): string;
  13614. /**
  13615. * Serializes the particle system to a JSON object.
  13616. * @returns the JSON object
  13617. */
  13618. serialize(): any;
  13619. /**
  13620. * Parse properties from a JSON object
  13621. * @param serializationObject defines the JSON object
  13622. */
  13623. parse(serializationObject: any): void;
  13624. }
  13625. }
  13626. declare module BABYLON {
  13627. /**
  13628. * Particle emitter emitting particles from a custom list of positions.
  13629. */
  13630. export class CustomParticleEmitter implements IParticleEmitterType {
  13631. /**
  13632. * Gets or sets the position generator that will create the inital position of each particle.
  13633. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13634. */
  13635. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13636. /**
  13637. * Gets or sets the destination generator that will create the final destination of each particle.
  13638. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13639. */
  13640. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13641. /**
  13642. * Creates a new instance CustomParticleEmitter
  13643. */
  13644. constructor();
  13645. /**
  13646. * Called by the particle System when the direction is computed for the created particle.
  13647. * @param worldMatrix is the world matrix of the particle system
  13648. * @param directionToUpdate is the direction vector to update with the result
  13649. * @param particle is the particle we are computed the direction for
  13650. * @param isLocal defines if the direction should be set in local space
  13651. */
  13652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13653. /**
  13654. * Called by the particle System when the position is computed for the created particle.
  13655. * @param worldMatrix is the world matrix of the particle system
  13656. * @param positionToUpdate is the position vector to update with the result
  13657. * @param particle is the particle we are computed the position for
  13658. * @param isLocal defines if the position should be set in local space
  13659. */
  13660. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13661. /**
  13662. * Clones the current emitter and returns a copy of it
  13663. * @returns the new emitter
  13664. */
  13665. clone(): CustomParticleEmitter;
  13666. /**
  13667. * Called by the GPUParticleSystem to setup the update shader
  13668. * @param effect defines the update shader
  13669. */
  13670. applyToShader(effect: Effect): void;
  13671. /**
  13672. * Returns a string to use to update the GPU particles update shader
  13673. * @returns a string containng the defines string
  13674. */
  13675. getEffectDefines(): string;
  13676. /**
  13677. * Returns the string "PointParticleEmitter"
  13678. * @returns a string containing the class name
  13679. */
  13680. getClassName(): string;
  13681. /**
  13682. * Serializes the particle system to a JSON object.
  13683. * @returns the JSON object
  13684. */
  13685. serialize(): any;
  13686. /**
  13687. * Parse properties from a JSON object
  13688. * @param serializationObject defines the JSON object
  13689. */
  13690. parse(serializationObject: any): void;
  13691. }
  13692. }
  13693. declare module BABYLON {
  13694. /**
  13695. * Particle emitter emitting particles from the inside of a box.
  13696. * It emits the particles randomly between 2 given directions.
  13697. */
  13698. export class MeshParticleEmitter implements IParticleEmitterType {
  13699. private _indices;
  13700. private _positions;
  13701. private _normals;
  13702. private _storedNormal;
  13703. private _mesh;
  13704. /**
  13705. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13706. */
  13707. direction1: Vector3;
  13708. /**
  13709. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13710. */
  13711. direction2: Vector3;
  13712. /**
  13713. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13714. */
  13715. useMeshNormalsForDirection: boolean;
  13716. /** Defines the mesh to use as source */
  13717. get mesh(): Nullable<AbstractMesh>;
  13718. set mesh(value: Nullable<AbstractMesh>);
  13719. /**
  13720. * Creates a new instance MeshParticleEmitter
  13721. * @param mesh defines the mesh to use as source
  13722. */
  13723. constructor(mesh?: Nullable<AbstractMesh>);
  13724. /**
  13725. * Called by the particle System when the direction is computed for the created particle.
  13726. * @param worldMatrix is the world matrix of the particle system
  13727. * @param directionToUpdate is the direction vector to update with the result
  13728. * @param particle is the particle we are computed the direction for
  13729. * @param isLocal defines if the direction should be set in local space
  13730. */
  13731. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13732. /**
  13733. * Called by the particle System when the position is computed for the created particle.
  13734. * @param worldMatrix is the world matrix of the particle system
  13735. * @param positionToUpdate is the position vector to update with the result
  13736. * @param particle is the particle we are computed the position for
  13737. * @param isLocal defines if the position should be set in local space
  13738. */
  13739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13740. /**
  13741. * Clones the current emitter and returns a copy of it
  13742. * @returns the new emitter
  13743. */
  13744. clone(): MeshParticleEmitter;
  13745. /**
  13746. * Called by the GPUParticleSystem to setup the update shader
  13747. * @param effect defines the update shader
  13748. */
  13749. applyToShader(effect: Effect): void;
  13750. /**
  13751. * Returns a string to use to update the GPU particles update shader
  13752. * @returns a string containng the defines string
  13753. */
  13754. getEffectDefines(): string;
  13755. /**
  13756. * Returns the string "BoxParticleEmitter"
  13757. * @returns a string containing the class name
  13758. */
  13759. getClassName(): string;
  13760. /**
  13761. * Serializes the particle system to a JSON object.
  13762. * @returns the JSON object
  13763. */
  13764. serialize(): any;
  13765. /**
  13766. * Parse properties from a JSON object
  13767. * @param serializationObject defines the JSON object
  13768. * @param scene defines the hosting scene
  13769. */
  13770. parse(serializationObject: any, scene: Scene): void;
  13771. }
  13772. }
  13773. declare module BABYLON {
  13774. /**
  13775. * Interface representing a particle system in Babylon.js.
  13776. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13777. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13778. */
  13779. export interface IParticleSystem {
  13780. /**
  13781. * List of animations used by the particle system.
  13782. */
  13783. animations: Animation[];
  13784. /**
  13785. * The id of the Particle system.
  13786. */
  13787. id: string;
  13788. /**
  13789. * The name of the Particle system.
  13790. */
  13791. name: string;
  13792. /**
  13793. * The emitter represents the Mesh or position we are attaching the particle system to.
  13794. */
  13795. emitter: Nullable<AbstractMesh | Vector3>;
  13796. /**
  13797. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13798. */
  13799. isBillboardBased: boolean;
  13800. /**
  13801. * The rendering group used by the Particle system to chose when to render.
  13802. */
  13803. renderingGroupId: number;
  13804. /**
  13805. * The layer mask we are rendering the particles through.
  13806. */
  13807. layerMask: number;
  13808. /**
  13809. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13810. */
  13811. updateSpeed: number;
  13812. /**
  13813. * The amount of time the particle system is running (depends of the overall update speed).
  13814. */
  13815. targetStopDuration: number;
  13816. /**
  13817. * The texture used to render each particle. (this can be a spritesheet)
  13818. */
  13819. particleTexture: Nullable<Texture>;
  13820. /**
  13821. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13822. */
  13823. blendMode: number;
  13824. /**
  13825. * Minimum life time of emitting particles.
  13826. */
  13827. minLifeTime: number;
  13828. /**
  13829. * Maximum life time of emitting particles.
  13830. */
  13831. maxLifeTime: number;
  13832. /**
  13833. * Minimum Size of emitting particles.
  13834. */
  13835. minSize: number;
  13836. /**
  13837. * Maximum Size of emitting particles.
  13838. */
  13839. maxSize: number;
  13840. /**
  13841. * Minimum scale of emitting particles on X axis.
  13842. */
  13843. minScaleX: number;
  13844. /**
  13845. * Maximum scale of emitting particles on X axis.
  13846. */
  13847. maxScaleX: number;
  13848. /**
  13849. * Minimum scale of emitting particles on Y axis.
  13850. */
  13851. minScaleY: number;
  13852. /**
  13853. * Maximum scale of emitting particles on Y axis.
  13854. */
  13855. maxScaleY: number;
  13856. /**
  13857. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13858. */
  13859. color1: Color4;
  13860. /**
  13861. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13862. */
  13863. color2: Color4;
  13864. /**
  13865. * Color the particle will have at the end of its lifetime.
  13866. */
  13867. colorDead: Color4;
  13868. /**
  13869. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13870. */
  13871. emitRate: number;
  13872. /**
  13873. * You can use gravity if you want to give an orientation to your particles.
  13874. */
  13875. gravity: Vector3;
  13876. /**
  13877. * Minimum power of emitting particles.
  13878. */
  13879. minEmitPower: number;
  13880. /**
  13881. * Maximum power of emitting particles.
  13882. */
  13883. maxEmitPower: number;
  13884. /**
  13885. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13886. */
  13887. minAngularSpeed: number;
  13888. /**
  13889. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13890. */
  13891. maxAngularSpeed: number;
  13892. /**
  13893. * Gets or sets the minimal initial rotation in radians.
  13894. */
  13895. minInitialRotation: number;
  13896. /**
  13897. * Gets or sets the maximal initial rotation in radians.
  13898. */
  13899. maxInitialRotation: number;
  13900. /**
  13901. * The particle emitter type defines the emitter used by the particle system.
  13902. * It can be for example box, sphere, or cone...
  13903. */
  13904. particleEmitterType: Nullable<IParticleEmitterType>;
  13905. /**
  13906. * Defines the delay in milliseconds before starting the system (0 by default)
  13907. */
  13908. startDelay: number;
  13909. /**
  13910. * 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
  13911. */
  13912. preWarmCycles: number;
  13913. /**
  13914. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13915. */
  13916. preWarmStepOffset: number;
  13917. /**
  13918. * 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)
  13919. */
  13920. spriteCellChangeSpeed: number;
  13921. /**
  13922. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13923. */
  13924. startSpriteCellID: number;
  13925. /**
  13926. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13927. */
  13928. endSpriteCellID: number;
  13929. /**
  13930. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13931. */
  13932. spriteCellWidth: number;
  13933. /**
  13934. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13935. */
  13936. spriteCellHeight: number;
  13937. /**
  13938. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13939. */
  13940. spriteRandomStartCell: boolean;
  13941. /**
  13942. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13943. */
  13944. isAnimationSheetEnabled: boolean;
  13945. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13946. translationPivot: Vector2;
  13947. /**
  13948. * Gets or sets a texture used to add random noise to particle positions
  13949. */
  13950. noiseTexture: Nullable<BaseTexture>;
  13951. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13952. noiseStrength: Vector3;
  13953. /**
  13954. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13955. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13956. */
  13957. billboardMode: number;
  13958. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13959. limitVelocityDamping: number;
  13960. /**
  13961. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13962. */
  13963. beginAnimationOnStart: boolean;
  13964. /**
  13965. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13966. */
  13967. beginAnimationFrom: number;
  13968. /**
  13969. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13970. */
  13971. beginAnimationTo: number;
  13972. /**
  13973. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13974. */
  13975. beginAnimationLoop: boolean;
  13976. /**
  13977. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13978. */
  13979. disposeOnStop: boolean;
  13980. /**
  13981. * Specifies if the particles are updated in emitter local space or world space
  13982. */
  13983. isLocal: boolean;
  13984. /** Snippet ID if the particle system was created from the snippet server */
  13985. snippetId: string;
  13986. /**
  13987. * Gets the maximum number of particles active at the same time.
  13988. * @returns The max number of active particles.
  13989. */
  13990. getCapacity(): number;
  13991. /**
  13992. * Gets the number of particles active at the same time.
  13993. * @returns The number of active particles.
  13994. */
  13995. getActiveCount(): number;
  13996. /**
  13997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13998. * @returns True if it has been started, otherwise false.
  13999. */
  14000. isStarted(): boolean;
  14001. /**
  14002. * Animates the particle system for this frame.
  14003. */
  14004. animate(): void;
  14005. /**
  14006. * Renders the particle system in its current state.
  14007. * @returns the current number of particles
  14008. */
  14009. render(): number;
  14010. /**
  14011. * Dispose the particle system and frees its associated resources.
  14012. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14013. */
  14014. dispose(disposeTexture?: boolean): void;
  14015. /**
  14016. * An event triggered when the system is disposed
  14017. */
  14018. onDisposeObservable: Observable<IParticleSystem>;
  14019. /**
  14020. * Clones the particle system.
  14021. * @param name The name of the cloned object
  14022. * @param newEmitter The new emitter to use
  14023. * @returns the cloned particle system
  14024. */
  14025. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14026. /**
  14027. * Serializes the particle system to a JSON object
  14028. * @param serializeTexture defines if the texture must be serialized as well
  14029. * @returns the JSON object
  14030. */
  14031. serialize(serializeTexture: boolean): any;
  14032. /**
  14033. * Rebuild the particle system
  14034. */
  14035. rebuild(): void;
  14036. /** Force the system to rebuild all gradients that need to be resync */
  14037. forceRefreshGradients(): void;
  14038. /**
  14039. * Starts the particle system and begins to emit
  14040. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14041. */
  14042. start(delay?: number): void;
  14043. /**
  14044. * Stops the particle system.
  14045. */
  14046. stop(): void;
  14047. /**
  14048. * Remove all active particles
  14049. */
  14050. reset(): void;
  14051. /**
  14052. * Gets a boolean indicating that the system is stopping
  14053. * @returns true if the system is currently stopping
  14054. */
  14055. isStopping(): boolean;
  14056. /**
  14057. * Is this system ready to be used/rendered
  14058. * @return true if the system is ready
  14059. */
  14060. isReady(): boolean;
  14061. /**
  14062. * Returns the string "ParticleSystem"
  14063. * @returns a string containing the class name
  14064. */
  14065. getClassName(): string;
  14066. /**
  14067. * Gets the custom effect used to render the particles
  14068. * @param blendMode Blend mode for which the effect should be retrieved
  14069. * @returns The effect
  14070. */
  14071. getCustomEffect(blendMode: number): Nullable<Effect>;
  14072. /**
  14073. * Sets the custom effect used to render the particles
  14074. * @param effect The effect to set
  14075. * @param blendMode Blend mode for which the effect should be set
  14076. */
  14077. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14078. /**
  14079. * Fill the defines array according to the current settings of the particle system
  14080. * @param defines Array to be updated
  14081. * @param blendMode blend mode to take into account when updating the array
  14082. */
  14083. fillDefines(defines: Array<string>, blendMode: number): void;
  14084. /**
  14085. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14086. * @param uniforms Uniforms array to fill
  14087. * @param attributes Attributes array to fill
  14088. * @param samplers Samplers array to fill
  14089. */
  14090. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14091. /**
  14092. * Observable that will be called just before the particles are drawn
  14093. */
  14094. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14095. /**
  14096. * Gets the name of the particle vertex shader
  14097. */
  14098. vertexShaderName: string;
  14099. /**
  14100. * Adds a new color gradient
  14101. * @param gradient defines the gradient to use (between 0 and 1)
  14102. * @param color1 defines the color to affect to the specified gradient
  14103. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14104. * @returns the current particle system
  14105. */
  14106. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14107. /**
  14108. * Remove a specific color gradient
  14109. * @param gradient defines the gradient to remove
  14110. * @returns the current particle system
  14111. */
  14112. removeColorGradient(gradient: number): IParticleSystem;
  14113. /**
  14114. * Adds a new size gradient
  14115. * @param gradient defines the gradient to use (between 0 and 1)
  14116. * @param factor defines the size factor to affect to the specified gradient
  14117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14118. * @returns the current particle system
  14119. */
  14120. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14121. /**
  14122. * Remove a specific size gradient
  14123. * @param gradient defines the gradient to remove
  14124. * @returns the current particle system
  14125. */
  14126. removeSizeGradient(gradient: number): IParticleSystem;
  14127. /**
  14128. * Gets the current list of color gradients.
  14129. * You must use addColorGradient and removeColorGradient to udpate this list
  14130. * @returns the list of color gradients
  14131. */
  14132. getColorGradients(): Nullable<Array<ColorGradient>>;
  14133. /**
  14134. * Gets the current list of size gradients.
  14135. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14136. * @returns the list of size gradients
  14137. */
  14138. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14139. /**
  14140. * Gets the current list of angular speed gradients.
  14141. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14142. * @returns the list of angular speed gradients
  14143. */
  14144. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14145. /**
  14146. * Adds a new angular speed gradient
  14147. * @param gradient defines the gradient to use (between 0 and 1)
  14148. * @param factor defines the angular speed to affect to the specified gradient
  14149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14150. * @returns the current particle system
  14151. */
  14152. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14153. /**
  14154. * Remove a specific angular speed gradient
  14155. * @param gradient defines the gradient to remove
  14156. * @returns the current particle system
  14157. */
  14158. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14159. /**
  14160. * Gets the current list of velocity gradients.
  14161. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14162. * @returns the list of velocity gradients
  14163. */
  14164. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14165. /**
  14166. * Adds a new velocity gradient
  14167. * @param gradient defines the gradient to use (between 0 and 1)
  14168. * @param factor defines the velocity to affect to the specified gradient
  14169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14170. * @returns the current particle system
  14171. */
  14172. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14173. /**
  14174. * Remove a specific velocity gradient
  14175. * @param gradient defines the gradient to remove
  14176. * @returns the current particle system
  14177. */
  14178. removeVelocityGradient(gradient: number): IParticleSystem;
  14179. /**
  14180. * Gets the current list of limit velocity gradients.
  14181. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14182. * @returns the list of limit velocity gradients
  14183. */
  14184. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14185. /**
  14186. * Adds a new limit velocity gradient
  14187. * @param gradient defines the gradient to use (between 0 and 1)
  14188. * @param factor defines the limit velocity to affect to the specified gradient
  14189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14190. * @returns the current particle system
  14191. */
  14192. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14193. /**
  14194. * Remove a specific limit velocity gradient
  14195. * @param gradient defines the gradient to remove
  14196. * @returns the current particle system
  14197. */
  14198. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14199. /**
  14200. * Adds a new drag gradient
  14201. * @param gradient defines the gradient to use (between 0 and 1)
  14202. * @param factor defines the drag to affect to the specified gradient
  14203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14204. * @returns the current particle system
  14205. */
  14206. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14207. /**
  14208. * Remove a specific drag gradient
  14209. * @param gradient defines the gradient to remove
  14210. * @returns the current particle system
  14211. */
  14212. removeDragGradient(gradient: number): IParticleSystem;
  14213. /**
  14214. * Gets the current list of drag gradients.
  14215. * You must use addDragGradient and removeDragGradient to udpate this list
  14216. * @returns the list of drag gradients
  14217. */
  14218. getDragGradients(): Nullable<Array<FactorGradient>>;
  14219. /**
  14220. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14221. * @param gradient defines the gradient to use (between 0 and 1)
  14222. * @param factor defines the emit rate to affect to the specified gradient
  14223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14224. * @returns the current particle system
  14225. */
  14226. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14227. /**
  14228. * Remove a specific emit rate gradient
  14229. * @param gradient defines the gradient to remove
  14230. * @returns the current particle system
  14231. */
  14232. removeEmitRateGradient(gradient: number): IParticleSystem;
  14233. /**
  14234. * Gets the current list of emit rate gradients.
  14235. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14236. * @returns the list of emit rate gradients
  14237. */
  14238. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14239. /**
  14240. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14241. * @param gradient defines the gradient to use (between 0 and 1)
  14242. * @param factor defines the start size to affect to the specified gradient
  14243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14244. * @returns the current particle system
  14245. */
  14246. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14247. /**
  14248. * Remove a specific start size gradient
  14249. * @param gradient defines the gradient to remove
  14250. * @returns the current particle system
  14251. */
  14252. removeStartSizeGradient(gradient: number): IParticleSystem;
  14253. /**
  14254. * Gets the current list of start size gradients.
  14255. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14256. * @returns the list of start size gradients
  14257. */
  14258. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14259. /**
  14260. * Adds a new life time gradient
  14261. * @param gradient defines the gradient to use (between 0 and 1)
  14262. * @param factor defines the life time factor to affect to the specified gradient
  14263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14264. * @returns the current particle system
  14265. */
  14266. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14267. /**
  14268. * Remove a specific life time gradient
  14269. * @param gradient defines the gradient to remove
  14270. * @returns the current particle system
  14271. */
  14272. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14273. /**
  14274. * Gets the current list of life time gradients.
  14275. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14276. * @returns the list of life time gradients
  14277. */
  14278. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14279. /**
  14280. * Gets the current list of color gradients.
  14281. * You must use addColorGradient and removeColorGradient to udpate this list
  14282. * @returns the list of color gradients
  14283. */
  14284. getColorGradients(): Nullable<Array<ColorGradient>>;
  14285. /**
  14286. * Adds a new ramp gradient used to remap particle colors
  14287. * @param gradient defines the gradient to use (between 0 and 1)
  14288. * @param color defines the color to affect to the specified gradient
  14289. * @returns the current particle system
  14290. */
  14291. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14292. /**
  14293. * Gets the current list of ramp gradients.
  14294. * You must use addRampGradient and removeRampGradient to udpate this list
  14295. * @returns the list of ramp gradients
  14296. */
  14297. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14298. /** Gets or sets a boolean indicating that ramp gradients must be used
  14299. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14300. */
  14301. useRampGradients: boolean;
  14302. /**
  14303. * Adds a new color remap gradient
  14304. * @param gradient defines the gradient to use (between 0 and 1)
  14305. * @param min defines the color remap minimal range
  14306. * @param max defines the color remap maximal range
  14307. * @returns the current particle system
  14308. */
  14309. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14310. /**
  14311. * Gets the current list of color remap gradients.
  14312. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14313. * @returns the list of color remap gradients
  14314. */
  14315. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14316. /**
  14317. * Adds a new alpha remap gradient
  14318. * @param gradient defines the gradient to use (between 0 and 1)
  14319. * @param min defines the alpha remap minimal range
  14320. * @param max defines the alpha remap maximal range
  14321. * @returns the current particle system
  14322. */
  14323. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14324. /**
  14325. * Gets the current list of alpha remap gradients.
  14326. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14327. * @returns the list of alpha remap gradients
  14328. */
  14329. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14330. /**
  14331. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14334. * @returns the emitter
  14335. */
  14336. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14337. /**
  14338. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14339. * @param radius The radius of the hemisphere to emit from
  14340. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14341. * @returns the emitter
  14342. */
  14343. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14344. /**
  14345. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14346. * @param radius The radius of the sphere to emit from
  14347. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14348. * @returns the emitter
  14349. */
  14350. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14351. /**
  14352. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14353. * @param radius The radius of the sphere to emit from
  14354. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14355. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14356. * @returns the emitter
  14357. */
  14358. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14359. /**
  14360. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14361. * @param radius The radius of the emission cylinder
  14362. * @param height The height of the emission cylinder
  14363. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14364. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14365. * @returns the emitter
  14366. */
  14367. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14368. /**
  14369. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14370. * @param radius The radius of the cylinder to emit from
  14371. * @param height The height of the emission cylinder
  14372. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14373. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14374. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14375. * @returns the emitter
  14376. */
  14377. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14378. /**
  14379. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14380. * @param radius The radius of the cone to emit from
  14381. * @param angle The base angle of the cone
  14382. * @returns the emitter
  14383. */
  14384. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14385. /**
  14386. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14387. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14388. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14389. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14390. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14391. * @returns the emitter
  14392. */
  14393. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14394. /**
  14395. * Get hosting scene
  14396. * @returns the scene
  14397. */
  14398. getScene(): Scene;
  14399. }
  14400. }
  14401. declare module BABYLON {
  14402. /**
  14403. * 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.
  14404. * @see https://doc.babylonjs.com/how_to/transformnode
  14405. */
  14406. export class TransformNode extends Node {
  14407. /**
  14408. * Object will not rotate to face the camera
  14409. */
  14410. static BILLBOARDMODE_NONE: number;
  14411. /**
  14412. * Object will rotate to face the camera but only on the x axis
  14413. */
  14414. static BILLBOARDMODE_X: number;
  14415. /**
  14416. * Object will rotate to face the camera but only on the y axis
  14417. */
  14418. static BILLBOARDMODE_Y: number;
  14419. /**
  14420. * Object will rotate to face the camera but only on the z axis
  14421. */
  14422. static BILLBOARDMODE_Z: number;
  14423. /**
  14424. * Object will rotate to face the camera
  14425. */
  14426. static BILLBOARDMODE_ALL: number;
  14427. /**
  14428. * Object will rotate to face the camera's position instead of orientation
  14429. */
  14430. static BILLBOARDMODE_USE_POSITION: number;
  14431. private static _TmpRotation;
  14432. private static _TmpScaling;
  14433. private static _TmpTranslation;
  14434. private _forward;
  14435. private _forwardInverted;
  14436. private _up;
  14437. private _right;
  14438. private _rightInverted;
  14439. private _position;
  14440. private _rotation;
  14441. private _rotationQuaternion;
  14442. protected _scaling: Vector3;
  14443. protected _isDirty: boolean;
  14444. private _transformToBoneReferal;
  14445. private _isAbsoluteSynced;
  14446. private _billboardMode;
  14447. /**
  14448. * Gets or sets the billboard mode. Default is 0.
  14449. *
  14450. * | Value | Type | Description |
  14451. * | --- | --- | --- |
  14452. * | 0 | BILLBOARDMODE_NONE | |
  14453. * | 1 | BILLBOARDMODE_X | |
  14454. * | 2 | BILLBOARDMODE_Y | |
  14455. * | 4 | BILLBOARDMODE_Z | |
  14456. * | 7 | BILLBOARDMODE_ALL | |
  14457. *
  14458. */
  14459. get billboardMode(): number;
  14460. set billboardMode(value: number);
  14461. private _preserveParentRotationForBillboard;
  14462. /**
  14463. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14464. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14465. */
  14466. get preserveParentRotationForBillboard(): boolean;
  14467. set preserveParentRotationForBillboard(value: boolean);
  14468. /**
  14469. * 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
  14470. */
  14471. scalingDeterminant: number;
  14472. private _infiniteDistance;
  14473. /**
  14474. * Gets or sets the distance of the object to max, often used by skybox
  14475. */
  14476. get infiniteDistance(): boolean;
  14477. set infiniteDistance(value: boolean);
  14478. /**
  14479. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14480. * By default the system will update normals to compensate
  14481. */
  14482. ignoreNonUniformScaling: boolean;
  14483. /**
  14484. * 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
  14485. */
  14486. reIntegrateRotationIntoRotationQuaternion: boolean;
  14487. /** @hidden */
  14488. _poseMatrix: Nullable<Matrix>;
  14489. /** @hidden */
  14490. _localMatrix: Matrix;
  14491. private _usePivotMatrix;
  14492. private _absolutePosition;
  14493. private _absoluteScaling;
  14494. private _absoluteRotationQuaternion;
  14495. private _pivotMatrix;
  14496. private _pivotMatrixInverse;
  14497. protected _postMultiplyPivotMatrix: boolean;
  14498. protected _isWorldMatrixFrozen: boolean;
  14499. /** @hidden */
  14500. _indexInSceneTransformNodesArray: number;
  14501. /**
  14502. * An event triggered after the world matrix is updated
  14503. */
  14504. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14505. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14506. /**
  14507. * Gets a string identifying the name of the class
  14508. * @returns "TransformNode" string
  14509. */
  14510. getClassName(): string;
  14511. /**
  14512. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14513. */
  14514. get position(): Vector3;
  14515. set position(newPosition: Vector3);
  14516. /**
  14517. * 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)).
  14518. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14519. */
  14520. get rotation(): Vector3;
  14521. set rotation(newRotation: Vector3);
  14522. /**
  14523. * 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)).
  14524. */
  14525. get scaling(): Vector3;
  14526. set scaling(newScaling: Vector3);
  14527. /**
  14528. * 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).
  14529. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14530. */
  14531. get rotationQuaternion(): Nullable<Quaternion>;
  14532. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14533. /**
  14534. * The forward direction of that transform in world space.
  14535. */
  14536. get forward(): Vector3;
  14537. /**
  14538. * The up direction of that transform in world space.
  14539. */
  14540. get up(): Vector3;
  14541. /**
  14542. * The right direction of that transform in world space.
  14543. */
  14544. get right(): Vector3;
  14545. /**
  14546. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14547. * @param matrix the matrix to copy the pose from
  14548. * @returns this TransformNode.
  14549. */
  14550. updatePoseMatrix(matrix: Matrix): TransformNode;
  14551. /**
  14552. * Returns the mesh Pose matrix.
  14553. * @returns the pose matrix
  14554. */
  14555. getPoseMatrix(): Matrix;
  14556. /** @hidden */
  14557. _isSynchronized(): boolean;
  14558. /** @hidden */
  14559. _initCache(): void;
  14560. /**
  14561. * Flag the transform node as dirty (Forcing it to update everything)
  14562. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14563. * @returns this transform node
  14564. */
  14565. markAsDirty(property: string): TransformNode;
  14566. /**
  14567. * Returns the current mesh absolute position.
  14568. * Returns a Vector3.
  14569. */
  14570. get absolutePosition(): Vector3;
  14571. /**
  14572. * Returns the current mesh absolute scaling.
  14573. * Returns a Vector3.
  14574. */
  14575. get absoluteScaling(): Vector3;
  14576. /**
  14577. * Returns the current mesh absolute rotation.
  14578. * Returns a Quaternion.
  14579. */
  14580. get absoluteRotationQuaternion(): Quaternion;
  14581. /**
  14582. * Sets a new matrix to apply before all other transformation
  14583. * @param matrix defines the transform matrix
  14584. * @returns the current TransformNode
  14585. */
  14586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14587. /**
  14588. * Sets a new pivot matrix to the current node
  14589. * @param matrix defines the new pivot matrix to use
  14590. * @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
  14591. * @returns the current TransformNode
  14592. */
  14593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14594. /**
  14595. * Returns the mesh pivot matrix.
  14596. * Default : Identity.
  14597. * @returns the matrix
  14598. */
  14599. getPivotMatrix(): Matrix;
  14600. /**
  14601. * Instantiate (when possible) or clone that node with its hierarchy
  14602. * @param newParent defines the new parent to use for the instance (or clone)
  14603. * @param options defines options to configure how copy is done
  14604. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14605. * @returns an instance (or a clone) of the current node with its hiearchy
  14606. */
  14607. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14608. doNotInstantiate: boolean;
  14609. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14610. /**
  14611. * Prevents the World matrix to be computed any longer
  14612. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14613. * @returns the TransformNode.
  14614. */
  14615. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14616. /**
  14617. * Allows back the World matrix computation.
  14618. * @returns the TransformNode.
  14619. */
  14620. unfreezeWorldMatrix(): this;
  14621. /**
  14622. * True if the World matrix has been frozen.
  14623. */
  14624. get isWorldMatrixFrozen(): boolean;
  14625. /**
  14626. * Retuns the mesh absolute position in the World.
  14627. * @returns a Vector3.
  14628. */
  14629. getAbsolutePosition(): Vector3;
  14630. /**
  14631. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14632. * @param absolutePosition the absolute position to set
  14633. * @returns the TransformNode.
  14634. */
  14635. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14636. /**
  14637. * Sets the mesh position in its local space.
  14638. * @param vector3 the position to set in localspace
  14639. * @returns the TransformNode.
  14640. */
  14641. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14642. /**
  14643. * Returns the mesh position in the local space from the current World matrix values.
  14644. * @returns a new Vector3.
  14645. */
  14646. getPositionExpressedInLocalSpace(): Vector3;
  14647. /**
  14648. * Translates the mesh along the passed Vector3 in its local space.
  14649. * @param vector3 the distance to translate in localspace
  14650. * @returns the TransformNode.
  14651. */
  14652. locallyTranslate(vector3: Vector3): TransformNode;
  14653. private static _lookAtVectorCache;
  14654. /**
  14655. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14656. * @param targetPoint the position (must be in same space as current mesh) to look at
  14657. * @param yawCor optional yaw (y-axis) correction in radians
  14658. * @param pitchCor optional pitch (x-axis) correction in radians
  14659. * @param rollCor optional roll (z-axis) correction in radians
  14660. * @param space the choosen space of the target
  14661. * @returns the TransformNode.
  14662. */
  14663. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14664. /**
  14665. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14666. * This Vector3 is expressed in the World space.
  14667. * @param localAxis axis to rotate
  14668. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14669. */
  14670. getDirection(localAxis: Vector3): Vector3;
  14671. /**
  14672. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14673. * localAxis is expressed in the mesh local space.
  14674. * result is computed in the Wordl space from the mesh World matrix.
  14675. * @param localAxis axis to rotate
  14676. * @param result the resulting transformnode
  14677. * @returns this TransformNode.
  14678. */
  14679. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14680. /**
  14681. * Sets this transform node rotation to the given local axis.
  14682. * @param localAxis the axis in local space
  14683. * @param yawCor optional yaw (y-axis) correction in radians
  14684. * @param pitchCor optional pitch (x-axis) correction in radians
  14685. * @param rollCor optional roll (z-axis) correction in radians
  14686. * @returns this TransformNode
  14687. */
  14688. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14689. /**
  14690. * Sets a new pivot point to the current node
  14691. * @param point defines the new pivot point to use
  14692. * @param space defines if the point is in world or local space (local by default)
  14693. * @returns the current TransformNode
  14694. */
  14695. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14696. /**
  14697. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14698. * @returns the pivot point
  14699. */
  14700. getPivotPoint(): Vector3;
  14701. /**
  14702. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14703. * @param result the vector3 to store the result
  14704. * @returns this TransformNode.
  14705. */
  14706. getPivotPointToRef(result: Vector3): TransformNode;
  14707. /**
  14708. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14709. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14710. */
  14711. getAbsolutePivotPoint(): Vector3;
  14712. /**
  14713. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14714. * @param result vector3 to store the result
  14715. * @returns this TransformNode.
  14716. */
  14717. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14718. /**
  14719. * Defines the passed node as the parent of the current node.
  14720. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14721. * @see https://doc.babylonjs.com/how_to/parenting
  14722. * @param node the node ot set as the parent
  14723. * @returns this TransformNode.
  14724. */
  14725. setParent(node: Nullable<Node>): TransformNode;
  14726. private _nonUniformScaling;
  14727. /**
  14728. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14729. */
  14730. get nonUniformScaling(): boolean;
  14731. /** @hidden */
  14732. _updateNonUniformScalingState(value: boolean): boolean;
  14733. /**
  14734. * Attach the current TransformNode to another TransformNode associated with a bone
  14735. * @param bone Bone affecting the TransformNode
  14736. * @param affectedTransformNode TransformNode associated with the bone
  14737. * @returns this object
  14738. */
  14739. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14740. /**
  14741. * Detach the transform node if its associated with a bone
  14742. * @returns this object
  14743. */
  14744. detachFromBone(): TransformNode;
  14745. private static _rotationAxisCache;
  14746. /**
  14747. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14748. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14749. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14750. * The passed axis is also normalized.
  14751. * @param axis the axis to rotate around
  14752. * @param amount the amount to rotate in radians
  14753. * @param space Space to rotate in (Default: local)
  14754. * @returns the TransformNode.
  14755. */
  14756. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14757. /**
  14758. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14759. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14760. * The passed axis is also normalized. .
  14761. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14762. * @param point the point to rotate around
  14763. * @param axis the axis to rotate around
  14764. * @param amount the amount to rotate in radians
  14765. * @returns the TransformNode
  14766. */
  14767. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14768. /**
  14769. * Translates the mesh along the axis vector for the passed distance in the given space.
  14770. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14771. * @param axis the axis to translate in
  14772. * @param distance the distance to translate
  14773. * @param space Space to rotate in (Default: local)
  14774. * @returns the TransformNode.
  14775. */
  14776. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14777. /**
  14778. * Adds a rotation step to the mesh current rotation.
  14779. * x, y, z are Euler angles expressed in radians.
  14780. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14781. * This means this rotation is made in the mesh local space only.
  14782. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14783. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14784. * ```javascript
  14785. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14786. * ```
  14787. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14788. * 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.
  14789. * @param x Rotation to add
  14790. * @param y Rotation to add
  14791. * @param z Rotation to add
  14792. * @returns the TransformNode.
  14793. */
  14794. addRotation(x: number, y: number, z: number): TransformNode;
  14795. /**
  14796. * @hidden
  14797. */
  14798. protected _getEffectiveParent(): Nullable<Node>;
  14799. /**
  14800. * Computes the world matrix of the node
  14801. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14802. * @returns the world matrix
  14803. */
  14804. computeWorldMatrix(force?: boolean): Matrix;
  14805. /**
  14806. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14807. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14808. */
  14809. resetLocalMatrix(independentOfChildren?: boolean): void;
  14810. protected _afterComputeWorldMatrix(): void;
  14811. /**
  14812. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14813. * @param func callback function to add
  14814. *
  14815. * @returns the TransformNode.
  14816. */
  14817. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14818. /**
  14819. * Removes a registered callback function.
  14820. * @param func callback function to remove
  14821. * @returns the TransformNode.
  14822. */
  14823. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14824. /**
  14825. * Gets the position of the current mesh in camera space
  14826. * @param camera defines the camera to use
  14827. * @returns a position
  14828. */
  14829. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14830. /**
  14831. * Returns the distance from the mesh to the active camera
  14832. * @param camera defines the camera to use
  14833. * @returns the distance
  14834. */
  14835. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14836. /**
  14837. * Clone the current transform node
  14838. * @param name Name of the new clone
  14839. * @param newParent New parent for the clone
  14840. * @param doNotCloneChildren Do not clone children hierarchy
  14841. * @returns the new transform node
  14842. */
  14843. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14844. /**
  14845. * Serializes the objects information.
  14846. * @param currentSerializationObject defines the object to serialize in
  14847. * @returns the serialized object
  14848. */
  14849. serialize(currentSerializationObject?: any): any;
  14850. /**
  14851. * Returns a new TransformNode object parsed from the source provided.
  14852. * @param parsedTransformNode is the source.
  14853. * @param scene the scne the object belongs to
  14854. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14855. * @returns a new TransformNode object parsed from the source provided.
  14856. */
  14857. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14858. /**
  14859. * Get all child-transformNodes of this node
  14860. * @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
  14861. * @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
  14862. * @returns an array of TransformNode
  14863. */
  14864. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14865. /**
  14866. * Releases resources associated with this transform node.
  14867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14869. */
  14870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14871. /**
  14872. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14873. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14874. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14875. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14876. * @returns the current mesh
  14877. */
  14878. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14879. private _syncAbsoluteScalingAndRotation;
  14880. }
  14881. }
  14882. declare module BABYLON {
  14883. /**
  14884. * Class used to override all child animations of a given target
  14885. */
  14886. export class AnimationPropertiesOverride {
  14887. /**
  14888. * Gets or sets a value indicating if animation blending must be used
  14889. */
  14890. enableBlending: boolean;
  14891. /**
  14892. * Gets or sets the blending speed to use when enableBlending is true
  14893. */
  14894. blendingSpeed: number;
  14895. /**
  14896. * Gets or sets the default loop mode to use
  14897. */
  14898. loopMode: number;
  14899. }
  14900. }
  14901. declare module BABYLON {
  14902. /**
  14903. * Class used to store bone information
  14904. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14905. */
  14906. export class Bone extends Node {
  14907. /**
  14908. * defines the bone name
  14909. */
  14910. name: string;
  14911. private static _tmpVecs;
  14912. private static _tmpQuat;
  14913. private static _tmpMats;
  14914. /**
  14915. * Gets the list of child bones
  14916. */
  14917. children: Bone[];
  14918. /** Gets the animations associated with this bone */
  14919. animations: Animation[];
  14920. /**
  14921. * Gets or sets bone length
  14922. */
  14923. length: number;
  14924. /**
  14925. * @hidden Internal only
  14926. * Set this value to map this bone to a different index in the transform matrices
  14927. * Set this value to -1 to exclude the bone from the transform matrices
  14928. */
  14929. _index: Nullable<number>;
  14930. private _skeleton;
  14931. private _localMatrix;
  14932. private _restPose;
  14933. private _baseMatrix;
  14934. private _absoluteTransform;
  14935. private _invertedAbsoluteTransform;
  14936. private _parent;
  14937. private _scalingDeterminant;
  14938. private _worldTransform;
  14939. private _localScaling;
  14940. private _localRotation;
  14941. private _localPosition;
  14942. private _needToDecompose;
  14943. private _needToCompose;
  14944. /** @hidden */
  14945. _linkedTransformNode: Nullable<TransformNode>;
  14946. /** @hidden */
  14947. _waitingTransformNodeId: Nullable<string>;
  14948. /** @hidden */
  14949. get _matrix(): Matrix;
  14950. /** @hidden */
  14951. set _matrix(value: Matrix);
  14952. /**
  14953. * Create a new bone
  14954. * @param name defines the bone name
  14955. * @param skeleton defines the parent skeleton
  14956. * @param parentBone defines the parent (can be null if the bone is the root)
  14957. * @param localMatrix defines the local matrix
  14958. * @param restPose defines the rest pose matrix
  14959. * @param baseMatrix defines the base matrix
  14960. * @param index defines index of the bone in the hiearchy
  14961. */
  14962. constructor(
  14963. /**
  14964. * defines the bone name
  14965. */
  14966. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14967. /**
  14968. * Gets the current object class name.
  14969. * @return the class name
  14970. */
  14971. getClassName(): string;
  14972. /**
  14973. * Gets the parent skeleton
  14974. * @returns a skeleton
  14975. */
  14976. getSkeleton(): Skeleton;
  14977. /**
  14978. * Gets parent bone
  14979. * @returns a bone or null if the bone is the root of the bone hierarchy
  14980. */
  14981. getParent(): Nullable<Bone>;
  14982. /**
  14983. * Returns an array containing the root bones
  14984. * @returns an array containing the root bones
  14985. */
  14986. getChildren(): Array<Bone>;
  14987. /**
  14988. * Gets the node index in matrix array generated for rendering
  14989. * @returns the node index
  14990. */
  14991. getIndex(): number;
  14992. /**
  14993. * Sets the parent bone
  14994. * @param parent defines the parent (can be null if the bone is the root)
  14995. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14996. */
  14997. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14998. /**
  14999. * Gets the local matrix
  15000. * @returns a matrix
  15001. */
  15002. getLocalMatrix(): Matrix;
  15003. /**
  15004. * Gets the base matrix (initial matrix which remains unchanged)
  15005. * @returns a matrix
  15006. */
  15007. getBaseMatrix(): Matrix;
  15008. /**
  15009. * Gets the rest pose matrix
  15010. * @returns a matrix
  15011. */
  15012. getRestPose(): Matrix;
  15013. /**
  15014. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15015. */
  15016. getWorldMatrix(): Matrix;
  15017. /**
  15018. * Sets the local matrix to rest pose matrix
  15019. */
  15020. returnToRest(): void;
  15021. /**
  15022. * Gets the inverse of the absolute transform matrix.
  15023. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15024. * @returns a matrix
  15025. */
  15026. getInvertedAbsoluteTransform(): Matrix;
  15027. /**
  15028. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15029. * @returns a matrix
  15030. */
  15031. getAbsoluteTransform(): Matrix;
  15032. /**
  15033. * Links with the given transform node.
  15034. * The local matrix of this bone is copied from the transform node every frame.
  15035. * @param transformNode defines the transform node to link to
  15036. */
  15037. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15038. /**
  15039. * Gets the node used to drive the bone's transformation
  15040. * @returns a transform node or null
  15041. */
  15042. getTransformNode(): Nullable<TransformNode>;
  15043. /** Gets or sets current position (in local space) */
  15044. get position(): Vector3;
  15045. set position(newPosition: Vector3);
  15046. /** Gets or sets current rotation (in local space) */
  15047. get rotation(): Vector3;
  15048. set rotation(newRotation: Vector3);
  15049. /** Gets or sets current rotation quaternion (in local space) */
  15050. get rotationQuaternion(): Quaternion;
  15051. set rotationQuaternion(newRotation: Quaternion);
  15052. /** Gets or sets current scaling (in local space) */
  15053. get scaling(): Vector3;
  15054. set scaling(newScaling: Vector3);
  15055. /**
  15056. * Gets the animation properties override
  15057. */
  15058. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15059. private _decompose;
  15060. private _compose;
  15061. /**
  15062. * Update the base and local matrices
  15063. * @param matrix defines the new base or local matrix
  15064. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15065. * @param updateLocalMatrix defines if the local matrix should be updated
  15066. */
  15067. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15068. /** @hidden */
  15069. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15070. /**
  15071. * Flag the bone as dirty (Forcing it to update everything)
  15072. */
  15073. markAsDirty(): void;
  15074. /** @hidden */
  15075. _markAsDirtyAndCompose(): void;
  15076. private _markAsDirtyAndDecompose;
  15077. /**
  15078. * Translate the bone in local or world space
  15079. * @param vec The amount to translate the bone
  15080. * @param space The space that the translation is in
  15081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15082. */
  15083. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15084. /**
  15085. * Set the postion of the bone in local or world space
  15086. * @param position The position to set the bone
  15087. * @param space The space that the position is in
  15088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15089. */
  15090. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15091. /**
  15092. * Set the absolute position of the bone (world space)
  15093. * @param position The position to set the bone
  15094. * @param mesh The mesh that this bone is attached to
  15095. */
  15096. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15097. /**
  15098. * Scale the bone on the x, y and z axes (in local space)
  15099. * @param x The amount to scale the bone on the x axis
  15100. * @param y The amount to scale the bone on the y axis
  15101. * @param z The amount to scale the bone on the z axis
  15102. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15103. */
  15104. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15105. /**
  15106. * Set the bone scaling in local space
  15107. * @param scale defines the scaling vector
  15108. */
  15109. setScale(scale: Vector3): void;
  15110. /**
  15111. * Gets the current scaling in local space
  15112. * @returns the current scaling vector
  15113. */
  15114. getScale(): Vector3;
  15115. /**
  15116. * Gets the current scaling in local space and stores it in a target vector
  15117. * @param result defines the target vector
  15118. */
  15119. getScaleToRef(result: Vector3): void;
  15120. /**
  15121. * Set the yaw, pitch, and roll of the bone in local or world space
  15122. * @param yaw The rotation of the bone on the y axis
  15123. * @param pitch The rotation of the bone on the x axis
  15124. * @param roll The rotation of the bone on the z axis
  15125. * @param space The space that the axes of rotation are in
  15126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15127. */
  15128. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15129. /**
  15130. * Add a rotation to the bone on an axis in local or world space
  15131. * @param axis The axis to rotate the bone on
  15132. * @param amount The amount to rotate the bone
  15133. * @param space The space that the axis is in
  15134. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15135. */
  15136. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15137. /**
  15138. * Set the rotation of the bone to a particular axis angle in local or world space
  15139. * @param axis The axis to rotate the bone on
  15140. * @param angle The angle that the bone should be rotated to
  15141. * @param space The space that the axis is in
  15142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15143. */
  15144. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15145. /**
  15146. * Set the euler rotation of the bone in local of world space
  15147. * @param rotation The euler rotation that the bone should be set to
  15148. * @param space The space that the rotation is in
  15149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15150. */
  15151. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15152. /**
  15153. * Set the quaternion rotation of the bone in local of world space
  15154. * @param quat The quaternion rotation that the bone should be set to
  15155. * @param space The space that the rotation is in
  15156. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15157. */
  15158. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15159. /**
  15160. * Set the rotation matrix of the bone in local of world space
  15161. * @param rotMat The rotation matrix that the bone should be set to
  15162. * @param space The space that the rotation is in
  15163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15164. */
  15165. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15166. private _rotateWithMatrix;
  15167. private _getNegativeRotationToRef;
  15168. /**
  15169. * Get the position of the bone in local or world space
  15170. * @param space The space that the returned position is in
  15171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15172. * @returns The position of the bone
  15173. */
  15174. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15175. /**
  15176. * Copy the position of the bone to a vector3 in local or world space
  15177. * @param space The space that the returned position is in
  15178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15179. * @param result The vector3 to copy the position to
  15180. */
  15181. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15182. /**
  15183. * Get the absolute position of the bone (world space)
  15184. * @param mesh The mesh that this bone is attached to
  15185. * @returns The absolute position of the bone
  15186. */
  15187. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15188. /**
  15189. * Copy the absolute position of the bone (world space) to the result param
  15190. * @param mesh The mesh that this bone is attached to
  15191. * @param result The vector3 to copy the absolute position to
  15192. */
  15193. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15194. /**
  15195. * Compute the absolute transforms of this bone and its children
  15196. */
  15197. computeAbsoluteTransforms(): void;
  15198. /**
  15199. * Get the world direction from an axis that is in the local space of the bone
  15200. * @param localAxis The local direction that is used to compute the world direction
  15201. * @param mesh The mesh that this bone is attached to
  15202. * @returns The world direction
  15203. */
  15204. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15205. /**
  15206. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15207. * @param localAxis The local direction that is used to compute the world direction
  15208. * @param mesh The mesh that this bone is attached to
  15209. * @param result The vector3 that the world direction will be copied to
  15210. */
  15211. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15212. /**
  15213. * Get the euler rotation of the bone in local or world space
  15214. * @param space The space that the rotation should be in
  15215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15216. * @returns The euler rotation
  15217. */
  15218. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15219. /**
  15220. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15221. * @param space The space that the rotation should be in
  15222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15223. * @param result The vector3 that the rotation should be copied to
  15224. */
  15225. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15226. /**
  15227. * Get the quaternion rotation of the bone in either local or world space
  15228. * @param space The space that the rotation should be in
  15229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15230. * @returns The quaternion rotation
  15231. */
  15232. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15233. /**
  15234. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15235. * @param space The space that the rotation should be in
  15236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15237. * @param result The quaternion that the rotation should be copied to
  15238. */
  15239. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15240. /**
  15241. * Get the rotation matrix of the bone in local or world space
  15242. * @param space The space that the rotation should be in
  15243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15244. * @returns The rotation matrix
  15245. */
  15246. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15247. /**
  15248. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15249. * @param space The space that the rotation should be in
  15250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15251. * @param result The quaternion that the rotation should be copied to
  15252. */
  15253. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15254. /**
  15255. * Get the world position of a point that is in the local space of the bone
  15256. * @param position The local position
  15257. * @param mesh The mesh that this bone is attached to
  15258. * @returns The world position
  15259. */
  15260. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15261. /**
  15262. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15263. * @param position The local position
  15264. * @param mesh The mesh that this bone is attached to
  15265. * @param result The vector3 that the world position should be copied to
  15266. */
  15267. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15268. /**
  15269. * Get the local position of a point that is in world space
  15270. * @param position The world position
  15271. * @param mesh The mesh that this bone is attached to
  15272. * @returns The local position
  15273. */
  15274. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15275. /**
  15276. * Get the local position of a point that is in world space and copy it to the result param
  15277. * @param position The world position
  15278. * @param mesh The mesh that this bone is attached to
  15279. * @param result The vector3 that the local position should be copied to
  15280. */
  15281. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15282. }
  15283. }
  15284. declare module BABYLON {
  15285. /**
  15286. * Defines a runtime animation
  15287. */
  15288. export class RuntimeAnimation {
  15289. private _events;
  15290. /**
  15291. * The current frame of the runtime animation
  15292. */
  15293. private _currentFrame;
  15294. /**
  15295. * The animation used by the runtime animation
  15296. */
  15297. private _animation;
  15298. /**
  15299. * The target of the runtime animation
  15300. */
  15301. private _target;
  15302. /**
  15303. * The initiating animatable
  15304. */
  15305. private _host;
  15306. /**
  15307. * The original value of the runtime animation
  15308. */
  15309. private _originalValue;
  15310. /**
  15311. * The original blend value of the runtime animation
  15312. */
  15313. private _originalBlendValue;
  15314. /**
  15315. * The offsets cache of the runtime animation
  15316. */
  15317. private _offsetsCache;
  15318. /**
  15319. * The high limits cache of the runtime animation
  15320. */
  15321. private _highLimitsCache;
  15322. /**
  15323. * Specifies if the runtime animation has been stopped
  15324. */
  15325. private _stopped;
  15326. /**
  15327. * The blending factor of the runtime animation
  15328. */
  15329. private _blendingFactor;
  15330. /**
  15331. * The BabylonJS scene
  15332. */
  15333. private _scene;
  15334. /**
  15335. * The current value of the runtime animation
  15336. */
  15337. private _currentValue;
  15338. /** @hidden */
  15339. _animationState: _IAnimationState;
  15340. /**
  15341. * The active target of the runtime animation
  15342. */
  15343. private _activeTargets;
  15344. private _currentActiveTarget;
  15345. private _directTarget;
  15346. /**
  15347. * The target path of the runtime animation
  15348. */
  15349. private _targetPath;
  15350. /**
  15351. * The weight of the runtime animation
  15352. */
  15353. private _weight;
  15354. /**
  15355. * The ratio offset of the runtime animation
  15356. */
  15357. private _ratioOffset;
  15358. /**
  15359. * The previous delay of the runtime animation
  15360. */
  15361. private _previousDelay;
  15362. /**
  15363. * The previous ratio of the runtime animation
  15364. */
  15365. private _previousRatio;
  15366. private _enableBlending;
  15367. private _keys;
  15368. private _minFrame;
  15369. private _maxFrame;
  15370. private _minValue;
  15371. private _maxValue;
  15372. private _targetIsArray;
  15373. /**
  15374. * Gets the current frame of the runtime animation
  15375. */
  15376. get currentFrame(): number;
  15377. /**
  15378. * Gets the weight of the runtime animation
  15379. */
  15380. get weight(): number;
  15381. /**
  15382. * Gets the current value of the runtime animation
  15383. */
  15384. get currentValue(): any;
  15385. /**
  15386. * Gets the target path of the runtime animation
  15387. */
  15388. get targetPath(): string;
  15389. /**
  15390. * Gets the actual target of the runtime animation
  15391. */
  15392. get target(): any;
  15393. /**
  15394. * Gets the additive state of the runtime animation
  15395. */
  15396. get isAdditive(): boolean;
  15397. /** @hidden */
  15398. _onLoop: () => void;
  15399. /**
  15400. * Create a new RuntimeAnimation object
  15401. * @param target defines the target of the animation
  15402. * @param animation defines the source animation object
  15403. * @param scene defines the hosting scene
  15404. * @param host defines the initiating Animatable
  15405. */
  15406. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15407. private _preparePath;
  15408. /**
  15409. * Gets the animation from the runtime animation
  15410. */
  15411. get animation(): Animation;
  15412. /**
  15413. * Resets the runtime animation to the beginning
  15414. * @param restoreOriginal defines whether to restore the target property to the original value
  15415. */
  15416. reset(restoreOriginal?: boolean): void;
  15417. /**
  15418. * Specifies if the runtime animation is stopped
  15419. * @returns Boolean specifying if the runtime animation is stopped
  15420. */
  15421. isStopped(): boolean;
  15422. /**
  15423. * Disposes of the runtime animation
  15424. */
  15425. dispose(): void;
  15426. /**
  15427. * Apply the interpolated value to the target
  15428. * @param currentValue defines the value computed by the animation
  15429. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15430. */
  15431. setValue(currentValue: any, weight: number): void;
  15432. private _getOriginalValues;
  15433. private _setValue;
  15434. /**
  15435. * Gets the loop pmode of the runtime animation
  15436. * @returns Loop Mode
  15437. */
  15438. private _getCorrectLoopMode;
  15439. /**
  15440. * Move the current animation to a given frame
  15441. * @param frame defines the frame to move to
  15442. */
  15443. goToFrame(frame: number): void;
  15444. /**
  15445. * @hidden Internal use only
  15446. */
  15447. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15448. /**
  15449. * Execute the current animation
  15450. * @param delay defines the delay to add to the current frame
  15451. * @param from defines the lower bound of the animation range
  15452. * @param to defines the upper bound of the animation range
  15453. * @param loop defines if the current animation must loop
  15454. * @param speedRatio defines the current speed ratio
  15455. * @param weight defines the weight of the animation (default is -1 so no weight)
  15456. * @param onLoop optional callback called when animation loops
  15457. * @returns a boolean indicating if the animation is running
  15458. */
  15459. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15460. }
  15461. }
  15462. declare module BABYLON {
  15463. /**
  15464. * Class used to store an actual running animation
  15465. */
  15466. export class Animatable {
  15467. /** defines the target object */
  15468. target: any;
  15469. /** defines the starting frame number (default is 0) */
  15470. fromFrame: number;
  15471. /** defines the ending frame number (default is 100) */
  15472. toFrame: number;
  15473. /** defines if the animation must loop (default is false) */
  15474. loopAnimation: boolean;
  15475. /** defines a callback to call when animation ends if it is not looping */
  15476. onAnimationEnd?: (() => void) | null | undefined;
  15477. /** defines a callback to call when animation loops */
  15478. onAnimationLoop?: (() => void) | null | undefined;
  15479. /** defines whether the animation should be evaluated additively */
  15480. isAdditive: boolean;
  15481. private _localDelayOffset;
  15482. private _pausedDelay;
  15483. private _runtimeAnimations;
  15484. private _paused;
  15485. private _scene;
  15486. private _speedRatio;
  15487. private _weight;
  15488. private _syncRoot;
  15489. /**
  15490. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15491. * This will only apply for non looping animation (default is true)
  15492. */
  15493. disposeOnEnd: boolean;
  15494. /**
  15495. * Gets a boolean indicating if the animation has started
  15496. */
  15497. animationStarted: boolean;
  15498. /**
  15499. * Observer raised when the animation ends
  15500. */
  15501. onAnimationEndObservable: Observable<Animatable>;
  15502. /**
  15503. * Observer raised when the animation loops
  15504. */
  15505. onAnimationLoopObservable: Observable<Animatable>;
  15506. /**
  15507. * Gets the root Animatable used to synchronize and normalize animations
  15508. */
  15509. get syncRoot(): Nullable<Animatable>;
  15510. /**
  15511. * Gets the current frame of the first RuntimeAnimation
  15512. * Used to synchronize Animatables
  15513. */
  15514. get masterFrame(): number;
  15515. /**
  15516. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15517. */
  15518. get weight(): number;
  15519. set weight(value: number);
  15520. /**
  15521. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15522. */
  15523. get speedRatio(): number;
  15524. set speedRatio(value: number);
  15525. /**
  15526. * Creates a new Animatable
  15527. * @param scene defines the hosting scene
  15528. * @param target defines the target object
  15529. * @param fromFrame defines the starting frame number (default is 0)
  15530. * @param toFrame defines the ending frame number (default is 100)
  15531. * @param loopAnimation defines if the animation must loop (default is false)
  15532. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15533. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15534. * @param animations defines a group of animation to add to the new Animatable
  15535. * @param onAnimationLoop defines a callback to call when animation loops
  15536. * @param isAdditive defines whether the animation should be evaluated additively
  15537. */
  15538. constructor(scene: Scene,
  15539. /** defines the target object */
  15540. target: any,
  15541. /** defines the starting frame number (default is 0) */
  15542. fromFrame?: number,
  15543. /** defines the ending frame number (default is 100) */
  15544. toFrame?: number,
  15545. /** defines if the animation must loop (default is false) */
  15546. loopAnimation?: boolean, speedRatio?: number,
  15547. /** defines a callback to call when animation ends if it is not looping */
  15548. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15549. /** defines a callback to call when animation loops */
  15550. onAnimationLoop?: (() => void) | null | undefined,
  15551. /** defines whether the animation should be evaluated additively */
  15552. isAdditive?: boolean);
  15553. /**
  15554. * Synchronize and normalize current Animatable with a source Animatable
  15555. * This is useful when using animation weights and when animations are not of the same length
  15556. * @param root defines the root Animatable to synchronize with
  15557. * @returns the current Animatable
  15558. */
  15559. syncWith(root: Animatable): Animatable;
  15560. /**
  15561. * Gets the list of runtime animations
  15562. * @returns an array of RuntimeAnimation
  15563. */
  15564. getAnimations(): RuntimeAnimation[];
  15565. /**
  15566. * Adds more animations to the current animatable
  15567. * @param target defines the target of the animations
  15568. * @param animations defines the new animations to add
  15569. */
  15570. appendAnimations(target: any, animations: Animation[]): void;
  15571. /**
  15572. * Gets the source animation for a specific property
  15573. * @param property defines the propertyu to look for
  15574. * @returns null or the source animation for the given property
  15575. */
  15576. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15577. /**
  15578. * Gets the runtime animation for a specific property
  15579. * @param property defines the propertyu to look for
  15580. * @returns null or the runtime animation for the given property
  15581. */
  15582. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15583. /**
  15584. * Resets the animatable to its original state
  15585. */
  15586. reset(): void;
  15587. /**
  15588. * Allows the animatable to blend with current running animations
  15589. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15590. * @param blendingSpeed defines the blending speed to use
  15591. */
  15592. enableBlending(blendingSpeed: number): void;
  15593. /**
  15594. * Disable animation blending
  15595. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15596. */
  15597. disableBlending(): void;
  15598. /**
  15599. * Jump directly to a given frame
  15600. * @param frame defines the frame to jump to
  15601. */
  15602. goToFrame(frame: number): void;
  15603. /**
  15604. * Pause the animation
  15605. */
  15606. pause(): void;
  15607. /**
  15608. * Restart the animation
  15609. */
  15610. restart(): void;
  15611. private _raiseOnAnimationEnd;
  15612. /**
  15613. * Stop and delete the current animation
  15614. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15615. * @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)
  15616. */
  15617. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15618. /**
  15619. * Wait asynchronously for the animation to end
  15620. * @returns a promise which will be fullfilled when the animation ends
  15621. */
  15622. waitAsync(): Promise<Animatable>;
  15623. /** @hidden */
  15624. _animate(delay: number): boolean;
  15625. }
  15626. interface Scene {
  15627. /** @hidden */
  15628. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15629. /** @hidden */
  15630. _processLateAnimationBindingsForMatrices(holder: {
  15631. totalWeight: number;
  15632. totalAdditiveWeight: number;
  15633. animations: RuntimeAnimation[];
  15634. additiveAnimations: RuntimeAnimation[];
  15635. originalValue: Matrix;
  15636. }): any;
  15637. /** @hidden */
  15638. _processLateAnimationBindingsForQuaternions(holder: {
  15639. totalWeight: number;
  15640. totalAdditiveWeight: number;
  15641. animations: RuntimeAnimation[];
  15642. additiveAnimations: RuntimeAnimation[];
  15643. originalValue: Quaternion;
  15644. }, refQuaternion: Quaternion): Quaternion;
  15645. /** @hidden */
  15646. _processLateAnimationBindings(): void;
  15647. /**
  15648. * Will start the animation sequence of a given target
  15649. * @param target defines the target
  15650. * @param from defines from which frame should animation start
  15651. * @param to defines until which frame should animation run.
  15652. * @param weight defines the weight to apply to the animation (1.0 by default)
  15653. * @param loop defines if the animation loops
  15654. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15655. * @param onAnimationEnd defines the function to be executed when the animation ends
  15656. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15657. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15658. * @param onAnimationLoop defines the callback to call when an animation loops
  15659. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15660. * @returns the animatable object created for this animation
  15661. */
  15662. 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;
  15663. /**
  15664. * Will start the animation sequence of a given target
  15665. * @param target defines the target
  15666. * @param from defines from which frame should animation start
  15667. * @param to defines until which frame should animation run.
  15668. * @param loop defines if the animation loops
  15669. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15670. * @param onAnimationEnd defines the function to be executed when the animation ends
  15671. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15672. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15673. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15674. * @param onAnimationLoop defines the callback to call when an animation loops
  15675. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15676. * @returns the animatable object created for this animation
  15677. */
  15678. 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;
  15679. /**
  15680. * Will start the animation sequence of a given target and its hierarchy
  15681. * @param target defines the target
  15682. * @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.
  15683. * @param from defines from which frame should animation start
  15684. * @param to defines until which frame should animation run.
  15685. * @param loop defines if the animation loops
  15686. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15687. * @param onAnimationEnd defines the function to be executed when the animation ends
  15688. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15689. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15690. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15691. * @param onAnimationLoop defines the callback to call when an animation loops
  15692. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15693. * @returns the list of created animatables
  15694. */
  15695. 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[];
  15696. /**
  15697. * Begin a new animation on a given node
  15698. * @param target defines the target where the animation will take place
  15699. * @param animations defines the list of animations to start
  15700. * @param from defines the initial value
  15701. * @param to defines the final value
  15702. * @param loop defines if you want animation to loop (off by default)
  15703. * @param speedRatio defines the speed ratio to apply to all animations
  15704. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15705. * @param onAnimationLoop defines the callback to call when an animation loops
  15706. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15707. * @returns the list of created animatables
  15708. */
  15709. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15710. /**
  15711. * Begin a new animation on a given node and its hierarchy
  15712. * @param target defines the root node where the animation will take place
  15713. * @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.
  15714. * @param animations defines the list of animations to start
  15715. * @param from defines the initial value
  15716. * @param to defines the final value
  15717. * @param loop defines if you want animation to loop (off by default)
  15718. * @param speedRatio defines the speed ratio to apply to all animations
  15719. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15720. * @param onAnimationLoop defines the callback to call when an animation loops
  15721. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15722. * @returns the list of animatables created for all nodes
  15723. */
  15724. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15725. /**
  15726. * Gets the animatable associated with a specific target
  15727. * @param target defines the target of the animatable
  15728. * @returns the required animatable if found
  15729. */
  15730. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15731. /**
  15732. * Gets all animatables associated with a given target
  15733. * @param target defines the target to look animatables for
  15734. * @returns an array of Animatables
  15735. */
  15736. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15737. /**
  15738. * Stops and removes all animations that have been applied to the scene
  15739. */
  15740. stopAllAnimations(): void;
  15741. /**
  15742. * Gets the current delta time used by animation engine
  15743. */
  15744. deltaTime: number;
  15745. }
  15746. interface Bone {
  15747. /**
  15748. * Copy an animation range from another bone
  15749. * @param source defines the source bone
  15750. * @param rangeName defines the range name to copy
  15751. * @param frameOffset defines the frame offset
  15752. * @param rescaleAsRequired defines if rescaling must be applied if required
  15753. * @param skelDimensionsRatio defines the scaling ratio
  15754. * @returns true if operation was successful
  15755. */
  15756. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15757. }
  15758. }
  15759. declare module BABYLON {
  15760. /**
  15761. * Class used to handle skinning animations
  15762. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15763. */
  15764. export class Skeleton implements IAnimatable {
  15765. /** defines the skeleton name */
  15766. name: string;
  15767. /** defines the skeleton Id */
  15768. id: string;
  15769. /**
  15770. * Defines the list of child bones
  15771. */
  15772. bones: Bone[];
  15773. /**
  15774. * Defines an estimate of the dimension of the skeleton at rest
  15775. */
  15776. dimensionsAtRest: Vector3;
  15777. /**
  15778. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15779. */
  15780. needInitialSkinMatrix: boolean;
  15781. /**
  15782. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15783. */
  15784. overrideMesh: Nullable<AbstractMesh>;
  15785. /**
  15786. * Gets the list of animations attached to this skeleton
  15787. */
  15788. animations: Array<Animation>;
  15789. private _scene;
  15790. private _isDirty;
  15791. private _transformMatrices;
  15792. private _transformMatrixTexture;
  15793. private _meshesWithPoseMatrix;
  15794. private _animatables;
  15795. private _identity;
  15796. private _synchronizedWithMesh;
  15797. private _ranges;
  15798. private _lastAbsoluteTransformsUpdateId;
  15799. private _canUseTextureForBones;
  15800. private _uniqueId;
  15801. /** @hidden */
  15802. _numBonesWithLinkedTransformNode: number;
  15803. /** @hidden */
  15804. _hasWaitingData: Nullable<boolean>;
  15805. /**
  15806. * Specifies if the skeleton should be serialized
  15807. */
  15808. doNotSerialize: boolean;
  15809. private _useTextureToStoreBoneMatrices;
  15810. /**
  15811. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15812. * Please note that this option is not available if the hardware does not support it
  15813. */
  15814. get useTextureToStoreBoneMatrices(): boolean;
  15815. set useTextureToStoreBoneMatrices(value: boolean);
  15816. private _animationPropertiesOverride;
  15817. /**
  15818. * Gets or sets the animation properties override
  15819. */
  15820. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15821. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15822. /**
  15823. * List of inspectable custom properties (used by the Inspector)
  15824. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15825. */
  15826. inspectableCustomProperties: IInspectable[];
  15827. /**
  15828. * An observable triggered before computing the skeleton's matrices
  15829. */
  15830. onBeforeComputeObservable: Observable<Skeleton>;
  15831. /**
  15832. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15833. */
  15834. get isUsingTextureForMatrices(): boolean;
  15835. /**
  15836. * Gets the unique ID of this skeleton
  15837. */
  15838. get uniqueId(): number;
  15839. /**
  15840. * Creates a new skeleton
  15841. * @param name defines the skeleton name
  15842. * @param id defines the skeleton Id
  15843. * @param scene defines the hosting scene
  15844. */
  15845. constructor(
  15846. /** defines the skeleton name */
  15847. name: string,
  15848. /** defines the skeleton Id */
  15849. id: string, scene: Scene);
  15850. /**
  15851. * Gets the current object class name.
  15852. * @return the class name
  15853. */
  15854. getClassName(): string;
  15855. /**
  15856. * Returns an array containing the root bones
  15857. * @returns an array containing the root bones
  15858. */
  15859. getChildren(): Array<Bone>;
  15860. /**
  15861. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15862. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15863. * @returns a Float32Array containing matrices data
  15864. */
  15865. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15866. /**
  15867. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15868. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15869. * @returns a raw texture containing the data
  15870. */
  15871. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15872. /**
  15873. * Gets the current hosting scene
  15874. * @returns a scene object
  15875. */
  15876. getScene(): Scene;
  15877. /**
  15878. * Gets a string representing the current skeleton data
  15879. * @param fullDetails defines a boolean indicating if we want a verbose version
  15880. * @returns a string representing the current skeleton data
  15881. */
  15882. toString(fullDetails?: boolean): string;
  15883. /**
  15884. * Get bone's index searching by name
  15885. * @param name defines bone's name to search for
  15886. * @return the indice of the bone. Returns -1 if not found
  15887. */
  15888. getBoneIndexByName(name: string): number;
  15889. /**
  15890. * Creater a new animation range
  15891. * @param name defines the name of the range
  15892. * @param from defines the start key
  15893. * @param to defines the end key
  15894. */
  15895. createAnimationRange(name: string, from: number, to: number): void;
  15896. /**
  15897. * Delete a specific animation range
  15898. * @param name defines the name of the range
  15899. * @param deleteFrames defines if frames must be removed as well
  15900. */
  15901. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15902. /**
  15903. * Gets a specific animation range
  15904. * @param name defines the name of the range to look for
  15905. * @returns the requested animation range or null if not found
  15906. */
  15907. getAnimationRange(name: string): Nullable<AnimationRange>;
  15908. /**
  15909. * Gets the list of all animation ranges defined on this skeleton
  15910. * @returns an array
  15911. */
  15912. getAnimationRanges(): Nullable<AnimationRange>[];
  15913. /**
  15914. * Copy animation range from a source skeleton.
  15915. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15916. * @param source defines the source skeleton
  15917. * @param name defines the name of the range to copy
  15918. * @param rescaleAsRequired defines if rescaling must be applied if required
  15919. * @returns true if operation was successful
  15920. */
  15921. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15922. /**
  15923. * Forces the skeleton to go to rest pose
  15924. */
  15925. returnToRest(): void;
  15926. private _getHighestAnimationFrame;
  15927. /**
  15928. * Begin a specific animation range
  15929. * @param name defines the name of the range to start
  15930. * @param loop defines if looping must be turned on (false by default)
  15931. * @param speedRatio defines the speed ratio to apply (1 by default)
  15932. * @param onAnimationEnd defines a callback which will be called when animation will end
  15933. * @returns a new animatable
  15934. */
  15935. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15936. /**
  15937. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15938. * @param skeleton defines the Skeleton containing the animation range to convert
  15939. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15940. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15941. * @returns the original skeleton
  15942. */
  15943. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15944. /** @hidden */
  15945. _markAsDirty(): void;
  15946. /** @hidden */
  15947. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15948. /** @hidden */
  15949. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15950. private _computeTransformMatrices;
  15951. /**
  15952. * Build all resources required to render a skeleton
  15953. */
  15954. prepare(): void;
  15955. /**
  15956. * Gets the list of animatables currently running for this skeleton
  15957. * @returns an array of animatables
  15958. */
  15959. getAnimatables(): IAnimatable[];
  15960. /**
  15961. * Clone the current skeleton
  15962. * @param name defines the name of the new skeleton
  15963. * @param id defines the id of the new skeleton
  15964. * @returns the new skeleton
  15965. */
  15966. clone(name: string, id?: string): Skeleton;
  15967. /**
  15968. * Enable animation blending for this skeleton
  15969. * @param blendingSpeed defines the blending speed to apply
  15970. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15971. */
  15972. enableBlending(blendingSpeed?: number): void;
  15973. /**
  15974. * Releases all resources associated with the current skeleton
  15975. */
  15976. dispose(): void;
  15977. /**
  15978. * Serialize the skeleton in a JSON object
  15979. * @returns a JSON object
  15980. */
  15981. serialize(): any;
  15982. /**
  15983. * Creates a new skeleton from serialized data
  15984. * @param parsedSkeleton defines the serialized data
  15985. * @param scene defines the hosting scene
  15986. * @returns a new skeleton
  15987. */
  15988. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15989. /**
  15990. * Compute all node absolute transforms
  15991. * @param forceUpdate defines if computation must be done even if cache is up to date
  15992. */
  15993. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15994. /**
  15995. * Gets the root pose matrix
  15996. * @returns a matrix
  15997. */
  15998. getPoseMatrix(): Nullable<Matrix>;
  15999. /**
  16000. * Sorts bones per internal index
  16001. */
  16002. sortBones(): void;
  16003. private _sortBones;
  16004. }
  16005. }
  16006. declare module BABYLON {
  16007. /**
  16008. * Creates an instance based on a source mesh.
  16009. */
  16010. export class InstancedMesh extends AbstractMesh {
  16011. private _sourceMesh;
  16012. private _currentLOD;
  16013. /** @hidden */
  16014. _indexInSourceMeshInstanceArray: number;
  16015. constructor(name: string, source: Mesh);
  16016. /**
  16017. * Returns the string "InstancedMesh".
  16018. */
  16019. getClassName(): string;
  16020. /** Gets the list of lights affecting that mesh */
  16021. get lightSources(): Light[];
  16022. _resyncLightSources(): void;
  16023. _resyncLightSource(light: Light): void;
  16024. _removeLightSource(light: Light, dispose: boolean): void;
  16025. /**
  16026. * If the source mesh receives shadows
  16027. */
  16028. get receiveShadows(): boolean;
  16029. /**
  16030. * The material of the source mesh
  16031. */
  16032. get material(): Nullable<Material>;
  16033. /**
  16034. * Visibility of the source mesh
  16035. */
  16036. get visibility(): number;
  16037. /**
  16038. * Skeleton of the source mesh
  16039. */
  16040. get skeleton(): Nullable<Skeleton>;
  16041. /**
  16042. * Rendering ground id of the source mesh
  16043. */
  16044. get renderingGroupId(): number;
  16045. set renderingGroupId(value: number);
  16046. /**
  16047. * Returns the total number of vertices (integer).
  16048. */
  16049. getTotalVertices(): number;
  16050. /**
  16051. * Returns a positive integer : the total number of indices in this mesh geometry.
  16052. * @returns the numner of indices or zero if the mesh has no geometry.
  16053. */
  16054. getTotalIndices(): number;
  16055. /**
  16056. * The source mesh of the instance
  16057. */
  16058. get sourceMesh(): Mesh;
  16059. /**
  16060. * Creates a new InstancedMesh object from the mesh model.
  16061. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16062. * @param name defines the name of the new instance
  16063. * @returns a new InstancedMesh
  16064. */
  16065. createInstance(name: string): InstancedMesh;
  16066. /**
  16067. * Is this node ready to be used/rendered
  16068. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16069. * @return {boolean} is it ready
  16070. */
  16071. isReady(completeCheck?: boolean): boolean;
  16072. /**
  16073. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16074. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16075. * @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.
  16076. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16077. */
  16078. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16079. /**
  16080. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16081. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16082. * The `data` are either a numeric array either a Float32Array.
  16083. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16084. * 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).
  16085. * Note that a new underlying VertexBuffer object is created each call.
  16086. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16087. *
  16088. * Possible `kind` values :
  16089. * - VertexBuffer.PositionKind
  16090. * - VertexBuffer.UVKind
  16091. * - VertexBuffer.UV2Kind
  16092. * - VertexBuffer.UV3Kind
  16093. * - VertexBuffer.UV4Kind
  16094. * - VertexBuffer.UV5Kind
  16095. * - VertexBuffer.UV6Kind
  16096. * - VertexBuffer.ColorKind
  16097. * - VertexBuffer.MatricesIndicesKind
  16098. * - VertexBuffer.MatricesIndicesExtraKind
  16099. * - VertexBuffer.MatricesWeightsKind
  16100. * - VertexBuffer.MatricesWeightsExtraKind
  16101. *
  16102. * Returns the Mesh.
  16103. */
  16104. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16105. /**
  16106. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16107. * If the mesh has no geometry, it is simply returned as it is.
  16108. * The `data` are either a numeric array either a Float32Array.
  16109. * No new underlying VertexBuffer object is created.
  16110. * 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.
  16111. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16112. *
  16113. * Possible `kind` values :
  16114. * - VertexBuffer.PositionKind
  16115. * - VertexBuffer.UVKind
  16116. * - VertexBuffer.UV2Kind
  16117. * - VertexBuffer.UV3Kind
  16118. * - VertexBuffer.UV4Kind
  16119. * - VertexBuffer.UV5Kind
  16120. * - VertexBuffer.UV6Kind
  16121. * - VertexBuffer.ColorKind
  16122. * - VertexBuffer.MatricesIndicesKind
  16123. * - VertexBuffer.MatricesIndicesExtraKind
  16124. * - VertexBuffer.MatricesWeightsKind
  16125. * - VertexBuffer.MatricesWeightsExtraKind
  16126. *
  16127. * Returns the Mesh.
  16128. */
  16129. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16130. /**
  16131. * Sets the mesh indices.
  16132. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16133. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16134. * This method creates a new index buffer each call.
  16135. * Returns the Mesh.
  16136. */
  16137. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16138. /**
  16139. * Boolean : True if the mesh owns the requested kind of data.
  16140. */
  16141. isVerticesDataPresent(kind: string): boolean;
  16142. /**
  16143. * Returns an array of indices (IndicesArray).
  16144. */
  16145. getIndices(): Nullable<IndicesArray>;
  16146. get _positions(): Nullable<Vector3[]>;
  16147. /**
  16148. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16149. * This means the mesh underlying bounding box and sphere are recomputed.
  16150. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16151. * @returns the current mesh
  16152. */
  16153. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16154. /** @hidden */
  16155. _preActivate(): InstancedMesh;
  16156. /** @hidden */
  16157. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16158. /** @hidden */
  16159. _postActivate(): void;
  16160. getWorldMatrix(): Matrix;
  16161. get isAnInstance(): boolean;
  16162. /**
  16163. * Returns the current associated LOD AbstractMesh.
  16164. */
  16165. getLOD(camera: Camera): AbstractMesh;
  16166. /** @hidden */
  16167. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16168. /** @hidden */
  16169. _syncSubMeshes(): InstancedMesh;
  16170. /** @hidden */
  16171. _generatePointsArray(): boolean;
  16172. /**
  16173. * Creates a new InstancedMesh from the current mesh.
  16174. * - name (string) : the cloned mesh name
  16175. * - newParent (optional Node) : the optional Node to parent the clone to.
  16176. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16177. *
  16178. * Returns the clone.
  16179. */
  16180. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16181. /**
  16182. * Disposes the InstancedMesh.
  16183. * Returns nothing.
  16184. */
  16185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16186. }
  16187. interface Mesh {
  16188. /**
  16189. * Register a custom buffer that will be instanced
  16190. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16191. * @param kind defines the buffer kind
  16192. * @param stride defines the stride in floats
  16193. */
  16194. registerInstancedBuffer(kind: string, stride: number): void;
  16195. /**
  16196. * true to use the edge renderer for all instances of this mesh
  16197. */
  16198. edgesShareWithInstances: boolean;
  16199. /** @hidden */
  16200. _userInstancedBuffersStorage: {
  16201. data: {
  16202. [key: string]: Float32Array;
  16203. };
  16204. sizes: {
  16205. [key: string]: number;
  16206. };
  16207. vertexBuffers: {
  16208. [key: string]: Nullable<VertexBuffer>;
  16209. };
  16210. strides: {
  16211. [key: string]: number;
  16212. };
  16213. };
  16214. }
  16215. interface AbstractMesh {
  16216. /**
  16217. * Object used to store instanced buffers defined by user
  16218. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16219. */
  16220. instancedBuffers: {
  16221. [key: string]: any;
  16222. };
  16223. }
  16224. }
  16225. declare module BABYLON {
  16226. /**
  16227. * Defines the options associated with the creation of a shader material.
  16228. */
  16229. export interface IShaderMaterialOptions {
  16230. /**
  16231. * Does the material work in alpha blend mode
  16232. */
  16233. needAlphaBlending: boolean;
  16234. /**
  16235. * Does the material work in alpha test mode
  16236. */
  16237. needAlphaTesting: boolean;
  16238. /**
  16239. * The list of attribute names used in the shader
  16240. */
  16241. attributes: string[];
  16242. /**
  16243. * The list of unifrom names used in the shader
  16244. */
  16245. uniforms: string[];
  16246. /**
  16247. * The list of UBO names used in the shader
  16248. */
  16249. uniformBuffers: string[];
  16250. /**
  16251. * The list of sampler names used in the shader
  16252. */
  16253. samplers: string[];
  16254. /**
  16255. * The list of defines used in the shader
  16256. */
  16257. defines: string[];
  16258. }
  16259. /**
  16260. * 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.
  16261. *
  16262. * This returned material effects how the mesh will look based on the code in the shaders.
  16263. *
  16264. * @see https://doc.babylonjs.com/how_to/shader_material
  16265. */
  16266. export class ShaderMaterial extends Material {
  16267. private _shaderPath;
  16268. private _options;
  16269. private _textures;
  16270. private _textureArrays;
  16271. private _floats;
  16272. private _ints;
  16273. private _floatsArrays;
  16274. private _colors3;
  16275. private _colors3Arrays;
  16276. private _colors4;
  16277. private _colors4Arrays;
  16278. private _vectors2;
  16279. private _vectors3;
  16280. private _vectors4;
  16281. private _matrices;
  16282. private _matrixArrays;
  16283. private _matrices3x3;
  16284. private _matrices2x2;
  16285. private _vectors2Arrays;
  16286. private _vectors3Arrays;
  16287. private _vectors4Arrays;
  16288. private _cachedWorldViewMatrix;
  16289. private _cachedWorldViewProjectionMatrix;
  16290. private _renderId;
  16291. private _multiview;
  16292. private _cachedDefines;
  16293. /** Define the Url to load snippets */
  16294. static SnippetUrl: string;
  16295. /** Snippet ID if the material was created from the snippet server */
  16296. snippetId: string;
  16297. /**
  16298. * Instantiate a new shader material.
  16299. * 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.
  16300. * This returned material effects how the mesh will look based on the code in the shaders.
  16301. * @see https://doc.babylonjs.com/how_to/shader_material
  16302. * @param name Define the name of the material in the scene
  16303. * @param scene Define the scene the material belongs to
  16304. * @param shaderPath Defines the route to the shader code in one of three ways:
  16305. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16306. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16307. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16308. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16309. * @param options Define the options used to create the shader
  16310. */
  16311. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16312. /**
  16313. * Gets the shader path used to define the shader code
  16314. * It can be modified to trigger a new compilation
  16315. */
  16316. get shaderPath(): any;
  16317. /**
  16318. * Sets the shader path used to define the shader code
  16319. * It can be modified to trigger a new compilation
  16320. */
  16321. set shaderPath(shaderPath: any);
  16322. /**
  16323. * Gets the options used to compile the shader.
  16324. * They can be modified to trigger a new compilation
  16325. */
  16326. get options(): IShaderMaterialOptions;
  16327. /**
  16328. * Gets the current class name of the material e.g. "ShaderMaterial"
  16329. * Mainly use in serialization.
  16330. * @returns the class name
  16331. */
  16332. getClassName(): string;
  16333. /**
  16334. * Specifies if the material will require alpha blending
  16335. * @returns a boolean specifying if alpha blending is needed
  16336. */
  16337. needAlphaBlending(): boolean;
  16338. /**
  16339. * Specifies if this material should be rendered in alpha test mode
  16340. * @returns a boolean specifying if an alpha test is needed.
  16341. */
  16342. needAlphaTesting(): boolean;
  16343. private _checkUniform;
  16344. /**
  16345. * Set a texture in the shader.
  16346. * @param name Define the name of the uniform samplers as defined in the shader
  16347. * @param texture Define the texture to bind to this sampler
  16348. * @return the material itself allowing "fluent" like uniform updates
  16349. */
  16350. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16351. /**
  16352. * Set a texture array in the shader.
  16353. * @param name Define the name of the uniform sampler array as defined in the shader
  16354. * @param textures Define the list of textures to bind to this sampler
  16355. * @return the material itself allowing "fluent" like uniform updates
  16356. */
  16357. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16358. /**
  16359. * Set a float in the shader.
  16360. * @param name Define the name of the uniform as defined in the shader
  16361. * @param value Define the value to give to the uniform
  16362. * @return the material itself allowing "fluent" like uniform updates
  16363. */
  16364. setFloat(name: string, value: number): ShaderMaterial;
  16365. /**
  16366. * Set a int in the shader.
  16367. * @param name Define the name of the uniform as defined in the shader
  16368. * @param value Define the value to give to the uniform
  16369. * @return the material itself allowing "fluent" like uniform updates
  16370. */
  16371. setInt(name: string, value: number): ShaderMaterial;
  16372. /**
  16373. * Set an array of floats in the shader.
  16374. * @param name Define the name of the uniform as defined in the shader
  16375. * @param value Define the value to give to the uniform
  16376. * @return the material itself allowing "fluent" like uniform updates
  16377. */
  16378. setFloats(name: string, value: number[]): ShaderMaterial;
  16379. /**
  16380. * Set a vec3 in the shader from a Color3.
  16381. * @param name Define the name of the uniform as defined in the shader
  16382. * @param value Define the value to give to the uniform
  16383. * @return the material itself allowing "fluent" like uniform updates
  16384. */
  16385. setColor3(name: string, value: Color3): ShaderMaterial;
  16386. /**
  16387. * Set a vec3 array in the shader from a Color3 array.
  16388. * @param name Define the name of the uniform as defined in the shader
  16389. * @param value Define the value to give to the uniform
  16390. * @return the material itself allowing "fluent" like uniform updates
  16391. */
  16392. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16393. /**
  16394. * Set a vec4 in the shader from a Color4.
  16395. * @param name Define the name of the uniform as defined in the shader
  16396. * @param value Define the value to give to the uniform
  16397. * @return the material itself allowing "fluent" like uniform updates
  16398. */
  16399. setColor4(name: string, value: Color4): ShaderMaterial;
  16400. /**
  16401. * Set a vec4 array in the shader from a Color4 array.
  16402. * @param name Define the name of the uniform as defined in the shader
  16403. * @param value Define the value to give to the uniform
  16404. * @return the material itself allowing "fluent" like uniform updates
  16405. */
  16406. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16407. /**
  16408. * Set a vec2 in the shader from a Vector2.
  16409. * @param name Define the name of the uniform as defined in the shader
  16410. * @param value Define the value to give to the uniform
  16411. * @return the material itself allowing "fluent" like uniform updates
  16412. */
  16413. setVector2(name: string, value: Vector2): ShaderMaterial;
  16414. /**
  16415. * Set a vec3 in the shader from a Vector3.
  16416. * @param name Define the name of the uniform as defined in the shader
  16417. * @param value Define the value to give to the uniform
  16418. * @return the material itself allowing "fluent" like uniform updates
  16419. */
  16420. setVector3(name: string, value: Vector3): ShaderMaterial;
  16421. /**
  16422. * Set a vec4 in the shader from a Vector4.
  16423. * @param name Define the name of the uniform as defined in the shader
  16424. * @param value Define the value to give to the uniform
  16425. * @return the material itself allowing "fluent" like uniform updates
  16426. */
  16427. setVector4(name: string, value: Vector4): ShaderMaterial;
  16428. /**
  16429. * Set a mat4 in the shader from a Matrix.
  16430. * @param name Define the name of the uniform as defined in the shader
  16431. * @param value Define the value to give to the uniform
  16432. * @return the material itself allowing "fluent" like uniform updates
  16433. */
  16434. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16435. /**
  16436. * Set a float32Array in the shader from a matrix array.
  16437. * @param name Define the name of the uniform as defined in the shader
  16438. * @param value Define the value to give to the uniform
  16439. * @return the material itself allowing "fluent" like uniform updates
  16440. */
  16441. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16442. /**
  16443. * Set a mat3 in the shader from a Float32Array.
  16444. * @param name Define the name of the uniform as defined in the shader
  16445. * @param value Define the value to give to the uniform
  16446. * @return the material itself allowing "fluent" like uniform updates
  16447. */
  16448. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16449. /**
  16450. * Set a mat2 in the shader from a Float32Array.
  16451. * @param name Define the name of the uniform as defined in the shader
  16452. * @param value Define the value to give to the uniform
  16453. * @return the material itself allowing "fluent" like uniform updates
  16454. */
  16455. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16456. /**
  16457. * Set a vec2 array in the shader from a number array.
  16458. * @param name Define the name of the uniform as defined in the shader
  16459. * @param value Define the value to give to the uniform
  16460. * @return the material itself allowing "fluent" like uniform updates
  16461. */
  16462. setArray2(name: string, value: number[]): ShaderMaterial;
  16463. /**
  16464. * Set a vec3 array in the shader from a number array.
  16465. * @param name Define the name of the uniform as defined in the shader
  16466. * @param value Define the value to give to the uniform
  16467. * @return the material itself allowing "fluent" like uniform updates
  16468. */
  16469. setArray3(name: string, value: number[]): ShaderMaterial;
  16470. /**
  16471. * Set a vec4 array in the shader from a number array.
  16472. * @param name Define the name of the uniform as defined in the shader
  16473. * @param value Define the value to give to the uniform
  16474. * @return the material itself allowing "fluent" like uniform updates
  16475. */
  16476. setArray4(name: string, value: number[]): ShaderMaterial;
  16477. private _checkCache;
  16478. /**
  16479. * Specifies that the submesh is ready to be used
  16480. * @param mesh defines the mesh to check
  16481. * @param subMesh defines which submesh to check
  16482. * @param useInstances specifies that instances should be used
  16483. * @returns a boolean indicating that the submesh is ready or not
  16484. */
  16485. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16486. /**
  16487. * Checks if the material is ready to render the requested mesh
  16488. * @param mesh Define the mesh to render
  16489. * @param useInstances Define whether or not the material is used with instances
  16490. * @returns true if ready, otherwise false
  16491. */
  16492. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16493. /**
  16494. * Binds the world matrix to the material
  16495. * @param world defines the world transformation matrix
  16496. * @param effectOverride - If provided, use this effect instead of internal effect
  16497. */
  16498. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16499. /**
  16500. * Binds the submesh to this material by preparing the effect and shader to draw
  16501. * @param world defines the world transformation matrix
  16502. * @param mesh defines the mesh containing the submesh
  16503. * @param subMesh defines the submesh to bind the material to
  16504. */
  16505. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16506. /**
  16507. * Binds the material to the mesh
  16508. * @param world defines the world transformation matrix
  16509. * @param mesh defines the mesh to bind the material to
  16510. * @param effectOverride - If provided, use this effect instead of internal effect
  16511. */
  16512. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16513. protected _afterBind(mesh?: Mesh): void;
  16514. /**
  16515. * Gets the active textures from the material
  16516. * @returns an array of textures
  16517. */
  16518. getActiveTextures(): BaseTexture[];
  16519. /**
  16520. * Specifies if the material uses a texture
  16521. * @param texture defines the texture to check against the material
  16522. * @returns a boolean specifying if the material uses the texture
  16523. */
  16524. hasTexture(texture: BaseTexture): boolean;
  16525. /**
  16526. * Makes a duplicate of the material, and gives it a new name
  16527. * @param name defines the new name for the duplicated material
  16528. * @returns the cloned material
  16529. */
  16530. clone(name: string): ShaderMaterial;
  16531. /**
  16532. * Disposes the material
  16533. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16534. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16535. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16536. */
  16537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16538. /**
  16539. * Serializes this material in a JSON representation
  16540. * @returns the serialized material object
  16541. */
  16542. serialize(): any;
  16543. /**
  16544. * Creates a shader material from parsed shader material data
  16545. * @param source defines the JSON represnetation of the material
  16546. * @param scene defines the hosting scene
  16547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16548. * @returns a new material
  16549. */
  16550. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16551. /**
  16552. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16553. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16554. * @param url defines the url to load from
  16555. * @param scene defines the hosting scene
  16556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16557. * @returns a promise that will resolve to the new ShaderMaterial
  16558. */
  16559. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16560. /**
  16561. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16562. * @param snippetId defines the snippet to load
  16563. * @param scene defines the hosting scene
  16564. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16565. * @returns a promise that will resolve to the new ShaderMaterial
  16566. */
  16567. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16568. }
  16569. }
  16570. declare module BABYLON {
  16571. /** @hidden */
  16572. export var colorPixelShader: {
  16573. name: string;
  16574. shader: string;
  16575. };
  16576. }
  16577. declare module BABYLON {
  16578. /** @hidden */
  16579. export var colorVertexShader: {
  16580. name: string;
  16581. shader: string;
  16582. };
  16583. }
  16584. declare module BABYLON {
  16585. /**
  16586. * Line mesh
  16587. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16588. */
  16589. export class LinesMesh extends Mesh {
  16590. /**
  16591. * If vertex color should be applied to the mesh
  16592. */
  16593. readonly useVertexColor?: boolean | undefined;
  16594. /**
  16595. * If vertex alpha should be applied to the mesh
  16596. */
  16597. readonly useVertexAlpha?: boolean | undefined;
  16598. /**
  16599. * Color of the line (Default: White)
  16600. */
  16601. color: Color3;
  16602. /**
  16603. * Alpha of the line (Default: 1)
  16604. */
  16605. alpha: number;
  16606. /**
  16607. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16608. * This margin is expressed in world space coordinates, so its value may vary.
  16609. * Default value is 0.1
  16610. */
  16611. intersectionThreshold: number;
  16612. private _colorShader;
  16613. private color4;
  16614. /**
  16615. * Creates a new LinesMesh
  16616. * @param name defines the name
  16617. * @param scene defines the hosting scene
  16618. * @param parent defines the parent mesh if any
  16619. * @param source defines the optional source LinesMesh used to clone data from
  16620. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16621. * When false, achieved by calling a clone(), also passing False.
  16622. * This will make creation of children, recursive.
  16623. * @param useVertexColor defines if this LinesMesh supports vertex color
  16624. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16625. */
  16626. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16627. /**
  16628. * If vertex color should be applied to the mesh
  16629. */
  16630. useVertexColor?: boolean | undefined,
  16631. /**
  16632. * If vertex alpha should be applied to the mesh
  16633. */
  16634. useVertexAlpha?: boolean | undefined);
  16635. private _addClipPlaneDefine;
  16636. private _removeClipPlaneDefine;
  16637. isReady(): boolean;
  16638. /**
  16639. * Returns the string "LineMesh"
  16640. */
  16641. getClassName(): string;
  16642. /**
  16643. * @hidden
  16644. */
  16645. get material(): Material;
  16646. /**
  16647. * @hidden
  16648. */
  16649. set material(value: Material);
  16650. /**
  16651. * @hidden
  16652. */
  16653. get checkCollisions(): boolean;
  16654. /** @hidden */
  16655. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16656. /** @hidden */
  16657. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16658. /**
  16659. * Disposes of the line mesh
  16660. * @param doNotRecurse If children should be disposed
  16661. */
  16662. dispose(doNotRecurse?: boolean): void;
  16663. /**
  16664. * Returns a new LineMesh object cloned from the current one.
  16665. */
  16666. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16667. /**
  16668. * Creates a new InstancedLinesMesh object from the mesh model.
  16669. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16670. * @param name defines the name of the new instance
  16671. * @returns a new InstancedLinesMesh
  16672. */
  16673. createInstance(name: string): InstancedLinesMesh;
  16674. }
  16675. /**
  16676. * Creates an instance based on a source LinesMesh
  16677. */
  16678. export class InstancedLinesMesh extends InstancedMesh {
  16679. /**
  16680. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16681. * This margin is expressed in world space coordinates, so its value may vary.
  16682. * Initilized with the intersectionThreshold value of the source LinesMesh
  16683. */
  16684. intersectionThreshold: number;
  16685. constructor(name: string, source: LinesMesh);
  16686. /**
  16687. * Returns the string "InstancedLinesMesh".
  16688. */
  16689. getClassName(): string;
  16690. }
  16691. }
  16692. declare module BABYLON {
  16693. /** @hidden */
  16694. export var linePixelShader: {
  16695. name: string;
  16696. shader: string;
  16697. };
  16698. }
  16699. declare module BABYLON {
  16700. /** @hidden */
  16701. export var lineVertexShader: {
  16702. name: string;
  16703. shader: string;
  16704. };
  16705. }
  16706. declare module BABYLON {
  16707. interface Scene {
  16708. /** @hidden */
  16709. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16710. }
  16711. interface AbstractMesh {
  16712. /**
  16713. * Gets the edgesRenderer associated with the mesh
  16714. */
  16715. edgesRenderer: Nullable<EdgesRenderer>;
  16716. }
  16717. interface LinesMesh {
  16718. /**
  16719. * Enables the edge rendering mode on the mesh.
  16720. * This mode makes the mesh edges visible
  16721. * @param epsilon defines the maximal distance between two angles to detect a face
  16722. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16723. * @returns the currentAbstractMesh
  16724. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16725. */
  16726. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16727. }
  16728. interface InstancedLinesMesh {
  16729. /**
  16730. * Enables the edge rendering mode on the mesh.
  16731. * This mode makes the mesh edges visible
  16732. * @param epsilon defines the maximal distance between two angles to detect a face
  16733. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16734. * @returns the current InstancedLinesMesh
  16735. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16736. */
  16737. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16738. }
  16739. /**
  16740. * Defines the minimum contract an Edges renderer should follow.
  16741. */
  16742. export interface IEdgesRenderer extends IDisposable {
  16743. /**
  16744. * Gets or sets a boolean indicating if the edgesRenderer is active
  16745. */
  16746. isEnabled: boolean;
  16747. /**
  16748. * Renders the edges of the attached mesh,
  16749. */
  16750. render(): void;
  16751. /**
  16752. * Checks wether or not the edges renderer is ready to render.
  16753. * @return true if ready, otherwise false.
  16754. */
  16755. isReady(): boolean;
  16756. /**
  16757. * List of instances to render in case the source mesh has instances
  16758. */
  16759. customInstances: SmartArray<Matrix>;
  16760. }
  16761. /**
  16762. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16763. */
  16764. export class EdgesRenderer implements IEdgesRenderer {
  16765. /**
  16766. * Define the size of the edges with an orthographic camera
  16767. */
  16768. edgesWidthScalerForOrthographic: number;
  16769. /**
  16770. * Define the size of the edges with a perspective camera
  16771. */
  16772. edgesWidthScalerForPerspective: number;
  16773. protected _source: AbstractMesh;
  16774. protected _linesPositions: number[];
  16775. protected _linesNormals: number[];
  16776. protected _linesIndices: number[];
  16777. protected _epsilon: number;
  16778. protected _indicesCount: number;
  16779. protected _lineShader: ShaderMaterial;
  16780. protected _ib: DataBuffer;
  16781. protected _buffers: {
  16782. [key: string]: Nullable<VertexBuffer>;
  16783. };
  16784. protected _buffersForInstances: {
  16785. [key: string]: Nullable<VertexBuffer>;
  16786. };
  16787. protected _checkVerticesInsteadOfIndices: boolean;
  16788. private _meshRebuildObserver;
  16789. private _meshDisposeObserver;
  16790. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16791. isEnabled: boolean;
  16792. /**
  16793. * List of instances to render in case the source mesh has instances
  16794. */
  16795. customInstances: SmartArray<Matrix>;
  16796. private static GetShader;
  16797. /**
  16798. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16799. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16800. * @param source Mesh used to create edges
  16801. * @param epsilon sum of angles in adjacency to check for edge
  16802. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16803. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16804. */
  16805. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16806. protected _prepareRessources(): void;
  16807. /** @hidden */
  16808. _rebuild(): void;
  16809. /**
  16810. * Releases the required resources for the edges renderer
  16811. */
  16812. dispose(): void;
  16813. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16814. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16815. /**
  16816. * Checks if the pair of p0 and p1 is en edge
  16817. * @param faceIndex
  16818. * @param edge
  16819. * @param faceNormals
  16820. * @param p0
  16821. * @param p1
  16822. * @private
  16823. */
  16824. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16825. /**
  16826. * push line into the position, normal and index buffer
  16827. * @protected
  16828. */
  16829. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16830. /**
  16831. * Generates lines edges from adjacencjes
  16832. * @private
  16833. */
  16834. _generateEdgesLines(): void;
  16835. /**
  16836. * Checks wether or not the edges renderer is ready to render.
  16837. * @return true if ready, otherwise false.
  16838. */
  16839. isReady(): boolean;
  16840. /**
  16841. * Renders the edges of the attached mesh,
  16842. */
  16843. render(): void;
  16844. }
  16845. /**
  16846. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16847. */
  16848. export class LineEdgesRenderer extends EdgesRenderer {
  16849. /**
  16850. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16851. * @param source LineMesh used to generate edges
  16852. * @param epsilon not important (specified angle for edge detection)
  16853. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16854. */
  16855. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16856. /**
  16857. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16858. */
  16859. _generateEdgesLines(): void;
  16860. }
  16861. }
  16862. declare module BABYLON {
  16863. /**
  16864. * This represents the object necessary to create a rendering group.
  16865. * This is exclusively used and created by the rendering manager.
  16866. * To modify the behavior, you use the available helpers in your scene or meshes.
  16867. * @hidden
  16868. */
  16869. export class RenderingGroup {
  16870. index: number;
  16871. private static _zeroVector;
  16872. private _scene;
  16873. private _opaqueSubMeshes;
  16874. private _transparentSubMeshes;
  16875. private _alphaTestSubMeshes;
  16876. private _depthOnlySubMeshes;
  16877. private _particleSystems;
  16878. private _spriteManagers;
  16879. private _opaqueSortCompareFn;
  16880. private _alphaTestSortCompareFn;
  16881. private _transparentSortCompareFn;
  16882. private _renderOpaque;
  16883. private _renderAlphaTest;
  16884. private _renderTransparent;
  16885. /** @hidden */
  16886. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16887. onBeforeTransparentRendering: () => void;
  16888. /**
  16889. * Set the opaque sort comparison function.
  16890. * If null the sub meshes will be render in the order they were created
  16891. */
  16892. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16893. /**
  16894. * Set the alpha test sort comparison function.
  16895. * If null the sub meshes will be render in the order they were created
  16896. */
  16897. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16898. /**
  16899. * Set the transparent sort comparison function.
  16900. * If null the sub meshes will be render in the order they were created
  16901. */
  16902. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16903. /**
  16904. * Creates a new rendering group.
  16905. * @param index The rendering group index
  16906. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16907. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16908. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16909. */
  16910. 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>);
  16911. /**
  16912. * Render all the sub meshes contained in the group.
  16913. * @param customRenderFunction Used to override the default render behaviour of the group.
  16914. * @returns true if rendered some submeshes.
  16915. */
  16916. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16917. /**
  16918. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16919. * @param subMeshes The submeshes to render
  16920. */
  16921. private renderOpaqueSorted;
  16922. /**
  16923. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16924. * @param subMeshes The submeshes to render
  16925. */
  16926. private renderAlphaTestSorted;
  16927. /**
  16928. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16929. * @param subMeshes The submeshes to render
  16930. */
  16931. private renderTransparentSorted;
  16932. /**
  16933. * Renders the submeshes in a specified order.
  16934. * @param subMeshes The submeshes to sort before render
  16935. * @param sortCompareFn The comparison function use to sort
  16936. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16937. * @param transparent Specifies to activate blending if true
  16938. */
  16939. private static renderSorted;
  16940. /**
  16941. * Renders the submeshes in the order they were dispatched (no sort applied).
  16942. * @param subMeshes The submeshes to render
  16943. */
  16944. private static renderUnsorted;
  16945. /**
  16946. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16947. * are rendered back to front if in the same alpha index.
  16948. *
  16949. * @param a The first submesh
  16950. * @param b The second submesh
  16951. * @returns The result of the comparison
  16952. */
  16953. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16954. /**
  16955. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16956. * are rendered back to front.
  16957. *
  16958. * @param a The first submesh
  16959. * @param b The second submesh
  16960. * @returns The result of the comparison
  16961. */
  16962. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16963. /**
  16964. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16965. * are rendered front to back (prevent overdraw).
  16966. *
  16967. * @param a The first submesh
  16968. * @param b The second submesh
  16969. * @returns The result of the comparison
  16970. */
  16971. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16972. /**
  16973. * Resets the different lists of submeshes to prepare a new frame.
  16974. */
  16975. prepare(): void;
  16976. dispose(): void;
  16977. /**
  16978. * Inserts the submesh in its correct queue depending on its material.
  16979. * @param subMesh The submesh to dispatch
  16980. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16981. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16982. */
  16983. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16984. dispatchSprites(spriteManager: ISpriteManager): void;
  16985. dispatchParticles(particleSystem: IParticleSystem): void;
  16986. private _renderParticles;
  16987. private _renderSprites;
  16988. }
  16989. }
  16990. declare module BABYLON {
  16991. /**
  16992. * Interface describing the different options available in the rendering manager
  16993. * regarding Auto Clear between groups.
  16994. */
  16995. export interface IRenderingManagerAutoClearSetup {
  16996. /**
  16997. * Defines whether or not autoclear is enable.
  16998. */
  16999. autoClear: boolean;
  17000. /**
  17001. * Defines whether or not to autoclear the depth buffer.
  17002. */
  17003. depth: boolean;
  17004. /**
  17005. * Defines whether or not to autoclear the stencil buffer.
  17006. */
  17007. stencil: boolean;
  17008. }
  17009. /**
  17010. * This class is used by the onRenderingGroupObservable
  17011. */
  17012. export class RenderingGroupInfo {
  17013. /**
  17014. * The Scene that being rendered
  17015. */
  17016. scene: Scene;
  17017. /**
  17018. * The camera currently used for the rendering pass
  17019. */
  17020. camera: Nullable<Camera>;
  17021. /**
  17022. * The ID of the renderingGroup being processed
  17023. */
  17024. renderingGroupId: number;
  17025. }
  17026. /**
  17027. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17028. * It is enable to manage the different groups as well as the different necessary sort functions.
  17029. * This should not be used directly aside of the few static configurations
  17030. */
  17031. export class RenderingManager {
  17032. /**
  17033. * The max id used for rendering groups (not included)
  17034. */
  17035. static MAX_RENDERINGGROUPS: number;
  17036. /**
  17037. * The min id used for rendering groups (included)
  17038. */
  17039. static MIN_RENDERINGGROUPS: number;
  17040. /**
  17041. * Used to globally prevent autoclearing scenes.
  17042. */
  17043. static AUTOCLEAR: boolean;
  17044. /**
  17045. * @hidden
  17046. */
  17047. _useSceneAutoClearSetup: boolean;
  17048. private _scene;
  17049. private _renderingGroups;
  17050. private _depthStencilBufferAlreadyCleaned;
  17051. private _autoClearDepthStencil;
  17052. private _customOpaqueSortCompareFn;
  17053. private _customAlphaTestSortCompareFn;
  17054. private _customTransparentSortCompareFn;
  17055. private _renderingGroupInfo;
  17056. /**
  17057. * Instantiates a new rendering group for a particular scene
  17058. * @param scene Defines the scene the groups belongs to
  17059. */
  17060. constructor(scene: Scene);
  17061. private _clearDepthStencilBuffer;
  17062. /**
  17063. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17064. * @hidden
  17065. */
  17066. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17067. /**
  17068. * Resets the different information of the group to prepare a new frame
  17069. * @hidden
  17070. */
  17071. reset(): void;
  17072. /**
  17073. * Dispose and release the group and its associated resources.
  17074. * @hidden
  17075. */
  17076. dispose(): void;
  17077. /**
  17078. * Clear the info related to rendering groups preventing retention points during dispose.
  17079. */
  17080. freeRenderingGroups(): void;
  17081. private _prepareRenderingGroup;
  17082. /**
  17083. * Add a sprite manager to the rendering manager in order to render it this frame.
  17084. * @param spriteManager Define the sprite manager to render
  17085. */
  17086. dispatchSprites(spriteManager: ISpriteManager): void;
  17087. /**
  17088. * Add a particle system to the rendering manager in order to render it this frame.
  17089. * @param particleSystem Define the particle system to render
  17090. */
  17091. dispatchParticles(particleSystem: IParticleSystem): void;
  17092. /**
  17093. * Add a submesh to the manager in order to render it this frame
  17094. * @param subMesh The submesh to dispatch
  17095. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17096. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17097. */
  17098. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17099. /**
  17100. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17101. * This allowed control for front to back rendering or reversly depending of the special needs.
  17102. *
  17103. * @param renderingGroupId The rendering group id corresponding to its index
  17104. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17105. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17106. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17107. */
  17108. 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;
  17109. /**
  17110. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17111. *
  17112. * @param renderingGroupId The rendering group id corresponding to its index
  17113. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17114. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17115. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17116. */
  17117. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17118. /**
  17119. * Gets the current auto clear configuration for one rendering group of the rendering
  17120. * manager.
  17121. * @param index the rendering group index to get the information for
  17122. * @returns The auto clear setup for the requested rendering group
  17123. */
  17124. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17125. }
  17126. }
  17127. declare module BABYLON {
  17128. /**
  17129. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17130. */
  17131. export interface ICustomShaderOptions {
  17132. /**
  17133. * Gets or sets the custom shader name to use
  17134. */
  17135. shaderName: string;
  17136. /**
  17137. * The list of attribute names used in the shader
  17138. */
  17139. attributes?: string[];
  17140. /**
  17141. * The list of unifrom names used in the shader
  17142. */
  17143. uniforms?: string[];
  17144. /**
  17145. * The list of sampler names used in the shader
  17146. */
  17147. samplers?: string[];
  17148. /**
  17149. * The list of defines used in the shader
  17150. */
  17151. defines?: string[];
  17152. }
  17153. /**
  17154. * Interface to implement to create a shadow generator compatible with BJS.
  17155. */
  17156. export interface IShadowGenerator {
  17157. /**
  17158. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17159. * @returns The render target texture if present otherwise, null
  17160. */
  17161. getShadowMap(): Nullable<RenderTargetTexture>;
  17162. /**
  17163. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17164. * @param subMesh The submesh we want to render in the shadow map
  17165. * @param useInstances Defines wether will draw in the map using instances
  17166. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17167. * @returns true if ready otherwise, false
  17168. */
  17169. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17170. /**
  17171. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17172. * @param defines Defines of the material we want to update
  17173. * @param lightIndex Index of the light in the enabled light list of the material
  17174. */
  17175. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17176. /**
  17177. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17178. * defined in the generator but impacting the effect).
  17179. * It implies the unifroms available on the materials are the standard BJS ones.
  17180. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17181. * @param effect The effect we are binfing the information for
  17182. */
  17183. bindShadowLight(lightIndex: string, effect: Effect): void;
  17184. /**
  17185. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17186. * (eq to shadow prjection matrix * light transform matrix)
  17187. * @returns The transform matrix used to create the shadow map
  17188. */
  17189. getTransformMatrix(): Matrix;
  17190. /**
  17191. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17192. * Cube and 2D textures for instance.
  17193. */
  17194. recreateShadowMap(): void;
  17195. /**
  17196. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17197. * @param onCompiled Callback triggered at the and of the effects compilation
  17198. * @param options Sets of optional options forcing the compilation with different modes
  17199. */
  17200. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17201. useInstances: boolean;
  17202. }>): void;
  17203. /**
  17204. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17205. * @param options Sets of optional options forcing the compilation with different modes
  17206. * @returns A promise that resolves when the compilation completes
  17207. */
  17208. forceCompilationAsync(options?: Partial<{
  17209. useInstances: boolean;
  17210. }>): Promise<void>;
  17211. /**
  17212. * Serializes the shadow generator setup to a json object.
  17213. * @returns The serialized JSON object
  17214. */
  17215. serialize(): any;
  17216. /**
  17217. * Disposes the Shadow map and related Textures and effects.
  17218. */
  17219. dispose(): void;
  17220. }
  17221. /**
  17222. * Default implementation IShadowGenerator.
  17223. * This is the main object responsible of generating shadows in the framework.
  17224. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17225. */
  17226. export class ShadowGenerator implements IShadowGenerator {
  17227. /**
  17228. * Name of the shadow generator class
  17229. */
  17230. static CLASSNAME: string;
  17231. /**
  17232. * Shadow generator mode None: no filtering applied.
  17233. */
  17234. static readonly FILTER_NONE: number;
  17235. /**
  17236. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17237. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17238. */
  17239. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17240. /**
  17241. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17242. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17243. */
  17244. static readonly FILTER_POISSONSAMPLING: number;
  17245. /**
  17246. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17247. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17248. */
  17249. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17250. /**
  17251. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17252. * edge artifacts on steep falloff.
  17253. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17254. */
  17255. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17256. /**
  17257. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17258. * edge artifacts on steep falloff.
  17259. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17260. */
  17261. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17262. /**
  17263. * Shadow generator mode PCF: Percentage Closer Filtering
  17264. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17265. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17266. */
  17267. static readonly FILTER_PCF: number;
  17268. /**
  17269. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17270. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17271. * Contact Hardening
  17272. */
  17273. static readonly FILTER_PCSS: number;
  17274. /**
  17275. * Reserved for PCF and PCSS
  17276. * Highest Quality.
  17277. *
  17278. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17279. *
  17280. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17281. */
  17282. static readonly QUALITY_HIGH: number;
  17283. /**
  17284. * Reserved for PCF and PCSS
  17285. * Good tradeoff for quality/perf cross devices
  17286. *
  17287. * Execute PCF on a 3*3 kernel.
  17288. *
  17289. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17290. */
  17291. static readonly QUALITY_MEDIUM: number;
  17292. /**
  17293. * Reserved for PCF and PCSS
  17294. * The lowest quality but the fastest.
  17295. *
  17296. * Execute PCF on a 1*1 kernel.
  17297. *
  17298. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17299. */
  17300. static readonly QUALITY_LOW: number;
  17301. /** Gets or sets the custom shader name to use */
  17302. customShaderOptions: ICustomShaderOptions;
  17303. /**
  17304. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17305. */
  17306. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17307. /**
  17308. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17309. */
  17310. onAfterShadowMapRenderObservable: Observable<Effect>;
  17311. /**
  17312. * Observable triggered before a mesh is rendered in the shadow map.
  17313. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17314. */
  17315. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17316. /**
  17317. * Observable triggered after a mesh is rendered in the shadow map.
  17318. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17319. */
  17320. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17321. protected _bias: number;
  17322. /**
  17323. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17324. */
  17325. get bias(): number;
  17326. /**
  17327. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17328. */
  17329. set bias(bias: number);
  17330. protected _normalBias: number;
  17331. /**
  17332. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17333. */
  17334. get normalBias(): number;
  17335. /**
  17336. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17337. */
  17338. set normalBias(normalBias: number);
  17339. protected _blurBoxOffset: number;
  17340. /**
  17341. * Gets the blur box offset: offset applied during the blur pass.
  17342. * Only useful if useKernelBlur = false
  17343. */
  17344. get blurBoxOffset(): number;
  17345. /**
  17346. * Sets the blur box offset: offset applied during the blur pass.
  17347. * Only useful if useKernelBlur = false
  17348. */
  17349. set blurBoxOffset(value: number);
  17350. protected _blurScale: number;
  17351. /**
  17352. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17353. * 2 means half of the size.
  17354. */
  17355. get blurScale(): number;
  17356. /**
  17357. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17358. * 2 means half of the size.
  17359. */
  17360. set blurScale(value: number);
  17361. protected _blurKernel: number;
  17362. /**
  17363. * Gets the blur kernel: kernel size of the blur pass.
  17364. * Only useful if useKernelBlur = true
  17365. */
  17366. get blurKernel(): number;
  17367. /**
  17368. * Sets the blur kernel: kernel size of the blur pass.
  17369. * Only useful if useKernelBlur = true
  17370. */
  17371. set blurKernel(value: number);
  17372. protected _useKernelBlur: boolean;
  17373. /**
  17374. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17375. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17376. */
  17377. get useKernelBlur(): boolean;
  17378. /**
  17379. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17380. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17381. */
  17382. set useKernelBlur(value: boolean);
  17383. protected _depthScale: number;
  17384. /**
  17385. * Gets the depth scale used in ESM mode.
  17386. */
  17387. get depthScale(): number;
  17388. /**
  17389. * Sets the depth scale used in ESM mode.
  17390. * This can override the scale stored on the light.
  17391. */
  17392. set depthScale(value: number);
  17393. protected _validateFilter(filter: number): number;
  17394. protected _filter: number;
  17395. /**
  17396. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17397. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17398. */
  17399. get filter(): number;
  17400. /**
  17401. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17402. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17403. */
  17404. set filter(value: number);
  17405. /**
  17406. * Gets if the current filter is set to Poisson Sampling.
  17407. */
  17408. get usePoissonSampling(): boolean;
  17409. /**
  17410. * Sets the current filter to Poisson Sampling.
  17411. */
  17412. set usePoissonSampling(value: boolean);
  17413. /**
  17414. * Gets if the current filter is set to ESM.
  17415. */
  17416. get useExponentialShadowMap(): boolean;
  17417. /**
  17418. * Sets the current filter is to ESM.
  17419. */
  17420. set useExponentialShadowMap(value: boolean);
  17421. /**
  17422. * Gets if the current filter is set to filtered ESM.
  17423. */
  17424. get useBlurExponentialShadowMap(): boolean;
  17425. /**
  17426. * Gets if the current filter is set to filtered ESM.
  17427. */
  17428. set useBlurExponentialShadowMap(value: boolean);
  17429. /**
  17430. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17431. * exponential to prevent steep falloff artifacts).
  17432. */
  17433. get useCloseExponentialShadowMap(): boolean;
  17434. /**
  17435. * Sets the current filter to "close ESM" (using the inverse of the
  17436. * exponential to prevent steep falloff artifacts).
  17437. */
  17438. set useCloseExponentialShadowMap(value: boolean);
  17439. /**
  17440. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17441. * exponential to prevent steep falloff artifacts).
  17442. */
  17443. get useBlurCloseExponentialShadowMap(): boolean;
  17444. /**
  17445. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17446. * exponential to prevent steep falloff artifacts).
  17447. */
  17448. set useBlurCloseExponentialShadowMap(value: boolean);
  17449. /**
  17450. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17451. */
  17452. get usePercentageCloserFiltering(): boolean;
  17453. /**
  17454. * Sets the current filter to "PCF" (percentage closer filtering).
  17455. */
  17456. set usePercentageCloserFiltering(value: boolean);
  17457. protected _filteringQuality: number;
  17458. /**
  17459. * Gets the PCF or PCSS Quality.
  17460. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17461. */
  17462. get filteringQuality(): number;
  17463. /**
  17464. * Sets the PCF or PCSS Quality.
  17465. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17466. */
  17467. set filteringQuality(filteringQuality: number);
  17468. /**
  17469. * Gets if the current filter is set to "PCSS" (contact hardening).
  17470. */
  17471. get useContactHardeningShadow(): boolean;
  17472. /**
  17473. * Sets the current filter to "PCSS" (contact hardening).
  17474. */
  17475. set useContactHardeningShadow(value: boolean);
  17476. protected _contactHardeningLightSizeUVRatio: number;
  17477. /**
  17478. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17479. * Using a ratio helps keeping shape stability independently of the map size.
  17480. *
  17481. * It does not account for the light projection as it was having too much
  17482. * instability during the light setup or during light position changes.
  17483. *
  17484. * Only valid if useContactHardeningShadow is true.
  17485. */
  17486. get contactHardeningLightSizeUVRatio(): number;
  17487. /**
  17488. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17489. * Using a ratio helps keeping shape stability independently of the map size.
  17490. *
  17491. * It does not account for the light projection as it was having too much
  17492. * instability during the light setup or during light position changes.
  17493. *
  17494. * Only valid if useContactHardeningShadow is true.
  17495. */
  17496. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17497. protected _darkness: number;
  17498. /** Gets or sets the actual darkness of a shadow */
  17499. get darkness(): number;
  17500. set darkness(value: number);
  17501. /**
  17502. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17503. * 0 means strongest and 1 would means no shadow.
  17504. * @returns the darkness.
  17505. */
  17506. getDarkness(): number;
  17507. /**
  17508. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17509. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17510. * @returns the shadow generator allowing fluent coding.
  17511. */
  17512. setDarkness(darkness: number): ShadowGenerator;
  17513. protected _transparencyShadow: boolean;
  17514. /** Gets or sets the ability to have transparent shadow */
  17515. get transparencyShadow(): boolean;
  17516. set transparencyShadow(value: boolean);
  17517. /**
  17518. * Sets the ability to have transparent shadow (boolean).
  17519. * @param transparent True if transparent else False
  17520. * @returns the shadow generator allowing fluent coding
  17521. */
  17522. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17523. /**
  17524. * Enables or disables shadows with varying strength based on the transparency
  17525. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17526. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17527. * mesh.visibility * alphaTexture.a
  17528. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17529. */
  17530. enableSoftTransparentShadow: boolean;
  17531. protected _shadowMap: Nullable<RenderTargetTexture>;
  17532. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17533. /**
  17534. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17535. * @returns The render target texture if present otherwise, null
  17536. */
  17537. getShadowMap(): Nullable<RenderTargetTexture>;
  17538. /**
  17539. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17540. * @returns The render target texture if the shadow map is present otherwise, null
  17541. */
  17542. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17543. /**
  17544. * Gets the class name of that object
  17545. * @returns "ShadowGenerator"
  17546. */
  17547. getClassName(): string;
  17548. /**
  17549. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17550. * @param mesh Mesh to add
  17551. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17552. * @returns the Shadow Generator itself
  17553. */
  17554. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17555. /**
  17556. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17557. * @param mesh Mesh to remove
  17558. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17559. * @returns the Shadow Generator itself
  17560. */
  17561. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17562. /**
  17563. * Controls the extent to which the shadows fade out at the edge of the frustum
  17564. */
  17565. frustumEdgeFalloff: number;
  17566. protected _light: IShadowLight;
  17567. /**
  17568. * Returns the associated light object.
  17569. * @returns the light generating the shadow
  17570. */
  17571. getLight(): IShadowLight;
  17572. /**
  17573. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17574. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17575. * It might on the other hand introduce peter panning.
  17576. */
  17577. forceBackFacesOnly: boolean;
  17578. protected _scene: Scene;
  17579. protected _lightDirection: Vector3;
  17580. protected _effect: Effect;
  17581. protected _viewMatrix: Matrix;
  17582. protected _projectionMatrix: Matrix;
  17583. protected _transformMatrix: Matrix;
  17584. protected _cachedPosition: Vector3;
  17585. protected _cachedDirection: Vector3;
  17586. protected _cachedDefines: string;
  17587. protected _currentRenderID: number;
  17588. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17589. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17590. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17591. protected _blurPostProcesses: PostProcess[];
  17592. protected _mapSize: number;
  17593. protected _currentFaceIndex: number;
  17594. protected _currentFaceIndexCache: number;
  17595. protected _textureType: number;
  17596. protected _defaultTextureMatrix: Matrix;
  17597. protected _storedUniqueId: Nullable<number>;
  17598. /** @hidden */
  17599. static _SceneComponentInitialization: (scene: Scene) => void;
  17600. /**
  17601. * Creates a ShadowGenerator object.
  17602. * A ShadowGenerator is the required tool to use the shadows.
  17603. * Each light casting shadows needs to use its own ShadowGenerator.
  17604. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17605. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17606. * @param light The light object generating the shadows.
  17607. * @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.
  17608. */
  17609. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17610. protected _initializeGenerator(): void;
  17611. protected _createTargetRenderTexture(): void;
  17612. protected _initializeShadowMap(): void;
  17613. protected _initializeBlurRTTAndPostProcesses(): void;
  17614. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17615. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17616. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17617. protected _applyFilterValues(): void;
  17618. /**
  17619. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17620. * @param onCompiled Callback triggered at the and of the effects compilation
  17621. * @param options Sets of optional options forcing the compilation with different modes
  17622. */
  17623. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17624. useInstances: boolean;
  17625. }>): void;
  17626. /**
  17627. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17628. * @param options Sets of optional options forcing the compilation with different modes
  17629. * @returns A promise that resolves when the compilation completes
  17630. */
  17631. forceCompilationAsync(options?: Partial<{
  17632. useInstances: boolean;
  17633. }>): Promise<void>;
  17634. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17635. private _prepareShadowDefines;
  17636. /**
  17637. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17638. * @param subMesh The submesh we want to render in the shadow map
  17639. * @param useInstances Defines wether will draw in the map using instances
  17640. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17641. * @returns true if ready otherwise, false
  17642. */
  17643. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17644. /**
  17645. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17646. * @param defines Defines of the material we want to update
  17647. * @param lightIndex Index of the light in the enabled light list of the material
  17648. */
  17649. prepareDefines(defines: any, lightIndex: number): void;
  17650. /**
  17651. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17652. * defined in the generator but impacting the effect).
  17653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17654. * @param effect The effect we are binfing the information for
  17655. */
  17656. bindShadowLight(lightIndex: string, effect: Effect): void;
  17657. /**
  17658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17659. * (eq to shadow prjection matrix * light transform matrix)
  17660. * @returns The transform matrix used to create the shadow map
  17661. */
  17662. getTransformMatrix(): Matrix;
  17663. /**
  17664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17665. * Cube and 2D textures for instance.
  17666. */
  17667. recreateShadowMap(): void;
  17668. protected _disposeBlurPostProcesses(): void;
  17669. protected _disposeRTTandPostProcesses(): void;
  17670. /**
  17671. * Disposes the ShadowGenerator.
  17672. * Returns nothing.
  17673. */
  17674. dispose(): void;
  17675. /**
  17676. * Serializes the shadow generator setup to a json object.
  17677. * @returns The serialized JSON object
  17678. */
  17679. serialize(): any;
  17680. /**
  17681. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17682. * @param parsedShadowGenerator The JSON object to parse
  17683. * @param scene The scene to create the shadow map for
  17684. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17685. * @returns The parsed shadow generator
  17686. */
  17687. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17688. }
  17689. }
  17690. declare module BABYLON {
  17691. /**
  17692. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17693. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17694. * 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.
  17695. */
  17696. export abstract class Light extends Node {
  17697. /**
  17698. * Falloff Default: light is falling off following the material specification:
  17699. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17700. */
  17701. static readonly FALLOFF_DEFAULT: number;
  17702. /**
  17703. * Falloff Physical: light is falling off following the inverse squared distance law.
  17704. */
  17705. static readonly FALLOFF_PHYSICAL: number;
  17706. /**
  17707. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17708. * to enhance interoperability with other engines.
  17709. */
  17710. static readonly FALLOFF_GLTF: number;
  17711. /**
  17712. * Falloff Standard: light is falling off like in the standard material
  17713. * to enhance interoperability with other materials.
  17714. */
  17715. static readonly FALLOFF_STANDARD: number;
  17716. /**
  17717. * If every light affecting the material is in this lightmapMode,
  17718. * material.lightmapTexture adds or multiplies
  17719. * (depends on material.useLightmapAsShadowmap)
  17720. * after every other light calculations.
  17721. */
  17722. static readonly LIGHTMAP_DEFAULT: number;
  17723. /**
  17724. * material.lightmapTexture as only diffuse lighting from this light
  17725. * adds only specular lighting from this light
  17726. * adds dynamic shadows
  17727. */
  17728. static readonly LIGHTMAP_SPECULAR: number;
  17729. /**
  17730. * material.lightmapTexture as only lighting
  17731. * no light calculation from this light
  17732. * only adds dynamic shadows from this light
  17733. */
  17734. static readonly LIGHTMAP_SHADOWSONLY: number;
  17735. /**
  17736. * Each light type uses the default quantity according to its type:
  17737. * point/spot lights use luminous intensity
  17738. * directional lights use illuminance
  17739. */
  17740. static readonly INTENSITYMODE_AUTOMATIC: number;
  17741. /**
  17742. * lumen (lm)
  17743. */
  17744. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17745. /**
  17746. * candela (lm/sr)
  17747. */
  17748. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17749. /**
  17750. * lux (lm/m^2)
  17751. */
  17752. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17753. /**
  17754. * nit (cd/m^2)
  17755. */
  17756. static readonly INTENSITYMODE_LUMINANCE: number;
  17757. /**
  17758. * Light type const id of the point light.
  17759. */
  17760. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17761. /**
  17762. * Light type const id of the directional light.
  17763. */
  17764. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17765. /**
  17766. * Light type const id of the spot light.
  17767. */
  17768. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17769. /**
  17770. * Light type const id of the hemispheric light.
  17771. */
  17772. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17773. /**
  17774. * Diffuse gives the basic color to an object.
  17775. */
  17776. diffuse: Color3;
  17777. /**
  17778. * Specular produces a highlight color on an object.
  17779. * Note: This is note affecting PBR materials.
  17780. */
  17781. specular: Color3;
  17782. /**
  17783. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17784. * falling off base on range or angle.
  17785. * This can be set to any values in Light.FALLOFF_x.
  17786. *
  17787. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17788. * other types of materials.
  17789. */
  17790. falloffType: number;
  17791. /**
  17792. * Strength of the light.
  17793. * Note: By default it is define in the framework own unit.
  17794. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17795. */
  17796. intensity: number;
  17797. private _range;
  17798. protected _inverseSquaredRange: number;
  17799. /**
  17800. * Defines how far from the source the light is impacting in scene units.
  17801. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17802. */
  17803. get range(): number;
  17804. /**
  17805. * Defines how far from the source the light is impacting in scene units.
  17806. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17807. */
  17808. set range(value: number);
  17809. /**
  17810. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17811. * of light.
  17812. */
  17813. private _photometricScale;
  17814. private _intensityMode;
  17815. /**
  17816. * Gets the photometric scale used to interpret the intensity.
  17817. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17818. */
  17819. get intensityMode(): number;
  17820. /**
  17821. * Sets the photometric scale used to interpret the intensity.
  17822. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17823. */
  17824. set intensityMode(value: number);
  17825. private _radius;
  17826. /**
  17827. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17828. */
  17829. get radius(): number;
  17830. /**
  17831. * sets the light radius used by PBR Materials to simulate soft area lights.
  17832. */
  17833. set radius(value: number);
  17834. private _renderPriority;
  17835. /**
  17836. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17837. * exceeding the number allowed of the materials.
  17838. */
  17839. renderPriority: number;
  17840. private _shadowEnabled;
  17841. /**
  17842. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17843. * the current shadow generator.
  17844. */
  17845. get shadowEnabled(): boolean;
  17846. /**
  17847. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17848. * the current shadow generator.
  17849. */
  17850. set shadowEnabled(value: boolean);
  17851. private _includedOnlyMeshes;
  17852. /**
  17853. * Gets the only meshes impacted by this light.
  17854. */
  17855. get includedOnlyMeshes(): AbstractMesh[];
  17856. /**
  17857. * Sets the only meshes impacted by this light.
  17858. */
  17859. set includedOnlyMeshes(value: AbstractMesh[]);
  17860. private _excludedMeshes;
  17861. /**
  17862. * Gets the meshes not impacted by this light.
  17863. */
  17864. get excludedMeshes(): AbstractMesh[];
  17865. /**
  17866. * Sets the meshes not impacted by this light.
  17867. */
  17868. set excludedMeshes(value: AbstractMesh[]);
  17869. private _excludeWithLayerMask;
  17870. /**
  17871. * Gets the layer id use to find what meshes are not impacted by the light.
  17872. * Inactive if 0
  17873. */
  17874. get excludeWithLayerMask(): number;
  17875. /**
  17876. * Sets the layer id use to find what meshes are not impacted by the light.
  17877. * Inactive if 0
  17878. */
  17879. set excludeWithLayerMask(value: number);
  17880. private _includeOnlyWithLayerMask;
  17881. /**
  17882. * Gets the layer id use to find what meshes are impacted by the light.
  17883. * Inactive if 0
  17884. */
  17885. get includeOnlyWithLayerMask(): number;
  17886. /**
  17887. * Sets the layer id use to find what meshes are impacted by the light.
  17888. * Inactive if 0
  17889. */
  17890. set includeOnlyWithLayerMask(value: number);
  17891. private _lightmapMode;
  17892. /**
  17893. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17894. */
  17895. get lightmapMode(): number;
  17896. /**
  17897. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17898. */
  17899. set lightmapMode(value: number);
  17900. /**
  17901. * Shadow generator associted to the light.
  17902. * @hidden Internal use only.
  17903. */
  17904. _shadowGenerator: Nullable<IShadowGenerator>;
  17905. /**
  17906. * @hidden Internal use only.
  17907. */
  17908. _excludedMeshesIds: string[];
  17909. /**
  17910. * @hidden Internal use only.
  17911. */
  17912. _includedOnlyMeshesIds: string[];
  17913. /**
  17914. * The current light unifom buffer.
  17915. * @hidden Internal use only.
  17916. */
  17917. _uniformBuffer: UniformBuffer;
  17918. /** @hidden */
  17919. _renderId: number;
  17920. /**
  17921. * Creates a Light object in the scene.
  17922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17923. * @param name The firendly name of the light
  17924. * @param scene The scene the light belongs too
  17925. */
  17926. constructor(name: string, scene: Scene);
  17927. protected abstract _buildUniformLayout(): void;
  17928. /**
  17929. * Sets the passed Effect "effect" with the Light information.
  17930. * @param effect The effect to update
  17931. * @param lightIndex The index of the light in the effect to update
  17932. * @returns The light
  17933. */
  17934. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17935. /**
  17936. * Sets the passed Effect "effect" with the Light textures.
  17937. * @param effect The effect to update
  17938. * @param lightIndex The index of the light in the effect to update
  17939. * @returns The light
  17940. */
  17941. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17942. /**
  17943. * Binds the lights information from the scene to the effect for the given mesh.
  17944. * @param lightIndex Light index
  17945. * @param scene The scene where the light belongs to
  17946. * @param effect The effect we are binding the data to
  17947. * @param useSpecular Defines if specular is supported
  17948. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17949. */
  17950. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17951. /**
  17952. * Sets the passed Effect "effect" with the Light information.
  17953. * @param effect The effect to update
  17954. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17955. * @returns The light
  17956. */
  17957. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17958. /**
  17959. * Returns the string "Light".
  17960. * @returns the class name
  17961. */
  17962. getClassName(): string;
  17963. /** @hidden */
  17964. readonly _isLight: boolean;
  17965. /**
  17966. * Converts the light information to a readable string for debug purpose.
  17967. * @param fullDetails Supports for multiple levels of logging within scene loading
  17968. * @returns the human readable light info
  17969. */
  17970. toString(fullDetails?: boolean): string;
  17971. /** @hidden */
  17972. protected _syncParentEnabledState(): void;
  17973. /**
  17974. * Set the enabled state of this node.
  17975. * @param value - the new enabled state
  17976. */
  17977. setEnabled(value: boolean): void;
  17978. /**
  17979. * Returns the Light associated shadow generator if any.
  17980. * @return the associated shadow generator.
  17981. */
  17982. getShadowGenerator(): Nullable<IShadowGenerator>;
  17983. /**
  17984. * Returns a Vector3, the absolute light position in the World.
  17985. * @returns the world space position of the light
  17986. */
  17987. getAbsolutePosition(): Vector3;
  17988. /**
  17989. * Specifies if the light will affect the passed mesh.
  17990. * @param mesh The mesh to test against the light
  17991. * @return true the mesh is affected otherwise, false.
  17992. */
  17993. canAffectMesh(mesh: AbstractMesh): boolean;
  17994. /**
  17995. * Sort function to order lights for rendering.
  17996. * @param a First Light object to compare to second.
  17997. * @param b Second Light object to compare first.
  17998. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17999. */
  18000. static CompareLightsPriority(a: Light, b: Light): number;
  18001. /**
  18002. * Releases resources associated with this node.
  18003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18005. */
  18006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18007. /**
  18008. * Returns the light type ID (integer).
  18009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18010. */
  18011. getTypeID(): number;
  18012. /**
  18013. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18014. * @returns the scaled intensity in intensity mode unit
  18015. */
  18016. getScaledIntensity(): number;
  18017. /**
  18018. * Returns a new Light object, named "name", from the current one.
  18019. * @param name The name of the cloned light
  18020. * @param newParent The parent of this light, if it has one
  18021. * @returns the new created light
  18022. */
  18023. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18024. /**
  18025. * Serializes the current light into a Serialization object.
  18026. * @returns the serialized object.
  18027. */
  18028. serialize(): any;
  18029. /**
  18030. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18031. * This new light is named "name" and added to the passed scene.
  18032. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18033. * @param name The friendly name of the light
  18034. * @param scene The scene the new light will belong to
  18035. * @returns the constructor function
  18036. */
  18037. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18038. /**
  18039. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18040. * @param parsedLight The JSON representation of the light
  18041. * @param scene The scene to create the parsed light in
  18042. * @returns the created light after parsing
  18043. */
  18044. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18045. private _hookArrayForExcluded;
  18046. private _hookArrayForIncludedOnly;
  18047. private _resyncMeshes;
  18048. /**
  18049. * Forces the meshes to update their light related information in their rendering used effects
  18050. * @hidden Internal Use Only
  18051. */
  18052. _markMeshesAsLightDirty(): void;
  18053. /**
  18054. * Recomputes the cached photometric scale if needed.
  18055. */
  18056. private _computePhotometricScale;
  18057. /**
  18058. * Returns the Photometric Scale according to the light type and intensity mode.
  18059. */
  18060. private _getPhotometricScale;
  18061. /**
  18062. * Reorder the light in the scene according to their defined priority.
  18063. * @hidden Internal Use Only
  18064. */
  18065. _reorderLightsInScene(): void;
  18066. /**
  18067. * Prepares the list of defines specific to the light type.
  18068. * @param defines the list of defines
  18069. * @param lightIndex defines the index of the light for the effect
  18070. */
  18071. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18072. }
  18073. }
  18074. declare module BABYLON {
  18075. /**
  18076. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18077. * This is the base of the follow, arc rotate cameras and Free camera
  18078. * @see https://doc.babylonjs.com/features/cameras
  18079. */
  18080. export class TargetCamera extends Camera {
  18081. private static _RigCamTransformMatrix;
  18082. private static _TargetTransformMatrix;
  18083. private static _TargetFocalPoint;
  18084. private _tmpUpVector;
  18085. private _tmpTargetVector;
  18086. /**
  18087. * Define the current direction the camera is moving to
  18088. */
  18089. cameraDirection: Vector3;
  18090. /**
  18091. * Define the current rotation the camera is rotating to
  18092. */
  18093. cameraRotation: Vector2;
  18094. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18095. ignoreParentScaling: boolean;
  18096. /**
  18097. * When set, the up vector of the camera will be updated by the rotation of the camera
  18098. */
  18099. updateUpVectorFromRotation: boolean;
  18100. private _tmpQuaternion;
  18101. /**
  18102. * Define the current rotation of the camera
  18103. */
  18104. rotation: Vector3;
  18105. /**
  18106. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18107. */
  18108. rotationQuaternion: Quaternion;
  18109. /**
  18110. * Define the current speed of the camera
  18111. */
  18112. speed: number;
  18113. /**
  18114. * Add constraint to the camera to prevent it to move freely in all directions and
  18115. * around all axis.
  18116. */
  18117. noRotationConstraint: boolean;
  18118. /**
  18119. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18120. * panning
  18121. */
  18122. invertRotation: boolean;
  18123. /**
  18124. * Speed multiplier for inverse camera panning
  18125. */
  18126. inverseRotationSpeed: number;
  18127. /**
  18128. * Define the current target of the camera as an object or a position.
  18129. */
  18130. lockedTarget: any;
  18131. /** @hidden */
  18132. _currentTarget: Vector3;
  18133. /** @hidden */
  18134. _initialFocalDistance: number;
  18135. /** @hidden */
  18136. _viewMatrix: Matrix;
  18137. /** @hidden */
  18138. _camMatrix: Matrix;
  18139. /** @hidden */
  18140. _cameraTransformMatrix: Matrix;
  18141. /** @hidden */
  18142. _cameraRotationMatrix: Matrix;
  18143. /** @hidden */
  18144. _referencePoint: Vector3;
  18145. /** @hidden */
  18146. _transformedReferencePoint: Vector3;
  18147. /** @hidden */
  18148. _reset: () => void;
  18149. private _defaultUp;
  18150. /**
  18151. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18152. * This is the base of the follow, arc rotate cameras and Free camera
  18153. * @see https://doc.babylonjs.com/features/cameras
  18154. * @param name Defines the name of the camera in the scene
  18155. * @param position Defines the start position of the camera in the scene
  18156. * @param scene Defines the scene the camera belongs to
  18157. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18158. */
  18159. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18160. /**
  18161. * Gets the position in front of the camera at a given distance.
  18162. * @param distance The distance from the camera we want the position to be
  18163. * @returns the position
  18164. */
  18165. getFrontPosition(distance: number): Vector3;
  18166. /** @hidden */
  18167. _getLockedTargetPosition(): Nullable<Vector3>;
  18168. private _storedPosition;
  18169. private _storedRotation;
  18170. private _storedRotationQuaternion;
  18171. /**
  18172. * Store current camera state of the camera (fov, position, rotation, etc..)
  18173. * @returns the camera
  18174. */
  18175. storeState(): Camera;
  18176. /**
  18177. * Restored camera state. You must call storeState() first
  18178. * @returns whether it was successful or not
  18179. * @hidden
  18180. */
  18181. _restoreStateValues(): boolean;
  18182. /** @hidden */
  18183. _initCache(): void;
  18184. /** @hidden */
  18185. _updateCache(ignoreParentClass?: boolean): void;
  18186. /** @hidden */
  18187. _isSynchronizedViewMatrix(): boolean;
  18188. /** @hidden */
  18189. _computeLocalCameraSpeed(): number;
  18190. /**
  18191. * Defines the target the camera should look at.
  18192. * @param target Defines the new target as a Vector or a mesh
  18193. */
  18194. setTarget(target: Vector3): void;
  18195. /**
  18196. * Return the current target position of the camera. This value is expressed in local space.
  18197. * @returns the target position
  18198. */
  18199. getTarget(): Vector3;
  18200. /** @hidden */
  18201. _decideIfNeedsToMove(): boolean;
  18202. /** @hidden */
  18203. _updatePosition(): void;
  18204. /** @hidden */
  18205. _checkInputs(): void;
  18206. protected _updateCameraRotationMatrix(): void;
  18207. /**
  18208. * 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)
  18209. * @returns the current camera
  18210. */
  18211. private _rotateUpVectorWithCameraRotationMatrix;
  18212. private _cachedRotationZ;
  18213. private _cachedQuaternionRotationZ;
  18214. /** @hidden */
  18215. _getViewMatrix(): Matrix;
  18216. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18217. /**
  18218. * @hidden
  18219. */
  18220. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18221. /**
  18222. * @hidden
  18223. */
  18224. _updateRigCameras(): void;
  18225. private _getRigCamPositionAndTarget;
  18226. /**
  18227. * Gets the current object class name.
  18228. * @return the class name
  18229. */
  18230. getClassName(): string;
  18231. }
  18232. }
  18233. declare module BABYLON {
  18234. /**
  18235. * Gather the list of keyboard event types as constants.
  18236. */
  18237. export class KeyboardEventTypes {
  18238. /**
  18239. * The keydown event is fired when a key becomes active (pressed).
  18240. */
  18241. static readonly KEYDOWN: number;
  18242. /**
  18243. * The keyup event is fired when a key has been released.
  18244. */
  18245. static readonly KEYUP: number;
  18246. }
  18247. /**
  18248. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18249. */
  18250. export class KeyboardInfo {
  18251. /**
  18252. * Defines the type of event (KeyboardEventTypes)
  18253. */
  18254. type: number;
  18255. /**
  18256. * Defines the related dom event
  18257. */
  18258. event: KeyboardEvent;
  18259. /**
  18260. * Instantiates a new keyboard info.
  18261. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18262. * @param type Defines the type of event (KeyboardEventTypes)
  18263. * @param event Defines the related dom event
  18264. */
  18265. constructor(
  18266. /**
  18267. * Defines the type of event (KeyboardEventTypes)
  18268. */
  18269. type: number,
  18270. /**
  18271. * Defines the related dom event
  18272. */
  18273. event: KeyboardEvent);
  18274. }
  18275. /**
  18276. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18277. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18278. */
  18279. export class KeyboardInfoPre extends KeyboardInfo {
  18280. /**
  18281. * Defines the type of event (KeyboardEventTypes)
  18282. */
  18283. type: number;
  18284. /**
  18285. * Defines the related dom event
  18286. */
  18287. event: KeyboardEvent;
  18288. /**
  18289. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18290. */
  18291. skipOnPointerObservable: boolean;
  18292. /**
  18293. * Instantiates a new keyboard pre info.
  18294. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18295. * @param type Defines the type of event (KeyboardEventTypes)
  18296. * @param event Defines the related dom event
  18297. */
  18298. constructor(
  18299. /**
  18300. * Defines the type of event (KeyboardEventTypes)
  18301. */
  18302. type: number,
  18303. /**
  18304. * Defines the related dom event
  18305. */
  18306. event: KeyboardEvent);
  18307. }
  18308. }
  18309. declare module BABYLON {
  18310. /**
  18311. * Manage the keyboard inputs to control the movement of a free camera.
  18312. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18313. */
  18314. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18315. /**
  18316. * Defines the camera the input is attached to.
  18317. */
  18318. camera: FreeCamera;
  18319. /**
  18320. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18321. */
  18322. keysUp: number[];
  18323. /**
  18324. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18325. */
  18326. keysUpward: number[];
  18327. /**
  18328. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18329. */
  18330. keysDown: number[];
  18331. /**
  18332. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18333. */
  18334. keysDownward: number[];
  18335. /**
  18336. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18337. */
  18338. keysLeft: number[];
  18339. /**
  18340. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18341. */
  18342. keysRight: number[];
  18343. private _keys;
  18344. private _onCanvasBlurObserver;
  18345. private _onKeyboardObserver;
  18346. private _engine;
  18347. private _scene;
  18348. /**
  18349. * Attach the input controls to a specific dom element to get the input from.
  18350. * @param element Defines the element the controls should be listened from
  18351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18352. */
  18353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18354. /**
  18355. * Detach the current controls from the specified dom element.
  18356. * @param element Defines the element to stop listening the inputs from
  18357. */
  18358. detachControl(element: Nullable<HTMLElement>): void;
  18359. /**
  18360. * Update the current camera state depending on the inputs that have been used this frame.
  18361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18362. */
  18363. checkInputs(): void;
  18364. /**
  18365. * Gets the class name of the current intput.
  18366. * @returns the class name
  18367. */
  18368. getClassName(): string;
  18369. /** @hidden */
  18370. _onLostFocus(): void;
  18371. /**
  18372. * Get the friendly name associated with the input class.
  18373. * @returns the input friendly name
  18374. */
  18375. getSimpleName(): string;
  18376. }
  18377. }
  18378. declare module BABYLON {
  18379. /**
  18380. * Gather the list of pointer event types as constants.
  18381. */
  18382. export class PointerEventTypes {
  18383. /**
  18384. * 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.
  18385. */
  18386. static readonly POINTERDOWN: number;
  18387. /**
  18388. * The pointerup event is fired when a pointer is no longer active.
  18389. */
  18390. static readonly POINTERUP: number;
  18391. /**
  18392. * The pointermove event is fired when a pointer changes coordinates.
  18393. */
  18394. static readonly POINTERMOVE: number;
  18395. /**
  18396. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18397. */
  18398. static readonly POINTERWHEEL: number;
  18399. /**
  18400. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18401. */
  18402. static readonly POINTERPICK: number;
  18403. /**
  18404. * The pointertap event is fired when a the object has been touched and released without drag.
  18405. */
  18406. static readonly POINTERTAP: number;
  18407. /**
  18408. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18409. */
  18410. static readonly POINTERDOUBLETAP: number;
  18411. }
  18412. /**
  18413. * Base class of pointer info types.
  18414. */
  18415. export class PointerInfoBase {
  18416. /**
  18417. * Defines the type of event (PointerEventTypes)
  18418. */
  18419. type: number;
  18420. /**
  18421. * Defines the related dom event
  18422. */
  18423. event: PointerEvent | MouseWheelEvent;
  18424. /**
  18425. * Instantiates the base class of pointers info.
  18426. * @param type Defines the type of event (PointerEventTypes)
  18427. * @param event Defines the related dom event
  18428. */
  18429. constructor(
  18430. /**
  18431. * Defines the type of event (PointerEventTypes)
  18432. */
  18433. type: number,
  18434. /**
  18435. * Defines the related dom event
  18436. */
  18437. event: PointerEvent | MouseWheelEvent);
  18438. }
  18439. /**
  18440. * This class is used to store pointer related info for the onPrePointerObservable event.
  18441. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18442. */
  18443. export class PointerInfoPre extends PointerInfoBase {
  18444. /**
  18445. * Ray from a pointer if availible (eg. 6dof controller)
  18446. */
  18447. ray: Nullable<Ray>;
  18448. /**
  18449. * Defines the local position of the pointer on the canvas.
  18450. */
  18451. localPosition: Vector2;
  18452. /**
  18453. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18454. */
  18455. skipOnPointerObservable: boolean;
  18456. /**
  18457. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18458. * @param type Defines the type of event (PointerEventTypes)
  18459. * @param event Defines the related dom event
  18460. * @param localX Defines the local x coordinates of the pointer when the event occured
  18461. * @param localY Defines the local y coordinates of the pointer when the event occured
  18462. */
  18463. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18464. }
  18465. /**
  18466. * This type contains all the data related to a pointer event in Babylon.js.
  18467. * 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.
  18468. */
  18469. export class PointerInfo extends PointerInfoBase {
  18470. /**
  18471. * Defines the picking info associated to the info (if any)\
  18472. */
  18473. pickInfo: Nullable<PickingInfo>;
  18474. /**
  18475. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18476. * @param type Defines the type of event (PointerEventTypes)
  18477. * @param event Defines the related dom event
  18478. * @param pickInfo Defines the picking info associated to the info (if any)\
  18479. */
  18480. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18481. /**
  18482. * Defines the picking info associated to the info (if any)\
  18483. */
  18484. pickInfo: Nullable<PickingInfo>);
  18485. }
  18486. /**
  18487. * Data relating to a touch event on the screen.
  18488. */
  18489. export interface PointerTouch {
  18490. /**
  18491. * X coordinate of touch.
  18492. */
  18493. x: number;
  18494. /**
  18495. * Y coordinate of touch.
  18496. */
  18497. y: number;
  18498. /**
  18499. * Id of touch. Unique for each finger.
  18500. */
  18501. pointerId: number;
  18502. /**
  18503. * Event type passed from DOM.
  18504. */
  18505. type: any;
  18506. }
  18507. }
  18508. declare module BABYLON {
  18509. /**
  18510. * Manage the mouse inputs to control the movement of a free camera.
  18511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18512. */
  18513. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18514. /**
  18515. * Define if touch is enabled in the mouse input
  18516. */
  18517. touchEnabled: boolean;
  18518. /**
  18519. * Defines the camera the input is attached to.
  18520. */
  18521. camera: FreeCamera;
  18522. /**
  18523. * Defines the buttons associated with the input to handle camera move.
  18524. */
  18525. buttons: number[];
  18526. /**
  18527. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18528. */
  18529. angularSensibility: number;
  18530. private _pointerInput;
  18531. private _onMouseMove;
  18532. private _observer;
  18533. private previousPosition;
  18534. /**
  18535. * Observable for when a pointer move event occurs containing the move offset
  18536. */
  18537. onPointerMovedObservable: Observable<{
  18538. offsetX: number;
  18539. offsetY: number;
  18540. }>;
  18541. /**
  18542. * @hidden
  18543. * If the camera should be rotated automatically based on pointer movement
  18544. */
  18545. _allowCameraRotation: boolean;
  18546. /**
  18547. * Manage the mouse inputs to control the movement of a free camera.
  18548. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18549. * @param touchEnabled Defines if touch is enabled or not
  18550. */
  18551. constructor(
  18552. /**
  18553. * Define if touch is enabled in the mouse input
  18554. */
  18555. touchEnabled?: boolean);
  18556. /**
  18557. * Attach the input controls to a specific dom element to get the input from.
  18558. * @param element Defines the element the controls should be listened from
  18559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18560. */
  18561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18562. /**
  18563. * Called on JS contextmenu event.
  18564. * Override this method to provide functionality.
  18565. */
  18566. protected onContextMenu(evt: PointerEvent): void;
  18567. /**
  18568. * Detach the current controls from the specified dom element.
  18569. * @param element Defines the element to stop listening the inputs from
  18570. */
  18571. detachControl(element: Nullable<HTMLElement>): void;
  18572. /**
  18573. * Gets the class name of the current intput.
  18574. * @returns the class name
  18575. */
  18576. getClassName(): string;
  18577. /**
  18578. * Get the friendly name associated with the input class.
  18579. * @returns the input friendly name
  18580. */
  18581. getSimpleName(): string;
  18582. }
  18583. }
  18584. declare module BABYLON {
  18585. /**
  18586. * Manage the touch inputs to control the movement of a free camera.
  18587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18588. */
  18589. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18590. /**
  18591. * Defines the camera the input is attached to.
  18592. */
  18593. camera: FreeCamera;
  18594. /**
  18595. * Defines the touch sensibility for rotation.
  18596. * The higher the faster.
  18597. */
  18598. touchAngularSensibility: number;
  18599. /**
  18600. * Defines the touch sensibility for move.
  18601. * The higher the faster.
  18602. */
  18603. touchMoveSensibility: number;
  18604. private _offsetX;
  18605. private _offsetY;
  18606. private _pointerPressed;
  18607. private _pointerInput;
  18608. private _observer;
  18609. private _onLostFocus;
  18610. /**
  18611. * Attach the input controls to a specific dom element to get the input from.
  18612. * @param element Defines the element the controls should be listened from
  18613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18614. */
  18615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18616. /**
  18617. * Detach the current controls from the specified dom element.
  18618. * @param element Defines the element to stop listening the inputs from
  18619. */
  18620. detachControl(element: Nullable<HTMLElement>): void;
  18621. /**
  18622. * Update the current camera state depending on the inputs that have been used this frame.
  18623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18624. */
  18625. checkInputs(): void;
  18626. /**
  18627. * Gets the class name of the current intput.
  18628. * @returns the class name
  18629. */
  18630. getClassName(): string;
  18631. /**
  18632. * Get the friendly name associated with the input class.
  18633. * @returns the input friendly name
  18634. */
  18635. getSimpleName(): string;
  18636. }
  18637. }
  18638. declare module BABYLON {
  18639. /**
  18640. * Default Inputs manager for the FreeCamera.
  18641. * It groups all the default supported inputs for ease of use.
  18642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18643. */
  18644. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18645. /**
  18646. * @hidden
  18647. */
  18648. _mouseInput: Nullable<FreeCameraMouseInput>;
  18649. /**
  18650. * Instantiates a new FreeCameraInputsManager.
  18651. * @param camera Defines the camera the inputs belong to
  18652. */
  18653. constructor(camera: FreeCamera);
  18654. /**
  18655. * Add keyboard input support to the input manager.
  18656. * @returns the current input manager
  18657. */
  18658. addKeyboard(): FreeCameraInputsManager;
  18659. /**
  18660. * Add mouse input support to the input manager.
  18661. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18662. * @returns the current input manager
  18663. */
  18664. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18665. /**
  18666. * Removes the mouse input support from the manager
  18667. * @returns the current input manager
  18668. */
  18669. removeMouse(): FreeCameraInputsManager;
  18670. /**
  18671. * Add touch input support to the input manager.
  18672. * @returns the current input manager
  18673. */
  18674. addTouch(): FreeCameraInputsManager;
  18675. /**
  18676. * Remove all attached input methods from a camera
  18677. */
  18678. clear(): void;
  18679. }
  18680. }
  18681. declare module BABYLON {
  18682. /**
  18683. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18684. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18685. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18686. */
  18687. export class FreeCamera extends TargetCamera {
  18688. /**
  18689. * Define the collision ellipsoid of the camera.
  18690. * This is helpful to simulate a camera body like the player body around the camera
  18691. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18692. */
  18693. ellipsoid: Vector3;
  18694. /**
  18695. * Define an offset for the position of the ellipsoid around the camera.
  18696. * This can be helpful to determine the center of the body near the gravity center of the body
  18697. * instead of its head.
  18698. */
  18699. ellipsoidOffset: Vector3;
  18700. /**
  18701. * Enable or disable collisions of the camera with the rest of the scene objects.
  18702. */
  18703. checkCollisions: boolean;
  18704. /**
  18705. * Enable or disable gravity on the camera.
  18706. */
  18707. applyGravity: boolean;
  18708. /**
  18709. * Define the input manager associated to the camera.
  18710. */
  18711. inputs: FreeCameraInputsManager;
  18712. /**
  18713. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18714. * Higher values reduce sensitivity.
  18715. */
  18716. get angularSensibility(): number;
  18717. /**
  18718. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18719. * Higher values reduce sensitivity.
  18720. */
  18721. set angularSensibility(value: number);
  18722. /**
  18723. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18724. */
  18725. get keysUp(): number[];
  18726. set keysUp(value: number[]);
  18727. /**
  18728. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18729. */
  18730. get keysUpward(): number[];
  18731. set keysUpward(value: number[]);
  18732. /**
  18733. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18734. */
  18735. get keysDown(): number[];
  18736. set keysDown(value: number[]);
  18737. /**
  18738. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18739. */
  18740. get keysDownward(): number[];
  18741. set keysDownward(value: number[]);
  18742. /**
  18743. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18744. */
  18745. get keysLeft(): number[];
  18746. set keysLeft(value: number[]);
  18747. /**
  18748. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18749. */
  18750. get keysRight(): number[];
  18751. set keysRight(value: number[]);
  18752. /**
  18753. * Event raised when the camera collide with a mesh in the scene.
  18754. */
  18755. onCollide: (collidedMesh: AbstractMesh) => void;
  18756. private _collider;
  18757. private _needMoveForGravity;
  18758. private _oldPosition;
  18759. private _diffPosition;
  18760. private _newPosition;
  18761. /** @hidden */
  18762. _localDirection: Vector3;
  18763. /** @hidden */
  18764. _transformedDirection: Vector3;
  18765. /**
  18766. * Instantiates a Free Camera.
  18767. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18768. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18769. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18770. * @param name Define the name of the camera in the scene
  18771. * @param position Define the start position of the camera in the scene
  18772. * @param scene Define the scene the camera belongs to
  18773. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18774. */
  18775. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18776. /**
  18777. * Attached controls to the current camera.
  18778. * @param element Defines the element the controls should be listened from
  18779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18780. */
  18781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18782. /**
  18783. * Detach the current controls from the camera.
  18784. * The camera will stop reacting to inputs.
  18785. * @param element Defines the element to stop listening the inputs from
  18786. */
  18787. detachControl(element: HTMLElement): void;
  18788. private _collisionMask;
  18789. /**
  18790. * Define a collision mask to limit the list of object the camera can collide with
  18791. */
  18792. get collisionMask(): number;
  18793. set collisionMask(mask: number);
  18794. /** @hidden */
  18795. _collideWithWorld(displacement: Vector3): void;
  18796. private _onCollisionPositionChange;
  18797. /** @hidden */
  18798. _checkInputs(): void;
  18799. /** @hidden */
  18800. _decideIfNeedsToMove(): boolean;
  18801. /** @hidden */
  18802. _updatePosition(): void;
  18803. /**
  18804. * Destroy the camera and release the current resources hold by it.
  18805. */
  18806. dispose(): void;
  18807. /**
  18808. * Gets the current object class name.
  18809. * @return the class name
  18810. */
  18811. getClassName(): string;
  18812. }
  18813. }
  18814. declare module BABYLON {
  18815. /**
  18816. * Represents a gamepad control stick position
  18817. */
  18818. export class StickValues {
  18819. /**
  18820. * The x component of the control stick
  18821. */
  18822. x: number;
  18823. /**
  18824. * The y component of the control stick
  18825. */
  18826. y: number;
  18827. /**
  18828. * Initializes the gamepad x and y control stick values
  18829. * @param x The x component of the gamepad control stick value
  18830. * @param y The y component of the gamepad control stick value
  18831. */
  18832. constructor(
  18833. /**
  18834. * The x component of the control stick
  18835. */
  18836. x: number,
  18837. /**
  18838. * The y component of the control stick
  18839. */
  18840. y: number);
  18841. }
  18842. /**
  18843. * An interface which manages callbacks for gamepad button changes
  18844. */
  18845. export interface GamepadButtonChanges {
  18846. /**
  18847. * Called when a gamepad has been changed
  18848. */
  18849. changed: boolean;
  18850. /**
  18851. * Called when a gamepad press event has been triggered
  18852. */
  18853. pressChanged: boolean;
  18854. /**
  18855. * Called when a touch event has been triggered
  18856. */
  18857. touchChanged: boolean;
  18858. /**
  18859. * Called when a value has changed
  18860. */
  18861. valueChanged: boolean;
  18862. }
  18863. /**
  18864. * Represents a gamepad
  18865. */
  18866. export class Gamepad {
  18867. /**
  18868. * The id of the gamepad
  18869. */
  18870. id: string;
  18871. /**
  18872. * The index of the gamepad
  18873. */
  18874. index: number;
  18875. /**
  18876. * The browser gamepad
  18877. */
  18878. browserGamepad: any;
  18879. /**
  18880. * Specifies what type of gamepad this represents
  18881. */
  18882. type: number;
  18883. private _leftStick;
  18884. private _rightStick;
  18885. /** @hidden */
  18886. _isConnected: boolean;
  18887. private _leftStickAxisX;
  18888. private _leftStickAxisY;
  18889. private _rightStickAxisX;
  18890. private _rightStickAxisY;
  18891. /**
  18892. * Triggered when the left control stick has been changed
  18893. */
  18894. private _onleftstickchanged;
  18895. /**
  18896. * Triggered when the right control stick has been changed
  18897. */
  18898. private _onrightstickchanged;
  18899. /**
  18900. * Represents a gamepad controller
  18901. */
  18902. static GAMEPAD: number;
  18903. /**
  18904. * Represents a generic controller
  18905. */
  18906. static GENERIC: number;
  18907. /**
  18908. * Represents an XBox controller
  18909. */
  18910. static XBOX: number;
  18911. /**
  18912. * Represents a pose-enabled controller
  18913. */
  18914. static POSE_ENABLED: number;
  18915. /**
  18916. * Represents an Dual Shock controller
  18917. */
  18918. static DUALSHOCK: number;
  18919. /**
  18920. * Specifies whether the left control stick should be Y-inverted
  18921. */
  18922. protected _invertLeftStickY: boolean;
  18923. /**
  18924. * Specifies if the gamepad has been connected
  18925. */
  18926. get isConnected(): boolean;
  18927. /**
  18928. * Initializes the gamepad
  18929. * @param id The id of the gamepad
  18930. * @param index The index of the gamepad
  18931. * @param browserGamepad The browser gamepad
  18932. * @param leftStickX The x component of the left joystick
  18933. * @param leftStickY The y component of the left joystick
  18934. * @param rightStickX The x component of the right joystick
  18935. * @param rightStickY The y component of the right joystick
  18936. */
  18937. constructor(
  18938. /**
  18939. * The id of the gamepad
  18940. */
  18941. id: string,
  18942. /**
  18943. * The index of the gamepad
  18944. */
  18945. index: number,
  18946. /**
  18947. * The browser gamepad
  18948. */
  18949. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18950. /**
  18951. * Callback triggered when the left joystick has changed
  18952. * @param callback
  18953. */
  18954. onleftstickchanged(callback: (values: StickValues) => void): void;
  18955. /**
  18956. * Callback triggered when the right joystick has changed
  18957. * @param callback
  18958. */
  18959. onrightstickchanged(callback: (values: StickValues) => void): void;
  18960. /**
  18961. * Gets the left joystick
  18962. */
  18963. get leftStick(): StickValues;
  18964. /**
  18965. * Sets the left joystick values
  18966. */
  18967. set leftStick(newValues: StickValues);
  18968. /**
  18969. * Gets the right joystick
  18970. */
  18971. get rightStick(): StickValues;
  18972. /**
  18973. * Sets the right joystick value
  18974. */
  18975. set rightStick(newValues: StickValues);
  18976. /**
  18977. * Updates the gamepad joystick positions
  18978. */
  18979. update(): void;
  18980. /**
  18981. * Disposes the gamepad
  18982. */
  18983. dispose(): void;
  18984. }
  18985. /**
  18986. * Represents a generic gamepad
  18987. */
  18988. export class GenericPad extends Gamepad {
  18989. private _buttons;
  18990. private _onbuttondown;
  18991. private _onbuttonup;
  18992. /**
  18993. * Observable triggered when a button has been pressed
  18994. */
  18995. onButtonDownObservable: Observable<number>;
  18996. /**
  18997. * Observable triggered when a button has been released
  18998. */
  18999. onButtonUpObservable: Observable<number>;
  19000. /**
  19001. * Callback triggered when a button has been pressed
  19002. * @param callback Called when a button has been pressed
  19003. */
  19004. onbuttondown(callback: (buttonPressed: number) => void): void;
  19005. /**
  19006. * Callback triggered when a button has been released
  19007. * @param callback Called when a button has been released
  19008. */
  19009. onbuttonup(callback: (buttonReleased: number) => void): void;
  19010. /**
  19011. * Initializes the generic gamepad
  19012. * @param id The id of the generic gamepad
  19013. * @param index The index of the generic gamepad
  19014. * @param browserGamepad The browser gamepad
  19015. */
  19016. constructor(id: string, index: number, browserGamepad: any);
  19017. private _setButtonValue;
  19018. /**
  19019. * Updates the generic gamepad
  19020. */
  19021. update(): void;
  19022. /**
  19023. * Disposes the generic gamepad
  19024. */
  19025. dispose(): void;
  19026. }
  19027. }
  19028. declare module BABYLON {
  19029. /**
  19030. * Defines the types of pose enabled controllers that are supported
  19031. */
  19032. export enum PoseEnabledControllerType {
  19033. /**
  19034. * HTC Vive
  19035. */
  19036. VIVE = 0,
  19037. /**
  19038. * Oculus Rift
  19039. */
  19040. OCULUS = 1,
  19041. /**
  19042. * Windows mixed reality
  19043. */
  19044. WINDOWS = 2,
  19045. /**
  19046. * Samsung gear VR
  19047. */
  19048. GEAR_VR = 3,
  19049. /**
  19050. * Google Daydream
  19051. */
  19052. DAYDREAM = 4,
  19053. /**
  19054. * Generic
  19055. */
  19056. GENERIC = 5
  19057. }
  19058. /**
  19059. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19060. */
  19061. export interface MutableGamepadButton {
  19062. /**
  19063. * Value of the button/trigger
  19064. */
  19065. value: number;
  19066. /**
  19067. * If the button/trigger is currently touched
  19068. */
  19069. touched: boolean;
  19070. /**
  19071. * If the button/trigger is currently pressed
  19072. */
  19073. pressed: boolean;
  19074. }
  19075. /**
  19076. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19077. * @hidden
  19078. */
  19079. export interface ExtendedGamepadButton extends GamepadButton {
  19080. /**
  19081. * If the button/trigger is currently pressed
  19082. */
  19083. readonly pressed: boolean;
  19084. /**
  19085. * If the button/trigger is currently touched
  19086. */
  19087. readonly touched: boolean;
  19088. /**
  19089. * Value of the button/trigger
  19090. */
  19091. readonly value: number;
  19092. }
  19093. /** @hidden */
  19094. export interface _GamePadFactory {
  19095. /**
  19096. * Returns whether or not the current gamepad can be created for this type of controller.
  19097. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19098. * @returns true if it can be created, otherwise false
  19099. */
  19100. canCreate(gamepadInfo: any): boolean;
  19101. /**
  19102. * Creates a new instance of the Gamepad.
  19103. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19104. * @returns the new gamepad instance
  19105. */
  19106. create(gamepadInfo: any): Gamepad;
  19107. }
  19108. /**
  19109. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19110. */
  19111. export class PoseEnabledControllerHelper {
  19112. /** @hidden */
  19113. static _ControllerFactories: _GamePadFactory[];
  19114. /** @hidden */
  19115. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19116. /**
  19117. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19118. * @param vrGamepad the gamepad to initialized
  19119. * @returns a vr controller of the type the gamepad identified as
  19120. */
  19121. static InitiateController(vrGamepad: any): Gamepad;
  19122. }
  19123. /**
  19124. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19125. */
  19126. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19127. /**
  19128. * If the controller is used in a webXR session
  19129. */
  19130. isXR: boolean;
  19131. private _deviceRoomPosition;
  19132. private _deviceRoomRotationQuaternion;
  19133. /**
  19134. * The device position in babylon space
  19135. */
  19136. devicePosition: Vector3;
  19137. /**
  19138. * The device rotation in babylon space
  19139. */
  19140. deviceRotationQuaternion: Quaternion;
  19141. /**
  19142. * The scale factor of the device in babylon space
  19143. */
  19144. deviceScaleFactor: number;
  19145. /**
  19146. * (Likely devicePosition should be used instead) The device position in its room space
  19147. */
  19148. position: Vector3;
  19149. /**
  19150. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19151. */
  19152. rotationQuaternion: Quaternion;
  19153. /**
  19154. * The type of controller (Eg. Windows mixed reality)
  19155. */
  19156. controllerType: PoseEnabledControllerType;
  19157. protected _calculatedPosition: Vector3;
  19158. private _calculatedRotation;
  19159. /**
  19160. * The raw pose from the device
  19161. */
  19162. rawPose: DevicePose;
  19163. private _trackPosition;
  19164. private _maxRotationDistFromHeadset;
  19165. private _draggedRoomRotation;
  19166. /**
  19167. * @hidden
  19168. */
  19169. _disableTrackPosition(fixedPosition: Vector3): void;
  19170. /**
  19171. * Internal, the mesh attached to the controller
  19172. * @hidden
  19173. */
  19174. _mesh: Nullable<AbstractMesh>;
  19175. private _poseControlledCamera;
  19176. private _leftHandSystemQuaternion;
  19177. /**
  19178. * Internal, matrix used to convert room space to babylon space
  19179. * @hidden
  19180. */
  19181. _deviceToWorld: Matrix;
  19182. /**
  19183. * Node to be used when casting a ray from the controller
  19184. * @hidden
  19185. */
  19186. _pointingPoseNode: Nullable<TransformNode>;
  19187. /**
  19188. * Name of the child mesh that can be used to cast a ray from the controller
  19189. */
  19190. static readonly POINTING_POSE: string;
  19191. /**
  19192. * Creates a new PoseEnabledController from a gamepad
  19193. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19194. */
  19195. constructor(browserGamepad: any);
  19196. private _workingMatrix;
  19197. /**
  19198. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19199. */
  19200. update(): void;
  19201. /**
  19202. * Updates only the pose device and mesh without doing any button event checking
  19203. */
  19204. protected _updatePoseAndMesh(): void;
  19205. /**
  19206. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19207. * @param poseData raw pose fromthe device
  19208. */
  19209. updateFromDevice(poseData: DevicePose): void;
  19210. /**
  19211. * @hidden
  19212. */
  19213. _meshAttachedObservable: Observable<AbstractMesh>;
  19214. /**
  19215. * Attaches a mesh to the controller
  19216. * @param mesh the mesh to be attached
  19217. */
  19218. attachToMesh(mesh: AbstractMesh): void;
  19219. /**
  19220. * Attaches the controllers mesh to a camera
  19221. * @param camera the camera the mesh should be attached to
  19222. */
  19223. attachToPoseControlledCamera(camera: TargetCamera): void;
  19224. /**
  19225. * Disposes of the controller
  19226. */
  19227. dispose(): void;
  19228. /**
  19229. * The mesh that is attached to the controller
  19230. */
  19231. get mesh(): Nullable<AbstractMesh>;
  19232. /**
  19233. * Gets the ray of the controller in the direction the controller is pointing
  19234. * @param length the length the resulting ray should be
  19235. * @returns a ray in the direction the controller is pointing
  19236. */
  19237. getForwardRay(length?: number): Ray;
  19238. }
  19239. }
  19240. declare module BABYLON {
  19241. /**
  19242. * Defines the WebVRController object that represents controllers tracked in 3D space
  19243. */
  19244. export abstract class WebVRController extends PoseEnabledController {
  19245. /**
  19246. * Internal, the default controller model for the controller
  19247. */
  19248. protected _defaultModel: Nullable<AbstractMesh>;
  19249. /**
  19250. * Fired when the trigger state has changed
  19251. */
  19252. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19253. /**
  19254. * Fired when the main button state has changed
  19255. */
  19256. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19257. /**
  19258. * Fired when the secondary button state has changed
  19259. */
  19260. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19261. /**
  19262. * Fired when the pad state has changed
  19263. */
  19264. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19265. /**
  19266. * Fired when controllers stick values have changed
  19267. */
  19268. onPadValuesChangedObservable: Observable<StickValues>;
  19269. /**
  19270. * Array of button availible on the controller
  19271. */
  19272. protected _buttons: Array<MutableGamepadButton>;
  19273. private _onButtonStateChange;
  19274. /**
  19275. * Fired when a controller button's state has changed
  19276. * @param callback the callback containing the button that was modified
  19277. */
  19278. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19279. /**
  19280. * X and Y axis corresponding to the controllers joystick
  19281. */
  19282. pad: StickValues;
  19283. /**
  19284. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19285. */
  19286. hand: string;
  19287. /**
  19288. * The default controller model for the controller
  19289. */
  19290. get defaultModel(): Nullable<AbstractMesh>;
  19291. /**
  19292. * Creates a new WebVRController from a gamepad
  19293. * @param vrGamepad the gamepad that the WebVRController should be created from
  19294. */
  19295. constructor(vrGamepad: any);
  19296. /**
  19297. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19298. */
  19299. update(): void;
  19300. /**
  19301. * Function to be called when a button is modified
  19302. */
  19303. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19304. /**
  19305. * Loads a mesh and attaches it to the controller
  19306. * @param scene the scene the mesh should be added to
  19307. * @param meshLoaded callback for when the mesh has been loaded
  19308. */
  19309. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19310. private _setButtonValue;
  19311. private _changes;
  19312. private _checkChanges;
  19313. /**
  19314. * Disposes of th webVRCOntroller
  19315. */
  19316. dispose(): void;
  19317. }
  19318. }
  19319. declare module BABYLON {
  19320. /**
  19321. * The HemisphericLight simulates the ambient environment light,
  19322. * so the passed direction is the light reflection direction, not the incoming direction.
  19323. */
  19324. export class HemisphericLight extends Light {
  19325. /**
  19326. * The groundColor is the light in the opposite direction to the one specified during creation.
  19327. * 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.
  19328. */
  19329. groundColor: Color3;
  19330. /**
  19331. * The light reflection direction, not the incoming direction.
  19332. */
  19333. direction: Vector3;
  19334. /**
  19335. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19336. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19337. * The HemisphericLight can't cast shadows.
  19338. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19339. * @param name The friendly name of the light
  19340. * @param direction The direction of the light reflection
  19341. * @param scene The scene the light belongs to
  19342. */
  19343. constructor(name: string, direction: Vector3, scene: Scene);
  19344. protected _buildUniformLayout(): void;
  19345. /**
  19346. * Returns the string "HemisphericLight".
  19347. * @return The class name
  19348. */
  19349. getClassName(): string;
  19350. /**
  19351. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19352. * Returns the updated direction.
  19353. * @param target The target the direction should point to
  19354. * @return The computed direction
  19355. */
  19356. setDirectionToTarget(target: Vector3): Vector3;
  19357. /**
  19358. * Returns the shadow generator associated to the light.
  19359. * @returns Always null for hemispheric lights because it does not support shadows.
  19360. */
  19361. getShadowGenerator(): Nullable<IShadowGenerator>;
  19362. /**
  19363. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19364. * @param effect The effect to update
  19365. * @param lightIndex The index of the light in the effect to update
  19366. * @returns The hemispheric light
  19367. */
  19368. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19369. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19370. /**
  19371. * Computes the world matrix of the node
  19372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19373. * @param useWasUpdatedFlag defines a reserved property
  19374. * @returns the world matrix
  19375. */
  19376. computeWorldMatrix(): Matrix;
  19377. /**
  19378. * Returns the integer 3.
  19379. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19380. */
  19381. getTypeID(): number;
  19382. /**
  19383. * Prepares the list of defines specific to the light type.
  19384. * @param defines the list of defines
  19385. * @param lightIndex defines the index of the light for the effect
  19386. */
  19387. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19388. }
  19389. }
  19390. declare module BABYLON {
  19391. /** @hidden */
  19392. export var vrMultiviewToSingleviewPixelShader: {
  19393. name: string;
  19394. shader: string;
  19395. };
  19396. }
  19397. declare module BABYLON {
  19398. /**
  19399. * Renders to multiple views with a single draw call
  19400. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19401. */
  19402. export class MultiviewRenderTarget extends RenderTargetTexture {
  19403. /**
  19404. * Creates a multiview render target
  19405. * @param scene scene used with the render target
  19406. * @param size the size of the render target (used for each view)
  19407. */
  19408. constructor(scene: Scene, size?: number | {
  19409. width: number;
  19410. height: number;
  19411. } | {
  19412. ratio: number;
  19413. });
  19414. /**
  19415. * @hidden
  19416. * @param faceIndex the face index, if its a cube texture
  19417. */
  19418. _bindFrameBuffer(faceIndex?: number): void;
  19419. /**
  19420. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19421. * @returns the view count
  19422. */
  19423. getViewCount(): number;
  19424. }
  19425. }
  19426. declare module BABYLON {
  19427. interface Engine {
  19428. /**
  19429. * Creates a new multiview render target
  19430. * @param width defines the width of the texture
  19431. * @param height defines the height of the texture
  19432. * @returns the created multiview texture
  19433. */
  19434. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19435. /**
  19436. * Binds a multiview framebuffer to be drawn to
  19437. * @param multiviewTexture texture to bind
  19438. */
  19439. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19440. }
  19441. interface Camera {
  19442. /**
  19443. * @hidden
  19444. * 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)
  19445. */
  19446. _useMultiviewToSingleView: boolean;
  19447. /**
  19448. * @hidden
  19449. * 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)
  19450. */
  19451. _multiviewTexture: Nullable<RenderTargetTexture>;
  19452. /**
  19453. * @hidden
  19454. * ensures the multiview texture of the camera exists and has the specified width/height
  19455. * @param width height to set on the multiview texture
  19456. * @param height width to set on the multiview texture
  19457. */
  19458. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19459. }
  19460. interface Scene {
  19461. /** @hidden */
  19462. _transformMatrixR: Matrix;
  19463. /** @hidden */
  19464. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19465. /** @hidden */
  19466. _createMultiviewUbo(): void;
  19467. /** @hidden */
  19468. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19469. /** @hidden */
  19470. _renderMultiviewToSingleView(camera: Camera): void;
  19471. }
  19472. }
  19473. declare module BABYLON {
  19474. /**
  19475. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19476. * This will not be used for webXR as it supports displaying texture arrays directly
  19477. */
  19478. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19479. /**
  19480. * Initializes a VRMultiviewToSingleview
  19481. * @param name name of the post process
  19482. * @param camera camera to be applied to
  19483. * @param scaleFactor scaling factor to the size of the output texture
  19484. */
  19485. constructor(name: string, camera: Camera, scaleFactor: number);
  19486. }
  19487. }
  19488. declare module BABYLON {
  19489. /**
  19490. * Interface used to define additional presentation attributes
  19491. */
  19492. export interface IVRPresentationAttributes {
  19493. /**
  19494. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19495. */
  19496. highRefreshRate: boolean;
  19497. /**
  19498. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19499. */
  19500. foveationLevel: number;
  19501. }
  19502. interface Engine {
  19503. /** @hidden */
  19504. _vrDisplay: any;
  19505. /** @hidden */
  19506. _vrSupported: boolean;
  19507. /** @hidden */
  19508. _oldSize: Size;
  19509. /** @hidden */
  19510. _oldHardwareScaleFactor: number;
  19511. /** @hidden */
  19512. _vrExclusivePointerMode: boolean;
  19513. /** @hidden */
  19514. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19515. /** @hidden */
  19516. _onVRDisplayPointerRestricted: () => void;
  19517. /** @hidden */
  19518. _onVRDisplayPointerUnrestricted: () => void;
  19519. /** @hidden */
  19520. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19521. /** @hidden */
  19522. _onVrDisplayDisconnect: Nullable<() => void>;
  19523. /** @hidden */
  19524. _onVrDisplayPresentChange: Nullable<() => void>;
  19525. /**
  19526. * Observable signaled when VR display mode changes
  19527. */
  19528. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19529. /**
  19530. * Observable signaled when VR request present is complete
  19531. */
  19532. onVRRequestPresentComplete: Observable<boolean>;
  19533. /**
  19534. * Observable signaled when VR request present starts
  19535. */
  19536. onVRRequestPresentStart: Observable<Engine>;
  19537. /**
  19538. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19539. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19540. */
  19541. isInVRExclusivePointerMode: boolean;
  19542. /**
  19543. * Gets a boolean indicating if a webVR device was detected
  19544. * @returns true if a webVR device was detected
  19545. */
  19546. isVRDevicePresent(): boolean;
  19547. /**
  19548. * Gets the current webVR device
  19549. * @returns the current webVR device (or null)
  19550. */
  19551. getVRDevice(): any;
  19552. /**
  19553. * Initializes a webVR display and starts listening to display change events
  19554. * The onVRDisplayChangedObservable will be notified upon these changes
  19555. * @returns A promise containing a VRDisplay and if vr is supported
  19556. */
  19557. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19558. /** @hidden */
  19559. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19560. /**
  19561. * Gets or sets the presentation attributes used to configure VR rendering
  19562. */
  19563. vrPresentationAttributes?: IVRPresentationAttributes;
  19564. /**
  19565. * Call this function to switch to webVR mode
  19566. * Will do nothing if webVR is not supported or if there is no webVR device
  19567. * @param options the webvr options provided to the camera. mainly used for multiview
  19568. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19569. */
  19570. enableVR(options: WebVROptions): void;
  19571. /** @hidden */
  19572. _onVRFullScreenTriggered(): void;
  19573. }
  19574. }
  19575. declare module BABYLON {
  19576. /**
  19577. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19578. * IMPORTANT!! The data is right-hand data.
  19579. * @export
  19580. * @interface DevicePose
  19581. */
  19582. export interface DevicePose {
  19583. /**
  19584. * The position of the device, values in array are [x,y,z].
  19585. */
  19586. readonly position: Nullable<Float32Array>;
  19587. /**
  19588. * The linearVelocity of the device, values in array are [x,y,z].
  19589. */
  19590. readonly linearVelocity: Nullable<Float32Array>;
  19591. /**
  19592. * The linearAcceleration of the device, values in array are [x,y,z].
  19593. */
  19594. readonly linearAcceleration: Nullable<Float32Array>;
  19595. /**
  19596. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19597. */
  19598. readonly orientation: Nullable<Float32Array>;
  19599. /**
  19600. * The angularVelocity of the device, values in array are [x,y,z].
  19601. */
  19602. readonly angularVelocity: Nullable<Float32Array>;
  19603. /**
  19604. * The angularAcceleration of the device, values in array are [x,y,z].
  19605. */
  19606. readonly angularAcceleration: Nullable<Float32Array>;
  19607. }
  19608. /**
  19609. * Interface representing a pose controlled object in Babylon.
  19610. * A pose controlled object has both regular pose values as well as pose values
  19611. * from an external device such as a VR head mounted display
  19612. */
  19613. export interface PoseControlled {
  19614. /**
  19615. * The position of the object in babylon space.
  19616. */
  19617. position: Vector3;
  19618. /**
  19619. * The rotation quaternion of the object in babylon space.
  19620. */
  19621. rotationQuaternion: Quaternion;
  19622. /**
  19623. * The position of the device in babylon space.
  19624. */
  19625. devicePosition?: Vector3;
  19626. /**
  19627. * The rotation quaternion of the device in babylon space.
  19628. */
  19629. deviceRotationQuaternion: Quaternion;
  19630. /**
  19631. * The raw pose coming from the device.
  19632. */
  19633. rawPose: Nullable<DevicePose>;
  19634. /**
  19635. * The scale of the device to be used when translating from device space to babylon space.
  19636. */
  19637. deviceScaleFactor: number;
  19638. /**
  19639. * Updates the poseControlled values based on the input device pose.
  19640. * @param poseData the pose data to update the object with
  19641. */
  19642. updateFromDevice(poseData: DevicePose): void;
  19643. }
  19644. /**
  19645. * Set of options to customize the webVRCamera
  19646. */
  19647. export interface WebVROptions {
  19648. /**
  19649. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19650. */
  19651. trackPosition?: boolean;
  19652. /**
  19653. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19654. */
  19655. positionScale?: number;
  19656. /**
  19657. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19658. */
  19659. displayName?: string;
  19660. /**
  19661. * Should the native controller meshes be initialized. (default: true)
  19662. */
  19663. controllerMeshes?: boolean;
  19664. /**
  19665. * Creating a default HemiLight only on controllers. (default: true)
  19666. */
  19667. defaultLightingOnControllers?: boolean;
  19668. /**
  19669. * If you don't want to use the default VR button of the helper. (default: false)
  19670. */
  19671. useCustomVRButton?: boolean;
  19672. /**
  19673. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19674. */
  19675. customVRButton?: HTMLButtonElement;
  19676. /**
  19677. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19678. */
  19679. rayLength?: number;
  19680. /**
  19681. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19682. */
  19683. defaultHeight?: number;
  19684. /**
  19685. * If multiview should be used if availible (default: false)
  19686. */
  19687. useMultiview?: boolean;
  19688. }
  19689. /**
  19690. * This represents a WebVR camera.
  19691. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19692. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19693. */
  19694. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19695. private webVROptions;
  19696. /**
  19697. * @hidden
  19698. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19699. */
  19700. _vrDevice: any;
  19701. /**
  19702. * The rawPose of the vrDevice.
  19703. */
  19704. rawPose: Nullable<DevicePose>;
  19705. private _onVREnabled;
  19706. private _specsVersion;
  19707. private _attached;
  19708. private _frameData;
  19709. protected _descendants: Array<Node>;
  19710. private _deviceRoomPosition;
  19711. /** @hidden */
  19712. _deviceRoomRotationQuaternion: Quaternion;
  19713. private _standingMatrix;
  19714. /**
  19715. * Represents device position in babylon space.
  19716. */
  19717. devicePosition: Vector3;
  19718. /**
  19719. * Represents device rotation in babylon space.
  19720. */
  19721. deviceRotationQuaternion: Quaternion;
  19722. /**
  19723. * The scale of the device to be used when translating from device space to babylon space.
  19724. */
  19725. deviceScaleFactor: number;
  19726. private _deviceToWorld;
  19727. private _worldToDevice;
  19728. /**
  19729. * References to the webVR controllers for the vrDevice.
  19730. */
  19731. controllers: Array<WebVRController>;
  19732. /**
  19733. * Emits an event when a controller is attached.
  19734. */
  19735. onControllersAttachedObservable: Observable<WebVRController[]>;
  19736. /**
  19737. * Emits an event when a controller's mesh has been loaded;
  19738. */
  19739. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19740. /**
  19741. * Emits an event when the HMD's pose has been updated.
  19742. */
  19743. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19744. private _poseSet;
  19745. /**
  19746. * If the rig cameras be used as parent instead of this camera.
  19747. */
  19748. rigParenting: boolean;
  19749. private _lightOnControllers;
  19750. private _defaultHeight?;
  19751. /**
  19752. * Instantiates a WebVRFreeCamera.
  19753. * @param name The name of the WebVRFreeCamera
  19754. * @param position The starting anchor position for the camera
  19755. * @param scene The scene the camera belongs to
  19756. * @param webVROptions a set of customizable options for the webVRCamera
  19757. */
  19758. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19759. /**
  19760. * Gets the device distance from the ground in meters.
  19761. * @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.
  19762. */
  19763. deviceDistanceToRoomGround(): number;
  19764. /**
  19765. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19766. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19767. */
  19768. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19769. /**
  19770. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19771. * @returns A promise with a boolean set to if the standing matrix is supported.
  19772. */
  19773. useStandingMatrixAsync(): Promise<boolean>;
  19774. /**
  19775. * Disposes the camera
  19776. */
  19777. dispose(): void;
  19778. /**
  19779. * Gets a vrController by name.
  19780. * @param name The name of the controller to retreive
  19781. * @returns the controller matching the name specified or null if not found
  19782. */
  19783. getControllerByName(name: string): Nullable<WebVRController>;
  19784. private _leftController;
  19785. /**
  19786. * The controller corresponding to the users left hand.
  19787. */
  19788. get leftController(): Nullable<WebVRController>;
  19789. private _rightController;
  19790. /**
  19791. * The controller corresponding to the users right hand.
  19792. */
  19793. get rightController(): Nullable<WebVRController>;
  19794. /**
  19795. * Casts a ray forward from the vrCamera's gaze.
  19796. * @param length Length of the ray (default: 100)
  19797. * @returns the ray corresponding to the gaze
  19798. */
  19799. getForwardRay(length?: number): Ray;
  19800. /**
  19801. * @hidden
  19802. * Updates the camera based on device's frame data
  19803. */
  19804. _checkInputs(): void;
  19805. /**
  19806. * Updates the poseControlled values based on the input device pose.
  19807. * @param poseData Pose coming from the device
  19808. */
  19809. updateFromDevice(poseData: DevicePose): void;
  19810. private _htmlElementAttached;
  19811. private _detachIfAttached;
  19812. /**
  19813. * WebVR's attach control will start broadcasting frames to the device.
  19814. * Note that in certain browsers (chrome for example) this function must be called
  19815. * within a user-interaction callback. Example:
  19816. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19817. *
  19818. * @param element html element to attach the vrDevice to
  19819. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19820. */
  19821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19822. /**
  19823. * Detaches the camera from the html element and disables VR
  19824. *
  19825. * @param element html element to detach from
  19826. */
  19827. detachControl(element: HTMLElement): void;
  19828. /**
  19829. * @returns the name of this class
  19830. */
  19831. getClassName(): string;
  19832. /**
  19833. * Calls resetPose on the vrDisplay
  19834. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19835. */
  19836. resetToCurrentRotation(): void;
  19837. /**
  19838. * @hidden
  19839. * Updates the rig cameras (left and right eye)
  19840. */
  19841. _updateRigCameras(): void;
  19842. private _workingVector;
  19843. private _oneVector;
  19844. private _workingMatrix;
  19845. private updateCacheCalled;
  19846. private _correctPositionIfNotTrackPosition;
  19847. /**
  19848. * @hidden
  19849. * Updates the cached values of the camera
  19850. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19851. */
  19852. _updateCache(ignoreParentClass?: boolean): void;
  19853. /**
  19854. * @hidden
  19855. * Get current device position in babylon world
  19856. */
  19857. _computeDevicePosition(): void;
  19858. /**
  19859. * Updates the current device position and rotation in the babylon world
  19860. */
  19861. update(): void;
  19862. /**
  19863. * @hidden
  19864. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19865. * @returns an identity matrix
  19866. */
  19867. _getViewMatrix(): Matrix;
  19868. private _tmpMatrix;
  19869. /**
  19870. * This function is called by the two RIG cameras.
  19871. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19872. * @hidden
  19873. */
  19874. _getWebVRViewMatrix(): Matrix;
  19875. /** @hidden */
  19876. _getWebVRProjectionMatrix(): Matrix;
  19877. private _onGamepadConnectedObserver;
  19878. private _onGamepadDisconnectedObserver;
  19879. private _updateCacheWhenTrackingDisabledObserver;
  19880. /**
  19881. * Initializes the controllers and their meshes
  19882. */
  19883. initControllers(): void;
  19884. }
  19885. }
  19886. declare module BABYLON {
  19887. /**
  19888. * "Static Class" containing the most commonly used helper while dealing with material for
  19889. * rendering purpose.
  19890. *
  19891. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19892. *
  19893. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19894. */
  19895. export class MaterialHelper {
  19896. /**
  19897. * Bind the current view position to an effect.
  19898. * @param effect The effect to be bound
  19899. * @param scene The scene the eyes position is used from
  19900. * @param variableName name of the shader variable that will hold the eye position
  19901. */
  19902. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19903. /**
  19904. * Helps preparing the defines values about the UVs in used in the effect.
  19905. * UVs are shared as much as we can accross channels in the shaders.
  19906. * @param texture The texture we are preparing the UVs for
  19907. * @param defines The defines to update
  19908. * @param key The channel key "diffuse", "specular"... used in the shader
  19909. */
  19910. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19911. /**
  19912. * Binds a texture matrix value to its corrsponding uniform
  19913. * @param texture The texture to bind the matrix for
  19914. * @param uniformBuffer The uniform buffer receivin the data
  19915. * @param key The channel key "diffuse", "specular"... used in the shader
  19916. */
  19917. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19918. /**
  19919. * Gets the current status of the fog (should it be enabled?)
  19920. * @param mesh defines the mesh to evaluate for fog support
  19921. * @param scene defines the hosting scene
  19922. * @returns true if fog must be enabled
  19923. */
  19924. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19925. /**
  19926. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19927. * @param mesh defines the current mesh
  19928. * @param scene defines the current scene
  19929. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19930. * @param pointsCloud defines if point cloud rendering has to be turned on
  19931. * @param fogEnabled defines if fog has to be turned on
  19932. * @param alphaTest defines if alpha testing has to be turned on
  19933. * @param defines defines the current list of defines
  19934. */
  19935. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19936. /**
  19937. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19938. * @param scene defines the current scene
  19939. * @param engine defines the current engine
  19940. * @param defines specifies the list of active defines
  19941. * @param useInstances defines if instances have to be turned on
  19942. * @param useClipPlane defines if clip plane have to be turned on
  19943. * @param useInstances defines if instances have to be turned on
  19944. * @param useThinInstances defines if thin instances have to be turned on
  19945. */
  19946. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  19947. /**
  19948. * Prepares the defines for bones
  19949. * @param mesh The mesh containing the geometry data we will draw
  19950. * @param defines The defines to update
  19951. */
  19952. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  19953. /**
  19954. * Prepares the defines for morph targets
  19955. * @param mesh The mesh containing the geometry data we will draw
  19956. * @param defines The defines to update
  19957. */
  19958. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  19959. /**
  19960. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19961. * @param mesh The mesh containing the geometry data we will draw
  19962. * @param defines The defines to update
  19963. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19964. * @param useBones Precise whether bones should be used or not (override mesh info)
  19965. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19966. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19967. * @returns false if defines are considered not dirty and have not been checked
  19968. */
  19969. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19970. /**
  19971. * Prepares the defines related to multiview
  19972. * @param scene The scene we are intending to draw
  19973. * @param defines The defines to update
  19974. */
  19975. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  19976. /**
  19977. * Prepares the defines related to the prepass
  19978. * @param scene The scene we are intending to draw
  19979. * @param defines The defines to update
  19980. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  19981. */
  19982. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  19983. /**
  19984. * Prepares the defines related to the light information passed in parameter
  19985. * @param scene The scene we are intending to draw
  19986. * @param mesh The mesh the effect is compiling for
  19987. * @param light The light the effect is compiling for
  19988. * @param lightIndex The index of the light
  19989. * @param defines The defines to update
  19990. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  19991. * @param state Defines the current state regarding what is needed (normals, etc...)
  19992. */
  19993. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  19994. needNormals: boolean;
  19995. needRebuild: boolean;
  19996. shadowEnabled: boolean;
  19997. specularEnabled: boolean;
  19998. lightmapMode: boolean;
  19999. }): void;
  20000. /**
  20001. * Prepares the defines related to the light information passed in parameter
  20002. * @param scene The scene we are intending to draw
  20003. * @param mesh The mesh the effect is compiling for
  20004. * @param defines The defines to update
  20005. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20006. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20007. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20008. * @returns true if normals will be required for the rest of the effect
  20009. */
  20010. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20011. /**
  20012. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20013. * @param lightIndex defines the light index
  20014. * @param uniformsList The uniform list
  20015. * @param samplersList The sampler list
  20016. * @param projectedLightTexture defines if projected texture must be used
  20017. * @param uniformBuffersList defines an optional list of uniform buffers
  20018. */
  20019. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20020. /**
  20021. * Prepares the uniforms and samplers list to be used in the effect
  20022. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20023. * @param samplersList The sampler list
  20024. * @param defines The defines helping in the list generation
  20025. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20026. */
  20027. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20028. /**
  20029. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20030. * @param defines The defines to update while falling back
  20031. * @param fallbacks The authorized effect fallbacks
  20032. * @param maxSimultaneousLights The maximum number of lights allowed
  20033. * @param rank the current rank of the Effect
  20034. * @returns The newly affected rank
  20035. */
  20036. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20037. private static _TmpMorphInfluencers;
  20038. /**
  20039. * Prepares the list of attributes required for morph targets according to the effect defines.
  20040. * @param attribs The current list of supported attribs
  20041. * @param mesh The mesh to prepare the morph targets attributes for
  20042. * @param influencers The number of influencers
  20043. */
  20044. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20045. /**
  20046. * Prepares the list of attributes required for morph targets according to the effect defines.
  20047. * @param attribs The current list of supported attribs
  20048. * @param mesh The mesh to prepare the morph targets attributes for
  20049. * @param defines The current Defines of the effect
  20050. */
  20051. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20052. /**
  20053. * Prepares the list of attributes required for bones according to the effect defines.
  20054. * @param attribs The current list of supported attribs
  20055. * @param mesh The mesh to prepare the bones attributes for
  20056. * @param defines The current Defines of the effect
  20057. * @param fallbacks The current efffect fallback strategy
  20058. */
  20059. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20060. /**
  20061. * Check and prepare the list of attributes required for instances according to the effect defines.
  20062. * @param attribs The current list of supported attribs
  20063. * @param defines The current MaterialDefines of the effect
  20064. */
  20065. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20066. /**
  20067. * Add the list of attributes required for instances to the attribs array.
  20068. * @param attribs The current list of supported attribs
  20069. */
  20070. static PushAttributesForInstances(attribs: string[]): void;
  20071. /**
  20072. * Binds the light information to the effect.
  20073. * @param light The light containing the generator
  20074. * @param effect The effect we are binding the data to
  20075. * @param lightIndex The light index in the effect used to render
  20076. */
  20077. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20078. /**
  20079. * Binds the lights information from the scene to the effect for the given mesh.
  20080. * @param light Light to bind
  20081. * @param lightIndex Light index
  20082. * @param scene The scene where the light belongs to
  20083. * @param effect The effect we are binding the data to
  20084. * @param useSpecular Defines if specular is supported
  20085. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20086. */
  20087. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20088. /**
  20089. * Binds the lights information from the scene to the effect for the given mesh.
  20090. * @param scene The scene the lights belongs to
  20091. * @param mesh The mesh we are binding the information to render
  20092. * @param effect The effect we are binding the data to
  20093. * @param defines The generated defines for the effect
  20094. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20095. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20096. */
  20097. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20098. private static _tempFogColor;
  20099. /**
  20100. * Binds the fog information from the scene to the effect for the given mesh.
  20101. * @param scene The scene the lights belongs to
  20102. * @param mesh The mesh we are binding the information to render
  20103. * @param effect The effect we are binding the data to
  20104. * @param linearSpace Defines if the fog effect is applied in linear space
  20105. */
  20106. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20107. /**
  20108. * Binds the bones information from the mesh to the effect.
  20109. * @param mesh The mesh we are binding the information to render
  20110. * @param effect The effect we are binding the data to
  20111. */
  20112. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20113. /**
  20114. * Binds the morph targets information from the mesh to the effect.
  20115. * @param abstractMesh The mesh we are binding the information to render
  20116. * @param effect The effect we are binding the data to
  20117. */
  20118. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20119. /**
  20120. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20121. * @param defines The generated defines used in the effect
  20122. * @param effect The effect we are binding the data to
  20123. * @param scene The scene we are willing to render with logarithmic scale for
  20124. */
  20125. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20126. /**
  20127. * Binds the clip plane information from the scene to the effect.
  20128. * @param scene The scene the clip plane information are extracted from
  20129. * @param effect The effect we are binding the data to
  20130. */
  20131. static BindClipPlane(effect: Effect, scene: Scene): void;
  20132. }
  20133. }
  20134. declare module BABYLON {
  20135. /**
  20136. * Block used to expose an input value
  20137. */
  20138. export class InputBlock extends NodeMaterialBlock {
  20139. private _mode;
  20140. private _associatedVariableName;
  20141. private _storedValue;
  20142. private _valueCallback;
  20143. private _type;
  20144. private _animationType;
  20145. /** Gets or set a value used to limit the range of float values */
  20146. min: number;
  20147. /** Gets or set a value used to limit the range of float values */
  20148. max: number;
  20149. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20150. isBoolean: boolean;
  20151. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20152. matrixMode: number;
  20153. /** @hidden */
  20154. _systemValue: Nullable<NodeMaterialSystemValues>;
  20155. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20156. visibleInInspector: boolean;
  20157. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20158. isConstant: boolean;
  20159. /** Gets or sets the group to use to display this block in the Inspector */
  20160. groupInInspector: string;
  20161. /** Gets an observable raised when the value is changed */
  20162. onValueChangedObservable: Observable<InputBlock>;
  20163. /**
  20164. * Gets or sets the connection point type (default is float)
  20165. */
  20166. get type(): NodeMaterialBlockConnectionPointTypes;
  20167. /**
  20168. * Creates a new InputBlock
  20169. * @param name defines the block name
  20170. * @param target defines the target of that block (Vertex by default)
  20171. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20172. */
  20173. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20174. /**
  20175. * Gets the output component
  20176. */
  20177. get output(): NodeMaterialConnectionPoint;
  20178. /**
  20179. * Set the source of this connection point to a vertex attribute
  20180. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20181. * @returns the current connection point
  20182. */
  20183. setAsAttribute(attributeName?: string): InputBlock;
  20184. /**
  20185. * Set the source of this connection point to a system value
  20186. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20187. * @returns the current connection point
  20188. */
  20189. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20190. /**
  20191. * Gets or sets the value of that point.
  20192. * Please note that this value will be ignored if valueCallback is defined
  20193. */
  20194. get value(): any;
  20195. set value(value: any);
  20196. /**
  20197. * Gets or sets a callback used to get the value of that point.
  20198. * Please note that setting this value will force the connection point to ignore the value property
  20199. */
  20200. get valueCallback(): () => any;
  20201. set valueCallback(value: () => any);
  20202. /**
  20203. * Gets or sets the associated variable name in the shader
  20204. */
  20205. get associatedVariableName(): string;
  20206. set associatedVariableName(value: string);
  20207. /** Gets or sets the type of animation applied to the input */
  20208. get animationType(): AnimatedInputBlockTypes;
  20209. set animationType(value: AnimatedInputBlockTypes);
  20210. /**
  20211. * Gets a boolean indicating that this connection point not defined yet
  20212. */
  20213. get isUndefined(): boolean;
  20214. /**
  20215. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20216. * In this case the connection point name must be the name of the uniform to use.
  20217. * Can only be set on inputs
  20218. */
  20219. get isUniform(): boolean;
  20220. set isUniform(value: boolean);
  20221. /**
  20222. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20223. * In this case the connection point name must be the name of the attribute to use
  20224. * Can only be set on inputs
  20225. */
  20226. get isAttribute(): boolean;
  20227. set isAttribute(value: boolean);
  20228. /**
  20229. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20230. * Can only be set on exit points
  20231. */
  20232. get isVarying(): boolean;
  20233. set isVarying(value: boolean);
  20234. /**
  20235. * Gets a boolean indicating that the current connection point is a system value
  20236. */
  20237. get isSystemValue(): boolean;
  20238. /**
  20239. * Gets or sets the current well known value or null if not defined as a system value
  20240. */
  20241. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20242. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20243. /**
  20244. * Gets the current class name
  20245. * @returns the class name
  20246. */
  20247. getClassName(): string;
  20248. /**
  20249. * Animate the input if animationType !== None
  20250. * @param scene defines the rendering scene
  20251. */
  20252. animate(scene: Scene): void;
  20253. private _emitDefine;
  20254. initialize(state: NodeMaterialBuildState): void;
  20255. /**
  20256. * Set the input block to its default value (based on its type)
  20257. */
  20258. setDefaultValue(): void;
  20259. private _emitConstant;
  20260. /** @hidden */
  20261. get _noContextSwitch(): boolean;
  20262. private _emit;
  20263. /** @hidden */
  20264. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20265. /** @hidden */
  20266. _transmit(effect: Effect, scene: Scene): void;
  20267. protected _buildBlock(state: NodeMaterialBuildState): void;
  20268. protected _dumpPropertiesCode(): string;
  20269. dispose(): void;
  20270. serialize(): any;
  20271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20272. }
  20273. }
  20274. declare module BABYLON {
  20275. /**
  20276. * Enum used to define the compatibility state between two connection points
  20277. */
  20278. export enum NodeMaterialConnectionPointCompatibilityStates {
  20279. /** Points are compatibles */
  20280. Compatible = 0,
  20281. /** Points are incompatible because of their types */
  20282. TypeIncompatible = 1,
  20283. /** Points are incompatible because of their targets (vertex vs fragment) */
  20284. TargetIncompatible = 2
  20285. }
  20286. /**
  20287. * Defines the direction of a connection point
  20288. */
  20289. export enum NodeMaterialConnectionPointDirection {
  20290. /** Input */
  20291. Input = 0,
  20292. /** Output */
  20293. Output = 1
  20294. }
  20295. /**
  20296. * Defines a connection point for a block
  20297. */
  20298. export class NodeMaterialConnectionPoint {
  20299. /** @hidden */
  20300. _ownerBlock: NodeMaterialBlock;
  20301. /** @hidden */
  20302. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20303. private _endpoints;
  20304. private _associatedVariableName;
  20305. private _direction;
  20306. /** @hidden */
  20307. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20308. /** @hidden */
  20309. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20310. private _type;
  20311. /** @hidden */
  20312. _enforceAssociatedVariableName: boolean;
  20313. /** Gets the direction of the point */
  20314. get direction(): NodeMaterialConnectionPointDirection;
  20315. /** Indicates that this connection point needs dual validation before being connected to another point */
  20316. needDualDirectionValidation: boolean;
  20317. /**
  20318. * Gets or sets the additional types supported by this connection point
  20319. */
  20320. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20321. /**
  20322. * Gets or sets the additional types excluded by this connection point
  20323. */
  20324. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20325. /**
  20326. * Observable triggered when this point is connected
  20327. */
  20328. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20329. /**
  20330. * Gets or sets the associated variable name in the shader
  20331. */
  20332. get associatedVariableName(): string;
  20333. set associatedVariableName(value: string);
  20334. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20335. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20336. /**
  20337. * Gets or sets the connection point type (default is float)
  20338. */
  20339. get type(): NodeMaterialBlockConnectionPointTypes;
  20340. set type(value: NodeMaterialBlockConnectionPointTypes);
  20341. /**
  20342. * Gets or sets the connection point name
  20343. */
  20344. name: string;
  20345. /**
  20346. * Gets or sets the connection point name
  20347. */
  20348. displayName: string;
  20349. /**
  20350. * Gets or sets a boolean indicating that this connection point can be omitted
  20351. */
  20352. isOptional: boolean;
  20353. /**
  20354. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20355. */
  20356. isExposedOnFrame: boolean;
  20357. /**
  20358. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20359. */
  20360. define: string;
  20361. /** @hidden */
  20362. _prioritizeVertex: boolean;
  20363. private _target;
  20364. /** Gets or sets the target of that connection point */
  20365. get target(): NodeMaterialBlockTargets;
  20366. set target(value: NodeMaterialBlockTargets);
  20367. /**
  20368. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20369. */
  20370. get isConnected(): boolean;
  20371. /**
  20372. * Gets a boolean indicating that the current point is connected to an input block
  20373. */
  20374. get isConnectedToInputBlock(): boolean;
  20375. /**
  20376. * Gets a the connected input block (if any)
  20377. */
  20378. get connectInputBlock(): Nullable<InputBlock>;
  20379. /** Get the other side of the connection (if any) */
  20380. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20381. /** Get the block that owns this connection point */
  20382. get ownerBlock(): NodeMaterialBlock;
  20383. /** Get the block connected on the other side of this connection (if any) */
  20384. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20385. /** Get the block connected on the endpoints of this connection (if any) */
  20386. get connectedBlocks(): Array<NodeMaterialBlock>;
  20387. /** Gets the list of connected endpoints */
  20388. get endpoints(): NodeMaterialConnectionPoint[];
  20389. /** Gets a boolean indicating if that output point is connected to at least one input */
  20390. get hasEndpoints(): boolean;
  20391. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20392. get isConnectedInVertexShader(): boolean;
  20393. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20394. get isConnectedInFragmentShader(): boolean;
  20395. /**
  20396. * Creates a block suitable to be used as an input for this input point.
  20397. * If null is returned, a block based on the point type will be created.
  20398. * @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
  20399. */
  20400. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20401. /**
  20402. * Creates a new connection point
  20403. * @param name defines the connection point name
  20404. * @param ownerBlock defines the block hosting this connection point
  20405. * @param direction defines the direction of the connection point
  20406. */
  20407. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20408. /**
  20409. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20410. * @returns the class name
  20411. */
  20412. getClassName(): string;
  20413. /**
  20414. * Gets a boolean indicating if the current point can be connected to another point
  20415. * @param connectionPoint defines the other connection point
  20416. * @returns a boolean
  20417. */
  20418. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20419. /**
  20420. * Gets a number indicating if the current point can be connected to another point
  20421. * @param connectionPoint defines the other connection point
  20422. * @returns a number defining the compatibility state
  20423. */
  20424. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20425. /**
  20426. * Connect this point to another connection point
  20427. * @param connectionPoint defines the other connection point
  20428. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20429. * @returns the current connection point
  20430. */
  20431. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20432. /**
  20433. * Disconnect this point from one of his endpoint
  20434. * @param endpoint defines the other connection point
  20435. * @returns the current connection point
  20436. */
  20437. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20438. /**
  20439. * Serializes this point in a JSON representation
  20440. * @param isInput defines if the connection point is an input (default is true)
  20441. * @returns the serialized point object
  20442. */
  20443. serialize(isInput?: boolean): any;
  20444. /**
  20445. * Release resources
  20446. */
  20447. dispose(): void;
  20448. }
  20449. }
  20450. declare module BABYLON {
  20451. /**
  20452. * Enum used to define the material modes
  20453. */
  20454. export enum NodeMaterialModes {
  20455. /** Regular material */
  20456. Material = 0,
  20457. /** For post process */
  20458. PostProcess = 1,
  20459. /** For particle system */
  20460. Particle = 2
  20461. }
  20462. }
  20463. declare module BABYLON {
  20464. /**
  20465. * Block used to read a texture from a sampler
  20466. */
  20467. export class TextureBlock extends NodeMaterialBlock {
  20468. private _defineName;
  20469. private _linearDefineName;
  20470. private _gammaDefineName;
  20471. private _tempTextureRead;
  20472. private _samplerName;
  20473. private _transformedUVName;
  20474. private _textureTransformName;
  20475. private _textureInfoName;
  20476. private _mainUVName;
  20477. private _mainUVDefineName;
  20478. private _fragmentOnly;
  20479. /**
  20480. * Gets or sets the texture associated with the node
  20481. */
  20482. texture: Nullable<Texture>;
  20483. /**
  20484. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20485. */
  20486. convertToGammaSpace: boolean;
  20487. /**
  20488. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20489. */
  20490. convertToLinearSpace: boolean;
  20491. /**
  20492. * Create a new TextureBlock
  20493. * @param name defines the block name
  20494. */
  20495. constructor(name: string, fragmentOnly?: boolean);
  20496. /**
  20497. * Gets the current class name
  20498. * @returns the class name
  20499. */
  20500. getClassName(): string;
  20501. /**
  20502. * Gets the uv input component
  20503. */
  20504. get uv(): NodeMaterialConnectionPoint;
  20505. /**
  20506. * Gets the rgba output component
  20507. */
  20508. get rgba(): NodeMaterialConnectionPoint;
  20509. /**
  20510. * Gets the rgb output component
  20511. */
  20512. get rgb(): NodeMaterialConnectionPoint;
  20513. /**
  20514. * Gets the r output component
  20515. */
  20516. get r(): NodeMaterialConnectionPoint;
  20517. /**
  20518. * Gets the g output component
  20519. */
  20520. get g(): NodeMaterialConnectionPoint;
  20521. /**
  20522. * Gets the b output component
  20523. */
  20524. get b(): NodeMaterialConnectionPoint;
  20525. /**
  20526. * Gets the a output component
  20527. */
  20528. get a(): NodeMaterialConnectionPoint;
  20529. get target(): NodeMaterialBlockTargets;
  20530. autoConfigure(material: NodeMaterial): void;
  20531. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20532. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20533. isReady(): boolean;
  20534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20535. private get _isMixed();
  20536. private _injectVertexCode;
  20537. private _writeTextureRead;
  20538. private _writeOutput;
  20539. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20540. protected _dumpPropertiesCode(): string;
  20541. serialize(): any;
  20542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20543. }
  20544. }
  20545. declare module BABYLON {
  20546. /** @hidden */
  20547. export var reflectionFunction: {
  20548. name: string;
  20549. shader: string;
  20550. };
  20551. }
  20552. declare module BABYLON {
  20553. /**
  20554. * Base block used to read a reflection texture from a sampler
  20555. */
  20556. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20557. /** @hidden */
  20558. _define3DName: string;
  20559. /** @hidden */
  20560. _defineCubicName: string;
  20561. /** @hidden */
  20562. _defineExplicitName: string;
  20563. /** @hidden */
  20564. _defineProjectionName: string;
  20565. /** @hidden */
  20566. _defineLocalCubicName: string;
  20567. /** @hidden */
  20568. _defineSphericalName: string;
  20569. /** @hidden */
  20570. _definePlanarName: string;
  20571. /** @hidden */
  20572. _defineEquirectangularName: string;
  20573. /** @hidden */
  20574. _defineMirroredEquirectangularFixedName: string;
  20575. /** @hidden */
  20576. _defineEquirectangularFixedName: string;
  20577. /** @hidden */
  20578. _defineSkyboxName: string;
  20579. /** @hidden */
  20580. _defineOppositeZ: string;
  20581. /** @hidden */
  20582. _cubeSamplerName: string;
  20583. /** @hidden */
  20584. _2DSamplerName: string;
  20585. protected _positionUVWName: string;
  20586. protected _directionWName: string;
  20587. protected _reflectionVectorName: string;
  20588. /** @hidden */
  20589. _reflectionCoordsName: string;
  20590. /** @hidden */
  20591. _reflectionMatrixName: string;
  20592. protected _reflectionColorName: string;
  20593. /**
  20594. * Gets or sets the texture associated with the node
  20595. */
  20596. texture: Nullable<BaseTexture>;
  20597. /**
  20598. * Create a new ReflectionTextureBaseBlock
  20599. * @param name defines the block name
  20600. */
  20601. constructor(name: string);
  20602. /**
  20603. * Gets the current class name
  20604. * @returns the class name
  20605. */
  20606. getClassName(): string;
  20607. /**
  20608. * Gets the world position input component
  20609. */
  20610. abstract get position(): NodeMaterialConnectionPoint;
  20611. /**
  20612. * Gets the world position input component
  20613. */
  20614. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20615. /**
  20616. * Gets the world normal input component
  20617. */
  20618. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20619. /**
  20620. * Gets the world input component
  20621. */
  20622. abstract get world(): NodeMaterialConnectionPoint;
  20623. /**
  20624. * Gets the camera (or eye) position component
  20625. */
  20626. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20627. /**
  20628. * Gets the view input component
  20629. */
  20630. abstract get view(): NodeMaterialConnectionPoint;
  20631. protected _getTexture(): Nullable<BaseTexture>;
  20632. autoConfigure(material: NodeMaterial): void;
  20633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20634. isReady(): boolean;
  20635. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20636. /**
  20637. * Gets the code to inject in the vertex shader
  20638. * @param state current state of the node material building
  20639. * @returns the shader code
  20640. */
  20641. handleVertexSide(state: NodeMaterialBuildState): string;
  20642. /**
  20643. * Handles the inits for the fragment code path
  20644. * @param state node material build state
  20645. */
  20646. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20647. /**
  20648. * Generates the reflection coords code for the fragment code path
  20649. * @param worldNormalVarName name of the world normal variable
  20650. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20651. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20652. * @returns the shader code
  20653. */
  20654. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20655. /**
  20656. * Generates the reflection color code for the fragment code path
  20657. * @param lodVarName name of the lod variable
  20658. * @param swizzleLookupTexture swizzle to use for the final color variable
  20659. * @returns the shader code
  20660. */
  20661. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20662. /**
  20663. * Generates the code corresponding to the connected output points
  20664. * @param state node material build state
  20665. * @param varName name of the variable to output
  20666. * @returns the shader code
  20667. */
  20668. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20669. protected _buildBlock(state: NodeMaterialBuildState): this;
  20670. protected _dumpPropertiesCode(): string;
  20671. serialize(): any;
  20672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20673. }
  20674. }
  20675. declare module BABYLON {
  20676. /**
  20677. * Defines a connection point to be used for points with a custom object type
  20678. */
  20679. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20680. private _blockType;
  20681. private _blockName;
  20682. private _nameForCheking?;
  20683. /**
  20684. * Creates a new connection point
  20685. * @param name defines the connection point name
  20686. * @param ownerBlock defines the block hosting this connection point
  20687. * @param direction defines the direction of the connection point
  20688. */
  20689. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20690. /**
  20691. * Gets a number indicating if the current point can be connected to another point
  20692. * @param connectionPoint defines the other connection point
  20693. * @returns a number defining the compatibility state
  20694. */
  20695. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20696. /**
  20697. * Creates a block suitable to be used as an input for this input point.
  20698. * If null is returned, a block based on the point type will be created.
  20699. * @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
  20700. */
  20701. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20702. }
  20703. }
  20704. declare module BABYLON {
  20705. /**
  20706. * Enum defining the type of properties that can be edited in the property pages in the NME
  20707. */
  20708. export enum PropertyTypeForEdition {
  20709. /** property is a boolean */
  20710. Boolean = 0,
  20711. /** property is a float */
  20712. Float = 1,
  20713. /** property is a Vector2 */
  20714. Vector2 = 2,
  20715. /** property is a list of values */
  20716. List = 3
  20717. }
  20718. /**
  20719. * Interface that defines an option in a variable of type list
  20720. */
  20721. export interface IEditablePropertyListOption {
  20722. /** label of the option */
  20723. "label": string;
  20724. /** value of the option */
  20725. "value": number;
  20726. }
  20727. /**
  20728. * Interface that defines the options available for an editable property
  20729. */
  20730. export interface IEditablePropertyOption {
  20731. /** min value */
  20732. "min"?: number;
  20733. /** max value */
  20734. "max"?: number;
  20735. /** notifiers: indicates which actions to take when the property is changed */
  20736. "notifiers"?: {
  20737. /** the material should be rebuilt */
  20738. "rebuild"?: boolean;
  20739. /** the preview should be updated */
  20740. "update"?: boolean;
  20741. };
  20742. /** list of the options for a variable of type list */
  20743. "options"?: IEditablePropertyListOption[];
  20744. }
  20745. /**
  20746. * Interface that describes an editable property
  20747. */
  20748. export interface IPropertyDescriptionForEdition {
  20749. /** name of the property */
  20750. "propertyName": string;
  20751. /** display name of the property */
  20752. "displayName": string;
  20753. /** type of the property */
  20754. "type": PropertyTypeForEdition;
  20755. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20756. "groupName": string;
  20757. /** options for the property */
  20758. "options": IEditablePropertyOption;
  20759. }
  20760. /**
  20761. * Decorator that flags a property in a node material block as being editable
  20762. */
  20763. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20764. }
  20765. declare module BABYLON {
  20766. /**
  20767. * Block used to implement the refraction part of the sub surface module of the PBR material
  20768. */
  20769. export class RefractionBlock extends NodeMaterialBlock {
  20770. /** @hidden */
  20771. _define3DName: string;
  20772. /** @hidden */
  20773. _refractionMatrixName: string;
  20774. /** @hidden */
  20775. _defineLODRefractionAlpha: string;
  20776. /** @hidden */
  20777. _defineLinearSpecularRefraction: string;
  20778. /** @hidden */
  20779. _defineOppositeZ: string;
  20780. /** @hidden */
  20781. _cubeSamplerName: string;
  20782. /** @hidden */
  20783. _2DSamplerName: string;
  20784. /** @hidden */
  20785. _vRefractionMicrosurfaceInfosName: string;
  20786. /** @hidden */
  20787. _vRefractionInfosName: string;
  20788. private _scene;
  20789. /**
  20790. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20791. * Materials half opaque for instance using refraction could benefit from this control.
  20792. */
  20793. linkRefractionWithTransparency: boolean;
  20794. /**
  20795. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20796. */
  20797. invertRefractionY: boolean;
  20798. /**
  20799. * Gets or sets the texture associated with the node
  20800. */
  20801. texture: Nullable<BaseTexture>;
  20802. /**
  20803. * Create a new RefractionBlock
  20804. * @param name defines the block name
  20805. */
  20806. constructor(name: string);
  20807. /**
  20808. * Gets the current class name
  20809. * @returns the class name
  20810. */
  20811. getClassName(): string;
  20812. /**
  20813. * Gets the intensity input component
  20814. */
  20815. get intensity(): NodeMaterialConnectionPoint;
  20816. /**
  20817. * Gets the index of refraction input component
  20818. */
  20819. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20820. /**
  20821. * Gets the tint at distance input component
  20822. */
  20823. get tintAtDistance(): NodeMaterialConnectionPoint;
  20824. /**
  20825. * Gets the view input component
  20826. */
  20827. get view(): NodeMaterialConnectionPoint;
  20828. /**
  20829. * Gets the refraction object output component
  20830. */
  20831. get refraction(): NodeMaterialConnectionPoint;
  20832. /**
  20833. * Returns true if the block has a texture
  20834. */
  20835. get hasTexture(): boolean;
  20836. protected _getTexture(): Nullable<BaseTexture>;
  20837. autoConfigure(material: NodeMaterial): void;
  20838. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20839. isReady(): boolean;
  20840. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20841. /**
  20842. * Gets the main code of the block (fragment side)
  20843. * @param state current state of the node material building
  20844. * @returns the shader code
  20845. */
  20846. getCode(state: NodeMaterialBuildState): string;
  20847. protected _buildBlock(state: NodeMaterialBuildState): this;
  20848. protected _dumpPropertiesCode(): string;
  20849. serialize(): any;
  20850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20851. }
  20852. }
  20853. declare module BABYLON {
  20854. /**
  20855. * Base block used as input for post process
  20856. */
  20857. export class CurrentScreenBlock extends NodeMaterialBlock {
  20858. private _samplerName;
  20859. private _linearDefineName;
  20860. private _gammaDefineName;
  20861. private _mainUVName;
  20862. private _tempTextureRead;
  20863. /**
  20864. * Gets or sets the texture associated with the node
  20865. */
  20866. texture: Nullable<BaseTexture>;
  20867. /**
  20868. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20869. */
  20870. convertToGammaSpace: boolean;
  20871. /**
  20872. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20873. */
  20874. convertToLinearSpace: boolean;
  20875. /**
  20876. * Create a new CurrentScreenBlock
  20877. * @param name defines the block name
  20878. */
  20879. constructor(name: string);
  20880. /**
  20881. * Gets the current class name
  20882. * @returns the class name
  20883. */
  20884. getClassName(): string;
  20885. /**
  20886. * Gets the uv input component
  20887. */
  20888. get uv(): NodeMaterialConnectionPoint;
  20889. /**
  20890. * Gets the rgba output component
  20891. */
  20892. get rgba(): NodeMaterialConnectionPoint;
  20893. /**
  20894. * Gets the rgb output component
  20895. */
  20896. get rgb(): NodeMaterialConnectionPoint;
  20897. /**
  20898. * Gets the r output component
  20899. */
  20900. get r(): NodeMaterialConnectionPoint;
  20901. /**
  20902. * Gets the g output component
  20903. */
  20904. get g(): NodeMaterialConnectionPoint;
  20905. /**
  20906. * Gets the b output component
  20907. */
  20908. get b(): NodeMaterialConnectionPoint;
  20909. /**
  20910. * Gets the a output component
  20911. */
  20912. get a(): NodeMaterialConnectionPoint;
  20913. /**
  20914. * Initialize the block and prepare the context for build
  20915. * @param state defines the state that will be used for the build
  20916. */
  20917. initialize(state: NodeMaterialBuildState): void;
  20918. get target(): NodeMaterialBlockTargets;
  20919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20920. isReady(): boolean;
  20921. private _injectVertexCode;
  20922. private _writeTextureRead;
  20923. private _writeOutput;
  20924. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20925. serialize(): any;
  20926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20927. }
  20928. }
  20929. declare module BABYLON {
  20930. /**
  20931. * Base block used for the particle texture
  20932. */
  20933. export class ParticleTextureBlock extends NodeMaterialBlock {
  20934. private _samplerName;
  20935. private _linearDefineName;
  20936. private _gammaDefineName;
  20937. private _tempTextureRead;
  20938. /**
  20939. * Gets or sets the texture associated with the node
  20940. */
  20941. texture: Nullable<BaseTexture>;
  20942. /**
  20943. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20944. */
  20945. convertToGammaSpace: boolean;
  20946. /**
  20947. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20948. */
  20949. convertToLinearSpace: boolean;
  20950. /**
  20951. * Create a new ParticleTextureBlock
  20952. * @param name defines the block name
  20953. */
  20954. constructor(name: string);
  20955. /**
  20956. * Gets the current class name
  20957. * @returns the class name
  20958. */
  20959. getClassName(): string;
  20960. /**
  20961. * Gets the uv input component
  20962. */
  20963. get uv(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the rgba output component
  20966. */
  20967. get rgba(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Gets the rgb output component
  20970. */
  20971. get rgb(): NodeMaterialConnectionPoint;
  20972. /**
  20973. * Gets the r output component
  20974. */
  20975. get r(): NodeMaterialConnectionPoint;
  20976. /**
  20977. * Gets the g output component
  20978. */
  20979. get g(): NodeMaterialConnectionPoint;
  20980. /**
  20981. * Gets the b output component
  20982. */
  20983. get b(): NodeMaterialConnectionPoint;
  20984. /**
  20985. * Gets the a output component
  20986. */
  20987. get a(): NodeMaterialConnectionPoint;
  20988. /**
  20989. * Initialize the block and prepare the context for build
  20990. * @param state defines the state that will be used for the build
  20991. */
  20992. initialize(state: NodeMaterialBuildState): void;
  20993. autoConfigure(material: NodeMaterial): void;
  20994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20995. isReady(): boolean;
  20996. private _writeOutput;
  20997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20998. serialize(): any;
  20999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21000. }
  21001. }
  21002. declare module BABYLON {
  21003. /**
  21004. * Class used to store shared data between 2 NodeMaterialBuildState
  21005. */
  21006. export class NodeMaterialBuildStateSharedData {
  21007. /**
  21008. * Gets the list of emitted varyings
  21009. */
  21010. temps: string[];
  21011. /**
  21012. * Gets the list of emitted varyings
  21013. */
  21014. varyings: string[];
  21015. /**
  21016. * Gets the varying declaration string
  21017. */
  21018. varyingDeclaration: string;
  21019. /**
  21020. * Input blocks
  21021. */
  21022. inputBlocks: InputBlock[];
  21023. /**
  21024. * Input blocks
  21025. */
  21026. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21027. /**
  21028. * Bindable blocks (Blocks that need to set data to the effect)
  21029. */
  21030. bindableBlocks: NodeMaterialBlock[];
  21031. /**
  21032. * List of blocks that can provide a compilation fallback
  21033. */
  21034. blocksWithFallbacks: NodeMaterialBlock[];
  21035. /**
  21036. * List of blocks that can provide a define update
  21037. */
  21038. blocksWithDefines: NodeMaterialBlock[];
  21039. /**
  21040. * List of blocks that can provide a repeatable content
  21041. */
  21042. repeatableContentBlocks: NodeMaterialBlock[];
  21043. /**
  21044. * List of blocks that can provide a dynamic list of uniforms
  21045. */
  21046. dynamicUniformBlocks: NodeMaterialBlock[];
  21047. /**
  21048. * List of blocks that can block the isReady function for the material
  21049. */
  21050. blockingBlocks: NodeMaterialBlock[];
  21051. /**
  21052. * Gets the list of animated inputs
  21053. */
  21054. animatedInputs: InputBlock[];
  21055. /**
  21056. * Build Id used to avoid multiple recompilations
  21057. */
  21058. buildId: number;
  21059. /** List of emitted variables */
  21060. variableNames: {
  21061. [key: string]: number;
  21062. };
  21063. /** List of emitted defines */
  21064. defineNames: {
  21065. [key: string]: number;
  21066. };
  21067. /** Should emit comments? */
  21068. emitComments: boolean;
  21069. /** Emit build activity */
  21070. verbose: boolean;
  21071. /** Gets or sets the hosting scene */
  21072. scene: Scene;
  21073. /**
  21074. * Gets the compilation hints emitted at compilation time
  21075. */
  21076. hints: {
  21077. needWorldViewMatrix: boolean;
  21078. needWorldViewProjectionMatrix: boolean;
  21079. needAlphaBlending: boolean;
  21080. needAlphaTesting: boolean;
  21081. };
  21082. /**
  21083. * List of compilation checks
  21084. */
  21085. checks: {
  21086. emitVertex: boolean;
  21087. emitFragment: boolean;
  21088. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21089. };
  21090. /**
  21091. * Is vertex program allowed to be empty?
  21092. */
  21093. allowEmptyVertexProgram: boolean;
  21094. /** Creates a new shared data */
  21095. constructor();
  21096. /**
  21097. * Emits console errors and exceptions if there is a failing check
  21098. */
  21099. emitErrors(): void;
  21100. }
  21101. }
  21102. declare module BABYLON {
  21103. /**
  21104. * Class used to store node based material build state
  21105. */
  21106. export class NodeMaterialBuildState {
  21107. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21108. supportUniformBuffers: boolean;
  21109. /**
  21110. * Gets the list of emitted attributes
  21111. */
  21112. attributes: string[];
  21113. /**
  21114. * Gets the list of emitted uniforms
  21115. */
  21116. uniforms: string[];
  21117. /**
  21118. * Gets the list of emitted constants
  21119. */
  21120. constants: string[];
  21121. /**
  21122. * Gets the list of emitted samplers
  21123. */
  21124. samplers: string[];
  21125. /**
  21126. * Gets the list of emitted functions
  21127. */
  21128. functions: {
  21129. [key: string]: string;
  21130. };
  21131. /**
  21132. * Gets the list of emitted extensions
  21133. */
  21134. extensions: {
  21135. [key: string]: string;
  21136. };
  21137. /**
  21138. * Gets the target of the compilation state
  21139. */
  21140. target: NodeMaterialBlockTargets;
  21141. /**
  21142. * Gets the list of emitted counters
  21143. */
  21144. counters: {
  21145. [key: string]: number;
  21146. };
  21147. /**
  21148. * Shared data between multiple NodeMaterialBuildState instances
  21149. */
  21150. sharedData: NodeMaterialBuildStateSharedData;
  21151. /** @hidden */
  21152. _vertexState: NodeMaterialBuildState;
  21153. /** @hidden */
  21154. _attributeDeclaration: string;
  21155. /** @hidden */
  21156. _uniformDeclaration: string;
  21157. /** @hidden */
  21158. _constantDeclaration: string;
  21159. /** @hidden */
  21160. _samplerDeclaration: string;
  21161. /** @hidden */
  21162. _varyingTransfer: string;
  21163. /** @hidden */
  21164. _injectAtEnd: string;
  21165. private _repeatableContentAnchorIndex;
  21166. /** @hidden */
  21167. _builtCompilationString: string;
  21168. /**
  21169. * Gets the emitted compilation strings
  21170. */
  21171. compilationString: string;
  21172. /**
  21173. * Finalize the compilation strings
  21174. * @param state defines the current compilation state
  21175. */
  21176. finalize(state: NodeMaterialBuildState): void;
  21177. /** @hidden */
  21178. get _repeatableContentAnchor(): string;
  21179. /** @hidden */
  21180. _getFreeVariableName(prefix: string): string;
  21181. /** @hidden */
  21182. _getFreeDefineName(prefix: string): string;
  21183. /** @hidden */
  21184. _excludeVariableName(name: string): void;
  21185. /** @hidden */
  21186. _emit2DSampler(name: string): void;
  21187. /** @hidden */
  21188. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21189. /** @hidden */
  21190. _emitExtension(name: string, extension: string, define?: string): void;
  21191. /** @hidden */
  21192. _emitFunction(name: string, code: string, comments: string): void;
  21193. /** @hidden */
  21194. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21195. replaceStrings?: {
  21196. search: RegExp;
  21197. replace: string;
  21198. }[];
  21199. repeatKey?: string;
  21200. }): string;
  21201. /** @hidden */
  21202. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21203. repeatKey?: string;
  21204. removeAttributes?: boolean;
  21205. removeUniforms?: boolean;
  21206. removeVaryings?: boolean;
  21207. removeIfDef?: boolean;
  21208. replaceStrings?: {
  21209. search: RegExp;
  21210. replace: string;
  21211. }[];
  21212. }, storeKey?: string): void;
  21213. /** @hidden */
  21214. _registerTempVariable(name: string): boolean;
  21215. /** @hidden */
  21216. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21217. /** @hidden */
  21218. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21219. /** @hidden */
  21220. _emitFloat(value: number): string;
  21221. }
  21222. }
  21223. declare module BABYLON {
  21224. /**
  21225. * Helper class used to generate session unique ID
  21226. */
  21227. export class UniqueIdGenerator {
  21228. private static _UniqueIdCounter;
  21229. /**
  21230. * Gets an unique (relatively to the current scene) Id
  21231. */
  21232. static get UniqueId(): number;
  21233. }
  21234. }
  21235. declare module BABYLON {
  21236. /**
  21237. * Defines a block that can be used inside a node based material
  21238. */
  21239. export class NodeMaterialBlock {
  21240. private _buildId;
  21241. private _buildTarget;
  21242. private _target;
  21243. private _isFinalMerger;
  21244. private _isInput;
  21245. protected _isUnique: boolean;
  21246. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21247. inputsAreExclusive: boolean;
  21248. /** @hidden */
  21249. _codeVariableName: string;
  21250. /** @hidden */
  21251. _inputs: NodeMaterialConnectionPoint[];
  21252. /** @hidden */
  21253. _outputs: NodeMaterialConnectionPoint[];
  21254. /** @hidden */
  21255. _preparationId: number;
  21256. /**
  21257. * Gets or sets the name of the block
  21258. */
  21259. name: string;
  21260. /**
  21261. * Gets or sets the unique id of the node
  21262. */
  21263. uniqueId: number;
  21264. /**
  21265. * Gets or sets the comments associated with this block
  21266. */
  21267. comments: string;
  21268. /**
  21269. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21270. */
  21271. get isUnique(): boolean;
  21272. /**
  21273. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21274. */
  21275. get isFinalMerger(): boolean;
  21276. /**
  21277. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21278. */
  21279. get isInput(): boolean;
  21280. /**
  21281. * Gets or sets the build Id
  21282. */
  21283. get buildId(): number;
  21284. set buildId(value: number);
  21285. /**
  21286. * Gets or sets the target of the block
  21287. */
  21288. get target(): NodeMaterialBlockTargets;
  21289. set target(value: NodeMaterialBlockTargets);
  21290. /**
  21291. * Gets the list of input points
  21292. */
  21293. get inputs(): NodeMaterialConnectionPoint[];
  21294. /** Gets the list of output points */
  21295. get outputs(): NodeMaterialConnectionPoint[];
  21296. /**
  21297. * Find an input by its name
  21298. * @param name defines the name of the input to look for
  21299. * @returns the input or null if not found
  21300. */
  21301. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21302. /**
  21303. * Find an output by its name
  21304. * @param name defines the name of the outputto look for
  21305. * @returns the output or null if not found
  21306. */
  21307. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21308. /**
  21309. * Creates a new NodeMaterialBlock
  21310. * @param name defines the block name
  21311. * @param target defines the target of that block (Vertex by default)
  21312. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21313. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21314. */
  21315. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21316. /**
  21317. * Initialize the block and prepare the context for build
  21318. * @param state defines the state that will be used for the build
  21319. */
  21320. initialize(state: NodeMaterialBuildState): void;
  21321. /**
  21322. * Bind data to effect. Will only be called for blocks with isBindable === true
  21323. * @param effect defines the effect to bind data to
  21324. * @param nodeMaterial defines the hosting NodeMaterial
  21325. * @param mesh defines the mesh that will be rendered
  21326. * @param subMesh defines the submesh that will be rendered
  21327. */
  21328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21329. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21330. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21331. protected _writeFloat(value: number): string;
  21332. /**
  21333. * Gets the current class name e.g. "NodeMaterialBlock"
  21334. * @returns the class name
  21335. */
  21336. getClassName(): string;
  21337. /**
  21338. * Register a new input. Must be called inside a block constructor
  21339. * @param name defines the connection point name
  21340. * @param type defines the connection point type
  21341. * @param isOptional defines a boolean indicating that this input can be omitted
  21342. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21343. * @param point an already created connection point. If not provided, create a new one
  21344. * @returns the current block
  21345. */
  21346. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21347. /**
  21348. * Register a new output. Must be called inside a block constructor
  21349. * @param name defines the connection point name
  21350. * @param type defines the connection point type
  21351. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21352. * @param point an already created connection point. If not provided, create a new one
  21353. * @returns the current block
  21354. */
  21355. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21356. /**
  21357. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21358. * @param forOutput defines an optional connection point to check compatibility with
  21359. * @returns the first available input or null
  21360. */
  21361. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21362. /**
  21363. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21364. * @param forBlock defines an optional block to check compatibility with
  21365. * @returns the first available input or null
  21366. */
  21367. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21368. /**
  21369. * Gets the sibling of the given output
  21370. * @param current defines the current output
  21371. * @returns the next output in the list or null
  21372. */
  21373. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21374. /**
  21375. * Connect current block with another block
  21376. * @param other defines the block to connect with
  21377. * @param options define the various options to help pick the right connections
  21378. * @returns the current block
  21379. */
  21380. connectTo(other: NodeMaterialBlock, options?: {
  21381. input?: string;
  21382. output?: string;
  21383. outputSwizzle?: string;
  21384. }): this | undefined;
  21385. protected _buildBlock(state: NodeMaterialBuildState): void;
  21386. /**
  21387. * Add uniforms, samplers and uniform buffers at compilation time
  21388. * @param state defines the state to update
  21389. * @param nodeMaterial defines the node material requesting the update
  21390. * @param defines defines the material defines to update
  21391. * @param uniformBuffers defines the list of uniform buffer names
  21392. */
  21393. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21394. /**
  21395. * Add potential fallbacks if shader compilation fails
  21396. * @param mesh defines the mesh to be rendered
  21397. * @param fallbacks defines the current prioritized list of fallbacks
  21398. */
  21399. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21400. /**
  21401. * Initialize defines for shader compilation
  21402. * @param mesh defines the mesh to be rendered
  21403. * @param nodeMaterial defines the node material requesting the update
  21404. * @param defines defines the material defines to update
  21405. * @param useInstances specifies that instances should be used
  21406. */
  21407. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21408. /**
  21409. * Update defines for shader compilation
  21410. * @param mesh defines the mesh to be rendered
  21411. * @param nodeMaterial defines the node material requesting the update
  21412. * @param defines defines the material defines to update
  21413. * @param useInstances specifies that instances should be used
  21414. * @param subMesh defines which submesh to render
  21415. */
  21416. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21417. /**
  21418. * Lets the block try to connect some inputs automatically
  21419. * @param material defines the hosting NodeMaterial
  21420. */
  21421. autoConfigure(material: NodeMaterial): void;
  21422. /**
  21423. * Function called when a block is declared as repeatable content generator
  21424. * @param vertexShaderState defines the current compilation state for the vertex shader
  21425. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21426. * @param mesh defines the mesh to be rendered
  21427. * @param defines defines the material defines to update
  21428. */
  21429. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21430. /**
  21431. * Checks if the block is ready
  21432. * @param mesh defines the mesh to be rendered
  21433. * @param nodeMaterial defines the node material requesting the update
  21434. * @param defines defines the material defines to update
  21435. * @param useInstances specifies that instances should be used
  21436. * @returns true if the block is ready
  21437. */
  21438. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21439. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21440. private _processBuild;
  21441. /**
  21442. * Compile the current node and generate the shader code
  21443. * @param state defines the current compilation state (uniforms, samplers, current string)
  21444. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21445. * @returns true if already built
  21446. */
  21447. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21448. protected _inputRename(name: string): string;
  21449. protected _outputRename(name: string): string;
  21450. protected _dumpPropertiesCode(): string;
  21451. /** @hidden */
  21452. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21453. /** @hidden */
  21454. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21455. /**
  21456. * Clone the current block to a new identical block
  21457. * @param scene defines the hosting scene
  21458. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21459. * @returns a copy of the current block
  21460. */
  21461. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21462. /**
  21463. * Serializes this block in a JSON representation
  21464. * @returns the serialized block object
  21465. */
  21466. serialize(): any;
  21467. /** @hidden */
  21468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21469. private _deserializePortDisplayNamesAndExposedOnFrame;
  21470. /**
  21471. * Release resources
  21472. */
  21473. dispose(): void;
  21474. }
  21475. }
  21476. declare module BABYLON {
  21477. /**
  21478. * Base class of materials working in push mode in babylon JS
  21479. * @hidden
  21480. */
  21481. export class PushMaterial extends Material {
  21482. protected _activeEffect: Effect;
  21483. protected _normalMatrix: Matrix;
  21484. constructor(name: string, scene: Scene);
  21485. getEffect(): Effect;
  21486. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21487. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21488. /**
  21489. * Binds the given world matrix to the active effect
  21490. *
  21491. * @param world the matrix to bind
  21492. */
  21493. bindOnlyWorldMatrix(world: Matrix): void;
  21494. /**
  21495. * Binds the given normal matrix to the active effect
  21496. *
  21497. * @param normalMatrix the matrix to bind
  21498. */
  21499. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21500. bind(world: Matrix, mesh?: Mesh): void;
  21501. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21502. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21503. }
  21504. }
  21505. declare module BABYLON {
  21506. /**
  21507. * Root class for all node material optimizers
  21508. */
  21509. export class NodeMaterialOptimizer {
  21510. /**
  21511. * Function used to optimize a NodeMaterial graph
  21512. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21513. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21514. */
  21515. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21516. }
  21517. }
  21518. declare module BABYLON {
  21519. /**
  21520. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21521. */
  21522. export class TransformBlock extends NodeMaterialBlock {
  21523. /**
  21524. * Defines the value to use to complement W value to transform it to a Vector4
  21525. */
  21526. complementW: number;
  21527. /**
  21528. * Defines the value to use to complement z value to transform it to a Vector4
  21529. */
  21530. complementZ: number;
  21531. /**
  21532. * Creates a new TransformBlock
  21533. * @param name defines the block name
  21534. */
  21535. constructor(name: string);
  21536. /**
  21537. * Gets the current class name
  21538. * @returns the class name
  21539. */
  21540. getClassName(): string;
  21541. /**
  21542. * Gets the vector input
  21543. */
  21544. get vector(): NodeMaterialConnectionPoint;
  21545. /**
  21546. * Gets the output component
  21547. */
  21548. get output(): NodeMaterialConnectionPoint;
  21549. /**
  21550. * Gets the xyz output component
  21551. */
  21552. get xyz(): NodeMaterialConnectionPoint;
  21553. /**
  21554. * Gets the matrix transform input
  21555. */
  21556. get transform(): NodeMaterialConnectionPoint;
  21557. protected _buildBlock(state: NodeMaterialBuildState): this;
  21558. /**
  21559. * Update defines for shader compilation
  21560. * @param mesh defines the mesh to be rendered
  21561. * @param nodeMaterial defines the node material requesting the update
  21562. * @param defines defines the material defines to update
  21563. * @param useInstances specifies that instances should be used
  21564. * @param subMesh defines which submesh to render
  21565. */
  21566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21567. serialize(): any;
  21568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21569. protected _dumpPropertiesCode(): string;
  21570. }
  21571. }
  21572. declare module BABYLON {
  21573. /**
  21574. * Block used to output the vertex position
  21575. */
  21576. export class VertexOutputBlock extends NodeMaterialBlock {
  21577. /**
  21578. * Creates a new VertexOutputBlock
  21579. * @param name defines the block name
  21580. */
  21581. constructor(name: string);
  21582. /**
  21583. * Gets the current class name
  21584. * @returns the class name
  21585. */
  21586. getClassName(): string;
  21587. /**
  21588. * Gets the vector input component
  21589. */
  21590. get vector(): NodeMaterialConnectionPoint;
  21591. protected _buildBlock(state: NodeMaterialBuildState): this;
  21592. }
  21593. }
  21594. declare module BABYLON {
  21595. /**
  21596. * Block used to output the final color
  21597. */
  21598. export class FragmentOutputBlock extends NodeMaterialBlock {
  21599. /**
  21600. * Create a new FragmentOutputBlock
  21601. * @param name defines the block name
  21602. */
  21603. constructor(name: string);
  21604. /**
  21605. * Gets the current class name
  21606. * @returns the class name
  21607. */
  21608. getClassName(): string;
  21609. /**
  21610. * Gets the rgba input component
  21611. */
  21612. get rgba(): NodeMaterialConnectionPoint;
  21613. /**
  21614. * Gets the rgb input component
  21615. */
  21616. get rgb(): NodeMaterialConnectionPoint;
  21617. /**
  21618. * Gets the a input component
  21619. */
  21620. get a(): NodeMaterialConnectionPoint;
  21621. protected _buildBlock(state: NodeMaterialBuildState): this;
  21622. }
  21623. }
  21624. declare module BABYLON {
  21625. /**
  21626. * Block used for the particle ramp gradient section
  21627. */
  21628. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21629. /**
  21630. * Create a new ParticleRampGradientBlock
  21631. * @param name defines the block name
  21632. */
  21633. constructor(name: string);
  21634. /**
  21635. * Gets the current class name
  21636. * @returns the class name
  21637. */
  21638. getClassName(): string;
  21639. /**
  21640. * Gets the color input component
  21641. */
  21642. get color(): NodeMaterialConnectionPoint;
  21643. /**
  21644. * Gets the rampColor output component
  21645. */
  21646. get rampColor(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Initialize the block and prepare the context for build
  21649. * @param state defines the state that will be used for the build
  21650. */
  21651. initialize(state: NodeMaterialBuildState): void;
  21652. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21653. }
  21654. }
  21655. declare module BABYLON {
  21656. /**
  21657. * Block used for the particle blend multiply section
  21658. */
  21659. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21660. /**
  21661. * Create a new ParticleBlendMultiplyBlock
  21662. * @param name defines the block name
  21663. */
  21664. constructor(name: string);
  21665. /**
  21666. * Gets the current class name
  21667. * @returns the class name
  21668. */
  21669. getClassName(): string;
  21670. /**
  21671. * Gets the color input component
  21672. */
  21673. get color(): NodeMaterialConnectionPoint;
  21674. /**
  21675. * Gets the alphaTexture input component
  21676. */
  21677. get alphaTexture(): NodeMaterialConnectionPoint;
  21678. /**
  21679. * Gets the alphaColor input component
  21680. */
  21681. get alphaColor(): NodeMaterialConnectionPoint;
  21682. /**
  21683. * Gets the blendColor output component
  21684. */
  21685. get blendColor(): NodeMaterialConnectionPoint;
  21686. /**
  21687. * Initialize the block and prepare the context for build
  21688. * @param state defines the state that will be used for the build
  21689. */
  21690. initialize(state: NodeMaterialBuildState): void;
  21691. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21692. }
  21693. }
  21694. declare module BABYLON {
  21695. /**
  21696. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21697. */
  21698. export class VectorMergerBlock extends NodeMaterialBlock {
  21699. /**
  21700. * Create a new VectorMergerBlock
  21701. * @param name defines the block name
  21702. */
  21703. constructor(name: string);
  21704. /**
  21705. * Gets the current class name
  21706. * @returns the class name
  21707. */
  21708. getClassName(): string;
  21709. /**
  21710. * Gets the xyz component (input)
  21711. */
  21712. get xyzIn(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the xy component (input)
  21715. */
  21716. get xyIn(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the x component (input)
  21719. */
  21720. get x(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Gets the y component (input)
  21723. */
  21724. get y(): NodeMaterialConnectionPoint;
  21725. /**
  21726. * Gets the z component (input)
  21727. */
  21728. get z(): NodeMaterialConnectionPoint;
  21729. /**
  21730. * Gets the w component (input)
  21731. */
  21732. get w(): NodeMaterialConnectionPoint;
  21733. /**
  21734. * Gets the xyzw component (output)
  21735. */
  21736. get xyzw(): NodeMaterialConnectionPoint;
  21737. /**
  21738. * Gets the xyz component (output)
  21739. */
  21740. get xyzOut(): NodeMaterialConnectionPoint;
  21741. /**
  21742. * Gets the xy component (output)
  21743. */
  21744. get xyOut(): NodeMaterialConnectionPoint;
  21745. /**
  21746. * Gets the xy component (output)
  21747. * @deprecated Please use xyOut instead.
  21748. */
  21749. get xy(): NodeMaterialConnectionPoint;
  21750. /**
  21751. * Gets the xyz component (output)
  21752. * @deprecated Please use xyzOut instead.
  21753. */
  21754. get xyz(): NodeMaterialConnectionPoint;
  21755. protected _buildBlock(state: NodeMaterialBuildState): this;
  21756. }
  21757. }
  21758. declare module BABYLON {
  21759. /**
  21760. * Block used to remap a float from a range to a new one
  21761. */
  21762. export class RemapBlock extends NodeMaterialBlock {
  21763. /**
  21764. * Gets or sets the source range
  21765. */
  21766. sourceRange: Vector2;
  21767. /**
  21768. * Gets or sets the target range
  21769. */
  21770. targetRange: Vector2;
  21771. /**
  21772. * Creates a new RemapBlock
  21773. * @param name defines the block name
  21774. */
  21775. constructor(name: string);
  21776. /**
  21777. * Gets the current class name
  21778. * @returns the class name
  21779. */
  21780. getClassName(): string;
  21781. /**
  21782. * Gets the input component
  21783. */
  21784. get input(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the source min input component
  21787. */
  21788. get sourceMin(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the source max input component
  21791. */
  21792. get sourceMax(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Gets the target min input component
  21795. */
  21796. get targetMin(): NodeMaterialConnectionPoint;
  21797. /**
  21798. * Gets the target max input component
  21799. */
  21800. get targetMax(): NodeMaterialConnectionPoint;
  21801. /**
  21802. * Gets the output component
  21803. */
  21804. get output(): NodeMaterialConnectionPoint;
  21805. protected _buildBlock(state: NodeMaterialBuildState): this;
  21806. protected _dumpPropertiesCode(): string;
  21807. serialize(): any;
  21808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21809. }
  21810. }
  21811. declare module BABYLON {
  21812. /**
  21813. * Block used to multiply 2 values
  21814. */
  21815. export class MultiplyBlock extends NodeMaterialBlock {
  21816. /**
  21817. * Creates a new MultiplyBlock
  21818. * @param name defines the block name
  21819. */
  21820. constructor(name: string);
  21821. /**
  21822. * Gets the current class name
  21823. * @returns the class name
  21824. */
  21825. getClassName(): string;
  21826. /**
  21827. * Gets the left operand input component
  21828. */
  21829. get left(): NodeMaterialConnectionPoint;
  21830. /**
  21831. * Gets the right operand input component
  21832. */
  21833. get right(): NodeMaterialConnectionPoint;
  21834. /**
  21835. * Gets the output component
  21836. */
  21837. get output(): NodeMaterialConnectionPoint;
  21838. protected _buildBlock(state: NodeMaterialBuildState): this;
  21839. }
  21840. }
  21841. declare module BABYLON {
  21842. /**
  21843. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21844. */
  21845. export class ColorSplitterBlock extends NodeMaterialBlock {
  21846. /**
  21847. * Create a new ColorSplitterBlock
  21848. * @param name defines the block name
  21849. */
  21850. constructor(name: string);
  21851. /**
  21852. * Gets the current class name
  21853. * @returns the class name
  21854. */
  21855. getClassName(): string;
  21856. /**
  21857. * Gets the rgba component (input)
  21858. */
  21859. get rgba(): NodeMaterialConnectionPoint;
  21860. /**
  21861. * Gets the rgb component (input)
  21862. */
  21863. get rgbIn(): NodeMaterialConnectionPoint;
  21864. /**
  21865. * Gets the rgb component (output)
  21866. */
  21867. get rgbOut(): NodeMaterialConnectionPoint;
  21868. /**
  21869. * Gets the r component (output)
  21870. */
  21871. get r(): NodeMaterialConnectionPoint;
  21872. /**
  21873. * Gets the g component (output)
  21874. */
  21875. get g(): NodeMaterialConnectionPoint;
  21876. /**
  21877. * Gets the b component (output)
  21878. */
  21879. get b(): NodeMaterialConnectionPoint;
  21880. /**
  21881. * Gets the a component (output)
  21882. */
  21883. get a(): NodeMaterialConnectionPoint;
  21884. protected _inputRename(name: string): string;
  21885. protected _outputRename(name: string): string;
  21886. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21887. }
  21888. }
  21889. declare module BABYLON {
  21890. /**
  21891. * Interface used to configure the node material editor
  21892. */
  21893. export interface INodeMaterialEditorOptions {
  21894. /** Define the URl to load node editor script */
  21895. editorURL?: string;
  21896. }
  21897. /** @hidden */
  21898. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21899. NORMAL: boolean;
  21900. TANGENT: boolean;
  21901. UV1: boolean;
  21902. /** BONES */
  21903. NUM_BONE_INFLUENCERS: number;
  21904. BonesPerMesh: number;
  21905. BONETEXTURE: boolean;
  21906. /** MORPH TARGETS */
  21907. MORPHTARGETS: boolean;
  21908. MORPHTARGETS_NORMAL: boolean;
  21909. MORPHTARGETS_TANGENT: boolean;
  21910. MORPHTARGETS_UV: boolean;
  21911. NUM_MORPH_INFLUENCERS: number;
  21912. /** IMAGE PROCESSING */
  21913. IMAGEPROCESSING: boolean;
  21914. VIGNETTE: boolean;
  21915. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21916. VIGNETTEBLENDMODEOPAQUE: boolean;
  21917. TONEMAPPING: boolean;
  21918. TONEMAPPING_ACES: boolean;
  21919. CONTRAST: boolean;
  21920. EXPOSURE: boolean;
  21921. COLORCURVES: boolean;
  21922. COLORGRADING: boolean;
  21923. COLORGRADING3D: boolean;
  21924. SAMPLER3DGREENDEPTH: boolean;
  21925. SAMPLER3DBGRMAP: boolean;
  21926. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21927. /** MISC. */
  21928. BUMPDIRECTUV: number;
  21929. constructor();
  21930. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21931. }
  21932. /**
  21933. * Class used to configure NodeMaterial
  21934. */
  21935. export interface INodeMaterialOptions {
  21936. /**
  21937. * Defines if blocks should emit comments
  21938. */
  21939. emitComments: boolean;
  21940. }
  21941. /**
  21942. * Class used to create a node based material built by assembling shader blocks
  21943. */
  21944. export class NodeMaterial extends PushMaterial {
  21945. private static _BuildIdGenerator;
  21946. private _options;
  21947. private _vertexCompilationState;
  21948. private _fragmentCompilationState;
  21949. private _sharedData;
  21950. private _buildId;
  21951. private _buildWasSuccessful;
  21952. private _cachedWorldViewMatrix;
  21953. private _cachedWorldViewProjectionMatrix;
  21954. private _optimizers;
  21955. private _animationFrame;
  21956. /** Define the Url to load node editor script */
  21957. static EditorURL: string;
  21958. /** Define the Url to load snippets */
  21959. static SnippetUrl: string;
  21960. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  21961. static IgnoreTexturesAtLoadTime: boolean;
  21962. private BJSNODEMATERIALEDITOR;
  21963. /** Get the inspector from bundle or global */
  21964. private _getGlobalNodeMaterialEditor;
  21965. /**
  21966. * Snippet ID if the material was created from the snippet server
  21967. */
  21968. snippetId: string;
  21969. /**
  21970. * Gets or sets data used by visual editor
  21971. * @see https://nme.babylonjs.com
  21972. */
  21973. editorData: any;
  21974. /**
  21975. * 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)
  21976. */
  21977. ignoreAlpha: boolean;
  21978. /**
  21979. * Defines the maximum number of lights that can be used in the material
  21980. */
  21981. maxSimultaneousLights: number;
  21982. /**
  21983. * Observable raised when the material is built
  21984. */
  21985. onBuildObservable: Observable<NodeMaterial>;
  21986. /**
  21987. * Gets or sets the root nodes of the material vertex shader
  21988. */
  21989. _vertexOutputNodes: NodeMaterialBlock[];
  21990. /**
  21991. * Gets or sets the root nodes of the material fragment (pixel) shader
  21992. */
  21993. _fragmentOutputNodes: NodeMaterialBlock[];
  21994. /** Gets or sets options to control the node material overall behavior */
  21995. get options(): INodeMaterialOptions;
  21996. set options(options: INodeMaterialOptions);
  21997. /**
  21998. * Default configuration related to image processing available in the standard Material.
  21999. */
  22000. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22001. /**
  22002. * Gets the image processing configuration used either in this material.
  22003. */
  22004. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22005. /**
  22006. * Sets the Default image processing configuration used either in the this material.
  22007. *
  22008. * If sets to null, the scene one is in use.
  22009. */
  22010. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22011. /**
  22012. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22013. */
  22014. attachedBlocks: NodeMaterialBlock[];
  22015. /**
  22016. * Specifies the mode of the node material
  22017. * @hidden
  22018. */
  22019. _mode: NodeMaterialModes;
  22020. /**
  22021. * Gets the mode property
  22022. */
  22023. get mode(): NodeMaterialModes;
  22024. /**
  22025. * Create a new node based material
  22026. * @param name defines the material name
  22027. * @param scene defines the hosting scene
  22028. * @param options defines creation option
  22029. */
  22030. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22031. /**
  22032. * Gets the current class name of the material e.g. "NodeMaterial"
  22033. * @returns the class name
  22034. */
  22035. getClassName(): string;
  22036. /**
  22037. * Keep track of the image processing observer to allow dispose and replace.
  22038. */
  22039. private _imageProcessingObserver;
  22040. /**
  22041. * Attaches a new image processing configuration to the Standard Material.
  22042. * @param configuration
  22043. */
  22044. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22045. /**
  22046. * Get a block by its name
  22047. * @param name defines the name of the block to retrieve
  22048. * @returns the required block or null if not found
  22049. */
  22050. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22051. /**
  22052. * Get a block by its name
  22053. * @param predicate defines the predicate used to find the good candidate
  22054. * @returns the required block or null if not found
  22055. */
  22056. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22057. /**
  22058. * Get an input block by its name
  22059. * @param predicate defines the predicate used to find the good candidate
  22060. * @returns the required input block or null if not found
  22061. */
  22062. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22063. /**
  22064. * Gets the list of input blocks attached to this material
  22065. * @returns an array of InputBlocks
  22066. */
  22067. getInputBlocks(): InputBlock[];
  22068. /**
  22069. * Adds a new optimizer to the list of optimizers
  22070. * @param optimizer defines the optimizers to add
  22071. * @returns the current material
  22072. */
  22073. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22074. /**
  22075. * Remove an optimizer from the list of optimizers
  22076. * @param optimizer defines the optimizers to remove
  22077. * @returns the current material
  22078. */
  22079. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22080. /**
  22081. * Add a new block to the list of output nodes
  22082. * @param node defines the node to add
  22083. * @returns the current material
  22084. */
  22085. addOutputNode(node: NodeMaterialBlock): this;
  22086. /**
  22087. * Remove a block from the list of root nodes
  22088. * @param node defines the node to remove
  22089. * @returns the current material
  22090. */
  22091. removeOutputNode(node: NodeMaterialBlock): this;
  22092. private _addVertexOutputNode;
  22093. private _removeVertexOutputNode;
  22094. private _addFragmentOutputNode;
  22095. private _removeFragmentOutputNode;
  22096. /**
  22097. * Specifies if the material will require alpha blending
  22098. * @returns a boolean specifying if alpha blending is needed
  22099. */
  22100. needAlphaBlending(): boolean;
  22101. /**
  22102. * Specifies if this material should be rendered in alpha test mode
  22103. * @returns a boolean specifying if an alpha test is needed.
  22104. */
  22105. needAlphaTesting(): boolean;
  22106. private _initializeBlock;
  22107. private _resetDualBlocks;
  22108. /**
  22109. * Remove a block from the current node material
  22110. * @param block defines the block to remove
  22111. */
  22112. removeBlock(block: NodeMaterialBlock): void;
  22113. /**
  22114. * Build the material and generates the inner effect
  22115. * @param verbose defines if the build should log activity
  22116. */
  22117. build(verbose?: boolean): void;
  22118. /**
  22119. * Runs an otpimization phase to try to improve the shader code
  22120. */
  22121. optimize(): void;
  22122. private _prepareDefinesForAttributes;
  22123. /**
  22124. * Create a post process from the material
  22125. * @param camera The camera to apply the render pass to.
  22126. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22128. * @param engine The engine which the post process will be applied. (default: current engine)
  22129. * @param reusable If the post process can be reused on the same frame. (default: false)
  22130. * @param textureType Type of textures used when performing the post process. (default: 0)
  22131. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22132. * @returns the post process created
  22133. */
  22134. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22135. /**
  22136. * Create the post process effect from the material
  22137. * @param postProcess The post process to create the effect for
  22138. */
  22139. createEffectForPostProcess(postProcess: PostProcess): void;
  22140. private _createEffectOrPostProcess;
  22141. private _createEffectForParticles;
  22142. /**
  22143. * Create the effect to be used as the custom effect for a particle system
  22144. * @param particleSystem Particle system to create the effect for
  22145. * @param onCompiled defines a function to call when the effect creation is successful
  22146. * @param onError defines a function to call when the effect creation has failed
  22147. */
  22148. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22149. private _processDefines;
  22150. /**
  22151. * Get if the submesh is ready to be used and all its information available.
  22152. * Child classes can use it to update shaders
  22153. * @param mesh defines the mesh to check
  22154. * @param subMesh defines which submesh to check
  22155. * @param useInstances specifies that instances should be used
  22156. * @returns a boolean indicating that the submesh is ready or not
  22157. */
  22158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22159. /**
  22160. * Get a string representing the shaders built by the current node graph
  22161. */
  22162. get compiledShaders(): string;
  22163. /**
  22164. * Binds the world matrix to the material
  22165. * @param world defines the world transformation matrix
  22166. */
  22167. bindOnlyWorldMatrix(world: Matrix): void;
  22168. /**
  22169. * Binds the submesh to this material by preparing the effect and shader to draw
  22170. * @param world defines the world transformation matrix
  22171. * @param mesh defines the mesh containing the submesh
  22172. * @param subMesh defines the submesh to bind the material to
  22173. */
  22174. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22175. /**
  22176. * Gets the active textures from the material
  22177. * @returns an array of textures
  22178. */
  22179. getActiveTextures(): BaseTexture[];
  22180. /**
  22181. * Gets the list of texture blocks
  22182. * @returns an array of texture blocks
  22183. */
  22184. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22185. /**
  22186. * Specifies if the material uses a texture
  22187. * @param texture defines the texture to check against the material
  22188. * @returns a boolean specifying if the material uses the texture
  22189. */
  22190. hasTexture(texture: BaseTexture): boolean;
  22191. /**
  22192. * Disposes the material
  22193. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22194. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22195. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22196. */
  22197. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22198. /** Creates the node editor window. */
  22199. private _createNodeEditor;
  22200. /**
  22201. * Launch the node material editor
  22202. * @param config Define the configuration of the editor
  22203. * @return a promise fulfilled when the node editor is visible
  22204. */
  22205. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22206. /**
  22207. * Clear the current material
  22208. */
  22209. clear(): void;
  22210. /**
  22211. * Clear the current material and set it to a default state
  22212. */
  22213. setToDefault(): void;
  22214. /**
  22215. * Clear the current material and set it to a default state for post process
  22216. */
  22217. setToDefaultPostProcess(): void;
  22218. /**
  22219. * Clear the current material and set it to a default state for particle
  22220. */
  22221. setToDefaultParticle(): void;
  22222. /**
  22223. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22224. * @param url defines the url to load from
  22225. * @returns a promise that will fullfil when the material is fully loaded
  22226. */
  22227. loadAsync(url: string): Promise<void>;
  22228. private _gatherBlocks;
  22229. /**
  22230. * Generate a string containing the code declaration required to create an equivalent of this material
  22231. * @returns a string
  22232. */
  22233. generateCode(): string;
  22234. /**
  22235. * Serializes this material in a JSON representation
  22236. * @returns the serialized material object
  22237. */
  22238. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22239. private _restoreConnections;
  22240. /**
  22241. * Clear the current graph and load a new one from a serialization object
  22242. * @param source defines the JSON representation of the material
  22243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22244. * @param merge defines whether or not the source must be merged or replace the current content
  22245. */
  22246. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22247. /**
  22248. * Makes a duplicate of the current material.
  22249. * @param name - name to use for the new material.
  22250. */
  22251. clone(name: string): NodeMaterial;
  22252. /**
  22253. * Creates a node material from parsed material data
  22254. * @param source defines the JSON representation of the material
  22255. * @param scene defines the hosting scene
  22256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22257. * @returns a new node material
  22258. */
  22259. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22260. /**
  22261. * Creates a node material from a snippet saved in a remote file
  22262. * @param name defines the name of the material to create
  22263. * @param url defines the url to load from
  22264. * @param scene defines the hosting scene
  22265. * @returns a promise that will resolve to the new node material
  22266. */
  22267. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22268. /**
  22269. * Creates a node material from a snippet saved by the node material editor
  22270. * @param snippetId defines the snippet to load
  22271. * @param scene defines the hosting scene
  22272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22273. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22274. * @returns a promise that will resolve to the new node material
  22275. */
  22276. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22277. /**
  22278. * Creates a new node material set to default basic configuration
  22279. * @param name defines the name of the material
  22280. * @param scene defines the hosting scene
  22281. * @returns a new NodeMaterial
  22282. */
  22283. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22284. }
  22285. }
  22286. declare module BABYLON {
  22287. /**
  22288. * Size options for a post process
  22289. */
  22290. export type PostProcessOptions = {
  22291. width: number;
  22292. height: number;
  22293. };
  22294. /**
  22295. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22296. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22297. */
  22298. export class PostProcess {
  22299. /** Name of the PostProcess. */
  22300. name: string;
  22301. /**
  22302. * Gets or sets the unique id of the post process
  22303. */
  22304. uniqueId: number;
  22305. /**
  22306. * Width of the texture to apply the post process on
  22307. */
  22308. width: number;
  22309. /**
  22310. * Height of the texture to apply the post process on
  22311. */
  22312. height: number;
  22313. /**
  22314. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22315. */
  22316. nodeMaterialSource: Nullable<NodeMaterial>;
  22317. /**
  22318. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22319. * @hidden
  22320. */
  22321. _outputTexture: Nullable<InternalTexture>;
  22322. /**
  22323. * Sampling mode used by the shader
  22324. * See https://doc.babylonjs.com/classes/3.1/texture
  22325. */
  22326. renderTargetSamplingMode: number;
  22327. /**
  22328. * Clear color to use when screen clearing
  22329. */
  22330. clearColor: Color4;
  22331. /**
  22332. * If the buffer needs to be cleared before applying the post process. (default: true)
  22333. * Should be set to false if shader will overwrite all previous pixels.
  22334. */
  22335. autoClear: boolean;
  22336. /**
  22337. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22338. */
  22339. alphaMode: number;
  22340. /**
  22341. * Sets the setAlphaBlendConstants of the babylon engine
  22342. */
  22343. alphaConstants: Color4;
  22344. /**
  22345. * Animations to be used for the post processing
  22346. */
  22347. animations: Animation[];
  22348. /**
  22349. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22350. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22351. */
  22352. enablePixelPerfectMode: boolean;
  22353. /**
  22354. * Force the postprocess to be applied without taking in account viewport
  22355. */
  22356. forceFullscreenViewport: boolean;
  22357. /**
  22358. * List of inspectable custom properties (used by the Inspector)
  22359. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22360. */
  22361. inspectableCustomProperties: IInspectable[];
  22362. /**
  22363. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22364. *
  22365. * | Value | Type | Description |
  22366. * | ----- | ----------------------------------- | ----------- |
  22367. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22368. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22369. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22370. *
  22371. */
  22372. scaleMode: number;
  22373. /**
  22374. * Force textures to be a power of two (default: false)
  22375. */
  22376. alwaysForcePOT: boolean;
  22377. private _samples;
  22378. /**
  22379. * Number of sample textures (default: 1)
  22380. */
  22381. get samples(): number;
  22382. set samples(n: number);
  22383. /**
  22384. * Modify the scale of the post process to be the same as the viewport (default: false)
  22385. */
  22386. adaptScaleToCurrentViewport: boolean;
  22387. private _camera;
  22388. protected _scene: Scene;
  22389. private _engine;
  22390. private _options;
  22391. private _reusable;
  22392. private _textureType;
  22393. private _textureFormat;
  22394. /**
  22395. * Smart array of input and output textures for the post process.
  22396. * @hidden
  22397. */
  22398. _textures: SmartArray<InternalTexture>;
  22399. /**
  22400. * The index in _textures that corresponds to the output texture.
  22401. * @hidden
  22402. */
  22403. _currentRenderTextureInd: number;
  22404. private _effect;
  22405. private _samplers;
  22406. private _fragmentUrl;
  22407. private _vertexUrl;
  22408. private _parameters;
  22409. private _scaleRatio;
  22410. protected _indexParameters: any;
  22411. private _shareOutputWithPostProcess;
  22412. private _texelSize;
  22413. private _forcedOutputTexture;
  22414. /**
  22415. * Returns the fragment url or shader name used in the post process.
  22416. * @returns the fragment url or name in the shader store.
  22417. */
  22418. getEffectName(): string;
  22419. /**
  22420. * An event triggered when the postprocess is activated.
  22421. */
  22422. onActivateObservable: Observable<Camera>;
  22423. private _onActivateObserver;
  22424. /**
  22425. * A function that is added to the onActivateObservable
  22426. */
  22427. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22428. /**
  22429. * An event triggered when the postprocess changes its size.
  22430. */
  22431. onSizeChangedObservable: Observable<PostProcess>;
  22432. private _onSizeChangedObserver;
  22433. /**
  22434. * A function that is added to the onSizeChangedObservable
  22435. */
  22436. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22437. /**
  22438. * An event triggered when the postprocess applies its effect.
  22439. */
  22440. onApplyObservable: Observable<Effect>;
  22441. private _onApplyObserver;
  22442. /**
  22443. * A function that is added to the onApplyObservable
  22444. */
  22445. set onApply(callback: (effect: Effect) => void);
  22446. /**
  22447. * An event triggered before rendering the postprocess
  22448. */
  22449. onBeforeRenderObservable: Observable<Effect>;
  22450. private _onBeforeRenderObserver;
  22451. /**
  22452. * A function that is added to the onBeforeRenderObservable
  22453. */
  22454. set onBeforeRender(callback: (effect: Effect) => void);
  22455. /**
  22456. * An event triggered after rendering the postprocess
  22457. */
  22458. onAfterRenderObservable: Observable<Effect>;
  22459. private _onAfterRenderObserver;
  22460. /**
  22461. * A function that is added to the onAfterRenderObservable
  22462. */
  22463. set onAfterRender(callback: (efect: Effect) => void);
  22464. /**
  22465. * 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
  22466. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22467. */
  22468. get inputTexture(): InternalTexture;
  22469. set inputTexture(value: InternalTexture);
  22470. /**
  22471. * Gets the camera which post process is applied to.
  22472. * @returns The camera the post process is applied to.
  22473. */
  22474. getCamera(): Camera;
  22475. /**
  22476. * Gets the texel size of the postprocess.
  22477. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22478. */
  22479. get texelSize(): Vector2;
  22480. /**
  22481. * Creates a new instance PostProcess
  22482. * @param name The name of the PostProcess.
  22483. * @param fragmentUrl The url of the fragment shader to be used.
  22484. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22485. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22486. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22487. * @param camera The camera to apply the render pass to.
  22488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22489. * @param engine The engine which the post process will be applied. (default: current engine)
  22490. * @param reusable If the post process can be reused on the same frame. (default: false)
  22491. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22492. * @param textureType Type of textures used when performing the post process. (default: 0)
  22493. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22494. * @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
  22495. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22496. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22497. */
  22498. constructor(
  22499. /** Name of the PostProcess. */
  22500. 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);
  22501. /**
  22502. * Gets a string idenfifying the name of the class
  22503. * @returns "PostProcess" string
  22504. */
  22505. getClassName(): string;
  22506. /**
  22507. * Gets the engine which this post process belongs to.
  22508. * @returns The engine the post process was enabled with.
  22509. */
  22510. getEngine(): Engine;
  22511. /**
  22512. * The effect that is created when initializing the post process.
  22513. * @returns The created effect corresponding the the postprocess.
  22514. */
  22515. getEffect(): Effect;
  22516. /**
  22517. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22518. * @param postProcess The post process to share the output with.
  22519. * @returns This post process.
  22520. */
  22521. shareOutputWith(postProcess: PostProcess): PostProcess;
  22522. /**
  22523. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22524. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22525. */
  22526. useOwnOutput(): void;
  22527. /**
  22528. * Updates the effect with the current post process compile time values and recompiles the shader.
  22529. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22530. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22531. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22532. * @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
  22533. * @param onCompiled Called when the shader has been compiled.
  22534. * @param onError Called if there is an error when compiling a shader.
  22535. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22536. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22537. */
  22538. 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;
  22539. /**
  22540. * The post process is reusable if it can be used multiple times within one frame.
  22541. * @returns If the post process is reusable
  22542. */
  22543. isReusable(): boolean;
  22544. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22545. markTextureDirty(): void;
  22546. /**
  22547. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22548. * 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.
  22549. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22550. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22551. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22552. * @returns The target texture that was bound to be written to.
  22553. */
  22554. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22555. /**
  22556. * If the post process is supported.
  22557. */
  22558. get isSupported(): boolean;
  22559. /**
  22560. * The aspect ratio of the output texture.
  22561. */
  22562. get aspectRatio(): number;
  22563. /**
  22564. * Get a value indicating if the post-process is ready to be used
  22565. * @returns true if the post-process is ready (shader is compiled)
  22566. */
  22567. isReady(): boolean;
  22568. /**
  22569. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22570. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22571. */
  22572. apply(): Nullable<Effect>;
  22573. private _disposeTextures;
  22574. /**
  22575. * Disposes the post process.
  22576. * @param camera The camera to dispose the post process on.
  22577. */
  22578. dispose(camera?: Camera): void;
  22579. }
  22580. }
  22581. declare module BABYLON {
  22582. /** @hidden */
  22583. export var kernelBlurVaryingDeclaration: {
  22584. name: string;
  22585. shader: string;
  22586. };
  22587. }
  22588. declare module BABYLON {
  22589. /** @hidden */
  22590. export var kernelBlurFragment: {
  22591. name: string;
  22592. shader: string;
  22593. };
  22594. }
  22595. declare module BABYLON {
  22596. /** @hidden */
  22597. export var kernelBlurFragment2: {
  22598. name: string;
  22599. shader: string;
  22600. };
  22601. }
  22602. declare module BABYLON {
  22603. /** @hidden */
  22604. export var kernelBlurPixelShader: {
  22605. name: string;
  22606. shader: string;
  22607. };
  22608. }
  22609. declare module BABYLON {
  22610. /** @hidden */
  22611. export var kernelBlurVertex: {
  22612. name: string;
  22613. shader: string;
  22614. };
  22615. }
  22616. declare module BABYLON {
  22617. /** @hidden */
  22618. export var kernelBlurVertexShader: {
  22619. name: string;
  22620. shader: string;
  22621. };
  22622. }
  22623. declare module BABYLON {
  22624. /**
  22625. * The Blur Post Process which blurs an image based on a kernel and direction.
  22626. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22627. */
  22628. export class BlurPostProcess extends PostProcess {
  22629. /** The direction in which to blur the image. */
  22630. direction: Vector2;
  22631. private blockCompilation;
  22632. protected _kernel: number;
  22633. protected _idealKernel: number;
  22634. protected _packedFloat: boolean;
  22635. private _staticDefines;
  22636. /**
  22637. * Sets the length in pixels of the blur sample region
  22638. */
  22639. set kernel(v: number);
  22640. /**
  22641. * Gets the length in pixels of the blur sample region
  22642. */
  22643. get kernel(): number;
  22644. /**
  22645. * Sets wether or not the blur needs to unpack/repack floats
  22646. */
  22647. set packedFloat(v: boolean);
  22648. /**
  22649. * Gets wether or not the blur is unpacking/repacking floats
  22650. */
  22651. get packedFloat(): boolean;
  22652. /**
  22653. * Creates a new instance BlurPostProcess
  22654. * @param name The name of the effect.
  22655. * @param direction The direction in which to blur the image.
  22656. * @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.
  22657. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22658. * @param camera The camera to apply the render pass to.
  22659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22660. * @param engine The engine which the post process will be applied. (default: current engine)
  22661. * @param reusable If the post process can be reused on the same frame. (default: false)
  22662. * @param textureType Type of textures used when performing the post process. (default: 0)
  22663. * @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)
  22664. */
  22665. constructor(name: string,
  22666. /** The direction in which to blur the image. */
  22667. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22668. /**
  22669. * Updates the effect with the current post process compile time values and recompiles the shader.
  22670. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22671. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22672. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22673. * @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
  22674. * @param onCompiled Called when the shader has been compiled.
  22675. * @param onError Called if there is an error when compiling a shader.
  22676. */
  22677. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22678. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22679. /**
  22680. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22681. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22682. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22683. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22684. * The gaps between physical kernels are compensated for in the weighting of the samples
  22685. * @param idealKernel Ideal blur kernel.
  22686. * @return Nearest best kernel.
  22687. */
  22688. protected _nearestBestKernel(idealKernel: number): number;
  22689. /**
  22690. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22691. * @param x The point on the Gaussian distribution to sample.
  22692. * @return the value of the Gaussian function at x.
  22693. */
  22694. protected _gaussianWeight(x: number): number;
  22695. /**
  22696. * Generates a string that can be used as a floating point number in GLSL.
  22697. * @param x Value to print.
  22698. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22699. * @return GLSL float string.
  22700. */
  22701. protected _glslFloat(x: number, decimalFigures?: number): string;
  22702. }
  22703. }
  22704. declare module BABYLON {
  22705. /**
  22706. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22707. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22708. * You can then easily use it as a reflectionTexture on a flat surface.
  22709. * In case the surface is not a plane, please consider relying on reflection probes.
  22710. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22711. */
  22712. export class MirrorTexture extends RenderTargetTexture {
  22713. private scene;
  22714. /**
  22715. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22716. * 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.
  22717. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22718. */
  22719. mirrorPlane: Plane;
  22720. /**
  22721. * Define the blur ratio used to blur the reflection if needed.
  22722. */
  22723. set blurRatio(value: number);
  22724. get blurRatio(): number;
  22725. /**
  22726. * Define the adaptive blur kernel used to blur the reflection if needed.
  22727. * This will autocompute the closest best match for the `blurKernel`
  22728. */
  22729. set adaptiveBlurKernel(value: number);
  22730. /**
  22731. * Define the blur kernel used to blur the reflection if needed.
  22732. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22733. */
  22734. set blurKernel(value: number);
  22735. /**
  22736. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22737. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22738. */
  22739. set blurKernelX(value: number);
  22740. get blurKernelX(): number;
  22741. /**
  22742. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22743. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22744. */
  22745. set blurKernelY(value: number);
  22746. get blurKernelY(): number;
  22747. private _autoComputeBlurKernel;
  22748. protected _onRatioRescale(): void;
  22749. private _updateGammaSpace;
  22750. private _imageProcessingConfigChangeObserver;
  22751. private _transformMatrix;
  22752. private _mirrorMatrix;
  22753. private _savedViewMatrix;
  22754. private _blurX;
  22755. private _blurY;
  22756. private _adaptiveBlurKernel;
  22757. private _blurKernelX;
  22758. private _blurKernelY;
  22759. private _blurRatio;
  22760. /**
  22761. * Instantiates a Mirror Texture.
  22762. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22763. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22764. * You can then easily use it as a reflectionTexture on a flat surface.
  22765. * In case the surface is not a plane, please consider relying on reflection probes.
  22766. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22767. * @param name
  22768. * @param size
  22769. * @param scene
  22770. * @param generateMipMaps
  22771. * @param type
  22772. * @param samplingMode
  22773. * @param generateDepthBuffer
  22774. */
  22775. constructor(name: string, size: number | {
  22776. width: number;
  22777. height: number;
  22778. } | {
  22779. ratio: number;
  22780. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22781. private _preparePostProcesses;
  22782. /**
  22783. * Clone the mirror texture.
  22784. * @returns the cloned texture
  22785. */
  22786. clone(): MirrorTexture;
  22787. /**
  22788. * Serialize the texture to a JSON representation you could use in Parse later on
  22789. * @returns the serialized JSON representation
  22790. */
  22791. serialize(): any;
  22792. /**
  22793. * Dispose the texture and release its associated resources.
  22794. */
  22795. dispose(): void;
  22796. }
  22797. }
  22798. declare module BABYLON {
  22799. /**
  22800. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22801. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22802. */
  22803. export class Texture extends BaseTexture {
  22804. /**
  22805. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22806. */
  22807. static SerializeBuffers: boolean;
  22808. /** @hidden */
  22809. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22810. /** @hidden */
  22811. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22812. /** @hidden */
  22813. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22814. /** nearest is mag = nearest and min = nearest and mip = linear */
  22815. static readonly NEAREST_SAMPLINGMODE: number;
  22816. /** nearest is mag = nearest and min = nearest and mip = linear */
  22817. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22818. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22819. static readonly BILINEAR_SAMPLINGMODE: number;
  22820. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22821. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22822. /** Trilinear is mag = linear and min = linear and mip = linear */
  22823. static readonly TRILINEAR_SAMPLINGMODE: number;
  22824. /** Trilinear is mag = linear and min = linear and mip = linear */
  22825. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22826. /** mag = nearest and min = nearest and mip = nearest */
  22827. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22828. /** mag = nearest and min = linear and mip = nearest */
  22829. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22830. /** mag = nearest and min = linear and mip = linear */
  22831. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22832. /** mag = nearest and min = linear and mip = none */
  22833. static readonly NEAREST_LINEAR: number;
  22834. /** mag = nearest and min = nearest and mip = none */
  22835. static readonly NEAREST_NEAREST: number;
  22836. /** mag = linear and min = nearest and mip = nearest */
  22837. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22838. /** mag = linear and min = nearest and mip = linear */
  22839. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22840. /** mag = linear and min = linear and mip = none */
  22841. static readonly LINEAR_LINEAR: number;
  22842. /** mag = linear and min = nearest and mip = none */
  22843. static readonly LINEAR_NEAREST: number;
  22844. /** Explicit coordinates mode */
  22845. static readonly EXPLICIT_MODE: number;
  22846. /** Spherical coordinates mode */
  22847. static readonly SPHERICAL_MODE: number;
  22848. /** Planar coordinates mode */
  22849. static readonly PLANAR_MODE: number;
  22850. /** Cubic coordinates mode */
  22851. static readonly CUBIC_MODE: number;
  22852. /** Projection coordinates mode */
  22853. static readonly PROJECTION_MODE: number;
  22854. /** Inverse Cubic coordinates mode */
  22855. static readonly SKYBOX_MODE: number;
  22856. /** Inverse Cubic coordinates mode */
  22857. static readonly INVCUBIC_MODE: number;
  22858. /** Equirectangular coordinates mode */
  22859. static readonly EQUIRECTANGULAR_MODE: number;
  22860. /** Equirectangular Fixed coordinates mode */
  22861. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22862. /** Equirectangular Fixed Mirrored coordinates mode */
  22863. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22864. /** Texture is not repeating outside of 0..1 UVs */
  22865. static readonly CLAMP_ADDRESSMODE: number;
  22866. /** Texture is repeating outside of 0..1 UVs */
  22867. static readonly WRAP_ADDRESSMODE: number;
  22868. /** Texture is repeating and mirrored */
  22869. static readonly MIRROR_ADDRESSMODE: number;
  22870. /**
  22871. * 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
  22872. */
  22873. static UseSerializedUrlIfAny: boolean;
  22874. /**
  22875. * Define the url of the texture.
  22876. */
  22877. url: Nullable<string>;
  22878. /**
  22879. * Define an offset on the texture to offset the u coordinates of the UVs
  22880. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22881. */
  22882. uOffset: number;
  22883. /**
  22884. * Define an offset on the texture to offset the v coordinates of the UVs
  22885. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22886. */
  22887. vOffset: number;
  22888. /**
  22889. * Define an offset on the texture to scale the u coordinates of the UVs
  22890. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22891. */
  22892. uScale: number;
  22893. /**
  22894. * Define an offset on the texture to scale the v coordinates of the UVs
  22895. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22896. */
  22897. vScale: number;
  22898. /**
  22899. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22900. * @see https://doc.babylonjs.com/how_to/more_materials
  22901. */
  22902. uAng: number;
  22903. /**
  22904. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22905. * @see https://doc.babylonjs.com/how_to/more_materials
  22906. */
  22907. vAng: number;
  22908. /**
  22909. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22910. * @see https://doc.babylonjs.com/how_to/more_materials
  22911. */
  22912. wAng: number;
  22913. /**
  22914. * Defines the center of rotation (U)
  22915. */
  22916. uRotationCenter: number;
  22917. /**
  22918. * Defines the center of rotation (V)
  22919. */
  22920. vRotationCenter: number;
  22921. /**
  22922. * Defines the center of rotation (W)
  22923. */
  22924. wRotationCenter: number;
  22925. /**
  22926. * Are mip maps generated for this texture or not.
  22927. */
  22928. get noMipmap(): boolean;
  22929. /**
  22930. * List of inspectable custom properties (used by the Inspector)
  22931. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22932. */
  22933. inspectableCustomProperties: Nullable<IInspectable[]>;
  22934. private _noMipmap;
  22935. /** @hidden */
  22936. _invertY: boolean;
  22937. private _rowGenerationMatrix;
  22938. private _cachedTextureMatrix;
  22939. private _projectionModeMatrix;
  22940. private _t0;
  22941. private _t1;
  22942. private _t2;
  22943. private _cachedUOffset;
  22944. private _cachedVOffset;
  22945. private _cachedUScale;
  22946. private _cachedVScale;
  22947. private _cachedUAng;
  22948. private _cachedVAng;
  22949. private _cachedWAng;
  22950. private _cachedProjectionMatrixId;
  22951. private _cachedCoordinatesMode;
  22952. /** @hidden */
  22953. protected _initialSamplingMode: number;
  22954. /** @hidden */
  22955. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22956. private _deleteBuffer;
  22957. protected _format: Nullable<number>;
  22958. private _delayedOnLoad;
  22959. private _delayedOnError;
  22960. private _mimeType?;
  22961. /**
  22962. * Observable triggered once the texture has been loaded.
  22963. */
  22964. onLoadObservable: Observable<Texture>;
  22965. protected _isBlocking: boolean;
  22966. /**
  22967. * Is the texture preventing material to render while loading.
  22968. * If false, a default texture will be used instead of the loading one during the preparation step.
  22969. */
  22970. set isBlocking(value: boolean);
  22971. get isBlocking(): boolean;
  22972. /**
  22973. * Get the current sampling mode associated with the texture.
  22974. */
  22975. get samplingMode(): number;
  22976. /**
  22977. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  22978. */
  22979. get invertY(): boolean;
  22980. /**
  22981. * Instantiates a new texture.
  22982. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22983. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22984. * @param url defines the url of the picture to load as a texture
  22985. * @param sceneOrEngine defines the scene or engine the texture will belong to
  22986. * @param noMipmap defines if the texture will require mip maps or not
  22987. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  22988. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  22989. * @param onLoad defines a callback triggered when the texture has been loaded
  22990. * @param onError defines a callback triggered when an error occurred during the loading session
  22991. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  22992. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  22993. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  22994. * @param mimeType defines an optional mime type information
  22995. */
  22996. 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);
  22997. /**
  22998. * Update the url (and optional buffer) of this texture if url was null during construction.
  22999. * @param url the url of the texture
  23000. * @param buffer the buffer of the texture (defaults to null)
  23001. * @param onLoad callback called when the texture is loaded (defaults to null)
  23002. */
  23003. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23004. /**
  23005. * Finish the loading sequence of a texture flagged as delayed load.
  23006. * @hidden
  23007. */
  23008. delayLoad(): void;
  23009. private _prepareRowForTextureGeneration;
  23010. /**
  23011. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23012. * @returns the transform matrix of the texture.
  23013. */
  23014. getTextureMatrix(uBase?: number): Matrix;
  23015. /**
  23016. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23017. * @returns The reflection texture transform
  23018. */
  23019. getReflectionTextureMatrix(): Matrix;
  23020. /**
  23021. * Clones the texture.
  23022. * @returns the cloned texture
  23023. */
  23024. clone(): Texture;
  23025. /**
  23026. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23027. * @returns The JSON representation of the texture
  23028. */
  23029. serialize(): any;
  23030. /**
  23031. * Get the current class name of the texture useful for serialization or dynamic coding.
  23032. * @returns "Texture"
  23033. */
  23034. getClassName(): string;
  23035. /**
  23036. * Dispose the texture and release its associated resources.
  23037. */
  23038. dispose(): void;
  23039. /**
  23040. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23041. * @param parsedTexture Define the JSON representation of the texture
  23042. * @param scene Define the scene the parsed texture should be instantiated in
  23043. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23044. * @returns The parsed texture if successful
  23045. */
  23046. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23047. /**
  23048. * Creates a texture from its base 64 representation.
  23049. * @param data Define the base64 payload without the data: prefix
  23050. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23051. * @param scene Define the scene the texture should belong to
  23052. * @param noMipmap Forces the texture to not create mip map information if true
  23053. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23054. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23055. * @param onLoad define a callback triggered when the texture has been loaded
  23056. * @param onError define a callback triggered when an error occurred during the loading session
  23057. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23058. * @returns the created texture
  23059. */
  23060. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23061. /**
  23062. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23063. * @param data Define the base64 payload without the data: prefix
  23064. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23065. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23066. * @param scene Define the scene the texture should belong to
  23067. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23068. * @param noMipmap Forces the texture to not create mip map information if true
  23069. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23070. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23071. * @param onLoad define a callback triggered when the texture has been loaded
  23072. * @param onError define a callback triggered when an error occurred during the loading session
  23073. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23074. * @returns the created texture
  23075. */
  23076. 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;
  23077. }
  23078. }
  23079. declare module BABYLON {
  23080. /**
  23081. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23082. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23083. */
  23084. export class PostProcessManager {
  23085. private _scene;
  23086. private _indexBuffer;
  23087. private _vertexBuffers;
  23088. /**
  23089. * Creates a new instance PostProcess
  23090. * @param scene The scene that the post process is associated with.
  23091. */
  23092. constructor(scene: Scene);
  23093. private _prepareBuffers;
  23094. private _buildIndexBuffer;
  23095. /**
  23096. * Rebuilds the vertex buffers of the manager.
  23097. * @hidden
  23098. */
  23099. _rebuild(): void;
  23100. /**
  23101. * Prepares a frame to be run through a post process.
  23102. * @param sourceTexture The input texture to the post procesess. (default: null)
  23103. * @param postProcesses An array of post processes to be run. (default: null)
  23104. * @returns True if the post processes were able to be run.
  23105. * @hidden
  23106. */
  23107. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23108. /**
  23109. * Manually render a set of post processes to a texture.
  23110. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23111. * @param postProcesses An array of post processes to be run.
  23112. * @param targetTexture The target texture to render to.
  23113. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23114. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23115. * @param lodLevel defines which lod of the texture to render to
  23116. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23117. */
  23118. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23119. /**
  23120. * Finalize the result of the output of the postprocesses.
  23121. * @param doNotPresent If true the result will not be displayed to the screen.
  23122. * @param targetTexture The target texture to render to.
  23123. * @param faceIndex The index of the face to bind the target texture to.
  23124. * @param postProcesses The array of post processes to render.
  23125. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23126. * @hidden
  23127. */
  23128. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23129. /**
  23130. * Disposes of the post process manager.
  23131. */
  23132. dispose(): void;
  23133. }
  23134. }
  23135. declare module BABYLON {
  23136. /**
  23137. * This Helps creating a texture that will be created from a camera in your scene.
  23138. * It is basically a dynamic texture that could be used to create special effects for instance.
  23139. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23140. */
  23141. export class RenderTargetTexture extends Texture {
  23142. isCube: boolean;
  23143. /**
  23144. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23145. */
  23146. static readonly REFRESHRATE_RENDER_ONCE: number;
  23147. /**
  23148. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23149. */
  23150. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23151. /**
  23152. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23153. * the central point of your effect and can save a lot of performances.
  23154. */
  23155. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23156. /**
  23157. * Use this predicate to dynamically define the list of mesh you want to render.
  23158. * If set, the renderList property will be overwritten.
  23159. */
  23160. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23161. private _renderList;
  23162. /**
  23163. * Use this list to define the list of mesh you want to render.
  23164. */
  23165. get renderList(): Nullable<Array<AbstractMesh>>;
  23166. set renderList(value: Nullable<Array<AbstractMesh>>);
  23167. /**
  23168. * Use this function to overload the renderList array at rendering time.
  23169. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23170. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23171. * the cube (if the RTT is a cube, else layerOrFace=0).
  23172. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23173. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23174. * hold dummy elements!
  23175. */
  23176. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23177. private _hookArray;
  23178. /**
  23179. * Define if particles should be rendered in your texture.
  23180. */
  23181. renderParticles: boolean;
  23182. /**
  23183. * Define if sprites should be rendered in your texture.
  23184. */
  23185. renderSprites: boolean;
  23186. /**
  23187. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23188. */
  23189. coordinatesMode: number;
  23190. /**
  23191. * Define the camera used to render the texture.
  23192. */
  23193. activeCamera: Nullable<Camera>;
  23194. /**
  23195. * Override the mesh isReady function with your own one.
  23196. */
  23197. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23198. /**
  23199. * Override the render function of the texture with your own one.
  23200. */
  23201. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23202. /**
  23203. * Define if camera post processes should be use while rendering the texture.
  23204. */
  23205. useCameraPostProcesses: boolean;
  23206. /**
  23207. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23208. */
  23209. ignoreCameraViewport: boolean;
  23210. private _postProcessManager;
  23211. private _postProcesses;
  23212. private _resizeObserver;
  23213. /**
  23214. * An event triggered when the texture is unbind.
  23215. */
  23216. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23217. /**
  23218. * An event triggered when the texture is unbind.
  23219. */
  23220. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23221. private _onAfterUnbindObserver;
  23222. /**
  23223. * Set a after unbind callback in the texture.
  23224. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23225. */
  23226. set onAfterUnbind(callback: () => void);
  23227. /**
  23228. * An event triggered before rendering the texture
  23229. */
  23230. onBeforeRenderObservable: Observable<number>;
  23231. private _onBeforeRenderObserver;
  23232. /**
  23233. * Set a before render callback in the texture.
  23234. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23235. */
  23236. set onBeforeRender(callback: (faceIndex: number) => void);
  23237. /**
  23238. * An event triggered after rendering the texture
  23239. */
  23240. onAfterRenderObservable: Observable<number>;
  23241. private _onAfterRenderObserver;
  23242. /**
  23243. * Set a after render callback in the texture.
  23244. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23245. */
  23246. set onAfterRender(callback: (faceIndex: number) => void);
  23247. /**
  23248. * An event triggered after the texture clear
  23249. */
  23250. onClearObservable: Observable<Engine>;
  23251. private _onClearObserver;
  23252. /**
  23253. * Set a clear callback in the texture.
  23254. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23255. */
  23256. set onClear(callback: (Engine: Engine) => void);
  23257. /**
  23258. * An event triggered when the texture is resized.
  23259. */
  23260. onResizeObservable: Observable<RenderTargetTexture>;
  23261. /**
  23262. * Define the clear color of the Render Target if it should be different from the scene.
  23263. */
  23264. clearColor: Color4;
  23265. protected _size: number | {
  23266. width: number;
  23267. height: number;
  23268. layers?: number;
  23269. };
  23270. protected _initialSizeParameter: number | {
  23271. width: number;
  23272. height: number;
  23273. } | {
  23274. ratio: number;
  23275. };
  23276. protected _sizeRatio: Nullable<number>;
  23277. /** @hidden */
  23278. _generateMipMaps: boolean;
  23279. protected _renderingManager: RenderingManager;
  23280. /** @hidden */
  23281. _waitingRenderList: string[];
  23282. protected _doNotChangeAspectRatio: boolean;
  23283. protected _currentRefreshId: number;
  23284. protected _refreshRate: number;
  23285. protected _textureMatrix: Matrix;
  23286. protected _samples: number;
  23287. protected _renderTargetOptions: RenderTargetCreationOptions;
  23288. /**
  23289. * Gets render target creation options that were used.
  23290. */
  23291. get renderTargetOptions(): RenderTargetCreationOptions;
  23292. protected _onRatioRescale(): void;
  23293. /**
  23294. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23295. * It must define where the camera used to render the texture is set
  23296. */
  23297. boundingBoxPosition: Vector3;
  23298. private _boundingBoxSize;
  23299. /**
  23300. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23301. * When defined, the cubemap will switch to local mode
  23302. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23303. * @example https://www.babylonjs-playground.com/#RNASML
  23304. */
  23305. set boundingBoxSize(value: Vector3);
  23306. get boundingBoxSize(): Vector3;
  23307. /**
  23308. * In case the RTT has been created with a depth texture, get the associated
  23309. * depth texture.
  23310. * Otherwise, return null.
  23311. */
  23312. get depthStencilTexture(): Nullable<InternalTexture>;
  23313. /**
  23314. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23315. * or used a shadow, depth texture...
  23316. * @param name The friendly name of the texture
  23317. * @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)
  23318. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23319. * @param generateMipMaps True if mip maps need to be generated after render.
  23320. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23321. * @param type The type of the buffer in the RTT (int, half float, float...)
  23322. * @param isCube True if a cube texture needs to be created
  23323. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23324. * @param generateDepthBuffer True to generate a depth buffer
  23325. * @param generateStencilBuffer True to generate a stencil buffer
  23326. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23327. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23328. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23329. */
  23330. constructor(name: string, size: number | {
  23331. width: number;
  23332. height: number;
  23333. layers?: number;
  23334. } | {
  23335. ratio: number;
  23336. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23337. /**
  23338. * Creates a depth stencil texture.
  23339. * This is only available in WebGL 2 or with the depth texture extension available.
  23340. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23341. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23342. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23343. */
  23344. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23345. private _processSizeParameter;
  23346. /**
  23347. * Define the number of samples to use in case of MSAA.
  23348. * It defaults to one meaning no MSAA has been enabled.
  23349. */
  23350. get samples(): number;
  23351. set samples(value: number);
  23352. /**
  23353. * Resets the refresh counter of the texture and start bak from scratch.
  23354. * Could be useful to regenerate the texture if it is setup to render only once.
  23355. */
  23356. resetRefreshCounter(): void;
  23357. /**
  23358. * Define the refresh rate of the texture or the rendering frequency.
  23359. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23360. */
  23361. get refreshRate(): number;
  23362. set refreshRate(value: number);
  23363. /**
  23364. * Adds a post process to the render target rendering passes.
  23365. * @param postProcess define the post process to add
  23366. */
  23367. addPostProcess(postProcess: PostProcess): void;
  23368. /**
  23369. * Clear all the post processes attached to the render target
  23370. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23371. */
  23372. clearPostProcesses(dispose?: boolean): void;
  23373. /**
  23374. * Remove one of the post process from the list of attached post processes to the texture
  23375. * @param postProcess define the post process to remove from the list
  23376. */
  23377. removePostProcess(postProcess: PostProcess): void;
  23378. /** @hidden */
  23379. _shouldRender(): boolean;
  23380. /**
  23381. * Gets the actual render size of the texture.
  23382. * @returns the width of the render size
  23383. */
  23384. getRenderSize(): number;
  23385. /**
  23386. * Gets the actual render width of the texture.
  23387. * @returns the width of the render size
  23388. */
  23389. getRenderWidth(): number;
  23390. /**
  23391. * Gets the actual render height of the texture.
  23392. * @returns the height of the render size
  23393. */
  23394. getRenderHeight(): number;
  23395. /**
  23396. * Gets the actual number of layers of the texture.
  23397. * @returns the number of layers
  23398. */
  23399. getRenderLayers(): number;
  23400. /**
  23401. * Get if the texture can be rescaled or not.
  23402. */
  23403. get canRescale(): boolean;
  23404. /**
  23405. * Resize the texture using a ratio.
  23406. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23407. */
  23408. scale(ratio: number): void;
  23409. /**
  23410. * Get the texture reflection matrix used to rotate/transform the reflection.
  23411. * @returns the reflection matrix
  23412. */
  23413. getReflectionTextureMatrix(): Matrix;
  23414. /**
  23415. * Resize the texture to a new desired size.
  23416. * Be carrefull as it will recreate all the data in the new texture.
  23417. * @param size Define the new size. It can be:
  23418. * - a number for squared texture,
  23419. * - an object containing { width: number, height: number }
  23420. * - or an object containing a ratio { ratio: number }
  23421. */
  23422. resize(size: number | {
  23423. width: number;
  23424. height: number;
  23425. } | {
  23426. ratio: number;
  23427. }): void;
  23428. private _defaultRenderListPrepared;
  23429. /**
  23430. * Renders all the objects from the render list into the texture.
  23431. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23432. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23433. */
  23434. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23435. private _bestReflectionRenderTargetDimension;
  23436. private _prepareRenderingManager;
  23437. /**
  23438. * @hidden
  23439. * @param faceIndex face index to bind to if this is a cubetexture
  23440. * @param layer defines the index of the texture to bind in the array
  23441. */
  23442. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23443. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23444. private renderToTarget;
  23445. /**
  23446. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23447. * This allowed control for front to back rendering or reversly depending of the special needs.
  23448. *
  23449. * @param renderingGroupId The rendering group id corresponding to its index
  23450. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23451. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23452. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23453. */
  23454. 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;
  23455. /**
  23456. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23457. *
  23458. * @param renderingGroupId The rendering group id corresponding to its index
  23459. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23460. */
  23461. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23462. /**
  23463. * Clones the texture.
  23464. * @returns the cloned texture
  23465. */
  23466. clone(): RenderTargetTexture;
  23467. /**
  23468. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23469. * @returns The JSON representation of the texture
  23470. */
  23471. serialize(): any;
  23472. /**
  23473. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23474. */
  23475. disposeFramebufferObjects(): void;
  23476. /**
  23477. * Dispose the texture and release its associated resources.
  23478. */
  23479. dispose(): void;
  23480. /** @hidden */
  23481. _rebuild(): void;
  23482. /**
  23483. * Clear the info related to rendering groups preventing retention point in material dispose.
  23484. */
  23485. freeRenderingGroups(): void;
  23486. /**
  23487. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23488. * @returns the view count
  23489. */
  23490. getViewCount(): number;
  23491. }
  23492. }
  23493. declare module BABYLON {
  23494. /**
  23495. * Class used to manipulate GUIDs
  23496. */
  23497. export class GUID {
  23498. /**
  23499. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23500. * Be aware Math.random() could cause collisions, but:
  23501. * "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"
  23502. * @returns a pseudo random id
  23503. */
  23504. static RandomId(): string;
  23505. }
  23506. }
  23507. declare module BABYLON {
  23508. /**
  23509. * Options to be used when creating a shadow depth material
  23510. */
  23511. export interface IIOptionShadowDepthMaterial {
  23512. /** Variables in the vertex shader code that need to have their names remapped.
  23513. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23514. * "var_name" should be either: worldPos or vNormalW
  23515. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23516. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23517. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23518. */
  23519. remappedVariables?: string[];
  23520. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23521. standalone?: boolean;
  23522. }
  23523. /**
  23524. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23525. */
  23526. export class ShadowDepthWrapper {
  23527. private _scene;
  23528. private _options?;
  23529. private _baseMaterial;
  23530. private _onEffectCreatedObserver;
  23531. private _subMeshToEffect;
  23532. private _subMeshToDepthEffect;
  23533. private _meshes;
  23534. /** @hidden */
  23535. _matriceNames: any;
  23536. /** Gets the standalone status of the wrapper */
  23537. get standalone(): boolean;
  23538. /** Gets the base material the wrapper is built upon */
  23539. get baseMaterial(): Material;
  23540. /**
  23541. * Instantiate a new shadow depth wrapper.
  23542. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23543. * generate the shadow depth map. For more information, please refer to the documentation:
  23544. * https://doc.babylonjs.com/babylon101/shadows
  23545. * @param baseMaterial Material to wrap
  23546. * @param scene Define the scene the material belongs to
  23547. * @param options Options used to create the wrapper
  23548. */
  23549. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23550. /**
  23551. * Gets the effect to use to generate the depth map
  23552. * @param subMesh subMesh to get the effect for
  23553. * @param shadowGenerator shadow generator to get the effect for
  23554. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23555. */
  23556. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23557. /**
  23558. * Specifies that the submesh is ready to be used for depth rendering
  23559. * @param subMesh submesh to check
  23560. * @param defines the list of defines to take into account when checking the effect
  23561. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23562. * @param useInstances specifies that instances should be used
  23563. * @returns a boolean indicating that the submesh is ready or not
  23564. */
  23565. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23566. /**
  23567. * Disposes the resources
  23568. */
  23569. dispose(): void;
  23570. private _makeEffect;
  23571. }
  23572. }
  23573. declare module BABYLON {
  23574. /**
  23575. * Options for compiling materials.
  23576. */
  23577. export interface IMaterialCompilationOptions {
  23578. /**
  23579. * Defines whether clip planes are enabled.
  23580. */
  23581. clipPlane: boolean;
  23582. /**
  23583. * Defines whether instances are enabled.
  23584. */
  23585. useInstances: boolean;
  23586. }
  23587. /**
  23588. * Options passed when calling customShaderNameResolve
  23589. */
  23590. export interface ICustomShaderNameResolveOptions {
  23591. /**
  23592. * 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
  23593. */
  23594. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23595. }
  23596. /**
  23597. * Base class for the main features of a material in Babylon.js
  23598. */
  23599. export class Material implements IAnimatable {
  23600. /**
  23601. * Returns the triangle fill mode
  23602. */
  23603. static readonly TriangleFillMode: number;
  23604. /**
  23605. * Returns the wireframe mode
  23606. */
  23607. static readonly WireFrameFillMode: number;
  23608. /**
  23609. * Returns the point fill mode
  23610. */
  23611. static readonly PointFillMode: number;
  23612. /**
  23613. * Returns the point list draw mode
  23614. */
  23615. static readonly PointListDrawMode: number;
  23616. /**
  23617. * Returns the line list draw mode
  23618. */
  23619. static readonly LineListDrawMode: number;
  23620. /**
  23621. * Returns the line loop draw mode
  23622. */
  23623. static readonly LineLoopDrawMode: number;
  23624. /**
  23625. * Returns the line strip draw mode
  23626. */
  23627. static readonly LineStripDrawMode: number;
  23628. /**
  23629. * Returns the triangle strip draw mode
  23630. */
  23631. static readonly TriangleStripDrawMode: number;
  23632. /**
  23633. * Returns the triangle fan draw mode
  23634. */
  23635. static readonly TriangleFanDrawMode: number;
  23636. /**
  23637. * Stores the clock-wise side orientation
  23638. */
  23639. static readonly ClockWiseSideOrientation: number;
  23640. /**
  23641. * Stores the counter clock-wise side orientation
  23642. */
  23643. static readonly CounterClockWiseSideOrientation: number;
  23644. /**
  23645. * The dirty texture flag value
  23646. */
  23647. static readonly TextureDirtyFlag: number;
  23648. /**
  23649. * The dirty light flag value
  23650. */
  23651. static readonly LightDirtyFlag: number;
  23652. /**
  23653. * The dirty fresnel flag value
  23654. */
  23655. static readonly FresnelDirtyFlag: number;
  23656. /**
  23657. * The dirty attribute flag value
  23658. */
  23659. static readonly AttributesDirtyFlag: number;
  23660. /**
  23661. * The dirty misc flag value
  23662. */
  23663. static readonly MiscDirtyFlag: number;
  23664. /**
  23665. * The all dirty flag value
  23666. */
  23667. static readonly AllDirtyFlag: number;
  23668. /**
  23669. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23670. */
  23671. static readonly MATERIAL_OPAQUE: number;
  23672. /**
  23673. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23674. */
  23675. static readonly MATERIAL_ALPHATEST: number;
  23676. /**
  23677. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23678. */
  23679. static readonly MATERIAL_ALPHABLEND: number;
  23680. /**
  23681. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23682. * They are also discarded below the alpha cutoff threshold to improve performances.
  23683. */
  23684. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23685. /**
  23686. * The Whiteout method is used to blend normals.
  23687. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23688. */
  23689. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23690. /**
  23691. * The Reoriented Normal Mapping method is used to blend normals.
  23692. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23693. */
  23694. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23695. /**
  23696. * Custom callback helping to override the default shader used in the material.
  23697. */
  23698. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23699. /**
  23700. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23701. */
  23702. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23703. /**
  23704. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23705. * This means that the material can keep using a previous shader while a new one is being compiled.
  23706. * This is mostly used when shader parallel compilation is supported (true by default)
  23707. */
  23708. allowShaderHotSwapping: boolean;
  23709. /**
  23710. * The ID of the material
  23711. */
  23712. id: string;
  23713. /**
  23714. * Gets or sets the unique id of the material
  23715. */
  23716. uniqueId: number;
  23717. /**
  23718. * The name of the material
  23719. */
  23720. name: string;
  23721. /**
  23722. * Gets or sets user defined metadata
  23723. */
  23724. metadata: any;
  23725. /**
  23726. * For internal use only. Please do not use.
  23727. */
  23728. reservedDataStore: any;
  23729. /**
  23730. * Specifies if the ready state should be checked on each call
  23731. */
  23732. checkReadyOnEveryCall: boolean;
  23733. /**
  23734. * Specifies if the ready state should be checked once
  23735. */
  23736. checkReadyOnlyOnce: boolean;
  23737. /**
  23738. * The state of the material
  23739. */
  23740. state: string;
  23741. /**
  23742. * If the material should be rendered to several textures with MRT extension
  23743. */
  23744. get shouldRenderToMRT(): boolean;
  23745. /**
  23746. * The alpha value of the material
  23747. */
  23748. protected _alpha: number;
  23749. /**
  23750. * List of inspectable custom properties (used by the Inspector)
  23751. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23752. */
  23753. inspectableCustomProperties: IInspectable[];
  23754. /**
  23755. * Sets the alpha value of the material
  23756. */
  23757. set alpha(value: number);
  23758. /**
  23759. * Gets the alpha value of the material
  23760. */
  23761. get alpha(): number;
  23762. /**
  23763. * Specifies if back face culling is enabled
  23764. */
  23765. protected _backFaceCulling: boolean;
  23766. /**
  23767. * Sets the back-face culling state
  23768. */
  23769. set backFaceCulling(value: boolean);
  23770. /**
  23771. * Gets the back-face culling state
  23772. */
  23773. get backFaceCulling(): boolean;
  23774. /**
  23775. * Stores the value for side orientation
  23776. */
  23777. sideOrientation: number;
  23778. /**
  23779. * Callback triggered when the material is compiled
  23780. */
  23781. onCompiled: Nullable<(effect: Effect) => void>;
  23782. /**
  23783. * Callback triggered when an error occurs
  23784. */
  23785. onError: Nullable<(effect: Effect, errors: string) => void>;
  23786. /**
  23787. * Callback triggered to get the render target textures
  23788. */
  23789. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23790. /**
  23791. * Gets a boolean indicating that current material needs to register RTT
  23792. */
  23793. get hasRenderTargetTextures(): boolean;
  23794. /**
  23795. * Specifies if the material should be serialized
  23796. */
  23797. doNotSerialize: boolean;
  23798. /**
  23799. * @hidden
  23800. */
  23801. _storeEffectOnSubMeshes: boolean;
  23802. /**
  23803. * Stores the animations for the material
  23804. */
  23805. animations: Nullable<Array<Animation>>;
  23806. /**
  23807. * An event triggered when the material is disposed
  23808. */
  23809. onDisposeObservable: Observable<Material>;
  23810. /**
  23811. * An observer which watches for dispose events
  23812. */
  23813. private _onDisposeObserver;
  23814. private _onUnBindObservable;
  23815. /**
  23816. * Called during a dispose event
  23817. */
  23818. set onDispose(callback: () => void);
  23819. private _onBindObservable;
  23820. /**
  23821. * An event triggered when the material is bound
  23822. */
  23823. get onBindObservable(): Observable<AbstractMesh>;
  23824. /**
  23825. * An observer which watches for bind events
  23826. */
  23827. private _onBindObserver;
  23828. /**
  23829. * Called during a bind event
  23830. */
  23831. set onBind(callback: (Mesh: AbstractMesh) => void);
  23832. /**
  23833. * An event triggered when the material is unbound
  23834. */
  23835. get onUnBindObservable(): Observable<Material>;
  23836. protected _onEffectCreatedObservable: Nullable<Observable<{
  23837. effect: Effect;
  23838. subMesh: Nullable<SubMesh>;
  23839. }>>;
  23840. /**
  23841. * An event triggered when the effect is (re)created
  23842. */
  23843. get onEffectCreatedObservable(): Observable<{
  23844. effect: Effect;
  23845. subMesh: Nullable<SubMesh>;
  23846. }>;
  23847. /**
  23848. * Stores the value of the alpha mode
  23849. */
  23850. private _alphaMode;
  23851. /**
  23852. * Sets the value of the alpha mode.
  23853. *
  23854. * | Value | Type | Description |
  23855. * | --- | --- | --- |
  23856. * | 0 | ALPHA_DISABLE | |
  23857. * | 1 | ALPHA_ADD | |
  23858. * | 2 | ALPHA_COMBINE | |
  23859. * | 3 | ALPHA_SUBTRACT | |
  23860. * | 4 | ALPHA_MULTIPLY | |
  23861. * | 5 | ALPHA_MAXIMIZED | |
  23862. * | 6 | ALPHA_ONEONE | |
  23863. * | 7 | ALPHA_PREMULTIPLIED | |
  23864. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23865. * | 9 | ALPHA_INTERPOLATE | |
  23866. * | 10 | ALPHA_SCREENMODE | |
  23867. *
  23868. */
  23869. set alphaMode(value: number);
  23870. /**
  23871. * Gets the value of the alpha mode
  23872. */
  23873. get alphaMode(): number;
  23874. /**
  23875. * Stores the state of the need depth pre-pass value
  23876. */
  23877. private _needDepthPrePass;
  23878. /**
  23879. * Sets the need depth pre-pass value
  23880. */
  23881. set needDepthPrePass(value: boolean);
  23882. /**
  23883. * Gets the depth pre-pass value
  23884. */
  23885. get needDepthPrePass(): boolean;
  23886. /**
  23887. * Specifies if depth writing should be disabled
  23888. */
  23889. disableDepthWrite: boolean;
  23890. /**
  23891. * Specifies if color writing should be disabled
  23892. */
  23893. disableColorWrite: boolean;
  23894. /**
  23895. * Specifies if depth writing should be forced
  23896. */
  23897. forceDepthWrite: boolean;
  23898. /**
  23899. * Specifies the depth function that should be used. 0 means the default engine function
  23900. */
  23901. depthFunction: number;
  23902. /**
  23903. * Specifies if there should be a separate pass for culling
  23904. */
  23905. separateCullingPass: boolean;
  23906. /**
  23907. * Stores the state specifing if fog should be enabled
  23908. */
  23909. private _fogEnabled;
  23910. /**
  23911. * Sets the state for enabling fog
  23912. */
  23913. set fogEnabled(value: boolean);
  23914. /**
  23915. * Gets the value of the fog enabled state
  23916. */
  23917. get fogEnabled(): boolean;
  23918. /**
  23919. * Stores the size of points
  23920. */
  23921. pointSize: number;
  23922. /**
  23923. * Stores the z offset value
  23924. */
  23925. zOffset: number;
  23926. get wireframe(): boolean;
  23927. /**
  23928. * Sets the state of wireframe mode
  23929. */
  23930. set wireframe(value: boolean);
  23931. /**
  23932. * Gets the value specifying if point clouds are enabled
  23933. */
  23934. get pointsCloud(): boolean;
  23935. /**
  23936. * Sets the state of point cloud mode
  23937. */
  23938. set pointsCloud(value: boolean);
  23939. /**
  23940. * Gets the material fill mode
  23941. */
  23942. get fillMode(): number;
  23943. /**
  23944. * Sets the material fill mode
  23945. */
  23946. set fillMode(value: number);
  23947. /**
  23948. * @hidden
  23949. * Stores the effects for the material
  23950. */
  23951. _effect: Nullable<Effect>;
  23952. /**
  23953. * Specifies if uniform buffers should be used
  23954. */
  23955. private _useUBO;
  23956. /**
  23957. * Stores a reference to the scene
  23958. */
  23959. private _scene;
  23960. /**
  23961. * Stores the fill mode state
  23962. */
  23963. private _fillMode;
  23964. /**
  23965. * Specifies if the depth write state should be cached
  23966. */
  23967. private _cachedDepthWriteState;
  23968. /**
  23969. * Specifies if the color write state should be cached
  23970. */
  23971. private _cachedColorWriteState;
  23972. /**
  23973. * Specifies if the depth function state should be cached
  23974. */
  23975. private _cachedDepthFunctionState;
  23976. /**
  23977. * Stores the uniform buffer
  23978. */
  23979. protected _uniformBuffer: UniformBuffer;
  23980. /** @hidden */
  23981. _indexInSceneMaterialArray: number;
  23982. /** @hidden */
  23983. meshMap: Nullable<{
  23984. [id: string]: AbstractMesh | undefined;
  23985. }>;
  23986. /**
  23987. * Creates a material instance
  23988. * @param name defines the name of the material
  23989. * @param scene defines the scene to reference
  23990. * @param doNotAdd specifies if the material should be added to the scene
  23991. */
  23992. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23993. /**
  23994. * Returns a string representation of the current material
  23995. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23996. * @returns a string with material information
  23997. */
  23998. toString(fullDetails?: boolean): string;
  23999. /**
  24000. * Gets the class name of the material
  24001. * @returns a string with the class name of the material
  24002. */
  24003. getClassName(): string;
  24004. /**
  24005. * Specifies if updates for the material been locked
  24006. */
  24007. get isFrozen(): boolean;
  24008. /**
  24009. * Locks updates for the material
  24010. */
  24011. freeze(): void;
  24012. /**
  24013. * Unlocks updates for the material
  24014. */
  24015. unfreeze(): void;
  24016. /**
  24017. * Specifies if the material is ready to be used
  24018. * @param mesh defines the mesh to check
  24019. * @param useInstances specifies if instances should be used
  24020. * @returns a boolean indicating if the material is ready to be used
  24021. */
  24022. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24023. /**
  24024. * Specifies that the submesh is ready to be used
  24025. * @param mesh defines the mesh to check
  24026. * @param subMesh defines which submesh to check
  24027. * @param useInstances specifies that instances should be used
  24028. * @returns a boolean indicating that the submesh is ready or not
  24029. */
  24030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24031. /**
  24032. * Returns the material effect
  24033. * @returns the effect associated with the material
  24034. */
  24035. getEffect(): Nullable<Effect>;
  24036. /**
  24037. * Returns the current scene
  24038. * @returns a Scene
  24039. */
  24040. getScene(): Scene;
  24041. /**
  24042. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24043. */
  24044. protected _forceAlphaTest: boolean;
  24045. /**
  24046. * The transparency mode of the material.
  24047. */
  24048. protected _transparencyMode: Nullable<number>;
  24049. /**
  24050. * Gets the current transparency mode.
  24051. */
  24052. get transparencyMode(): Nullable<number>;
  24053. /**
  24054. * Sets the transparency mode of the material.
  24055. *
  24056. * | Value | Type | Description |
  24057. * | ----- | ----------------------------------- | ----------- |
  24058. * | 0 | OPAQUE | |
  24059. * | 1 | ALPHATEST | |
  24060. * | 2 | ALPHABLEND | |
  24061. * | 3 | ALPHATESTANDBLEND | |
  24062. *
  24063. */
  24064. set transparencyMode(value: Nullable<number>);
  24065. /**
  24066. * Returns true if alpha blending should be disabled.
  24067. */
  24068. protected get _disableAlphaBlending(): boolean;
  24069. /**
  24070. * Specifies whether or not this material should be rendered in alpha blend mode.
  24071. * @returns a boolean specifying if alpha blending is needed
  24072. */
  24073. needAlphaBlending(): boolean;
  24074. /**
  24075. * Specifies if the mesh will require alpha blending
  24076. * @param mesh defines the mesh to check
  24077. * @returns a boolean specifying if alpha blending is needed for the mesh
  24078. */
  24079. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24080. /**
  24081. * Specifies whether or not this material should be rendered in alpha test mode.
  24082. * @returns a boolean specifying if an alpha test is needed.
  24083. */
  24084. needAlphaTesting(): boolean;
  24085. /**
  24086. * Specifies if material alpha testing should be turned on for the mesh
  24087. * @param mesh defines the mesh to check
  24088. */
  24089. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24090. /**
  24091. * Gets the texture used for the alpha test
  24092. * @returns the texture to use for alpha testing
  24093. */
  24094. getAlphaTestTexture(): Nullable<BaseTexture>;
  24095. /**
  24096. * Marks the material to indicate that it needs to be re-calculated
  24097. */
  24098. markDirty(): void;
  24099. /** @hidden */
  24100. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24101. /**
  24102. * Binds the material to the mesh
  24103. * @param world defines the world transformation matrix
  24104. * @param mesh defines the mesh to bind the material to
  24105. */
  24106. bind(world: Matrix, mesh?: Mesh): void;
  24107. /**
  24108. * Binds the submesh to the material
  24109. * @param world defines the world transformation matrix
  24110. * @param mesh defines the mesh containing the submesh
  24111. * @param subMesh defines the submesh to bind the material to
  24112. */
  24113. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24114. /**
  24115. * Binds the world matrix to the material
  24116. * @param world defines the world transformation matrix
  24117. */
  24118. bindOnlyWorldMatrix(world: Matrix): void;
  24119. /**
  24120. * Binds the scene's uniform buffer to the effect.
  24121. * @param effect defines the effect to bind to the scene uniform buffer
  24122. * @param sceneUbo defines the uniform buffer storing scene data
  24123. */
  24124. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24125. /**
  24126. * Binds the view matrix to the effect
  24127. * @param effect defines the effect to bind the view matrix to
  24128. */
  24129. bindView(effect: Effect): void;
  24130. /**
  24131. * Binds the view projection matrix to the effect
  24132. * @param effect defines the effect to bind the view projection matrix to
  24133. */
  24134. bindViewProjection(effect: Effect): void;
  24135. /**
  24136. * Processes to execute after binding the material to a mesh
  24137. * @param mesh defines the rendered mesh
  24138. */
  24139. protected _afterBind(mesh?: Mesh): void;
  24140. /**
  24141. * Unbinds the material from the mesh
  24142. */
  24143. unbind(): void;
  24144. /**
  24145. * Gets the active textures from the material
  24146. * @returns an array of textures
  24147. */
  24148. getActiveTextures(): BaseTexture[];
  24149. /**
  24150. * Specifies if the material uses a texture
  24151. * @param texture defines the texture to check against the material
  24152. * @returns a boolean specifying if the material uses the texture
  24153. */
  24154. hasTexture(texture: BaseTexture): boolean;
  24155. /**
  24156. * Makes a duplicate of the material, and gives it a new name
  24157. * @param name defines the new name for the duplicated material
  24158. * @returns the cloned material
  24159. */
  24160. clone(name: string): Nullable<Material>;
  24161. /**
  24162. * Gets the meshes bound to the material
  24163. * @returns an array of meshes bound to the material
  24164. */
  24165. getBindedMeshes(): AbstractMesh[];
  24166. /**
  24167. * Force shader compilation
  24168. * @param mesh defines the mesh associated with this material
  24169. * @param onCompiled defines a function to execute once the material is compiled
  24170. * @param options defines the options to configure the compilation
  24171. * @param onError defines a function to execute if the material fails compiling
  24172. */
  24173. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24174. /**
  24175. * Force shader compilation
  24176. * @param mesh defines the mesh that will use this material
  24177. * @param options defines additional options for compiling the shaders
  24178. * @returns a promise that resolves when the compilation completes
  24179. */
  24180. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24181. private static readonly _AllDirtyCallBack;
  24182. private static readonly _ImageProcessingDirtyCallBack;
  24183. private static readonly _TextureDirtyCallBack;
  24184. private static readonly _FresnelDirtyCallBack;
  24185. private static readonly _MiscDirtyCallBack;
  24186. private static readonly _LightsDirtyCallBack;
  24187. private static readonly _AttributeDirtyCallBack;
  24188. private static _FresnelAndMiscDirtyCallBack;
  24189. private static _TextureAndMiscDirtyCallBack;
  24190. private static readonly _DirtyCallbackArray;
  24191. private static readonly _RunDirtyCallBacks;
  24192. /**
  24193. * Marks a define in the material to indicate that it needs to be re-computed
  24194. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24195. */
  24196. markAsDirty(flag: number): void;
  24197. /**
  24198. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24199. * @param func defines a function which checks material defines against the submeshes
  24200. */
  24201. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24202. /**
  24203. * Indicates that the scene should check if the rendering now needs a prepass
  24204. */
  24205. protected _markScenePrePassDirty(): void;
  24206. /**
  24207. * Indicates that we need to re-calculated for all submeshes
  24208. */
  24209. protected _markAllSubMeshesAsAllDirty(): void;
  24210. /**
  24211. * Indicates that image processing needs to be re-calculated for all submeshes
  24212. */
  24213. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24214. /**
  24215. * Indicates that textures need to be re-calculated for all submeshes
  24216. */
  24217. protected _markAllSubMeshesAsTexturesDirty(): void;
  24218. /**
  24219. * Indicates that fresnel needs to be re-calculated for all submeshes
  24220. */
  24221. protected _markAllSubMeshesAsFresnelDirty(): void;
  24222. /**
  24223. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24224. */
  24225. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24226. /**
  24227. * Indicates that lights need to be re-calculated for all submeshes
  24228. */
  24229. protected _markAllSubMeshesAsLightsDirty(): void;
  24230. /**
  24231. * Indicates that attributes need to be re-calculated for all submeshes
  24232. */
  24233. protected _markAllSubMeshesAsAttributesDirty(): void;
  24234. /**
  24235. * Indicates that misc needs to be re-calculated for all submeshes
  24236. */
  24237. protected _markAllSubMeshesAsMiscDirty(): void;
  24238. /**
  24239. * Indicates that textures and misc need to be re-calculated for all submeshes
  24240. */
  24241. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24242. /**
  24243. * Disposes the material
  24244. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24245. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24246. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24247. */
  24248. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24249. /** @hidden */
  24250. private releaseVertexArrayObject;
  24251. /**
  24252. * Serializes this material
  24253. * @returns the serialized material object
  24254. */
  24255. serialize(): any;
  24256. /**
  24257. * Creates a material from parsed material data
  24258. * @param parsedMaterial defines parsed material data
  24259. * @param scene defines the hosting scene
  24260. * @param rootUrl defines the root URL to use to load textures
  24261. * @returns a new material
  24262. */
  24263. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24264. }
  24265. }
  24266. declare module BABYLON {
  24267. /**
  24268. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24269. * separate meshes. This can be use to improve performances.
  24270. * @see https://doc.babylonjs.com/how_to/multi_materials
  24271. */
  24272. export class MultiMaterial extends Material {
  24273. private _subMaterials;
  24274. /**
  24275. * Gets or Sets the list of Materials used within the multi material.
  24276. * They need to be ordered according to the submeshes order in the associated mesh
  24277. */
  24278. get subMaterials(): Nullable<Material>[];
  24279. set subMaterials(value: Nullable<Material>[]);
  24280. /**
  24281. * Function used to align with Node.getChildren()
  24282. * @returns the list of Materials used within the multi material
  24283. */
  24284. getChildren(): Nullable<Material>[];
  24285. /**
  24286. * Instantiates a new Multi Material
  24287. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24288. * separate meshes. This can be use to improve performances.
  24289. * @see https://doc.babylonjs.com/how_to/multi_materials
  24290. * @param name Define the name in the scene
  24291. * @param scene Define the scene the material belongs to
  24292. */
  24293. constructor(name: string, scene: Scene);
  24294. private _hookArray;
  24295. /**
  24296. * Get one of the submaterial by its index in the submaterials array
  24297. * @param index The index to look the sub material at
  24298. * @returns The Material if the index has been defined
  24299. */
  24300. getSubMaterial(index: number): Nullable<Material>;
  24301. /**
  24302. * Get the list of active textures for the whole sub materials list.
  24303. * @returns All the textures that will be used during the rendering
  24304. */
  24305. getActiveTextures(): BaseTexture[];
  24306. /**
  24307. * Gets the current class name of the material e.g. "MultiMaterial"
  24308. * Mainly use in serialization.
  24309. * @returns the class name
  24310. */
  24311. getClassName(): string;
  24312. /**
  24313. * Checks if the material is ready to render the requested sub mesh
  24314. * @param mesh Define the mesh the submesh belongs to
  24315. * @param subMesh Define the sub mesh to look readyness for
  24316. * @param useInstances Define whether or not the material is used with instances
  24317. * @returns true if ready, otherwise false
  24318. */
  24319. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24320. /**
  24321. * Clones the current material and its related sub materials
  24322. * @param name Define the name of the newly cloned material
  24323. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24324. * @returns the cloned material
  24325. */
  24326. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24327. /**
  24328. * Serializes the materials into a JSON representation.
  24329. * @returns the JSON representation
  24330. */
  24331. serialize(): any;
  24332. /**
  24333. * Dispose the material and release its associated resources
  24334. * @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)
  24335. * @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)
  24336. * @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)
  24337. */
  24338. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24339. /**
  24340. * Creates a MultiMaterial from parsed MultiMaterial data.
  24341. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24342. * @param scene defines the hosting scene
  24343. * @returns a new MultiMaterial
  24344. */
  24345. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24346. }
  24347. }
  24348. declare module BABYLON {
  24349. /**
  24350. * Defines a subdivision inside a mesh
  24351. */
  24352. export class SubMesh implements ICullable {
  24353. /** the material index to use */
  24354. materialIndex: number;
  24355. /** vertex index start */
  24356. verticesStart: number;
  24357. /** vertices count */
  24358. verticesCount: number;
  24359. /** index start */
  24360. indexStart: number;
  24361. /** indices count */
  24362. indexCount: number;
  24363. /** @hidden */
  24364. _materialDefines: Nullable<MaterialDefines>;
  24365. /** @hidden */
  24366. _materialEffect: Nullable<Effect>;
  24367. /** @hidden */
  24368. _effectOverride: Nullable<Effect>;
  24369. /**
  24370. * Gets material defines used by the effect associated to the sub mesh
  24371. */
  24372. get materialDefines(): Nullable<MaterialDefines>;
  24373. /**
  24374. * Sets material defines used by the effect associated to the sub mesh
  24375. */
  24376. set materialDefines(defines: Nullable<MaterialDefines>);
  24377. /**
  24378. * Gets associated effect
  24379. */
  24380. get effect(): Nullable<Effect>;
  24381. /**
  24382. * Sets associated effect (effect used to render this submesh)
  24383. * @param effect defines the effect to associate with
  24384. * @param defines defines the set of defines used to compile this effect
  24385. */
  24386. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24387. /** @hidden */
  24388. _linesIndexCount: number;
  24389. private _mesh;
  24390. private _renderingMesh;
  24391. private _boundingInfo;
  24392. private _linesIndexBuffer;
  24393. /** @hidden */
  24394. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24395. /** @hidden */
  24396. _trianglePlanes: Plane[];
  24397. /** @hidden */
  24398. _lastColliderTransformMatrix: Nullable<Matrix>;
  24399. /** @hidden */
  24400. _renderId: number;
  24401. /** @hidden */
  24402. _alphaIndex: number;
  24403. /** @hidden */
  24404. _distanceToCamera: number;
  24405. /** @hidden */
  24406. _id: number;
  24407. private _currentMaterial;
  24408. /**
  24409. * Add a new submesh to a mesh
  24410. * @param materialIndex defines the material index to use
  24411. * @param verticesStart defines vertex index start
  24412. * @param verticesCount defines vertices count
  24413. * @param indexStart defines index start
  24414. * @param indexCount defines indices count
  24415. * @param mesh defines the parent mesh
  24416. * @param renderingMesh defines an optional rendering mesh
  24417. * @param createBoundingBox defines if bounding box should be created for this submesh
  24418. * @returns the new submesh
  24419. */
  24420. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24421. /**
  24422. * Creates a new submesh
  24423. * @param materialIndex defines the material index to use
  24424. * @param verticesStart defines vertex index start
  24425. * @param verticesCount defines vertices count
  24426. * @param indexStart defines index start
  24427. * @param indexCount defines indices count
  24428. * @param mesh defines the parent mesh
  24429. * @param renderingMesh defines an optional rendering mesh
  24430. * @param createBoundingBox defines if bounding box should be created for this submesh
  24431. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24432. */
  24433. constructor(
  24434. /** the material index to use */
  24435. materialIndex: number,
  24436. /** vertex index start */
  24437. verticesStart: number,
  24438. /** vertices count */
  24439. verticesCount: number,
  24440. /** index start */
  24441. indexStart: number,
  24442. /** indices count */
  24443. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24444. /**
  24445. * Returns true if this submesh covers the entire parent mesh
  24446. * @ignorenaming
  24447. */
  24448. get IsGlobal(): boolean;
  24449. /**
  24450. * Returns the submesh BoudingInfo object
  24451. * @returns current bounding info (or mesh's one if the submesh is global)
  24452. */
  24453. getBoundingInfo(): BoundingInfo;
  24454. /**
  24455. * Sets the submesh BoundingInfo
  24456. * @param boundingInfo defines the new bounding info to use
  24457. * @returns the SubMesh
  24458. */
  24459. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24460. /**
  24461. * Returns the mesh of the current submesh
  24462. * @return the parent mesh
  24463. */
  24464. getMesh(): AbstractMesh;
  24465. /**
  24466. * Returns the rendering mesh of the submesh
  24467. * @returns the rendering mesh (could be different from parent mesh)
  24468. */
  24469. getRenderingMesh(): Mesh;
  24470. /**
  24471. * Returns the replacement mesh of the submesh
  24472. * @returns the replacement mesh (could be different from parent mesh)
  24473. */
  24474. getReplacementMesh(): Nullable<AbstractMesh>;
  24475. /**
  24476. * Returns the effective mesh of the submesh
  24477. * @returns the effective mesh (could be different from parent mesh)
  24478. */
  24479. getEffectiveMesh(): AbstractMesh;
  24480. /**
  24481. * Returns the submesh material
  24482. * @returns null or the current material
  24483. */
  24484. getMaterial(): Nullable<Material>;
  24485. private _IsMultiMaterial;
  24486. /**
  24487. * Sets a new updated BoundingInfo object to the submesh
  24488. * @param data defines an optional position array to use to determine the bounding info
  24489. * @returns the SubMesh
  24490. */
  24491. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24492. /** @hidden */
  24493. _checkCollision(collider: Collider): boolean;
  24494. /**
  24495. * Updates the submesh BoundingInfo
  24496. * @param world defines the world matrix to use to update the bounding info
  24497. * @returns the submesh
  24498. */
  24499. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24500. /**
  24501. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24502. * @param frustumPlanes defines the frustum planes
  24503. * @returns true if the submesh is intersecting with the frustum
  24504. */
  24505. isInFrustum(frustumPlanes: Plane[]): boolean;
  24506. /**
  24507. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24508. * @param frustumPlanes defines the frustum planes
  24509. * @returns true if the submesh is inside the frustum
  24510. */
  24511. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24512. /**
  24513. * Renders the submesh
  24514. * @param enableAlphaMode defines if alpha needs to be used
  24515. * @returns the submesh
  24516. */
  24517. render(enableAlphaMode: boolean): SubMesh;
  24518. /**
  24519. * @hidden
  24520. */
  24521. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24522. /**
  24523. * Checks if the submesh intersects with a ray
  24524. * @param ray defines the ray to test
  24525. * @returns true is the passed ray intersects the submesh bounding box
  24526. */
  24527. canIntersects(ray: Ray): boolean;
  24528. /**
  24529. * Intersects current submesh with a ray
  24530. * @param ray defines the ray to test
  24531. * @param positions defines mesh's positions array
  24532. * @param indices defines mesh's indices array
  24533. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24534. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24535. * @returns intersection info or null if no intersection
  24536. */
  24537. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24538. /** @hidden */
  24539. private _intersectLines;
  24540. /** @hidden */
  24541. private _intersectUnIndexedLines;
  24542. /** @hidden */
  24543. private _intersectTriangles;
  24544. /** @hidden */
  24545. private _intersectUnIndexedTriangles;
  24546. /** @hidden */
  24547. _rebuild(): void;
  24548. /**
  24549. * Creates a new submesh from the passed mesh
  24550. * @param newMesh defines the new hosting mesh
  24551. * @param newRenderingMesh defines an optional rendering mesh
  24552. * @returns the new submesh
  24553. */
  24554. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24555. /**
  24556. * Release associated resources
  24557. */
  24558. dispose(): void;
  24559. /**
  24560. * Gets the class name
  24561. * @returns the string "SubMesh".
  24562. */
  24563. getClassName(): string;
  24564. /**
  24565. * Creates a new submesh from indices data
  24566. * @param materialIndex the index of the main mesh material
  24567. * @param startIndex the index where to start the copy in the mesh indices array
  24568. * @param indexCount the number of indices to copy then from the startIndex
  24569. * @param mesh the main mesh to create the submesh from
  24570. * @param renderingMesh the optional rendering mesh
  24571. * @returns a new submesh
  24572. */
  24573. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24574. }
  24575. }
  24576. declare module BABYLON {
  24577. /**
  24578. * Class used to represent data loading progression
  24579. */
  24580. export class SceneLoaderFlags {
  24581. private static _ForceFullSceneLoadingForIncremental;
  24582. private static _ShowLoadingScreen;
  24583. private static _CleanBoneMatrixWeights;
  24584. private static _loggingLevel;
  24585. /**
  24586. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24587. */
  24588. static get ForceFullSceneLoadingForIncremental(): boolean;
  24589. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24590. /**
  24591. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24592. */
  24593. static get ShowLoadingScreen(): boolean;
  24594. static set ShowLoadingScreen(value: boolean);
  24595. /**
  24596. * Defines the current logging level (while loading the scene)
  24597. * @ignorenaming
  24598. */
  24599. static get loggingLevel(): number;
  24600. static set loggingLevel(value: number);
  24601. /**
  24602. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24603. */
  24604. static get CleanBoneMatrixWeights(): boolean;
  24605. static set CleanBoneMatrixWeights(value: boolean);
  24606. }
  24607. }
  24608. declare module BABYLON {
  24609. /**
  24610. * Class used to store geometry data (vertex buffers + index buffer)
  24611. */
  24612. export class Geometry implements IGetSetVerticesData {
  24613. /**
  24614. * Gets or sets the ID of the geometry
  24615. */
  24616. id: string;
  24617. /**
  24618. * Gets or sets the unique ID of the geometry
  24619. */
  24620. uniqueId: number;
  24621. /**
  24622. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24623. */
  24624. delayLoadState: number;
  24625. /**
  24626. * Gets the file containing the data to load when running in delay load state
  24627. */
  24628. delayLoadingFile: Nullable<string>;
  24629. /**
  24630. * Callback called when the geometry is updated
  24631. */
  24632. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24633. private _scene;
  24634. private _engine;
  24635. private _meshes;
  24636. private _totalVertices;
  24637. /** @hidden */
  24638. _indices: IndicesArray;
  24639. /** @hidden */
  24640. _vertexBuffers: {
  24641. [key: string]: VertexBuffer;
  24642. };
  24643. private _isDisposed;
  24644. private _extend;
  24645. private _boundingBias;
  24646. /** @hidden */
  24647. _delayInfo: Array<string>;
  24648. private _indexBuffer;
  24649. private _indexBufferIsUpdatable;
  24650. /** @hidden */
  24651. _boundingInfo: Nullable<BoundingInfo>;
  24652. /** @hidden */
  24653. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24654. /** @hidden */
  24655. _softwareSkinningFrameId: number;
  24656. private _vertexArrayObjects;
  24657. private _updatable;
  24658. /** @hidden */
  24659. _positions: Nullable<Vector3[]>;
  24660. /**
  24661. * 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
  24662. */
  24663. get boundingBias(): Vector2;
  24664. /**
  24665. * 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
  24666. */
  24667. set boundingBias(value: Vector2);
  24668. /**
  24669. * Static function used to attach a new empty geometry to a mesh
  24670. * @param mesh defines the mesh to attach the geometry to
  24671. * @returns the new Geometry
  24672. */
  24673. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24674. /** Get the list of meshes using this geometry */
  24675. get meshes(): Mesh[];
  24676. /**
  24677. * 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
  24678. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  24679. */
  24680. useBoundingInfoFromGeometry: boolean;
  24681. /**
  24682. * Creates a new geometry
  24683. * @param id defines the unique ID
  24684. * @param scene defines the hosting scene
  24685. * @param vertexData defines the VertexData used to get geometry data
  24686. * @param updatable defines if geometry must be updatable (false by default)
  24687. * @param mesh defines the mesh that will be associated with the geometry
  24688. */
  24689. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24690. /**
  24691. * Gets the current extend of the geometry
  24692. */
  24693. get extend(): {
  24694. minimum: Vector3;
  24695. maximum: Vector3;
  24696. };
  24697. /**
  24698. * Gets the hosting scene
  24699. * @returns the hosting Scene
  24700. */
  24701. getScene(): Scene;
  24702. /**
  24703. * Gets the hosting engine
  24704. * @returns the hosting Engine
  24705. */
  24706. getEngine(): Engine;
  24707. /**
  24708. * Defines if the geometry is ready to use
  24709. * @returns true if the geometry is ready to be used
  24710. */
  24711. isReady(): boolean;
  24712. /**
  24713. * Gets a value indicating that the geometry should not be serialized
  24714. */
  24715. get doNotSerialize(): boolean;
  24716. /** @hidden */
  24717. _rebuild(): void;
  24718. /**
  24719. * Affects all geometry data in one call
  24720. * @param vertexData defines the geometry data
  24721. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24722. */
  24723. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24724. /**
  24725. * Set specific vertex data
  24726. * @param kind defines the data kind (Position, normal, etc...)
  24727. * @param data defines the vertex data to use
  24728. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24729. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24730. */
  24731. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24732. /**
  24733. * Removes a specific vertex data
  24734. * @param kind defines the data kind (Position, normal, etc...)
  24735. */
  24736. removeVerticesData(kind: string): void;
  24737. /**
  24738. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24739. * @param buffer defines the vertex buffer to use
  24740. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24741. */
  24742. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24743. /**
  24744. * Update a specific vertex buffer
  24745. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24746. * It will do nothing if the buffer is not updatable
  24747. * @param kind defines the data kind (Position, normal, etc...)
  24748. * @param data defines the data to use
  24749. * @param offset defines the offset in the target buffer where to store the data
  24750. * @param useBytes set to true if the offset is in bytes
  24751. */
  24752. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24753. /**
  24754. * Update a specific vertex buffer
  24755. * This function will create a new buffer if the current one is not updatable
  24756. * @param kind defines the data kind (Position, normal, etc...)
  24757. * @param data defines the data to use
  24758. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24759. */
  24760. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24761. private _updateBoundingInfo;
  24762. /** @hidden */
  24763. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24764. /**
  24765. * Gets total number of vertices
  24766. * @returns the total number of vertices
  24767. */
  24768. getTotalVertices(): number;
  24769. /**
  24770. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24771. * @param kind defines the data kind (Position, normal, etc...)
  24772. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24773. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24774. * @returns a float array containing vertex data
  24775. */
  24776. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24777. /**
  24778. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24779. * @param kind defines the data kind (Position, normal, etc...)
  24780. * @returns true if the vertex buffer with the specified kind is updatable
  24781. */
  24782. isVertexBufferUpdatable(kind: string): boolean;
  24783. /**
  24784. * Gets a specific vertex buffer
  24785. * @param kind defines the data kind (Position, normal, etc...)
  24786. * @returns a VertexBuffer
  24787. */
  24788. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24789. /**
  24790. * Returns all vertex buffers
  24791. * @return an object holding all vertex buffers indexed by kind
  24792. */
  24793. getVertexBuffers(): Nullable<{
  24794. [key: string]: VertexBuffer;
  24795. }>;
  24796. /**
  24797. * Gets a boolean indicating if specific vertex buffer is present
  24798. * @param kind defines the data kind (Position, normal, etc...)
  24799. * @returns true if data is present
  24800. */
  24801. isVerticesDataPresent(kind: string): boolean;
  24802. /**
  24803. * Gets a list of all attached data kinds (Position, normal, etc...)
  24804. * @returns a list of string containing all kinds
  24805. */
  24806. getVerticesDataKinds(): string[];
  24807. /**
  24808. * Update index buffer
  24809. * @param indices defines the indices to store in the index buffer
  24810. * @param offset defines the offset in the target buffer where to store the data
  24811. * @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)
  24812. */
  24813. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24814. /**
  24815. * Creates a new index buffer
  24816. * @param indices defines the indices to store in the index buffer
  24817. * @param totalVertices defines the total number of vertices (could be null)
  24818. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24819. */
  24820. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24821. /**
  24822. * Return the total number of indices
  24823. * @returns the total number of indices
  24824. */
  24825. getTotalIndices(): number;
  24826. /**
  24827. * Gets the index buffer array
  24828. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24829. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24830. * @returns the index buffer array
  24831. */
  24832. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24833. /**
  24834. * Gets the index buffer
  24835. * @return the index buffer
  24836. */
  24837. getIndexBuffer(): Nullable<DataBuffer>;
  24838. /** @hidden */
  24839. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24840. /**
  24841. * Release the associated resources for a specific mesh
  24842. * @param mesh defines the source mesh
  24843. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24844. */
  24845. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24846. /**
  24847. * Apply current geometry to a given mesh
  24848. * @param mesh defines the mesh to apply geometry to
  24849. */
  24850. applyToMesh(mesh: Mesh): void;
  24851. private _updateExtend;
  24852. private _applyToMesh;
  24853. private notifyUpdate;
  24854. /**
  24855. * Load the geometry if it was flagged as delay loaded
  24856. * @param scene defines the hosting scene
  24857. * @param onLoaded defines a callback called when the geometry is loaded
  24858. */
  24859. load(scene: Scene, onLoaded?: () => void): void;
  24860. private _queueLoad;
  24861. /**
  24862. * Invert the geometry to move from a right handed system to a left handed one.
  24863. */
  24864. toLeftHanded(): void;
  24865. /** @hidden */
  24866. _resetPointsArrayCache(): void;
  24867. /** @hidden */
  24868. _generatePointsArray(): boolean;
  24869. /**
  24870. * Gets a value indicating if the geometry is disposed
  24871. * @returns true if the geometry was disposed
  24872. */
  24873. isDisposed(): boolean;
  24874. private _disposeVertexArrayObjects;
  24875. /**
  24876. * Free all associated resources
  24877. */
  24878. dispose(): void;
  24879. /**
  24880. * Clone the current geometry into a new geometry
  24881. * @param id defines the unique ID of the new geometry
  24882. * @returns a new geometry object
  24883. */
  24884. copy(id: string): Geometry;
  24885. /**
  24886. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24887. * @return a JSON representation of the current geometry data (without the vertices data)
  24888. */
  24889. serialize(): any;
  24890. private toNumberArray;
  24891. /**
  24892. * Serialize all vertices data into a JSON oject
  24893. * @returns a JSON representation of the current geometry data
  24894. */
  24895. serializeVerticeData(): any;
  24896. /**
  24897. * Extracts a clone of a mesh geometry
  24898. * @param mesh defines the source mesh
  24899. * @param id defines the unique ID of the new geometry object
  24900. * @returns the new geometry object
  24901. */
  24902. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24903. /**
  24904. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24905. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24906. * Be aware Math.random() could cause collisions, but:
  24907. * "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"
  24908. * @returns a string containing a new GUID
  24909. */
  24910. static RandomId(): string;
  24911. /** @hidden */
  24912. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24913. private static _CleanMatricesWeights;
  24914. /**
  24915. * Create a new geometry from persisted data (Using .babylon file format)
  24916. * @param parsedVertexData defines the persisted data
  24917. * @param scene defines the hosting scene
  24918. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24919. * @returns the new geometry object
  24920. */
  24921. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24922. }
  24923. }
  24924. declare module BABYLON {
  24925. /**
  24926. * Define an interface for all classes that will get and set the data on vertices
  24927. */
  24928. export interface IGetSetVerticesData {
  24929. /**
  24930. * Gets a boolean indicating if specific vertex data is present
  24931. * @param kind defines the vertex data kind to use
  24932. * @returns true is data kind is present
  24933. */
  24934. isVerticesDataPresent(kind: string): boolean;
  24935. /**
  24936. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24937. * @param kind defines the data kind (Position, normal, etc...)
  24938. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24940. * @returns a float array containing vertex data
  24941. */
  24942. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24943. /**
  24944. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24945. * @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.
  24946. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24947. * @returns the indices array or an empty array if the mesh has no geometry
  24948. */
  24949. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24950. /**
  24951. * Set specific vertex data
  24952. * @param kind defines the data kind (Position, normal, etc...)
  24953. * @param data defines the vertex data to use
  24954. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24955. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24956. */
  24957. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24958. /**
  24959. * Update a specific associated vertex buffer
  24960. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24961. * - VertexBuffer.PositionKind
  24962. * - VertexBuffer.UVKind
  24963. * - VertexBuffer.UV2Kind
  24964. * - VertexBuffer.UV3Kind
  24965. * - VertexBuffer.UV4Kind
  24966. * - VertexBuffer.UV5Kind
  24967. * - VertexBuffer.UV6Kind
  24968. * - VertexBuffer.ColorKind
  24969. * - VertexBuffer.MatricesIndicesKind
  24970. * - VertexBuffer.MatricesIndicesExtraKind
  24971. * - VertexBuffer.MatricesWeightsKind
  24972. * - VertexBuffer.MatricesWeightsExtraKind
  24973. * @param data defines the data source
  24974. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24975. * @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)
  24976. */
  24977. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24978. /**
  24979. * Creates a new index buffer
  24980. * @param indices defines the indices to store in the index buffer
  24981. * @param totalVertices defines the total number of vertices (could be null)
  24982. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24983. */
  24984. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24985. }
  24986. /**
  24987. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24988. */
  24989. export class VertexData {
  24990. /**
  24991. * Mesh side orientation : usually the external or front surface
  24992. */
  24993. static readonly FRONTSIDE: number;
  24994. /**
  24995. * Mesh side orientation : usually the internal or back surface
  24996. */
  24997. static readonly BACKSIDE: number;
  24998. /**
  24999. * Mesh side orientation : both internal and external or front and back surfaces
  25000. */
  25001. static readonly DOUBLESIDE: number;
  25002. /**
  25003. * Mesh side orientation : by default, `FRONTSIDE`
  25004. */
  25005. static readonly DEFAULTSIDE: number;
  25006. /**
  25007. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25008. */
  25009. positions: Nullable<FloatArray>;
  25010. /**
  25011. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25012. */
  25013. normals: Nullable<FloatArray>;
  25014. /**
  25015. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25016. */
  25017. tangents: Nullable<FloatArray>;
  25018. /**
  25019. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25020. */
  25021. uvs: Nullable<FloatArray>;
  25022. /**
  25023. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25024. */
  25025. uvs2: Nullable<FloatArray>;
  25026. /**
  25027. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25028. */
  25029. uvs3: Nullable<FloatArray>;
  25030. /**
  25031. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25032. */
  25033. uvs4: Nullable<FloatArray>;
  25034. /**
  25035. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25036. */
  25037. uvs5: Nullable<FloatArray>;
  25038. /**
  25039. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25040. */
  25041. uvs6: Nullable<FloatArray>;
  25042. /**
  25043. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25044. */
  25045. colors: Nullable<FloatArray>;
  25046. /**
  25047. * 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).
  25048. */
  25049. matricesIndices: Nullable<FloatArray>;
  25050. /**
  25051. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25052. */
  25053. matricesWeights: Nullable<FloatArray>;
  25054. /**
  25055. * An array extending the number of possible indices
  25056. */
  25057. matricesIndicesExtra: Nullable<FloatArray>;
  25058. /**
  25059. * An array extending the number of possible weights when the number of indices is extended
  25060. */
  25061. matricesWeightsExtra: Nullable<FloatArray>;
  25062. /**
  25063. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25064. */
  25065. indices: Nullable<IndicesArray>;
  25066. /**
  25067. * Uses the passed data array to set the set the values for the specified kind of data
  25068. * @param data a linear array of floating numbers
  25069. * @param kind the type of data that is being set, eg positions, colors etc
  25070. */
  25071. set(data: FloatArray, kind: string): void;
  25072. /**
  25073. * Associates the vertexData to the passed Mesh.
  25074. * Sets it as updatable or not (default `false`)
  25075. * @param mesh the mesh the vertexData is applied to
  25076. * @param updatable when used and having the value true allows new data to update the vertexData
  25077. * @returns the VertexData
  25078. */
  25079. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25080. /**
  25081. * Associates the vertexData to the passed Geometry.
  25082. * Sets it as updatable or not (default `false`)
  25083. * @param geometry the geometry the vertexData is applied to
  25084. * @param updatable when used and having the value true allows new data to update the vertexData
  25085. * @returns VertexData
  25086. */
  25087. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25088. /**
  25089. * Updates the associated mesh
  25090. * @param mesh the mesh to be updated
  25091. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25092. * @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
  25093. * @returns VertexData
  25094. */
  25095. updateMesh(mesh: Mesh): VertexData;
  25096. /**
  25097. * Updates the associated geometry
  25098. * @param geometry the geometry to be updated
  25099. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25100. * @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
  25101. * @returns VertexData.
  25102. */
  25103. updateGeometry(geometry: Geometry): VertexData;
  25104. private _applyTo;
  25105. private _update;
  25106. /**
  25107. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25108. * @param matrix the transforming matrix
  25109. * @returns the VertexData
  25110. */
  25111. transform(matrix: Matrix): VertexData;
  25112. /**
  25113. * Merges the passed VertexData into the current one
  25114. * @param other the VertexData to be merged into the current one
  25115. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25116. * @returns the modified VertexData
  25117. */
  25118. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25119. private _mergeElement;
  25120. private _validate;
  25121. /**
  25122. * Serializes the VertexData
  25123. * @returns a serialized object
  25124. */
  25125. serialize(): any;
  25126. /**
  25127. * Extracts the vertexData from a mesh
  25128. * @param mesh the mesh from which to extract the VertexData
  25129. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25130. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25131. * @returns the object VertexData associated to the passed mesh
  25132. */
  25133. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25134. /**
  25135. * Extracts the vertexData from the geometry
  25136. * @param geometry the geometry from which to extract the VertexData
  25137. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25138. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25139. * @returns the object VertexData associated to the passed mesh
  25140. */
  25141. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25142. private static _ExtractFrom;
  25143. /**
  25144. * Creates the VertexData for a Ribbon
  25145. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25146. * * pathArray array of paths, each of which an array of successive Vector3
  25147. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25148. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25149. * * 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
  25150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25151. * * 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)
  25152. * * 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)
  25153. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25154. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25155. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25156. * @returns the VertexData of the ribbon
  25157. */
  25158. static CreateRibbon(options: {
  25159. pathArray: Vector3[][];
  25160. closeArray?: boolean;
  25161. closePath?: boolean;
  25162. offset?: number;
  25163. sideOrientation?: number;
  25164. frontUVs?: Vector4;
  25165. backUVs?: Vector4;
  25166. invertUV?: boolean;
  25167. uvs?: Vector2[];
  25168. colors?: Color4[];
  25169. }): VertexData;
  25170. /**
  25171. * Creates the VertexData for a box
  25172. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25173. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25174. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25175. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25176. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25177. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25178. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25180. * * 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)
  25181. * * 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)
  25182. * @returns the VertexData of the box
  25183. */
  25184. static CreateBox(options: {
  25185. size?: number;
  25186. width?: number;
  25187. height?: number;
  25188. depth?: number;
  25189. faceUV?: Vector4[];
  25190. faceColors?: Color4[];
  25191. sideOrientation?: number;
  25192. frontUVs?: Vector4;
  25193. backUVs?: Vector4;
  25194. }): VertexData;
  25195. /**
  25196. * Creates the VertexData for a tiled box
  25197. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25198. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25199. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25200. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25202. * @returns the VertexData of the box
  25203. */
  25204. static CreateTiledBox(options: {
  25205. pattern?: number;
  25206. width?: number;
  25207. height?: number;
  25208. depth?: number;
  25209. tileSize?: number;
  25210. tileWidth?: number;
  25211. tileHeight?: number;
  25212. alignHorizontal?: number;
  25213. alignVertical?: number;
  25214. faceUV?: Vector4[];
  25215. faceColors?: Color4[];
  25216. sideOrientation?: number;
  25217. }): VertexData;
  25218. /**
  25219. * Creates the VertexData for a tiled plane
  25220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25221. * * pattern a limited pattern arrangement depending on the number
  25222. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25223. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25224. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25226. * * 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)
  25227. * * 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)
  25228. * @returns the VertexData of the tiled plane
  25229. */
  25230. static CreateTiledPlane(options: {
  25231. pattern?: number;
  25232. tileSize?: number;
  25233. tileWidth?: number;
  25234. tileHeight?: number;
  25235. size?: number;
  25236. width?: number;
  25237. height?: number;
  25238. alignHorizontal?: number;
  25239. alignVertical?: number;
  25240. sideOrientation?: number;
  25241. frontUVs?: Vector4;
  25242. backUVs?: Vector4;
  25243. }): VertexData;
  25244. /**
  25245. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25246. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25247. * * segments sets the number of horizontal strips optional, default 32
  25248. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25249. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25250. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25251. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25252. * * 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
  25253. * * 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
  25254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25255. * * 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)
  25256. * * 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)
  25257. * @returns the VertexData of the ellipsoid
  25258. */
  25259. static CreateSphere(options: {
  25260. segments?: number;
  25261. diameter?: number;
  25262. diameterX?: number;
  25263. diameterY?: number;
  25264. diameterZ?: number;
  25265. arc?: number;
  25266. slice?: number;
  25267. sideOrientation?: number;
  25268. frontUVs?: Vector4;
  25269. backUVs?: Vector4;
  25270. }): VertexData;
  25271. /**
  25272. * Creates the VertexData for a cylinder, cone or prism
  25273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25274. * * height sets the height (y direction) of the cylinder, optional, default 2
  25275. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25276. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25277. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25278. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25279. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25280. * * 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
  25281. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25282. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25283. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25284. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25286. * * 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)
  25287. * * 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)
  25288. * @returns the VertexData of the cylinder, cone or prism
  25289. */
  25290. static CreateCylinder(options: {
  25291. height?: number;
  25292. diameterTop?: number;
  25293. diameterBottom?: number;
  25294. diameter?: number;
  25295. tessellation?: number;
  25296. subdivisions?: number;
  25297. arc?: number;
  25298. faceColors?: Color4[];
  25299. faceUV?: Vector4[];
  25300. hasRings?: boolean;
  25301. enclose?: boolean;
  25302. sideOrientation?: number;
  25303. frontUVs?: Vector4;
  25304. backUVs?: Vector4;
  25305. }): VertexData;
  25306. /**
  25307. * Creates the VertexData for a torus
  25308. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25309. * * diameter the diameter of the torus, optional default 1
  25310. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25311. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25313. * * 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)
  25314. * * 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)
  25315. * @returns the VertexData of the torus
  25316. */
  25317. static CreateTorus(options: {
  25318. diameter?: number;
  25319. thickness?: number;
  25320. tessellation?: number;
  25321. sideOrientation?: number;
  25322. frontUVs?: Vector4;
  25323. backUVs?: Vector4;
  25324. }): VertexData;
  25325. /**
  25326. * Creates the VertexData of the LineSystem
  25327. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25328. * - lines an array of lines, each line being an array of successive Vector3
  25329. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25330. * @returns the VertexData of the LineSystem
  25331. */
  25332. static CreateLineSystem(options: {
  25333. lines: Vector3[][];
  25334. colors?: Nullable<Color4[][]>;
  25335. }): VertexData;
  25336. /**
  25337. * Create the VertexData for a DashedLines
  25338. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25339. * - points an array successive Vector3
  25340. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25341. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25342. * - dashNb the intended total number of dashes, optional, default 200
  25343. * @returns the VertexData for the DashedLines
  25344. */
  25345. static CreateDashedLines(options: {
  25346. points: Vector3[];
  25347. dashSize?: number;
  25348. gapSize?: number;
  25349. dashNb?: number;
  25350. }): VertexData;
  25351. /**
  25352. * Creates the VertexData for a Ground
  25353. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25354. * - width the width (x direction) of the ground, optional, default 1
  25355. * - height the height (z direction) of the ground, optional, default 1
  25356. * - subdivisions the number of subdivisions per side, optional, default 1
  25357. * @returns the VertexData of the Ground
  25358. */
  25359. static CreateGround(options: {
  25360. width?: number;
  25361. height?: number;
  25362. subdivisions?: number;
  25363. subdivisionsX?: number;
  25364. subdivisionsY?: number;
  25365. }): VertexData;
  25366. /**
  25367. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25368. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25369. * * xmin the ground minimum X coordinate, optional, default -1
  25370. * * zmin the ground minimum Z coordinate, optional, default -1
  25371. * * xmax the ground maximum X coordinate, optional, default 1
  25372. * * zmax the ground maximum Z coordinate, optional, default 1
  25373. * * 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}
  25374. * * 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}
  25375. * @returns the VertexData of the TiledGround
  25376. */
  25377. static CreateTiledGround(options: {
  25378. xmin: number;
  25379. zmin: number;
  25380. xmax: number;
  25381. zmax: number;
  25382. subdivisions?: {
  25383. w: number;
  25384. h: number;
  25385. };
  25386. precision?: {
  25387. w: number;
  25388. h: number;
  25389. };
  25390. }): VertexData;
  25391. /**
  25392. * Creates the VertexData of the Ground designed from a heightmap
  25393. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25394. * * width the width (x direction) of the ground
  25395. * * height the height (z direction) of the ground
  25396. * * subdivisions the number of subdivisions per side
  25397. * * minHeight the minimum altitude on the ground, optional, default 0
  25398. * * maxHeight the maximum altitude on the ground, optional default 1
  25399. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25400. * * buffer the array holding the image color data
  25401. * * bufferWidth the width of image
  25402. * * bufferHeight the height of image
  25403. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25404. * @returns the VertexData of the Ground designed from a heightmap
  25405. */
  25406. static CreateGroundFromHeightMap(options: {
  25407. width: number;
  25408. height: number;
  25409. subdivisions: number;
  25410. minHeight: number;
  25411. maxHeight: number;
  25412. colorFilter: Color3;
  25413. buffer: Uint8Array;
  25414. bufferWidth: number;
  25415. bufferHeight: number;
  25416. alphaFilter: number;
  25417. }): VertexData;
  25418. /**
  25419. * Creates the VertexData for a Plane
  25420. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25421. * * size sets the width and height of the plane to the value of size, optional default 1
  25422. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25423. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25425. * * 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)
  25426. * * 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)
  25427. * @returns the VertexData of the box
  25428. */
  25429. static CreatePlane(options: {
  25430. size?: number;
  25431. width?: number;
  25432. height?: number;
  25433. sideOrientation?: number;
  25434. frontUVs?: Vector4;
  25435. backUVs?: Vector4;
  25436. }): VertexData;
  25437. /**
  25438. * Creates the VertexData of the Disc or regular Polygon
  25439. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25440. * * radius the radius of the disc, optional default 0.5
  25441. * * tessellation the number of polygon sides, optional, default 64
  25442. * * 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
  25443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25444. * * 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)
  25445. * * 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)
  25446. * @returns the VertexData of the box
  25447. */
  25448. static CreateDisc(options: {
  25449. radius?: number;
  25450. tessellation?: number;
  25451. arc?: number;
  25452. sideOrientation?: number;
  25453. frontUVs?: Vector4;
  25454. backUVs?: Vector4;
  25455. }): VertexData;
  25456. /**
  25457. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25458. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25459. * @param polygon a mesh built from polygonTriangulation.build()
  25460. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25461. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25462. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25463. * @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)
  25464. * @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)
  25465. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25466. * @returns the VertexData of the Polygon
  25467. */
  25468. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25469. /**
  25470. * Creates the VertexData of the IcoSphere
  25471. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25472. * * radius the radius of the IcoSphere, optional default 1
  25473. * * radiusX allows stretching in the x direction, optional, default radius
  25474. * * radiusY allows stretching in the y direction, optional, default radius
  25475. * * radiusZ allows stretching in the z direction, optional, default radius
  25476. * * flat when true creates a flat shaded mesh, optional, default true
  25477. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25479. * * 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)
  25480. * * 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)
  25481. * @returns the VertexData of the IcoSphere
  25482. */
  25483. static CreateIcoSphere(options: {
  25484. radius?: number;
  25485. radiusX?: number;
  25486. radiusY?: number;
  25487. radiusZ?: number;
  25488. flat?: boolean;
  25489. subdivisions?: number;
  25490. sideOrientation?: number;
  25491. frontUVs?: Vector4;
  25492. backUVs?: Vector4;
  25493. }): VertexData;
  25494. /**
  25495. * Creates the VertexData for a Polyhedron
  25496. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25497. * * type provided types are:
  25498. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25499. * * 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)
  25500. * * size the size of the IcoSphere, optional default 1
  25501. * * sizeX allows stretching in the x direction, optional, default size
  25502. * * sizeY allows stretching in the y direction, optional, default size
  25503. * * sizeZ allows stretching in the z direction, optional, default size
  25504. * * 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
  25505. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25506. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25507. * * flat when true creates a flat shaded mesh, optional, default true
  25508. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25510. * * 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)
  25511. * * 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)
  25512. * @returns the VertexData of the Polyhedron
  25513. */
  25514. static CreatePolyhedron(options: {
  25515. type?: number;
  25516. size?: number;
  25517. sizeX?: number;
  25518. sizeY?: number;
  25519. sizeZ?: number;
  25520. custom?: any;
  25521. faceUV?: Vector4[];
  25522. faceColors?: Color4[];
  25523. flat?: boolean;
  25524. sideOrientation?: number;
  25525. frontUVs?: Vector4;
  25526. backUVs?: Vector4;
  25527. }): VertexData;
  25528. /**
  25529. * Creates the VertexData for a TorusKnot
  25530. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25531. * * radius the radius of the torus knot, optional, default 2
  25532. * * tube the thickness of the tube, optional, default 0.5
  25533. * * radialSegments the number of sides on each tube segments, optional, default 32
  25534. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25535. * * p the number of windings around the z axis, optional, default 2
  25536. * * q the number of windings around the x axis, optional, default 3
  25537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25538. * * 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)
  25539. * * 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)
  25540. * @returns the VertexData of the Torus Knot
  25541. */
  25542. static CreateTorusKnot(options: {
  25543. radius?: number;
  25544. tube?: number;
  25545. radialSegments?: number;
  25546. tubularSegments?: number;
  25547. p?: number;
  25548. q?: number;
  25549. sideOrientation?: number;
  25550. frontUVs?: Vector4;
  25551. backUVs?: Vector4;
  25552. }): VertexData;
  25553. /**
  25554. * Compute normals for given positions and indices
  25555. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25556. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25557. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25558. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25559. * * facetNormals : optional array of facet normals (vector3)
  25560. * * facetPositions : optional array of facet positions (vector3)
  25561. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25562. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25563. * * bInfo : optional bounding info, required for facetPartitioning computation
  25564. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25565. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25566. * * useRightHandedSystem: optional boolean to for right handed system computation
  25567. * * depthSort : optional boolean to enable the facet depth sort computation
  25568. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25569. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25570. */
  25571. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25572. facetNormals?: any;
  25573. facetPositions?: any;
  25574. facetPartitioning?: any;
  25575. ratio?: number;
  25576. bInfo?: any;
  25577. bbSize?: Vector3;
  25578. subDiv?: any;
  25579. useRightHandedSystem?: boolean;
  25580. depthSort?: boolean;
  25581. distanceTo?: Vector3;
  25582. depthSortedFacets?: any;
  25583. }): void;
  25584. /** @hidden */
  25585. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25586. /**
  25587. * Applies VertexData created from the imported parameters to the geometry
  25588. * @param parsedVertexData the parsed data from an imported file
  25589. * @param geometry the geometry to apply the VertexData to
  25590. */
  25591. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25592. }
  25593. }
  25594. declare module BABYLON {
  25595. /**
  25596. * Defines a target to use with MorphTargetManager
  25597. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25598. */
  25599. export class MorphTarget implements IAnimatable {
  25600. /** defines the name of the target */
  25601. name: string;
  25602. /**
  25603. * Gets or sets the list of animations
  25604. */
  25605. animations: Animation[];
  25606. private _scene;
  25607. private _positions;
  25608. private _normals;
  25609. private _tangents;
  25610. private _uvs;
  25611. private _influence;
  25612. private _uniqueId;
  25613. /**
  25614. * Observable raised when the influence changes
  25615. */
  25616. onInfluenceChanged: Observable<boolean>;
  25617. /** @hidden */
  25618. _onDataLayoutChanged: Observable<void>;
  25619. /**
  25620. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25621. */
  25622. get influence(): number;
  25623. set influence(influence: number);
  25624. /**
  25625. * Gets or sets the id of the morph Target
  25626. */
  25627. id: string;
  25628. private _animationPropertiesOverride;
  25629. /**
  25630. * Gets or sets the animation properties override
  25631. */
  25632. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25633. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25634. /**
  25635. * Creates a new MorphTarget
  25636. * @param name defines the name of the target
  25637. * @param influence defines the influence to use
  25638. * @param scene defines the scene the morphtarget belongs to
  25639. */
  25640. constructor(
  25641. /** defines the name of the target */
  25642. name: string, influence?: number, scene?: Nullable<Scene>);
  25643. /**
  25644. * Gets the unique ID of this manager
  25645. */
  25646. get uniqueId(): number;
  25647. /**
  25648. * Gets a boolean defining if the target contains position data
  25649. */
  25650. get hasPositions(): boolean;
  25651. /**
  25652. * Gets a boolean defining if the target contains normal data
  25653. */
  25654. get hasNormals(): boolean;
  25655. /**
  25656. * Gets a boolean defining if the target contains tangent data
  25657. */
  25658. get hasTangents(): boolean;
  25659. /**
  25660. * Gets a boolean defining if the target contains texture coordinates data
  25661. */
  25662. get hasUVs(): boolean;
  25663. /**
  25664. * Affects position data to this target
  25665. * @param data defines the position data to use
  25666. */
  25667. setPositions(data: Nullable<FloatArray>): void;
  25668. /**
  25669. * Gets the position data stored in this target
  25670. * @returns a FloatArray containing the position data (or null if not present)
  25671. */
  25672. getPositions(): Nullable<FloatArray>;
  25673. /**
  25674. * Affects normal data to this target
  25675. * @param data defines the normal data to use
  25676. */
  25677. setNormals(data: Nullable<FloatArray>): void;
  25678. /**
  25679. * Gets the normal data stored in this target
  25680. * @returns a FloatArray containing the normal data (or null if not present)
  25681. */
  25682. getNormals(): Nullable<FloatArray>;
  25683. /**
  25684. * Affects tangent data to this target
  25685. * @param data defines the tangent data to use
  25686. */
  25687. setTangents(data: Nullable<FloatArray>): void;
  25688. /**
  25689. * Gets the tangent data stored in this target
  25690. * @returns a FloatArray containing the tangent data (or null if not present)
  25691. */
  25692. getTangents(): Nullable<FloatArray>;
  25693. /**
  25694. * Affects texture coordinates data to this target
  25695. * @param data defines the texture coordinates data to use
  25696. */
  25697. setUVs(data: Nullable<FloatArray>): void;
  25698. /**
  25699. * Gets the texture coordinates data stored in this target
  25700. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25701. */
  25702. getUVs(): Nullable<FloatArray>;
  25703. /**
  25704. * Clone the current target
  25705. * @returns a new MorphTarget
  25706. */
  25707. clone(): MorphTarget;
  25708. /**
  25709. * Serializes the current target into a Serialization object
  25710. * @returns the serialized object
  25711. */
  25712. serialize(): any;
  25713. /**
  25714. * Returns the string "MorphTarget"
  25715. * @returns "MorphTarget"
  25716. */
  25717. getClassName(): string;
  25718. /**
  25719. * Creates a new target from serialized data
  25720. * @param serializationObject defines the serialized data to use
  25721. * @returns a new MorphTarget
  25722. */
  25723. static Parse(serializationObject: any): MorphTarget;
  25724. /**
  25725. * Creates a MorphTarget from mesh data
  25726. * @param mesh defines the source mesh
  25727. * @param name defines the name to use for the new target
  25728. * @param influence defines the influence to attach to the target
  25729. * @returns a new MorphTarget
  25730. */
  25731. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25732. }
  25733. }
  25734. declare module BABYLON {
  25735. /**
  25736. * This class is used to deform meshes using morphing between different targets
  25737. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25738. */
  25739. export class MorphTargetManager {
  25740. private _targets;
  25741. private _targetInfluenceChangedObservers;
  25742. private _targetDataLayoutChangedObservers;
  25743. private _activeTargets;
  25744. private _scene;
  25745. private _influences;
  25746. private _supportsNormals;
  25747. private _supportsTangents;
  25748. private _supportsUVs;
  25749. private _vertexCount;
  25750. private _uniqueId;
  25751. private _tempInfluences;
  25752. /**
  25753. * Gets or sets a boolean indicating if normals must be morphed
  25754. */
  25755. enableNormalMorphing: boolean;
  25756. /**
  25757. * Gets or sets a boolean indicating if tangents must be morphed
  25758. */
  25759. enableTangentMorphing: boolean;
  25760. /**
  25761. * Gets or sets a boolean indicating if UV must be morphed
  25762. */
  25763. enableUVMorphing: boolean;
  25764. /**
  25765. * Creates a new MorphTargetManager
  25766. * @param scene defines the current scene
  25767. */
  25768. constructor(scene?: Nullable<Scene>);
  25769. /**
  25770. * Gets the unique ID of this manager
  25771. */
  25772. get uniqueId(): number;
  25773. /**
  25774. * Gets the number of vertices handled by this manager
  25775. */
  25776. get vertexCount(): number;
  25777. /**
  25778. * Gets a boolean indicating if this manager supports morphing of normals
  25779. */
  25780. get supportsNormals(): boolean;
  25781. /**
  25782. * Gets a boolean indicating if this manager supports morphing of tangents
  25783. */
  25784. get supportsTangents(): boolean;
  25785. /**
  25786. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25787. */
  25788. get supportsUVs(): boolean;
  25789. /**
  25790. * Gets the number of targets stored in this manager
  25791. */
  25792. get numTargets(): number;
  25793. /**
  25794. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25795. */
  25796. get numInfluencers(): number;
  25797. /**
  25798. * Gets the list of influences (one per target)
  25799. */
  25800. get influences(): Float32Array;
  25801. /**
  25802. * Gets the active target at specified index. An active target is a target with an influence > 0
  25803. * @param index defines the index to check
  25804. * @returns the requested target
  25805. */
  25806. getActiveTarget(index: number): MorphTarget;
  25807. /**
  25808. * Gets the target at specified index
  25809. * @param index defines the index to check
  25810. * @returns the requested target
  25811. */
  25812. getTarget(index: number): MorphTarget;
  25813. /**
  25814. * Add a new target to this manager
  25815. * @param target defines the target to add
  25816. */
  25817. addTarget(target: MorphTarget): void;
  25818. /**
  25819. * Removes a target from the manager
  25820. * @param target defines the target to remove
  25821. */
  25822. removeTarget(target: MorphTarget): void;
  25823. /**
  25824. * Clone the current manager
  25825. * @returns a new MorphTargetManager
  25826. */
  25827. clone(): MorphTargetManager;
  25828. /**
  25829. * Serializes the current manager into a Serialization object
  25830. * @returns the serialized object
  25831. */
  25832. serialize(): any;
  25833. private _syncActiveTargets;
  25834. /**
  25835. * Syncrhonize the targets with all the meshes using this morph target manager
  25836. */
  25837. synchronize(): void;
  25838. /**
  25839. * Creates a new MorphTargetManager from serialized data
  25840. * @param serializationObject defines the serialized data
  25841. * @param scene defines the hosting scene
  25842. * @returns the new MorphTargetManager
  25843. */
  25844. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25845. }
  25846. }
  25847. declare module BABYLON {
  25848. /**
  25849. * Class used to represent a specific level of detail of a mesh
  25850. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25851. */
  25852. export class MeshLODLevel {
  25853. /** Defines the distance where this level should start being displayed */
  25854. distance: number;
  25855. /** Defines the mesh to use to render this level */
  25856. mesh: Nullable<Mesh>;
  25857. /**
  25858. * Creates a new LOD level
  25859. * @param distance defines the distance where this level should star being displayed
  25860. * @param mesh defines the mesh to use to render this level
  25861. */
  25862. constructor(
  25863. /** Defines the distance where this level should start being displayed */
  25864. distance: number,
  25865. /** Defines the mesh to use to render this level */
  25866. mesh: Nullable<Mesh>);
  25867. }
  25868. }
  25869. declare module BABYLON {
  25870. /**
  25871. * Helper class used to generate a canvas to manipulate images
  25872. */
  25873. export class CanvasGenerator {
  25874. /**
  25875. * Create a new canvas (or offscreen canvas depending on the context)
  25876. * @param width defines the expected width
  25877. * @param height defines the expected height
  25878. * @return a new canvas or offscreen canvas
  25879. */
  25880. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  25881. }
  25882. }
  25883. declare module BABYLON {
  25884. /**
  25885. * Mesh representing the gorund
  25886. */
  25887. export class GroundMesh extends Mesh {
  25888. /** If octree should be generated */
  25889. generateOctree: boolean;
  25890. private _heightQuads;
  25891. /** @hidden */
  25892. _subdivisionsX: number;
  25893. /** @hidden */
  25894. _subdivisionsY: number;
  25895. /** @hidden */
  25896. _width: number;
  25897. /** @hidden */
  25898. _height: number;
  25899. /** @hidden */
  25900. _minX: number;
  25901. /** @hidden */
  25902. _maxX: number;
  25903. /** @hidden */
  25904. _minZ: number;
  25905. /** @hidden */
  25906. _maxZ: number;
  25907. constructor(name: string, scene: Scene);
  25908. /**
  25909. * "GroundMesh"
  25910. * @returns "GroundMesh"
  25911. */
  25912. getClassName(): string;
  25913. /**
  25914. * The minimum of x and y subdivisions
  25915. */
  25916. get subdivisions(): number;
  25917. /**
  25918. * X subdivisions
  25919. */
  25920. get subdivisionsX(): number;
  25921. /**
  25922. * Y subdivisions
  25923. */
  25924. get subdivisionsY(): number;
  25925. /**
  25926. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25927. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25928. * @param chunksCount the number of subdivisions for x and y
  25929. * @param octreeBlocksSize (Default: 32)
  25930. */
  25931. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25932. /**
  25933. * Returns a height (y) value in the Worl system :
  25934. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25935. * @param x x coordinate
  25936. * @param z z coordinate
  25937. * @returns the ground y position if (x, z) are outside the ground surface.
  25938. */
  25939. getHeightAtCoordinates(x: number, z: number): number;
  25940. /**
  25941. * Returns a normalized vector (Vector3) orthogonal to the ground
  25942. * at the ground coordinates (x, z) expressed in the World system.
  25943. * @param x x coordinate
  25944. * @param z z coordinate
  25945. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25946. */
  25947. getNormalAtCoordinates(x: number, z: number): Vector3;
  25948. /**
  25949. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25950. * at the ground coordinates (x, z) expressed in the World system.
  25951. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25952. * @param x x coordinate
  25953. * @param z z coordinate
  25954. * @param ref vector to store the result
  25955. * @returns the GroundMesh.
  25956. */
  25957. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25958. /**
  25959. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25960. * if the ground has been updated.
  25961. * This can be used in the render loop.
  25962. * @returns the GroundMesh.
  25963. */
  25964. updateCoordinateHeights(): GroundMesh;
  25965. private _getFacetAt;
  25966. private _initHeightQuads;
  25967. private _computeHeightQuads;
  25968. /**
  25969. * Serializes this ground mesh
  25970. * @param serializationObject object to write serialization to
  25971. */
  25972. serialize(serializationObject: any): void;
  25973. /**
  25974. * Parses a serialized ground mesh
  25975. * @param parsedMesh the serialized mesh
  25976. * @param scene the scene to create the ground mesh in
  25977. * @returns the created ground mesh
  25978. */
  25979. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25980. }
  25981. }
  25982. declare module BABYLON {
  25983. /**
  25984. * Interface for Physics-Joint data
  25985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25986. */
  25987. export interface PhysicsJointData {
  25988. /**
  25989. * The main pivot of the joint
  25990. */
  25991. mainPivot?: Vector3;
  25992. /**
  25993. * The connected pivot of the joint
  25994. */
  25995. connectedPivot?: Vector3;
  25996. /**
  25997. * The main axis of the joint
  25998. */
  25999. mainAxis?: Vector3;
  26000. /**
  26001. * The connected axis of the joint
  26002. */
  26003. connectedAxis?: Vector3;
  26004. /**
  26005. * The collision of the joint
  26006. */
  26007. collision?: boolean;
  26008. /**
  26009. * Native Oimo/Cannon/Energy data
  26010. */
  26011. nativeParams?: any;
  26012. }
  26013. /**
  26014. * This is a holder class for the physics joint created by the physics plugin
  26015. * It holds a set of functions to control the underlying joint
  26016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26017. */
  26018. export class PhysicsJoint {
  26019. /**
  26020. * The type of the physics joint
  26021. */
  26022. type: number;
  26023. /**
  26024. * The data for the physics joint
  26025. */
  26026. jointData: PhysicsJointData;
  26027. private _physicsJoint;
  26028. protected _physicsPlugin: IPhysicsEnginePlugin;
  26029. /**
  26030. * Initializes the physics joint
  26031. * @param type The type of the physics joint
  26032. * @param jointData The data for the physics joint
  26033. */
  26034. constructor(
  26035. /**
  26036. * The type of the physics joint
  26037. */
  26038. type: number,
  26039. /**
  26040. * The data for the physics joint
  26041. */
  26042. jointData: PhysicsJointData);
  26043. /**
  26044. * Gets the physics joint
  26045. */
  26046. get physicsJoint(): any;
  26047. /**
  26048. * Sets the physics joint
  26049. */
  26050. set physicsJoint(newJoint: any);
  26051. /**
  26052. * Sets the physics plugin
  26053. */
  26054. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26055. /**
  26056. * Execute a function that is physics-plugin specific.
  26057. * @param {Function} func the function that will be executed.
  26058. * It accepts two parameters: the physics world and the physics joint
  26059. */
  26060. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26061. /**
  26062. * Distance-Joint type
  26063. */
  26064. static DistanceJoint: number;
  26065. /**
  26066. * Hinge-Joint type
  26067. */
  26068. static HingeJoint: number;
  26069. /**
  26070. * Ball-and-Socket joint type
  26071. */
  26072. static BallAndSocketJoint: number;
  26073. /**
  26074. * Wheel-Joint type
  26075. */
  26076. static WheelJoint: number;
  26077. /**
  26078. * Slider-Joint type
  26079. */
  26080. static SliderJoint: number;
  26081. /**
  26082. * Prismatic-Joint type
  26083. */
  26084. static PrismaticJoint: number;
  26085. /**
  26086. * Universal-Joint type
  26087. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26088. */
  26089. static UniversalJoint: number;
  26090. /**
  26091. * Hinge-Joint 2 type
  26092. */
  26093. static Hinge2Joint: number;
  26094. /**
  26095. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26096. */
  26097. static PointToPointJoint: number;
  26098. /**
  26099. * Spring-Joint type
  26100. */
  26101. static SpringJoint: number;
  26102. /**
  26103. * Lock-Joint type
  26104. */
  26105. static LockJoint: number;
  26106. }
  26107. /**
  26108. * A class representing a physics distance joint
  26109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26110. */
  26111. export class DistanceJoint extends PhysicsJoint {
  26112. /**
  26113. *
  26114. * @param jointData The data for the Distance-Joint
  26115. */
  26116. constructor(jointData: DistanceJointData);
  26117. /**
  26118. * Update the predefined distance.
  26119. * @param maxDistance The maximum preferred distance
  26120. * @param minDistance The minimum preferred distance
  26121. */
  26122. updateDistance(maxDistance: number, minDistance?: number): void;
  26123. }
  26124. /**
  26125. * Represents a Motor-Enabled Joint
  26126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26127. */
  26128. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26129. /**
  26130. * Initializes the Motor-Enabled Joint
  26131. * @param type The type of the joint
  26132. * @param jointData The physica joint data for the joint
  26133. */
  26134. constructor(type: number, jointData: PhysicsJointData);
  26135. /**
  26136. * Set the motor values.
  26137. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26138. * @param force the force to apply
  26139. * @param maxForce max force for this motor.
  26140. */
  26141. setMotor(force?: number, maxForce?: number): void;
  26142. /**
  26143. * Set the motor's limits.
  26144. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26145. * @param upperLimit The upper limit of the motor
  26146. * @param lowerLimit The lower limit of the motor
  26147. */
  26148. setLimit(upperLimit: number, lowerLimit?: number): void;
  26149. }
  26150. /**
  26151. * This class represents a single physics Hinge-Joint
  26152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26153. */
  26154. export class HingeJoint extends MotorEnabledJoint {
  26155. /**
  26156. * Initializes the Hinge-Joint
  26157. * @param jointData The joint data for the Hinge-Joint
  26158. */
  26159. constructor(jointData: PhysicsJointData);
  26160. /**
  26161. * Set the motor values.
  26162. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26163. * @param {number} force the force to apply
  26164. * @param {number} maxForce max force for this motor.
  26165. */
  26166. setMotor(force?: number, maxForce?: number): void;
  26167. /**
  26168. * Set the motor's limits.
  26169. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26170. * @param upperLimit The upper limit of the motor
  26171. * @param lowerLimit The lower limit of the motor
  26172. */
  26173. setLimit(upperLimit: number, lowerLimit?: number): void;
  26174. }
  26175. /**
  26176. * This class represents a dual hinge physics joint (same as wheel joint)
  26177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26178. */
  26179. export class Hinge2Joint extends MotorEnabledJoint {
  26180. /**
  26181. * Initializes the Hinge2-Joint
  26182. * @param jointData The joint data for the Hinge2-Joint
  26183. */
  26184. constructor(jointData: PhysicsJointData);
  26185. /**
  26186. * Set the motor values.
  26187. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26188. * @param {number} targetSpeed the speed the motor is to reach
  26189. * @param {number} maxForce max force for this motor.
  26190. * @param {motorIndex} the motor's index, 0 or 1.
  26191. */
  26192. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26193. /**
  26194. * Set the motor limits.
  26195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26196. * @param {number} upperLimit the upper limit
  26197. * @param {number} lowerLimit lower limit
  26198. * @param {motorIndex} the motor's index, 0 or 1.
  26199. */
  26200. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26201. }
  26202. /**
  26203. * Interface for a motor enabled joint
  26204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26205. */
  26206. export interface IMotorEnabledJoint {
  26207. /**
  26208. * Physics joint
  26209. */
  26210. physicsJoint: any;
  26211. /**
  26212. * Sets the motor of the motor-enabled joint
  26213. * @param force The force of the motor
  26214. * @param maxForce The maximum force of the motor
  26215. * @param motorIndex The index of the motor
  26216. */
  26217. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26218. /**
  26219. * Sets the limit of the motor
  26220. * @param upperLimit The upper limit of the motor
  26221. * @param lowerLimit The lower limit of the motor
  26222. * @param motorIndex The index of the motor
  26223. */
  26224. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26225. }
  26226. /**
  26227. * Joint data for a Distance-Joint
  26228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26229. */
  26230. export interface DistanceJointData extends PhysicsJointData {
  26231. /**
  26232. * Max distance the 2 joint objects can be apart
  26233. */
  26234. maxDistance: number;
  26235. }
  26236. /**
  26237. * Joint data from a spring joint
  26238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26239. */
  26240. export interface SpringJointData extends PhysicsJointData {
  26241. /**
  26242. * Length of the spring
  26243. */
  26244. length: number;
  26245. /**
  26246. * Stiffness of the spring
  26247. */
  26248. stiffness: number;
  26249. /**
  26250. * Damping of the spring
  26251. */
  26252. damping: number;
  26253. /** this callback will be called when applying the force to the impostors. */
  26254. forceApplicationCallback: () => void;
  26255. }
  26256. }
  26257. declare module BABYLON {
  26258. /**
  26259. * Holds the data for the raycast result
  26260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26261. */
  26262. export class PhysicsRaycastResult {
  26263. private _hasHit;
  26264. private _hitDistance;
  26265. private _hitNormalWorld;
  26266. private _hitPointWorld;
  26267. private _rayFromWorld;
  26268. private _rayToWorld;
  26269. /**
  26270. * Gets if there was a hit
  26271. */
  26272. get hasHit(): boolean;
  26273. /**
  26274. * Gets the distance from the hit
  26275. */
  26276. get hitDistance(): number;
  26277. /**
  26278. * Gets the hit normal/direction in the world
  26279. */
  26280. get hitNormalWorld(): Vector3;
  26281. /**
  26282. * Gets the hit point in the world
  26283. */
  26284. get hitPointWorld(): Vector3;
  26285. /**
  26286. * Gets the ray "start point" of the ray in the world
  26287. */
  26288. get rayFromWorld(): Vector3;
  26289. /**
  26290. * Gets the ray "end point" of the ray in the world
  26291. */
  26292. get rayToWorld(): Vector3;
  26293. /**
  26294. * Sets the hit data (normal & point in world space)
  26295. * @param hitNormalWorld defines the normal in world space
  26296. * @param hitPointWorld defines the point in world space
  26297. */
  26298. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26299. /**
  26300. * Sets the distance from the start point to the hit point
  26301. * @param distance
  26302. */
  26303. setHitDistance(distance: number): void;
  26304. /**
  26305. * Calculates the distance manually
  26306. */
  26307. calculateHitDistance(): void;
  26308. /**
  26309. * Resets all the values to default
  26310. * @param from The from point on world space
  26311. * @param to The to point on world space
  26312. */
  26313. reset(from?: Vector3, to?: Vector3): void;
  26314. }
  26315. /**
  26316. * Interface for the size containing width and height
  26317. */
  26318. interface IXYZ {
  26319. /**
  26320. * X
  26321. */
  26322. x: number;
  26323. /**
  26324. * Y
  26325. */
  26326. y: number;
  26327. /**
  26328. * Z
  26329. */
  26330. z: number;
  26331. }
  26332. }
  26333. declare module BABYLON {
  26334. /**
  26335. * Interface used to describe a physics joint
  26336. */
  26337. export interface PhysicsImpostorJoint {
  26338. /** Defines the main impostor to which the joint is linked */
  26339. mainImpostor: PhysicsImpostor;
  26340. /** Defines the impostor that is connected to the main impostor using this joint */
  26341. connectedImpostor: PhysicsImpostor;
  26342. /** Defines the joint itself */
  26343. joint: PhysicsJoint;
  26344. }
  26345. /** @hidden */
  26346. export interface IPhysicsEnginePlugin {
  26347. world: any;
  26348. name: string;
  26349. setGravity(gravity: Vector3): void;
  26350. setTimeStep(timeStep: number): void;
  26351. getTimeStep(): number;
  26352. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26353. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26354. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26355. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26356. removePhysicsBody(impostor: PhysicsImpostor): void;
  26357. generateJoint(joint: PhysicsImpostorJoint): void;
  26358. removeJoint(joint: PhysicsImpostorJoint): void;
  26359. isSupported(): boolean;
  26360. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26361. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26362. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26363. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26364. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26365. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26366. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26367. getBodyMass(impostor: PhysicsImpostor): number;
  26368. getBodyFriction(impostor: PhysicsImpostor): number;
  26369. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26370. getBodyRestitution(impostor: PhysicsImpostor): number;
  26371. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26372. getBodyPressure?(impostor: PhysicsImpostor): number;
  26373. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26374. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26375. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26376. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26377. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26378. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26379. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26380. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26381. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26382. sleepBody(impostor: PhysicsImpostor): void;
  26383. wakeUpBody(impostor: PhysicsImpostor): void;
  26384. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26385. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26386. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26387. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26388. getRadius(impostor: PhysicsImpostor): number;
  26389. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26390. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26391. dispose(): void;
  26392. }
  26393. /**
  26394. * Interface used to define a physics engine
  26395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26396. */
  26397. export interface IPhysicsEngine {
  26398. /**
  26399. * Gets the gravity vector used by the simulation
  26400. */
  26401. gravity: Vector3;
  26402. /**
  26403. * Sets the gravity vector used by the simulation
  26404. * @param gravity defines the gravity vector to use
  26405. */
  26406. setGravity(gravity: Vector3): void;
  26407. /**
  26408. * Set the time step of the physics engine.
  26409. * Default is 1/60.
  26410. * To slow it down, enter 1/600 for example.
  26411. * To speed it up, 1/30
  26412. * @param newTimeStep the new timestep to apply to this world.
  26413. */
  26414. setTimeStep(newTimeStep: number): void;
  26415. /**
  26416. * Get the time step of the physics engine.
  26417. * @returns the current time step
  26418. */
  26419. getTimeStep(): number;
  26420. /**
  26421. * Set the sub time step of the physics engine.
  26422. * Default is 0 meaning there is no sub steps
  26423. * To increase physics resolution precision, set a small value (like 1 ms)
  26424. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26425. */
  26426. setSubTimeStep(subTimeStep: number): void;
  26427. /**
  26428. * Get the sub time step of the physics engine.
  26429. * @returns the current sub time step
  26430. */
  26431. getSubTimeStep(): number;
  26432. /**
  26433. * Release all resources
  26434. */
  26435. dispose(): void;
  26436. /**
  26437. * Gets the name of the current physics plugin
  26438. * @returns the name of the plugin
  26439. */
  26440. getPhysicsPluginName(): string;
  26441. /**
  26442. * Adding a new impostor for the impostor tracking.
  26443. * This will be done by the impostor itself.
  26444. * @param impostor the impostor to add
  26445. */
  26446. addImpostor(impostor: PhysicsImpostor): void;
  26447. /**
  26448. * Remove an impostor from the engine.
  26449. * This impostor and its mesh will not longer be updated by the physics engine.
  26450. * @param impostor the impostor to remove
  26451. */
  26452. removeImpostor(impostor: PhysicsImpostor): void;
  26453. /**
  26454. * Add a joint to the physics engine
  26455. * @param mainImpostor defines the main impostor to which the joint is added.
  26456. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26457. * @param joint defines the joint that will connect both impostors.
  26458. */
  26459. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26460. /**
  26461. * Removes a joint from the simulation
  26462. * @param mainImpostor defines the impostor used with the joint
  26463. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26464. * @param joint defines the joint to remove
  26465. */
  26466. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26467. /**
  26468. * Gets the current plugin used to run the simulation
  26469. * @returns current plugin
  26470. */
  26471. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26472. /**
  26473. * Gets the list of physic impostors
  26474. * @returns an array of PhysicsImpostor
  26475. */
  26476. getImpostors(): Array<PhysicsImpostor>;
  26477. /**
  26478. * Gets the impostor for a physics enabled object
  26479. * @param object defines the object impersonated by the impostor
  26480. * @returns the PhysicsImpostor or null if not found
  26481. */
  26482. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26483. /**
  26484. * Gets the impostor for a physics body object
  26485. * @param body defines physics body used by the impostor
  26486. * @returns the PhysicsImpostor or null if not found
  26487. */
  26488. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26489. /**
  26490. * Does a raycast in the physics world
  26491. * @param from when should the ray start?
  26492. * @param to when should the ray end?
  26493. * @returns PhysicsRaycastResult
  26494. */
  26495. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26496. /**
  26497. * Called by the scene. No need to call it.
  26498. * @param delta defines the timespam between frames
  26499. */
  26500. _step(delta: number): void;
  26501. }
  26502. }
  26503. declare module BABYLON {
  26504. /**
  26505. * The interface for the physics imposter parameters
  26506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26507. */
  26508. export interface PhysicsImpostorParameters {
  26509. /**
  26510. * The mass of the physics imposter
  26511. */
  26512. mass: number;
  26513. /**
  26514. * The friction of the physics imposter
  26515. */
  26516. friction?: number;
  26517. /**
  26518. * The coefficient of restitution of the physics imposter
  26519. */
  26520. restitution?: number;
  26521. /**
  26522. * The native options of the physics imposter
  26523. */
  26524. nativeOptions?: any;
  26525. /**
  26526. * Specifies if the parent should be ignored
  26527. */
  26528. ignoreParent?: boolean;
  26529. /**
  26530. * Specifies if bi-directional transformations should be disabled
  26531. */
  26532. disableBidirectionalTransformation?: boolean;
  26533. /**
  26534. * The pressure inside the physics imposter, soft object only
  26535. */
  26536. pressure?: number;
  26537. /**
  26538. * The stiffness the physics imposter, soft object only
  26539. */
  26540. stiffness?: number;
  26541. /**
  26542. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26543. */
  26544. velocityIterations?: number;
  26545. /**
  26546. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26547. */
  26548. positionIterations?: number;
  26549. /**
  26550. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26551. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26552. * Add to fix multiple points
  26553. */
  26554. fixedPoints?: number;
  26555. /**
  26556. * The collision margin around a soft object
  26557. */
  26558. margin?: number;
  26559. /**
  26560. * The collision margin around a soft object
  26561. */
  26562. damping?: number;
  26563. /**
  26564. * The path for a rope based on an extrusion
  26565. */
  26566. path?: any;
  26567. /**
  26568. * The shape of an extrusion used for a rope based on an extrusion
  26569. */
  26570. shape?: any;
  26571. }
  26572. /**
  26573. * Interface for a physics-enabled object
  26574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26575. */
  26576. export interface IPhysicsEnabledObject {
  26577. /**
  26578. * The position of the physics-enabled object
  26579. */
  26580. position: Vector3;
  26581. /**
  26582. * The rotation of the physics-enabled object
  26583. */
  26584. rotationQuaternion: Nullable<Quaternion>;
  26585. /**
  26586. * The scale of the physics-enabled object
  26587. */
  26588. scaling: Vector3;
  26589. /**
  26590. * The rotation of the physics-enabled object
  26591. */
  26592. rotation?: Vector3;
  26593. /**
  26594. * The parent of the physics-enabled object
  26595. */
  26596. parent?: any;
  26597. /**
  26598. * The bounding info of the physics-enabled object
  26599. * @returns The bounding info of the physics-enabled object
  26600. */
  26601. getBoundingInfo(): BoundingInfo;
  26602. /**
  26603. * Computes the world matrix
  26604. * @param force Specifies if the world matrix should be computed by force
  26605. * @returns A world matrix
  26606. */
  26607. computeWorldMatrix(force: boolean): Matrix;
  26608. /**
  26609. * Gets the world matrix
  26610. * @returns A world matrix
  26611. */
  26612. getWorldMatrix?(): Matrix;
  26613. /**
  26614. * Gets the child meshes
  26615. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26616. * @returns An array of abstract meshes
  26617. */
  26618. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26619. /**
  26620. * Gets the vertex data
  26621. * @param kind The type of vertex data
  26622. * @returns A nullable array of numbers, or a float32 array
  26623. */
  26624. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26625. /**
  26626. * Gets the indices from the mesh
  26627. * @returns A nullable array of index arrays
  26628. */
  26629. getIndices?(): Nullable<IndicesArray>;
  26630. /**
  26631. * Gets the scene from the mesh
  26632. * @returns the indices array or null
  26633. */
  26634. getScene?(): Scene;
  26635. /**
  26636. * Gets the absolute position from the mesh
  26637. * @returns the absolute position
  26638. */
  26639. getAbsolutePosition(): Vector3;
  26640. /**
  26641. * Gets the absolute pivot point from the mesh
  26642. * @returns the absolute pivot point
  26643. */
  26644. getAbsolutePivotPoint(): Vector3;
  26645. /**
  26646. * Rotates the mesh
  26647. * @param axis The axis of rotation
  26648. * @param amount The amount of rotation
  26649. * @param space The space of the rotation
  26650. * @returns The rotation transform node
  26651. */
  26652. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26653. /**
  26654. * Translates the mesh
  26655. * @param axis The axis of translation
  26656. * @param distance The distance of translation
  26657. * @param space The space of the translation
  26658. * @returns The transform node
  26659. */
  26660. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26661. /**
  26662. * Sets the absolute position of the mesh
  26663. * @param absolutePosition The absolute position of the mesh
  26664. * @returns The transform node
  26665. */
  26666. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26667. /**
  26668. * Gets the class name of the mesh
  26669. * @returns The class name
  26670. */
  26671. getClassName(): string;
  26672. }
  26673. /**
  26674. * Represents a physics imposter
  26675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26676. */
  26677. export class PhysicsImpostor {
  26678. /**
  26679. * The physics-enabled object used as the physics imposter
  26680. */
  26681. object: IPhysicsEnabledObject;
  26682. /**
  26683. * The type of the physics imposter
  26684. */
  26685. type: number;
  26686. private _options;
  26687. private _scene?;
  26688. /**
  26689. * The default object size of the imposter
  26690. */
  26691. static DEFAULT_OBJECT_SIZE: Vector3;
  26692. /**
  26693. * The identity quaternion of the imposter
  26694. */
  26695. static IDENTITY_QUATERNION: Quaternion;
  26696. /** @hidden */
  26697. _pluginData: any;
  26698. private _physicsEngine;
  26699. private _physicsBody;
  26700. private _bodyUpdateRequired;
  26701. private _onBeforePhysicsStepCallbacks;
  26702. private _onAfterPhysicsStepCallbacks;
  26703. /** @hidden */
  26704. _onPhysicsCollideCallbacks: Array<{
  26705. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26706. otherImpostors: Array<PhysicsImpostor>;
  26707. }>;
  26708. private _deltaPosition;
  26709. private _deltaRotation;
  26710. private _deltaRotationConjugated;
  26711. /** @hidden */
  26712. _isFromLine: boolean;
  26713. private _parent;
  26714. private _isDisposed;
  26715. private static _tmpVecs;
  26716. private static _tmpQuat;
  26717. /**
  26718. * Specifies if the physics imposter is disposed
  26719. */
  26720. get isDisposed(): boolean;
  26721. /**
  26722. * Gets the mass of the physics imposter
  26723. */
  26724. get mass(): number;
  26725. set mass(value: number);
  26726. /**
  26727. * Gets the coefficient of friction
  26728. */
  26729. get friction(): number;
  26730. /**
  26731. * Sets the coefficient of friction
  26732. */
  26733. set friction(value: number);
  26734. /**
  26735. * Gets the coefficient of restitution
  26736. */
  26737. get restitution(): number;
  26738. /**
  26739. * Sets the coefficient of restitution
  26740. */
  26741. set restitution(value: number);
  26742. /**
  26743. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26744. */
  26745. get pressure(): number;
  26746. /**
  26747. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26748. */
  26749. set pressure(value: number);
  26750. /**
  26751. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26752. */
  26753. get stiffness(): number;
  26754. /**
  26755. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26756. */
  26757. set stiffness(value: number);
  26758. /**
  26759. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26760. */
  26761. get velocityIterations(): number;
  26762. /**
  26763. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26764. */
  26765. set velocityIterations(value: number);
  26766. /**
  26767. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26768. */
  26769. get positionIterations(): number;
  26770. /**
  26771. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26772. */
  26773. set positionIterations(value: number);
  26774. /**
  26775. * The unique id of the physics imposter
  26776. * set by the physics engine when adding this impostor to the array
  26777. */
  26778. uniqueId: number;
  26779. /**
  26780. * @hidden
  26781. */
  26782. soft: boolean;
  26783. /**
  26784. * @hidden
  26785. */
  26786. segments: number;
  26787. private _joints;
  26788. /**
  26789. * Initializes the physics imposter
  26790. * @param object The physics-enabled object used as the physics imposter
  26791. * @param type The type of the physics imposter
  26792. * @param _options The options for the physics imposter
  26793. * @param _scene The Babylon scene
  26794. */
  26795. constructor(
  26796. /**
  26797. * The physics-enabled object used as the physics imposter
  26798. */
  26799. object: IPhysicsEnabledObject,
  26800. /**
  26801. * The type of the physics imposter
  26802. */
  26803. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26804. /**
  26805. * This function will completly initialize this impostor.
  26806. * It will create a new body - but only if this mesh has no parent.
  26807. * If it has, this impostor will not be used other than to define the impostor
  26808. * of the child mesh.
  26809. * @hidden
  26810. */
  26811. _init(): void;
  26812. private _getPhysicsParent;
  26813. /**
  26814. * Should a new body be generated.
  26815. * @returns boolean specifying if body initialization is required
  26816. */
  26817. isBodyInitRequired(): boolean;
  26818. /**
  26819. * Sets the updated scaling
  26820. * @param updated Specifies if the scaling is updated
  26821. */
  26822. setScalingUpdated(): void;
  26823. /**
  26824. * Force a regeneration of this or the parent's impostor's body.
  26825. * Use under cautious - This will remove all joints already implemented.
  26826. */
  26827. forceUpdate(): void;
  26828. /**
  26829. * Gets the body that holds this impostor. Either its own, or its parent.
  26830. */
  26831. get physicsBody(): any;
  26832. /**
  26833. * Get the parent of the physics imposter
  26834. * @returns Physics imposter or null
  26835. */
  26836. get parent(): Nullable<PhysicsImpostor>;
  26837. /**
  26838. * Sets the parent of the physics imposter
  26839. */
  26840. set parent(value: Nullable<PhysicsImpostor>);
  26841. /**
  26842. * Set the physics body. Used mainly by the physics engine/plugin
  26843. */
  26844. set physicsBody(physicsBody: any);
  26845. /**
  26846. * Resets the update flags
  26847. */
  26848. resetUpdateFlags(): void;
  26849. /**
  26850. * Gets the object extend size
  26851. * @returns the object extend size
  26852. */
  26853. getObjectExtendSize(): Vector3;
  26854. /**
  26855. * Gets the object center
  26856. * @returns The object center
  26857. */
  26858. getObjectCenter(): Vector3;
  26859. /**
  26860. * Get a specific parameter from the options parameters
  26861. * @param paramName The object parameter name
  26862. * @returns The object parameter
  26863. */
  26864. getParam(paramName: string): any;
  26865. /**
  26866. * Sets a specific parameter in the options given to the physics plugin
  26867. * @param paramName The parameter name
  26868. * @param value The value of the parameter
  26869. */
  26870. setParam(paramName: string, value: number): void;
  26871. /**
  26872. * Specifically change the body's mass option. Won't recreate the physics body object
  26873. * @param mass The mass of the physics imposter
  26874. */
  26875. setMass(mass: number): void;
  26876. /**
  26877. * Gets the linear velocity
  26878. * @returns linear velocity or null
  26879. */
  26880. getLinearVelocity(): Nullable<Vector3>;
  26881. /**
  26882. * Sets the linear velocity
  26883. * @param velocity linear velocity or null
  26884. */
  26885. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26886. /**
  26887. * Gets the angular velocity
  26888. * @returns angular velocity or null
  26889. */
  26890. getAngularVelocity(): Nullable<Vector3>;
  26891. /**
  26892. * Sets the angular velocity
  26893. * @param velocity The velocity or null
  26894. */
  26895. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26896. /**
  26897. * Execute a function with the physics plugin native code
  26898. * Provide a function the will have two variables - the world object and the physics body object
  26899. * @param func The function to execute with the physics plugin native code
  26900. */
  26901. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26902. /**
  26903. * Register a function that will be executed before the physics world is stepping forward
  26904. * @param func The function to execute before the physics world is stepped forward
  26905. */
  26906. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26907. /**
  26908. * Unregister a function that will be executed before the physics world is stepping forward
  26909. * @param func The function to execute before the physics world is stepped forward
  26910. */
  26911. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26912. /**
  26913. * Register a function that will be executed after the physics step
  26914. * @param func The function to execute after physics step
  26915. */
  26916. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26917. /**
  26918. * Unregisters a function that will be executed after the physics step
  26919. * @param func The function to execute after physics step
  26920. */
  26921. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26922. /**
  26923. * register a function that will be executed when this impostor collides against a different body
  26924. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26925. * @param func Callback that is executed on collision
  26926. */
  26927. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26928. /**
  26929. * Unregisters the physics imposter on contact
  26930. * @param collideAgainst The physics object to collide against
  26931. * @param func Callback to execute on collision
  26932. */
  26933. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26934. private _tmpQuat;
  26935. private _tmpQuat2;
  26936. /**
  26937. * Get the parent rotation
  26938. * @returns The parent rotation
  26939. */
  26940. getParentsRotation(): Quaternion;
  26941. /**
  26942. * this function is executed by the physics engine.
  26943. */
  26944. beforeStep: () => void;
  26945. /**
  26946. * this function is executed by the physics engine
  26947. */
  26948. afterStep: () => void;
  26949. /**
  26950. * Legacy collision detection event support
  26951. */
  26952. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26953. /**
  26954. * event and body object due to cannon's event-based architecture.
  26955. */
  26956. onCollide: (e: {
  26957. body: any;
  26958. }) => void;
  26959. /**
  26960. * Apply a force
  26961. * @param force The force to apply
  26962. * @param contactPoint The contact point for the force
  26963. * @returns The physics imposter
  26964. */
  26965. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26966. /**
  26967. * Apply an impulse
  26968. * @param force The impulse force
  26969. * @param contactPoint The contact point for the impulse force
  26970. * @returns The physics imposter
  26971. */
  26972. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26973. /**
  26974. * A help function to create a joint
  26975. * @param otherImpostor A physics imposter used to create a joint
  26976. * @param jointType The type of joint
  26977. * @param jointData The data for the joint
  26978. * @returns The physics imposter
  26979. */
  26980. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26981. /**
  26982. * Add a joint to this impostor with a different impostor
  26983. * @param otherImpostor A physics imposter used to add a joint
  26984. * @param joint The joint to add
  26985. * @returns The physics imposter
  26986. */
  26987. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26988. /**
  26989. * Add an anchor to a cloth impostor
  26990. * @param otherImpostor rigid impostor to anchor to
  26991. * @param width ratio across width from 0 to 1
  26992. * @param height ratio up height from 0 to 1
  26993. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26994. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26995. * @returns impostor the soft imposter
  26996. */
  26997. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26998. /**
  26999. * Add a hook to a rope impostor
  27000. * @param otherImpostor rigid impostor to anchor to
  27001. * @param length ratio across rope from 0 to 1
  27002. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27003. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27004. * @returns impostor the rope imposter
  27005. */
  27006. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27007. /**
  27008. * Will keep this body still, in a sleep mode.
  27009. * @returns the physics imposter
  27010. */
  27011. sleep(): PhysicsImpostor;
  27012. /**
  27013. * Wake the body up.
  27014. * @returns The physics imposter
  27015. */
  27016. wakeUp(): PhysicsImpostor;
  27017. /**
  27018. * Clones the physics imposter
  27019. * @param newObject The physics imposter clones to this physics-enabled object
  27020. * @returns A nullable physics imposter
  27021. */
  27022. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27023. /**
  27024. * Disposes the physics imposter
  27025. */
  27026. dispose(): void;
  27027. /**
  27028. * Sets the delta position
  27029. * @param position The delta position amount
  27030. */
  27031. setDeltaPosition(position: Vector3): void;
  27032. /**
  27033. * Sets the delta rotation
  27034. * @param rotation The delta rotation amount
  27035. */
  27036. setDeltaRotation(rotation: Quaternion): void;
  27037. /**
  27038. * Gets the box size of the physics imposter and stores the result in the input parameter
  27039. * @param result Stores the box size
  27040. * @returns The physics imposter
  27041. */
  27042. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27043. /**
  27044. * Gets the radius of the physics imposter
  27045. * @returns Radius of the physics imposter
  27046. */
  27047. getRadius(): number;
  27048. /**
  27049. * Sync a bone with this impostor
  27050. * @param bone The bone to sync to the impostor.
  27051. * @param boneMesh The mesh that the bone is influencing.
  27052. * @param jointPivot The pivot of the joint / bone in local space.
  27053. * @param distToJoint Optional distance from the impostor to the joint.
  27054. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27055. */
  27056. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27057. /**
  27058. * Sync impostor to a bone
  27059. * @param bone The bone that the impostor will be synced to.
  27060. * @param boneMesh The mesh that the bone is influencing.
  27061. * @param jointPivot The pivot of the joint / bone in local space.
  27062. * @param distToJoint Optional distance from the impostor to the joint.
  27063. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27064. * @param boneAxis Optional vector3 axis the bone is aligned with
  27065. */
  27066. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27067. /**
  27068. * No-Imposter type
  27069. */
  27070. static NoImpostor: number;
  27071. /**
  27072. * Sphere-Imposter type
  27073. */
  27074. static SphereImpostor: number;
  27075. /**
  27076. * Box-Imposter type
  27077. */
  27078. static BoxImpostor: number;
  27079. /**
  27080. * Plane-Imposter type
  27081. */
  27082. static PlaneImpostor: number;
  27083. /**
  27084. * Mesh-imposter type
  27085. */
  27086. static MeshImpostor: number;
  27087. /**
  27088. * Capsule-Impostor type (Ammo.js plugin only)
  27089. */
  27090. static CapsuleImpostor: number;
  27091. /**
  27092. * Cylinder-Imposter type
  27093. */
  27094. static CylinderImpostor: number;
  27095. /**
  27096. * Particle-Imposter type
  27097. */
  27098. static ParticleImpostor: number;
  27099. /**
  27100. * Heightmap-Imposter type
  27101. */
  27102. static HeightmapImpostor: number;
  27103. /**
  27104. * ConvexHull-Impostor type (Ammo.js plugin only)
  27105. */
  27106. static ConvexHullImpostor: number;
  27107. /**
  27108. * Custom-Imposter type (Ammo.js plugin only)
  27109. */
  27110. static CustomImpostor: number;
  27111. /**
  27112. * Rope-Imposter type
  27113. */
  27114. static RopeImpostor: number;
  27115. /**
  27116. * Cloth-Imposter type
  27117. */
  27118. static ClothImpostor: number;
  27119. /**
  27120. * Softbody-Imposter type
  27121. */
  27122. static SoftbodyImpostor: number;
  27123. }
  27124. }
  27125. declare module BABYLON {
  27126. /**
  27127. * @hidden
  27128. **/
  27129. export class _CreationDataStorage {
  27130. closePath?: boolean;
  27131. closeArray?: boolean;
  27132. idx: number[];
  27133. dashSize: number;
  27134. gapSize: number;
  27135. path3D: Path3D;
  27136. pathArray: Vector3[][];
  27137. arc: number;
  27138. radius: number;
  27139. cap: number;
  27140. tessellation: number;
  27141. }
  27142. /**
  27143. * @hidden
  27144. **/
  27145. class _InstanceDataStorage {
  27146. visibleInstances: any;
  27147. batchCache: _InstancesBatch;
  27148. instancesBufferSize: number;
  27149. instancesBuffer: Nullable<Buffer>;
  27150. instancesData: Float32Array;
  27151. overridenInstanceCount: number;
  27152. isFrozen: boolean;
  27153. previousBatch: Nullable<_InstancesBatch>;
  27154. hardwareInstancedRendering: boolean;
  27155. sideOrientation: number;
  27156. manualUpdate: boolean;
  27157. }
  27158. /**
  27159. * @hidden
  27160. **/
  27161. export class _InstancesBatch {
  27162. mustReturn: boolean;
  27163. visibleInstances: Nullable<InstancedMesh[]>[];
  27164. renderSelf: boolean[];
  27165. hardwareInstancedRendering: boolean[];
  27166. }
  27167. /**
  27168. * @hidden
  27169. **/
  27170. class _ThinInstanceDataStorage {
  27171. instancesCount: number;
  27172. matrixBuffer: Nullable<Buffer>;
  27173. matrixBufferSize: number;
  27174. matrixData: Nullable<Float32Array>;
  27175. boundingVectors: Array<Vector3>;
  27176. }
  27177. /**
  27178. * Class used to represent renderable models
  27179. */
  27180. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27181. /**
  27182. * Mesh side orientation : usually the external or front surface
  27183. */
  27184. static readonly FRONTSIDE: number;
  27185. /**
  27186. * Mesh side orientation : usually the internal or back surface
  27187. */
  27188. static readonly BACKSIDE: number;
  27189. /**
  27190. * Mesh side orientation : both internal and external or front and back surfaces
  27191. */
  27192. static readonly DOUBLESIDE: number;
  27193. /**
  27194. * Mesh side orientation : by default, `FRONTSIDE`
  27195. */
  27196. static readonly DEFAULTSIDE: number;
  27197. /**
  27198. * Mesh cap setting : no cap
  27199. */
  27200. static readonly NO_CAP: number;
  27201. /**
  27202. * Mesh cap setting : one cap at the beginning of the mesh
  27203. */
  27204. static readonly CAP_START: number;
  27205. /**
  27206. * Mesh cap setting : one cap at the end of the mesh
  27207. */
  27208. static readonly CAP_END: number;
  27209. /**
  27210. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27211. */
  27212. static readonly CAP_ALL: number;
  27213. /**
  27214. * Mesh pattern setting : no flip or rotate
  27215. */
  27216. static readonly NO_FLIP: number;
  27217. /**
  27218. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27219. */
  27220. static readonly FLIP_TILE: number;
  27221. /**
  27222. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27223. */
  27224. static readonly ROTATE_TILE: number;
  27225. /**
  27226. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27227. */
  27228. static readonly FLIP_ROW: number;
  27229. /**
  27230. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27231. */
  27232. static readonly ROTATE_ROW: number;
  27233. /**
  27234. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27235. */
  27236. static readonly FLIP_N_ROTATE_TILE: number;
  27237. /**
  27238. * Mesh pattern setting : rotate pattern and rotate
  27239. */
  27240. static readonly FLIP_N_ROTATE_ROW: number;
  27241. /**
  27242. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27243. */
  27244. static readonly CENTER: number;
  27245. /**
  27246. * Mesh tile positioning : part tiles on left
  27247. */
  27248. static readonly LEFT: number;
  27249. /**
  27250. * Mesh tile positioning : part tiles on right
  27251. */
  27252. static readonly RIGHT: number;
  27253. /**
  27254. * Mesh tile positioning : part tiles on top
  27255. */
  27256. static readonly TOP: number;
  27257. /**
  27258. * Mesh tile positioning : part tiles on bottom
  27259. */
  27260. static readonly BOTTOM: number;
  27261. /**
  27262. * Gets the default side orientation.
  27263. * @param orientation the orientation to value to attempt to get
  27264. * @returns the default orientation
  27265. * @hidden
  27266. */
  27267. static _GetDefaultSideOrientation(orientation?: number): number;
  27268. private _internalMeshDataInfo;
  27269. /**
  27270. * An event triggered before rendering the mesh
  27271. */
  27272. get onBeforeRenderObservable(): Observable<Mesh>;
  27273. /**
  27274. * An event triggered before binding the mesh
  27275. */
  27276. get onBeforeBindObservable(): Observable<Mesh>;
  27277. /**
  27278. * An event triggered after rendering the mesh
  27279. */
  27280. get onAfterRenderObservable(): Observable<Mesh>;
  27281. /**
  27282. * An event triggered before drawing the mesh
  27283. */
  27284. get onBeforeDrawObservable(): Observable<Mesh>;
  27285. private _onBeforeDrawObserver;
  27286. /**
  27287. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27288. */
  27289. set onBeforeDraw(callback: () => void);
  27290. get hasInstances(): boolean;
  27291. get hasThinInstances(): boolean;
  27292. /**
  27293. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27294. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27295. */
  27296. delayLoadState: number;
  27297. /**
  27298. * Gets the list of instances created from this mesh
  27299. * it is not supposed to be modified manually.
  27300. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27301. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27302. */
  27303. instances: InstancedMesh[];
  27304. /**
  27305. * Gets the file containing delay loading data for this mesh
  27306. */
  27307. delayLoadingFile: string;
  27308. /** @hidden */
  27309. _binaryInfo: any;
  27310. /**
  27311. * User defined function used to change how LOD level selection is done
  27312. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27313. */
  27314. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27315. /**
  27316. * Gets or sets the morph target manager
  27317. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27318. */
  27319. get morphTargetManager(): Nullable<MorphTargetManager>;
  27320. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27321. /** @hidden */
  27322. _creationDataStorage: Nullable<_CreationDataStorage>;
  27323. /** @hidden */
  27324. _geometry: Nullable<Geometry>;
  27325. /** @hidden */
  27326. _delayInfo: Array<string>;
  27327. /** @hidden */
  27328. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27329. /** @hidden */
  27330. _instanceDataStorage: _InstanceDataStorage;
  27331. /** @hidden */
  27332. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27333. private _effectiveMaterial;
  27334. /** @hidden */
  27335. _shouldGenerateFlatShading: boolean;
  27336. /** @hidden */
  27337. _originalBuilderSideOrientation: number;
  27338. /**
  27339. * Use this property to change the original side orientation defined at construction time
  27340. */
  27341. overrideMaterialSideOrientation: Nullable<number>;
  27342. /**
  27343. * Gets the source mesh (the one used to clone this one from)
  27344. */
  27345. get source(): Nullable<Mesh>;
  27346. /**
  27347. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27348. */
  27349. get isUnIndexed(): boolean;
  27350. set isUnIndexed(value: boolean);
  27351. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27352. get worldMatrixInstancedBuffer(): Float32Array;
  27353. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27354. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27355. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27356. /**
  27357. * @constructor
  27358. * @param name The value used by scene.getMeshByName() to do a lookup.
  27359. * @param scene The scene to add this mesh to.
  27360. * @param parent The parent of this mesh, if it has one
  27361. * @param source An optional Mesh from which geometry is shared, cloned.
  27362. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27363. * When false, achieved by calling a clone(), also passing False.
  27364. * This will make creation of children, recursive.
  27365. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27366. */
  27367. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27368. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27369. doNotInstantiate: boolean;
  27370. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27371. /**
  27372. * Gets the class name
  27373. * @returns the string "Mesh".
  27374. */
  27375. getClassName(): string;
  27376. /** @hidden */
  27377. get _isMesh(): boolean;
  27378. /**
  27379. * Returns a description of this mesh
  27380. * @param fullDetails define if full details about this mesh must be used
  27381. * @returns a descriptive string representing this mesh
  27382. */
  27383. toString(fullDetails?: boolean): string;
  27384. /** @hidden */
  27385. _unBindEffect(): void;
  27386. /**
  27387. * Gets a boolean indicating if this mesh has LOD
  27388. */
  27389. get hasLODLevels(): boolean;
  27390. /**
  27391. * Gets the list of MeshLODLevel associated with the current mesh
  27392. * @returns an array of MeshLODLevel
  27393. */
  27394. getLODLevels(): MeshLODLevel[];
  27395. private _sortLODLevels;
  27396. /**
  27397. * Add a mesh as LOD level triggered at the given distance.
  27398. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27399. * @param distance The distance from the center of the object to show this level
  27400. * @param mesh The mesh to be added as LOD level (can be null)
  27401. * @return This mesh (for chaining)
  27402. */
  27403. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27404. /**
  27405. * Returns the LOD level mesh at the passed distance or null if not found.
  27406. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27407. * @param distance The distance from the center of the object to show this level
  27408. * @returns a Mesh or `null`
  27409. */
  27410. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27411. /**
  27412. * Remove a mesh from the LOD array
  27413. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27414. * @param mesh defines the mesh to be removed
  27415. * @return This mesh (for chaining)
  27416. */
  27417. removeLODLevel(mesh: Mesh): Mesh;
  27418. /**
  27419. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27421. * @param camera defines the camera to use to compute distance
  27422. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27423. * @return This mesh (for chaining)
  27424. */
  27425. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27426. /**
  27427. * Gets the mesh internal Geometry object
  27428. */
  27429. get geometry(): Nullable<Geometry>;
  27430. /**
  27431. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27432. * @returns the total number of vertices
  27433. */
  27434. getTotalVertices(): number;
  27435. /**
  27436. * Returns the content of an associated vertex buffer
  27437. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27438. * - VertexBuffer.PositionKind
  27439. * - VertexBuffer.UVKind
  27440. * - VertexBuffer.UV2Kind
  27441. * - VertexBuffer.UV3Kind
  27442. * - VertexBuffer.UV4Kind
  27443. * - VertexBuffer.UV5Kind
  27444. * - VertexBuffer.UV6Kind
  27445. * - VertexBuffer.ColorKind
  27446. * - VertexBuffer.MatricesIndicesKind
  27447. * - VertexBuffer.MatricesIndicesExtraKind
  27448. * - VertexBuffer.MatricesWeightsKind
  27449. * - VertexBuffer.MatricesWeightsExtraKind
  27450. * @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
  27451. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27452. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27453. */
  27454. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27455. /**
  27456. * Returns the mesh VertexBuffer object from the requested `kind`
  27457. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27458. * - VertexBuffer.PositionKind
  27459. * - VertexBuffer.NormalKind
  27460. * - VertexBuffer.UVKind
  27461. * - VertexBuffer.UV2Kind
  27462. * - VertexBuffer.UV3Kind
  27463. * - VertexBuffer.UV4Kind
  27464. * - VertexBuffer.UV5Kind
  27465. * - VertexBuffer.UV6Kind
  27466. * - VertexBuffer.ColorKind
  27467. * - VertexBuffer.MatricesIndicesKind
  27468. * - VertexBuffer.MatricesIndicesExtraKind
  27469. * - VertexBuffer.MatricesWeightsKind
  27470. * - VertexBuffer.MatricesWeightsExtraKind
  27471. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27472. */
  27473. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27474. /**
  27475. * Tests if a specific vertex buffer is associated with this mesh
  27476. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27477. * - VertexBuffer.PositionKind
  27478. * - VertexBuffer.NormalKind
  27479. * - VertexBuffer.UVKind
  27480. * - VertexBuffer.UV2Kind
  27481. * - VertexBuffer.UV3Kind
  27482. * - VertexBuffer.UV4Kind
  27483. * - VertexBuffer.UV5Kind
  27484. * - VertexBuffer.UV6Kind
  27485. * - VertexBuffer.ColorKind
  27486. * - VertexBuffer.MatricesIndicesKind
  27487. * - VertexBuffer.MatricesIndicesExtraKind
  27488. * - VertexBuffer.MatricesWeightsKind
  27489. * - VertexBuffer.MatricesWeightsExtraKind
  27490. * @returns a boolean
  27491. */
  27492. isVerticesDataPresent(kind: string): boolean;
  27493. /**
  27494. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27495. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27496. * - VertexBuffer.PositionKind
  27497. * - VertexBuffer.UVKind
  27498. * - VertexBuffer.UV2Kind
  27499. * - VertexBuffer.UV3Kind
  27500. * - VertexBuffer.UV4Kind
  27501. * - VertexBuffer.UV5Kind
  27502. * - VertexBuffer.UV6Kind
  27503. * - VertexBuffer.ColorKind
  27504. * - VertexBuffer.MatricesIndicesKind
  27505. * - VertexBuffer.MatricesIndicesExtraKind
  27506. * - VertexBuffer.MatricesWeightsKind
  27507. * - VertexBuffer.MatricesWeightsExtraKind
  27508. * @returns a boolean
  27509. */
  27510. isVertexBufferUpdatable(kind: string): boolean;
  27511. /**
  27512. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27513. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27514. * - VertexBuffer.PositionKind
  27515. * - VertexBuffer.NormalKind
  27516. * - VertexBuffer.UVKind
  27517. * - VertexBuffer.UV2Kind
  27518. * - VertexBuffer.UV3Kind
  27519. * - VertexBuffer.UV4Kind
  27520. * - VertexBuffer.UV5Kind
  27521. * - VertexBuffer.UV6Kind
  27522. * - VertexBuffer.ColorKind
  27523. * - VertexBuffer.MatricesIndicesKind
  27524. * - VertexBuffer.MatricesIndicesExtraKind
  27525. * - VertexBuffer.MatricesWeightsKind
  27526. * - VertexBuffer.MatricesWeightsExtraKind
  27527. * @returns an array of strings
  27528. */
  27529. getVerticesDataKinds(): string[];
  27530. /**
  27531. * Returns a positive integer : the total number of indices in this mesh geometry.
  27532. * @returns the numner of indices or zero if the mesh has no geometry.
  27533. */
  27534. getTotalIndices(): number;
  27535. /**
  27536. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27537. * @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.
  27538. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27539. * @returns the indices array or an empty array if the mesh has no geometry
  27540. */
  27541. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27542. get isBlocked(): boolean;
  27543. /**
  27544. * Determine if the current mesh is ready to be rendered
  27545. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27546. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27547. * @returns true if all associated assets are ready (material, textures, shaders)
  27548. */
  27549. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27550. /**
  27551. * 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.
  27552. */
  27553. get areNormalsFrozen(): boolean;
  27554. /**
  27555. * 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.
  27556. * @returns the current mesh
  27557. */
  27558. freezeNormals(): Mesh;
  27559. /**
  27560. * 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
  27561. * @returns the current mesh
  27562. */
  27563. unfreezeNormals(): Mesh;
  27564. /**
  27565. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27566. */
  27567. set overridenInstanceCount(count: number);
  27568. /** @hidden */
  27569. _preActivate(): Mesh;
  27570. /** @hidden */
  27571. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27572. /** @hidden */
  27573. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27574. protected _afterComputeWorldMatrix(): void;
  27575. /** @hidden */
  27576. _postActivate(): void;
  27577. /**
  27578. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27579. * This means the mesh underlying bounding box and sphere are recomputed.
  27580. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27581. * @returns the current mesh
  27582. */
  27583. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27584. /** @hidden */
  27585. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27586. /**
  27587. * This function will subdivide the mesh into multiple submeshes
  27588. * @param count defines the expected number of submeshes
  27589. */
  27590. subdivide(count: number): void;
  27591. /**
  27592. * Copy a FloatArray into a specific associated vertex buffer
  27593. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27594. * - VertexBuffer.PositionKind
  27595. * - VertexBuffer.UVKind
  27596. * - VertexBuffer.UV2Kind
  27597. * - VertexBuffer.UV3Kind
  27598. * - VertexBuffer.UV4Kind
  27599. * - VertexBuffer.UV5Kind
  27600. * - VertexBuffer.UV6Kind
  27601. * - VertexBuffer.ColorKind
  27602. * - VertexBuffer.MatricesIndicesKind
  27603. * - VertexBuffer.MatricesIndicesExtraKind
  27604. * - VertexBuffer.MatricesWeightsKind
  27605. * - VertexBuffer.MatricesWeightsExtraKind
  27606. * @param data defines the data source
  27607. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27608. * @param stride defines the data stride size (can be null)
  27609. * @returns the current mesh
  27610. */
  27611. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27612. /**
  27613. * Delete a vertex buffer associated with this mesh
  27614. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27615. * - VertexBuffer.PositionKind
  27616. * - VertexBuffer.UVKind
  27617. * - VertexBuffer.UV2Kind
  27618. * - VertexBuffer.UV3Kind
  27619. * - VertexBuffer.UV4Kind
  27620. * - VertexBuffer.UV5Kind
  27621. * - VertexBuffer.UV6Kind
  27622. * - VertexBuffer.ColorKind
  27623. * - VertexBuffer.MatricesIndicesKind
  27624. * - VertexBuffer.MatricesIndicesExtraKind
  27625. * - VertexBuffer.MatricesWeightsKind
  27626. * - VertexBuffer.MatricesWeightsExtraKind
  27627. */
  27628. removeVerticesData(kind: string): void;
  27629. /**
  27630. * Flags an associated vertex buffer as updatable
  27631. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27632. * - VertexBuffer.PositionKind
  27633. * - VertexBuffer.UVKind
  27634. * - VertexBuffer.UV2Kind
  27635. * - VertexBuffer.UV3Kind
  27636. * - VertexBuffer.UV4Kind
  27637. * - VertexBuffer.UV5Kind
  27638. * - VertexBuffer.UV6Kind
  27639. * - VertexBuffer.ColorKind
  27640. * - VertexBuffer.MatricesIndicesKind
  27641. * - VertexBuffer.MatricesIndicesExtraKind
  27642. * - VertexBuffer.MatricesWeightsKind
  27643. * - VertexBuffer.MatricesWeightsExtraKind
  27644. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27645. */
  27646. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27647. /**
  27648. * Sets the mesh global Vertex Buffer
  27649. * @param buffer defines the buffer to use
  27650. * @returns the current mesh
  27651. */
  27652. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27653. /**
  27654. * Update a specific associated vertex buffer
  27655. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27656. * - VertexBuffer.PositionKind
  27657. * - VertexBuffer.UVKind
  27658. * - VertexBuffer.UV2Kind
  27659. * - VertexBuffer.UV3Kind
  27660. * - VertexBuffer.UV4Kind
  27661. * - VertexBuffer.UV5Kind
  27662. * - VertexBuffer.UV6Kind
  27663. * - VertexBuffer.ColorKind
  27664. * - VertexBuffer.MatricesIndicesKind
  27665. * - VertexBuffer.MatricesIndicesExtraKind
  27666. * - VertexBuffer.MatricesWeightsKind
  27667. * - VertexBuffer.MatricesWeightsExtraKind
  27668. * @param data defines the data source
  27669. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27670. * @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)
  27671. * @returns the current mesh
  27672. */
  27673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27674. /**
  27675. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27676. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27677. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27678. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27679. * @returns the current mesh
  27680. */
  27681. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27682. /**
  27683. * Creates a un-shared specific occurence of the geometry for the mesh.
  27684. * @returns the current mesh
  27685. */
  27686. makeGeometryUnique(): Mesh;
  27687. /**
  27688. * Set the index buffer of this mesh
  27689. * @param indices defines the source data
  27690. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27691. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27692. * @returns the current mesh
  27693. */
  27694. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27695. /**
  27696. * Update the current index buffer
  27697. * @param indices defines the source data
  27698. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27699. * @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)
  27700. * @returns the current mesh
  27701. */
  27702. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27703. /**
  27704. * Invert the geometry to move from a right handed system to a left handed one.
  27705. * @returns the current mesh
  27706. */
  27707. toLeftHanded(): Mesh;
  27708. /** @hidden */
  27709. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27710. /** @hidden */
  27711. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27712. /**
  27713. * Registers for this mesh a javascript function called just before the rendering process
  27714. * @param func defines the function to call before rendering this mesh
  27715. * @returns the current mesh
  27716. */
  27717. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27718. /**
  27719. * Disposes a previously registered javascript function called before the rendering
  27720. * @param func defines the function to remove
  27721. * @returns the current mesh
  27722. */
  27723. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27724. /**
  27725. * Registers for this mesh a javascript function called just after the rendering is complete
  27726. * @param func defines the function to call after rendering this mesh
  27727. * @returns the current mesh
  27728. */
  27729. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27730. /**
  27731. * Disposes a previously registered javascript function called after the rendering.
  27732. * @param func defines the function to remove
  27733. * @returns the current mesh
  27734. */
  27735. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27736. /** @hidden */
  27737. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27738. /** @hidden */
  27739. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27740. /** @hidden */
  27741. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27742. /** @hidden */
  27743. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27744. /** @hidden */
  27745. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27746. /** @hidden */
  27747. _rebuild(): void;
  27748. /** @hidden */
  27749. _freeze(): void;
  27750. /** @hidden */
  27751. _unFreeze(): void;
  27752. /**
  27753. * 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
  27754. * @param subMesh defines the subMesh to render
  27755. * @param enableAlphaMode defines if alpha mode can be changed
  27756. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27757. * @returns the current mesh
  27758. */
  27759. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27760. private _onBeforeDraw;
  27761. /**
  27762. * Renormalize the mesh and patch it up if there are no weights
  27763. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27764. * However in the case of zero weights then we set just a single influence to 1.
  27765. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27766. */
  27767. cleanMatrixWeights(): void;
  27768. private normalizeSkinFourWeights;
  27769. private normalizeSkinWeightsAndExtra;
  27770. /**
  27771. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27772. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27773. * the user know there was an issue with importing the mesh
  27774. * @returns a validation object with skinned, valid and report string
  27775. */
  27776. validateSkinning(): {
  27777. skinned: boolean;
  27778. valid: boolean;
  27779. report: string;
  27780. };
  27781. /** @hidden */
  27782. _checkDelayState(): Mesh;
  27783. private _queueLoad;
  27784. /**
  27785. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27786. * A mesh is in the frustum if its bounding box intersects the frustum
  27787. * @param frustumPlanes defines the frustum to test
  27788. * @returns true if the mesh is in the frustum planes
  27789. */
  27790. isInFrustum(frustumPlanes: Plane[]): boolean;
  27791. /**
  27792. * Sets the mesh material by the material or multiMaterial `id` property
  27793. * @param id is a string identifying the material or the multiMaterial
  27794. * @returns the current mesh
  27795. */
  27796. setMaterialByID(id: string): Mesh;
  27797. /**
  27798. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27799. * @returns an array of IAnimatable
  27800. */
  27801. getAnimatables(): IAnimatable[];
  27802. /**
  27803. * Modifies the mesh geometry according to the passed transformation matrix.
  27804. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27805. * The mesh normals are modified using the same transformation.
  27806. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27807. * @param transform defines the transform matrix to use
  27808. * @see https://doc.babylonjs.com/resources/baking_transformations
  27809. * @returns the current mesh
  27810. */
  27811. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27812. /**
  27813. * Modifies the mesh geometry according to its own current World Matrix.
  27814. * The mesh World Matrix is then reset.
  27815. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27816. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27817. * @see https://doc.babylonjs.com/resources/baking_transformations
  27818. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27819. * @returns the current mesh
  27820. */
  27821. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27822. /** @hidden */
  27823. get _positions(): Nullable<Vector3[]>;
  27824. /** @hidden */
  27825. _resetPointsArrayCache(): Mesh;
  27826. /** @hidden */
  27827. _generatePointsArray(): boolean;
  27828. /**
  27829. * Returns a new Mesh object generated from the current mesh properties.
  27830. * This method must not get confused with createInstance()
  27831. * @param name is a string, the name given to the new mesh
  27832. * @param newParent can be any Node object (default `null`)
  27833. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27834. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27835. * @returns a new mesh
  27836. */
  27837. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27838. /**
  27839. * Releases resources associated with this mesh.
  27840. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27841. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27842. */
  27843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27844. /** @hidden */
  27845. _disposeInstanceSpecificData(): void;
  27846. /** @hidden */
  27847. _disposeThinInstanceSpecificData(): void;
  27848. /**
  27849. * Modifies the mesh geometry according to a displacement map.
  27850. * 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.
  27851. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27852. * @param url is a string, the URL from the image file is to be downloaded.
  27853. * @param minHeight is the lower limit of the displacement.
  27854. * @param maxHeight is the upper limit of the displacement.
  27855. * @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.
  27856. * @param uvOffset is an optional vector2 used to offset UV.
  27857. * @param uvScale is an optional vector2 used to scale UV.
  27858. * @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.
  27859. * @returns the Mesh.
  27860. */
  27861. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27862. /**
  27863. * Modifies the mesh geometry according to a displacementMap buffer.
  27864. * 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.
  27865. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27866. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27867. * @param heightMapWidth is the width of the buffer image.
  27868. * @param heightMapHeight is the height of the buffer image.
  27869. * @param minHeight is the lower limit of the displacement.
  27870. * @param maxHeight is the upper limit of the displacement.
  27871. * @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.
  27872. * @param uvOffset is an optional vector2 used to offset UV.
  27873. * @param uvScale is an optional vector2 used to scale UV.
  27874. * @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.
  27875. * @returns the Mesh.
  27876. */
  27877. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27878. /**
  27879. * Modify the mesh to get a flat shading rendering.
  27880. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27881. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27882. * @returns current mesh
  27883. */
  27884. convertToFlatShadedMesh(): Mesh;
  27885. /**
  27886. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27887. * In other words, more vertices, no more indices and a single bigger VBO.
  27888. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27889. * @returns current mesh
  27890. */
  27891. convertToUnIndexedMesh(): Mesh;
  27892. /**
  27893. * Inverses facet orientations.
  27894. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27895. * @param flipNormals will also inverts the normals
  27896. * @returns current mesh
  27897. */
  27898. flipFaces(flipNormals?: boolean): Mesh;
  27899. /**
  27900. * Increase the number of facets and hence vertices in a mesh
  27901. * Vertex normals are interpolated from existing vertex normals
  27902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27903. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27904. */
  27905. increaseVertices(numberPerEdge: number): void;
  27906. /**
  27907. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27908. * This will undo any application of covertToFlatShadedMesh
  27909. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27910. */
  27911. forceSharedVertices(): void;
  27912. /** @hidden */
  27913. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27914. /** @hidden */
  27915. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27916. /**
  27917. * Creates a new InstancedMesh object from the mesh model.
  27918. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27919. * @param name defines the name of the new instance
  27920. * @returns a new InstancedMesh
  27921. */
  27922. createInstance(name: string): InstancedMesh;
  27923. /**
  27924. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27925. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27926. * @returns the current mesh
  27927. */
  27928. synchronizeInstances(): Mesh;
  27929. /**
  27930. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27931. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27932. * This should be used together with the simplification to avoid disappearing triangles.
  27933. * @param successCallback an optional success callback to be called after the optimization finished.
  27934. * @returns the current mesh
  27935. */
  27936. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27937. /**
  27938. * Serialize current mesh
  27939. * @param serializationObject defines the object which will receive the serialization data
  27940. */
  27941. serialize(serializationObject: any): void;
  27942. /** @hidden */
  27943. _syncGeometryWithMorphTargetManager(): void;
  27944. /** @hidden */
  27945. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27946. /**
  27947. * Returns a new Mesh object parsed from the source provided.
  27948. * @param parsedMesh is the source
  27949. * @param scene defines the hosting scene
  27950. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27951. * @returns a new Mesh
  27952. */
  27953. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27954. /**
  27955. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  27957. * @param name defines the name of the mesh to create
  27958. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27959. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27960. * @param closePath creates a seam between the first and the last points of each path of the path array
  27961. * @param offset is taken in account only if the `pathArray` is containing a single path
  27962. * @param scene defines the hosting scene
  27963. * @param updatable defines if the mesh must be flagged as updatable
  27964. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27965. * @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)
  27966. * @returns a new Mesh
  27967. */
  27968. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27969. /**
  27970. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27971. * @param name defines the name of the mesh to create
  27972. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27973. * @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
  27974. * @param scene defines the hosting scene
  27975. * @param updatable defines if the mesh must be flagged as updatable
  27976. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27977. * @returns a new Mesh
  27978. */
  27979. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27980. /**
  27981. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27982. * @param name defines the name of the mesh to create
  27983. * @param size sets the size (float) of each box side (default 1)
  27984. * @param scene defines the hosting scene
  27985. * @param updatable defines if the mesh must be flagged as updatable
  27986. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27987. * @returns a new Mesh
  27988. */
  27989. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27990. /**
  27991. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27992. * @param name defines the name of the mesh to create
  27993. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27994. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27995. * @param scene defines the hosting scene
  27996. * @param updatable defines if the mesh must be flagged as updatable
  27997. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27998. * @returns a new Mesh
  27999. */
  28000. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28001. /**
  28002. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28003. * @param name defines the name of the mesh to create
  28004. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28005. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28006. * @param scene defines the hosting scene
  28007. * @returns a new Mesh
  28008. */
  28009. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28010. /**
  28011. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28012. * @param name defines the name of the mesh to create
  28013. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28014. * @param diameterTop set the top cap diameter (floats, default 1)
  28015. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28016. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28017. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28018. * @param scene defines the hosting scene
  28019. * @param updatable defines if the mesh must be flagged as updatable
  28020. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28021. * @returns a new Mesh
  28022. */
  28023. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28024. /**
  28025. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28026. * @param name defines the name of the mesh to create
  28027. * @param diameter sets the diameter size (float) of the torus (default 1)
  28028. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28029. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28030. * @param scene defines the hosting scene
  28031. * @param updatable defines if the mesh must be flagged as updatable
  28032. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28033. * @returns a new Mesh
  28034. */
  28035. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28036. /**
  28037. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28038. * @param name defines the name of the mesh to create
  28039. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28040. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28041. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28042. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28043. * @param p the number of windings on X axis (positive integers, default 2)
  28044. * @param q the number of windings on Y axis (positive integers, default 3)
  28045. * @param scene defines the hosting scene
  28046. * @param updatable defines if the mesh must be flagged as updatable
  28047. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28048. * @returns a new Mesh
  28049. */
  28050. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28051. /**
  28052. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28053. * @param name defines the name of the mesh to create
  28054. * @param points is an array successive Vector3
  28055. * @param scene defines the hosting scene
  28056. * @param updatable defines if the mesh must be flagged as updatable
  28057. * @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).
  28058. * @returns a new Mesh
  28059. */
  28060. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28061. /**
  28062. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28063. * @param name defines the name of the mesh to create
  28064. * @param points is an array successive Vector3
  28065. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28066. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28067. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28068. * @param scene defines the hosting scene
  28069. * @param updatable defines if the mesh must be flagged as updatable
  28070. * @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)
  28071. * @returns a new Mesh
  28072. */
  28073. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28074. /**
  28075. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28076. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28077. * 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.
  28078. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28079. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28080. * Remember you can only change the shape positions, not their number when updating a polygon.
  28081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28082. * @param name defines the name of the mesh to create
  28083. * @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
  28084. * @param scene defines the hosting scene
  28085. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28086. * @param updatable defines if the mesh must be flagged as updatable
  28087. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28088. * @param earcutInjection can be used to inject your own earcut reference
  28089. * @returns a new Mesh
  28090. */
  28091. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28092. /**
  28093. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28095. * @param name defines the name of the mesh to create
  28096. * @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
  28097. * @param depth defines the height of extrusion
  28098. * @param scene defines the hosting scene
  28099. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28100. * @param updatable defines if the mesh must be flagged as updatable
  28101. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28102. * @param earcutInjection can be used to inject your own earcut reference
  28103. * @returns a new Mesh
  28104. */
  28105. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28106. /**
  28107. * Creates an extruded shape mesh.
  28108. * 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
  28109. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28111. * @param name defines the name of the mesh to create
  28112. * @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
  28113. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28114. * @param scale is the value to scale the shape
  28115. * @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
  28116. * @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
  28117. * @param scene defines the hosting scene
  28118. * @param updatable defines if the mesh must be flagged as updatable
  28119. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28120. * @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)
  28121. * @returns a new Mesh
  28122. */
  28123. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28124. /**
  28125. * Creates an custom extruded shape mesh.
  28126. * The custom extrusion is a parametric shape.
  28127. * It has no predefined shape. Its final shape will depend on the input parameters.
  28128. * Please consider using the same method from the MeshBuilder class instead
  28129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28130. * @param name defines the name of the mesh to create
  28131. * @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
  28132. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28133. * @param scaleFunction is a custom Javascript function called on each path point
  28134. * @param rotationFunction is a custom Javascript function called on each path point
  28135. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28136. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28137. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  28138. * @param scene defines the hosting scene
  28139. * @param updatable defines if the mesh must be flagged as updatable
  28140. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28141. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  28142. * @returns a new Mesh
  28143. */
  28144. static 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;
  28145. /**
  28146. * Creates lathe mesh.
  28147. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28148. * Please consider using the same method from the MeshBuilder class instead
  28149. * @param name defines the name of the mesh to create
  28150. * @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
  28151. * @param radius is the radius value of the lathe
  28152. * @param tessellation is the side number of the lathe.
  28153. * @param scene defines the hosting scene
  28154. * @param updatable defines if the mesh must be flagged as updatable
  28155. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28156. * @returns a new Mesh
  28157. */
  28158. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28159. /**
  28160. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28161. * @param name defines the name of the mesh to create
  28162. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28163. * @param scene defines the hosting scene
  28164. * @param updatable defines if the mesh must be flagged as updatable
  28165. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28166. * @returns a new Mesh
  28167. */
  28168. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28169. /**
  28170. * Creates a ground mesh.
  28171. * Please consider using the same method from the MeshBuilder class instead
  28172. * @param name defines the name of the mesh to create
  28173. * @param width set the width of the ground
  28174. * @param height set the height of the ground
  28175. * @param subdivisions sets the number of subdivisions per side
  28176. * @param scene defines the hosting scene
  28177. * @param updatable defines if the mesh must be flagged as updatable
  28178. * @returns a new Mesh
  28179. */
  28180. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28181. /**
  28182. * Creates a tiled ground mesh.
  28183. * Please consider using the same method from the MeshBuilder class instead
  28184. * @param name defines the name of the mesh to create
  28185. * @param xmin set the ground minimum X coordinate
  28186. * @param zmin set the ground minimum Y coordinate
  28187. * @param xmax set the ground maximum X coordinate
  28188. * @param zmax set the ground maximum Z coordinate
  28189. * @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
  28190. * @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
  28191. * @param scene defines the hosting scene
  28192. * @param updatable defines if the mesh must be flagged as updatable
  28193. * @returns a new Mesh
  28194. */
  28195. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28196. w: number;
  28197. h: number;
  28198. }, precision: {
  28199. w: number;
  28200. h: number;
  28201. }, scene: Scene, updatable?: boolean): Mesh;
  28202. /**
  28203. * Creates a ground mesh from a height map.
  28204. * Please consider using the same method from the MeshBuilder class instead
  28205. * @see https://doc.babylonjs.com/babylon101/height_map
  28206. * @param name defines the name of the mesh to create
  28207. * @param url sets the URL of the height map image resource
  28208. * @param width set the ground width size
  28209. * @param height set the ground height size
  28210. * @param subdivisions sets the number of subdivision per side
  28211. * @param minHeight is the minimum altitude on the ground
  28212. * @param maxHeight is the maximum altitude on the ground
  28213. * @param scene defines the hosting scene
  28214. * @param updatable defines if the mesh must be flagged as updatable
  28215. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28216. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28217. * @returns a new Mesh
  28218. */
  28219. 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;
  28220. /**
  28221. * Creates a tube mesh.
  28222. * The tube is a parametric shape.
  28223. * It has no predefined shape. Its final shape will depend on the input parameters.
  28224. * Please consider using the same method from the MeshBuilder class instead
  28225. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28226. * @param name defines the name of the mesh to create
  28227. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28228. * @param radius sets the tube radius size
  28229. * @param tessellation is the number of sides on the tubular surface
  28230. * @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
  28231. * @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
  28232. * @param scene defines the hosting scene
  28233. * @param updatable defines if the mesh must be flagged as updatable
  28234. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28235. * @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)
  28236. * @returns a new Mesh
  28237. */
  28238. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28239. (i: number, distance: number): number;
  28240. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28241. /**
  28242. * Creates a polyhedron mesh.
  28243. * Please consider using the same method from the MeshBuilder class instead.
  28244. * * 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
  28245. * * The parameter `size` (positive float, default 1) sets the polygon size
  28246. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28247. * * 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`
  28248. * * 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
  28249. * * 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)`)
  28250. * * 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
  28251. * * 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
  28252. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28253. * * 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
  28254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28255. * @param name defines the name of the mesh to create
  28256. * @param options defines the options used to create the mesh
  28257. * @param scene defines the hosting scene
  28258. * @returns a new Mesh
  28259. */
  28260. static CreatePolyhedron(name: string, options: {
  28261. type?: number;
  28262. size?: number;
  28263. sizeX?: number;
  28264. sizeY?: number;
  28265. sizeZ?: number;
  28266. custom?: any;
  28267. faceUV?: Vector4[];
  28268. faceColors?: Color4[];
  28269. updatable?: boolean;
  28270. sideOrientation?: number;
  28271. }, scene: Scene): Mesh;
  28272. /**
  28273. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28274. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28275. * * 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`)
  28276. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28277. * * 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
  28278. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28279. * * 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
  28280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28281. * @param name defines the name of the mesh
  28282. * @param options defines the options used to create the mesh
  28283. * @param scene defines the hosting scene
  28284. * @returns a new Mesh
  28285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28286. */
  28287. static CreateIcoSphere(name: string, options: {
  28288. radius?: number;
  28289. flat?: boolean;
  28290. subdivisions?: number;
  28291. sideOrientation?: number;
  28292. updatable?: boolean;
  28293. }, scene: Scene): Mesh;
  28294. /**
  28295. * Creates a decal mesh.
  28296. * Please consider using the same method from the MeshBuilder class instead.
  28297. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28298. * @param name defines the name of the mesh
  28299. * @param sourceMesh defines the mesh receiving the decal
  28300. * @param position sets the position of the decal in world coordinates
  28301. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28302. * @param size sets the decal scaling
  28303. * @param angle sets the angle to rotate the decal
  28304. * @returns a new Mesh
  28305. */
  28306. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28307. /**
  28308. * Prepare internal position array for software CPU skinning
  28309. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28310. */
  28311. setPositionsForCPUSkinning(): Float32Array;
  28312. /**
  28313. * Prepare internal normal array for software CPU skinning
  28314. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28315. */
  28316. setNormalsForCPUSkinning(): Float32Array;
  28317. /**
  28318. * Updates the vertex buffer by applying transformation from the bones
  28319. * @param skeleton defines the skeleton to apply to current mesh
  28320. * @returns the current mesh
  28321. */
  28322. applySkeleton(skeleton: Skeleton): Mesh;
  28323. /**
  28324. * 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
  28325. * @param meshes defines the list of meshes to scan
  28326. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28327. */
  28328. static MinMax(meshes: AbstractMesh[]): {
  28329. min: Vector3;
  28330. max: Vector3;
  28331. };
  28332. /**
  28333. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28334. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28335. * @returns a vector3
  28336. */
  28337. static Center(meshesOrMinMaxVector: {
  28338. min: Vector3;
  28339. max: Vector3;
  28340. } | AbstractMesh[]): Vector3;
  28341. /**
  28342. * Merge the array of meshes into a single mesh for performance reasons.
  28343. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28344. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28345. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28346. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28347. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28348. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28349. * @returns a new mesh
  28350. */
  28351. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28352. /** @hidden */
  28353. addInstance(instance: InstancedMesh): void;
  28354. /** @hidden */
  28355. removeInstance(instance: InstancedMesh): void;
  28356. }
  28357. }
  28358. declare module BABYLON {
  28359. /**
  28360. * This is the base class of all the camera used in the application.
  28361. * @see https://doc.babylonjs.com/features/cameras
  28362. */
  28363. export class Camera extends Node {
  28364. /** @hidden */
  28365. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28366. /**
  28367. * This is the default projection mode used by the cameras.
  28368. * It helps recreating a feeling of perspective and better appreciate depth.
  28369. * This is the best way to simulate real life cameras.
  28370. */
  28371. static readonly PERSPECTIVE_CAMERA: number;
  28372. /**
  28373. * This helps creating camera with an orthographic mode.
  28374. * 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.
  28375. */
  28376. static readonly ORTHOGRAPHIC_CAMERA: number;
  28377. /**
  28378. * This is the default FOV mode for perspective cameras.
  28379. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28380. */
  28381. static readonly FOVMODE_VERTICAL_FIXED: number;
  28382. /**
  28383. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28384. */
  28385. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28386. /**
  28387. * This specifies ther is no need for a camera rig.
  28388. * Basically only one eye is rendered corresponding to the camera.
  28389. */
  28390. static readonly RIG_MODE_NONE: number;
  28391. /**
  28392. * Simulates a camera Rig with one blue eye and one red eye.
  28393. * This can be use with 3d blue and red glasses.
  28394. */
  28395. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28396. /**
  28397. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28398. */
  28399. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28400. /**
  28401. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28402. */
  28403. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28404. /**
  28405. * Defines that both eyes of the camera will be rendered over under each other.
  28406. */
  28407. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28408. /**
  28409. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28410. */
  28411. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28412. /**
  28413. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28414. */
  28415. static readonly RIG_MODE_VR: number;
  28416. /**
  28417. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28418. */
  28419. static readonly RIG_MODE_WEBVR: number;
  28420. /**
  28421. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28422. */
  28423. static readonly RIG_MODE_CUSTOM: number;
  28424. /**
  28425. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28426. */
  28427. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28428. /**
  28429. * Define the input manager associated with the camera.
  28430. */
  28431. inputs: CameraInputsManager<Camera>;
  28432. /** @hidden */
  28433. _position: Vector3;
  28434. /**
  28435. * Define the current local position of the camera in the scene
  28436. */
  28437. get position(): Vector3;
  28438. set position(newPosition: Vector3);
  28439. /**
  28440. * The vector the camera should consider as up.
  28441. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28442. */
  28443. upVector: Vector3;
  28444. /**
  28445. * Define the current limit on the left side for an orthographic camera
  28446. * In scene unit
  28447. */
  28448. orthoLeft: Nullable<number>;
  28449. /**
  28450. * Define the current limit on the right side for an orthographic camera
  28451. * In scene unit
  28452. */
  28453. orthoRight: Nullable<number>;
  28454. /**
  28455. * Define the current limit on the bottom side for an orthographic camera
  28456. * In scene unit
  28457. */
  28458. orthoBottom: Nullable<number>;
  28459. /**
  28460. * Define the current limit on the top side for an orthographic camera
  28461. * In scene unit
  28462. */
  28463. orthoTop: Nullable<number>;
  28464. /**
  28465. * Field Of View is set in Radians. (default is 0.8)
  28466. */
  28467. fov: number;
  28468. /**
  28469. * Define the minimum distance the camera can see from.
  28470. * This is important to note that the depth buffer are not infinite and the closer it starts
  28471. * the more your scene might encounter depth fighting issue.
  28472. */
  28473. minZ: number;
  28474. /**
  28475. * Define the maximum distance the camera can see to.
  28476. * This is important to note that the depth buffer are not infinite and the further it end
  28477. * the more your scene might encounter depth fighting issue.
  28478. */
  28479. maxZ: number;
  28480. /**
  28481. * Define the default inertia of the camera.
  28482. * This helps giving a smooth feeling to the camera movement.
  28483. */
  28484. inertia: number;
  28485. /**
  28486. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28487. */
  28488. mode: number;
  28489. /**
  28490. * Define whether the camera is intermediate.
  28491. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28492. */
  28493. isIntermediate: boolean;
  28494. /**
  28495. * Define the viewport of the camera.
  28496. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28497. */
  28498. viewport: Viewport;
  28499. /**
  28500. * Restricts the camera to viewing objects with the same layerMask.
  28501. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28502. */
  28503. layerMask: number;
  28504. /**
  28505. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28506. */
  28507. fovMode: number;
  28508. /**
  28509. * Rig mode of the camera.
  28510. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28511. * This is normally controlled byt the camera themselves as internal use.
  28512. */
  28513. cameraRigMode: number;
  28514. /**
  28515. * Defines the distance between both "eyes" in case of a RIG
  28516. */
  28517. interaxialDistance: number;
  28518. /**
  28519. * Defines if stereoscopic rendering is done side by side or over under.
  28520. */
  28521. isStereoscopicSideBySide: boolean;
  28522. /**
  28523. * 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
  28524. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28525. * else in the scene. (Eg. security camera)
  28526. *
  28527. * 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)
  28528. */
  28529. customRenderTargets: RenderTargetTexture[];
  28530. /**
  28531. * When set, the camera will render to this render target instead of the default canvas
  28532. *
  28533. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28534. */
  28535. outputRenderTarget: Nullable<RenderTargetTexture>;
  28536. /**
  28537. * Observable triggered when the camera view matrix has changed.
  28538. */
  28539. onViewMatrixChangedObservable: Observable<Camera>;
  28540. /**
  28541. * Observable triggered when the camera Projection matrix has changed.
  28542. */
  28543. onProjectionMatrixChangedObservable: Observable<Camera>;
  28544. /**
  28545. * Observable triggered when the inputs have been processed.
  28546. */
  28547. onAfterCheckInputsObservable: Observable<Camera>;
  28548. /**
  28549. * Observable triggered when reset has been called and applied to the camera.
  28550. */
  28551. onRestoreStateObservable: Observable<Camera>;
  28552. /**
  28553. * Is this camera a part of a rig system?
  28554. */
  28555. isRigCamera: boolean;
  28556. /**
  28557. * If isRigCamera set to true this will be set with the parent camera.
  28558. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28559. */
  28560. rigParent?: Camera;
  28561. /** @hidden */
  28562. _cameraRigParams: any;
  28563. /** @hidden */
  28564. _rigCameras: Camera[];
  28565. /** @hidden */
  28566. _rigPostProcess: Nullable<PostProcess>;
  28567. protected _webvrViewMatrix: Matrix;
  28568. /** @hidden */
  28569. _skipRendering: boolean;
  28570. /** @hidden */
  28571. _projectionMatrix: Matrix;
  28572. /** @hidden */
  28573. _postProcesses: Nullable<PostProcess>[];
  28574. /** @hidden */
  28575. _activeMeshes: SmartArray<AbstractMesh>;
  28576. protected _globalPosition: Vector3;
  28577. /** @hidden */
  28578. _computedViewMatrix: Matrix;
  28579. private _doNotComputeProjectionMatrix;
  28580. private _transformMatrix;
  28581. private _frustumPlanes;
  28582. private _refreshFrustumPlanes;
  28583. private _storedFov;
  28584. private _stateStored;
  28585. /**
  28586. * Instantiates a new camera object.
  28587. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28588. * @see https://doc.babylonjs.com/features/cameras
  28589. * @param name Defines the name of the camera in the scene
  28590. * @param position Defines the position of the camera
  28591. * @param scene Defines the scene the camera belongs too
  28592. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28593. */
  28594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28595. /**
  28596. * Store current camera state (fov, position, etc..)
  28597. * @returns the camera
  28598. */
  28599. storeState(): Camera;
  28600. /**
  28601. * Restores the camera state values if it has been stored. You must call storeState() first
  28602. */
  28603. protected _restoreStateValues(): boolean;
  28604. /**
  28605. * Restored camera state. You must call storeState() first.
  28606. * @returns true if restored and false otherwise
  28607. */
  28608. restoreState(): boolean;
  28609. /**
  28610. * Gets the class name of the camera.
  28611. * @returns the class name
  28612. */
  28613. getClassName(): string;
  28614. /** @hidden */
  28615. readonly _isCamera: boolean;
  28616. /**
  28617. * Gets a string representation of the camera useful for debug purpose.
  28618. * @param fullDetails Defines that a more verboe level of logging is required
  28619. * @returns the string representation
  28620. */
  28621. toString(fullDetails?: boolean): string;
  28622. /**
  28623. * Gets the current world space position of the camera.
  28624. */
  28625. get globalPosition(): Vector3;
  28626. /**
  28627. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28628. * @returns the active meshe list
  28629. */
  28630. getActiveMeshes(): SmartArray<AbstractMesh>;
  28631. /**
  28632. * Check whether a mesh is part of the current active mesh list of the camera
  28633. * @param mesh Defines the mesh to check
  28634. * @returns true if active, false otherwise
  28635. */
  28636. isActiveMesh(mesh: Mesh): boolean;
  28637. /**
  28638. * Is this camera ready to be used/rendered
  28639. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28640. * @return true if the camera is ready
  28641. */
  28642. isReady(completeCheck?: boolean): boolean;
  28643. /** @hidden */
  28644. _initCache(): void;
  28645. /** @hidden */
  28646. _updateCache(ignoreParentClass?: boolean): void;
  28647. /** @hidden */
  28648. _isSynchronized(): boolean;
  28649. /** @hidden */
  28650. _isSynchronizedViewMatrix(): boolean;
  28651. /** @hidden */
  28652. _isSynchronizedProjectionMatrix(): boolean;
  28653. /**
  28654. * Attach the input controls to a specific dom element to get the input from.
  28655. * @param element Defines the element the controls should be listened from
  28656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28657. */
  28658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28659. /**
  28660. * Detach the current controls from the specified dom element.
  28661. * @param element Defines the element to stop listening the inputs from
  28662. */
  28663. detachControl(element: HTMLElement): void;
  28664. /**
  28665. * Update the camera state according to the different inputs gathered during the frame.
  28666. */
  28667. update(): void;
  28668. /** @hidden */
  28669. _checkInputs(): void;
  28670. /** @hidden */
  28671. get rigCameras(): Camera[];
  28672. /**
  28673. * Gets the post process used by the rig cameras
  28674. */
  28675. get rigPostProcess(): Nullable<PostProcess>;
  28676. /**
  28677. * Internal, gets the first post proces.
  28678. * @returns the first post process to be run on this camera.
  28679. */
  28680. _getFirstPostProcess(): Nullable<PostProcess>;
  28681. private _cascadePostProcessesToRigCams;
  28682. /**
  28683. * Attach a post process to the camera.
  28684. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28685. * @param postProcess The post process to attach to the camera
  28686. * @param insertAt The position of the post process in case several of them are in use in the scene
  28687. * @returns the position the post process has been inserted at
  28688. */
  28689. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28690. /**
  28691. * Detach a post process to the camera.
  28692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28693. * @param postProcess The post process to detach from the camera
  28694. */
  28695. detachPostProcess(postProcess: PostProcess): void;
  28696. /**
  28697. * Gets the current world matrix of the camera
  28698. */
  28699. getWorldMatrix(): Matrix;
  28700. /** @hidden */
  28701. _getViewMatrix(): Matrix;
  28702. /**
  28703. * Gets the current view matrix of the camera.
  28704. * @param force forces the camera to recompute the matrix without looking at the cached state
  28705. * @returns the view matrix
  28706. */
  28707. getViewMatrix(force?: boolean): Matrix;
  28708. /**
  28709. * Freeze the projection matrix.
  28710. * It will prevent the cache check of the camera projection compute and can speed up perf
  28711. * if no parameter of the camera are meant to change
  28712. * @param projection Defines manually a projection if necessary
  28713. */
  28714. freezeProjectionMatrix(projection?: Matrix): void;
  28715. /**
  28716. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28717. */
  28718. unfreezeProjectionMatrix(): void;
  28719. /**
  28720. * Gets the current projection matrix of the camera.
  28721. * @param force forces the camera to recompute the matrix without looking at the cached state
  28722. * @returns the projection matrix
  28723. */
  28724. getProjectionMatrix(force?: boolean): Matrix;
  28725. /**
  28726. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28727. * @returns a Matrix
  28728. */
  28729. getTransformationMatrix(): Matrix;
  28730. private _updateFrustumPlanes;
  28731. /**
  28732. * Checks if a cullable object (mesh...) is in the camera frustum
  28733. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28734. * @param target The object to check
  28735. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28736. * @returns true if the object is in frustum otherwise false
  28737. */
  28738. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28739. /**
  28740. * Checks if a cullable object (mesh...) is in the camera frustum
  28741. * Unlike isInFrustum this cheks the full bounding box
  28742. * @param target The object to check
  28743. * @returns true if the object is in frustum otherwise false
  28744. */
  28745. isCompletelyInFrustum(target: ICullable): boolean;
  28746. /**
  28747. * Gets a ray in the forward direction from the camera.
  28748. * @param length Defines the length of the ray to create
  28749. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28750. * @param origin Defines the start point of the ray which defaults to the camera position
  28751. * @returns the forward ray
  28752. */
  28753. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28754. /**
  28755. * Releases resources associated with this node.
  28756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28758. */
  28759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28760. /** @hidden */
  28761. _isLeftCamera: boolean;
  28762. /**
  28763. * Gets the left camera of a rig setup in case of Rigged Camera
  28764. */
  28765. get isLeftCamera(): boolean;
  28766. /** @hidden */
  28767. _isRightCamera: boolean;
  28768. /**
  28769. * Gets the right camera of a rig setup in case of Rigged Camera
  28770. */
  28771. get isRightCamera(): boolean;
  28772. /**
  28773. * Gets the left camera of a rig setup in case of Rigged Camera
  28774. */
  28775. get leftCamera(): Nullable<FreeCamera>;
  28776. /**
  28777. * Gets the right camera of a rig setup in case of Rigged Camera
  28778. */
  28779. get rightCamera(): Nullable<FreeCamera>;
  28780. /**
  28781. * Gets the left camera target of a rig setup in case of Rigged Camera
  28782. * @returns the target position
  28783. */
  28784. getLeftTarget(): Nullable<Vector3>;
  28785. /**
  28786. * Gets the right camera target of a rig setup in case of Rigged Camera
  28787. * @returns the target position
  28788. */
  28789. getRightTarget(): Nullable<Vector3>;
  28790. /**
  28791. * @hidden
  28792. */
  28793. setCameraRigMode(mode: number, rigParams: any): void;
  28794. /** @hidden */
  28795. static _setStereoscopicRigMode(camera: Camera): void;
  28796. /** @hidden */
  28797. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28798. /** @hidden */
  28799. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28800. /** @hidden */
  28801. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28802. /** @hidden */
  28803. _getVRProjectionMatrix(): Matrix;
  28804. protected _updateCameraRotationMatrix(): void;
  28805. protected _updateWebVRCameraRotationMatrix(): void;
  28806. /**
  28807. * This function MUST be overwritten by the different WebVR cameras available.
  28808. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28809. * @hidden
  28810. */
  28811. _getWebVRProjectionMatrix(): Matrix;
  28812. /**
  28813. * This function MUST be overwritten by the different WebVR cameras available.
  28814. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28815. * @hidden
  28816. */
  28817. _getWebVRViewMatrix(): Matrix;
  28818. /** @hidden */
  28819. setCameraRigParameter(name: string, value: any): void;
  28820. /**
  28821. * needs to be overridden by children so sub has required properties to be copied
  28822. * @hidden
  28823. */
  28824. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28825. /**
  28826. * May need to be overridden by children
  28827. * @hidden
  28828. */
  28829. _updateRigCameras(): void;
  28830. /** @hidden */
  28831. _setupInputs(): void;
  28832. /**
  28833. * Serialiaze the camera setup to a json represention
  28834. * @returns the JSON representation
  28835. */
  28836. serialize(): any;
  28837. /**
  28838. * Clones the current camera.
  28839. * @param name The cloned camera name
  28840. * @returns the cloned camera
  28841. */
  28842. clone(name: string): Camera;
  28843. /**
  28844. * Gets the direction of the camera relative to a given local axis.
  28845. * @param localAxis Defines the reference axis to provide a relative direction.
  28846. * @return the direction
  28847. */
  28848. getDirection(localAxis: Vector3): Vector3;
  28849. /**
  28850. * Returns the current camera absolute rotation
  28851. */
  28852. get absoluteRotation(): Quaternion;
  28853. /**
  28854. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28855. * @param localAxis Defines the reference axis to provide a relative direction.
  28856. * @param result Defines the vector to store the result in
  28857. */
  28858. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28859. /**
  28860. * Gets a camera constructor for a given camera type
  28861. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28862. * @param name The name of the camera the result will be able to instantiate
  28863. * @param scene The scene the result will construct the camera in
  28864. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28865. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28866. * @returns a factory method to construc the camera
  28867. */
  28868. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28869. /**
  28870. * Compute the world matrix of the camera.
  28871. * @returns the camera world matrix
  28872. */
  28873. computeWorldMatrix(): Matrix;
  28874. /**
  28875. * Parse a JSON and creates the camera from the parsed information
  28876. * @param parsedCamera The JSON to parse
  28877. * @param scene The scene to instantiate the camera in
  28878. * @returns the newly constructed camera
  28879. */
  28880. static Parse(parsedCamera: any, scene: Scene): Camera;
  28881. }
  28882. }
  28883. declare module BABYLON {
  28884. /**
  28885. * Class containing static functions to help procedurally build meshes
  28886. */
  28887. export class DiscBuilder {
  28888. /**
  28889. * Creates a plane polygonal mesh. By default, this is a disc
  28890. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28891. * * 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
  28892. * * 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
  28893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28894. * * 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
  28895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28896. * @param name defines the name of the mesh
  28897. * @param options defines the options used to create the mesh
  28898. * @param scene defines the hosting scene
  28899. * @returns the plane polygonal mesh
  28900. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28901. */
  28902. static CreateDisc(name: string, options: {
  28903. radius?: number;
  28904. tessellation?: number;
  28905. arc?: number;
  28906. updatable?: boolean;
  28907. sideOrientation?: number;
  28908. frontUVs?: Vector4;
  28909. backUVs?: Vector4;
  28910. }, scene?: Nullable<Scene>): Mesh;
  28911. }
  28912. }
  28913. declare module BABYLON {
  28914. /**
  28915. * Options to be used when creating a FresnelParameters.
  28916. */
  28917. export type IFresnelParametersCreationOptions = {
  28918. /**
  28919. * Define the color used on edges (grazing angle)
  28920. */
  28921. leftColor?: Color3;
  28922. /**
  28923. * Define the color used on center
  28924. */
  28925. rightColor?: Color3;
  28926. /**
  28927. * Define bias applied to computed fresnel term
  28928. */
  28929. bias?: number;
  28930. /**
  28931. * Defined the power exponent applied to fresnel term
  28932. */
  28933. power?: number;
  28934. /**
  28935. * Define if the fresnel effect is enable or not.
  28936. */
  28937. isEnabled?: boolean;
  28938. };
  28939. /**
  28940. * Serialized format for FresnelParameters.
  28941. */
  28942. export type IFresnelParametersSerialized = {
  28943. /**
  28944. * Define the color used on edges (grazing angle) [as an array]
  28945. */
  28946. leftColor: number[];
  28947. /**
  28948. * Define the color used on center [as an array]
  28949. */
  28950. rightColor: number[];
  28951. /**
  28952. * Define bias applied to computed fresnel term
  28953. */
  28954. bias: number;
  28955. /**
  28956. * Defined the power exponent applied to fresnel term
  28957. */
  28958. power?: number;
  28959. /**
  28960. * Define if the fresnel effect is enable or not.
  28961. */
  28962. isEnabled: boolean;
  28963. };
  28964. /**
  28965. * This represents all the required information to add a fresnel effect on a material:
  28966. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28967. */
  28968. export class FresnelParameters {
  28969. private _isEnabled;
  28970. /**
  28971. * Define if the fresnel effect is enable or not.
  28972. */
  28973. get isEnabled(): boolean;
  28974. set isEnabled(value: boolean);
  28975. /**
  28976. * Define the color used on edges (grazing angle)
  28977. */
  28978. leftColor: Color3;
  28979. /**
  28980. * Define the color used on center
  28981. */
  28982. rightColor: Color3;
  28983. /**
  28984. * Define bias applied to computed fresnel term
  28985. */
  28986. bias: number;
  28987. /**
  28988. * Defined the power exponent applied to fresnel term
  28989. */
  28990. power: number;
  28991. /**
  28992. * Creates a new FresnelParameters object.
  28993. *
  28994. * @param options provide your own settings to optionally to override defaults
  28995. */
  28996. constructor(options?: IFresnelParametersCreationOptions);
  28997. /**
  28998. * Clones the current fresnel and its valuues
  28999. * @returns a clone fresnel configuration
  29000. */
  29001. clone(): FresnelParameters;
  29002. /**
  29003. * Determines equality between FresnelParameters objects
  29004. * @param otherFresnelParameters defines the second operand
  29005. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29006. */
  29007. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29008. /**
  29009. * Serializes the current fresnel parameters to a JSON representation.
  29010. * @return the JSON serialization
  29011. */
  29012. serialize(): IFresnelParametersSerialized;
  29013. /**
  29014. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29015. * @param parsedFresnelParameters Define the JSON representation
  29016. * @returns the parsed parameters
  29017. */
  29018. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29019. }
  29020. }
  29021. declare module BABYLON {
  29022. /**
  29023. * This groups all the flags used to control the materials channel.
  29024. */
  29025. export class MaterialFlags {
  29026. private static _DiffuseTextureEnabled;
  29027. /**
  29028. * Are diffuse textures enabled in the application.
  29029. */
  29030. static get DiffuseTextureEnabled(): boolean;
  29031. static set DiffuseTextureEnabled(value: boolean);
  29032. private static _DetailTextureEnabled;
  29033. /**
  29034. * Are detail textures enabled in the application.
  29035. */
  29036. static get DetailTextureEnabled(): boolean;
  29037. static set DetailTextureEnabled(value: boolean);
  29038. private static _AmbientTextureEnabled;
  29039. /**
  29040. * Are ambient textures enabled in the application.
  29041. */
  29042. static get AmbientTextureEnabled(): boolean;
  29043. static set AmbientTextureEnabled(value: boolean);
  29044. private static _OpacityTextureEnabled;
  29045. /**
  29046. * Are opacity textures enabled in the application.
  29047. */
  29048. static get OpacityTextureEnabled(): boolean;
  29049. static set OpacityTextureEnabled(value: boolean);
  29050. private static _ReflectionTextureEnabled;
  29051. /**
  29052. * Are reflection textures enabled in the application.
  29053. */
  29054. static get ReflectionTextureEnabled(): boolean;
  29055. static set ReflectionTextureEnabled(value: boolean);
  29056. private static _EmissiveTextureEnabled;
  29057. /**
  29058. * Are emissive textures enabled in the application.
  29059. */
  29060. static get EmissiveTextureEnabled(): boolean;
  29061. static set EmissiveTextureEnabled(value: boolean);
  29062. private static _SpecularTextureEnabled;
  29063. /**
  29064. * Are specular textures enabled in the application.
  29065. */
  29066. static get SpecularTextureEnabled(): boolean;
  29067. static set SpecularTextureEnabled(value: boolean);
  29068. private static _BumpTextureEnabled;
  29069. /**
  29070. * Are bump textures enabled in the application.
  29071. */
  29072. static get BumpTextureEnabled(): boolean;
  29073. static set BumpTextureEnabled(value: boolean);
  29074. private static _LightmapTextureEnabled;
  29075. /**
  29076. * Are lightmap textures enabled in the application.
  29077. */
  29078. static get LightmapTextureEnabled(): boolean;
  29079. static set LightmapTextureEnabled(value: boolean);
  29080. private static _RefractionTextureEnabled;
  29081. /**
  29082. * Are refraction textures enabled in the application.
  29083. */
  29084. static get RefractionTextureEnabled(): boolean;
  29085. static set RefractionTextureEnabled(value: boolean);
  29086. private static _ColorGradingTextureEnabled;
  29087. /**
  29088. * Are color grading textures enabled in the application.
  29089. */
  29090. static get ColorGradingTextureEnabled(): boolean;
  29091. static set ColorGradingTextureEnabled(value: boolean);
  29092. private static _FresnelEnabled;
  29093. /**
  29094. * Are fresnels enabled in the application.
  29095. */
  29096. static get FresnelEnabled(): boolean;
  29097. static set FresnelEnabled(value: boolean);
  29098. private static _ClearCoatTextureEnabled;
  29099. /**
  29100. * Are clear coat textures enabled in the application.
  29101. */
  29102. static get ClearCoatTextureEnabled(): boolean;
  29103. static set ClearCoatTextureEnabled(value: boolean);
  29104. private static _ClearCoatBumpTextureEnabled;
  29105. /**
  29106. * Are clear coat bump textures enabled in the application.
  29107. */
  29108. static get ClearCoatBumpTextureEnabled(): boolean;
  29109. static set ClearCoatBumpTextureEnabled(value: boolean);
  29110. private static _ClearCoatTintTextureEnabled;
  29111. /**
  29112. * Are clear coat tint textures enabled in the application.
  29113. */
  29114. static get ClearCoatTintTextureEnabled(): boolean;
  29115. static set ClearCoatTintTextureEnabled(value: boolean);
  29116. private static _SheenTextureEnabled;
  29117. /**
  29118. * Are sheen textures enabled in the application.
  29119. */
  29120. static get SheenTextureEnabled(): boolean;
  29121. static set SheenTextureEnabled(value: boolean);
  29122. private static _AnisotropicTextureEnabled;
  29123. /**
  29124. * Are anisotropic textures enabled in the application.
  29125. */
  29126. static get AnisotropicTextureEnabled(): boolean;
  29127. static set AnisotropicTextureEnabled(value: boolean);
  29128. private static _ThicknessTextureEnabled;
  29129. /**
  29130. * Are thickness textures enabled in the application.
  29131. */
  29132. static get ThicknessTextureEnabled(): boolean;
  29133. static set ThicknessTextureEnabled(value: boolean);
  29134. }
  29135. }
  29136. declare module BABYLON {
  29137. /** @hidden */
  29138. export var defaultFragmentDeclaration: {
  29139. name: string;
  29140. shader: string;
  29141. };
  29142. }
  29143. declare module BABYLON {
  29144. /** @hidden */
  29145. export var defaultUboDeclaration: {
  29146. name: string;
  29147. shader: string;
  29148. };
  29149. }
  29150. declare module BABYLON {
  29151. /** @hidden */
  29152. export var lightFragmentDeclaration: {
  29153. name: string;
  29154. shader: string;
  29155. };
  29156. }
  29157. declare module BABYLON {
  29158. /** @hidden */
  29159. export var lightUboDeclaration: {
  29160. name: string;
  29161. shader: string;
  29162. };
  29163. }
  29164. declare module BABYLON {
  29165. /** @hidden */
  29166. export var lightsFragmentFunctions: {
  29167. name: string;
  29168. shader: string;
  29169. };
  29170. }
  29171. declare module BABYLON {
  29172. /** @hidden */
  29173. export var shadowsFragmentFunctions: {
  29174. name: string;
  29175. shader: string;
  29176. };
  29177. }
  29178. declare module BABYLON {
  29179. /** @hidden */
  29180. export var fresnelFunction: {
  29181. name: string;
  29182. shader: string;
  29183. };
  29184. }
  29185. declare module BABYLON {
  29186. /** @hidden */
  29187. export var bumpFragmentMainFunctions: {
  29188. name: string;
  29189. shader: string;
  29190. };
  29191. }
  29192. declare module BABYLON {
  29193. /** @hidden */
  29194. export var bumpFragmentFunctions: {
  29195. name: string;
  29196. shader: string;
  29197. };
  29198. }
  29199. declare module BABYLON {
  29200. /** @hidden */
  29201. export var logDepthDeclaration: {
  29202. name: string;
  29203. shader: string;
  29204. };
  29205. }
  29206. declare module BABYLON {
  29207. /** @hidden */
  29208. export var bumpFragment: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module BABYLON {
  29214. /** @hidden */
  29215. export var depthPrePass: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module BABYLON {
  29221. /** @hidden */
  29222. export var lightFragment: {
  29223. name: string;
  29224. shader: string;
  29225. };
  29226. }
  29227. declare module BABYLON {
  29228. /** @hidden */
  29229. export var logDepthFragment: {
  29230. name: string;
  29231. shader: string;
  29232. };
  29233. }
  29234. declare module BABYLON {
  29235. /** @hidden */
  29236. export var defaultPixelShader: {
  29237. name: string;
  29238. shader: string;
  29239. };
  29240. }
  29241. declare module BABYLON {
  29242. /** @hidden */
  29243. export var defaultVertexDeclaration: {
  29244. name: string;
  29245. shader: string;
  29246. };
  29247. }
  29248. declare module BABYLON {
  29249. /** @hidden */
  29250. export var bumpVertexDeclaration: {
  29251. name: string;
  29252. shader: string;
  29253. };
  29254. }
  29255. declare module BABYLON {
  29256. /** @hidden */
  29257. export var bumpVertex: {
  29258. name: string;
  29259. shader: string;
  29260. };
  29261. }
  29262. declare module BABYLON {
  29263. /** @hidden */
  29264. export var fogVertex: {
  29265. name: string;
  29266. shader: string;
  29267. };
  29268. }
  29269. declare module BABYLON {
  29270. /** @hidden */
  29271. export var shadowsVertex: {
  29272. name: string;
  29273. shader: string;
  29274. };
  29275. }
  29276. declare module BABYLON {
  29277. /** @hidden */
  29278. export var pointCloudVertex: {
  29279. name: string;
  29280. shader: string;
  29281. };
  29282. }
  29283. declare module BABYLON {
  29284. /** @hidden */
  29285. export var logDepthVertex: {
  29286. name: string;
  29287. shader: string;
  29288. };
  29289. }
  29290. declare module BABYLON {
  29291. /** @hidden */
  29292. export var defaultVertexShader: {
  29293. name: string;
  29294. shader: string;
  29295. };
  29296. }
  29297. declare module BABYLON {
  29298. /**
  29299. * @hidden
  29300. */
  29301. export interface IMaterialDetailMapDefines {
  29302. DETAIL: boolean;
  29303. DETAILDIRECTUV: number;
  29304. DETAIL_NORMALBLENDMETHOD: number;
  29305. /** @hidden */
  29306. _areTexturesDirty: boolean;
  29307. }
  29308. /**
  29309. * Define the code related to the detail map parameters of a material
  29310. *
  29311. * Inspired from:
  29312. * 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
  29313. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29314. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29315. */
  29316. export class DetailMapConfiguration {
  29317. private _texture;
  29318. /**
  29319. * The detail texture of the material.
  29320. */
  29321. texture: Nullable<BaseTexture>;
  29322. /**
  29323. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29324. * Bigger values mean stronger blending
  29325. */
  29326. diffuseBlendLevel: number;
  29327. /**
  29328. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29329. * Bigger values mean stronger blending. Only used with PBR materials
  29330. */
  29331. roughnessBlendLevel: number;
  29332. /**
  29333. * Defines how strong the bump effect from the detail map is
  29334. * Bigger values mean stronger effect
  29335. */
  29336. bumpLevel: number;
  29337. private _normalBlendMethod;
  29338. /**
  29339. * The method used to blend the bump and detail normals together
  29340. */
  29341. normalBlendMethod: number;
  29342. private _isEnabled;
  29343. /**
  29344. * Enable or disable the detail map on this material
  29345. */
  29346. isEnabled: boolean;
  29347. /** @hidden */
  29348. private _internalMarkAllSubMeshesAsTexturesDirty;
  29349. /** @hidden */
  29350. _markAllSubMeshesAsTexturesDirty(): void;
  29351. /**
  29352. * Instantiate a new detail map
  29353. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29354. */
  29355. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29356. /**
  29357. * Gets whether the submesh is ready to be used or not.
  29358. * @param defines the list of "defines" to update.
  29359. * @param scene defines the scene the material belongs to.
  29360. * @returns - boolean indicating that the submesh is ready or not.
  29361. */
  29362. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29363. /**
  29364. * Update the defines for detail map usage
  29365. * @param defines the list of "defines" to update.
  29366. * @param scene defines the scene the material belongs to.
  29367. */
  29368. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29369. /**
  29370. * Binds the material data.
  29371. * @param uniformBuffer defines the Uniform buffer to fill in.
  29372. * @param scene defines the scene the material belongs to.
  29373. * @param isFrozen defines whether the material is frozen or not.
  29374. */
  29375. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29376. /**
  29377. * Checks to see if a texture is used in the material.
  29378. * @param texture - Base texture to use.
  29379. * @returns - Boolean specifying if a texture is used in the material.
  29380. */
  29381. hasTexture(texture: BaseTexture): boolean;
  29382. /**
  29383. * Returns an array of the actively used textures.
  29384. * @param activeTextures Array of BaseTextures
  29385. */
  29386. getActiveTextures(activeTextures: BaseTexture[]): void;
  29387. /**
  29388. * Returns the animatable textures.
  29389. * @param animatables Array of animatable textures.
  29390. */
  29391. getAnimatables(animatables: IAnimatable[]): void;
  29392. /**
  29393. * Disposes the resources of the material.
  29394. * @param forceDisposeTextures - Forces the disposal of all textures.
  29395. */
  29396. dispose(forceDisposeTextures?: boolean): void;
  29397. /**
  29398. * Get the current class name useful for serialization or dynamic coding.
  29399. * @returns "DetailMap"
  29400. */
  29401. getClassName(): string;
  29402. /**
  29403. * Add the required uniforms to the current list.
  29404. * @param uniforms defines the current uniform list.
  29405. */
  29406. static AddUniforms(uniforms: string[]): void;
  29407. /**
  29408. * Add the required samplers to the current list.
  29409. * @param samplers defines the current sampler list.
  29410. */
  29411. static AddSamplers(samplers: string[]): void;
  29412. /**
  29413. * Add the required uniforms to the current buffer.
  29414. * @param uniformBuffer defines the current uniform buffer.
  29415. */
  29416. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29417. /**
  29418. * Makes a duplicate of the current instance into another one.
  29419. * @param detailMap define the instance where to copy the info
  29420. */
  29421. copyTo(detailMap: DetailMapConfiguration): void;
  29422. /**
  29423. * Serializes this detail map instance
  29424. * @returns - An object with the serialized instance.
  29425. */
  29426. serialize(): any;
  29427. /**
  29428. * Parses a detail map setting from a serialized object.
  29429. * @param source - Serialized object.
  29430. * @param scene Defines the scene we are parsing for
  29431. * @param rootUrl Defines the rootUrl to load from
  29432. */
  29433. parse(source: any, scene: Scene, rootUrl: string): void;
  29434. }
  29435. }
  29436. declare module BABYLON {
  29437. /** @hidden */
  29438. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29439. MAINUV1: boolean;
  29440. MAINUV2: boolean;
  29441. DIFFUSE: boolean;
  29442. DIFFUSEDIRECTUV: number;
  29443. DETAIL: boolean;
  29444. DETAILDIRECTUV: number;
  29445. DETAIL_NORMALBLENDMETHOD: number;
  29446. AMBIENT: boolean;
  29447. AMBIENTDIRECTUV: number;
  29448. OPACITY: boolean;
  29449. OPACITYDIRECTUV: number;
  29450. OPACITYRGB: boolean;
  29451. REFLECTION: boolean;
  29452. EMISSIVE: boolean;
  29453. EMISSIVEDIRECTUV: number;
  29454. SPECULAR: boolean;
  29455. SPECULARDIRECTUV: number;
  29456. BUMP: boolean;
  29457. BUMPDIRECTUV: number;
  29458. PARALLAX: boolean;
  29459. PARALLAXOCCLUSION: boolean;
  29460. SPECULAROVERALPHA: boolean;
  29461. CLIPPLANE: boolean;
  29462. CLIPPLANE2: boolean;
  29463. CLIPPLANE3: boolean;
  29464. CLIPPLANE4: boolean;
  29465. CLIPPLANE5: boolean;
  29466. CLIPPLANE6: boolean;
  29467. ALPHATEST: boolean;
  29468. DEPTHPREPASS: boolean;
  29469. ALPHAFROMDIFFUSE: boolean;
  29470. POINTSIZE: boolean;
  29471. FOG: boolean;
  29472. SPECULARTERM: boolean;
  29473. DIFFUSEFRESNEL: boolean;
  29474. OPACITYFRESNEL: boolean;
  29475. REFLECTIONFRESNEL: boolean;
  29476. REFRACTIONFRESNEL: boolean;
  29477. EMISSIVEFRESNEL: boolean;
  29478. FRESNEL: boolean;
  29479. NORMAL: boolean;
  29480. UV1: boolean;
  29481. UV2: boolean;
  29482. VERTEXCOLOR: boolean;
  29483. VERTEXALPHA: boolean;
  29484. NUM_BONE_INFLUENCERS: number;
  29485. BonesPerMesh: number;
  29486. BONETEXTURE: boolean;
  29487. INSTANCES: boolean;
  29488. THIN_INSTANCES: boolean;
  29489. GLOSSINESS: boolean;
  29490. ROUGHNESS: boolean;
  29491. EMISSIVEASILLUMINATION: boolean;
  29492. LINKEMISSIVEWITHDIFFUSE: boolean;
  29493. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29494. LIGHTMAP: boolean;
  29495. LIGHTMAPDIRECTUV: number;
  29496. OBJECTSPACE_NORMALMAP: boolean;
  29497. USELIGHTMAPASSHADOWMAP: boolean;
  29498. REFLECTIONMAP_3D: boolean;
  29499. REFLECTIONMAP_SPHERICAL: boolean;
  29500. REFLECTIONMAP_PLANAR: boolean;
  29501. REFLECTIONMAP_CUBIC: boolean;
  29502. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29503. REFLECTIONMAP_PROJECTION: boolean;
  29504. REFLECTIONMAP_SKYBOX: boolean;
  29505. REFLECTIONMAP_EXPLICIT: boolean;
  29506. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29507. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29508. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29509. INVERTCUBICMAP: boolean;
  29510. LOGARITHMICDEPTH: boolean;
  29511. REFRACTION: boolean;
  29512. REFRACTIONMAP_3D: boolean;
  29513. REFLECTIONOVERALPHA: boolean;
  29514. TWOSIDEDLIGHTING: boolean;
  29515. SHADOWFLOAT: boolean;
  29516. MORPHTARGETS: boolean;
  29517. MORPHTARGETS_NORMAL: boolean;
  29518. MORPHTARGETS_TANGENT: boolean;
  29519. MORPHTARGETS_UV: boolean;
  29520. NUM_MORPH_INFLUENCERS: number;
  29521. NONUNIFORMSCALING: boolean;
  29522. PREMULTIPLYALPHA: boolean;
  29523. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29524. ALPHABLEND: boolean;
  29525. PREPASS: boolean;
  29526. SCENE_MRT_COUNT: number;
  29527. RGBDLIGHTMAP: boolean;
  29528. RGBDREFLECTION: boolean;
  29529. RGBDREFRACTION: boolean;
  29530. IMAGEPROCESSING: boolean;
  29531. VIGNETTE: boolean;
  29532. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29533. VIGNETTEBLENDMODEOPAQUE: boolean;
  29534. TONEMAPPING: boolean;
  29535. TONEMAPPING_ACES: boolean;
  29536. CONTRAST: boolean;
  29537. COLORCURVES: boolean;
  29538. COLORGRADING: boolean;
  29539. COLORGRADING3D: boolean;
  29540. SAMPLER3DGREENDEPTH: boolean;
  29541. SAMPLER3DBGRMAP: boolean;
  29542. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29543. MULTIVIEW: boolean;
  29544. /**
  29545. * If the reflection texture on this material is in linear color space
  29546. * @hidden
  29547. */
  29548. IS_REFLECTION_LINEAR: boolean;
  29549. /**
  29550. * If the refraction texture on this material is in linear color space
  29551. * @hidden
  29552. */
  29553. IS_REFRACTION_LINEAR: boolean;
  29554. EXPOSURE: boolean;
  29555. constructor();
  29556. setReflectionMode(modeToEnable: string): void;
  29557. }
  29558. /**
  29559. * This is the default material used in Babylon. It is the best trade off between quality
  29560. * and performances.
  29561. * @see https://doc.babylonjs.com/babylon101/materials
  29562. */
  29563. export class StandardMaterial extends PushMaterial {
  29564. private _diffuseTexture;
  29565. /**
  29566. * The basic texture of the material as viewed under a light.
  29567. */
  29568. diffuseTexture: Nullable<BaseTexture>;
  29569. private _ambientTexture;
  29570. /**
  29571. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29572. */
  29573. ambientTexture: Nullable<BaseTexture>;
  29574. private _opacityTexture;
  29575. /**
  29576. * Define the transparency of the material from a texture.
  29577. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29578. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29579. */
  29580. opacityTexture: Nullable<BaseTexture>;
  29581. private _reflectionTexture;
  29582. /**
  29583. * Define the texture used to display the reflection.
  29584. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29585. */
  29586. reflectionTexture: Nullable<BaseTexture>;
  29587. private _emissiveTexture;
  29588. /**
  29589. * Define texture of the material as if self lit.
  29590. * This will be mixed in the final result even in the absence of light.
  29591. */
  29592. emissiveTexture: Nullable<BaseTexture>;
  29593. private _specularTexture;
  29594. /**
  29595. * Define how the color and intensity of the highlight given by the light in the material.
  29596. */
  29597. specularTexture: Nullable<BaseTexture>;
  29598. private _bumpTexture;
  29599. /**
  29600. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29601. * 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.
  29602. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  29603. */
  29604. bumpTexture: Nullable<BaseTexture>;
  29605. private _lightmapTexture;
  29606. /**
  29607. * Complex lighting can be computationally expensive to compute at runtime.
  29608. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29609. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  29610. */
  29611. lightmapTexture: Nullable<BaseTexture>;
  29612. private _refractionTexture;
  29613. /**
  29614. * Define the texture used to display the refraction.
  29615. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29616. */
  29617. refractionTexture: Nullable<BaseTexture>;
  29618. /**
  29619. * The color of the material lit by the environmental background lighting.
  29620. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29621. */
  29622. ambientColor: Color3;
  29623. /**
  29624. * The basic color of the material as viewed under a light.
  29625. */
  29626. diffuseColor: Color3;
  29627. /**
  29628. * Define how the color and intensity of the highlight given by the light in the material.
  29629. */
  29630. specularColor: Color3;
  29631. /**
  29632. * Define the color of the material as if self lit.
  29633. * This will be mixed in the final result even in the absence of light.
  29634. */
  29635. emissiveColor: Color3;
  29636. /**
  29637. * Defines how sharp are the highlights in the material.
  29638. * The bigger the value the sharper giving a more glossy feeling to the result.
  29639. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29640. */
  29641. specularPower: number;
  29642. private _useAlphaFromDiffuseTexture;
  29643. /**
  29644. * Does the transparency come from the diffuse texture alpha channel.
  29645. */
  29646. useAlphaFromDiffuseTexture: boolean;
  29647. private _useEmissiveAsIllumination;
  29648. /**
  29649. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29650. */
  29651. useEmissiveAsIllumination: boolean;
  29652. private _linkEmissiveWithDiffuse;
  29653. /**
  29654. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29655. * the emissive level when the final color is close to one.
  29656. */
  29657. linkEmissiveWithDiffuse: boolean;
  29658. private _useSpecularOverAlpha;
  29659. /**
  29660. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29661. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29662. */
  29663. useSpecularOverAlpha: boolean;
  29664. private _useReflectionOverAlpha;
  29665. /**
  29666. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29667. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29668. */
  29669. useReflectionOverAlpha: boolean;
  29670. private _disableLighting;
  29671. /**
  29672. * Does lights from the scene impacts this material.
  29673. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29674. */
  29675. disableLighting: boolean;
  29676. private _useObjectSpaceNormalMap;
  29677. /**
  29678. * Allows using an object space normal map (instead of tangent space).
  29679. */
  29680. useObjectSpaceNormalMap: boolean;
  29681. private _useParallax;
  29682. /**
  29683. * Is parallax enabled or not.
  29684. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29685. */
  29686. useParallax: boolean;
  29687. private _useParallaxOcclusion;
  29688. /**
  29689. * Is parallax occlusion enabled or not.
  29690. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29691. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29692. */
  29693. useParallaxOcclusion: boolean;
  29694. /**
  29695. * 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.
  29696. */
  29697. parallaxScaleBias: number;
  29698. private _roughness;
  29699. /**
  29700. * Helps to define how blurry the reflections should appears in the material.
  29701. */
  29702. roughness: number;
  29703. /**
  29704. * In case of refraction, define the value of the index of refraction.
  29705. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29706. */
  29707. indexOfRefraction: number;
  29708. /**
  29709. * Invert the refraction texture alongside the y axis.
  29710. * It can be useful with procedural textures or probe for instance.
  29711. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29712. */
  29713. invertRefractionY: boolean;
  29714. /**
  29715. * Defines the alpha limits in alpha test mode.
  29716. */
  29717. alphaCutOff: number;
  29718. private _useLightmapAsShadowmap;
  29719. /**
  29720. * In case of light mapping, define whether the map contains light or shadow informations.
  29721. */
  29722. useLightmapAsShadowmap: boolean;
  29723. private _diffuseFresnelParameters;
  29724. /**
  29725. * Define the diffuse fresnel parameters of the material.
  29726. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29727. */
  29728. diffuseFresnelParameters: FresnelParameters;
  29729. private _opacityFresnelParameters;
  29730. /**
  29731. * Define the opacity fresnel parameters of the material.
  29732. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29733. */
  29734. opacityFresnelParameters: FresnelParameters;
  29735. private _reflectionFresnelParameters;
  29736. /**
  29737. * Define the reflection fresnel parameters of the material.
  29738. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29739. */
  29740. reflectionFresnelParameters: FresnelParameters;
  29741. private _refractionFresnelParameters;
  29742. /**
  29743. * Define the refraction fresnel parameters of the material.
  29744. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29745. */
  29746. refractionFresnelParameters: FresnelParameters;
  29747. private _emissiveFresnelParameters;
  29748. /**
  29749. * Define the emissive fresnel parameters of the material.
  29750. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29751. */
  29752. emissiveFresnelParameters: FresnelParameters;
  29753. private _useReflectionFresnelFromSpecular;
  29754. /**
  29755. * If true automatically deducts the fresnels values from the material specularity.
  29756. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29757. */
  29758. useReflectionFresnelFromSpecular: boolean;
  29759. private _useGlossinessFromSpecularMapAlpha;
  29760. /**
  29761. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29762. */
  29763. useGlossinessFromSpecularMapAlpha: boolean;
  29764. private _maxSimultaneousLights;
  29765. /**
  29766. * Defines the maximum number of lights that can be used in the material
  29767. */
  29768. maxSimultaneousLights: number;
  29769. private _invertNormalMapX;
  29770. /**
  29771. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29772. */
  29773. invertNormalMapX: boolean;
  29774. private _invertNormalMapY;
  29775. /**
  29776. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29777. */
  29778. invertNormalMapY: boolean;
  29779. private _twoSidedLighting;
  29780. /**
  29781. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29782. */
  29783. twoSidedLighting: boolean;
  29784. /**
  29785. * Default configuration related to image processing available in the standard Material.
  29786. */
  29787. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29788. /**
  29789. * Gets the image processing configuration used either in this material.
  29790. */
  29791. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29792. /**
  29793. * Sets the Default image processing configuration used either in the this material.
  29794. *
  29795. * If sets to null, the scene one is in use.
  29796. */
  29797. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29798. /**
  29799. * Keep track of the image processing observer to allow dispose and replace.
  29800. */
  29801. private _imageProcessingObserver;
  29802. /**
  29803. * Attaches a new image processing configuration to the Standard Material.
  29804. * @param configuration
  29805. */
  29806. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29807. /**
  29808. * Gets wether the color curves effect is enabled.
  29809. */
  29810. get cameraColorCurvesEnabled(): boolean;
  29811. /**
  29812. * Sets wether the color curves effect is enabled.
  29813. */
  29814. set cameraColorCurvesEnabled(value: boolean);
  29815. /**
  29816. * Gets wether the color grading effect is enabled.
  29817. */
  29818. get cameraColorGradingEnabled(): boolean;
  29819. /**
  29820. * Gets wether the color grading effect is enabled.
  29821. */
  29822. set cameraColorGradingEnabled(value: boolean);
  29823. /**
  29824. * Gets wether tonemapping is enabled or not.
  29825. */
  29826. get cameraToneMappingEnabled(): boolean;
  29827. /**
  29828. * Sets wether tonemapping is enabled or not
  29829. */
  29830. set cameraToneMappingEnabled(value: boolean);
  29831. /**
  29832. * The camera exposure used on this material.
  29833. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29834. * This corresponds to a photographic exposure.
  29835. */
  29836. get cameraExposure(): number;
  29837. /**
  29838. * The camera exposure used on this material.
  29839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29840. * This corresponds to a photographic exposure.
  29841. */
  29842. set cameraExposure(value: number);
  29843. /**
  29844. * Gets The camera contrast used on this material.
  29845. */
  29846. get cameraContrast(): number;
  29847. /**
  29848. * Sets The camera contrast used on this material.
  29849. */
  29850. set cameraContrast(value: number);
  29851. /**
  29852. * Gets the Color Grading 2D Lookup Texture.
  29853. */
  29854. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29855. /**
  29856. * Sets the Color Grading 2D Lookup Texture.
  29857. */
  29858. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29859. /**
  29860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29862. * 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;
  29863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29864. */
  29865. get cameraColorCurves(): Nullable<ColorCurves>;
  29866. /**
  29867. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29869. * 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;
  29870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29871. */
  29872. set cameraColorCurves(value: Nullable<ColorCurves>);
  29873. /**
  29874. * Defines the detail map parameters for the material.
  29875. */
  29876. readonly detailMap: DetailMapConfiguration;
  29877. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29878. protected _worldViewProjectionMatrix: Matrix;
  29879. protected _globalAmbientColor: Color3;
  29880. protected _useLogarithmicDepth: boolean;
  29881. protected _rebuildInParallel: boolean;
  29882. /**
  29883. * Instantiates a new standard material.
  29884. * This is the default material used in Babylon. It is the best trade off between quality
  29885. * and performances.
  29886. * @see https://doc.babylonjs.com/babylon101/materials
  29887. * @param name Define the name of the material in the scene
  29888. * @param scene Define the scene the material belong to
  29889. */
  29890. constructor(name: string, scene: Scene);
  29891. /**
  29892. * Gets a boolean indicating that current material needs to register RTT
  29893. */
  29894. get hasRenderTargetTextures(): boolean;
  29895. /**
  29896. * Gets the current class name of the material e.g. "StandardMaterial"
  29897. * Mainly use in serialization.
  29898. * @returns the class name
  29899. */
  29900. getClassName(): string;
  29901. /**
  29902. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29903. * You can try switching to logarithmic depth.
  29904. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29905. */
  29906. get useLogarithmicDepth(): boolean;
  29907. set useLogarithmicDepth(value: boolean);
  29908. /**
  29909. * Specifies if the material will require alpha blending
  29910. * @returns a boolean specifying if alpha blending is needed
  29911. */
  29912. needAlphaBlending(): boolean;
  29913. /**
  29914. * Specifies if this material should be rendered in alpha test mode
  29915. * @returns a boolean specifying if an alpha test is needed.
  29916. */
  29917. needAlphaTesting(): boolean;
  29918. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29919. /**
  29920. * Get the texture used for alpha test purpose.
  29921. * @returns the diffuse texture in case of the standard material.
  29922. */
  29923. getAlphaTestTexture(): Nullable<BaseTexture>;
  29924. /**
  29925. * Get if the submesh is ready to be used and all its information available.
  29926. * Child classes can use it to update shaders
  29927. * @param mesh defines the mesh to check
  29928. * @param subMesh defines which submesh to check
  29929. * @param useInstances specifies that instances should be used
  29930. * @returns a boolean indicating that the submesh is ready or not
  29931. */
  29932. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29933. /**
  29934. * Builds the material UBO layouts.
  29935. * Used internally during the effect preparation.
  29936. */
  29937. buildUniformLayout(): void;
  29938. /**
  29939. * Unbinds the material from the mesh
  29940. */
  29941. unbind(): void;
  29942. /**
  29943. * Binds the submesh to this material by preparing the effect and shader to draw
  29944. * @param world defines the world transformation matrix
  29945. * @param mesh defines the mesh containing the submesh
  29946. * @param subMesh defines the submesh to bind the material to
  29947. */
  29948. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29949. /**
  29950. * Get the list of animatables in the material.
  29951. * @returns the list of animatables object used in the material
  29952. */
  29953. getAnimatables(): IAnimatable[];
  29954. /**
  29955. * Gets the active textures from the material
  29956. * @returns an array of textures
  29957. */
  29958. getActiveTextures(): BaseTexture[];
  29959. /**
  29960. * Specifies if the material uses a texture
  29961. * @param texture defines the texture to check against the material
  29962. * @returns a boolean specifying if the material uses the texture
  29963. */
  29964. hasTexture(texture: BaseTexture): boolean;
  29965. /**
  29966. * Disposes the material
  29967. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29968. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29969. */
  29970. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29971. /**
  29972. * Makes a duplicate of the material, and gives it a new name
  29973. * @param name defines the new name for the duplicated material
  29974. * @returns the cloned material
  29975. */
  29976. clone(name: string): StandardMaterial;
  29977. /**
  29978. * Serializes this material in a JSON representation
  29979. * @returns the serialized material object
  29980. */
  29981. serialize(): any;
  29982. /**
  29983. * Creates a standard material from parsed material data
  29984. * @param source defines the JSON representation of the material
  29985. * @param scene defines the hosting scene
  29986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29987. * @returns a new standard material
  29988. */
  29989. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29990. /**
  29991. * Are diffuse textures enabled in the application.
  29992. */
  29993. static get DiffuseTextureEnabled(): boolean;
  29994. static set DiffuseTextureEnabled(value: boolean);
  29995. /**
  29996. * Are detail textures enabled in the application.
  29997. */
  29998. static get DetailTextureEnabled(): boolean;
  29999. static set DetailTextureEnabled(value: boolean);
  30000. /**
  30001. * Are ambient textures enabled in the application.
  30002. */
  30003. static get AmbientTextureEnabled(): boolean;
  30004. static set AmbientTextureEnabled(value: boolean);
  30005. /**
  30006. * Are opacity textures enabled in the application.
  30007. */
  30008. static get OpacityTextureEnabled(): boolean;
  30009. static set OpacityTextureEnabled(value: boolean);
  30010. /**
  30011. * Are reflection textures enabled in the application.
  30012. */
  30013. static get ReflectionTextureEnabled(): boolean;
  30014. static set ReflectionTextureEnabled(value: boolean);
  30015. /**
  30016. * Are emissive textures enabled in the application.
  30017. */
  30018. static get EmissiveTextureEnabled(): boolean;
  30019. static set EmissiveTextureEnabled(value: boolean);
  30020. /**
  30021. * Are specular textures enabled in the application.
  30022. */
  30023. static get SpecularTextureEnabled(): boolean;
  30024. static set SpecularTextureEnabled(value: boolean);
  30025. /**
  30026. * Are bump textures enabled in the application.
  30027. */
  30028. static get BumpTextureEnabled(): boolean;
  30029. static set BumpTextureEnabled(value: boolean);
  30030. /**
  30031. * Are lightmap textures enabled in the application.
  30032. */
  30033. static get LightmapTextureEnabled(): boolean;
  30034. static set LightmapTextureEnabled(value: boolean);
  30035. /**
  30036. * Are refraction textures enabled in the application.
  30037. */
  30038. static get RefractionTextureEnabled(): boolean;
  30039. static set RefractionTextureEnabled(value: boolean);
  30040. /**
  30041. * Are color grading textures enabled in the application.
  30042. */
  30043. static get ColorGradingTextureEnabled(): boolean;
  30044. static set ColorGradingTextureEnabled(value: boolean);
  30045. /**
  30046. * Are fresnels enabled in the application.
  30047. */
  30048. static get FresnelEnabled(): boolean;
  30049. static set FresnelEnabled(value: boolean);
  30050. }
  30051. }
  30052. declare module BABYLON {
  30053. /**
  30054. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30055. *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.
  30056. * The SPS is also a particle system. It provides some methods to manage the particles.
  30057. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30058. *
  30059. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30060. */
  30061. export class SolidParticleSystem implements IDisposable {
  30062. /**
  30063. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30064. * Example : var p = SPS.particles[i];
  30065. */
  30066. particles: SolidParticle[];
  30067. /**
  30068. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30069. */
  30070. nbParticles: number;
  30071. /**
  30072. * If the particles must ever face the camera (default false). Useful for planar particles.
  30073. */
  30074. billboard: boolean;
  30075. /**
  30076. * Recompute normals when adding a shape
  30077. */
  30078. recomputeNormals: boolean;
  30079. /**
  30080. * This a counter ofr your own usage. It's not set by any SPS functions.
  30081. */
  30082. counter: number;
  30083. /**
  30084. * The SPS name. This name is also given to the underlying mesh.
  30085. */
  30086. name: string;
  30087. /**
  30088. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30089. */
  30090. mesh: Mesh;
  30091. /**
  30092. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30093. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30094. */
  30095. vars: any;
  30096. /**
  30097. * This array is populated when the SPS is set as 'pickable'.
  30098. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30099. * Each element of this array is an object `{idx: int, faceId: int}`.
  30100. * `idx` is the picked particle index in the `SPS.particles` array
  30101. * `faceId` is the picked face index counted within this particle.
  30102. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30103. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30104. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30105. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30106. */
  30107. pickedParticles: {
  30108. idx: number;
  30109. faceId: number;
  30110. }[];
  30111. /**
  30112. * This array is populated when the SPS is set as 'pickable'
  30113. * Each key of this array is a submesh index.
  30114. * Each element of this array is a second array defined like this :
  30115. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30116. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30117. * `idx` is the picked particle index in the `SPS.particles` array
  30118. * `faceId` is the picked face index counted within this particle.
  30119. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30120. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30121. */
  30122. pickedBySubMesh: {
  30123. idx: number;
  30124. faceId: number;
  30125. }[][];
  30126. /**
  30127. * This array is populated when `enableDepthSort` is set to true.
  30128. * Each element of this array is an instance of the class DepthSortedParticle.
  30129. */
  30130. depthSortedParticles: DepthSortedParticle[];
  30131. /**
  30132. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30133. * @hidden
  30134. */
  30135. _bSphereOnly: boolean;
  30136. /**
  30137. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30138. * @hidden
  30139. */
  30140. _bSphereRadiusFactor: number;
  30141. private _scene;
  30142. private _positions;
  30143. private _indices;
  30144. private _normals;
  30145. private _colors;
  30146. private _uvs;
  30147. private _indices32;
  30148. private _positions32;
  30149. private _normals32;
  30150. private _fixedNormal32;
  30151. private _colors32;
  30152. private _uvs32;
  30153. private _index;
  30154. private _updatable;
  30155. private _pickable;
  30156. private _isVisibilityBoxLocked;
  30157. private _alwaysVisible;
  30158. private _depthSort;
  30159. private _expandable;
  30160. private _shapeCounter;
  30161. private _copy;
  30162. private _color;
  30163. private _computeParticleColor;
  30164. private _computeParticleTexture;
  30165. private _computeParticleRotation;
  30166. private _computeParticleVertex;
  30167. private _computeBoundingBox;
  30168. private _depthSortParticles;
  30169. private _camera;
  30170. private _mustUnrotateFixedNormals;
  30171. private _particlesIntersect;
  30172. private _needs32Bits;
  30173. private _isNotBuilt;
  30174. private _lastParticleId;
  30175. private _idxOfId;
  30176. private _multimaterialEnabled;
  30177. private _useModelMaterial;
  30178. private _indicesByMaterial;
  30179. private _materialIndexes;
  30180. private _depthSortFunction;
  30181. private _materialSortFunction;
  30182. private _materials;
  30183. private _multimaterial;
  30184. private _materialIndexesById;
  30185. private _defaultMaterial;
  30186. private _autoUpdateSubMeshes;
  30187. private _tmpVertex;
  30188. /**
  30189. * Creates a SPS (Solid Particle System) object.
  30190. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30191. * @param scene (Scene) is the scene in which the SPS is added.
  30192. * @param options defines the options of the sps e.g.
  30193. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30194. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30195. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30196. * * 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.
  30197. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30198. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30199. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30200. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30201. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30202. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30203. */
  30204. constructor(name: string, scene: Scene, options?: {
  30205. updatable?: boolean;
  30206. isPickable?: boolean;
  30207. enableDepthSort?: boolean;
  30208. particleIntersection?: boolean;
  30209. boundingSphereOnly?: boolean;
  30210. bSphereRadiusFactor?: number;
  30211. expandable?: boolean;
  30212. useModelMaterial?: boolean;
  30213. enableMultiMaterial?: boolean;
  30214. });
  30215. /**
  30216. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30217. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30218. * @returns the created mesh
  30219. */
  30220. buildMesh(): Mesh;
  30221. /**
  30222. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30223. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30224. * Thus the particles generated from `digest()` have their property `position` set yet.
  30225. * @param mesh ( Mesh ) is the mesh to be digested
  30226. * @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
  30227. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30228. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30229. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30230. * @returns the current SPS
  30231. */
  30232. digest(mesh: Mesh, options?: {
  30233. facetNb?: number;
  30234. number?: number;
  30235. delta?: number;
  30236. storage?: [];
  30237. }): SolidParticleSystem;
  30238. /**
  30239. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30240. * @hidden
  30241. */
  30242. private _unrotateFixedNormals;
  30243. /**
  30244. * Resets the temporary working copy particle
  30245. * @hidden
  30246. */
  30247. private _resetCopy;
  30248. /**
  30249. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30250. * @param p the current index in the positions array to be updated
  30251. * @param ind the current index in the indices array
  30252. * @param shape a Vector3 array, the shape geometry
  30253. * @param positions the positions array to be updated
  30254. * @param meshInd the shape indices array
  30255. * @param indices the indices array to be updated
  30256. * @param meshUV the shape uv array
  30257. * @param uvs the uv array to be updated
  30258. * @param meshCol the shape color array
  30259. * @param colors the color array to be updated
  30260. * @param meshNor the shape normals array
  30261. * @param normals the normals array to be updated
  30262. * @param idx the particle index
  30263. * @param idxInShape the particle index in its shape
  30264. * @param options the addShape() method passed options
  30265. * @model the particle model
  30266. * @hidden
  30267. */
  30268. private _meshBuilder;
  30269. /**
  30270. * Returns a shape Vector3 array from positions float array
  30271. * @param positions float array
  30272. * @returns a vector3 array
  30273. * @hidden
  30274. */
  30275. private _posToShape;
  30276. /**
  30277. * Returns a shapeUV array from a float uvs (array deep copy)
  30278. * @param uvs as a float array
  30279. * @returns a shapeUV array
  30280. * @hidden
  30281. */
  30282. private _uvsToShapeUV;
  30283. /**
  30284. * Adds a new particle object in the particles array
  30285. * @param idx particle index in particles array
  30286. * @param id particle id
  30287. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30288. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30289. * @param model particle ModelShape object
  30290. * @param shapeId model shape identifier
  30291. * @param idxInShape index of the particle in the current model
  30292. * @param bInfo model bounding info object
  30293. * @param storage target storage array, if any
  30294. * @hidden
  30295. */
  30296. private _addParticle;
  30297. /**
  30298. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30299. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30300. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30301. * @param nb (positive integer) the number of particles to be created from this model
  30302. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30303. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30304. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30305. * @returns the number of shapes in the system
  30306. */
  30307. addShape(mesh: Mesh, nb: number, options?: {
  30308. positionFunction?: any;
  30309. vertexFunction?: any;
  30310. storage?: [];
  30311. }): number;
  30312. /**
  30313. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30314. * @hidden
  30315. */
  30316. private _rebuildParticle;
  30317. /**
  30318. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30319. * @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.
  30320. * @returns the SPS.
  30321. */
  30322. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30323. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30324. * Returns an array with the removed particles.
  30325. * 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.
  30326. * The SPS can't be empty so at least one particle needs to remain in place.
  30327. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30328. * @param start index of the first particle to remove
  30329. * @param end index of the last particle to remove (included)
  30330. * @returns an array populated with the removed particles
  30331. */
  30332. removeParticles(start: number, end: number): SolidParticle[];
  30333. /**
  30334. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30335. * @param solidParticleArray an array populated with Solid Particles objects
  30336. * @returns the SPS
  30337. */
  30338. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30339. /**
  30340. * Creates a new particle and modifies the SPS mesh geometry :
  30341. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30342. * - calls _addParticle() to populate the particle array
  30343. * factorized code from addShape() and insertParticlesFromArray()
  30344. * @param idx particle index in the particles array
  30345. * @param i particle index in its shape
  30346. * @param modelShape particle ModelShape object
  30347. * @param shape shape vertex array
  30348. * @param meshInd shape indices array
  30349. * @param meshUV shape uv array
  30350. * @param meshCol shape color array
  30351. * @param meshNor shape normals array
  30352. * @param bbInfo shape bounding info
  30353. * @param storage target particle storage
  30354. * @options addShape() passed options
  30355. * @hidden
  30356. */
  30357. private _insertNewParticle;
  30358. /**
  30359. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30360. * This method calls `updateParticle()` for each particle of the SPS.
  30361. * For an animated SPS, it is usually called within the render loop.
  30362. * 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.
  30363. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30364. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30365. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30366. * @returns the SPS.
  30367. */
  30368. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30369. /**
  30370. * Disposes the SPS.
  30371. */
  30372. dispose(): void;
  30373. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30374. * idx is the particle index in the SPS
  30375. * faceId is the picked face index counted within this particle.
  30376. * Returns null if the pickInfo can't identify a picked particle.
  30377. * @param pickingInfo (PickingInfo object)
  30378. * @returns {idx: number, faceId: number} or null
  30379. */
  30380. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30381. idx: number;
  30382. faceId: number;
  30383. }>;
  30384. /**
  30385. * Returns a SolidParticle object from its identifier : particle.id
  30386. * @param id (integer) the particle Id
  30387. * @returns the searched particle or null if not found in the SPS.
  30388. */
  30389. getParticleById(id: number): Nullable<SolidParticle>;
  30390. /**
  30391. * Returns a new array populated with the particles having the passed shapeId.
  30392. * @param shapeId (integer) the shape identifier
  30393. * @returns a new solid particle array
  30394. */
  30395. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30396. /**
  30397. * Populates the passed array "ref" with the particles having the passed shapeId.
  30398. * @param shapeId the shape identifier
  30399. * @returns the SPS
  30400. * @param ref
  30401. */
  30402. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30403. /**
  30404. * Computes the required SubMeshes according the materials assigned to the particles.
  30405. * @returns the solid particle system.
  30406. * Does nothing if called before the SPS mesh is built.
  30407. */
  30408. computeSubMeshes(): SolidParticleSystem;
  30409. /**
  30410. * Sorts the solid particles by material when MultiMaterial is enabled.
  30411. * Updates the indices32 array.
  30412. * Updates the indicesByMaterial array.
  30413. * Updates the mesh indices array.
  30414. * @returns the SPS
  30415. * @hidden
  30416. */
  30417. private _sortParticlesByMaterial;
  30418. /**
  30419. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30420. * @hidden
  30421. */
  30422. private _setMaterialIndexesById;
  30423. /**
  30424. * Returns an array with unique values of Materials from the passed array
  30425. * @param array the material array to be checked and filtered
  30426. * @hidden
  30427. */
  30428. private _filterUniqueMaterialId;
  30429. /**
  30430. * Sets a new Standard Material as _defaultMaterial if not already set.
  30431. * @hidden
  30432. */
  30433. private _setDefaultMaterial;
  30434. /**
  30435. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30436. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30437. * @returns the SPS.
  30438. */
  30439. refreshVisibleSize(): SolidParticleSystem;
  30440. /**
  30441. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30442. * @param size the size (float) of the visibility box
  30443. * note : this doesn't lock the SPS mesh bounding box.
  30444. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30445. */
  30446. setVisibilityBox(size: number): void;
  30447. /**
  30448. * Gets whether the SPS as always visible or not
  30449. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30450. */
  30451. get isAlwaysVisible(): boolean;
  30452. /**
  30453. * Sets the SPS as always visible or not
  30454. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30455. */
  30456. set isAlwaysVisible(val: boolean);
  30457. /**
  30458. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30459. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30460. */
  30461. set isVisibilityBoxLocked(val: boolean);
  30462. /**
  30463. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30464. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30465. */
  30466. get isVisibilityBoxLocked(): boolean;
  30467. /**
  30468. * Tells to `setParticles()` to compute the particle rotations or not.
  30469. * Default value : true. The SPS is faster when it's set to false.
  30470. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30471. */
  30472. set computeParticleRotation(val: boolean);
  30473. /**
  30474. * Tells to `setParticles()` to compute the particle colors or not.
  30475. * Default value : true. The SPS is faster when it's set to false.
  30476. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30477. */
  30478. set computeParticleColor(val: boolean);
  30479. set computeParticleTexture(val: boolean);
  30480. /**
  30481. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30482. * Default value : false. The SPS is faster when it's set to false.
  30483. * Note : the particle custom vertex positions aren't stored values.
  30484. */
  30485. set computeParticleVertex(val: boolean);
  30486. /**
  30487. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30488. */
  30489. set computeBoundingBox(val: boolean);
  30490. /**
  30491. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30492. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30493. * Default : `true`
  30494. */
  30495. set depthSortParticles(val: boolean);
  30496. /**
  30497. * Gets if `setParticles()` computes the particle rotations or not.
  30498. * Default value : true. The SPS is faster when it's set to false.
  30499. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30500. */
  30501. get computeParticleRotation(): boolean;
  30502. /**
  30503. * Gets if `setParticles()` computes the particle colors or not.
  30504. * Default value : true. The SPS is faster when it's set to false.
  30505. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30506. */
  30507. get computeParticleColor(): boolean;
  30508. /**
  30509. * Gets if `setParticles()` computes the particle textures or not.
  30510. * Default value : true. The SPS is faster when it's set to false.
  30511. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30512. */
  30513. get computeParticleTexture(): boolean;
  30514. /**
  30515. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30516. * Default value : false. The SPS is faster when it's set to false.
  30517. * Note : the particle custom vertex positions aren't stored values.
  30518. */
  30519. get computeParticleVertex(): boolean;
  30520. /**
  30521. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30522. */
  30523. get computeBoundingBox(): boolean;
  30524. /**
  30525. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30526. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30527. * Default : `true`
  30528. */
  30529. get depthSortParticles(): boolean;
  30530. /**
  30531. * Gets if the SPS is created as expandable at construction time.
  30532. * Default : `false`
  30533. */
  30534. get expandable(): boolean;
  30535. /**
  30536. * Gets if the SPS supports the Multi Materials
  30537. */
  30538. get multimaterialEnabled(): boolean;
  30539. /**
  30540. * Gets if the SPS uses the model materials for its own multimaterial.
  30541. */
  30542. get useModelMaterial(): boolean;
  30543. /**
  30544. * The SPS used material array.
  30545. */
  30546. get materials(): Material[];
  30547. /**
  30548. * Sets the SPS MultiMaterial from the passed materials.
  30549. * Note : the passed array is internally copied and not used then by reference.
  30550. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30551. */
  30552. setMultiMaterial(materials: Material[]): void;
  30553. /**
  30554. * The SPS computed multimaterial object
  30555. */
  30556. get multimaterial(): MultiMaterial;
  30557. set multimaterial(mm: MultiMaterial);
  30558. /**
  30559. * If the subMeshes must be updated on the next call to setParticles()
  30560. */
  30561. get autoUpdateSubMeshes(): boolean;
  30562. set autoUpdateSubMeshes(val: boolean);
  30563. /**
  30564. * This function does nothing. It may be overwritten to set all the particle first values.
  30565. * The SPS doesn't call this function, you may have to call it by your own.
  30566. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30567. */
  30568. initParticles(): void;
  30569. /**
  30570. * This function does nothing. It may be overwritten to recycle a particle.
  30571. * The SPS doesn't call this function, you may have to call it by your own.
  30572. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30573. * @param particle The particle to recycle
  30574. * @returns the recycled particle
  30575. */
  30576. recycleParticle(particle: SolidParticle): SolidParticle;
  30577. /**
  30578. * Updates a particle : this function should be overwritten by the user.
  30579. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30580. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30581. * @example : just set a particle position or velocity and recycle conditions
  30582. * @param particle The particle to update
  30583. * @returns the updated particle
  30584. */
  30585. updateParticle(particle: SolidParticle): SolidParticle;
  30586. /**
  30587. * Updates a vertex of a particle : it can be overwritten by the user.
  30588. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30589. * @param particle the current particle
  30590. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30591. * @param pt the index of the current vertex in the particle shape
  30592. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30593. * @example : just set a vertex particle position or color
  30594. * @returns the sps
  30595. */
  30596. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30597. /**
  30598. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30599. * This does nothing and may be overwritten by the user.
  30600. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30601. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30602. * @param update the boolean update value actually passed to setParticles()
  30603. */
  30604. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30605. /**
  30606. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30607. * This will be passed three parameters.
  30608. * This does nothing and may be overwritten by the user.
  30609. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30610. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30611. * @param update the boolean update value actually passed to setParticles()
  30612. */
  30613. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30614. }
  30615. }
  30616. declare module BABYLON {
  30617. /**
  30618. * Represents one particle of a solid particle system.
  30619. */
  30620. export class SolidParticle {
  30621. /**
  30622. * particle global index
  30623. */
  30624. idx: number;
  30625. /**
  30626. * particle identifier
  30627. */
  30628. id: number;
  30629. /**
  30630. * The color of the particle
  30631. */
  30632. color: Nullable<Color4>;
  30633. /**
  30634. * The world space position of the particle.
  30635. */
  30636. position: Vector3;
  30637. /**
  30638. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30639. */
  30640. rotation: Vector3;
  30641. /**
  30642. * The world space rotation quaternion of the particle.
  30643. */
  30644. rotationQuaternion: Nullable<Quaternion>;
  30645. /**
  30646. * The scaling of the particle.
  30647. */
  30648. scaling: Vector3;
  30649. /**
  30650. * The uvs of the particle.
  30651. */
  30652. uvs: Vector4;
  30653. /**
  30654. * The current speed of the particle.
  30655. */
  30656. velocity: Vector3;
  30657. /**
  30658. * The pivot point in the particle local space.
  30659. */
  30660. pivot: Vector3;
  30661. /**
  30662. * Must the particle be translated from its pivot point in its local space ?
  30663. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30664. * Default : false
  30665. */
  30666. translateFromPivot: boolean;
  30667. /**
  30668. * Is the particle active or not ?
  30669. */
  30670. alive: boolean;
  30671. /**
  30672. * Is the particle visible or not ?
  30673. */
  30674. isVisible: boolean;
  30675. /**
  30676. * Index of this particle in the global "positions" array (Internal use)
  30677. * @hidden
  30678. */
  30679. _pos: number;
  30680. /**
  30681. * @hidden Index of this particle in the global "indices" array (Internal use)
  30682. */
  30683. _ind: number;
  30684. /**
  30685. * @hidden ModelShape of this particle (Internal use)
  30686. */
  30687. _model: ModelShape;
  30688. /**
  30689. * ModelShape id of this particle
  30690. */
  30691. shapeId: number;
  30692. /**
  30693. * Index of the particle in its shape id
  30694. */
  30695. idxInShape: number;
  30696. /**
  30697. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30698. */
  30699. _modelBoundingInfo: BoundingInfo;
  30700. /**
  30701. * @hidden Particle BoundingInfo object (Internal use)
  30702. */
  30703. _boundingInfo: BoundingInfo;
  30704. /**
  30705. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30706. */
  30707. _sps: SolidParticleSystem;
  30708. /**
  30709. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30710. */
  30711. _stillInvisible: boolean;
  30712. /**
  30713. * @hidden Last computed particle rotation matrix
  30714. */
  30715. _rotationMatrix: number[];
  30716. /**
  30717. * Parent particle Id, if any.
  30718. * Default null.
  30719. */
  30720. parentId: Nullable<number>;
  30721. /**
  30722. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30723. */
  30724. materialIndex: Nullable<number>;
  30725. /**
  30726. * Custom object or properties.
  30727. */
  30728. props: Nullable<any>;
  30729. /**
  30730. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30731. * The possible values are :
  30732. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30733. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30734. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30735. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30736. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30737. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30738. * */
  30739. cullingStrategy: number;
  30740. /**
  30741. * @hidden Internal global position in the SPS.
  30742. */
  30743. _globalPosition: Vector3;
  30744. /**
  30745. * Creates a Solid Particle object.
  30746. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30747. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30748. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30749. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30750. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30751. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30752. * @param shapeId (integer) is the model shape identifier in the SPS.
  30753. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30754. * @param sps defines the sps it is associated to
  30755. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30756. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30757. */
  30758. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30759. /**
  30760. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30761. * @param target the particle target
  30762. * @returns the current particle
  30763. */
  30764. copyToRef(target: SolidParticle): SolidParticle;
  30765. /**
  30766. * Legacy support, changed scale to scaling
  30767. */
  30768. get scale(): Vector3;
  30769. /**
  30770. * Legacy support, changed scale to scaling
  30771. */
  30772. set scale(scale: Vector3);
  30773. /**
  30774. * Legacy support, changed quaternion to rotationQuaternion
  30775. */
  30776. get quaternion(): Nullable<Quaternion>;
  30777. /**
  30778. * Legacy support, changed quaternion to rotationQuaternion
  30779. */
  30780. set quaternion(q: Nullable<Quaternion>);
  30781. /**
  30782. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30783. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30784. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30785. * @returns true if it intersects
  30786. */
  30787. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30788. /**
  30789. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30790. * A particle is in the frustum if its bounding box intersects the frustum
  30791. * @param frustumPlanes defines the frustum to test
  30792. * @returns true if the particle is in the frustum planes
  30793. */
  30794. isInFrustum(frustumPlanes: Plane[]): boolean;
  30795. /**
  30796. * get the rotation matrix of the particle
  30797. * @hidden
  30798. */
  30799. getRotationMatrix(m: Matrix): void;
  30800. }
  30801. /**
  30802. * Represents the shape of the model used by one particle of a solid particle system.
  30803. * SPS internal tool, don't use it manually.
  30804. */
  30805. export class ModelShape {
  30806. /**
  30807. * The shape id
  30808. * @hidden
  30809. */
  30810. shapeID: number;
  30811. /**
  30812. * flat array of model positions (internal use)
  30813. * @hidden
  30814. */
  30815. _shape: Vector3[];
  30816. /**
  30817. * flat array of model UVs (internal use)
  30818. * @hidden
  30819. */
  30820. _shapeUV: number[];
  30821. /**
  30822. * color array of the model
  30823. * @hidden
  30824. */
  30825. _shapeColors: number[];
  30826. /**
  30827. * indices array of the model
  30828. * @hidden
  30829. */
  30830. _indices: number[];
  30831. /**
  30832. * normals array of the model
  30833. * @hidden
  30834. */
  30835. _normals: number[];
  30836. /**
  30837. * length of the shape in the model indices array (internal use)
  30838. * @hidden
  30839. */
  30840. _indicesLength: number;
  30841. /**
  30842. * Custom position function (internal use)
  30843. * @hidden
  30844. */
  30845. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30846. /**
  30847. * Custom vertex function (internal use)
  30848. * @hidden
  30849. */
  30850. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30851. /**
  30852. * Model material (internal use)
  30853. * @hidden
  30854. */
  30855. _material: Nullable<Material>;
  30856. /**
  30857. * 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.
  30858. * SPS internal tool, don't use it manually.
  30859. * @hidden
  30860. */
  30861. 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>);
  30862. }
  30863. /**
  30864. * Represents a Depth Sorted Particle in the solid particle system.
  30865. * @hidden
  30866. */
  30867. export class DepthSortedParticle {
  30868. /**
  30869. * Particle index
  30870. */
  30871. idx: number;
  30872. /**
  30873. * Index of the particle in the "indices" array
  30874. */
  30875. ind: number;
  30876. /**
  30877. * Length of the particle shape in the "indices" array
  30878. */
  30879. indicesLength: number;
  30880. /**
  30881. * Squared distance from the particle to the camera
  30882. */
  30883. sqDistance: number;
  30884. /**
  30885. * Material index when used with MultiMaterials
  30886. */
  30887. materialIndex: number;
  30888. /**
  30889. * Creates a new sorted particle
  30890. * @param materialIndex
  30891. */
  30892. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30893. }
  30894. /**
  30895. * Represents a solid particle vertex
  30896. */
  30897. export class SolidParticleVertex {
  30898. /**
  30899. * Vertex position
  30900. */
  30901. position: Vector3;
  30902. /**
  30903. * Vertex color
  30904. */
  30905. color: Color4;
  30906. /**
  30907. * Vertex UV
  30908. */
  30909. uv: Vector2;
  30910. /**
  30911. * Creates a new solid particle vertex
  30912. */
  30913. constructor();
  30914. /** Vertex x coordinate */
  30915. get x(): number;
  30916. set x(val: number);
  30917. /** Vertex y coordinate */
  30918. get y(): number;
  30919. set y(val: number);
  30920. /** Vertex z coordinate */
  30921. get z(): number;
  30922. set z(val: number);
  30923. }
  30924. }
  30925. declare module BABYLON {
  30926. /**
  30927. * @hidden
  30928. */
  30929. export class _MeshCollisionData {
  30930. _checkCollisions: boolean;
  30931. _collisionMask: number;
  30932. _collisionGroup: number;
  30933. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30934. _collider: Nullable<Collider>;
  30935. _oldPositionForCollisions: Vector3;
  30936. _diffPositionForCollisions: Vector3;
  30937. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30938. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30939. }
  30940. }
  30941. declare module BABYLON {
  30942. /** @hidden */
  30943. class _FacetDataStorage {
  30944. facetPositions: Vector3[];
  30945. facetNormals: Vector3[];
  30946. facetPartitioning: number[][];
  30947. facetNb: number;
  30948. partitioningSubdivisions: number;
  30949. partitioningBBoxRatio: number;
  30950. facetDataEnabled: boolean;
  30951. facetParameters: any;
  30952. bbSize: Vector3;
  30953. subDiv: {
  30954. max: number;
  30955. X: number;
  30956. Y: number;
  30957. Z: number;
  30958. };
  30959. facetDepthSort: boolean;
  30960. facetDepthSortEnabled: boolean;
  30961. depthSortedIndices: IndicesArray;
  30962. depthSortedFacets: {
  30963. ind: number;
  30964. sqDistance: number;
  30965. }[];
  30966. facetDepthSortFunction: (f1: {
  30967. ind: number;
  30968. sqDistance: number;
  30969. }, f2: {
  30970. ind: number;
  30971. sqDistance: number;
  30972. }) => number;
  30973. facetDepthSortFrom: Vector3;
  30974. facetDepthSortOrigin: Vector3;
  30975. invertedMatrix: Matrix;
  30976. }
  30977. /**
  30978. * @hidden
  30979. **/
  30980. class _InternalAbstractMeshDataInfo {
  30981. _hasVertexAlpha: boolean;
  30982. _useVertexColors: boolean;
  30983. _numBoneInfluencers: number;
  30984. _applyFog: boolean;
  30985. _receiveShadows: boolean;
  30986. _facetData: _FacetDataStorage;
  30987. _visibility: number;
  30988. _skeleton: Nullable<Skeleton>;
  30989. _layerMask: number;
  30990. _computeBonesUsingShaders: boolean;
  30991. _isActive: boolean;
  30992. _onlyForInstances: boolean;
  30993. _isActiveIntermediate: boolean;
  30994. _onlyForInstancesIntermediate: boolean;
  30995. _actAsRegularMesh: boolean;
  30996. }
  30997. /**
  30998. * Class used to store all common mesh properties
  30999. */
  31000. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31001. /** No occlusion */
  31002. static OCCLUSION_TYPE_NONE: number;
  31003. /** Occlusion set to optimisitic */
  31004. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31005. /** Occlusion set to strict */
  31006. static OCCLUSION_TYPE_STRICT: number;
  31007. /** Use an accurante occlusion algorithm */
  31008. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31009. /** Use a conservative occlusion algorithm */
  31010. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31011. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31012. * Test order :
  31013. * Is the bounding sphere outside the frustum ?
  31014. * If not, are the bounding box vertices outside the frustum ?
  31015. * It not, then the cullable object is in the frustum.
  31016. */
  31017. static readonly CULLINGSTRATEGY_STANDARD: number;
  31018. /** Culling strategy : Bounding Sphere Only.
  31019. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31020. * It's also less accurate than the standard because some not visible objects can still be selected.
  31021. * Test : is the bounding sphere outside the frustum ?
  31022. * If not, then the cullable object is in the frustum.
  31023. */
  31024. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31025. /** Culling strategy : Optimistic Inclusion.
  31026. * This in an inclusion test first, then the standard exclusion test.
  31027. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31028. * 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.
  31029. * Anyway, it's as accurate as the standard strategy.
  31030. * Test :
  31031. * Is the cullable object bounding sphere center in the frustum ?
  31032. * If not, apply the default culling strategy.
  31033. */
  31034. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31035. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31036. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31037. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31038. * 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.
  31039. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31040. * Test :
  31041. * Is the cullable object bounding sphere center in the frustum ?
  31042. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31043. */
  31044. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31045. /**
  31046. * No billboard
  31047. */
  31048. static get BILLBOARDMODE_NONE(): number;
  31049. /** Billboard on X axis */
  31050. static get BILLBOARDMODE_X(): number;
  31051. /** Billboard on Y axis */
  31052. static get BILLBOARDMODE_Y(): number;
  31053. /** Billboard on Z axis */
  31054. static get BILLBOARDMODE_Z(): number;
  31055. /** Billboard on all axes */
  31056. static get BILLBOARDMODE_ALL(): number;
  31057. /** Billboard on using position instead of orientation */
  31058. static get BILLBOARDMODE_USE_POSITION(): number;
  31059. /** @hidden */
  31060. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31061. /**
  31062. * The culling strategy to use to check whether the mesh must be rendered or not.
  31063. * This value can be changed at any time and will be used on the next render mesh selection.
  31064. * The possible values are :
  31065. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31066. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31067. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31068. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31069. * Please read each static variable documentation to get details about the culling process.
  31070. * */
  31071. cullingStrategy: number;
  31072. /**
  31073. * Gets the number of facets in the mesh
  31074. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31075. */
  31076. get facetNb(): number;
  31077. /**
  31078. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31079. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31080. */
  31081. get partitioningSubdivisions(): number;
  31082. set partitioningSubdivisions(nb: number);
  31083. /**
  31084. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31085. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31086. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31087. */
  31088. get partitioningBBoxRatio(): number;
  31089. set partitioningBBoxRatio(ratio: number);
  31090. /**
  31091. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31092. * Works only for updatable meshes.
  31093. * Doesn't work with multi-materials
  31094. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31095. */
  31096. get mustDepthSortFacets(): boolean;
  31097. set mustDepthSortFacets(sort: boolean);
  31098. /**
  31099. * The location (Vector3) where the facet depth sort must be computed from.
  31100. * By default, the active camera position.
  31101. * Used only when facet depth sort is enabled
  31102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31103. */
  31104. get facetDepthSortFrom(): Vector3;
  31105. set facetDepthSortFrom(location: Vector3);
  31106. /**
  31107. * gets a boolean indicating if facetData is enabled
  31108. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31109. */
  31110. get isFacetDataEnabled(): boolean;
  31111. /** @hidden */
  31112. _updateNonUniformScalingState(value: boolean): boolean;
  31113. /**
  31114. * An event triggered when this mesh collides with another one
  31115. */
  31116. onCollideObservable: Observable<AbstractMesh>;
  31117. /** Set a function to call when this mesh collides with another one */
  31118. set onCollide(callback: () => void);
  31119. /**
  31120. * An event triggered when the collision's position changes
  31121. */
  31122. onCollisionPositionChangeObservable: Observable<Vector3>;
  31123. /** Set a function to call when the collision's position changes */
  31124. set onCollisionPositionChange(callback: () => void);
  31125. /**
  31126. * An event triggered when material is changed
  31127. */
  31128. onMaterialChangedObservable: Observable<AbstractMesh>;
  31129. /**
  31130. * Gets or sets the orientation for POV movement & rotation
  31131. */
  31132. definedFacingForward: boolean;
  31133. /** @hidden */
  31134. _occlusionQuery: Nullable<WebGLQuery>;
  31135. /** @hidden */
  31136. _renderingGroup: Nullable<RenderingGroup>;
  31137. /**
  31138. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31139. */
  31140. get visibility(): number;
  31141. /**
  31142. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31143. */
  31144. set visibility(value: number);
  31145. /** Gets or sets the alpha index used to sort transparent meshes
  31146. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31147. */
  31148. alphaIndex: number;
  31149. /**
  31150. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31151. */
  31152. isVisible: boolean;
  31153. /**
  31154. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31155. */
  31156. isPickable: boolean;
  31157. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31158. showSubMeshesBoundingBox: boolean;
  31159. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31160. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31161. */
  31162. isBlocker: boolean;
  31163. /**
  31164. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31165. */
  31166. enablePointerMoveEvents: boolean;
  31167. /**
  31168. * Specifies the rendering group id for this mesh (0 by default)
  31169. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31170. */
  31171. renderingGroupId: number;
  31172. private _material;
  31173. /** Gets or sets current material */
  31174. get material(): Nullable<Material>;
  31175. set material(value: Nullable<Material>);
  31176. /**
  31177. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31178. * @see https://doc.babylonjs.com/babylon101/shadows
  31179. */
  31180. get receiveShadows(): boolean;
  31181. set receiveShadows(value: boolean);
  31182. /** Defines color to use when rendering outline */
  31183. outlineColor: Color3;
  31184. /** Define width to use when rendering outline */
  31185. outlineWidth: number;
  31186. /** Defines color to use when rendering overlay */
  31187. overlayColor: Color3;
  31188. /** Defines alpha to use when rendering overlay */
  31189. overlayAlpha: number;
  31190. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31191. get hasVertexAlpha(): boolean;
  31192. set hasVertexAlpha(value: boolean);
  31193. /** 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) */
  31194. get useVertexColors(): boolean;
  31195. set useVertexColors(value: boolean);
  31196. /**
  31197. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31198. */
  31199. get computeBonesUsingShaders(): boolean;
  31200. set computeBonesUsingShaders(value: boolean);
  31201. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31202. get numBoneInfluencers(): number;
  31203. set numBoneInfluencers(value: number);
  31204. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31205. get applyFog(): boolean;
  31206. set applyFog(value: boolean);
  31207. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31208. useOctreeForRenderingSelection: boolean;
  31209. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31210. useOctreeForPicking: boolean;
  31211. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31212. useOctreeForCollisions: boolean;
  31213. /**
  31214. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31215. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31216. */
  31217. get layerMask(): number;
  31218. set layerMask(value: number);
  31219. /**
  31220. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31221. */
  31222. alwaysSelectAsActiveMesh: boolean;
  31223. /**
  31224. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31225. */
  31226. doNotSyncBoundingInfo: boolean;
  31227. /**
  31228. * Gets or sets the current action manager
  31229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31230. */
  31231. actionManager: Nullable<AbstractActionManager>;
  31232. private _meshCollisionData;
  31233. /**
  31234. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31235. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31236. */
  31237. ellipsoid: Vector3;
  31238. /**
  31239. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31240. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31241. */
  31242. ellipsoidOffset: Vector3;
  31243. /**
  31244. * Gets or sets a collision mask used to mask collisions (default is -1).
  31245. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31246. */
  31247. get collisionMask(): number;
  31248. set collisionMask(mask: number);
  31249. /**
  31250. * Gets or sets the current collision group mask (-1 by default).
  31251. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31252. */
  31253. get collisionGroup(): number;
  31254. set collisionGroup(mask: number);
  31255. /**
  31256. * Gets or sets current surrounding meshes (null by default).
  31257. *
  31258. * By default collision detection is tested against every mesh in the scene.
  31259. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31260. * meshes will be tested for the collision.
  31261. *
  31262. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31263. */
  31264. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31265. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31266. /**
  31267. * Defines edge width used when edgesRenderer is enabled
  31268. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31269. */
  31270. edgesWidth: number;
  31271. /**
  31272. * Defines edge color used when edgesRenderer is enabled
  31273. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31274. */
  31275. edgesColor: Color4;
  31276. /** @hidden */
  31277. _edgesRenderer: Nullable<IEdgesRenderer>;
  31278. /** @hidden */
  31279. _masterMesh: Nullable<AbstractMesh>;
  31280. /** @hidden */
  31281. _boundingInfo: Nullable<BoundingInfo>;
  31282. /** @hidden */
  31283. _renderId: number;
  31284. /**
  31285. * Gets or sets the list of subMeshes
  31286. * @see https://doc.babylonjs.com/how_to/multi_materials
  31287. */
  31288. subMeshes: SubMesh[];
  31289. /** @hidden */
  31290. _intersectionsInProgress: AbstractMesh[];
  31291. /** @hidden */
  31292. _unIndexed: boolean;
  31293. /** @hidden */
  31294. _lightSources: Light[];
  31295. /** Gets the list of lights affecting that mesh */
  31296. get lightSources(): Light[];
  31297. /** @hidden */
  31298. get _positions(): Nullable<Vector3[]>;
  31299. /** @hidden */
  31300. _waitingData: {
  31301. lods: Nullable<any>;
  31302. actions: Nullable<any>;
  31303. freezeWorldMatrix: Nullable<boolean>;
  31304. };
  31305. /** @hidden */
  31306. _bonesTransformMatrices: Nullable<Float32Array>;
  31307. /** @hidden */
  31308. _transformMatrixTexture: Nullable<RawTexture>;
  31309. /**
  31310. * Gets or sets a skeleton to apply skining transformations
  31311. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31312. */
  31313. set skeleton(value: Nullable<Skeleton>);
  31314. get skeleton(): Nullable<Skeleton>;
  31315. /**
  31316. * An event triggered when the mesh is rebuilt.
  31317. */
  31318. onRebuildObservable: Observable<AbstractMesh>;
  31319. /**
  31320. * Creates a new AbstractMesh
  31321. * @param name defines the name of the mesh
  31322. * @param scene defines the hosting scene
  31323. */
  31324. constructor(name: string, scene?: Nullable<Scene>);
  31325. /**
  31326. * Returns the string "AbstractMesh"
  31327. * @returns "AbstractMesh"
  31328. */
  31329. getClassName(): string;
  31330. /**
  31331. * Gets a string representation of the current mesh
  31332. * @param fullDetails defines a boolean indicating if full details must be included
  31333. * @returns a string representation of the current mesh
  31334. */
  31335. toString(fullDetails?: boolean): string;
  31336. /**
  31337. * @hidden
  31338. */
  31339. protected _getEffectiveParent(): Nullable<Node>;
  31340. /** @hidden */
  31341. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31342. /** @hidden */
  31343. _rebuild(): void;
  31344. /** @hidden */
  31345. _resyncLightSources(): void;
  31346. /** @hidden */
  31347. _resyncLightSource(light: Light): void;
  31348. /** @hidden */
  31349. _unBindEffect(): void;
  31350. /** @hidden */
  31351. _removeLightSource(light: Light, dispose: boolean): void;
  31352. private _markSubMeshesAsDirty;
  31353. /** @hidden */
  31354. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31355. /** @hidden */
  31356. _markSubMeshesAsAttributesDirty(): void;
  31357. /** @hidden */
  31358. _markSubMeshesAsMiscDirty(): void;
  31359. /**
  31360. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31361. */
  31362. get scaling(): Vector3;
  31363. set scaling(newScaling: Vector3);
  31364. /**
  31365. * Returns true if the mesh is blocked. Implemented by child classes
  31366. */
  31367. get isBlocked(): boolean;
  31368. /**
  31369. * Returns the mesh itself by default. Implemented by child classes
  31370. * @param camera defines the camera to use to pick the right LOD level
  31371. * @returns the currentAbstractMesh
  31372. */
  31373. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31374. /**
  31375. * Returns 0 by default. Implemented by child classes
  31376. * @returns an integer
  31377. */
  31378. getTotalVertices(): number;
  31379. /**
  31380. * Returns a positive integer : the total number of indices in this mesh geometry.
  31381. * @returns the numner of indices or zero if the mesh has no geometry.
  31382. */
  31383. getTotalIndices(): number;
  31384. /**
  31385. * Returns null by default. Implemented by child classes
  31386. * @returns null
  31387. */
  31388. getIndices(): Nullable<IndicesArray>;
  31389. /**
  31390. * Returns the array of the requested vertex data kind. Implemented by child classes
  31391. * @param kind defines the vertex data kind to use
  31392. * @returns null
  31393. */
  31394. getVerticesData(kind: string): Nullable<FloatArray>;
  31395. /**
  31396. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31397. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31398. * Note that a new underlying VertexBuffer object is created each call.
  31399. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31400. * @param kind defines vertex data kind:
  31401. * * VertexBuffer.PositionKind
  31402. * * VertexBuffer.UVKind
  31403. * * VertexBuffer.UV2Kind
  31404. * * VertexBuffer.UV3Kind
  31405. * * VertexBuffer.UV4Kind
  31406. * * VertexBuffer.UV5Kind
  31407. * * VertexBuffer.UV6Kind
  31408. * * VertexBuffer.ColorKind
  31409. * * VertexBuffer.MatricesIndicesKind
  31410. * * VertexBuffer.MatricesIndicesExtraKind
  31411. * * VertexBuffer.MatricesWeightsKind
  31412. * * VertexBuffer.MatricesWeightsExtraKind
  31413. * @param data defines the data source
  31414. * @param updatable defines if the data must be flagged as updatable (or static)
  31415. * @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
  31416. * @returns the current mesh
  31417. */
  31418. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31419. /**
  31420. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31421. * If the mesh has no geometry, it is simply returned as it is.
  31422. * @param kind defines vertex data kind:
  31423. * * VertexBuffer.PositionKind
  31424. * * VertexBuffer.UVKind
  31425. * * VertexBuffer.UV2Kind
  31426. * * VertexBuffer.UV3Kind
  31427. * * VertexBuffer.UV4Kind
  31428. * * VertexBuffer.UV5Kind
  31429. * * VertexBuffer.UV6Kind
  31430. * * VertexBuffer.ColorKind
  31431. * * VertexBuffer.MatricesIndicesKind
  31432. * * VertexBuffer.MatricesIndicesExtraKind
  31433. * * VertexBuffer.MatricesWeightsKind
  31434. * * VertexBuffer.MatricesWeightsExtraKind
  31435. * @param data defines the data source
  31436. * @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
  31437. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31438. * @returns the current mesh
  31439. */
  31440. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31441. /**
  31442. * Sets the mesh indices,
  31443. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31444. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31445. * @param totalVertices Defines the total number of vertices
  31446. * @returns the current mesh
  31447. */
  31448. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31449. /**
  31450. * Gets a boolean indicating if specific vertex data is present
  31451. * @param kind defines the vertex data kind to use
  31452. * @returns true is data kind is present
  31453. */
  31454. isVerticesDataPresent(kind: string): boolean;
  31455. /**
  31456. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31457. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31458. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31459. * @returns a BoundingInfo
  31460. */
  31461. getBoundingInfo(): BoundingInfo;
  31462. /**
  31463. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31464. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31465. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31466. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31467. * @returns the current mesh
  31468. */
  31469. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31470. /**
  31471. * Overwrite the current bounding info
  31472. * @param boundingInfo defines the new bounding info
  31473. * @returns the current mesh
  31474. */
  31475. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31476. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31477. get useBones(): boolean;
  31478. /** @hidden */
  31479. _preActivate(): void;
  31480. /** @hidden */
  31481. _preActivateForIntermediateRendering(renderId: number): void;
  31482. /** @hidden */
  31483. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31484. /** @hidden */
  31485. _postActivate(): void;
  31486. /** @hidden */
  31487. _freeze(): void;
  31488. /** @hidden */
  31489. _unFreeze(): void;
  31490. /**
  31491. * Gets the current world matrix
  31492. * @returns a Matrix
  31493. */
  31494. getWorldMatrix(): Matrix;
  31495. /** @hidden */
  31496. _getWorldMatrixDeterminant(): number;
  31497. /**
  31498. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31499. */
  31500. get isAnInstance(): boolean;
  31501. /**
  31502. * Gets a boolean indicating if this mesh has instances
  31503. */
  31504. get hasInstances(): boolean;
  31505. /**
  31506. * Gets a boolean indicating if this mesh has thin instances
  31507. */
  31508. get hasThinInstances(): boolean;
  31509. /**
  31510. * Perform relative position change from the point of view of behind the front of the mesh.
  31511. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31512. * Supports definition of mesh facing forward or backward
  31513. * @param amountRight defines the distance on the right axis
  31514. * @param amountUp defines the distance on the up axis
  31515. * @param amountForward defines the distance on the forward axis
  31516. * @returns the current mesh
  31517. */
  31518. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31519. /**
  31520. * Calculate relative position change from the point of view of behind the front of the mesh.
  31521. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31522. * Supports definition of mesh facing forward or backward
  31523. * @param amountRight defines the distance on the right axis
  31524. * @param amountUp defines the distance on the up axis
  31525. * @param amountForward defines the distance on the forward axis
  31526. * @returns the new displacement vector
  31527. */
  31528. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31529. /**
  31530. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31531. * Supports definition of mesh facing forward or backward
  31532. * @param flipBack defines the flip
  31533. * @param twirlClockwise defines the twirl
  31534. * @param tiltRight defines the tilt
  31535. * @returns the current mesh
  31536. */
  31537. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31538. /**
  31539. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31540. * Supports definition of mesh facing forward or backward.
  31541. * @param flipBack defines the flip
  31542. * @param twirlClockwise defines the twirl
  31543. * @param tiltRight defines the tilt
  31544. * @returns the new rotation vector
  31545. */
  31546. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31547. /**
  31548. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31549. * This means the mesh underlying bounding box and sphere are recomputed.
  31550. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31551. * @returns the current mesh
  31552. */
  31553. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31554. /** @hidden */
  31555. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31556. /** @hidden */
  31557. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31558. /** @hidden */
  31559. _updateBoundingInfo(): AbstractMesh;
  31560. /** @hidden */
  31561. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31562. /** @hidden */
  31563. protected _afterComputeWorldMatrix(): void;
  31564. /** @hidden */
  31565. get _effectiveMesh(): AbstractMesh;
  31566. /**
  31567. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31568. * A mesh is in the frustum if its bounding box intersects the frustum
  31569. * @param frustumPlanes defines the frustum to test
  31570. * @returns true if the mesh is in the frustum planes
  31571. */
  31572. isInFrustum(frustumPlanes: Plane[]): boolean;
  31573. /**
  31574. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31575. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31576. * @param frustumPlanes defines the frustum to test
  31577. * @returns true if the mesh is completely in the frustum planes
  31578. */
  31579. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31580. /**
  31581. * True if the mesh intersects another mesh or a SolidParticle object
  31582. * @param mesh defines a target mesh or SolidParticle to test
  31583. * @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)
  31584. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31585. * @returns true if there is an intersection
  31586. */
  31587. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31588. /**
  31589. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31590. * @param point defines the point to test
  31591. * @returns true if there is an intersection
  31592. */
  31593. intersectsPoint(point: Vector3): boolean;
  31594. /**
  31595. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31596. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31597. */
  31598. get checkCollisions(): boolean;
  31599. set checkCollisions(collisionEnabled: boolean);
  31600. /**
  31601. * Gets Collider object used to compute collisions (not physics)
  31602. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31603. */
  31604. get collider(): Nullable<Collider>;
  31605. /**
  31606. * Move the mesh using collision engine
  31607. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31608. * @param displacement defines the requested displacement vector
  31609. * @returns the current mesh
  31610. */
  31611. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31612. private _onCollisionPositionChange;
  31613. /** @hidden */
  31614. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31615. /** @hidden */
  31616. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31617. /** @hidden */
  31618. _checkCollision(collider: Collider): AbstractMesh;
  31619. /** @hidden */
  31620. _generatePointsArray(): boolean;
  31621. /**
  31622. * Checks if the passed Ray intersects with the mesh
  31623. * @param ray defines the ray to use
  31624. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31625. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31626. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31627. * @returns the picking info
  31628. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31629. */
  31630. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31631. /**
  31632. * Clones the current mesh
  31633. * @param name defines the mesh name
  31634. * @param newParent defines the new mesh parent
  31635. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31636. * @returns the new mesh
  31637. */
  31638. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31639. /**
  31640. * Disposes all the submeshes of the current meshnp
  31641. * @returns the current mesh
  31642. */
  31643. releaseSubMeshes(): AbstractMesh;
  31644. /**
  31645. * Releases resources associated with this abstract mesh.
  31646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31648. */
  31649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31650. /**
  31651. * Adds the passed mesh as a child to the current mesh
  31652. * @param mesh defines the child mesh
  31653. * @returns the current mesh
  31654. */
  31655. addChild(mesh: AbstractMesh): AbstractMesh;
  31656. /**
  31657. * Removes the passed mesh from the current mesh children list
  31658. * @param mesh defines the child mesh
  31659. * @returns the current mesh
  31660. */
  31661. removeChild(mesh: AbstractMesh): AbstractMesh;
  31662. /** @hidden */
  31663. private _initFacetData;
  31664. /**
  31665. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31666. * This method can be called within the render loop.
  31667. * 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
  31668. * @returns the current mesh
  31669. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31670. */
  31671. updateFacetData(): AbstractMesh;
  31672. /**
  31673. * Returns the facetLocalNormals array.
  31674. * The normals are expressed in the mesh local spac
  31675. * @returns an array of Vector3
  31676. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31677. */
  31678. getFacetLocalNormals(): Vector3[];
  31679. /**
  31680. * Returns the facetLocalPositions array.
  31681. * The facet positions are expressed in the mesh local space
  31682. * @returns an array of Vector3
  31683. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31684. */
  31685. getFacetLocalPositions(): Vector3[];
  31686. /**
  31687. * Returns the facetLocalPartioning array
  31688. * @returns an array of array of numbers
  31689. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31690. */
  31691. getFacetLocalPartitioning(): number[][];
  31692. /**
  31693. * Returns the i-th facet position in the world system.
  31694. * This method allocates a new Vector3 per call
  31695. * @param i defines the facet index
  31696. * @returns a new Vector3
  31697. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31698. */
  31699. getFacetPosition(i: number): Vector3;
  31700. /**
  31701. * Sets the reference Vector3 with the i-th facet position in the world system
  31702. * @param i defines the facet index
  31703. * @param ref defines the target vector
  31704. * @returns the current mesh
  31705. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31706. */
  31707. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31708. /**
  31709. * Returns the i-th facet normal in the world system.
  31710. * This method allocates a new Vector3 per call
  31711. * @param i defines the facet index
  31712. * @returns a new Vector3
  31713. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31714. */
  31715. getFacetNormal(i: number): Vector3;
  31716. /**
  31717. * Sets the reference Vector3 with the i-th facet normal in the world system
  31718. * @param i defines the facet index
  31719. * @param ref defines the target vector
  31720. * @returns the current mesh
  31721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31722. */
  31723. getFacetNormalToRef(i: number, ref: Vector3): this;
  31724. /**
  31725. * 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)
  31726. * @param x defines x coordinate
  31727. * @param y defines y coordinate
  31728. * @param z defines z coordinate
  31729. * @returns the array of facet indexes
  31730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31731. */
  31732. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31733. /**
  31734. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31735. * @param projected sets as the (x,y,z) world projection on the facet
  31736. * @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
  31737. * @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
  31738. * @param x defines x coordinate
  31739. * @param y defines y coordinate
  31740. * @param z defines z coordinate
  31741. * @returns the face index if found (or null instead)
  31742. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31743. */
  31744. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31745. /**
  31746. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31747. * @param projected sets as the (x,y,z) local projection on the facet
  31748. * @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
  31749. * @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
  31750. * @param x defines x coordinate
  31751. * @param y defines y coordinate
  31752. * @param z defines z coordinate
  31753. * @returns the face index if found (or null instead)
  31754. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31755. */
  31756. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31757. /**
  31758. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31759. * @returns the parameters
  31760. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31761. */
  31762. getFacetDataParameters(): any;
  31763. /**
  31764. * Disables the feature FacetData and frees the related memory
  31765. * @returns the current mesh
  31766. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31767. */
  31768. disableFacetData(): AbstractMesh;
  31769. /**
  31770. * Updates the AbstractMesh indices array
  31771. * @param indices defines the data source
  31772. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31773. * @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)
  31774. * @returns the current mesh
  31775. */
  31776. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31777. /**
  31778. * Creates new normals data for the mesh
  31779. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31780. * @returns the current mesh
  31781. */
  31782. createNormals(updatable: boolean): AbstractMesh;
  31783. /**
  31784. * Align the mesh with a normal
  31785. * @param normal defines the normal to use
  31786. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31787. * @returns the current mesh
  31788. */
  31789. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31790. /** @hidden */
  31791. _checkOcclusionQuery(): boolean;
  31792. /**
  31793. * Disables the mesh edge rendering mode
  31794. * @returns the currentAbstractMesh
  31795. */
  31796. disableEdgesRendering(): AbstractMesh;
  31797. /**
  31798. * Enables the edge rendering mode on the mesh.
  31799. * This mode makes the mesh edges visible
  31800. * @param epsilon defines the maximal distance between two angles to detect a face
  31801. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31802. * @returns the currentAbstractMesh
  31803. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31804. */
  31805. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31806. /**
  31807. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  31808. * @returns an array of particle systems in the scene that use the mesh as an emitter
  31809. */
  31810. getConnectedParticleSystems(): IParticleSystem[];
  31811. }
  31812. }
  31813. declare module BABYLON {
  31814. /**
  31815. * Interface used to define ActionEvent
  31816. */
  31817. export interface IActionEvent {
  31818. /** The mesh or sprite that triggered the action */
  31819. source: any;
  31820. /** The X mouse cursor position at the time of the event */
  31821. pointerX: number;
  31822. /** The Y mouse cursor position at the time of the event */
  31823. pointerY: number;
  31824. /** The mesh that is currently pointed at (can be null) */
  31825. meshUnderPointer: Nullable<AbstractMesh>;
  31826. /** the original (browser) event that triggered the ActionEvent */
  31827. sourceEvent?: any;
  31828. /** additional data for the event */
  31829. additionalData?: any;
  31830. }
  31831. /**
  31832. * ActionEvent is the event being sent when an action is triggered.
  31833. */
  31834. export class ActionEvent implements IActionEvent {
  31835. /** The mesh or sprite that triggered the action */
  31836. source: any;
  31837. /** The X mouse cursor position at the time of the event */
  31838. pointerX: number;
  31839. /** The Y mouse cursor position at the time of the event */
  31840. pointerY: number;
  31841. /** The mesh that is currently pointed at (can be null) */
  31842. meshUnderPointer: Nullable<AbstractMesh>;
  31843. /** the original (browser) event that triggered the ActionEvent */
  31844. sourceEvent?: any;
  31845. /** additional data for the event */
  31846. additionalData?: any;
  31847. /**
  31848. * Creates a new ActionEvent
  31849. * @param source The mesh or sprite that triggered the action
  31850. * @param pointerX The X mouse cursor position at the time of the event
  31851. * @param pointerY The Y mouse cursor position at the time of the event
  31852. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31853. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31854. * @param additionalData additional data for the event
  31855. */
  31856. constructor(
  31857. /** The mesh or sprite that triggered the action */
  31858. source: any,
  31859. /** The X mouse cursor position at the time of the event */
  31860. pointerX: number,
  31861. /** The Y mouse cursor position at the time of the event */
  31862. pointerY: number,
  31863. /** The mesh that is currently pointed at (can be null) */
  31864. meshUnderPointer: Nullable<AbstractMesh>,
  31865. /** the original (browser) event that triggered the ActionEvent */
  31866. sourceEvent?: any,
  31867. /** additional data for the event */
  31868. additionalData?: any);
  31869. /**
  31870. * Helper function to auto-create an ActionEvent from a source mesh.
  31871. * @param source The source mesh that triggered the event
  31872. * @param evt The original (browser) event
  31873. * @param additionalData additional data for the event
  31874. * @returns the new ActionEvent
  31875. */
  31876. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31877. /**
  31878. * Helper function to auto-create an ActionEvent from a source sprite
  31879. * @param source The source sprite that triggered the event
  31880. * @param scene Scene associated with the sprite
  31881. * @param evt The original (browser) event
  31882. * @param additionalData additional data for the event
  31883. * @returns the new ActionEvent
  31884. */
  31885. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31886. /**
  31887. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31888. * @param scene the scene where the event occurred
  31889. * @param evt The original (browser) event
  31890. * @returns the new ActionEvent
  31891. */
  31892. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31893. /**
  31894. * Helper function to auto-create an ActionEvent from a primitive
  31895. * @param prim defines the target primitive
  31896. * @param pointerPos defines the pointer position
  31897. * @param evt The original (browser) event
  31898. * @param additionalData additional data for the event
  31899. * @returns the new ActionEvent
  31900. */
  31901. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31902. }
  31903. }
  31904. declare module BABYLON {
  31905. /**
  31906. * Abstract class used to decouple action Manager from scene and meshes.
  31907. * Do not instantiate.
  31908. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31909. */
  31910. export abstract class AbstractActionManager implements IDisposable {
  31911. /** Gets the list of active triggers */
  31912. static Triggers: {
  31913. [key: string]: number;
  31914. };
  31915. /** Gets the cursor to use when hovering items */
  31916. hoverCursor: string;
  31917. /** Gets the list of actions */
  31918. actions: IAction[];
  31919. /**
  31920. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31921. */
  31922. isRecursive: boolean;
  31923. /**
  31924. * Releases all associated resources
  31925. */
  31926. abstract dispose(): void;
  31927. /**
  31928. * Does this action manager has pointer triggers
  31929. */
  31930. abstract get hasPointerTriggers(): boolean;
  31931. /**
  31932. * Does this action manager has pick triggers
  31933. */
  31934. abstract get hasPickTriggers(): boolean;
  31935. /**
  31936. * Process a specific trigger
  31937. * @param trigger defines the trigger to process
  31938. * @param evt defines the event details to be processed
  31939. */
  31940. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31941. /**
  31942. * Does this action manager handles actions of any of the given triggers
  31943. * @param triggers defines the triggers to be tested
  31944. * @return a boolean indicating whether one (or more) of the triggers is handled
  31945. */
  31946. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31947. /**
  31948. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31949. * speed.
  31950. * @param triggerA defines the trigger to be tested
  31951. * @param triggerB defines the trigger to be tested
  31952. * @return a boolean indicating whether one (or more) of the triggers is handled
  31953. */
  31954. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31955. /**
  31956. * Does this action manager handles actions of a given trigger
  31957. * @param trigger defines the trigger to be tested
  31958. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31959. * @return whether the trigger is handled
  31960. */
  31961. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31962. /**
  31963. * Serialize this manager to a JSON object
  31964. * @param name defines the property name to store this manager
  31965. * @returns a JSON representation of this manager
  31966. */
  31967. abstract serialize(name: string): any;
  31968. /**
  31969. * Registers an action to this action manager
  31970. * @param action defines the action to be registered
  31971. * @return the action amended (prepared) after registration
  31972. */
  31973. abstract registerAction(action: IAction): Nullable<IAction>;
  31974. /**
  31975. * Unregisters an action to this action manager
  31976. * @param action defines the action to be unregistered
  31977. * @return a boolean indicating whether the action has been unregistered
  31978. */
  31979. abstract unregisterAction(action: IAction): Boolean;
  31980. /**
  31981. * Does exist one action manager with at least one trigger
  31982. **/
  31983. static get HasTriggers(): boolean;
  31984. /**
  31985. * Does exist one action manager with at least one pick trigger
  31986. **/
  31987. static get HasPickTriggers(): boolean;
  31988. /**
  31989. * Does exist one action manager that handles actions of a given trigger
  31990. * @param trigger defines the trigger to be tested
  31991. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31992. **/
  31993. static HasSpecificTrigger(trigger: number): boolean;
  31994. }
  31995. }
  31996. declare module BABYLON {
  31997. /**
  31998. * Defines how a node can be built from a string name.
  31999. */
  32000. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32001. /**
  32002. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32003. */
  32004. export class Node implements IBehaviorAware<Node> {
  32005. /** @hidden */
  32006. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32007. private static _NodeConstructors;
  32008. /**
  32009. * Add a new node constructor
  32010. * @param type defines the type name of the node to construct
  32011. * @param constructorFunc defines the constructor function
  32012. */
  32013. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32014. /**
  32015. * Returns a node constructor based on type name
  32016. * @param type defines the type name
  32017. * @param name defines the new node name
  32018. * @param scene defines the hosting scene
  32019. * @param options defines optional options to transmit to constructors
  32020. * @returns the new constructor or null
  32021. */
  32022. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32023. /**
  32024. * Gets or sets the name of the node
  32025. */
  32026. name: string;
  32027. /**
  32028. * Gets or sets the id of the node
  32029. */
  32030. id: string;
  32031. /**
  32032. * Gets or sets the unique id of the node
  32033. */
  32034. uniqueId: number;
  32035. /**
  32036. * Gets or sets a string used to store user defined state for the node
  32037. */
  32038. state: string;
  32039. /**
  32040. * Gets or sets an object used to store user defined information for the node
  32041. */
  32042. metadata: any;
  32043. /**
  32044. * For internal use only. Please do not use.
  32045. */
  32046. reservedDataStore: any;
  32047. /**
  32048. * List of inspectable custom properties (used by the Inspector)
  32049. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32050. */
  32051. inspectableCustomProperties: IInspectable[];
  32052. private _doNotSerialize;
  32053. /**
  32054. * Gets or sets a boolean used to define if the node must be serialized
  32055. */
  32056. get doNotSerialize(): boolean;
  32057. set doNotSerialize(value: boolean);
  32058. /** @hidden */
  32059. _isDisposed: boolean;
  32060. /**
  32061. * Gets a list of Animations associated with the node
  32062. */
  32063. animations: Animation[];
  32064. protected _ranges: {
  32065. [name: string]: Nullable<AnimationRange>;
  32066. };
  32067. /**
  32068. * Callback raised when the node is ready to be used
  32069. */
  32070. onReady: Nullable<(node: Node) => void>;
  32071. private _isEnabled;
  32072. private _isParentEnabled;
  32073. private _isReady;
  32074. /** @hidden */
  32075. _currentRenderId: number;
  32076. private _parentUpdateId;
  32077. /** @hidden */
  32078. _childUpdateId: number;
  32079. /** @hidden */
  32080. _waitingParentId: Nullable<string>;
  32081. /** @hidden */
  32082. _scene: Scene;
  32083. /** @hidden */
  32084. _cache: any;
  32085. private _parentNode;
  32086. private _children;
  32087. /** @hidden */
  32088. _worldMatrix: Matrix;
  32089. /** @hidden */
  32090. _worldMatrixDeterminant: number;
  32091. /** @hidden */
  32092. _worldMatrixDeterminantIsDirty: boolean;
  32093. /** @hidden */
  32094. private _sceneRootNodesIndex;
  32095. /**
  32096. * Gets a boolean indicating if the node has been disposed
  32097. * @returns true if the node was disposed
  32098. */
  32099. isDisposed(): boolean;
  32100. /**
  32101. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32102. * @see https://doc.babylonjs.com/how_to/parenting
  32103. */
  32104. set parent(parent: Nullable<Node>);
  32105. get parent(): Nullable<Node>;
  32106. /** @hidden */
  32107. _addToSceneRootNodes(): void;
  32108. /** @hidden */
  32109. _removeFromSceneRootNodes(): void;
  32110. private _animationPropertiesOverride;
  32111. /**
  32112. * Gets or sets the animation properties override
  32113. */
  32114. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32115. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32116. /**
  32117. * Gets a string idenfifying the name of the class
  32118. * @returns "Node" string
  32119. */
  32120. getClassName(): string;
  32121. /** @hidden */
  32122. readonly _isNode: boolean;
  32123. /**
  32124. * An event triggered when the mesh is disposed
  32125. */
  32126. onDisposeObservable: Observable<Node>;
  32127. private _onDisposeObserver;
  32128. /**
  32129. * Sets a callback that will be raised when the node will be disposed
  32130. */
  32131. set onDispose(callback: () => void);
  32132. /**
  32133. * Creates a new Node
  32134. * @param name the name and id to be given to this node
  32135. * @param scene the scene this node will be added to
  32136. */
  32137. constructor(name: string, scene?: Nullable<Scene>);
  32138. /**
  32139. * Gets the scene of the node
  32140. * @returns a scene
  32141. */
  32142. getScene(): Scene;
  32143. /**
  32144. * Gets the engine of the node
  32145. * @returns a Engine
  32146. */
  32147. getEngine(): Engine;
  32148. private _behaviors;
  32149. /**
  32150. * Attach a behavior to the node
  32151. * @see https://doc.babylonjs.com/features/behaviour
  32152. * @param behavior defines the behavior to attach
  32153. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32154. * @returns the current Node
  32155. */
  32156. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32157. /**
  32158. * Remove an attached behavior
  32159. * @see https://doc.babylonjs.com/features/behaviour
  32160. * @param behavior defines the behavior to attach
  32161. * @returns the current Node
  32162. */
  32163. removeBehavior(behavior: Behavior<Node>): Node;
  32164. /**
  32165. * Gets the list of attached behaviors
  32166. * @see https://doc.babylonjs.com/features/behaviour
  32167. */
  32168. get behaviors(): Behavior<Node>[];
  32169. /**
  32170. * Gets an attached behavior by name
  32171. * @param name defines the name of the behavior to look for
  32172. * @see https://doc.babylonjs.com/features/behaviour
  32173. * @returns null if behavior was not found else the requested behavior
  32174. */
  32175. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32176. /**
  32177. * Returns the latest update of the World matrix
  32178. * @returns a Matrix
  32179. */
  32180. getWorldMatrix(): Matrix;
  32181. /** @hidden */
  32182. _getWorldMatrixDeterminant(): number;
  32183. /**
  32184. * Returns directly the latest state of the mesh World matrix.
  32185. * A Matrix is returned.
  32186. */
  32187. get worldMatrixFromCache(): Matrix;
  32188. /** @hidden */
  32189. _initCache(): void;
  32190. /** @hidden */
  32191. updateCache(force?: boolean): void;
  32192. /** @hidden */
  32193. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32194. /** @hidden */
  32195. _updateCache(ignoreParentClass?: boolean): void;
  32196. /** @hidden */
  32197. _isSynchronized(): boolean;
  32198. /** @hidden */
  32199. _markSyncedWithParent(): void;
  32200. /** @hidden */
  32201. isSynchronizedWithParent(): boolean;
  32202. /** @hidden */
  32203. isSynchronized(): boolean;
  32204. /**
  32205. * Is this node ready to be used/rendered
  32206. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32207. * @return true if the node is ready
  32208. */
  32209. isReady(completeCheck?: boolean): boolean;
  32210. /**
  32211. * Is this node enabled?
  32212. * 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
  32213. * @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
  32214. * @return whether this node (and its parent) is enabled
  32215. */
  32216. isEnabled(checkAncestors?: boolean): boolean;
  32217. /** @hidden */
  32218. protected _syncParentEnabledState(): void;
  32219. /**
  32220. * Set the enabled state of this node
  32221. * @param value defines the new enabled state
  32222. */
  32223. setEnabled(value: boolean): void;
  32224. /**
  32225. * Is this node a descendant of the given node?
  32226. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32227. * @param ancestor defines the parent node to inspect
  32228. * @returns a boolean indicating if this node is a descendant of the given node
  32229. */
  32230. isDescendantOf(ancestor: Node): boolean;
  32231. /** @hidden */
  32232. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32233. /**
  32234. * Will return all nodes that have this node as ascendant
  32235. * @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
  32236. * @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
  32237. * @return all children nodes of all types
  32238. */
  32239. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32240. /**
  32241. * Get all child-meshes of this node
  32242. * @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)
  32243. * @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
  32244. * @returns an array of AbstractMesh
  32245. */
  32246. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32247. /**
  32248. * Get all direct children of this node
  32249. * @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
  32250. * @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)
  32251. * @returns an array of Node
  32252. */
  32253. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32254. /** @hidden */
  32255. _setReady(state: boolean): void;
  32256. /**
  32257. * Get an animation by name
  32258. * @param name defines the name of the animation to look for
  32259. * @returns null if not found else the requested animation
  32260. */
  32261. getAnimationByName(name: string): Nullable<Animation>;
  32262. /**
  32263. * Creates an animation range for this node
  32264. * @param name defines the name of the range
  32265. * @param from defines the starting key
  32266. * @param to defines the end key
  32267. */
  32268. createAnimationRange(name: string, from: number, to: number): void;
  32269. /**
  32270. * Delete a specific animation range
  32271. * @param name defines the name of the range to delete
  32272. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32273. */
  32274. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32275. /**
  32276. * Get an animation range by name
  32277. * @param name defines the name of the animation range to look for
  32278. * @returns null if not found else the requested animation range
  32279. */
  32280. getAnimationRange(name: string): Nullable<AnimationRange>;
  32281. /**
  32282. * Gets the list of all animation ranges defined on this node
  32283. * @returns an array
  32284. */
  32285. getAnimationRanges(): Nullable<AnimationRange>[];
  32286. /**
  32287. * Will start the animation sequence
  32288. * @param name defines the range frames for animation sequence
  32289. * @param loop defines if the animation should loop (false by default)
  32290. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32291. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32292. * @returns the object created for this animation. If range does not exist, it will return null
  32293. */
  32294. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32295. /**
  32296. * Serialize animation ranges into a JSON compatible object
  32297. * @returns serialization object
  32298. */
  32299. serializeAnimationRanges(): any;
  32300. /**
  32301. * Computes the world matrix of the node
  32302. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32303. * @returns the world matrix
  32304. */
  32305. computeWorldMatrix(force?: boolean): Matrix;
  32306. /**
  32307. * Releases resources associated with this node.
  32308. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32309. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32310. */
  32311. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32312. /**
  32313. * Parse animation range data from a serialization object and store them into a given node
  32314. * @param node defines where to store the animation ranges
  32315. * @param parsedNode defines the serialization object to read data from
  32316. * @param scene defines the hosting scene
  32317. */
  32318. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32319. /**
  32320. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32321. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32322. * @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
  32323. * @returns the new bounding vectors
  32324. */
  32325. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32326. min: Vector3;
  32327. max: Vector3;
  32328. };
  32329. }
  32330. }
  32331. declare module BABYLON {
  32332. /**
  32333. * @hidden
  32334. */
  32335. export class _IAnimationState {
  32336. key: number;
  32337. repeatCount: number;
  32338. workValue?: any;
  32339. loopMode?: number;
  32340. offsetValue?: any;
  32341. highLimitValue?: any;
  32342. }
  32343. /**
  32344. * Class used to store any kind of animation
  32345. */
  32346. export class Animation {
  32347. /**Name of the animation */
  32348. name: string;
  32349. /**Property to animate */
  32350. targetProperty: string;
  32351. /**The frames per second of the animation */
  32352. framePerSecond: number;
  32353. /**The data type of the animation */
  32354. dataType: number;
  32355. /**The loop mode of the animation */
  32356. loopMode?: number | undefined;
  32357. /**Specifies if blending should be enabled */
  32358. enableBlending?: boolean | undefined;
  32359. /**
  32360. * Use matrix interpolation instead of using direct key value when animating matrices
  32361. */
  32362. static AllowMatricesInterpolation: boolean;
  32363. /**
  32364. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32365. */
  32366. static AllowMatrixDecomposeForInterpolation: boolean;
  32367. /** Define the Url to load snippets */
  32368. static SnippetUrl: string;
  32369. /** Snippet ID if the animation was created from the snippet server */
  32370. snippetId: string;
  32371. /**
  32372. * Stores the key frames of the animation
  32373. */
  32374. private _keys;
  32375. /**
  32376. * Stores the easing function of the animation
  32377. */
  32378. private _easingFunction;
  32379. /**
  32380. * @hidden Internal use only
  32381. */
  32382. _runtimeAnimations: RuntimeAnimation[];
  32383. /**
  32384. * The set of event that will be linked to this animation
  32385. */
  32386. private _events;
  32387. /**
  32388. * Stores an array of target property paths
  32389. */
  32390. targetPropertyPath: string[];
  32391. /**
  32392. * Stores the blending speed of the animation
  32393. */
  32394. blendingSpeed: number;
  32395. /**
  32396. * Stores the animation ranges for the animation
  32397. */
  32398. private _ranges;
  32399. /**
  32400. * @hidden Internal use
  32401. */
  32402. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32403. /**
  32404. * Sets up an animation
  32405. * @param property The property to animate
  32406. * @param animationType The animation type to apply
  32407. * @param framePerSecond The frames per second of the animation
  32408. * @param easingFunction The easing function used in the animation
  32409. * @returns The created animation
  32410. */
  32411. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32412. /**
  32413. * Create and start an animation on a node
  32414. * @param name defines the name of the global animation that will be run on all nodes
  32415. * @param node defines the root node where the animation will take place
  32416. * @param targetProperty defines property to animate
  32417. * @param framePerSecond defines the number of frame per second yo use
  32418. * @param totalFrame defines the number of frames in total
  32419. * @param from defines the initial value
  32420. * @param to defines the final value
  32421. * @param loopMode defines which loop mode you want to use (off by default)
  32422. * @param easingFunction defines the easing function to use (linear by default)
  32423. * @param onAnimationEnd defines the callback to call when animation end
  32424. * @returns the animatable created for this animation
  32425. */
  32426. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32427. /**
  32428. * Create and start an animation on a node and its descendants
  32429. * @param name defines the name of the global animation that will be run on all nodes
  32430. * @param node defines the root node where the animation will take place
  32431. * @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
  32432. * @param targetProperty defines property to animate
  32433. * @param framePerSecond defines the number of frame per second to use
  32434. * @param totalFrame defines the number of frames in total
  32435. * @param from defines the initial value
  32436. * @param to defines the final value
  32437. * @param loopMode defines which loop mode you want to use (off by default)
  32438. * @param easingFunction defines the easing function to use (linear by default)
  32439. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32440. * @returns the list of animatables created for all nodes
  32441. * @example https://www.babylonjs-playground.com/#MH0VLI
  32442. */
  32443. 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[]>;
  32444. /**
  32445. * Creates a new animation, merges it with the existing animations and starts it
  32446. * @param name Name of the animation
  32447. * @param node Node which contains the scene that begins the animations
  32448. * @param targetProperty Specifies which property to animate
  32449. * @param framePerSecond The frames per second of the animation
  32450. * @param totalFrame The total number of frames
  32451. * @param from The frame at the beginning of the animation
  32452. * @param to The frame at the end of the animation
  32453. * @param loopMode Specifies the loop mode of the animation
  32454. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32455. * @param onAnimationEnd Callback to run once the animation is complete
  32456. * @returns Nullable animation
  32457. */
  32458. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32459. /**
  32460. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32461. * @param sourceAnimation defines the Animation containing keyframes to convert
  32462. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32463. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32464. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32465. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32466. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32467. */
  32468. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32469. /**
  32470. * Transition property of an host to the target Value
  32471. * @param property The property to transition
  32472. * @param targetValue The target Value of the property
  32473. * @param host The object where the property to animate belongs
  32474. * @param scene Scene used to run the animation
  32475. * @param frameRate Framerate (in frame/s) to use
  32476. * @param transition The transition type we want to use
  32477. * @param duration The duration of the animation, in milliseconds
  32478. * @param onAnimationEnd Callback trigger at the end of the animation
  32479. * @returns Nullable animation
  32480. */
  32481. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32482. /**
  32483. * Return the array of runtime animations currently using this animation
  32484. */
  32485. get runtimeAnimations(): RuntimeAnimation[];
  32486. /**
  32487. * Specifies if any of the runtime animations are currently running
  32488. */
  32489. get hasRunningRuntimeAnimations(): boolean;
  32490. /**
  32491. * Initializes the animation
  32492. * @param name Name of the animation
  32493. * @param targetProperty Property to animate
  32494. * @param framePerSecond The frames per second of the animation
  32495. * @param dataType The data type of the animation
  32496. * @param loopMode The loop mode of the animation
  32497. * @param enableBlending Specifies if blending should be enabled
  32498. */
  32499. constructor(
  32500. /**Name of the animation */
  32501. name: string,
  32502. /**Property to animate */
  32503. targetProperty: string,
  32504. /**The frames per second of the animation */
  32505. framePerSecond: number,
  32506. /**The data type of the animation */
  32507. dataType: number,
  32508. /**The loop mode of the animation */
  32509. loopMode?: number | undefined,
  32510. /**Specifies if blending should be enabled */
  32511. enableBlending?: boolean | undefined);
  32512. /**
  32513. * Converts the animation to a string
  32514. * @param fullDetails support for multiple levels of logging within scene loading
  32515. * @returns String form of the animation
  32516. */
  32517. toString(fullDetails?: boolean): string;
  32518. /**
  32519. * Add an event to this animation
  32520. * @param event Event to add
  32521. */
  32522. addEvent(event: AnimationEvent): void;
  32523. /**
  32524. * Remove all events found at the given frame
  32525. * @param frame The frame to remove events from
  32526. */
  32527. removeEvents(frame: number): void;
  32528. /**
  32529. * Retrieves all the events from the animation
  32530. * @returns Events from the animation
  32531. */
  32532. getEvents(): AnimationEvent[];
  32533. /**
  32534. * Creates an animation range
  32535. * @param name Name of the animation range
  32536. * @param from Starting frame of the animation range
  32537. * @param to Ending frame of the animation
  32538. */
  32539. createRange(name: string, from: number, to: number): void;
  32540. /**
  32541. * Deletes an animation range by name
  32542. * @param name Name of the animation range to delete
  32543. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32544. */
  32545. deleteRange(name: string, deleteFrames?: boolean): void;
  32546. /**
  32547. * Gets the animation range by name, or null if not defined
  32548. * @param name Name of the animation range
  32549. * @returns Nullable animation range
  32550. */
  32551. getRange(name: string): Nullable<AnimationRange>;
  32552. /**
  32553. * Gets the key frames from the animation
  32554. * @returns The key frames of the animation
  32555. */
  32556. getKeys(): Array<IAnimationKey>;
  32557. /**
  32558. * Gets the highest frame rate of the animation
  32559. * @returns Highest frame rate of the animation
  32560. */
  32561. getHighestFrame(): number;
  32562. /**
  32563. * Gets the easing function of the animation
  32564. * @returns Easing function of the animation
  32565. */
  32566. getEasingFunction(): IEasingFunction;
  32567. /**
  32568. * Sets the easing function of the animation
  32569. * @param easingFunction A custom mathematical formula for animation
  32570. */
  32571. setEasingFunction(easingFunction: EasingFunction): void;
  32572. /**
  32573. * Interpolates a scalar linearly
  32574. * @param startValue Start value of the animation curve
  32575. * @param endValue End value of the animation curve
  32576. * @param gradient Scalar amount to interpolate
  32577. * @returns Interpolated scalar value
  32578. */
  32579. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32580. /**
  32581. * Interpolates a scalar cubically
  32582. * @param startValue Start value of the animation curve
  32583. * @param outTangent End tangent of the animation
  32584. * @param endValue End value of the animation curve
  32585. * @param inTangent Start tangent of the animation curve
  32586. * @param gradient Scalar amount to interpolate
  32587. * @returns Interpolated scalar value
  32588. */
  32589. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32590. /**
  32591. * Interpolates a quaternion using a spherical linear interpolation
  32592. * @param startValue Start value of the animation curve
  32593. * @param endValue End value of the animation curve
  32594. * @param gradient Scalar amount to interpolate
  32595. * @returns Interpolated quaternion value
  32596. */
  32597. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32598. /**
  32599. * Interpolates a quaternion cubically
  32600. * @param startValue Start value of the animation curve
  32601. * @param outTangent End tangent of the animation curve
  32602. * @param endValue End value of the animation curve
  32603. * @param inTangent Start tangent of the animation curve
  32604. * @param gradient Scalar amount to interpolate
  32605. * @returns Interpolated quaternion value
  32606. */
  32607. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32608. /**
  32609. * Interpolates a Vector3 linearl
  32610. * @param startValue Start value of the animation curve
  32611. * @param endValue End value of the animation curve
  32612. * @param gradient Scalar amount to interpolate
  32613. * @returns Interpolated scalar value
  32614. */
  32615. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32616. /**
  32617. * Interpolates a Vector3 cubically
  32618. * @param startValue Start value of the animation curve
  32619. * @param outTangent End tangent of the animation
  32620. * @param endValue End value of the animation curve
  32621. * @param inTangent Start tangent of the animation curve
  32622. * @param gradient Scalar amount to interpolate
  32623. * @returns InterpolatedVector3 value
  32624. */
  32625. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32626. /**
  32627. * Interpolates a Vector2 linearly
  32628. * @param startValue Start value of the animation curve
  32629. * @param endValue End value of the animation curve
  32630. * @param gradient Scalar amount to interpolate
  32631. * @returns Interpolated Vector2 value
  32632. */
  32633. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32634. /**
  32635. * Interpolates a Vector2 cubically
  32636. * @param startValue Start value of the animation curve
  32637. * @param outTangent End tangent of the animation
  32638. * @param endValue End value of the animation curve
  32639. * @param inTangent Start tangent of the animation curve
  32640. * @param gradient Scalar amount to interpolate
  32641. * @returns Interpolated Vector2 value
  32642. */
  32643. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32644. /**
  32645. * Interpolates a size linearly
  32646. * @param startValue Start value of the animation curve
  32647. * @param endValue End value of the animation curve
  32648. * @param gradient Scalar amount to interpolate
  32649. * @returns Interpolated Size value
  32650. */
  32651. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32652. /**
  32653. * Interpolates a Color3 linearly
  32654. * @param startValue Start value of the animation curve
  32655. * @param endValue End value of the animation curve
  32656. * @param gradient Scalar amount to interpolate
  32657. * @returns Interpolated Color3 value
  32658. */
  32659. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32660. /**
  32661. * Interpolates a Color4 linearly
  32662. * @param startValue Start value of the animation curve
  32663. * @param endValue End value of the animation curve
  32664. * @param gradient Scalar amount to interpolate
  32665. * @returns Interpolated Color3 value
  32666. */
  32667. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32668. /**
  32669. * @hidden Internal use only
  32670. */
  32671. _getKeyValue(value: any): any;
  32672. /**
  32673. * @hidden Internal use only
  32674. */
  32675. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32676. /**
  32677. * Defines the function to use to interpolate matrices
  32678. * @param startValue defines the start matrix
  32679. * @param endValue defines the end matrix
  32680. * @param gradient defines the gradient between both matrices
  32681. * @param result defines an optional target matrix where to store the interpolation
  32682. * @returns the interpolated matrix
  32683. */
  32684. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32685. /**
  32686. * Makes a copy of the animation
  32687. * @returns Cloned animation
  32688. */
  32689. clone(): Animation;
  32690. /**
  32691. * Sets the key frames of the animation
  32692. * @param values The animation key frames to set
  32693. */
  32694. setKeys(values: Array<IAnimationKey>): void;
  32695. /**
  32696. * Serializes the animation to an object
  32697. * @returns Serialized object
  32698. */
  32699. serialize(): any;
  32700. /**
  32701. * Float animation type
  32702. */
  32703. static readonly ANIMATIONTYPE_FLOAT: number;
  32704. /**
  32705. * Vector3 animation type
  32706. */
  32707. static readonly ANIMATIONTYPE_VECTOR3: number;
  32708. /**
  32709. * Quaternion animation type
  32710. */
  32711. static readonly ANIMATIONTYPE_QUATERNION: number;
  32712. /**
  32713. * Matrix animation type
  32714. */
  32715. static readonly ANIMATIONTYPE_MATRIX: number;
  32716. /**
  32717. * Color3 animation type
  32718. */
  32719. static readonly ANIMATIONTYPE_COLOR3: number;
  32720. /**
  32721. * Color3 animation type
  32722. */
  32723. static readonly ANIMATIONTYPE_COLOR4: number;
  32724. /**
  32725. * Vector2 animation type
  32726. */
  32727. static readonly ANIMATIONTYPE_VECTOR2: number;
  32728. /**
  32729. * Size animation type
  32730. */
  32731. static readonly ANIMATIONTYPE_SIZE: number;
  32732. /**
  32733. * Relative Loop Mode
  32734. */
  32735. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32736. /**
  32737. * Cycle Loop Mode
  32738. */
  32739. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32740. /**
  32741. * Constant Loop Mode
  32742. */
  32743. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32744. /** @hidden */
  32745. static _UniversalLerp(left: any, right: any, amount: number): any;
  32746. /**
  32747. * Parses an animation object and creates an animation
  32748. * @param parsedAnimation Parsed animation object
  32749. * @returns Animation object
  32750. */
  32751. static Parse(parsedAnimation: any): Animation;
  32752. /**
  32753. * Appends the serialized animations from the source animations
  32754. * @param source Source containing the animations
  32755. * @param destination Target to store the animations
  32756. */
  32757. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32758. /**
  32759. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32760. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32761. * @param url defines the url to load from
  32762. * @returns a promise that will resolve to the new animation or an array of animations
  32763. */
  32764. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32765. /**
  32766. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32767. * @param snippetId defines the snippet to load
  32768. * @returns a promise that will resolve to the new animation or a new array of animations
  32769. */
  32770. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32771. }
  32772. }
  32773. declare module BABYLON {
  32774. /**
  32775. * Interface containing an array of animations
  32776. */
  32777. export interface IAnimatable {
  32778. /**
  32779. * Array of animations
  32780. */
  32781. animations: Nullable<Array<Animation>>;
  32782. }
  32783. }
  32784. declare module BABYLON {
  32785. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32786. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32787. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32788. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32789. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32790. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32791. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32792. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32793. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32794. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32795. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32796. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32797. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32798. /**
  32799. * Decorator used to define property that can be serialized as reference to a camera
  32800. * @param sourceName defines the name of the property to decorate
  32801. */
  32802. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32803. /**
  32804. * Class used to help serialization objects
  32805. */
  32806. export class SerializationHelper {
  32807. /** @hidden */
  32808. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32809. /** @hidden */
  32810. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32811. /** @hidden */
  32812. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32813. /** @hidden */
  32814. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32815. /**
  32816. * Appends the serialized animations from the source animations
  32817. * @param source Source containing the animations
  32818. * @param destination Target to store the animations
  32819. */
  32820. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32821. /**
  32822. * Static function used to serialized a specific entity
  32823. * @param entity defines the entity to serialize
  32824. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32825. * @returns a JSON compatible object representing the serialization of the entity
  32826. */
  32827. static Serialize<T>(entity: T, serializationObject?: any): any;
  32828. /**
  32829. * Creates a new entity from a serialization data object
  32830. * @param creationFunction defines a function used to instanciated the new entity
  32831. * @param source defines the source serialization data
  32832. * @param scene defines the hosting scene
  32833. * @param rootUrl defines the root url for resources
  32834. * @returns a new entity
  32835. */
  32836. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32837. /**
  32838. * Clones an object
  32839. * @param creationFunction defines the function used to instanciate the new object
  32840. * @param source defines the source object
  32841. * @returns the cloned object
  32842. */
  32843. static Clone<T>(creationFunction: () => T, source: T): T;
  32844. /**
  32845. * Instanciates a new object based on a source one (some data will be shared between both object)
  32846. * @param creationFunction defines the function used to instanciate the new object
  32847. * @param source defines the source object
  32848. * @returns the new object
  32849. */
  32850. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32851. }
  32852. }
  32853. declare module BABYLON {
  32854. /**
  32855. * Base class of all the textures in babylon.
  32856. * It groups all the common properties the materials, post process, lights... might need
  32857. * in order to make a correct use of the texture.
  32858. */
  32859. export class BaseTexture implements IAnimatable {
  32860. /**
  32861. * Default anisotropic filtering level for the application.
  32862. * It is set to 4 as a good tradeoff between perf and quality.
  32863. */
  32864. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32865. /**
  32866. * Gets or sets the unique id of the texture
  32867. */
  32868. uniqueId: number;
  32869. /**
  32870. * Define the name of the texture.
  32871. */
  32872. name: string;
  32873. /**
  32874. * Gets or sets an object used to store user defined information.
  32875. */
  32876. metadata: any;
  32877. /**
  32878. * For internal use only. Please do not use.
  32879. */
  32880. reservedDataStore: any;
  32881. private _hasAlpha;
  32882. /**
  32883. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32884. */
  32885. set hasAlpha(value: boolean);
  32886. get hasAlpha(): boolean;
  32887. /**
  32888. * Defines if the alpha value should be determined via the rgb values.
  32889. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32890. */
  32891. getAlphaFromRGB: boolean;
  32892. /**
  32893. * Intensity or strength of the texture.
  32894. * It is commonly used by materials to fine tune the intensity of the texture
  32895. */
  32896. level: number;
  32897. /**
  32898. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32899. * This is part of the texture as textures usually maps to one uv set.
  32900. */
  32901. coordinatesIndex: number;
  32902. private _coordinatesMode;
  32903. /**
  32904. * How a texture is mapped.
  32905. *
  32906. * | Value | Type | Description |
  32907. * | ----- | ----------------------------------- | ----------- |
  32908. * | 0 | EXPLICIT_MODE | |
  32909. * | 1 | SPHERICAL_MODE | |
  32910. * | 2 | PLANAR_MODE | |
  32911. * | 3 | CUBIC_MODE | |
  32912. * | 4 | PROJECTION_MODE | |
  32913. * | 5 | SKYBOX_MODE | |
  32914. * | 6 | INVCUBIC_MODE | |
  32915. * | 7 | EQUIRECTANGULAR_MODE | |
  32916. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32917. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32918. */
  32919. set coordinatesMode(value: number);
  32920. get coordinatesMode(): number;
  32921. /**
  32922. * | Value | Type | Description |
  32923. * | ----- | ------------------ | ----------- |
  32924. * | 0 | CLAMP_ADDRESSMODE | |
  32925. * | 1 | WRAP_ADDRESSMODE | |
  32926. * | 2 | MIRROR_ADDRESSMODE | |
  32927. */
  32928. wrapU: number;
  32929. /**
  32930. * | Value | Type | Description |
  32931. * | ----- | ------------------ | ----------- |
  32932. * | 0 | CLAMP_ADDRESSMODE | |
  32933. * | 1 | WRAP_ADDRESSMODE | |
  32934. * | 2 | MIRROR_ADDRESSMODE | |
  32935. */
  32936. wrapV: number;
  32937. /**
  32938. * | Value | Type | Description |
  32939. * | ----- | ------------------ | ----------- |
  32940. * | 0 | CLAMP_ADDRESSMODE | |
  32941. * | 1 | WRAP_ADDRESSMODE | |
  32942. * | 2 | MIRROR_ADDRESSMODE | |
  32943. */
  32944. wrapR: number;
  32945. /**
  32946. * With compliant hardware and browser (supporting anisotropic filtering)
  32947. * this defines the level of anisotropic filtering in the texture.
  32948. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32949. */
  32950. anisotropicFilteringLevel: number;
  32951. /**
  32952. * Define if the texture is a cube texture or if false a 2d texture.
  32953. */
  32954. get isCube(): boolean;
  32955. set isCube(value: boolean);
  32956. /**
  32957. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32958. */
  32959. get is3D(): boolean;
  32960. set is3D(value: boolean);
  32961. /**
  32962. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32963. */
  32964. get is2DArray(): boolean;
  32965. set is2DArray(value: boolean);
  32966. /**
  32967. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32968. * HDR texture are usually stored in linear space.
  32969. * This only impacts the PBR and Background materials
  32970. */
  32971. gammaSpace: boolean;
  32972. /**
  32973. * Gets or sets whether or not the texture contains RGBD data.
  32974. */
  32975. get isRGBD(): boolean;
  32976. set isRGBD(value: boolean);
  32977. /**
  32978. * Is Z inverted in the texture (useful in a cube texture).
  32979. */
  32980. invertZ: boolean;
  32981. /**
  32982. * Are mip maps generated for this texture or not.
  32983. */
  32984. get noMipmap(): boolean;
  32985. /**
  32986. * @hidden
  32987. */
  32988. lodLevelInAlpha: boolean;
  32989. /**
  32990. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32991. */
  32992. get lodGenerationOffset(): number;
  32993. set lodGenerationOffset(value: number);
  32994. /**
  32995. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32996. */
  32997. get lodGenerationScale(): number;
  32998. set lodGenerationScale(value: number);
  32999. /**
  33000. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33001. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33002. * average roughness values.
  33003. */
  33004. get linearSpecularLOD(): boolean;
  33005. set linearSpecularLOD(value: boolean);
  33006. /**
  33007. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33008. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33009. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33010. */
  33011. get irradianceTexture(): Nullable<BaseTexture>;
  33012. set irradianceTexture(value: Nullable<BaseTexture>);
  33013. /**
  33014. * Define if the texture is a render target.
  33015. */
  33016. isRenderTarget: boolean;
  33017. /**
  33018. * Define the unique id of the texture in the scene.
  33019. */
  33020. get uid(): string;
  33021. /** @hidden */
  33022. _prefiltered: boolean;
  33023. /**
  33024. * Return a string representation of the texture.
  33025. * @returns the texture as a string
  33026. */
  33027. toString(): string;
  33028. /**
  33029. * Get the class name of the texture.
  33030. * @returns "BaseTexture"
  33031. */
  33032. getClassName(): string;
  33033. /**
  33034. * Define the list of animation attached to the texture.
  33035. */
  33036. animations: Animation[];
  33037. /**
  33038. * An event triggered when the texture is disposed.
  33039. */
  33040. onDisposeObservable: Observable<BaseTexture>;
  33041. private _onDisposeObserver;
  33042. /**
  33043. * Callback triggered when the texture has been disposed.
  33044. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33045. */
  33046. set onDispose(callback: () => void);
  33047. /**
  33048. * Define the current state of the loading sequence when in delayed load mode.
  33049. */
  33050. delayLoadState: number;
  33051. private _scene;
  33052. private _engine;
  33053. /** @hidden */
  33054. _texture: Nullable<InternalTexture>;
  33055. private _uid;
  33056. /**
  33057. * Define if the texture is preventinga material to render or not.
  33058. * If not and the texture is not ready, the engine will use a default black texture instead.
  33059. */
  33060. get isBlocking(): boolean;
  33061. /**
  33062. * Instantiates a new BaseTexture.
  33063. * Base class of all the textures in babylon.
  33064. * It groups all the common properties the materials, post process, lights... might need
  33065. * in order to make a correct use of the texture.
  33066. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33067. */
  33068. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33069. /**
  33070. * Get the scene the texture belongs to.
  33071. * @returns the scene or null if undefined
  33072. */
  33073. getScene(): Nullable<Scene>;
  33074. /** @hidden */
  33075. protected _getEngine(): Nullable<ThinEngine>;
  33076. /**
  33077. * Get the texture transform matrix used to offset tile the texture for istance.
  33078. * @returns the transformation matrix
  33079. */
  33080. getTextureMatrix(): Matrix;
  33081. /**
  33082. * Get the texture reflection matrix used to rotate/transform the reflection.
  33083. * @returns the reflection matrix
  33084. */
  33085. getReflectionTextureMatrix(): Matrix;
  33086. /**
  33087. * Get the underlying lower level texture from Babylon.
  33088. * @returns the insternal texture
  33089. */
  33090. getInternalTexture(): Nullable<InternalTexture>;
  33091. /**
  33092. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33093. * @returns true if ready or not blocking
  33094. */
  33095. isReadyOrNotBlocking(): boolean;
  33096. /**
  33097. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33098. * @returns true if fully ready
  33099. */
  33100. isReady(): boolean;
  33101. private _cachedSize;
  33102. /**
  33103. * Get the size of the texture.
  33104. * @returns the texture size.
  33105. */
  33106. getSize(): ISize;
  33107. /**
  33108. * Get the base size of the texture.
  33109. * It can be different from the size if the texture has been resized for POT for instance
  33110. * @returns the base size
  33111. */
  33112. getBaseSize(): ISize;
  33113. /**
  33114. * Update the sampling mode of the texture.
  33115. * Default is Trilinear mode.
  33116. *
  33117. * | Value | Type | Description |
  33118. * | ----- | ------------------ | ----------- |
  33119. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33120. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33121. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33122. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33123. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33124. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33125. * | 7 | NEAREST_LINEAR | |
  33126. * | 8 | NEAREST_NEAREST | |
  33127. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33128. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33129. * | 11 | LINEAR_LINEAR | |
  33130. * | 12 | LINEAR_NEAREST | |
  33131. *
  33132. * > _mag_: magnification filter (close to the viewer)
  33133. * > _min_: minification filter (far from the viewer)
  33134. * > _mip_: filter used between mip map levels
  33135. *@param samplingMode Define the new sampling mode of the texture
  33136. */
  33137. updateSamplingMode(samplingMode: number): void;
  33138. /**
  33139. * Scales the texture if is `canRescale()`
  33140. * @param ratio the resize factor we want to use to rescale
  33141. */
  33142. scale(ratio: number): void;
  33143. /**
  33144. * Get if the texture can rescale.
  33145. */
  33146. get canRescale(): boolean;
  33147. /** @hidden */
  33148. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33149. /** @hidden */
  33150. _rebuild(): void;
  33151. /**
  33152. * Triggers the load sequence in delayed load mode.
  33153. */
  33154. delayLoad(): void;
  33155. /**
  33156. * Clones the texture.
  33157. * @returns the cloned texture
  33158. */
  33159. clone(): Nullable<BaseTexture>;
  33160. /**
  33161. * Get the texture underlying type (INT, FLOAT...)
  33162. */
  33163. get textureType(): number;
  33164. /**
  33165. * Get the texture underlying format (RGB, RGBA...)
  33166. */
  33167. get textureFormat(): number;
  33168. /**
  33169. * Indicates that textures need to be re-calculated for all materials
  33170. */
  33171. protected _markAllSubMeshesAsTexturesDirty(): void;
  33172. /**
  33173. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33174. * This will returns an RGBA array buffer containing either in values (0-255) or
  33175. * float values (0-1) depending of the underlying buffer type.
  33176. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33177. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33178. * @param buffer defines a user defined buffer to fill with data (can be null)
  33179. * @returns The Array buffer containing the pixels data.
  33180. */
  33181. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33182. /**
  33183. * Release and destroy the underlying lower level texture aka internalTexture.
  33184. */
  33185. releaseInternalTexture(): void;
  33186. /** @hidden */
  33187. get _lodTextureHigh(): Nullable<BaseTexture>;
  33188. /** @hidden */
  33189. get _lodTextureMid(): Nullable<BaseTexture>;
  33190. /** @hidden */
  33191. get _lodTextureLow(): Nullable<BaseTexture>;
  33192. /**
  33193. * Dispose the texture and release its associated resources.
  33194. */
  33195. dispose(): void;
  33196. /**
  33197. * Serialize the texture into a JSON representation that can be parsed later on.
  33198. * @returns the JSON representation of the texture
  33199. */
  33200. serialize(): any;
  33201. /**
  33202. * Helper function to be called back once a list of texture contains only ready textures.
  33203. * @param textures Define the list of textures to wait for
  33204. * @param callback Define the callback triggered once the entire list will be ready
  33205. */
  33206. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33207. private static _isScene;
  33208. }
  33209. }
  33210. declare module BABYLON {
  33211. /**
  33212. * Options to be used when creating an effect.
  33213. */
  33214. export interface IEffectCreationOptions {
  33215. /**
  33216. * Atrributes that will be used in the shader.
  33217. */
  33218. attributes: string[];
  33219. /**
  33220. * Uniform varible names that will be set in the shader.
  33221. */
  33222. uniformsNames: string[];
  33223. /**
  33224. * Uniform buffer variable names that will be set in the shader.
  33225. */
  33226. uniformBuffersNames: string[];
  33227. /**
  33228. * Sampler texture variable names that will be set in the shader.
  33229. */
  33230. samplers: string[];
  33231. /**
  33232. * Define statements that will be set in the shader.
  33233. */
  33234. defines: any;
  33235. /**
  33236. * Possible fallbacks for this effect to improve performance when needed.
  33237. */
  33238. fallbacks: Nullable<IEffectFallbacks>;
  33239. /**
  33240. * Callback that will be called when the shader is compiled.
  33241. */
  33242. onCompiled: Nullable<(effect: Effect) => void>;
  33243. /**
  33244. * Callback that will be called if an error occurs during shader compilation.
  33245. */
  33246. onError: Nullable<(effect: Effect, errors: string) => void>;
  33247. /**
  33248. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33249. */
  33250. indexParameters?: any;
  33251. /**
  33252. * Max number of lights that can be used in the shader.
  33253. */
  33254. maxSimultaneousLights?: number;
  33255. /**
  33256. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33257. */
  33258. transformFeedbackVaryings?: Nullable<string[]>;
  33259. /**
  33260. * 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
  33261. */
  33262. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33263. /**
  33264. * Is this effect rendering to several color attachments ?
  33265. */
  33266. multiTarget?: boolean;
  33267. }
  33268. /**
  33269. * Effect containing vertex and fragment shader that can be executed on an object.
  33270. */
  33271. export class Effect implements IDisposable {
  33272. /**
  33273. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33274. */
  33275. static ShadersRepository: string;
  33276. /**
  33277. * Enable logging of the shader code when a compilation error occurs
  33278. */
  33279. static LogShaderCodeOnCompilationError: boolean;
  33280. /**
  33281. * Name of the effect.
  33282. */
  33283. name: any;
  33284. /**
  33285. * String container all the define statements that should be set on the shader.
  33286. */
  33287. defines: string;
  33288. /**
  33289. * Callback that will be called when the shader is compiled.
  33290. */
  33291. onCompiled: Nullable<(effect: Effect) => void>;
  33292. /**
  33293. * Callback that will be called if an error occurs during shader compilation.
  33294. */
  33295. onError: Nullable<(effect: Effect, errors: string) => void>;
  33296. /**
  33297. * Callback that will be called when effect is bound.
  33298. */
  33299. onBind: Nullable<(effect: Effect) => void>;
  33300. /**
  33301. * Unique ID of the effect.
  33302. */
  33303. uniqueId: number;
  33304. /**
  33305. * Observable that will be called when the shader is compiled.
  33306. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33307. */
  33308. onCompileObservable: Observable<Effect>;
  33309. /**
  33310. * Observable that will be called if an error occurs during shader compilation.
  33311. */
  33312. onErrorObservable: Observable<Effect>;
  33313. /** @hidden */
  33314. _onBindObservable: Nullable<Observable<Effect>>;
  33315. /**
  33316. * @hidden
  33317. * Specifies if the effect was previously ready
  33318. */
  33319. _wasPreviouslyReady: boolean;
  33320. /**
  33321. * Observable that will be called when effect is bound.
  33322. */
  33323. get onBindObservable(): Observable<Effect>;
  33324. /** @hidden */
  33325. _bonesComputationForcedToCPU: boolean;
  33326. /** @hidden */
  33327. _multiTarget: boolean;
  33328. private static _uniqueIdSeed;
  33329. private _engine;
  33330. private _uniformBuffersNames;
  33331. private _uniformBuffersNamesList;
  33332. private _uniformsNames;
  33333. private _samplerList;
  33334. private _samplers;
  33335. private _isReady;
  33336. private _compilationError;
  33337. private _allFallbacksProcessed;
  33338. private _attributesNames;
  33339. private _attributes;
  33340. private _attributeLocationByName;
  33341. private _uniforms;
  33342. /**
  33343. * Key for the effect.
  33344. * @hidden
  33345. */
  33346. _key: string;
  33347. private _indexParameters;
  33348. private _fallbacks;
  33349. private _vertexSourceCode;
  33350. private _fragmentSourceCode;
  33351. private _vertexSourceCodeOverride;
  33352. private _fragmentSourceCodeOverride;
  33353. private _transformFeedbackVaryings;
  33354. /**
  33355. * Compiled shader to webGL program.
  33356. * @hidden
  33357. */
  33358. _pipelineContext: Nullable<IPipelineContext>;
  33359. private _valueCache;
  33360. private static _baseCache;
  33361. /**
  33362. * Instantiates an effect.
  33363. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33364. * @param baseName Name of the effect.
  33365. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33366. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33367. * @param samplers List of sampler variables that will be passed to the shader.
  33368. * @param engine Engine to be used to render the effect
  33369. * @param defines Define statements to be added to the shader.
  33370. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33371. * @param onCompiled Callback that will be called when the shader is compiled.
  33372. * @param onError Callback that will be called if an error occurs during shader compilation.
  33373. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33374. */
  33375. 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);
  33376. private _useFinalCode;
  33377. /**
  33378. * Unique key for this effect
  33379. */
  33380. get key(): string;
  33381. /**
  33382. * If the effect has been compiled and prepared.
  33383. * @returns if the effect is compiled and prepared.
  33384. */
  33385. isReady(): boolean;
  33386. private _isReadyInternal;
  33387. /**
  33388. * The engine the effect was initialized with.
  33389. * @returns the engine.
  33390. */
  33391. getEngine(): Engine;
  33392. /**
  33393. * The pipeline context for this effect
  33394. * @returns the associated pipeline context
  33395. */
  33396. getPipelineContext(): Nullable<IPipelineContext>;
  33397. /**
  33398. * The set of names of attribute variables for the shader.
  33399. * @returns An array of attribute names.
  33400. */
  33401. getAttributesNames(): string[];
  33402. /**
  33403. * Returns the attribute at the given index.
  33404. * @param index The index of the attribute.
  33405. * @returns The location of the attribute.
  33406. */
  33407. getAttributeLocation(index: number): number;
  33408. /**
  33409. * Returns the attribute based on the name of the variable.
  33410. * @param name of the attribute to look up.
  33411. * @returns the attribute location.
  33412. */
  33413. getAttributeLocationByName(name: string): number;
  33414. /**
  33415. * The number of attributes.
  33416. * @returns the numnber of attributes.
  33417. */
  33418. getAttributesCount(): number;
  33419. /**
  33420. * Gets the index of a uniform variable.
  33421. * @param uniformName of the uniform to look up.
  33422. * @returns the index.
  33423. */
  33424. getUniformIndex(uniformName: string): number;
  33425. /**
  33426. * Returns the attribute based on the name of the variable.
  33427. * @param uniformName of the uniform to look up.
  33428. * @returns the location of the uniform.
  33429. */
  33430. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33431. /**
  33432. * Returns an array of sampler variable names
  33433. * @returns The array of sampler variable names.
  33434. */
  33435. getSamplers(): string[];
  33436. /**
  33437. * Returns an array of uniform variable names
  33438. * @returns The array of uniform variable names.
  33439. */
  33440. getUniformNames(): string[];
  33441. /**
  33442. * Returns an array of uniform buffer variable names
  33443. * @returns The array of uniform buffer variable names.
  33444. */
  33445. getUniformBuffersNames(): string[];
  33446. /**
  33447. * Returns the index parameters used to create the effect
  33448. * @returns The index parameters object
  33449. */
  33450. getIndexParameters(): any;
  33451. /**
  33452. * The error from the last compilation.
  33453. * @returns the error string.
  33454. */
  33455. getCompilationError(): string;
  33456. /**
  33457. * Gets a boolean indicating that all fallbacks were used during compilation
  33458. * @returns true if all fallbacks were used
  33459. */
  33460. allFallbacksProcessed(): boolean;
  33461. /**
  33462. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33463. * @param func The callback to be used.
  33464. */
  33465. executeWhenCompiled(func: (effect: Effect) => void): void;
  33466. private _checkIsReady;
  33467. private _loadShader;
  33468. /**
  33469. * Gets the vertex shader source code of this effect
  33470. */
  33471. get vertexSourceCode(): string;
  33472. /**
  33473. * Gets the fragment shader source code of this effect
  33474. */
  33475. get fragmentSourceCode(): string;
  33476. /**
  33477. * Recompiles the webGL program
  33478. * @param vertexSourceCode The source code for the vertex shader.
  33479. * @param fragmentSourceCode The source code for the fragment shader.
  33480. * @param onCompiled Callback called when completed.
  33481. * @param onError Callback called on error.
  33482. * @hidden
  33483. */
  33484. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33485. /**
  33486. * Prepares the effect
  33487. * @hidden
  33488. */
  33489. _prepareEffect(): void;
  33490. private _getShaderCodeAndErrorLine;
  33491. private _processCompilationErrors;
  33492. /**
  33493. * Checks if the effect is supported. (Must be called after compilation)
  33494. */
  33495. get isSupported(): boolean;
  33496. /**
  33497. * Binds a texture to the engine to be used as output of the shader.
  33498. * @param channel Name of the output variable.
  33499. * @param texture Texture to bind.
  33500. * @hidden
  33501. */
  33502. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33503. /**
  33504. * Sets a texture on the engine to be used in the shader.
  33505. * @param channel Name of the sampler variable.
  33506. * @param texture Texture to set.
  33507. */
  33508. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33509. /**
  33510. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33511. * @param channel Name of the sampler variable.
  33512. * @param texture Texture to set.
  33513. */
  33514. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33515. /**
  33516. * Sets an array of textures on the engine to be used in the shader.
  33517. * @param channel Name of the variable.
  33518. * @param textures Textures to set.
  33519. */
  33520. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33521. /**
  33522. * 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)
  33523. * @param channel Name of the sampler variable.
  33524. * @param postProcess Post process to get the input texture from.
  33525. */
  33526. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33527. /**
  33528. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33529. * 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)
  33530. * @param channel Name of the sampler variable.
  33531. * @param postProcess Post process to get the output texture from.
  33532. */
  33533. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33534. /** @hidden */
  33535. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33536. /** @hidden */
  33537. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33538. /** @hidden */
  33539. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33540. /** @hidden */
  33541. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33542. /**
  33543. * Binds a buffer to a uniform.
  33544. * @param buffer Buffer to bind.
  33545. * @param name Name of the uniform variable to bind to.
  33546. */
  33547. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33548. /**
  33549. * Binds block to a uniform.
  33550. * @param blockName Name of the block to bind.
  33551. * @param index Index to bind.
  33552. */
  33553. bindUniformBlock(blockName: string, index: number): void;
  33554. /**
  33555. * Sets an interger value on a uniform variable.
  33556. * @param uniformName Name of the variable.
  33557. * @param value Value to be set.
  33558. * @returns this effect.
  33559. */
  33560. setInt(uniformName: string, value: number): Effect;
  33561. /**
  33562. * Sets an int array on a uniform variable.
  33563. * @param uniformName Name of the variable.
  33564. * @param array array to be set.
  33565. * @returns this effect.
  33566. */
  33567. setIntArray(uniformName: string, array: Int32Array): Effect;
  33568. /**
  33569. * 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)
  33570. * @param uniformName Name of the variable.
  33571. * @param array array to be set.
  33572. * @returns this effect.
  33573. */
  33574. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33575. /**
  33576. * 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)
  33577. * @param uniformName Name of the variable.
  33578. * @param array array to be set.
  33579. * @returns this effect.
  33580. */
  33581. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33582. /**
  33583. * 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)
  33584. * @param uniformName Name of the variable.
  33585. * @param array array to be set.
  33586. * @returns this effect.
  33587. */
  33588. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33589. /**
  33590. * Sets an float array on a uniform variable.
  33591. * @param uniformName Name of the variable.
  33592. * @param array array to be set.
  33593. * @returns this effect.
  33594. */
  33595. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33596. /**
  33597. * 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)
  33598. * @param uniformName Name of the variable.
  33599. * @param array array to be set.
  33600. * @returns this effect.
  33601. */
  33602. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33603. /**
  33604. * 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)
  33605. * @param uniformName Name of the variable.
  33606. * @param array array to be set.
  33607. * @returns this effect.
  33608. */
  33609. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33610. /**
  33611. * 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)
  33612. * @param uniformName Name of the variable.
  33613. * @param array array to be set.
  33614. * @returns this effect.
  33615. */
  33616. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33617. /**
  33618. * Sets an array on a uniform variable.
  33619. * @param uniformName Name of the variable.
  33620. * @param array array to be set.
  33621. * @returns this effect.
  33622. */
  33623. setArray(uniformName: string, array: number[]): Effect;
  33624. /**
  33625. * 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)
  33626. * @param uniformName Name of the variable.
  33627. * @param array array to be set.
  33628. * @returns this effect.
  33629. */
  33630. setArray2(uniformName: string, array: number[]): Effect;
  33631. /**
  33632. * 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)
  33633. * @param uniformName Name of the variable.
  33634. * @param array array to be set.
  33635. * @returns this effect.
  33636. */
  33637. setArray3(uniformName: string, array: number[]): Effect;
  33638. /**
  33639. * 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)
  33640. * @param uniformName Name of the variable.
  33641. * @param array array to be set.
  33642. * @returns this effect.
  33643. */
  33644. setArray4(uniformName: string, array: number[]): Effect;
  33645. /**
  33646. * Sets matrices on a uniform variable.
  33647. * @param uniformName Name of the variable.
  33648. * @param matrices matrices to be set.
  33649. * @returns this effect.
  33650. */
  33651. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33652. /**
  33653. * Sets matrix on a uniform variable.
  33654. * @param uniformName Name of the variable.
  33655. * @param matrix matrix to be set.
  33656. * @returns this effect.
  33657. */
  33658. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33659. /**
  33660. * 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)
  33661. * @param uniformName Name of the variable.
  33662. * @param matrix matrix to be set.
  33663. * @returns this effect.
  33664. */
  33665. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33666. /**
  33667. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33668. * @param uniformName Name of the variable.
  33669. * @param matrix matrix to be set.
  33670. * @returns this effect.
  33671. */
  33672. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33673. /**
  33674. * Sets a float on a uniform variable.
  33675. * @param uniformName Name of the variable.
  33676. * @param value value to be set.
  33677. * @returns this effect.
  33678. */
  33679. setFloat(uniformName: string, value: number): Effect;
  33680. /**
  33681. * Sets a boolean on a uniform variable.
  33682. * @param uniformName Name of the variable.
  33683. * @param bool value to be set.
  33684. * @returns this effect.
  33685. */
  33686. setBool(uniformName: string, bool: boolean): Effect;
  33687. /**
  33688. * Sets a Vector2 on a uniform variable.
  33689. * @param uniformName Name of the variable.
  33690. * @param vector2 vector2 to be set.
  33691. * @returns this effect.
  33692. */
  33693. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33694. /**
  33695. * Sets a float2 on a uniform variable.
  33696. * @param uniformName Name of the variable.
  33697. * @param x First float in float2.
  33698. * @param y Second float in float2.
  33699. * @returns this effect.
  33700. */
  33701. setFloat2(uniformName: string, x: number, y: number): Effect;
  33702. /**
  33703. * Sets a Vector3 on a uniform variable.
  33704. * @param uniformName Name of the variable.
  33705. * @param vector3 Value to be set.
  33706. * @returns this effect.
  33707. */
  33708. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33709. /**
  33710. * Sets a float3 on a uniform variable.
  33711. * @param uniformName Name of the variable.
  33712. * @param x First float in float3.
  33713. * @param y Second float in float3.
  33714. * @param z Third float in float3.
  33715. * @returns this effect.
  33716. */
  33717. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33718. /**
  33719. * Sets a Vector4 on a uniform variable.
  33720. * @param uniformName Name of the variable.
  33721. * @param vector4 Value to be set.
  33722. * @returns this effect.
  33723. */
  33724. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33725. /**
  33726. * Sets a float4 on a uniform variable.
  33727. * @param uniformName Name of the variable.
  33728. * @param x First float in float4.
  33729. * @param y Second float in float4.
  33730. * @param z Third float in float4.
  33731. * @param w Fourth float in float4.
  33732. * @returns this effect.
  33733. */
  33734. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33735. /**
  33736. * Sets a Color3 on a uniform variable.
  33737. * @param uniformName Name of the variable.
  33738. * @param color3 Value to be set.
  33739. * @returns this effect.
  33740. */
  33741. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33742. /**
  33743. * Sets a Color4 on a uniform variable.
  33744. * @param uniformName Name of the variable.
  33745. * @param color3 Value to be set.
  33746. * @param alpha Alpha value to be set.
  33747. * @returns this effect.
  33748. */
  33749. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33750. /**
  33751. * Sets a Color4 on a uniform variable
  33752. * @param uniformName defines the name of the variable
  33753. * @param color4 defines the value to be set
  33754. * @returns this effect.
  33755. */
  33756. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33757. /** Release all associated resources */
  33758. dispose(): void;
  33759. /**
  33760. * This function will add a new shader to the shader store
  33761. * @param name the name of the shader
  33762. * @param pixelShader optional pixel shader content
  33763. * @param vertexShader optional vertex shader content
  33764. */
  33765. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33766. /**
  33767. * Store of each shader (The can be looked up using effect.key)
  33768. */
  33769. static ShadersStore: {
  33770. [key: string]: string;
  33771. };
  33772. /**
  33773. * Store of each included file for a shader (The can be looked up using effect.key)
  33774. */
  33775. static IncludesShadersStore: {
  33776. [key: string]: string;
  33777. };
  33778. /**
  33779. * Resets the cache of effects.
  33780. */
  33781. static ResetCache(): void;
  33782. }
  33783. }
  33784. declare module BABYLON {
  33785. /**
  33786. * Interface used to describe the capabilities of the engine relatively to the current browser
  33787. */
  33788. export interface EngineCapabilities {
  33789. /** Maximum textures units per fragment shader */
  33790. maxTexturesImageUnits: number;
  33791. /** Maximum texture units per vertex shader */
  33792. maxVertexTextureImageUnits: number;
  33793. /** Maximum textures units in the entire pipeline */
  33794. maxCombinedTexturesImageUnits: number;
  33795. /** Maximum texture size */
  33796. maxTextureSize: number;
  33797. /** Maximum texture samples */
  33798. maxSamples?: number;
  33799. /** Maximum cube texture size */
  33800. maxCubemapTextureSize: number;
  33801. /** Maximum render texture size */
  33802. maxRenderTextureSize: number;
  33803. /** Maximum number of vertex attributes */
  33804. maxVertexAttribs: number;
  33805. /** Maximum number of varyings */
  33806. maxVaryingVectors: number;
  33807. /** Maximum number of uniforms per vertex shader */
  33808. maxVertexUniformVectors: number;
  33809. /** Maximum number of uniforms per fragment shader */
  33810. maxFragmentUniformVectors: number;
  33811. /** Defines if standard derivates (dx/dy) are supported */
  33812. standardDerivatives: boolean;
  33813. /** Defines if s3tc texture compression is supported */
  33814. s3tc?: WEBGL_compressed_texture_s3tc;
  33815. /** Defines if pvrtc texture compression is supported */
  33816. pvrtc: any;
  33817. /** Defines if etc1 texture compression is supported */
  33818. etc1: any;
  33819. /** Defines if etc2 texture compression is supported */
  33820. etc2: any;
  33821. /** Defines if astc texture compression is supported */
  33822. astc: any;
  33823. /** Defines if float textures are supported */
  33824. textureFloat: boolean;
  33825. /** Defines if vertex array objects are supported */
  33826. vertexArrayObject: boolean;
  33827. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33828. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33829. /** Gets the maximum level of anisotropy supported */
  33830. maxAnisotropy: number;
  33831. /** Defines if instancing is supported */
  33832. instancedArrays: boolean;
  33833. /** Defines if 32 bits indices are supported */
  33834. uintIndices: boolean;
  33835. /** Defines if high precision shaders are supported */
  33836. highPrecisionShaderSupported: boolean;
  33837. /** Defines if depth reading in the fragment shader is supported */
  33838. fragmentDepthSupported: boolean;
  33839. /** Defines if float texture linear filtering is supported*/
  33840. textureFloatLinearFiltering: boolean;
  33841. /** Defines if rendering to float textures is supported */
  33842. textureFloatRender: boolean;
  33843. /** Defines if half float textures are supported*/
  33844. textureHalfFloat: boolean;
  33845. /** Defines if half float texture linear filtering is supported*/
  33846. textureHalfFloatLinearFiltering: boolean;
  33847. /** Defines if rendering to half float textures is supported */
  33848. textureHalfFloatRender: boolean;
  33849. /** Defines if textureLOD shader command is supported */
  33850. textureLOD: boolean;
  33851. /** Defines if draw buffers extension is supported */
  33852. drawBuffersExtension: boolean;
  33853. /** Defines if depth textures are supported */
  33854. depthTextureExtension: boolean;
  33855. /** Defines if float color buffer are supported */
  33856. colorBufferFloat: boolean;
  33857. /** Gets disjoint timer query extension (null if not supported) */
  33858. timerQuery?: EXT_disjoint_timer_query;
  33859. /** Defines if timestamp can be used with timer query */
  33860. canUseTimestampForTimerQuery: boolean;
  33861. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33862. multiview?: any;
  33863. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33864. oculusMultiview?: any;
  33865. /** Function used to let the system compiles shaders in background */
  33866. parallelShaderCompile?: {
  33867. COMPLETION_STATUS_KHR: number;
  33868. };
  33869. /** Max number of texture samples for MSAA */
  33870. maxMSAASamples: number;
  33871. /** Defines if the blend min max extension is supported */
  33872. blendMinMax: boolean;
  33873. }
  33874. }
  33875. declare module BABYLON {
  33876. /**
  33877. * @hidden
  33878. **/
  33879. export class DepthCullingState {
  33880. private _isDepthTestDirty;
  33881. private _isDepthMaskDirty;
  33882. private _isDepthFuncDirty;
  33883. private _isCullFaceDirty;
  33884. private _isCullDirty;
  33885. private _isZOffsetDirty;
  33886. private _isFrontFaceDirty;
  33887. private _depthTest;
  33888. private _depthMask;
  33889. private _depthFunc;
  33890. private _cull;
  33891. private _cullFace;
  33892. private _zOffset;
  33893. private _frontFace;
  33894. /**
  33895. * Initializes the state.
  33896. */
  33897. constructor();
  33898. get isDirty(): boolean;
  33899. get zOffset(): number;
  33900. set zOffset(value: number);
  33901. get cullFace(): Nullable<number>;
  33902. set cullFace(value: Nullable<number>);
  33903. get cull(): Nullable<boolean>;
  33904. set cull(value: Nullable<boolean>);
  33905. get depthFunc(): Nullable<number>;
  33906. set depthFunc(value: Nullable<number>);
  33907. get depthMask(): boolean;
  33908. set depthMask(value: boolean);
  33909. get depthTest(): boolean;
  33910. set depthTest(value: boolean);
  33911. get frontFace(): Nullable<number>;
  33912. set frontFace(value: Nullable<number>);
  33913. reset(): void;
  33914. apply(gl: WebGLRenderingContext): void;
  33915. }
  33916. }
  33917. declare module BABYLON {
  33918. /**
  33919. * @hidden
  33920. **/
  33921. export class StencilState {
  33922. /** 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 */
  33923. static readonly ALWAYS: number;
  33924. /** Passed to stencilOperation to specify that stencil value must be kept */
  33925. static readonly KEEP: number;
  33926. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33927. static readonly REPLACE: number;
  33928. private _isStencilTestDirty;
  33929. private _isStencilMaskDirty;
  33930. private _isStencilFuncDirty;
  33931. private _isStencilOpDirty;
  33932. private _stencilTest;
  33933. private _stencilMask;
  33934. private _stencilFunc;
  33935. private _stencilFuncRef;
  33936. private _stencilFuncMask;
  33937. private _stencilOpStencilFail;
  33938. private _stencilOpDepthFail;
  33939. private _stencilOpStencilDepthPass;
  33940. get isDirty(): boolean;
  33941. get stencilFunc(): number;
  33942. set stencilFunc(value: number);
  33943. get stencilFuncRef(): number;
  33944. set stencilFuncRef(value: number);
  33945. get stencilFuncMask(): number;
  33946. set stencilFuncMask(value: number);
  33947. get stencilOpStencilFail(): number;
  33948. set stencilOpStencilFail(value: number);
  33949. get stencilOpDepthFail(): number;
  33950. set stencilOpDepthFail(value: number);
  33951. get stencilOpStencilDepthPass(): number;
  33952. set stencilOpStencilDepthPass(value: number);
  33953. get stencilMask(): number;
  33954. set stencilMask(value: number);
  33955. get stencilTest(): boolean;
  33956. set stencilTest(value: boolean);
  33957. constructor();
  33958. reset(): void;
  33959. apply(gl: WebGLRenderingContext): void;
  33960. }
  33961. }
  33962. declare module BABYLON {
  33963. /**
  33964. * @hidden
  33965. **/
  33966. export class AlphaState {
  33967. private _isAlphaBlendDirty;
  33968. private _isBlendFunctionParametersDirty;
  33969. private _isBlendEquationParametersDirty;
  33970. private _isBlendConstantsDirty;
  33971. private _alphaBlend;
  33972. private _blendFunctionParameters;
  33973. private _blendEquationParameters;
  33974. private _blendConstants;
  33975. /**
  33976. * Initializes the state.
  33977. */
  33978. constructor();
  33979. get isDirty(): boolean;
  33980. get alphaBlend(): boolean;
  33981. set alphaBlend(value: boolean);
  33982. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33983. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33984. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33985. reset(): void;
  33986. apply(gl: WebGLRenderingContext): void;
  33987. }
  33988. }
  33989. declare module BABYLON {
  33990. /** @hidden */
  33991. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33992. attributeProcessor(attribute: string): string;
  33993. varyingProcessor(varying: string, isFragment: boolean): string;
  33994. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33995. }
  33996. }
  33997. declare module BABYLON {
  33998. /**
  33999. * Interface for attribute information associated with buffer instanciation
  34000. */
  34001. export interface InstancingAttributeInfo {
  34002. /**
  34003. * Name of the GLSL attribute
  34004. * if attribute index is not specified, this is used to retrieve the index from the effect
  34005. */
  34006. attributeName: string;
  34007. /**
  34008. * Index/offset of the attribute in the vertex shader
  34009. * if not specified, this will be computes from the name.
  34010. */
  34011. index?: number;
  34012. /**
  34013. * size of the attribute, 1, 2, 3 or 4
  34014. */
  34015. attributeSize: number;
  34016. /**
  34017. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34018. */
  34019. offset: number;
  34020. /**
  34021. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34022. * default to 1
  34023. */
  34024. divisor?: number;
  34025. /**
  34026. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34027. * default is FLOAT
  34028. */
  34029. attributeType?: number;
  34030. /**
  34031. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34032. */
  34033. normalized?: boolean;
  34034. }
  34035. }
  34036. declare module BABYLON {
  34037. interface ThinEngine {
  34038. /**
  34039. * Update a video texture
  34040. * @param texture defines the texture to update
  34041. * @param video defines the video element to use
  34042. * @param invertY defines if data must be stored with Y axis inverted
  34043. */
  34044. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34045. }
  34046. }
  34047. declare module BABYLON {
  34048. interface ThinEngine {
  34049. /**
  34050. * Creates a dynamic texture
  34051. * @param width defines the width of the texture
  34052. * @param height defines the height of the texture
  34053. * @param generateMipMaps defines if the engine should generate the mip levels
  34054. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34055. * @returns the dynamic texture inside an InternalTexture
  34056. */
  34057. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34058. /**
  34059. * Update the content of a dynamic texture
  34060. * @param texture defines the texture to update
  34061. * @param canvas defines the canvas containing the source
  34062. * @param invertY defines if data must be stored with Y axis inverted
  34063. * @param premulAlpha defines if alpha is stored as premultiplied
  34064. * @param format defines the format of the data
  34065. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34066. */
  34067. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34068. }
  34069. }
  34070. declare module BABYLON {
  34071. /**
  34072. * Settings for finer control over video usage
  34073. */
  34074. export interface VideoTextureSettings {
  34075. /**
  34076. * Applies `autoplay` to video, if specified
  34077. */
  34078. autoPlay?: boolean;
  34079. /**
  34080. * Applies `loop` to video, if specified
  34081. */
  34082. loop?: boolean;
  34083. /**
  34084. * Automatically updates internal texture from video at every frame in the render loop
  34085. */
  34086. autoUpdateTexture: boolean;
  34087. /**
  34088. * Image src displayed during the video loading or until the user interacts with the video.
  34089. */
  34090. poster?: string;
  34091. }
  34092. /**
  34093. * If you want to display a video in your scene, this is the special texture for that.
  34094. * This special texture works similar to other textures, with the exception of a few parameters.
  34095. * @see https://doc.babylonjs.com/how_to/video_texture
  34096. */
  34097. export class VideoTexture extends Texture {
  34098. /**
  34099. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34100. */
  34101. readonly autoUpdateTexture: boolean;
  34102. /**
  34103. * The video instance used by the texture internally
  34104. */
  34105. readonly video: HTMLVideoElement;
  34106. private _onUserActionRequestedObservable;
  34107. /**
  34108. * Event triggerd when a dom action is required by the user to play the video.
  34109. * This happens due to recent changes in browser policies preventing video to auto start.
  34110. */
  34111. get onUserActionRequestedObservable(): Observable<Texture>;
  34112. private _generateMipMaps;
  34113. private _stillImageCaptured;
  34114. private _displayingPosterTexture;
  34115. private _settings;
  34116. private _createInternalTextureOnEvent;
  34117. private _frameId;
  34118. private _currentSrc;
  34119. /**
  34120. * Creates a video texture.
  34121. * If you want to display a video in your scene, this is the special texture for that.
  34122. * This special texture works similar to other textures, with the exception of a few parameters.
  34123. * @see https://doc.babylonjs.com/how_to/video_texture
  34124. * @param name optional name, will detect from video source, if not defined
  34125. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34126. * @param scene is obviously the current scene.
  34127. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34128. * @param invertY is false by default but can be used to invert video on Y axis
  34129. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34130. * @param settings allows finer control over video usage
  34131. */
  34132. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34133. private _getName;
  34134. private _getVideo;
  34135. private _createInternalTexture;
  34136. private reset;
  34137. /**
  34138. * @hidden Internal method to initiate `update`.
  34139. */
  34140. _rebuild(): void;
  34141. /**
  34142. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34143. */
  34144. update(): void;
  34145. /**
  34146. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34147. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34148. */
  34149. updateTexture(isVisible: boolean): void;
  34150. protected _updateInternalTexture: () => void;
  34151. /**
  34152. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34153. * @param url New url.
  34154. */
  34155. updateURL(url: string): void;
  34156. /**
  34157. * Clones the texture.
  34158. * @returns the cloned texture
  34159. */
  34160. clone(): VideoTexture;
  34161. /**
  34162. * Dispose the texture and release its associated resources.
  34163. */
  34164. dispose(): void;
  34165. /**
  34166. * Creates a video texture straight from a stream.
  34167. * @param scene Define the scene the texture should be created in
  34168. * @param stream Define the stream the texture should be created from
  34169. * @returns The created video texture as a promise
  34170. */
  34171. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34172. /**
  34173. * Creates a video texture straight from your WebCam video feed.
  34174. * @param scene Define the scene the texture should be created in
  34175. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34176. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34177. * @returns The created video texture as a promise
  34178. */
  34179. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34180. minWidth: number;
  34181. maxWidth: number;
  34182. minHeight: number;
  34183. maxHeight: number;
  34184. deviceId: string;
  34185. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34186. /**
  34187. * Creates a video texture straight from your WebCam video feed.
  34188. * @param scene Define the scene the texture should be created in
  34189. * @param onReady Define a callback to triggered once the texture will be ready
  34190. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34191. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34192. */
  34193. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34194. minWidth: number;
  34195. maxWidth: number;
  34196. minHeight: number;
  34197. maxHeight: number;
  34198. deviceId: string;
  34199. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34200. }
  34201. }
  34202. declare module BABYLON {
  34203. /**
  34204. * Defines the interface used by objects working like Scene
  34205. * @hidden
  34206. */
  34207. export interface ISceneLike {
  34208. _addPendingData(data: any): void;
  34209. _removePendingData(data: any): void;
  34210. offlineProvider: IOfflineProvider;
  34211. }
  34212. /** Interface defining initialization parameters for Engine class */
  34213. export interface EngineOptions extends WebGLContextAttributes {
  34214. /**
  34215. * Defines if the engine should no exceed a specified device ratio
  34216. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34217. */
  34218. limitDeviceRatio?: number;
  34219. /**
  34220. * Defines if webvr should be enabled automatically
  34221. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34222. */
  34223. autoEnableWebVR?: boolean;
  34224. /**
  34225. * Defines if webgl2 should be turned off even if supported
  34226. * @see https://doc.babylonjs.com/features/webgl2
  34227. */
  34228. disableWebGL2Support?: boolean;
  34229. /**
  34230. * Defines if webaudio should be initialized as well
  34231. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  34232. */
  34233. audioEngine?: boolean;
  34234. /**
  34235. * Defines if animations should run using a deterministic lock step
  34236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34237. */
  34238. deterministicLockstep?: boolean;
  34239. /** Defines the maximum steps to use with deterministic lock step mode */
  34240. lockstepMaxSteps?: number;
  34241. /** Defines the seconds between each deterministic lock step */
  34242. timeStep?: number;
  34243. /**
  34244. * Defines that engine should ignore context lost events
  34245. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34246. */
  34247. doNotHandleContextLost?: boolean;
  34248. /**
  34249. * Defines that engine should ignore modifying touch action attribute and style
  34250. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34251. */
  34252. doNotHandleTouchAction?: boolean;
  34253. /**
  34254. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34255. */
  34256. useHighPrecisionFloats?: boolean;
  34257. /**
  34258. * Make the canvas XR Compatible for XR sessions
  34259. */
  34260. xrCompatible?: boolean;
  34261. }
  34262. /**
  34263. * The base engine class (root of all engines)
  34264. */
  34265. export class ThinEngine {
  34266. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34267. static ExceptionList: ({
  34268. key: string;
  34269. capture: string;
  34270. captureConstraint: number;
  34271. targets: string[];
  34272. } | {
  34273. key: string;
  34274. capture: null;
  34275. captureConstraint: null;
  34276. targets: string[];
  34277. })[];
  34278. /** @hidden */
  34279. static _TextureLoaders: IInternalTextureLoader[];
  34280. /**
  34281. * Returns the current npm package of the sdk
  34282. */
  34283. static get NpmPackage(): string;
  34284. /**
  34285. * Returns the current version of the framework
  34286. */
  34287. static get Version(): string;
  34288. /**
  34289. * Returns a string describing the current engine
  34290. */
  34291. get description(): string;
  34292. /**
  34293. * Gets or sets the epsilon value used by collision engine
  34294. */
  34295. static CollisionsEpsilon: number;
  34296. /**
  34297. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34298. */
  34299. static get ShadersRepository(): string;
  34300. static set ShadersRepository(value: string);
  34301. /** @hidden */
  34302. _shaderProcessor: IShaderProcessor;
  34303. /**
  34304. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34305. */
  34306. forcePOTTextures: boolean;
  34307. /**
  34308. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34309. */
  34310. isFullscreen: boolean;
  34311. /**
  34312. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34313. */
  34314. cullBackFaces: boolean;
  34315. /**
  34316. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34317. */
  34318. renderEvenInBackground: boolean;
  34319. /**
  34320. * Gets or sets a boolean indicating that cache can be kept between frames
  34321. */
  34322. preventCacheWipeBetweenFrames: boolean;
  34323. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34324. validateShaderPrograms: boolean;
  34325. /**
  34326. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34327. * This can provide greater z depth for distant objects.
  34328. */
  34329. useReverseDepthBuffer: boolean;
  34330. /**
  34331. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34332. */
  34333. disableUniformBuffers: boolean;
  34334. /** @hidden */
  34335. _uniformBuffers: UniformBuffer[];
  34336. /**
  34337. * Gets a boolean indicating that the engine supports uniform buffers
  34338. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34339. */
  34340. get supportsUniformBuffers(): boolean;
  34341. /** @hidden */
  34342. _gl: WebGLRenderingContext;
  34343. /** @hidden */
  34344. _webGLVersion: number;
  34345. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34346. protected _windowIsBackground: boolean;
  34347. protected _creationOptions: EngineOptions;
  34348. protected _highPrecisionShadersAllowed: boolean;
  34349. /** @hidden */
  34350. get _shouldUseHighPrecisionShader(): boolean;
  34351. /**
  34352. * Gets a boolean indicating that only power of 2 textures are supported
  34353. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34354. */
  34355. get needPOTTextures(): boolean;
  34356. /** @hidden */
  34357. _badOS: boolean;
  34358. /** @hidden */
  34359. _badDesktopOS: boolean;
  34360. private _hardwareScalingLevel;
  34361. /** @hidden */
  34362. _caps: EngineCapabilities;
  34363. private _isStencilEnable;
  34364. private _glVersion;
  34365. private _glRenderer;
  34366. private _glVendor;
  34367. /** @hidden */
  34368. _videoTextureSupported: boolean;
  34369. protected _renderingQueueLaunched: boolean;
  34370. protected _activeRenderLoops: (() => void)[];
  34371. /**
  34372. * Observable signaled when a context lost event is raised
  34373. */
  34374. onContextLostObservable: Observable<ThinEngine>;
  34375. /**
  34376. * Observable signaled when a context restored event is raised
  34377. */
  34378. onContextRestoredObservable: Observable<ThinEngine>;
  34379. private _onContextLost;
  34380. private _onContextRestored;
  34381. protected _contextWasLost: boolean;
  34382. /** @hidden */
  34383. _doNotHandleContextLost: boolean;
  34384. /**
  34385. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34386. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34387. */
  34388. get doNotHandleContextLost(): boolean;
  34389. set doNotHandleContextLost(value: boolean);
  34390. /**
  34391. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34392. */
  34393. disableVertexArrayObjects: boolean;
  34394. /** @hidden */
  34395. protected _colorWrite: boolean;
  34396. /** @hidden */
  34397. protected _colorWriteChanged: boolean;
  34398. /** @hidden */
  34399. protected _depthCullingState: DepthCullingState;
  34400. /** @hidden */
  34401. protected _stencilState: StencilState;
  34402. /** @hidden */
  34403. _alphaState: AlphaState;
  34404. /** @hidden */
  34405. _alphaMode: number;
  34406. /** @hidden */
  34407. _alphaEquation: number;
  34408. /** @hidden */
  34409. _internalTexturesCache: InternalTexture[];
  34410. /** @hidden */
  34411. protected _activeChannel: number;
  34412. private _currentTextureChannel;
  34413. /** @hidden */
  34414. protected _boundTexturesCache: {
  34415. [key: string]: Nullable<InternalTexture>;
  34416. };
  34417. /** @hidden */
  34418. protected _currentEffect: Nullable<Effect>;
  34419. /** @hidden */
  34420. protected _currentProgram: Nullable<WebGLProgram>;
  34421. private _compiledEffects;
  34422. private _vertexAttribArraysEnabled;
  34423. /** @hidden */
  34424. protected _cachedViewport: Nullable<IViewportLike>;
  34425. private _cachedVertexArrayObject;
  34426. /** @hidden */
  34427. protected _cachedVertexBuffers: any;
  34428. /** @hidden */
  34429. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34430. /** @hidden */
  34431. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34432. /** @hidden */
  34433. _currentRenderTarget: Nullable<InternalTexture>;
  34434. private _uintIndicesCurrentlySet;
  34435. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34436. /** @hidden */
  34437. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34438. /** @hidden */
  34439. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34440. private _currentBufferPointers;
  34441. private _currentInstanceLocations;
  34442. private _currentInstanceBuffers;
  34443. private _textureUnits;
  34444. /** @hidden */
  34445. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34446. /** @hidden */
  34447. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34448. /** @hidden */
  34449. _boundRenderFunction: any;
  34450. private _vaoRecordInProgress;
  34451. private _mustWipeVertexAttributes;
  34452. private _emptyTexture;
  34453. private _emptyCubeTexture;
  34454. private _emptyTexture3D;
  34455. private _emptyTexture2DArray;
  34456. /** @hidden */
  34457. _frameHandler: number;
  34458. private _nextFreeTextureSlots;
  34459. private _maxSimultaneousTextures;
  34460. private _activeRequests;
  34461. /** @hidden */
  34462. _transformTextureUrl: Nullable<(url: string) => string>;
  34463. protected get _supportsHardwareTextureRescaling(): boolean;
  34464. private _framebufferDimensionsObject;
  34465. /**
  34466. * sets the object from which width and height will be taken from when getting render width and height
  34467. * Will fallback to the gl object
  34468. * @param dimensions the framebuffer width and height that will be used.
  34469. */
  34470. set framebufferDimensionsObject(dimensions: Nullable<{
  34471. framebufferWidth: number;
  34472. framebufferHeight: number;
  34473. }>);
  34474. /**
  34475. * Gets the current viewport
  34476. */
  34477. get currentViewport(): Nullable<IViewportLike>;
  34478. /**
  34479. * Gets the default empty texture
  34480. */
  34481. get emptyTexture(): InternalTexture;
  34482. /**
  34483. * Gets the default empty 3D texture
  34484. */
  34485. get emptyTexture3D(): InternalTexture;
  34486. /**
  34487. * Gets the default empty 2D array texture
  34488. */
  34489. get emptyTexture2DArray(): InternalTexture;
  34490. /**
  34491. * Gets the default empty cube texture
  34492. */
  34493. get emptyCubeTexture(): InternalTexture;
  34494. /**
  34495. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34496. */
  34497. readonly premultipliedAlpha: boolean;
  34498. /**
  34499. * Observable event triggered before each texture is initialized
  34500. */
  34501. onBeforeTextureInitObservable: Observable<Texture>;
  34502. /**
  34503. * Creates a new engine
  34504. * @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
  34505. * @param antialias defines enable antialiasing (default: false)
  34506. * @param options defines further options to be sent to the getContext() function
  34507. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34508. */
  34509. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34510. private _rebuildInternalTextures;
  34511. private _rebuildEffects;
  34512. /**
  34513. * Gets a boolean indicating if all created effects are ready
  34514. * @returns true if all effects are ready
  34515. */
  34516. areAllEffectsReady(): boolean;
  34517. protected _rebuildBuffers(): void;
  34518. protected _initGLContext(): void;
  34519. /**
  34520. * Gets version of the current webGL context
  34521. */
  34522. get webGLVersion(): number;
  34523. /**
  34524. * Gets a string idenfifying the name of the class
  34525. * @returns "Engine" string
  34526. */
  34527. getClassName(): string;
  34528. /**
  34529. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34530. */
  34531. get isStencilEnable(): boolean;
  34532. /** @hidden */
  34533. _prepareWorkingCanvas(): void;
  34534. /**
  34535. * Reset the texture cache to empty state
  34536. */
  34537. resetTextureCache(): void;
  34538. /**
  34539. * Gets an object containing information about the current webGL context
  34540. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34541. */
  34542. getGlInfo(): {
  34543. vendor: string;
  34544. renderer: string;
  34545. version: string;
  34546. };
  34547. /**
  34548. * Defines the hardware scaling level.
  34549. * By default the hardware scaling level is computed from the window device ratio.
  34550. * 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.
  34551. * @param level defines the level to use
  34552. */
  34553. setHardwareScalingLevel(level: number): void;
  34554. /**
  34555. * Gets the current hardware scaling level.
  34556. * By default the hardware scaling level is computed from the window device ratio.
  34557. * 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.
  34558. * @returns a number indicating the current hardware scaling level
  34559. */
  34560. getHardwareScalingLevel(): number;
  34561. /**
  34562. * Gets the list of loaded textures
  34563. * @returns an array containing all loaded textures
  34564. */
  34565. getLoadedTexturesCache(): InternalTexture[];
  34566. /**
  34567. * Gets the object containing all engine capabilities
  34568. * @returns the EngineCapabilities object
  34569. */
  34570. getCaps(): EngineCapabilities;
  34571. /**
  34572. * stop executing a render loop function and remove it from the execution array
  34573. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34574. */
  34575. stopRenderLoop(renderFunction?: () => void): void;
  34576. /** @hidden */
  34577. _renderLoop(): void;
  34578. /**
  34579. * Gets the HTML canvas attached with the current webGL context
  34580. * @returns a HTML canvas
  34581. */
  34582. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34583. /**
  34584. * Gets host window
  34585. * @returns the host window object
  34586. */
  34587. getHostWindow(): Nullable<Window>;
  34588. /**
  34589. * Gets the current render width
  34590. * @param useScreen defines if screen size must be used (or the current render target if any)
  34591. * @returns a number defining the current render width
  34592. */
  34593. getRenderWidth(useScreen?: boolean): number;
  34594. /**
  34595. * Gets the current render height
  34596. * @param useScreen defines if screen size must be used (or the current render target if any)
  34597. * @returns a number defining the current render height
  34598. */
  34599. getRenderHeight(useScreen?: boolean): number;
  34600. /**
  34601. * Can be used to override the current requestAnimationFrame requester.
  34602. * @hidden
  34603. */
  34604. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34605. /**
  34606. * Register and execute a render loop. The engine can have more than one render function
  34607. * @param renderFunction defines the function to continuously execute
  34608. */
  34609. runRenderLoop(renderFunction: () => void): void;
  34610. /**
  34611. * Clear the current render buffer or the current render target (if any is set up)
  34612. * @param color defines the color to use
  34613. * @param backBuffer defines if the back buffer must be cleared
  34614. * @param depth defines if the depth buffer must be cleared
  34615. * @param stencil defines if the stencil buffer must be cleared
  34616. */
  34617. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34618. private _viewportCached;
  34619. /** @hidden */
  34620. _viewport(x: number, y: number, width: number, height: number): void;
  34621. /**
  34622. * Set the WebGL's viewport
  34623. * @param viewport defines the viewport element to be used
  34624. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34625. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34626. */
  34627. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34628. /**
  34629. * Begin a new frame
  34630. */
  34631. beginFrame(): void;
  34632. /**
  34633. * Enf the current frame
  34634. */
  34635. endFrame(): void;
  34636. /**
  34637. * Resize the view according to the canvas' size
  34638. */
  34639. resize(): void;
  34640. /**
  34641. * Force a specific size of the canvas
  34642. * @param width defines the new canvas' width
  34643. * @param height defines the new canvas' height
  34644. * @returns true if the size was changed
  34645. */
  34646. setSize(width: number, height: number): boolean;
  34647. /**
  34648. * Binds the frame buffer to the specified texture.
  34649. * @param texture The texture to render to or null for the default canvas
  34650. * @param faceIndex The face of the texture to render to in case of cube texture
  34651. * @param requiredWidth The width of the target to render to
  34652. * @param requiredHeight The height of the target to render to
  34653. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34654. * @param lodLevel defines the lod level to bind to the frame buffer
  34655. * @param layer defines the 2d array index to bind to frame buffer to
  34656. */
  34657. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34658. /** @hidden */
  34659. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34660. /**
  34661. * Unbind the current render target texture from the webGL context
  34662. * @param texture defines the render target texture to unbind
  34663. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34664. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34665. */
  34666. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34667. /**
  34668. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34669. */
  34670. flushFramebuffer(): void;
  34671. /**
  34672. * Unbind the current render target and bind the default framebuffer
  34673. */
  34674. restoreDefaultFramebuffer(): void;
  34675. /** @hidden */
  34676. protected _resetVertexBufferBinding(): void;
  34677. /**
  34678. * Creates a vertex buffer
  34679. * @param data the data for the vertex buffer
  34680. * @returns the new WebGL static buffer
  34681. */
  34682. createVertexBuffer(data: DataArray): DataBuffer;
  34683. private _createVertexBuffer;
  34684. /**
  34685. * Creates a dynamic vertex buffer
  34686. * @param data the data for the dynamic vertex buffer
  34687. * @returns the new WebGL dynamic buffer
  34688. */
  34689. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34690. protected _resetIndexBufferBinding(): void;
  34691. /**
  34692. * Creates a new index buffer
  34693. * @param indices defines the content of the index buffer
  34694. * @param updatable defines if the index buffer must be updatable
  34695. * @returns a new webGL buffer
  34696. */
  34697. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34698. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34699. /**
  34700. * Bind a webGL buffer to the webGL context
  34701. * @param buffer defines the buffer to bind
  34702. */
  34703. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34704. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34705. private bindBuffer;
  34706. /**
  34707. * update the bound buffer with the given data
  34708. * @param data defines the data to update
  34709. */
  34710. updateArrayBuffer(data: Float32Array): void;
  34711. private _vertexAttribPointer;
  34712. /** @hidden */
  34713. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34714. private _bindVertexBuffersAttributes;
  34715. /**
  34716. * Records a vertex array object
  34717. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34718. * @param vertexBuffers defines the list of vertex buffers to store
  34719. * @param indexBuffer defines the index buffer to store
  34720. * @param effect defines the effect to store
  34721. * @returns the new vertex array object
  34722. */
  34723. recordVertexArrayObject(vertexBuffers: {
  34724. [key: string]: VertexBuffer;
  34725. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34726. /**
  34727. * Bind a specific vertex array object
  34728. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34729. * @param vertexArrayObject defines the vertex array object to bind
  34730. * @param indexBuffer defines the index buffer to bind
  34731. */
  34732. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34733. /**
  34734. * Bind webGl buffers directly to the webGL context
  34735. * @param vertexBuffer defines the vertex buffer to bind
  34736. * @param indexBuffer defines the index buffer to bind
  34737. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34738. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34739. * @param effect defines the effect associated with the vertex buffer
  34740. */
  34741. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34742. private _unbindVertexArrayObject;
  34743. /**
  34744. * Bind a list of vertex buffers to the webGL context
  34745. * @param vertexBuffers defines the list of vertex buffers to bind
  34746. * @param indexBuffer defines the index buffer to bind
  34747. * @param effect defines the effect associated with the vertex buffers
  34748. */
  34749. bindBuffers(vertexBuffers: {
  34750. [key: string]: Nullable<VertexBuffer>;
  34751. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34752. /**
  34753. * Unbind all instance attributes
  34754. */
  34755. unbindInstanceAttributes(): void;
  34756. /**
  34757. * Release and free the memory of a vertex array object
  34758. * @param vao defines the vertex array object to delete
  34759. */
  34760. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34761. /** @hidden */
  34762. _releaseBuffer(buffer: DataBuffer): boolean;
  34763. protected _deleteBuffer(buffer: DataBuffer): void;
  34764. /**
  34765. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34766. * @param instancesBuffer defines the webGL buffer to update and bind
  34767. * @param data defines the data to store in the buffer
  34768. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34769. */
  34770. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34771. /**
  34772. * Bind the content of a webGL buffer used with instantiation
  34773. * @param instancesBuffer defines the webGL buffer to bind
  34774. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34775. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34776. */
  34777. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34778. /**
  34779. * Disable the instance attribute corresponding to the name in parameter
  34780. * @param name defines the name of the attribute to disable
  34781. */
  34782. disableInstanceAttributeByName(name: string): void;
  34783. /**
  34784. * Disable the instance attribute corresponding to the location in parameter
  34785. * @param attributeLocation defines the attribute location of the attribute to disable
  34786. */
  34787. disableInstanceAttribute(attributeLocation: number): void;
  34788. /**
  34789. * Disable the attribute corresponding to the location in parameter
  34790. * @param attributeLocation defines the attribute location of the attribute to disable
  34791. */
  34792. disableAttributeByIndex(attributeLocation: number): void;
  34793. /**
  34794. * Send a draw order
  34795. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34796. * @param indexStart defines the starting index
  34797. * @param indexCount defines the number of index to draw
  34798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34799. */
  34800. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34801. /**
  34802. * Draw a list of points
  34803. * @param verticesStart defines the index of first vertex to draw
  34804. * @param verticesCount defines the count of vertices to draw
  34805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34806. */
  34807. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34808. /**
  34809. * Draw a list of unindexed primitives
  34810. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34811. * @param verticesStart defines the index of first vertex to draw
  34812. * @param verticesCount defines the count of vertices to draw
  34813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34814. */
  34815. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34816. /**
  34817. * Draw a list of indexed primitives
  34818. * @param fillMode defines the primitive to use
  34819. * @param indexStart defines the starting index
  34820. * @param indexCount defines the number of index to draw
  34821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34822. */
  34823. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34824. /**
  34825. * Draw a list of unindexed primitives
  34826. * @param fillMode defines the primitive to use
  34827. * @param verticesStart defines the index of first vertex to draw
  34828. * @param verticesCount defines the count of vertices to draw
  34829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34830. */
  34831. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34832. private _drawMode;
  34833. /** @hidden */
  34834. protected _reportDrawCall(): void;
  34835. /** @hidden */
  34836. _releaseEffect(effect: Effect): void;
  34837. /** @hidden */
  34838. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34839. /**
  34840. * Create a new effect (used to store vertex/fragment shaders)
  34841. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34842. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34843. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34844. * @param samplers defines an array of string used to represent textures
  34845. * @param defines defines the string containing the defines to use to compile the shaders
  34846. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34847. * @param onCompiled defines a function to call when the effect creation is successful
  34848. * @param onError defines a function to call when the effect creation has failed
  34849. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34850. * @returns the new Effect
  34851. */
  34852. 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;
  34853. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34854. private _compileShader;
  34855. private _compileRawShader;
  34856. /** @hidden */
  34857. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34858. /**
  34859. * Directly creates a webGL program
  34860. * @param pipelineContext defines the pipeline context to attach to
  34861. * @param vertexCode defines the vertex shader code to use
  34862. * @param fragmentCode defines the fragment shader code to use
  34863. * @param context defines the webGL context to use (if not set, the current one will be used)
  34864. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34865. * @returns the new webGL program
  34866. */
  34867. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34868. /**
  34869. * Creates a webGL program
  34870. * @param pipelineContext defines the pipeline context to attach to
  34871. * @param vertexCode defines the vertex shader code to use
  34872. * @param fragmentCode defines the fragment shader code to use
  34873. * @param defines defines the string containing the defines to use to compile the shaders
  34874. * @param context defines the webGL context to use (if not set, the current one will be used)
  34875. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34876. * @returns the new webGL program
  34877. */
  34878. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34879. /**
  34880. * Creates a new pipeline context
  34881. * @returns the new pipeline
  34882. */
  34883. createPipelineContext(): IPipelineContext;
  34884. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34885. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34886. /** @hidden */
  34887. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34888. /** @hidden */
  34889. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34890. /** @hidden */
  34891. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34892. /**
  34893. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34894. * @param pipelineContext defines the pipeline context to use
  34895. * @param uniformsNames defines the list of uniform names
  34896. * @returns an array of webGL uniform locations
  34897. */
  34898. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34899. /**
  34900. * Gets the lsit of active attributes for a given webGL program
  34901. * @param pipelineContext defines the pipeline context to use
  34902. * @param attributesNames defines the list of attribute names to get
  34903. * @returns an array of indices indicating the offset of each attribute
  34904. */
  34905. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34906. /**
  34907. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34908. * @param effect defines the effect to activate
  34909. */
  34910. enableEffect(effect: Nullable<Effect>): void;
  34911. /**
  34912. * Set the value of an uniform to a number (int)
  34913. * @param uniform defines the webGL uniform location where to store the value
  34914. * @param value defines the int number to store
  34915. */
  34916. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34917. /**
  34918. * Set the value of an uniform to an array of int32
  34919. * @param uniform defines the webGL uniform location where to store the value
  34920. * @param array defines the array of int32 to store
  34921. */
  34922. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34923. /**
  34924. * Set the value of an uniform to an array of int32 (stored as vec2)
  34925. * @param uniform defines the webGL uniform location where to store the value
  34926. * @param array defines the array of int32 to store
  34927. */
  34928. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34929. /**
  34930. * Set the value of an uniform to an array of int32 (stored as vec3)
  34931. * @param uniform defines the webGL uniform location where to store the value
  34932. * @param array defines the array of int32 to store
  34933. */
  34934. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34935. /**
  34936. * Set the value of an uniform to an array of int32 (stored as vec4)
  34937. * @param uniform defines the webGL uniform location where to store the value
  34938. * @param array defines the array of int32 to store
  34939. */
  34940. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34941. /**
  34942. * Set the value of an uniform to an array of number
  34943. * @param uniform defines the webGL uniform location where to store the value
  34944. * @param array defines the array of number to store
  34945. */
  34946. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34947. /**
  34948. * Set the value of an uniform to an array of number (stored as vec2)
  34949. * @param uniform defines the webGL uniform location where to store the value
  34950. * @param array defines the array of number to store
  34951. */
  34952. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34953. /**
  34954. * Set the value of an uniform to an array of number (stored as vec3)
  34955. * @param uniform defines the webGL uniform location where to store the value
  34956. * @param array defines the array of number to store
  34957. */
  34958. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34959. /**
  34960. * Set the value of an uniform to an array of number (stored as vec4)
  34961. * @param uniform defines the webGL uniform location where to store the value
  34962. * @param array defines the array of number to store
  34963. */
  34964. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34965. /**
  34966. * Set the value of an uniform to an array of float32 (stored as matrices)
  34967. * @param uniform defines the webGL uniform location where to store the value
  34968. * @param matrices defines the array of float32 to store
  34969. */
  34970. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34971. /**
  34972. * Set the value of an uniform to a matrix (3x3)
  34973. * @param uniform defines the webGL uniform location where to store the value
  34974. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34975. */
  34976. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34977. /**
  34978. * Set the value of an uniform to a matrix (2x2)
  34979. * @param uniform defines the webGL uniform location where to store the value
  34980. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34981. */
  34982. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34983. /**
  34984. * Set the value of an uniform to a number (float)
  34985. * @param uniform defines the webGL uniform location where to store the value
  34986. * @param value defines the float number to store
  34987. */
  34988. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34989. /**
  34990. * Set the value of an uniform to a vec2
  34991. * @param uniform defines the webGL uniform location where to store the value
  34992. * @param x defines the 1st component of the value
  34993. * @param y defines the 2nd component of the value
  34994. */
  34995. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34996. /**
  34997. * Set the value of an uniform to a vec3
  34998. * @param uniform defines the webGL uniform location where to store the value
  34999. * @param x defines the 1st component of the value
  35000. * @param y defines the 2nd component of the value
  35001. * @param z defines the 3rd component of the value
  35002. */
  35003. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35004. /**
  35005. * Set the value of an uniform to a vec4
  35006. * @param uniform defines the webGL uniform location where to store the value
  35007. * @param x defines the 1st component of the value
  35008. * @param y defines the 2nd component of the value
  35009. * @param z defines the 3rd component of the value
  35010. * @param w defines the 4th component of the value
  35011. */
  35012. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35013. /**
  35014. * Apply all cached states (depth, culling, stencil and alpha)
  35015. */
  35016. applyStates(): void;
  35017. /**
  35018. * Enable or disable color writing
  35019. * @param enable defines the state to set
  35020. */
  35021. setColorWrite(enable: boolean): void;
  35022. /**
  35023. * Gets a boolean indicating if color writing is enabled
  35024. * @returns the current color writing state
  35025. */
  35026. getColorWrite(): boolean;
  35027. /**
  35028. * Gets the depth culling state manager
  35029. */
  35030. get depthCullingState(): DepthCullingState;
  35031. /**
  35032. * Gets the alpha state manager
  35033. */
  35034. get alphaState(): AlphaState;
  35035. /**
  35036. * Gets the stencil state manager
  35037. */
  35038. get stencilState(): StencilState;
  35039. /**
  35040. * Clears the list of texture accessible through engine.
  35041. * This can help preventing texture load conflict due to name collision.
  35042. */
  35043. clearInternalTexturesCache(): void;
  35044. /**
  35045. * Force the entire cache to be cleared
  35046. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35047. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35048. */
  35049. wipeCaches(bruteForce?: boolean): void;
  35050. /** @hidden */
  35051. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35052. min: number;
  35053. mag: number;
  35054. };
  35055. /** @hidden */
  35056. _createTexture(): WebGLTexture;
  35057. /**
  35058. * Usually called from Texture.ts.
  35059. * Passed information to create a WebGLTexture
  35060. * @param url defines a value which contains one of the following:
  35061. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35062. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35063. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35064. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35065. * @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)
  35066. * @param scene needed for loading to the correct scene
  35067. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35068. * @param onLoad optional callback to be called upon successful completion
  35069. * @param onError optional callback to be called upon failure
  35070. * @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
  35071. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35072. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35073. * @param forcedExtension defines the extension to use to pick the right loader
  35074. * @param mimeType defines an optional mime type
  35075. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35076. */
  35077. 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;
  35078. /**
  35079. * Loads an image as an HTMLImageElement.
  35080. * @param input url string, ArrayBuffer, or Blob to load
  35081. * @param onLoad callback called when the image successfully loads
  35082. * @param onError callback called when the image fails to load
  35083. * @param offlineProvider offline provider for caching
  35084. * @param mimeType optional mime type
  35085. * @returns the HTMLImageElement of the loaded image
  35086. * @hidden
  35087. */
  35088. 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>;
  35089. /**
  35090. * @hidden
  35091. */
  35092. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35093. private _unpackFlipYCached;
  35094. /**
  35095. * In case you are sharing the context with other applications, it might
  35096. * be interested to not cache the unpack flip y state to ensure a consistent
  35097. * value would be set.
  35098. */
  35099. enableUnpackFlipYCached: boolean;
  35100. /** @hidden */
  35101. _unpackFlipY(value: boolean): void;
  35102. /** @hidden */
  35103. _getUnpackAlignement(): number;
  35104. private _getTextureTarget;
  35105. /**
  35106. * Update the sampling mode of a given texture
  35107. * @param samplingMode defines the required sampling mode
  35108. * @param texture defines the texture to update
  35109. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35110. */
  35111. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35112. /**
  35113. * Update the sampling mode of a given texture
  35114. * @param texture defines the texture to update
  35115. * @param wrapU defines the texture wrap mode of the u coordinates
  35116. * @param wrapV defines the texture wrap mode of the v coordinates
  35117. * @param wrapR defines the texture wrap mode of the r coordinates
  35118. */
  35119. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35120. /** @hidden */
  35121. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35122. width: number;
  35123. height: number;
  35124. layers?: number;
  35125. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35126. /** @hidden */
  35127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35128. /** @hidden */
  35129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35130. /**
  35131. * Update a portion of an internal texture
  35132. * @param texture defines the texture to update
  35133. * @param imageData defines the data to store into the texture
  35134. * @param xOffset defines the x coordinates of the update rectangle
  35135. * @param yOffset defines the y coordinates of the update rectangle
  35136. * @param width defines the width of the update rectangle
  35137. * @param height defines the height of the update rectangle
  35138. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35139. * @param lod defines the lod level to update (0 by default)
  35140. */
  35141. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35142. /** @hidden */
  35143. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35144. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35145. private _prepareWebGLTexture;
  35146. /** @hidden */
  35147. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35148. private _getDepthStencilBuffer;
  35149. /** @hidden */
  35150. _releaseFramebufferObjects(texture: InternalTexture): void;
  35151. /** @hidden */
  35152. _releaseTexture(texture: InternalTexture): void;
  35153. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35154. protected _setProgram(program: WebGLProgram): void;
  35155. protected _boundUniforms: {
  35156. [key: number]: WebGLUniformLocation;
  35157. };
  35158. /**
  35159. * Binds an effect to the webGL context
  35160. * @param effect defines the effect to bind
  35161. */
  35162. bindSamplers(effect: Effect): void;
  35163. private _activateCurrentTexture;
  35164. /** @hidden */
  35165. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35166. /** @hidden */
  35167. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35168. /**
  35169. * Unbind all textures from the webGL context
  35170. */
  35171. unbindAllTextures(): void;
  35172. /**
  35173. * Sets a texture to the according uniform.
  35174. * @param channel The texture channel
  35175. * @param uniform The uniform to set
  35176. * @param texture The texture to apply
  35177. */
  35178. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35179. private _bindSamplerUniformToChannel;
  35180. private _getTextureWrapMode;
  35181. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35182. /**
  35183. * Sets an array of texture to the webGL context
  35184. * @param channel defines the channel where the texture array must be set
  35185. * @param uniform defines the associated uniform location
  35186. * @param textures defines the array of textures to bind
  35187. */
  35188. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35189. /** @hidden */
  35190. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35191. private _setTextureParameterFloat;
  35192. private _setTextureParameterInteger;
  35193. /**
  35194. * Unbind all vertex attributes from the webGL context
  35195. */
  35196. unbindAllAttributes(): void;
  35197. /**
  35198. * 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
  35199. */
  35200. releaseEffects(): void;
  35201. /**
  35202. * Dispose and release all associated resources
  35203. */
  35204. dispose(): void;
  35205. /**
  35206. * Attach a new callback raised when context lost event is fired
  35207. * @param callback defines the callback to call
  35208. */
  35209. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35210. /**
  35211. * Attach a new callback raised when context restored event is fired
  35212. * @param callback defines the callback to call
  35213. */
  35214. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35215. /**
  35216. * Get the current error code of the webGL context
  35217. * @returns the error code
  35218. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35219. */
  35220. getError(): number;
  35221. private _canRenderToFloatFramebuffer;
  35222. private _canRenderToHalfFloatFramebuffer;
  35223. private _canRenderToFramebuffer;
  35224. /** @hidden */
  35225. _getWebGLTextureType(type: number): number;
  35226. /** @hidden */
  35227. _getInternalFormat(format: number): number;
  35228. /** @hidden */
  35229. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35230. /** @hidden */
  35231. _getRGBAMultiSampleBufferFormat(type: number): number;
  35232. /** @hidden */
  35233. _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;
  35234. /**
  35235. * Loads a file from a url
  35236. * @param url url to load
  35237. * @param onSuccess callback called when the file successfully loads
  35238. * @param onProgress callback called while file is loading (if the server supports this mode)
  35239. * @param offlineProvider defines the offline provider for caching
  35240. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35241. * @param onError callback called when the file fails to load
  35242. * @returns a file request object
  35243. * @hidden
  35244. */
  35245. 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;
  35246. /**
  35247. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35248. * @param x defines the x coordinate of the rectangle where pixels must be read
  35249. * @param y defines the y coordinate of the rectangle where pixels must be read
  35250. * @param width defines the width of the rectangle where pixels must be read
  35251. * @param height defines the height of the rectangle where pixels must be read
  35252. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35253. * @returns a Uint8Array containing RGBA colors
  35254. */
  35255. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35256. private static _isSupported;
  35257. /**
  35258. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35259. * @returns true if the engine can be created
  35260. * @ignorenaming
  35261. */
  35262. static isSupported(): boolean;
  35263. /**
  35264. * Find the next highest power of two.
  35265. * @param x Number to start search from.
  35266. * @return Next highest power of two.
  35267. */
  35268. static CeilingPOT(x: number): number;
  35269. /**
  35270. * Find the next lowest power of two.
  35271. * @param x Number to start search from.
  35272. * @return Next lowest power of two.
  35273. */
  35274. static FloorPOT(x: number): number;
  35275. /**
  35276. * Find the nearest power of two.
  35277. * @param x Number to start search from.
  35278. * @return Next nearest power of two.
  35279. */
  35280. static NearestPOT(x: number): number;
  35281. /**
  35282. * Get the closest exponent of two
  35283. * @param value defines the value to approximate
  35284. * @param max defines the maximum value to return
  35285. * @param mode defines how to define the closest value
  35286. * @returns closest exponent of two of the given value
  35287. */
  35288. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35289. /**
  35290. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35291. * @param func - the function to be called
  35292. * @param requester - the object that will request the next frame. Falls back to window.
  35293. * @returns frame number
  35294. */
  35295. static QueueNewFrame(func: () => void, requester?: any): number;
  35296. /**
  35297. * Gets host document
  35298. * @returns the host document object
  35299. */
  35300. getHostDocument(): Nullable<Document>;
  35301. }
  35302. }
  35303. declare module BABYLON {
  35304. /**
  35305. * Class representing spherical harmonics coefficients to the 3rd degree
  35306. */
  35307. export class SphericalHarmonics {
  35308. /**
  35309. * Defines whether or not the harmonics have been prescaled for rendering.
  35310. */
  35311. preScaled: boolean;
  35312. /**
  35313. * The l0,0 coefficients of the spherical harmonics
  35314. */
  35315. l00: Vector3;
  35316. /**
  35317. * The l1,-1 coefficients of the spherical harmonics
  35318. */
  35319. l1_1: Vector3;
  35320. /**
  35321. * The l1,0 coefficients of the spherical harmonics
  35322. */
  35323. l10: Vector3;
  35324. /**
  35325. * The l1,1 coefficients of the spherical harmonics
  35326. */
  35327. l11: Vector3;
  35328. /**
  35329. * The l2,-2 coefficients of the spherical harmonics
  35330. */
  35331. l2_2: Vector3;
  35332. /**
  35333. * The l2,-1 coefficients of the spherical harmonics
  35334. */
  35335. l2_1: Vector3;
  35336. /**
  35337. * The l2,0 coefficients of the spherical harmonics
  35338. */
  35339. l20: Vector3;
  35340. /**
  35341. * The l2,1 coefficients of the spherical harmonics
  35342. */
  35343. l21: Vector3;
  35344. /**
  35345. * The l2,2 coefficients of the spherical harmonics
  35346. */
  35347. l22: Vector3;
  35348. /**
  35349. * Adds a light to the spherical harmonics
  35350. * @param direction the direction of the light
  35351. * @param color the color of the light
  35352. * @param deltaSolidAngle the delta solid angle of the light
  35353. */
  35354. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35355. /**
  35356. * Scales the spherical harmonics by the given amount
  35357. * @param scale the amount to scale
  35358. */
  35359. scaleInPlace(scale: number): void;
  35360. /**
  35361. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35362. *
  35363. * ```
  35364. * E_lm = A_l * L_lm
  35365. * ```
  35366. *
  35367. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35368. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35369. * the scaling factors are given in equation 9.
  35370. */
  35371. convertIncidentRadianceToIrradiance(): void;
  35372. /**
  35373. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35374. *
  35375. * ```
  35376. * L = (1/pi) * E * rho
  35377. * ```
  35378. *
  35379. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35380. */
  35381. convertIrradianceToLambertianRadiance(): void;
  35382. /**
  35383. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35384. * required operations at run time.
  35385. *
  35386. * This is simply done by scaling back the SH with Ylm constants parameter.
  35387. * The trigonometric part being applied by the shader at run time.
  35388. */
  35389. preScaleForRendering(): void;
  35390. /**
  35391. * Constructs a spherical harmonics from an array.
  35392. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35393. * @returns the spherical harmonics
  35394. */
  35395. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35396. /**
  35397. * Gets the spherical harmonics from polynomial
  35398. * @param polynomial the spherical polynomial
  35399. * @returns the spherical harmonics
  35400. */
  35401. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35402. }
  35403. /**
  35404. * Class representing spherical polynomial coefficients to the 3rd degree
  35405. */
  35406. export class SphericalPolynomial {
  35407. private _harmonics;
  35408. /**
  35409. * The spherical harmonics used to create the polynomials.
  35410. */
  35411. get preScaledHarmonics(): SphericalHarmonics;
  35412. /**
  35413. * The x coefficients of the spherical polynomial
  35414. */
  35415. x: Vector3;
  35416. /**
  35417. * The y coefficients of the spherical polynomial
  35418. */
  35419. y: Vector3;
  35420. /**
  35421. * The z coefficients of the spherical polynomial
  35422. */
  35423. z: Vector3;
  35424. /**
  35425. * The xx coefficients of the spherical polynomial
  35426. */
  35427. xx: Vector3;
  35428. /**
  35429. * The yy coefficients of the spherical polynomial
  35430. */
  35431. yy: Vector3;
  35432. /**
  35433. * The zz coefficients of the spherical polynomial
  35434. */
  35435. zz: Vector3;
  35436. /**
  35437. * The xy coefficients of the spherical polynomial
  35438. */
  35439. xy: Vector3;
  35440. /**
  35441. * The yz coefficients of the spherical polynomial
  35442. */
  35443. yz: Vector3;
  35444. /**
  35445. * The zx coefficients of the spherical polynomial
  35446. */
  35447. zx: Vector3;
  35448. /**
  35449. * Adds an ambient color to the spherical polynomial
  35450. * @param color the color to add
  35451. */
  35452. addAmbient(color: Color3): void;
  35453. /**
  35454. * Scales the spherical polynomial by the given amount
  35455. * @param scale the amount to scale
  35456. */
  35457. scaleInPlace(scale: number): void;
  35458. /**
  35459. * Gets the spherical polynomial from harmonics
  35460. * @param harmonics the spherical harmonics
  35461. * @returns the spherical polynomial
  35462. */
  35463. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35464. /**
  35465. * Constructs a spherical polynomial from an array.
  35466. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35467. * @returns the spherical polynomial
  35468. */
  35469. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35470. }
  35471. }
  35472. declare module BABYLON {
  35473. /**
  35474. * Defines the source of the internal texture
  35475. */
  35476. export enum InternalTextureSource {
  35477. /**
  35478. * The source of the texture data is unknown
  35479. */
  35480. Unknown = 0,
  35481. /**
  35482. * Texture data comes from an URL
  35483. */
  35484. Url = 1,
  35485. /**
  35486. * Texture data is only used for temporary storage
  35487. */
  35488. Temp = 2,
  35489. /**
  35490. * Texture data comes from raw data (ArrayBuffer)
  35491. */
  35492. Raw = 3,
  35493. /**
  35494. * Texture content is dynamic (video or dynamic texture)
  35495. */
  35496. Dynamic = 4,
  35497. /**
  35498. * Texture content is generated by rendering to it
  35499. */
  35500. RenderTarget = 5,
  35501. /**
  35502. * Texture content is part of a multi render target process
  35503. */
  35504. MultiRenderTarget = 6,
  35505. /**
  35506. * Texture data comes from a cube data file
  35507. */
  35508. Cube = 7,
  35509. /**
  35510. * Texture data comes from a raw cube data
  35511. */
  35512. CubeRaw = 8,
  35513. /**
  35514. * Texture data come from a prefiltered cube data file
  35515. */
  35516. CubePrefiltered = 9,
  35517. /**
  35518. * Texture content is raw 3D data
  35519. */
  35520. Raw3D = 10,
  35521. /**
  35522. * Texture content is raw 2D array data
  35523. */
  35524. Raw2DArray = 11,
  35525. /**
  35526. * Texture content is a depth texture
  35527. */
  35528. Depth = 12,
  35529. /**
  35530. * Texture data comes from a raw cube data encoded with RGBD
  35531. */
  35532. CubeRawRGBD = 13
  35533. }
  35534. /**
  35535. * Class used to store data associated with WebGL texture data for the engine
  35536. * This class should not be used directly
  35537. */
  35538. export class InternalTexture {
  35539. /** @hidden */
  35540. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35541. /**
  35542. * Defines if the texture is ready
  35543. */
  35544. isReady: boolean;
  35545. /**
  35546. * Defines if the texture is a cube texture
  35547. */
  35548. isCube: boolean;
  35549. /**
  35550. * Defines if the texture contains 3D data
  35551. */
  35552. is3D: boolean;
  35553. /**
  35554. * Defines if the texture contains 2D array data
  35555. */
  35556. is2DArray: boolean;
  35557. /**
  35558. * Defines if the texture contains multiview data
  35559. */
  35560. isMultiview: boolean;
  35561. /**
  35562. * Gets the URL used to load this texture
  35563. */
  35564. url: string;
  35565. /**
  35566. * Gets the sampling mode of the texture
  35567. */
  35568. samplingMode: number;
  35569. /**
  35570. * Gets a boolean indicating if the texture needs mipmaps generation
  35571. */
  35572. generateMipMaps: boolean;
  35573. /**
  35574. * Gets the number of samples used by the texture (WebGL2+ only)
  35575. */
  35576. samples: number;
  35577. /**
  35578. * Gets the type of the texture (int, float...)
  35579. */
  35580. type: number;
  35581. /**
  35582. * Gets the format of the texture (RGB, RGBA...)
  35583. */
  35584. format: number;
  35585. /**
  35586. * Observable called when the texture is loaded
  35587. */
  35588. onLoadedObservable: Observable<InternalTexture>;
  35589. /**
  35590. * Gets the width of the texture
  35591. */
  35592. width: number;
  35593. /**
  35594. * Gets the height of the texture
  35595. */
  35596. height: number;
  35597. /**
  35598. * Gets the depth of the texture
  35599. */
  35600. depth: number;
  35601. /**
  35602. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35603. */
  35604. baseWidth: number;
  35605. /**
  35606. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35607. */
  35608. baseHeight: number;
  35609. /**
  35610. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35611. */
  35612. baseDepth: number;
  35613. /**
  35614. * Gets a boolean indicating if the texture is inverted on Y axis
  35615. */
  35616. invertY: boolean;
  35617. /** @hidden */
  35618. _invertVScale: boolean;
  35619. /** @hidden */
  35620. _associatedChannel: number;
  35621. /** @hidden */
  35622. _source: InternalTextureSource;
  35623. /** @hidden */
  35624. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35625. /** @hidden */
  35626. _bufferView: Nullable<ArrayBufferView>;
  35627. /** @hidden */
  35628. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35629. /** @hidden */
  35630. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35631. /** @hidden */
  35632. _size: number;
  35633. /** @hidden */
  35634. _extension: string;
  35635. /** @hidden */
  35636. _files: Nullable<string[]>;
  35637. /** @hidden */
  35638. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35639. /** @hidden */
  35640. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35641. /** @hidden */
  35642. _framebuffer: Nullable<WebGLFramebuffer>;
  35643. /** @hidden */
  35644. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35645. /** @hidden */
  35646. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35647. /** @hidden */
  35648. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35649. /** @hidden */
  35650. _attachments: Nullable<number[]>;
  35651. /** @hidden */
  35652. _textureArray: Nullable<InternalTexture[]>;
  35653. /** @hidden */
  35654. _cachedCoordinatesMode: Nullable<number>;
  35655. /** @hidden */
  35656. _cachedWrapU: Nullable<number>;
  35657. /** @hidden */
  35658. _cachedWrapV: Nullable<number>;
  35659. /** @hidden */
  35660. _cachedWrapR: Nullable<number>;
  35661. /** @hidden */
  35662. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35663. /** @hidden */
  35664. _isDisabled: boolean;
  35665. /** @hidden */
  35666. _compression: Nullable<string>;
  35667. /** @hidden */
  35668. _generateStencilBuffer: boolean;
  35669. /** @hidden */
  35670. _generateDepthBuffer: boolean;
  35671. /** @hidden */
  35672. _comparisonFunction: number;
  35673. /** @hidden */
  35674. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35675. /** @hidden */
  35676. _lodGenerationScale: number;
  35677. /** @hidden */
  35678. _lodGenerationOffset: number;
  35679. /** @hidden */
  35680. _depthStencilTexture: Nullable<InternalTexture>;
  35681. /** @hidden */
  35682. _colorTextureArray: Nullable<WebGLTexture>;
  35683. /** @hidden */
  35684. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35685. /** @hidden */
  35686. _lodTextureHigh: Nullable<BaseTexture>;
  35687. /** @hidden */
  35688. _lodTextureMid: Nullable<BaseTexture>;
  35689. /** @hidden */
  35690. _lodTextureLow: Nullable<BaseTexture>;
  35691. /** @hidden */
  35692. _isRGBD: boolean;
  35693. /** @hidden */
  35694. _linearSpecularLOD: boolean;
  35695. /** @hidden */
  35696. _irradianceTexture: Nullable<BaseTexture>;
  35697. /** @hidden */
  35698. _webGLTexture: Nullable<WebGLTexture>;
  35699. /** @hidden */
  35700. _references: number;
  35701. private _engine;
  35702. /**
  35703. * Gets the Engine the texture belongs to.
  35704. * @returns The babylon engine
  35705. */
  35706. getEngine(): ThinEngine;
  35707. /**
  35708. * Gets the data source type of the texture
  35709. */
  35710. get source(): InternalTextureSource;
  35711. /**
  35712. * Creates a new InternalTexture
  35713. * @param engine defines the engine to use
  35714. * @param source defines the type of data that will be used
  35715. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35716. */
  35717. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35718. /**
  35719. * Increments the number of references (ie. the number of Texture that point to it)
  35720. */
  35721. incrementReferences(): void;
  35722. /**
  35723. * Change the size of the texture (not the size of the content)
  35724. * @param width defines the new width
  35725. * @param height defines the new height
  35726. * @param depth defines the new depth (1 by default)
  35727. */
  35728. updateSize(width: int, height: int, depth?: int): void;
  35729. /** @hidden */
  35730. _rebuild(): void;
  35731. /** @hidden */
  35732. _swapAndDie(target: InternalTexture): void;
  35733. /**
  35734. * Dispose the current allocated resources
  35735. */
  35736. dispose(): void;
  35737. }
  35738. }
  35739. declare module BABYLON {
  35740. /**
  35741. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35742. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35743. */
  35744. export class Analyser {
  35745. /**
  35746. * Gets or sets the smoothing
  35747. * @ignorenaming
  35748. */
  35749. SMOOTHING: number;
  35750. /**
  35751. * Gets or sets the FFT table size
  35752. * @ignorenaming
  35753. */
  35754. FFT_SIZE: number;
  35755. /**
  35756. * Gets or sets the bar graph amplitude
  35757. * @ignorenaming
  35758. */
  35759. BARGRAPHAMPLITUDE: number;
  35760. /**
  35761. * Gets or sets the position of the debug canvas
  35762. * @ignorenaming
  35763. */
  35764. DEBUGCANVASPOS: {
  35765. x: number;
  35766. y: number;
  35767. };
  35768. /**
  35769. * Gets or sets the debug canvas size
  35770. * @ignorenaming
  35771. */
  35772. DEBUGCANVASSIZE: {
  35773. width: number;
  35774. height: number;
  35775. };
  35776. private _byteFreqs;
  35777. private _byteTime;
  35778. private _floatFreqs;
  35779. private _webAudioAnalyser;
  35780. private _debugCanvas;
  35781. private _debugCanvasContext;
  35782. private _scene;
  35783. private _registerFunc;
  35784. private _audioEngine;
  35785. /**
  35786. * Creates a new analyser
  35787. * @param scene defines hosting scene
  35788. */
  35789. constructor(scene: Scene);
  35790. /**
  35791. * Get the number of data values you will have to play with for the visualization
  35792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35793. * @returns a number
  35794. */
  35795. getFrequencyBinCount(): number;
  35796. /**
  35797. * Gets the current frequency data as a byte array
  35798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35799. * @returns a Uint8Array
  35800. */
  35801. getByteFrequencyData(): Uint8Array;
  35802. /**
  35803. * Gets the current waveform as a byte array
  35804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35805. * @returns a Uint8Array
  35806. */
  35807. getByteTimeDomainData(): Uint8Array;
  35808. /**
  35809. * Gets the current frequency data as a float array
  35810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35811. * @returns a Float32Array
  35812. */
  35813. getFloatFrequencyData(): Float32Array;
  35814. /**
  35815. * Renders the debug canvas
  35816. */
  35817. drawDebugCanvas(): void;
  35818. /**
  35819. * Stops rendering the debug canvas and removes it
  35820. */
  35821. stopDebugCanvas(): void;
  35822. /**
  35823. * Connects two audio nodes
  35824. * @param inputAudioNode defines first node to connect
  35825. * @param outputAudioNode defines second node to connect
  35826. */
  35827. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35828. /**
  35829. * Releases all associated resources
  35830. */
  35831. dispose(): void;
  35832. }
  35833. }
  35834. declare module BABYLON {
  35835. /**
  35836. * This represents an audio engine and it is responsible
  35837. * to play, synchronize and analyse sounds throughout the application.
  35838. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35839. */
  35840. export interface IAudioEngine extends IDisposable {
  35841. /**
  35842. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35843. */
  35844. readonly canUseWebAudio: boolean;
  35845. /**
  35846. * Gets the current AudioContext if available.
  35847. */
  35848. readonly audioContext: Nullable<AudioContext>;
  35849. /**
  35850. * The master gain node defines the global audio volume of your audio engine.
  35851. */
  35852. readonly masterGain: GainNode;
  35853. /**
  35854. * Gets whether or not mp3 are supported by your browser.
  35855. */
  35856. readonly isMP3supported: boolean;
  35857. /**
  35858. * Gets whether or not ogg are supported by your browser.
  35859. */
  35860. readonly isOGGsupported: boolean;
  35861. /**
  35862. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35863. * @ignoreNaming
  35864. */
  35865. WarnedWebAudioUnsupported: boolean;
  35866. /**
  35867. * Defines if the audio engine relies on a custom unlocked button.
  35868. * In this case, the embedded button will not be displayed.
  35869. */
  35870. useCustomUnlockedButton: boolean;
  35871. /**
  35872. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35873. */
  35874. readonly unlocked: boolean;
  35875. /**
  35876. * Event raised when audio has been unlocked on the browser.
  35877. */
  35878. onAudioUnlockedObservable: Observable<AudioEngine>;
  35879. /**
  35880. * Event raised when audio has been locked on the browser.
  35881. */
  35882. onAudioLockedObservable: Observable<AudioEngine>;
  35883. /**
  35884. * Flags the audio engine in Locked state.
  35885. * This happens due to new browser policies preventing audio to autoplay.
  35886. */
  35887. lock(): void;
  35888. /**
  35889. * Unlocks the audio engine once a user action has been done on the dom.
  35890. * This is helpful to resume play once browser policies have been satisfied.
  35891. */
  35892. unlock(): void;
  35893. /**
  35894. * Gets the global volume sets on the master gain.
  35895. * @returns the global volume if set or -1 otherwise
  35896. */
  35897. getGlobalVolume(): number;
  35898. /**
  35899. * Sets the global volume of your experience (sets on the master gain).
  35900. * @param newVolume Defines the new global volume of the application
  35901. */
  35902. setGlobalVolume(newVolume: number): void;
  35903. /**
  35904. * Connect the audio engine to an audio analyser allowing some amazing
  35905. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35907. * @param analyser The analyser to connect to the engine
  35908. */
  35909. connectToAnalyser(analyser: Analyser): void;
  35910. }
  35911. /**
  35912. * This represents the default audio engine used in babylon.
  35913. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35915. */
  35916. export class AudioEngine implements IAudioEngine {
  35917. private _audioContext;
  35918. private _audioContextInitialized;
  35919. private _muteButton;
  35920. private _hostElement;
  35921. /**
  35922. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35923. */
  35924. canUseWebAudio: boolean;
  35925. /**
  35926. * The master gain node defines the global audio volume of your audio engine.
  35927. */
  35928. masterGain: GainNode;
  35929. /**
  35930. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35931. * @ignoreNaming
  35932. */
  35933. WarnedWebAudioUnsupported: boolean;
  35934. /**
  35935. * Gets whether or not mp3 are supported by your browser.
  35936. */
  35937. isMP3supported: boolean;
  35938. /**
  35939. * Gets whether or not ogg are supported by your browser.
  35940. */
  35941. isOGGsupported: boolean;
  35942. /**
  35943. * Gets whether audio has been unlocked on the device.
  35944. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35945. * a user interaction has happened.
  35946. */
  35947. unlocked: boolean;
  35948. /**
  35949. * Defines if the audio engine relies on a custom unlocked button.
  35950. * In this case, the embedded button will not be displayed.
  35951. */
  35952. useCustomUnlockedButton: boolean;
  35953. /**
  35954. * Event raised when audio has been unlocked on the browser.
  35955. */
  35956. onAudioUnlockedObservable: Observable<AudioEngine>;
  35957. /**
  35958. * Event raised when audio has been locked on the browser.
  35959. */
  35960. onAudioLockedObservable: Observable<AudioEngine>;
  35961. /**
  35962. * Gets the current AudioContext if available.
  35963. */
  35964. get audioContext(): Nullable<AudioContext>;
  35965. private _connectedAnalyser;
  35966. /**
  35967. * Instantiates a new audio engine.
  35968. *
  35969. * There should be only one per page as some browsers restrict the number
  35970. * of audio contexts you can create.
  35971. * @param hostElement defines the host element where to display the mute icon if necessary
  35972. */
  35973. constructor(hostElement?: Nullable<HTMLElement>);
  35974. /**
  35975. * Flags the audio engine in Locked state.
  35976. * This happens due to new browser policies preventing audio to autoplay.
  35977. */
  35978. lock(): void;
  35979. /**
  35980. * Unlocks the audio engine once a user action has been done on the dom.
  35981. * This is helpful to resume play once browser policies have been satisfied.
  35982. */
  35983. unlock(): void;
  35984. private _resumeAudioContext;
  35985. private _initializeAudioContext;
  35986. private _tryToRun;
  35987. private _triggerRunningState;
  35988. private _triggerSuspendedState;
  35989. private _displayMuteButton;
  35990. private _moveButtonToTopLeft;
  35991. private _onResize;
  35992. private _hideMuteButton;
  35993. /**
  35994. * Destroy and release the resources associated with the audio ccontext.
  35995. */
  35996. dispose(): void;
  35997. /**
  35998. * Gets the global volume sets on the master gain.
  35999. * @returns the global volume if set or -1 otherwise
  36000. */
  36001. getGlobalVolume(): number;
  36002. /**
  36003. * Sets the global volume of your experience (sets on the master gain).
  36004. * @param newVolume Defines the new global volume of the application
  36005. */
  36006. setGlobalVolume(newVolume: number): void;
  36007. /**
  36008. * Connect the audio engine to an audio analyser allowing some amazing
  36009. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36011. * @param analyser The analyser to connect to the engine
  36012. */
  36013. connectToAnalyser(analyser: Analyser): void;
  36014. }
  36015. }
  36016. declare module BABYLON {
  36017. /**
  36018. * Interface used to present a loading screen while loading a scene
  36019. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36020. */
  36021. export interface ILoadingScreen {
  36022. /**
  36023. * Function called to display the loading screen
  36024. */
  36025. displayLoadingUI: () => void;
  36026. /**
  36027. * Function called to hide the loading screen
  36028. */
  36029. hideLoadingUI: () => void;
  36030. /**
  36031. * Gets or sets the color to use for the background
  36032. */
  36033. loadingUIBackgroundColor: string;
  36034. /**
  36035. * Gets or sets the text to display while loading
  36036. */
  36037. loadingUIText: string;
  36038. }
  36039. /**
  36040. * Class used for the default loading screen
  36041. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36042. */
  36043. export class DefaultLoadingScreen implements ILoadingScreen {
  36044. private _renderingCanvas;
  36045. private _loadingText;
  36046. private _loadingDivBackgroundColor;
  36047. private _loadingDiv;
  36048. private _loadingTextDiv;
  36049. /** Gets or sets the logo url to use for the default loading screen */
  36050. static DefaultLogoUrl: string;
  36051. /** Gets or sets the spinner url to use for the default loading screen */
  36052. static DefaultSpinnerUrl: string;
  36053. /**
  36054. * Creates a new default loading screen
  36055. * @param _renderingCanvas defines the canvas used to render the scene
  36056. * @param _loadingText defines the default text to display
  36057. * @param _loadingDivBackgroundColor defines the default background color
  36058. */
  36059. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36060. /**
  36061. * Function called to display the loading screen
  36062. */
  36063. displayLoadingUI(): void;
  36064. /**
  36065. * Function called to hide the loading screen
  36066. */
  36067. hideLoadingUI(): void;
  36068. /**
  36069. * Gets or sets the text to display while loading
  36070. */
  36071. set loadingUIText(text: string);
  36072. get loadingUIText(): string;
  36073. /**
  36074. * Gets or sets the color to use for the background
  36075. */
  36076. get loadingUIBackgroundColor(): string;
  36077. set loadingUIBackgroundColor(color: string);
  36078. private _resizeLoadingUI;
  36079. }
  36080. }
  36081. declare module BABYLON {
  36082. /**
  36083. * Interface for any object that can request an animation frame
  36084. */
  36085. export interface ICustomAnimationFrameRequester {
  36086. /**
  36087. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36088. */
  36089. renderFunction?: Function;
  36090. /**
  36091. * Called to request the next frame to render to
  36092. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36093. */
  36094. requestAnimationFrame: Function;
  36095. /**
  36096. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36097. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36098. */
  36099. requestID?: number;
  36100. }
  36101. }
  36102. declare module BABYLON {
  36103. /**
  36104. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36105. */
  36106. export class PerformanceMonitor {
  36107. private _enabled;
  36108. private _rollingFrameTime;
  36109. private _lastFrameTimeMs;
  36110. /**
  36111. * constructor
  36112. * @param frameSampleSize The number of samples required to saturate the sliding window
  36113. */
  36114. constructor(frameSampleSize?: number);
  36115. /**
  36116. * Samples current frame
  36117. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36118. */
  36119. sampleFrame(timeMs?: number): void;
  36120. /**
  36121. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36122. */
  36123. get averageFrameTime(): number;
  36124. /**
  36125. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36126. */
  36127. get averageFrameTimeVariance(): number;
  36128. /**
  36129. * Returns the frame time of the most recent frame
  36130. */
  36131. get instantaneousFrameTime(): number;
  36132. /**
  36133. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36134. */
  36135. get averageFPS(): number;
  36136. /**
  36137. * Returns the average framerate in frames per second using the most recent frame time
  36138. */
  36139. get instantaneousFPS(): number;
  36140. /**
  36141. * Returns true if enough samples have been taken to completely fill the sliding window
  36142. */
  36143. get isSaturated(): boolean;
  36144. /**
  36145. * Enables contributions to the sliding window sample set
  36146. */
  36147. enable(): void;
  36148. /**
  36149. * Disables contributions to the sliding window sample set
  36150. * Samples will not be interpolated over the disabled period
  36151. */
  36152. disable(): void;
  36153. /**
  36154. * Returns true if sampling is enabled
  36155. */
  36156. get isEnabled(): boolean;
  36157. /**
  36158. * Resets performance monitor
  36159. */
  36160. reset(): void;
  36161. }
  36162. /**
  36163. * RollingAverage
  36164. *
  36165. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36166. */
  36167. export class RollingAverage {
  36168. /**
  36169. * Current average
  36170. */
  36171. average: number;
  36172. /**
  36173. * Current variance
  36174. */
  36175. variance: number;
  36176. protected _samples: Array<number>;
  36177. protected _sampleCount: number;
  36178. protected _pos: number;
  36179. protected _m2: number;
  36180. /**
  36181. * constructor
  36182. * @param length The number of samples required to saturate the sliding window
  36183. */
  36184. constructor(length: number);
  36185. /**
  36186. * Adds a sample to the sample set
  36187. * @param v The sample value
  36188. */
  36189. add(v: number): void;
  36190. /**
  36191. * Returns previously added values or null if outside of history or outside the sliding window domain
  36192. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36193. * @return Value previously recorded with add() or null if outside of range
  36194. */
  36195. history(i: number): number;
  36196. /**
  36197. * Returns true if enough samples have been taken to completely fill the sliding window
  36198. * @return true if sample-set saturated
  36199. */
  36200. isSaturated(): boolean;
  36201. /**
  36202. * Resets the rolling average (equivalent to 0 samples taken so far)
  36203. */
  36204. reset(): void;
  36205. /**
  36206. * Wraps a value around the sample range boundaries
  36207. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36208. * @return Wrapped position in sample range
  36209. */
  36210. protected _wrapPosition(i: number): number;
  36211. }
  36212. }
  36213. declare module BABYLON {
  36214. /**
  36215. * This class is used to track a performance counter which is number based.
  36216. * The user has access to many properties which give statistics of different nature.
  36217. *
  36218. * The implementer can track two kinds of Performance Counter: time and count.
  36219. * 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.
  36220. * 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.
  36221. */
  36222. export class PerfCounter {
  36223. /**
  36224. * Gets or sets a global boolean to turn on and off all the counters
  36225. */
  36226. static Enabled: boolean;
  36227. /**
  36228. * Returns the smallest value ever
  36229. */
  36230. get min(): number;
  36231. /**
  36232. * Returns the biggest value ever
  36233. */
  36234. get max(): number;
  36235. /**
  36236. * Returns the average value since the performance counter is running
  36237. */
  36238. get average(): number;
  36239. /**
  36240. * Returns the average value of the last second the counter was monitored
  36241. */
  36242. get lastSecAverage(): number;
  36243. /**
  36244. * Returns the current value
  36245. */
  36246. get current(): number;
  36247. /**
  36248. * Gets the accumulated total
  36249. */
  36250. get total(): number;
  36251. /**
  36252. * Gets the total value count
  36253. */
  36254. get count(): number;
  36255. /**
  36256. * Creates a new counter
  36257. */
  36258. constructor();
  36259. /**
  36260. * Call this method to start monitoring a new frame.
  36261. * 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.
  36262. */
  36263. fetchNewFrame(): void;
  36264. /**
  36265. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36266. * @param newCount the count value to add to the monitored count
  36267. * @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.
  36268. */
  36269. addCount(newCount: number, fetchResult: boolean): void;
  36270. /**
  36271. * Start monitoring this performance counter
  36272. */
  36273. beginMonitoring(): void;
  36274. /**
  36275. * Compute the time lapsed since the previous beginMonitoring() call.
  36276. * @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
  36277. */
  36278. endMonitoring(newFrame?: boolean): void;
  36279. private _fetchResult;
  36280. private _startMonitoringTime;
  36281. private _min;
  36282. private _max;
  36283. private _average;
  36284. private _current;
  36285. private _totalValueCount;
  36286. private _totalAccumulated;
  36287. private _lastSecAverage;
  36288. private _lastSecAccumulated;
  36289. private _lastSecTime;
  36290. private _lastSecValueCount;
  36291. }
  36292. }
  36293. declare module BABYLON {
  36294. interface ThinEngine {
  36295. /**
  36296. * Sets alpha constants used by some alpha blending modes
  36297. * @param r defines the red component
  36298. * @param g defines the green component
  36299. * @param b defines the blue component
  36300. * @param a defines the alpha component
  36301. */
  36302. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36303. /**
  36304. * Sets the current alpha mode
  36305. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36306. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36307. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36308. */
  36309. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36310. /**
  36311. * Gets the current alpha mode
  36312. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36313. * @returns the current alpha mode
  36314. */
  36315. getAlphaMode(): number;
  36316. /**
  36317. * Sets the current alpha equation
  36318. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36319. */
  36320. setAlphaEquation(equation: number): void;
  36321. /**
  36322. * Gets the current alpha equation.
  36323. * @returns the current alpha equation
  36324. */
  36325. getAlphaEquation(): number;
  36326. }
  36327. }
  36328. declare module BABYLON {
  36329. interface ThinEngine {
  36330. /** @hidden */
  36331. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36332. }
  36333. }
  36334. declare module BABYLON {
  36335. /**
  36336. * Defines the interface used by display changed events
  36337. */
  36338. export interface IDisplayChangedEventArgs {
  36339. /** Gets the vrDisplay object (if any) */
  36340. vrDisplay: Nullable<any>;
  36341. /** Gets a boolean indicating if webVR is supported */
  36342. vrSupported: boolean;
  36343. }
  36344. /**
  36345. * Defines the interface used by objects containing a viewport (like a camera)
  36346. */
  36347. interface IViewportOwnerLike {
  36348. /**
  36349. * Gets or sets the viewport
  36350. */
  36351. viewport: IViewportLike;
  36352. }
  36353. /**
  36354. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36355. */
  36356. export class Engine extends ThinEngine {
  36357. /** Defines that alpha blending is disabled */
  36358. static readonly ALPHA_DISABLE: number;
  36359. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36360. static readonly ALPHA_ADD: number;
  36361. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36362. static readonly ALPHA_COMBINE: number;
  36363. /** Defines that alpha blending to DEST - SRC * DEST */
  36364. static readonly ALPHA_SUBTRACT: number;
  36365. /** Defines that alpha blending to SRC * DEST */
  36366. static readonly ALPHA_MULTIPLY: number;
  36367. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36368. static readonly ALPHA_MAXIMIZED: number;
  36369. /** Defines that alpha blending to SRC + DEST */
  36370. static readonly ALPHA_ONEONE: number;
  36371. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36372. static readonly ALPHA_PREMULTIPLIED: number;
  36373. /**
  36374. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36375. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36376. */
  36377. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36378. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36379. static readonly ALPHA_INTERPOLATE: number;
  36380. /**
  36381. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36382. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36383. */
  36384. static readonly ALPHA_SCREENMODE: number;
  36385. /** Defines that the ressource is not delayed*/
  36386. static readonly DELAYLOADSTATE_NONE: number;
  36387. /** Defines that the ressource was successfully delay loaded */
  36388. static readonly DELAYLOADSTATE_LOADED: number;
  36389. /** Defines that the ressource is currently delay loading */
  36390. static readonly DELAYLOADSTATE_LOADING: number;
  36391. /** Defines that the ressource is delayed and has not started loading */
  36392. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36393. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36394. static readonly NEVER: number;
  36395. /** 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 */
  36396. static readonly ALWAYS: number;
  36397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36398. static readonly LESS: number;
  36399. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36400. static readonly EQUAL: number;
  36401. /** 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 */
  36402. static readonly LEQUAL: number;
  36403. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36404. static readonly GREATER: number;
  36405. /** 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 */
  36406. static readonly GEQUAL: number;
  36407. /** 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 */
  36408. static readonly NOTEQUAL: number;
  36409. /** Passed to stencilOperation to specify that stencil value must be kept */
  36410. static readonly KEEP: number;
  36411. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36412. static readonly REPLACE: number;
  36413. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36414. static readonly INCR: number;
  36415. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36416. static readonly DECR: number;
  36417. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36418. static readonly INVERT: number;
  36419. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36420. static readonly INCR_WRAP: number;
  36421. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36422. static readonly DECR_WRAP: number;
  36423. /** Texture is not repeating outside of 0..1 UVs */
  36424. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36425. /** Texture is repeating outside of 0..1 UVs */
  36426. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36427. /** Texture is repeating and mirrored */
  36428. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36429. /** ALPHA */
  36430. static readonly TEXTUREFORMAT_ALPHA: number;
  36431. /** LUMINANCE */
  36432. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36433. /** LUMINANCE_ALPHA */
  36434. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36435. /** RGB */
  36436. static readonly TEXTUREFORMAT_RGB: number;
  36437. /** RGBA */
  36438. static readonly TEXTUREFORMAT_RGBA: number;
  36439. /** RED */
  36440. static readonly TEXTUREFORMAT_RED: number;
  36441. /** RED (2nd reference) */
  36442. static readonly TEXTUREFORMAT_R: number;
  36443. /** RG */
  36444. static readonly TEXTUREFORMAT_RG: number;
  36445. /** RED_INTEGER */
  36446. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36447. /** RED_INTEGER (2nd reference) */
  36448. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36449. /** RG_INTEGER */
  36450. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36451. /** RGB_INTEGER */
  36452. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36453. /** RGBA_INTEGER */
  36454. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36455. /** UNSIGNED_BYTE */
  36456. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36457. /** UNSIGNED_BYTE (2nd reference) */
  36458. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36459. /** FLOAT */
  36460. static readonly TEXTURETYPE_FLOAT: number;
  36461. /** HALF_FLOAT */
  36462. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36463. /** BYTE */
  36464. static readonly TEXTURETYPE_BYTE: number;
  36465. /** SHORT */
  36466. static readonly TEXTURETYPE_SHORT: number;
  36467. /** UNSIGNED_SHORT */
  36468. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36469. /** INT */
  36470. static readonly TEXTURETYPE_INT: number;
  36471. /** UNSIGNED_INT */
  36472. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36473. /** UNSIGNED_SHORT_4_4_4_4 */
  36474. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36475. /** UNSIGNED_SHORT_5_5_5_1 */
  36476. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36477. /** UNSIGNED_SHORT_5_6_5 */
  36478. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36479. /** UNSIGNED_INT_2_10_10_10_REV */
  36480. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36481. /** UNSIGNED_INT_24_8 */
  36482. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36483. /** UNSIGNED_INT_10F_11F_11F_REV */
  36484. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36485. /** UNSIGNED_INT_5_9_9_9_REV */
  36486. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36487. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36488. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36489. /** nearest is mag = nearest and min = nearest and mip = linear */
  36490. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36492. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36493. /** Trilinear is mag = linear and min = linear and mip = linear */
  36494. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36495. /** nearest is mag = nearest and min = nearest and mip = linear */
  36496. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36497. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36498. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36499. /** Trilinear is mag = linear and min = linear and mip = linear */
  36500. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36501. /** mag = nearest and min = nearest and mip = nearest */
  36502. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36503. /** mag = nearest and min = linear and mip = nearest */
  36504. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36505. /** mag = nearest and min = linear and mip = linear */
  36506. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36507. /** mag = nearest and min = linear and mip = none */
  36508. static readonly TEXTURE_NEAREST_LINEAR: number;
  36509. /** mag = nearest and min = nearest and mip = none */
  36510. static readonly TEXTURE_NEAREST_NEAREST: number;
  36511. /** mag = linear and min = nearest and mip = nearest */
  36512. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36513. /** mag = linear and min = nearest and mip = linear */
  36514. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36515. /** mag = linear and min = linear and mip = none */
  36516. static readonly TEXTURE_LINEAR_LINEAR: number;
  36517. /** mag = linear and min = nearest and mip = none */
  36518. static readonly TEXTURE_LINEAR_NEAREST: number;
  36519. /** Explicit coordinates mode */
  36520. static readonly TEXTURE_EXPLICIT_MODE: number;
  36521. /** Spherical coordinates mode */
  36522. static readonly TEXTURE_SPHERICAL_MODE: number;
  36523. /** Planar coordinates mode */
  36524. static readonly TEXTURE_PLANAR_MODE: number;
  36525. /** Cubic coordinates mode */
  36526. static readonly TEXTURE_CUBIC_MODE: number;
  36527. /** Projection coordinates mode */
  36528. static readonly TEXTURE_PROJECTION_MODE: number;
  36529. /** Skybox coordinates mode */
  36530. static readonly TEXTURE_SKYBOX_MODE: number;
  36531. /** Inverse Cubic coordinates mode */
  36532. static readonly TEXTURE_INVCUBIC_MODE: number;
  36533. /** Equirectangular coordinates mode */
  36534. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36535. /** Equirectangular Fixed coordinates mode */
  36536. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36537. /** Equirectangular Fixed Mirrored coordinates mode */
  36538. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36539. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36540. static readonly SCALEMODE_FLOOR: number;
  36541. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36542. static readonly SCALEMODE_NEAREST: number;
  36543. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36544. static readonly SCALEMODE_CEILING: number;
  36545. /**
  36546. * Returns the current npm package of the sdk
  36547. */
  36548. static get NpmPackage(): string;
  36549. /**
  36550. * Returns the current version of the framework
  36551. */
  36552. static get Version(): string;
  36553. /** Gets the list of created engines */
  36554. static get Instances(): Engine[];
  36555. /**
  36556. * Gets the latest created engine
  36557. */
  36558. static get LastCreatedEngine(): Nullable<Engine>;
  36559. /**
  36560. * Gets the latest created scene
  36561. */
  36562. static get LastCreatedScene(): Nullable<Scene>;
  36563. /**
  36564. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36565. * @param flag defines which part of the materials must be marked as dirty
  36566. * @param predicate defines a predicate used to filter which materials should be affected
  36567. */
  36568. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36569. /**
  36570. * Method called to create the default loading screen.
  36571. * This can be overriden in your own app.
  36572. * @param canvas The rendering canvas element
  36573. * @returns The loading screen
  36574. */
  36575. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36576. /**
  36577. * Method called to create the default rescale post process on each engine.
  36578. */
  36579. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36580. /**
  36581. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36582. **/
  36583. enableOfflineSupport: boolean;
  36584. /**
  36585. * 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)
  36586. **/
  36587. disableManifestCheck: boolean;
  36588. /**
  36589. * Gets the list of created scenes
  36590. */
  36591. scenes: Scene[];
  36592. /**
  36593. * Event raised when a new scene is created
  36594. */
  36595. onNewSceneAddedObservable: Observable<Scene>;
  36596. /**
  36597. * Gets the list of created postprocesses
  36598. */
  36599. postProcesses: PostProcess[];
  36600. /**
  36601. * Gets a boolean indicating if the pointer is currently locked
  36602. */
  36603. isPointerLock: boolean;
  36604. /**
  36605. * Observable event triggered each time the rendering canvas is resized
  36606. */
  36607. onResizeObservable: Observable<Engine>;
  36608. /**
  36609. * Observable event triggered each time the canvas loses focus
  36610. */
  36611. onCanvasBlurObservable: Observable<Engine>;
  36612. /**
  36613. * Observable event triggered each time the canvas gains focus
  36614. */
  36615. onCanvasFocusObservable: Observable<Engine>;
  36616. /**
  36617. * Observable event triggered each time the canvas receives pointerout event
  36618. */
  36619. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36620. /**
  36621. * Observable raised when the engine begins a new frame
  36622. */
  36623. onBeginFrameObservable: Observable<Engine>;
  36624. /**
  36625. * If set, will be used to request the next animation frame for the render loop
  36626. */
  36627. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36628. /**
  36629. * Observable raised when the engine ends the current frame
  36630. */
  36631. onEndFrameObservable: Observable<Engine>;
  36632. /**
  36633. * Observable raised when the engine is about to compile a shader
  36634. */
  36635. onBeforeShaderCompilationObservable: Observable<Engine>;
  36636. /**
  36637. * Observable raised when the engine has jsut compiled a shader
  36638. */
  36639. onAfterShaderCompilationObservable: Observable<Engine>;
  36640. /**
  36641. * Gets the audio engine
  36642. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36643. * @ignorenaming
  36644. */
  36645. static audioEngine: IAudioEngine;
  36646. /**
  36647. * Default AudioEngine factory responsible of creating the Audio Engine.
  36648. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36649. */
  36650. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36651. /**
  36652. * Default offline support factory responsible of creating a tool used to store data locally.
  36653. * By default, this will create a Database object if the workload has been embedded.
  36654. */
  36655. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36656. private _loadingScreen;
  36657. private _pointerLockRequested;
  36658. private _rescalePostProcess;
  36659. private _deterministicLockstep;
  36660. private _lockstepMaxSteps;
  36661. private _timeStep;
  36662. protected get _supportsHardwareTextureRescaling(): boolean;
  36663. private _fps;
  36664. private _deltaTime;
  36665. /** @hidden */
  36666. _drawCalls: PerfCounter;
  36667. /** 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 */
  36668. canvasTabIndex: number;
  36669. /**
  36670. * Turn this value on if you want to pause FPS computation when in background
  36671. */
  36672. disablePerformanceMonitorInBackground: boolean;
  36673. private _performanceMonitor;
  36674. /**
  36675. * Gets the performance monitor attached to this engine
  36676. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36677. */
  36678. get performanceMonitor(): PerformanceMonitor;
  36679. private _onFocus;
  36680. private _onBlur;
  36681. private _onCanvasPointerOut;
  36682. private _onCanvasBlur;
  36683. private _onCanvasFocus;
  36684. private _onFullscreenChange;
  36685. private _onPointerLockChange;
  36686. /**
  36687. * Gets the HTML element used to attach event listeners
  36688. * @returns a HTML element
  36689. */
  36690. getInputElement(): Nullable<HTMLElement>;
  36691. /**
  36692. * Creates a new engine
  36693. * @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
  36694. * @param antialias defines enable antialiasing (default: false)
  36695. * @param options defines further options to be sent to the getContext() function
  36696. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36697. */
  36698. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36699. /**
  36700. * Gets current aspect ratio
  36701. * @param viewportOwner defines the camera to use to get the aspect ratio
  36702. * @param useScreen defines if screen size must be used (or the current render target if any)
  36703. * @returns a number defining the aspect ratio
  36704. */
  36705. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36706. /**
  36707. * Gets current screen aspect ratio
  36708. * @returns a number defining the aspect ratio
  36709. */
  36710. getScreenAspectRatio(): number;
  36711. /**
  36712. * Gets the client rect of the HTML canvas attached with the current webGL context
  36713. * @returns a client rectanglee
  36714. */
  36715. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36716. /**
  36717. * Gets the client rect of the HTML element used for events
  36718. * @returns a client rectanglee
  36719. */
  36720. getInputElementClientRect(): Nullable<ClientRect>;
  36721. /**
  36722. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36723. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36724. * @returns true if engine is in deterministic lock step mode
  36725. */
  36726. isDeterministicLockStep(): boolean;
  36727. /**
  36728. * Gets the max steps when engine is running in deterministic lock step
  36729. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36730. * @returns the max steps
  36731. */
  36732. getLockstepMaxSteps(): number;
  36733. /**
  36734. * Returns the time in ms between steps when using deterministic lock step.
  36735. * @returns time step in (ms)
  36736. */
  36737. getTimeStep(): number;
  36738. /**
  36739. * Force the mipmap generation for the given render target texture
  36740. * @param texture defines the render target texture to use
  36741. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36742. */
  36743. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36744. /** States */
  36745. /**
  36746. * Set various states to the webGL context
  36747. * @param culling defines backface culling state
  36748. * @param zOffset defines the value to apply to zOffset (0 by default)
  36749. * @param force defines if states must be applied even if cache is up to date
  36750. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36751. */
  36752. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36753. /**
  36754. * Set the z offset to apply to current rendering
  36755. * @param value defines the offset to apply
  36756. */
  36757. setZOffset(value: number): void;
  36758. /**
  36759. * Gets the current value of the zOffset
  36760. * @returns the current zOffset state
  36761. */
  36762. getZOffset(): number;
  36763. /**
  36764. * Enable or disable depth buffering
  36765. * @param enable defines the state to set
  36766. */
  36767. setDepthBuffer(enable: boolean): void;
  36768. /**
  36769. * Gets a boolean indicating if depth writing is enabled
  36770. * @returns the current depth writing state
  36771. */
  36772. getDepthWrite(): boolean;
  36773. /**
  36774. * Enable or disable depth writing
  36775. * @param enable defines the state to set
  36776. */
  36777. setDepthWrite(enable: boolean): void;
  36778. /**
  36779. * Gets a boolean indicating if stencil buffer is enabled
  36780. * @returns the current stencil buffer state
  36781. */
  36782. getStencilBuffer(): boolean;
  36783. /**
  36784. * Enable or disable the stencil buffer
  36785. * @param enable defines if the stencil buffer must be enabled or disabled
  36786. */
  36787. setStencilBuffer(enable: boolean): void;
  36788. /**
  36789. * Gets the current stencil mask
  36790. * @returns a number defining the new stencil mask to use
  36791. */
  36792. getStencilMask(): number;
  36793. /**
  36794. * Sets the current stencil mask
  36795. * @param mask defines the new stencil mask to use
  36796. */
  36797. setStencilMask(mask: number): void;
  36798. /**
  36799. * Gets the current stencil function
  36800. * @returns a number defining the stencil function to use
  36801. */
  36802. getStencilFunction(): number;
  36803. /**
  36804. * Gets the current stencil reference value
  36805. * @returns a number defining the stencil reference value to use
  36806. */
  36807. getStencilFunctionReference(): number;
  36808. /**
  36809. * Gets the current stencil mask
  36810. * @returns a number defining the stencil mask to use
  36811. */
  36812. getStencilFunctionMask(): number;
  36813. /**
  36814. * Sets the current stencil function
  36815. * @param stencilFunc defines the new stencil function to use
  36816. */
  36817. setStencilFunction(stencilFunc: number): void;
  36818. /**
  36819. * Sets the current stencil reference
  36820. * @param reference defines the new stencil reference to use
  36821. */
  36822. setStencilFunctionReference(reference: number): void;
  36823. /**
  36824. * Sets the current stencil mask
  36825. * @param mask defines the new stencil mask to use
  36826. */
  36827. setStencilFunctionMask(mask: number): void;
  36828. /**
  36829. * Gets the current stencil operation when stencil fails
  36830. * @returns a number defining stencil operation to use when stencil fails
  36831. */
  36832. getStencilOperationFail(): number;
  36833. /**
  36834. * Gets the current stencil operation when depth fails
  36835. * @returns a number defining stencil operation to use when depth fails
  36836. */
  36837. getStencilOperationDepthFail(): number;
  36838. /**
  36839. * Gets the current stencil operation when stencil passes
  36840. * @returns a number defining stencil operation to use when stencil passes
  36841. */
  36842. getStencilOperationPass(): number;
  36843. /**
  36844. * Sets the stencil operation to use when stencil fails
  36845. * @param operation defines the stencil operation to use when stencil fails
  36846. */
  36847. setStencilOperationFail(operation: number): void;
  36848. /**
  36849. * Sets the stencil operation to use when depth fails
  36850. * @param operation defines the stencil operation to use when depth fails
  36851. */
  36852. setStencilOperationDepthFail(operation: number): void;
  36853. /**
  36854. * Sets the stencil operation to use when stencil passes
  36855. * @param operation defines the stencil operation to use when stencil passes
  36856. */
  36857. setStencilOperationPass(operation: number): void;
  36858. /**
  36859. * Sets a boolean indicating if the dithering state is enabled or disabled
  36860. * @param value defines the dithering state
  36861. */
  36862. setDitheringState(value: boolean): void;
  36863. /**
  36864. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36865. * @param value defines the rasterizer state
  36866. */
  36867. setRasterizerState(value: boolean): void;
  36868. /**
  36869. * Gets the current depth function
  36870. * @returns a number defining the depth function
  36871. */
  36872. getDepthFunction(): Nullable<number>;
  36873. /**
  36874. * Sets the current depth function
  36875. * @param depthFunc defines the function to use
  36876. */
  36877. setDepthFunction(depthFunc: number): void;
  36878. /**
  36879. * Sets the current depth function to GREATER
  36880. */
  36881. setDepthFunctionToGreater(): void;
  36882. /**
  36883. * Sets the current depth function to GEQUAL
  36884. */
  36885. setDepthFunctionToGreaterOrEqual(): void;
  36886. /**
  36887. * Sets the current depth function to LESS
  36888. */
  36889. setDepthFunctionToLess(): void;
  36890. /**
  36891. * Sets the current depth function to LEQUAL
  36892. */
  36893. setDepthFunctionToLessOrEqual(): void;
  36894. private _cachedStencilBuffer;
  36895. private _cachedStencilFunction;
  36896. private _cachedStencilMask;
  36897. private _cachedStencilOperationPass;
  36898. private _cachedStencilOperationFail;
  36899. private _cachedStencilOperationDepthFail;
  36900. private _cachedStencilReference;
  36901. /**
  36902. * Caches the the state of the stencil buffer
  36903. */
  36904. cacheStencilState(): void;
  36905. /**
  36906. * Restores the state of the stencil buffer
  36907. */
  36908. restoreStencilState(): void;
  36909. /**
  36910. * Directly set the WebGL Viewport
  36911. * @param x defines the x coordinate of the viewport (in screen space)
  36912. * @param y defines the y coordinate of the viewport (in screen space)
  36913. * @param width defines the width of the viewport (in screen space)
  36914. * @param height defines the height of the viewport (in screen space)
  36915. * @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
  36916. */
  36917. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36918. /**
  36919. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36920. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36921. * @param y defines the y-coordinate of the corner of the clear rectangle
  36922. * @param width defines the width of the clear rectangle
  36923. * @param height defines the height of the clear rectangle
  36924. * @param clearColor defines the clear color
  36925. */
  36926. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36927. /**
  36928. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36929. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36930. * @param y defines the y-coordinate of the corner of the clear rectangle
  36931. * @param width defines the width of the clear rectangle
  36932. * @param height defines the height of the clear rectangle
  36933. */
  36934. enableScissor(x: number, y: number, width: number, height: number): void;
  36935. /**
  36936. * Disable previously set scissor test rectangle
  36937. */
  36938. disableScissor(): void;
  36939. protected _reportDrawCall(): void;
  36940. /**
  36941. * Initializes a webVR display and starts listening to display change events
  36942. * The onVRDisplayChangedObservable will be notified upon these changes
  36943. * @returns The onVRDisplayChangedObservable
  36944. */
  36945. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36946. /** @hidden */
  36947. _prepareVRComponent(): void;
  36948. /** @hidden */
  36949. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36950. /** @hidden */
  36951. _submitVRFrame(): void;
  36952. /**
  36953. * Call this function to leave webVR mode
  36954. * Will do nothing if webVR is not supported or if there is no webVR device
  36955. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36956. */
  36957. disableVR(): void;
  36958. /**
  36959. * Gets a boolean indicating that the system is in VR mode and is presenting
  36960. * @returns true if VR mode is engaged
  36961. */
  36962. isVRPresenting(): boolean;
  36963. /** @hidden */
  36964. _requestVRFrame(): void;
  36965. /** @hidden */
  36966. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36967. /**
  36968. * Gets the source code of the vertex shader associated with a specific webGL program
  36969. * @param program defines the program to use
  36970. * @returns a string containing the source code of the vertex shader associated with the program
  36971. */
  36972. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36973. /**
  36974. * Gets the source code of the fragment shader associated with a specific webGL program
  36975. * @param program defines the program to use
  36976. * @returns a string containing the source code of the fragment shader associated with the program
  36977. */
  36978. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36979. /**
  36980. * Sets a depth stencil texture from a render target to the according uniform.
  36981. * @param channel The texture channel
  36982. * @param uniform The uniform to set
  36983. * @param texture The render target texture containing the depth stencil texture to apply
  36984. */
  36985. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36986. /**
  36987. * Sets a texture to the webGL context from a postprocess
  36988. * @param channel defines the channel to use
  36989. * @param postProcess defines the source postprocess
  36990. */
  36991. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36992. /**
  36993. * Binds the output of the passed in post process to the texture channel specified
  36994. * @param channel The channel the texture should be bound to
  36995. * @param postProcess The post process which's output should be bound
  36996. */
  36997. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36998. protected _rebuildBuffers(): void;
  36999. /** @hidden */
  37000. _renderFrame(): void;
  37001. _renderLoop(): void;
  37002. /** @hidden */
  37003. _renderViews(): boolean;
  37004. /**
  37005. * Toggle full screen mode
  37006. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37007. */
  37008. switchFullscreen(requestPointerLock: boolean): void;
  37009. /**
  37010. * Enters full screen mode
  37011. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37012. */
  37013. enterFullscreen(requestPointerLock: boolean): void;
  37014. /**
  37015. * Exits full screen mode
  37016. */
  37017. exitFullscreen(): void;
  37018. /**
  37019. * Enters Pointerlock mode
  37020. */
  37021. enterPointerlock(): void;
  37022. /**
  37023. * Exits Pointerlock mode
  37024. */
  37025. exitPointerlock(): void;
  37026. /**
  37027. * Begin a new frame
  37028. */
  37029. beginFrame(): void;
  37030. /**
  37031. * Enf the current frame
  37032. */
  37033. endFrame(): void;
  37034. resize(): void;
  37035. /**
  37036. * Force a specific size of the canvas
  37037. * @param width defines the new canvas' width
  37038. * @param height defines the new canvas' height
  37039. * @returns true if the size was changed
  37040. */
  37041. setSize(width: number, height: number): boolean;
  37042. /**
  37043. * Updates a dynamic vertex buffer.
  37044. * @param vertexBuffer the vertex buffer to update
  37045. * @param data the data used to update the vertex buffer
  37046. * @param byteOffset the byte offset of the data
  37047. * @param byteLength the byte length of the data
  37048. */
  37049. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37050. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37051. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37052. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37053. _releaseTexture(texture: InternalTexture): void;
  37054. /**
  37055. * @hidden
  37056. * Rescales a texture
  37057. * @param source input texutre
  37058. * @param destination destination texture
  37059. * @param scene scene to use to render the resize
  37060. * @param internalFormat format to use when resizing
  37061. * @param onComplete callback to be called when resize has completed
  37062. */
  37063. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37064. /**
  37065. * Gets the current framerate
  37066. * @returns a number representing the framerate
  37067. */
  37068. getFps(): number;
  37069. /**
  37070. * Gets the time spent between current and previous frame
  37071. * @returns a number representing the delta time in ms
  37072. */
  37073. getDeltaTime(): number;
  37074. private _measureFps;
  37075. /** @hidden */
  37076. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37077. /**
  37078. * Update a dynamic index buffer
  37079. * @param indexBuffer defines the target index buffer
  37080. * @param indices defines the data to update
  37081. * @param offset defines the offset in the target index buffer where update should start
  37082. */
  37083. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37084. /**
  37085. * Updates the sample count of a render target texture
  37086. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37087. * @param texture defines the texture to update
  37088. * @param samples defines the sample count to set
  37089. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37090. */
  37091. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37092. /**
  37093. * Updates a depth texture Comparison Mode and Function.
  37094. * If the comparison Function is equal to 0, the mode will be set to none.
  37095. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37096. * @param texture The texture to set the comparison function for
  37097. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37098. */
  37099. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37100. /**
  37101. * Creates a webGL buffer to use with instanciation
  37102. * @param capacity defines the size of the buffer
  37103. * @returns the webGL buffer
  37104. */
  37105. createInstancesBuffer(capacity: number): DataBuffer;
  37106. /**
  37107. * Delete a webGL buffer used with instanciation
  37108. * @param buffer defines the webGL buffer to delete
  37109. */
  37110. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37111. private _clientWaitAsync;
  37112. /** @hidden */
  37113. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37114. dispose(): void;
  37115. private _disableTouchAction;
  37116. /**
  37117. * Display the loading screen
  37118. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37119. */
  37120. displayLoadingUI(): void;
  37121. /**
  37122. * Hide the loading screen
  37123. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37124. */
  37125. hideLoadingUI(): void;
  37126. /**
  37127. * Gets the current loading screen object
  37128. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37129. */
  37130. get loadingScreen(): ILoadingScreen;
  37131. /**
  37132. * Sets the current loading screen object
  37133. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37134. */
  37135. set loadingScreen(loadingScreen: ILoadingScreen);
  37136. /**
  37137. * Sets the current loading screen text
  37138. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37139. */
  37140. set loadingUIText(text: string);
  37141. /**
  37142. * Sets the current loading screen background color
  37143. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37144. */
  37145. set loadingUIBackgroundColor(color: string);
  37146. /** Pointerlock and fullscreen */
  37147. /**
  37148. * Ask the browser to promote the current element to pointerlock mode
  37149. * @param element defines the DOM element to promote
  37150. */
  37151. static _RequestPointerlock(element: HTMLElement): void;
  37152. /**
  37153. * Asks the browser to exit pointerlock mode
  37154. */
  37155. static _ExitPointerlock(): void;
  37156. /**
  37157. * Ask the browser to promote the current element to fullscreen rendering mode
  37158. * @param element defines the DOM element to promote
  37159. */
  37160. static _RequestFullscreen(element: HTMLElement): void;
  37161. /**
  37162. * Asks the browser to exit fullscreen mode
  37163. */
  37164. static _ExitFullscreen(): void;
  37165. }
  37166. }
  37167. declare module BABYLON {
  37168. /**
  37169. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37170. * during the life time of the application.
  37171. */
  37172. export class EngineStore {
  37173. /** Gets the list of created engines */
  37174. static Instances: Engine[];
  37175. /** @hidden */
  37176. static _LastCreatedScene: Nullable<Scene>;
  37177. /**
  37178. * Gets the latest created engine
  37179. */
  37180. static get LastCreatedEngine(): Nullable<Engine>;
  37181. /**
  37182. * Gets the latest created scene
  37183. */
  37184. static get LastCreatedScene(): Nullable<Scene>;
  37185. /**
  37186. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37187. * @ignorenaming
  37188. */
  37189. static UseFallbackTexture: boolean;
  37190. /**
  37191. * Texture content used if a texture cannot loaded
  37192. * @ignorenaming
  37193. */
  37194. static FallbackTexture: string;
  37195. }
  37196. }
  37197. declare module BABYLON {
  37198. /**
  37199. * Helper class that provides a small promise polyfill
  37200. */
  37201. export class PromisePolyfill {
  37202. /**
  37203. * Static function used to check if the polyfill is required
  37204. * If this is the case then the function will inject the polyfill to window.Promise
  37205. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37206. */
  37207. static Apply(force?: boolean): void;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. /**
  37212. * Interface for screenshot methods with describe argument called `size` as object with options
  37213. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37214. */
  37215. export interface IScreenshotSize {
  37216. /**
  37217. * number in pixels for canvas height
  37218. */
  37219. height?: number;
  37220. /**
  37221. * multiplier allowing render at a higher or lower resolution
  37222. * If value is defined then height and width will be ignored and taken from camera
  37223. */
  37224. precision?: number;
  37225. /**
  37226. * number in pixels for canvas width
  37227. */
  37228. width?: number;
  37229. }
  37230. }
  37231. declare module BABYLON {
  37232. interface IColor4Like {
  37233. r: float;
  37234. g: float;
  37235. b: float;
  37236. a: float;
  37237. }
  37238. /**
  37239. * Class containing a set of static utilities functions
  37240. */
  37241. export class Tools {
  37242. /**
  37243. * Gets or sets the base URL to use to load assets
  37244. */
  37245. static get BaseUrl(): string;
  37246. static set BaseUrl(value: string);
  37247. /**
  37248. * Enable/Disable Custom HTTP Request Headers globally.
  37249. * default = false
  37250. * @see CustomRequestHeaders
  37251. */
  37252. static UseCustomRequestHeaders: boolean;
  37253. /**
  37254. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37255. * i.e. when loading files, where the server/service expects an Authorization header
  37256. */
  37257. static CustomRequestHeaders: {
  37258. [key: string]: string;
  37259. };
  37260. /**
  37261. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37262. */
  37263. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37264. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37265. /**
  37266. * Default behaviour for cors in the application.
  37267. * It can be a string if the expected behavior is identical in the entire app.
  37268. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37269. */
  37270. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37271. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37272. /**
  37273. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37274. * @ignorenaming
  37275. */
  37276. static get UseFallbackTexture(): boolean;
  37277. static set UseFallbackTexture(value: boolean);
  37278. /**
  37279. * Use this object to register external classes like custom textures or material
  37280. * to allow the laoders to instantiate them
  37281. */
  37282. static get RegisteredExternalClasses(): {
  37283. [key: string]: Object;
  37284. };
  37285. static set RegisteredExternalClasses(classes: {
  37286. [key: string]: Object;
  37287. });
  37288. /**
  37289. * Texture content used if a texture cannot loaded
  37290. * @ignorenaming
  37291. */
  37292. static get fallbackTexture(): string;
  37293. static set fallbackTexture(value: string);
  37294. /**
  37295. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37296. * @param u defines the coordinate on X axis
  37297. * @param v defines the coordinate on Y axis
  37298. * @param width defines the width of the source data
  37299. * @param height defines the height of the source data
  37300. * @param pixels defines the source byte array
  37301. * @param color defines the output color
  37302. */
  37303. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37304. /**
  37305. * Interpolates between a and b via alpha
  37306. * @param a The lower value (returned when alpha = 0)
  37307. * @param b The upper value (returned when alpha = 1)
  37308. * @param alpha The interpolation-factor
  37309. * @return The mixed value
  37310. */
  37311. static Mix(a: number, b: number, alpha: number): number;
  37312. /**
  37313. * Tries to instantiate a new object from a given class name
  37314. * @param className defines the class name to instantiate
  37315. * @returns the new object or null if the system was not able to do the instantiation
  37316. */
  37317. static Instantiate(className: string): any;
  37318. /**
  37319. * Provides a slice function that will work even on IE
  37320. * @param data defines the array to slice
  37321. * @param start defines the start of the data (optional)
  37322. * @param end defines the end of the data (optional)
  37323. * @returns the new sliced array
  37324. */
  37325. static Slice<T>(data: T, start?: number, end?: number): T;
  37326. /**
  37327. * Polyfill for setImmediate
  37328. * @param action defines the action to execute after the current execution block
  37329. */
  37330. static SetImmediate(action: () => void): void;
  37331. /**
  37332. * Function indicating if a number is an exponent of 2
  37333. * @param value defines the value to test
  37334. * @returns true if the value is an exponent of 2
  37335. */
  37336. static IsExponentOfTwo(value: number): boolean;
  37337. private static _tmpFloatArray;
  37338. /**
  37339. * Returns the nearest 32-bit single precision float representation of a Number
  37340. * @param value A Number. If the parameter is of a different type, it will get converted
  37341. * to a number or to NaN if it cannot be converted
  37342. * @returns number
  37343. */
  37344. static FloatRound(value: number): number;
  37345. /**
  37346. * Extracts the filename from a path
  37347. * @param path defines the path to use
  37348. * @returns the filename
  37349. */
  37350. static GetFilename(path: string): string;
  37351. /**
  37352. * Extracts the "folder" part of a path (everything before the filename).
  37353. * @param uri The URI to extract the info from
  37354. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37355. * @returns The "folder" part of the path
  37356. */
  37357. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37358. /**
  37359. * Extracts text content from a DOM element hierarchy
  37360. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37361. */
  37362. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37363. /**
  37364. * Convert an angle in radians to degrees
  37365. * @param angle defines the angle to convert
  37366. * @returns the angle in degrees
  37367. */
  37368. static ToDegrees(angle: number): number;
  37369. /**
  37370. * Convert an angle in degrees to radians
  37371. * @param angle defines the angle to convert
  37372. * @returns the angle in radians
  37373. */
  37374. static ToRadians(angle: number): number;
  37375. /**
  37376. * Returns an array if obj is not an array
  37377. * @param obj defines the object to evaluate as an array
  37378. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37379. * @returns either obj directly if obj is an array or a new array containing obj
  37380. */
  37381. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37382. /**
  37383. * Gets the pointer prefix to use
  37384. * @param engine defines the engine we are finding the prefix for
  37385. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37386. */
  37387. static GetPointerPrefix(engine: Engine): string;
  37388. /**
  37389. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37390. * @param url define the url we are trying
  37391. * @param element define the dom element where to configure the cors policy
  37392. */
  37393. static SetCorsBehavior(url: string | string[], element: {
  37394. crossOrigin: string | null;
  37395. }): void;
  37396. /**
  37397. * Removes unwanted characters from an url
  37398. * @param url defines the url to clean
  37399. * @returns the cleaned url
  37400. */
  37401. static CleanUrl(url: string): string;
  37402. /**
  37403. * Gets or sets a function used to pre-process url before using them to load assets
  37404. */
  37405. static get PreprocessUrl(): (url: string) => string;
  37406. static set PreprocessUrl(processor: (url: string) => string);
  37407. /**
  37408. * Loads an image as an HTMLImageElement.
  37409. * @param input url string, ArrayBuffer, or Blob to load
  37410. * @param onLoad callback called when the image successfully loads
  37411. * @param onError callback called when the image fails to load
  37412. * @param offlineProvider offline provider for caching
  37413. * @param mimeType optional mime type
  37414. * @returns the HTMLImageElement of the loaded image
  37415. */
  37416. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37417. /**
  37418. * Loads a file from a url
  37419. * @param url url string, ArrayBuffer, or Blob to load
  37420. * @param onSuccess callback called when the file successfully loads
  37421. * @param onProgress callback called while file is loading (if the server supports this mode)
  37422. * @param offlineProvider defines the offline provider for caching
  37423. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37424. * @param onError callback called when the file fails to load
  37425. * @returns a file request object
  37426. */
  37427. 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;
  37428. /**
  37429. * Loads a file from a url
  37430. * @param url the file url to load
  37431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37432. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37433. */
  37434. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37435. /**
  37436. * Load a script (identified by an url). When the url returns, the
  37437. * content of this file is added into a new script element, attached to the DOM (body element)
  37438. * @param scriptUrl defines the url of the script to laod
  37439. * @param onSuccess defines the callback called when the script is loaded
  37440. * @param onError defines the callback to call if an error occurs
  37441. * @param scriptId defines the id of the script element
  37442. */
  37443. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37444. /**
  37445. * Load an asynchronous script (identified by an url). When the url returns, the
  37446. * content of this file is added into a new script element, attached to the DOM (body element)
  37447. * @param scriptUrl defines the url of the script to laod
  37448. * @param scriptId defines the id of the script element
  37449. * @returns a promise request object
  37450. */
  37451. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37452. /**
  37453. * Loads a file from a blob
  37454. * @param fileToLoad defines the blob to use
  37455. * @param callback defines the callback to call when data is loaded
  37456. * @param progressCallback defines the callback to call during loading process
  37457. * @returns a file request object
  37458. */
  37459. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37460. /**
  37461. * Reads a file from a File object
  37462. * @param file defines the file to load
  37463. * @param onSuccess defines the callback to call when data is loaded
  37464. * @param onProgress defines the callback to call during loading process
  37465. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37466. * @param onError defines the callback to call when an error occurs
  37467. * @returns a file request object
  37468. */
  37469. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37470. /**
  37471. * Creates a data url from a given string content
  37472. * @param content defines the content to convert
  37473. * @returns the new data url link
  37474. */
  37475. static FileAsURL(content: string): string;
  37476. /**
  37477. * Format the given number to a specific decimal format
  37478. * @param value defines the number to format
  37479. * @param decimals defines the number of decimals to use
  37480. * @returns the formatted string
  37481. */
  37482. static Format(value: number, decimals?: number): string;
  37483. /**
  37484. * Tries to copy an object by duplicating every property
  37485. * @param source defines the source object
  37486. * @param destination defines the target object
  37487. * @param doNotCopyList defines a list of properties to avoid
  37488. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37489. */
  37490. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37491. /**
  37492. * Gets a boolean indicating if the given object has no own property
  37493. * @param obj defines the object to test
  37494. * @returns true if object has no own property
  37495. */
  37496. static IsEmpty(obj: any): boolean;
  37497. /**
  37498. * Function used to register events at window level
  37499. * @param windowElement defines the Window object to use
  37500. * @param events defines the events to register
  37501. */
  37502. static RegisterTopRootEvents(windowElement: Window, events: {
  37503. name: string;
  37504. handler: Nullable<(e: FocusEvent) => any>;
  37505. }[]): void;
  37506. /**
  37507. * Function used to unregister events from window level
  37508. * @param windowElement defines the Window object to use
  37509. * @param events defines the events to unregister
  37510. */
  37511. static UnregisterTopRootEvents(windowElement: Window, events: {
  37512. name: string;
  37513. handler: Nullable<(e: FocusEvent) => any>;
  37514. }[]): void;
  37515. /**
  37516. * @ignore
  37517. */
  37518. static _ScreenshotCanvas: HTMLCanvasElement;
  37519. /**
  37520. * Dumps the current bound framebuffer
  37521. * @param width defines the rendering width
  37522. * @param height defines the rendering height
  37523. * @param engine defines the hosting engine
  37524. * @param successCallback defines the callback triggered once the data are available
  37525. * @param mimeType defines the mime type of the result
  37526. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37527. */
  37528. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37529. /**
  37530. * Converts the canvas data to blob.
  37531. * This acts as a polyfill for browsers not supporting the to blob function.
  37532. * @param canvas Defines the canvas to extract the data from
  37533. * @param successCallback Defines the callback triggered once the data are available
  37534. * @param mimeType Defines the mime type of the result
  37535. */
  37536. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37537. /**
  37538. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37539. * @param successCallback defines the callback triggered once the data are available
  37540. * @param mimeType defines the mime type of the result
  37541. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37542. */
  37543. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37544. /**
  37545. * Downloads a blob in the browser
  37546. * @param blob defines the blob to download
  37547. * @param fileName defines the name of the downloaded file
  37548. */
  37549. static Download(blob: Blob, fileName: string): void;
  37550. /**
  37551. * Captures a screenshot of the current rendering
  37552. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37553. * @param engine defines the rendering engine
  37554. * @param camera defines the source camera
  37555. * @param size This parameter can be set to a single number or to an object with the
  37556. * following (optional) properties: precision, width, height. If a single number is passed,
  37557. * it will be used for both width and height. If an object is passed, the screenshot size
  37558. * will be derived from the parameters. The precision property is a multiplier allowing
  37559. * rendering at a higher or lower resolution
  37560. * @param successCallback defines the callback receives a single parameter which contains the
  37561. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37562. * src parameter of an <img> to display it
  37563. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37564. * Check your browser for supported MIME types
  37565. */
  37566. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37567. /**
  37568. * Captures a screenshot of the current rendering
  37569. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37570. * @param engine defines the rendering engine
  37571. * @param camera defines the source camera
  37572. * @param size This parameter can be set to a single number or to an object with the
  37573. * following (optional) properties: precision, width, height. If a single number is passed,
  37574. * it will be used for both width and height. If an object is passed, the screenshot size
  37575. * will be derived from the parameters. The precision property is a multiplier allowing
  37576. * rendering at a higher or lower resolution
  37577. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37578. * Check your browser for supported MIME types
  37579. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37580. * to the src parameter of an <img> to display it
  37581. */
  37582. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37583. /**
  37584. * Generates an image screenshot from the specified camera.
  37585. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37586. * @param engine The engine to use for rendering
  37587. * @param camera The camera to use for rendering
  37588. * @param size This parameter can be set to a single number or to an object with the
  37589. * following (optional) properties: precision, width, height. If a single number is passed,
  37590. * it will be used for both width and height. If an object is passed, the screenshot size
  37591. * will be derived from the parameters. The precision property is a multiplier allowing
  37592. * rendering at a higher or lower resolution
  37593. * @param successCallback The callback receives a single parameter which contains the
  37594. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37595. * src parameter of an <img> to display it
  37596. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37597. * Check your browser for supported MIME types
  37598. * @param samples Texture samples (default: 1)
  37599. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37600. * @param fileName A name for for the downloaded file.
  37601. */
  37602. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37603. /**
  37604. * Generates an image screenshot from the specified camera.
  37605. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37606. * @param engine The engine to use for rendering
  37607. * @param camera The camera to use for rendering
  37608. * @param size This parameter can be set to a single number or to an object with the
  37609. * following (optional) properties: precision, width, height. If a single number is passed,
  37610. * it will be used for both width and height. If an object is passed, the screenshot size
  37611. * will be derived from the parameters. The precision property is a multiplier allowing
  37612. * rendering at a higher or lower resolution
  37613. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37614. * Check your browser for supported MIME types
  37615. * @param samples Texture samples (default: 1)
  37616. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37617. * @param fileName A name for for the downloaded file.
  37618. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37619. * to the src parameter of an <img> to display it
  37620. */
  37621. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37622. /**
  37623. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37624. * Be aware Math.random() could cause collisions, but:
  37625. * "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"
  37626. * @returns a pseudo random id
  37627. */
  37628. static RandomId(): string;
  37629. /**
  37630. * Test if the given uri is a base64 string
  37631. * @param uri The uri to test
  37632. * @return True if the uri is a base64 string or false otherwise
  37633. */
  37634. static IsBase64(uri: string): boolean;
  37635. /**
  37636. * Decode the given base64 uri.
  37637. * @param uri The uri to decode
  37638. * @return The decoded base64 data.
  37639. */
  37640. static DecodeBase64(uri: string): ArrayBuffer;
  37641. /**
  37642. * Gets the absolute url.
  37643. * @param url the input url
  37644. * @return the absolute url
  37645. */
  37646. static GetAbsoluteUrl(url: string): string;
  37647. /**
  37648. * No log
  37649. */
  37650. static readonly NoneLogLevel: number;
  37651. /**
  37652. * Only message logs
  37653. */
  37654. static readonly MessageLogLevel: number;
  37655. /**
  37656. * Only warning logs
  37657. */
  37658. static readonly WarningLogLevel: number;
  37659. /**
  37660. * Only error logs
  37661. */
  37662. static readonly ErrorLogLevel: number;
  37663. /**
  37664. * All logs
  37665. */
  37666. static readonly AllLogLevel: number;
  37667. /**
  37668. * Gets a value indicating the number of loading errors
  37669. * @ignorenaming
  37670. */
  37671. static get errorsCount(): number;
  37672. /**
  37673. * Callback called when a new log is added
  37674. */
  37675. static OnNewCacheEntry: (entry: string) => void;
  37676. /**
  37677. * Log a message to the console
  37678. * @param message defines the message to log
  37679. */
  37680. static Log(message: string): void;
  37681. /**
  37682. * Write a warning message to the console
  37683. * @param message defines the message to log
  37684. */
  37685. static Warn(message: string): void;
  37686. /**
  37687. * Write an error message to the console
  37688. * @param message defines the message to log
  37689. */
  37690. static Error(message: string): void;
  37691. /**
  37692. * Gets current log cache (list of logs)
  37693. */
  37694. static get LogCache(): string;
  37695. /**
  37696. * Clears the log cache
  37697. */
  37698. static ClearLogCache(): void;
  37699. /**
  37700. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37701. */
  37702. static set LogLevels(level: number);
  37703. /**
  37704. * Checks if the window object exists
  37705. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37706. */
  37707. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37708. /**
  37709. * No performance log
  37710. */
  37711. static readonly PerformanceNoneLogLevel: number;
  37712. /**
  37713. * Use user marks to log performance
  37714. */
  37715. static readonly PerformanceUserMarkLogLevel: number;
  37716. /**
  37717. * Log performance to the console
  37718. */
  37719. static readonly PerformanceConsoleLogLevel: number;
  37720. private static _performance;
  37721. /**
  37722. * Sets the current performance log level
  37723. */
  37724. static set PerformanceLogLevel(level: number);
  37725. private static _StartPerformanceCounterDisabled;
  37726. private static _EndPerformanceCounterDisabled;
  37727. private static _StartUserMark;
  37728. private static _EndUserMark;
  37729. private static _StartPerformanceConsole;
  37730. private static _EndPerformanceConsole;
  37731. /**
  37732. * Starts a performance counter
  37733. */
  37734. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37735. /**
  37736. * Ends a specific performance coutner
  37737. */
  37738. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37739. /**
  37740. * Gets either window.performance.now() if supported or Date.now() else
  37741. */
  37742. static get Now(): number;
  37743. /**
  37744. * This method will return the name of the class used to create the instance of the given object.
  37745. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37746. * @param object the object to get the class name from
  37747. * @param isType defines if the object is actually a type
  37748. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37749. */
  37750. static GetClassName(object: any, isType?: boolean): string;
  37751. /**
  37752. * Gets the first element of an array satisfying a given predicate
  37753. * @param array defines the array to browse
  37754. * @param predicate defines the predicate to use
  37755. * @returns null if not found or the element
  37756. */
  37757. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37758. /**
  37759. * This method will return the name of the full name of the class, including its owning module (if any).
  37760. * 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).
  37761. * @param object the object to get the class name from
  37762. * @param isType defines if the object is actually a type
  37763. * @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.
  37764. * @ignorenaming
  37765. */
  37766. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37767. /**
  37768. * Returns a promise that resolves after the given amount of time.
  37769. * @param delay Number of milliseconds to delay
  37770. * @returns Promise that resolves after the given amount of time
  37771. */
  37772. static DelayAsync(delay: number): Promise<void>;
  37773. /**
  37774. * Utility function to detect if the current user agent is Safari
  37775. * @returns whether or not the current user agent is safari
  37776. */
  37777. static IsSafari(): boolean;
  37778. }
  37779. /**
  37780. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37781. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37782. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37783. * @param name The name of the class, case should be preserved
  37784. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37785. */
  37786. export function className(name: string, module?: string): (target: Object) => void;
  37787. /**
  37788. * An implementation of a loop for asynchronous functions.
  37789. */
  37790. export class AsyncLoop {
  37791. /**
  37792. * Defines the number of iterations for the loop
  37793. */
  37794. iterations: number;
  37795. /**
  37796. * Defines the current index of the loop.
  37797. */
  37798. index: number;
  37799. private _done;
  37800. private _fn;
  37801. private _successCallback;
  37802. /**
  37803. * Constructor.
  37804. * @param iterations the number of iterations.
  37805. * @param func the function to run each iteration
  37806. * @param successCallback the callback that will be called upon succesful execution
  37807. * @param offset starting offset.
  37808. */
  37809. constructor(
  37810. /**
  37811. * Defines the number of iterations for the loop
  37812. */
  37813. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37814. /**
  37815. * Execute the next iteration. Must be called after the last iteration was finished.
  37816. */
  37817. executeNext(): void;
  37818. /**
  37819. * Break the loop and run the success callback.
  37820. */
  37821. breakLoop(): void;
  37822. /**
  37823. * Create and run an async loop.
  37824. * @param iterations the number of iterations.
  37825. * @param fn the function to run each iteration
  37826. * @param successCallback the callback that will be called upon succesful execution
  37827. * @param offset starting offset.
  37828. * @returns the created async loop object
  37829. */
  37830. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37831. /**
  37832. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37833. * @param iterations total number of iterations
  37834. * @param syncedIterations number of synchronous iterations in each async iteration.
  37835. * @param fn the function to call each iteration.
  37836. * @param callback a success call back that will be called when iterating stops.
  37837. * @param breakFunction a break condition (optional)
  37838. * @param timeout timeout settings for the setTimeout function. default - 0.
  37839. * @returns the created async loop object
  37840. */
  37841. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37842. }
  37843. }
  37844. declare module BABYLON {
  37845. /**
  37846. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37847. * The underlying implementation relies on an associative array to ensure the best performances.
  37848. * The value can be anything including 'null' but except 'undefined'
  37849. */
  37850. export class StringDictionary<T> {
  37851. /**
  37852. * This will clear this dictionary and copy the content from the 'source' one.
  37853. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37854. * @param source the dictionary to take the content from and copy to this dictionary
  37855. */
  37856. copyFrom(source: StringDictionary<T>): void;
  37857. /**
  37858. * Get a value based from its key
  37859. * @param key the given key to get the matching value from
  37860. * @return the value if found, otherwise undefined is returned
  37861. */
  37862. get(key: string): T | undefined;
  37863. /**
  37864. * Get a value from its key or add it if it doesn't exist.
  37865. * This method will ensure you that a given key/data will be present in the dictionary.
  37866. * @param key the given key to get the matching value from
  37867. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37868. * The factory will only be invoked if there's no data for the given key.
  37869. * @return the value corresponding to the key.
  37870. */
  37871. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37872. /**
  37873. * Get a value from its key if present in the dictionary otherwise add it
  37874. * @param key the key to get the value from
  37875. * @param val if there's no such key/value pair in the dictionary add it with this value
  37876. * @return the value corresponding to the key
  37877. */
  37878. getOrAdd(key: string, val: T): T;
  37879. /**
  37880. * Check if there's a given key in the dictionary
  37881. * @param key the key to check for
  37882. * @return true if the key is present, false otherwise
  37883. */
  37884. contains(key: string): boolean;
  37885. /**
  37886. * Add a new key and its corresponding value
  37887. * @param key the key to add
  37888. * @param value the value corresponding to the key
  37889. * @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
  37890. */
  37891. add(key: string, value: T): boolean;
  37892. /**
  37893. * Update a specific value associated to a key
  37894. * @param key defines the key to use
  37895. * @param value defines the value to store
  37896. * @returns true if the value was updated (or false if the key was not found)
  37897. */
  37898. set(key: string, value: T): boolean;
  37899. /**
  37900. * Get the element of the given key and remove it from the dictionary
  37901. * @param key defines the key to search
  37902. * @returns the value associated with the key or null if not found
  37903. */
  37904. getAndRemove(key: string): Nullable<T>;
  37905. /**
  37906. * Remove a key/value from the dictionary.
  37907. * @param key the key to remove
  37908. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37909. */
  37910. remove(key: string): boolean;
  37911. /**
  37912. * Clear the whole content of the dictionary
  37913. */
  37914. clear(): void;
  37915. /**
  37916. * Gets the current count
  37917. */
  37918. get count(): number;
  37919. /**
  37920. * Execute a callback on each key/val of the dictionary.
  37921. * Note that you can remove any element in this dictionary in the callback implementation
  37922. * @param callback the callback to execute on a given key/value pair
  37923. */
  37924. forEach(callback: (key: string, val: T) => void): void;
  37925. /**
  37926. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37927. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37928. * Note that you can remove any element in this dictionary in the callback implementation
  37929. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37930. * @returns the first item
  37931. */
  37932. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37933. private _count;
  37934. private _data;
  37935. }
  37936. }
  37937. declare module BABYLON {
  37938. /** @hidden */
  37939. export interface ICollisionCoordinator {
  37940. createCollider(): Collider;
  37941. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37942. init(scene: Scene): void;
  37943. }
  37944. /** @hidden */
  37945. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37946. private _scene;
  37947. private _scaledPosition;
  37948. private _scaledVelocity;
  37949. private _finalPosition;
  37950. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37951. createCollider(): Collider;
  37952. init(scene: Scene): void;
  37953. private _collideWithWorld;
  37954. }
  37955. }
  37956. declare module BABYLON {
  37957. /**
  37958. * Class used to manage all inputs for the scene.
  37959. */
  37960. export class InputManager {
  37961. /** The distance in pixel that you have to move to prevent some events */
  37962. static DragMovementThreshold: number;
  37963. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37964. static LongPressDelay: number;
  37965. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37966. static DoubleClickDelay: number;
  37967. /** If you need to check double click without raising a single click at first click, enable this flag */
  37968. static ExclusiveDoubleClickMode: boolean;
  37969. private _wheelEventName;
  37970. private _onPointerMove;
  37971. private _onPointerDown;
  37972. private _onPointerUp;
  37973. private _initClickEvent;
  37974. private _initActionManager;
  37975. private _delayedSimpleClick;
  37976. private _delayedSimpleClickTimeout;
  37977. private _previousDelayedSimpleClickTimeout;
  37978. private _meshPickProceed;
  37979. private _previousButtonPressed;
  37980. private _currentPickResult;
  37981. private _previousPickResult;
  37982. private _totalPointersPressed;
  37983. private _doubleClickOccured;
  37984. private _pointerOverMesh;
  37985. private _pickedDownMesh;
  37986. private _pickedUpMesh;
  37987. private _pointerX;
  37988. private _pointerY;
  37989. private _unTranslatedPointerX;
  37990. private _unTranslatedPointerY;
  37991. private _startingPointerPosition;
  37992. private _previousStartingPointerPosition;
  37993. private _startingPointerTime;
  37994. private _previousStartingPointerTime;
  37995. private _pointerCaptures;
  37996. private _onKeyDown;
  37997. private _onKeyUp;
  37998. private _onCanvasFocusObserver;
  37999. private _onCanvasBlurObserver;
  38000. private _scene;
  38001. /**
  38002. * Creates a new InputManager
  38003. * @param scene defines the hosting scene
  38004. */
  38005. constructor(scene: Scene);
  38006. /**
  38007. * Gets the mesh that is currently under the pointer
  38008. */
  38009. get meshUnderPointer(): Nullable<AbstractMesh>;
  38010. /**
  38011. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38012. */
  38013. get unTranslatedPointer(): Vector2;
  38014. /**
  38015. * Gets or sets the current on-screen X position of the pointer
  38016. */
  38017. get pointerX(): number;
  38018. set pointerX(value: number);
  38019. /**
  38020. * Gets or sets the current on-screen Y position of the pointer
  38021. */
  38022. get pointerY(): number;
  38023. set pointerY(value: number);
  38024. private _updatePointerPosition;
  38025. private _processPointerMove;
  38026. private _setRayOnPointerInfo;
  38027. private _checkPrePointerObservable;
  38028. /**
  38029. * Use this method to simulate a pointer move on a mesh
  38030. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38031. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38032. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38033. */
  38034. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38035. /**
  38036. * Use this method to simulate a pointer down on a mesh
  38037. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38038. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38039. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38040. */
  38041. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38042. private _processPointerDown;
  38043. /** @hidden */
  38044. _isPointerSwiping(): boolean;
  38045. /**
  38046. * Use this method to simulate a pointer up on a mesh
  38047. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38048. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38049. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38050. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38051. */
  38052. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38053. private _processPointerUp;
  38054. /**
  38055. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38056. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38057. * @returns true if the pointer was captured
  38058. */
  38059. isPointerCaptured(pointerId?: number): boolean;
  38060. /**
  38061. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38062. * @param attachUp defines if you want to attach events to pointerup
  38063. * @param attachDown defines if you want to attach events to pointerdown
  38064. * @param attachMove defines if you want to attach events to pointermove
  38065. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38066. */
  38067. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38068. /**
  38069. * Detaches all event handlers
  38070. */
  38071. detachControl(): void;
  38072. /**
  38073. * Force the value of meshUnderPointer
  38074. * @param mesh defines the mesh to use
  38075. */
  38076. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38077. /**
  38078. * Gets the mesh under the pointer
  38079. * @returns a Mesh or null if no mesh is under the pointer
  38080. */
  38081. getPointerOverMesh(): Nullable<AbstractMesh>;
  38082. }
  38083. }
  38084. declare module BABYLON {
  38085. /**
  38086. * This class defines the direct association between an animation and a target
  38087. */
  38088. export class TargetedAnimation {
  38089. /**
  38090. * Animation to perform
  38091. */
  38092. animation: Animation;
  38093. /**
  38094. * Target to animate
  38095. */
  38096. target: any;
  38097. /**
  38098. * Returns the string "TargetedAnimation"
  38099. * @returns "TargetedAnimation"
  38100. */
  38101. getClassName(): string;
  38102. /**
  38103. * Serialize the object
  38104. * @returns the JSON object representing the current entity
  38105. */
  38106. serialize(): any;
  38107. }
  38108. /**
  38109. * Use this class to create coordinated animations on multiple targets
  38110. */
  38111. export class AnimationGroup implements IDisposable {
  38112. /** The name of the animation group */
  38113. name: string;
  38114. private _scene;
  38115. private _targetedAnimations;
  38116. private _animatables;
  38117. private _from;
  38118. private _to;
  38119. private _isStarted;
  38120. private _isPaused;
  38121. private _speedRatio;
  38122. private _loopAnimation;
  38123. private _isAdditive;
  38124. /**
  38125. * Gets or sets the unique id of the node
  38126. */
  38127. uniqueId: number;
  38128. /**
  38129. * This observable will notify when one animation have ended
  38130. */
  38131. onAnimationEndObservable: Observable<TargetedAnimation>;
  38132. /**
  38133. * Observer raised when one animation loops
  38134. */
  38135. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38136. /**
  38137. * Observer raised when all animations have looped
  38138. */
  38139. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38140. /**
  38141. * This observable will notify when all animations have ended.
  38142. */
  38143. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38144. /**
  38145. * This observable will notify when all animations have paused.
  38146. */
  38147. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38148. /**
  38149. * This observable will notify when all animations are playing.
  38150. */
  38151. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38152. /**
  38153. * Gets the first frame
  38154. */
  38155. get from(): number;
  38156. /**
  38157. * Gets the last frame
  38158. */
  38159. get to(): number;
  38160. /**
  38161. * Define if the animations are started
  38162. */
  38163. get isStarted(): boolean;
  38164. /**
  38165. * Gets a value indicating that the current group is playing
  38166. */
  38167. get isPlaying(): boolean;
  38168. /**
  38169. * Gets or sets the speed ratio to use for all animations
  38170. */
  38171. get speedRatio(): number;
  38172. /**
  38173. * Gets or sets the speed ratio to use for all animations
  38174. */
  38175. set speedRatio(value: number);
  38176. /**
  38177. * Gets or sets if all animations should loop or not
  38178. */
  38179. get loopAnimation(): boolean;
  38180. set loopAnimation(value: boolean);
  38181. /**
  38182. * Gets or sets if all animations should be evaluated additively
  38183. */
  38184. get isAdditive(): boolean;
  38185. set isAdditive(value: boolean);
  38186. /**
  38187. * Gets the targeted animations for this animation group
  38188. */
  38189. get targetedAnimations(): Array<TargetedAnimation>;
  38190. /**
  38191. * returning the list of animatables controlled by this animation group.
  38192. */
  38193. get animatables(): Array<Animatable>;
  38194. /**
  38195. * Gets the list of target animations
  38196. */
  38197. get children(): TargetedAnimation[];
  38198. /**
  38199. * Instantiates a new Animation Group.
  38200. * This helps managing several animations at once.
  38201. * @see https://doc.babylonjs.com/how_to/group
  38202. * @param name Defines the name of the group
  38203. * @param scene Defines the scene the group belongs to
  38204. */
  38205. constructor(
  38206. /** The name of the animation group */
  38207. name: string, scene?: Nullable<Scene>);
  38208. /**
  38209. * Add an animation (with its target) in the group
  38210. * @param animation defines the animation we want to add
  38211. * @param target defines the target of the animation
  38212. * @returns the TargetedAnimation object
  38213. */
  38214. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38215. /**
  38216. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38217. * It can add constant keys at begin or end
  38218. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38219. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38220. * @returns the animation group
  38221. */
  38222. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38223. private _animationLoopCount;
  38224. private _animationLoopFlags;
  38225. private _processLoop;
  38226. /**
  38227. * Start all animations on given targets
  38228. * @param loop defines if animations must loop
  38229. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38230. * @param from defines the from key (optional)
  38231. * @param to defines the to key (optional)
  38232. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38233. * @returns the current animation group
  38234. */
  38235. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38236. /**
  38237. * Pause all animations
  38238. * @returns the animation group
  38239. */
  38240. pause(): AnimationGroup;
  38241. /**
  38242. * Play all animations to initial state
  38243. * This function will start() the animations if they were not started or will restart() them if they were paused
  38244. * @param loop defines if animations must loop
  38245. * @returns the animation group
  38246. */
  38247. play(loop?: boolean): AnimationGroup;
  38248. /**
  38249. * Reset all animations to initial state
  38250. * @returns the animation group
  38251. */
  38252. reset(): AnimationGroup;
  38253. /**
  38254. * Restart animations from key 0
  38255. * @returns the animation group
  38256. */
  38257. restart(): AnimationGroup;
  38258. /**
  38259. * Stop all animations
  38260. * @returns the animation group
  38261. */
  38262. stop(): AnimationGroup;
  38263. /**
  38264. * Set animation weight for all animatables
  38265. * @param weight defines the weight to use
  38266. * @return the animationGroup
  38267. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38268. */
  38269. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38270. /**
  38271. * Synchronize and normalize all animatables with a source animatable
  38272. * @param root defines the root animatable to synchronize with
  38273. * @return the animationGroup
  38274. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38275. */
  38276. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38277. /**
  38278. * Goes to a specific frame in this animation group
  38279. * @param frame the frame number to go to
  38280. * @return the animationGroup
  38281. */
  38282. goToFrame(frame: number): AnimationGroup;
  38283. /**
  38284. * Dispose all associated resources
  38285. */
  38286. dispose(): void;
  38287. private _checkAnimationGroupEnded;
  38288. /**
  38289. * Clone the current animation group and returns a copy
  38290. * @param newName defines the name of the new group
  38291. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38292. * @returns the new aniamtion group
  38293. */
  38294. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38295. /**
  38296. * Serializes the animationGroup to an object
  38297. * @returns Serialized object
  38298. */
  38299. serialize(): any;
  38300. /**
  38301. * Returns a new AnimationGroup object parsed from the source provided.
  38302. * @param parsedAnimationGroup defines the source
  38303. * @param scene defines the scene that will receive the animationGroup
  38304. * @returns a new AnimationGroup
  38305. */
  38306. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38307. /**
  38308. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38309. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38310. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38311. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38312. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38313. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38314. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38315. */
  38316. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38317. /**
  38318. * Returns the string "AnimationGroup"
  38319. * @returns "AnimationGroup"
  38320. */
  38321. getClassName(): string;
  38322. /**
  38323. * Creates a detailled string about the object
  38324. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38325. * @returns a string representing the object
  38326. */
  38327. toString(fullDetails?: boolean): string;
  38328. }
  38329. }
  38330. declare module BABYLON {
  38331. /**
  38332. * Define an interface for all classes that will hold resources
  38333. */
  38334. export interface IDisposable {
  38335. /**
  38336. * Releases all held resources
  38337. */
  38338. dispose(): void;
  38339. }
  38340. /** Interface defining initialization parameters for Scene class */
  38341. export interface SceneOptions {
  38342. /**
  38343. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38344. * It will improve performance when the number of geometries becomes important.
  38345. */
  38346. useGeometryUniqueIdsMap?: boolean;
  38347. /**
  38348. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38349. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38350. */
  38351. useMaterialMeshMap?: boolean;
  38352. /**
  38353. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38354. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38355. */
  38356. useClonedMeshMap?: boolean;
  38357. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38358. virtual?: boolean;
  38359. }
  38360. /**
  38361. * Represents a scene to be rendered by the engine.
  38362. * @see https://doc.babylonjs.com/features/scene
  38363. */
  38364. export class Scene extends AbstractScene implements IAnimatable {
  38365. /** The fog is deactivated */
  38366. static readonly FOGMODE_NONE: number;
  38367. /** The fog density is following an exponential function */
  38368. static readonly FOGMODE_EXP: number;
  38369. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38370. static readonly FOGMODE_EXP2: number;
  38371. /** The fog density is following a linear function. */
  38372. static readonly FOGMODE_LINEAR: number;
  38373. /**
  38374. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38375. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38376. */
  38377. static MinDeltaTime: number;
  38378. /**
  38379. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38380. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38381. */
  38382. static MaxDeltaTime: number;
  38383. /**
  38384. * Factory used to create the default material.
  38385. * @param name The name of the material to create
  38386. * @param scene The scene to create the material for
  38387. * @returns The default material
  38388. */
  38389. static DefaultMaterialFactory(scene: Scene): Material;
  38390. /**
  38391. * Factory used to create the a collision coordinator.
  38392. * @returns The collision coordinator
  38393. */
  38394. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38395. /** @hidden */
  38396. _inputManager: InputManager;
  38397. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38398. cameraToUseForPointers: Nullable<Camera>;
  38399. /** @hidden */
  38400. readonly _isScene: boolean;
  38401. /** @hidden */
  38402. _blockEntityCollection: boolean;
  38403. /**
  38404. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38405. */
  38406. autoClear: boolean;
  38407. /**
  38408. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38409. */
  38410. autoClearDepthAndStencil: boolean;
  38411. /**
  38412. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38413. */
  38414. clearColor: Color4;
  38415. /**
  38416. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38417. */
  38418. ambientColor: Color3;
  38419. /**
  38420. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38421. * It should only be one of the following (if not the default embedded one):
  38422. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38423. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38424. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38425. * The material properties need to be setup according to the type of texture in use.
  38426. */
  38427. environmentBRDFTexture: BaseTexture;
  38428. /** @hidden */
  38429. protected _environmentTexture: Nullable<BaseTexture>;
  38430. /**
  38431. * Texture used in all pbr material as the reflection texture.
  38432. * As in the majority of the scene they are the same (exception for multi room and so on),
  38433. * this is easier to reference from here than from all the materials.
  38434. */
  38435. get environmentTexture(): Nullable<BaseTexture>;
  38436. /**
  38437. * Texture used in all pbr material as the reflection texture.
  38438. * As in the majority of the scene they are the same (exception for multi room and so on),
  38439. * this is easier to set here than in all the materials.
  38440. */
  38441. set environmentTexture(value: Nullable<BaseTexture>);
  38442. /** @hidden */
  38443. protected _environmentIntensity: number;
  38444. /**
  38445. * Intensity of the environment in all pbr material.
  38446. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38447. * As in the majority of the scene they are the same (exception for multi room and so on),
  38448. * this is easier to reference from here than from all the materials.
  38449. */
  38450. get environmentIntensity(): number;
  38451. /**
  38452. * Intensity of the environment in all pbr material.
  38453. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38454. * As in the majority of the scene they are the same (exception for multi room and so on),
  38455. * this is easier to set here than in all the materials.
  38456. */
  38457. set environmentIntensity(value: number);
  38458. /** @hidden */
  38459. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38460. /**
  38461. * Default image processing configuration used either in the rendering
  38462. * Forward main pass or through the imageProcessingPostProcess if present.
  38463. * As in the majority of the scene they are the same (exception for multi camera),
  38464. * this is easier to reference from here than from all the materials and post process.
  38465. *
  38466. * No setter as we it is a shared configuration, you can set the values instead.
  38467. */
  38468. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38469. private _forceWireframe;
  38470. /**
  38471. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38472. */
  38473. set forceWireframe(value: boolean);
  38474. get forceWireframe(): boolean;
  38475. private _skipFrustumClipping;
  38476. /**
  38477. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38478. */
  38479. set skipFrustumClipping(value: boolean);
  38480. get skipFrustumClipping(): boolean;
  38481. private _forcePointsCloud;
  38482. /**
  38483. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38484. */
  38485. set forcePointsCloud(value: boolean);
  38486. get forcePointsCloud(): boolean;
  38487. /**
  38488. * Gets or sets the active clipplane 1
  38489. */
  38490. clipPlane: Nullable<Plane>;
  38491. /**
  38492. * Gets or sets the active clipplane 2
  38493. */
  38494. clipPlane2: Nullable<Plane>;
  38495. /**
  38496. * Gets or sets the active clipplane 3
  38497. */
  38498. clipPlane3: Nullable<Plane>;
  38499. /**
  38500. * Gets or sets the active clipplane 4
  38501. */
  38502. clipPlane4: Nullable<Plane>;
  38503. /**
  38504. * Gets or sets the active clipplane 5
  38505. */
  38506. clipPlane5: Nullable<Plane>;
  38507. /**
  38508. * Gets or sets the active clipplane 6
  38509. */
  38510. clipPlane6: Nullable<Plane>;
  38511. /**
  38512. * Gets or sets a boolean indicating if animations are enabled
  38513. */
  38514. animationsEnabled: boolean;
  38515. private _animationPropertiesOverride;
  38516. /**
  38517. * Gets or sets the animation properties override
  38518. */
  38519. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38520. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38521. /**
  38522. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38523. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38524. */
  38525. useConstantAnimationDeltaTime: boolean;
  38526. /**
  38527. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38528. * Please note that it requires to run a ray cast through the scene on every frame
  38529. */
  38530. constantlyUpdateMeshUnderPointer: boolean;
  38531. /**
  38532. * Defines the HTML cursor to use when hovering over interactive elements
  38533. */
  38534. hoverCursor: string;
  38535. /**
  38536. * Defines the HTML default cursor to use (empty by default)
  38537. */
  38538. defaultCursor: string;
  38539. /**
  38540. * Defines whether cursors are handled by the scene.
  38541. */
  38542. doNotHandleCursors: boolean;
  38543. /**
  38544. * This is used to call preventDefault() on pointer down
  38545. * in order to block unwanted artifacts like system double clicks
  38546. */
  38547. preventDefaultOnPointerDown: boolean;
  38548. /**
  38549. * This is used to call preventDefault() on pointer up
  38550. * in order to block unwanted artifacts like system double clicks
  38551. */
  38552. preventDefaultOnPointerUp: boolean;
  38553. /**
  38554. * Gets or sets user defined metadata
  38555. */
  38556. metadata: any;
  38557. /**
  38558. * For internal use only. Please do not use.
  38559. */
  38560. reservedDataStore: any;
  38561. /**
  38562. * Gets the name of the plugin used to load this scene (null by default)
  38563. */
  38564. loadingPluginName: string;
  38565. /**
  38566. * Use this array to add regular expressions used to disable offline support for specific urls
  38567. */
  38568. disableOfflineSupportExceptionRules: RegExp[];
  38569. /**
  38570. * An event triggered when the scene is disposed.
  38571. */
  38572. onDisposeObservable: Observable<Scene>;
  38573. private _onDisposeObserver;
  38574. /** Sets a function to be executed when this scene is disposed. */
  38575. set onDispose(callback: () => void);
  38576. /**
  38577. * An event triggered before rendering the scene (right after animations and physics)
  38578. */
  38579. onBeforeRenderObservable: Observable<Scene>;
  38580. private _onBeforeRenderObserver;
  38581. /** Sets a function to be executed before rendering this scene */
  38582. set beforeRender(callback: Nullable<() => void>);
  38583. /**
  38584. * An event triggered after rendering the scene
  38585. */
  38586. onAfterRenderObservable: Observable<Scene>;
  38587. /**
  38588. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38589. */
  38590. onAfterRenderCameraObservable: Observable<Camera>;
  38591. private _onAfterRenderObserver;
  38592. /** Sets a function to be executed after rendering this scene */
  38593. set afterRender(callback: Nullable<() => void>);
  38594. /**
  38595. * An event triggered before animating the scene
  38596. */
  38597. onBeforeAnimationsObservable: Observable<Scene>;
  38598. /**
  38599. * An event triggered after animations processing
  38600. */
  38601. onAfterAnimationsObservable: Observable<Scene>;
  38602. /**
  38603. * An event triggered before draw calls are ready to be sent
  38604. */
  38605. onBeforeDrawPhaseObservable: Observable<Scene>;
  38606. /**
  38607. * An event triggered after draw calls have been sent
  38608. */
  38609. onAfterDrawPhaseObservable: Observable<Scene>;
  38610. /**
  38611. * An event triggered when the scene is ready
  38612. */
  38613. onReadyObservable: Observable<Scene>;
  38614. /**
  38615. * An event triggered before rendering a camera
  38616. */
  38617. onBeforeCameraRenderObservable: Observable<Camera>;
  38618. private _onBeforeCameraRenderObserver;
  38619. /** Sets a function to be executed before rendering a camera*/
  38620. set beforeCameraRender(callback: () => void);
  38621. /**
  38622. * An event triggered after rendering a camera
  38623. */
  38624. onAfterCameraRenderObservable: Observable<Camera>;
  38625. private _onAfterCameraRenderObserver;
  38626. /** Sets a function to be executed after rendering a camera*/
  38627. set afterCameraRender(callback: () => void);
  38628. /**
  38629. * An event triggered when active meshes evaluation is about to start
  38630. */
  38631. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38632. /**
  38633. * An event triggered when active meshes evaluation is done
  38634. */
  38635. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38636. /**
  38637. * An event triggered when particles rendering is about to start
  38638. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38639. */
  38640. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38641. /**
  38642. * An event triggered when particles rendering is done
  38643. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38644. */
  38645. onAfterParticlesRenderingObservable: Observable<Scene>;
  38646. /**
  38647. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38648. */
  38649. onDataLoadedObservable: Observable<Scene>;
  38650. /**
  38651. * An event triggered when a camera is created
  38652. */
  38653. onNewCameraAddedObservable: Observable<Camera>;
  38654. /**
  38655. * An event triggered when a camera is removed
  38656. */
  38657. onCameraRemovedObservable: Observable<Camera>;
  38658. /**
  38659. * An event triggered when a light is created
  38660. */
  38661. onNewLightAddedObservable: Observable<Light>;
  38662. /**
  38663. * An event triggered when a light is removed
  38664. */
  38665. onLightRemovedObservable: Observable<Light>;
  38666. /**
  38667. * An event triggered when a geometry is created
  38668. */
  38669. onNewGeometryAddedObservable: Observable<Geometry>;
  38670. /**
  38671. * An event triggered when a geometry is removed
  38672. */
  38673. onGeometryRemovedObservable: Observable<Geometry>;
  38674. /**
  38675. * An event triggered when a transform node is created
  38676. */
  38677. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38678. /**
  38679. * An event triggered when a transform node is removed
  38680. */
  38681. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38682. /**
  38683. * An event triggered when a mesh is created
  38684. */
  38685. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38686. /**
  38687. * An event triggered when a mesh is removed
  38688. */
  38689. onMeshRemovedObservable: Observable<AbstractMesh>;
  38690. /**
  38691. * An event triggered when a skeleton is created
  38692. */
  38693. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38694. /**
  38695. * An event triggered when a skeleton is removed
  38696. */
  38697. onSkeletonRemovedObservable: Observable<Skeleton>;
  38698. /**
  38699. * An event triggered when a material is created
  38700. */
  38701. onNewMaterialAddedObservable: Observable<Material>;
  38702. /**
  38703. * An event triggered when a material is removed
  38704. */
  38705. onMaterialRemovedObservable: Observable<Material>;
  38706. /**
  38707. * An event triggered when a texture is created
  38708. */
  38709. onNewTextureAddedObservable: Observable<BaseTexture>;
  38710. /**
  38711. * An event triggered when a texture is removed
  38712. */
  38713. onTextureRemovedObservable: Observable<BaseTexture>;
  38714. /**
  38715. * An event triggered when render targets are about to be rendered
  38716. * Can happen multiple times per frame.
  38717. */
  38718. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38719. /**
  38720. * An event triggered when render targets were rendered.
  38721. * Can happen multiple times per frame.
  38722. */
  38723. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38724. /**
  38725. * An event triggered before calculating deterministic simulation step
  38726. */
  38727. onBeforeStepObservable: Observable<Scene>;
  38728. /**
  38729. * An event triggered after calculating deterministic simulation step
  38730. */
  38731. onAfterStepObservable: Observable<Scene>;
  38732. /**
  38733. * An event triggered when the activeCamera property is updated
  38734. */
  38735. onActiveCameraChanged: Observable<Scene>;
  38736. /**
  38737. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38738. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38739. * 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)
  38740. */
  38741. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38742. /**
  38743. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38744. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38745. * 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)
  38746. */
  38747. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38748. /**
  38749. * This Observable will when a mesh has been imported into the scene.
  38750. */
  38751. onMeshImportedObservable: Observable<AbstractMesh>;
  38752. /**
  38753. * This Observable will when an animation file has been imported into the scene.
  38754. */
  38755. onAnimationFileImportedObservable: Observable<Scene>;
  38756. /**
  38757. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38758. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38759. */
  38760. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38761. /** @hidden */
  38762. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38763. /**
  38764. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38765. */
  38766. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38767. /**
  38768. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38769. */
  38770. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38771. /**
  38772. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38773. */
  38774. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38775. /** Callback called when a pointer move is detected */
  38776. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38777. /** Callback called when a pointer down is detected */
  38778. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38779. /** Callback called when a pointer up is detected */
  38780. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38781. /** Callback called when a pointer pick is detected */
  38782. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38783. /**
  38784. * 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).
  38785. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38786. */
  38787. onPrePointerObservable: Observable<PointerInfoPre>;
  38788. /**
  38789. * Observable event triggered each time an input event is received from the rendering canvas
  38790. */
  38791. onPointerObservable: Observable<PointerInfo>;
  38792. /**
  38793. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38794. */
  38795. get unTranslatedPointer(): Vector2;
  38796. /**
  38797. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38798. */
  38799. static get DragMovementThreshold(): number;
  38800. static set DragMovementThreshold(value: number);
  38801. /**
  38802. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38803. */
  38804. static get LongPressDelay(): number;
  38805. static set LongPressDelay(value: number);
  38806. /**
  38807. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38808. */
  38809. static get DoubleClickDelay(): number;
  38810. static set DoubleClickDelay(value: number);
  38811. /** If you need to check double click without raising a single click at first click, enable this flag */
  38812. static get ExclusiveDoubleClickMode(): boolean;
  38813. static set ExclusiveDoubleClickMode(value: boolean);
  38814. /** @hidden */
  38815. _mirroredCameraPosition: Nullable<Vector3>;
  38816. /**
  38817. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38818. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38819. */
  38820. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38821. /**
  38822. * Observable event triggered each time an keyboard event is received from the hosting window
  38823. */
  38824. onKeyboardObservable: Observable<KeyboardInfo>;
  38825. private _useRightHandedSystem;
  38826. /**
  38827. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38828. */
  38829. set useRightHandedSystem(value: boolean);
  38830. get useRightHandedSystem(): boolean;
  38831. private _timeAccumulator;
  38832. private _currentStepId;
  38833. private _currentInternalStep;
  38834. /**
  38835. * Sets the step Id used by deterministic lock step
  38836. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38837. * @param newStepId defines the step Id
  38838. */
  38839. setStepId(newStepId: number): void;
  38840. /**
  38841. * Gets the step Id used by deterministic lock step
  38842. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38843. * @returns the step Id
  38844. */
  38845. getStepId(): number;
  38846. /**
  38847. * Gets the internal step used by deterministic lock step
  38848. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38849. * @returns the internal step
  38850. */
  38851. getInternalStep(): number;
  38852. private _fogEnabled;
  38853. /**
  38854. * Gets or sets a boolean indicating if fog is enabled on this scene
  38855. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38856. * (Default is true)
  38857. */
  38858. set fogEnabled(value: boolean);
  38859. get fogEnabled(): boolean;
  38860. private _fogMode;
  38861. /**
  38862. * Gets or sets the fog mode to use
  38863. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38864. * | mode | value |
  38865. * | --- | --- |
  38866. * | FOGMODE_NONE | 0 |
  38867. * | FOGMODE_EXP | 1 |
  38868. * | FOGMODE_EXP2 | 2 |
  38869. * | FOGMODE_LINEAR | 3 |
  38870. */
  38871. set fogMode(value: number);
  38872. get fogMode(): number;
  38873. /**
  38874. * Gets or sets the fog color to use
  38875. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38876. * (Default is Color3(0.2, 0.2, 0.3))
  38877. */
  38878. fogColor: Color3;
  38879. /**
  38880. * Gets or sets the fog density to use
  38881. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38882. * (Default is 0.1)
  38883. */
  38884. fogDensity: number;
  38885. /**
  38886. * Gets or sets the fog start distance to use
  38887. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38888. * (Default is 0)
  38889. */
  38890. fogStart: number;
  38891. /**
  38892. * Gets or sets the fog end distance to use
  38893. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38894. * (Default is 1000)
  38895. */
  38896. fogEnd: number;
  38897. /**
  38898. * Flag indicating that the frame buffer binding is handled by another component
  38899. */
  38900. prePass: boolean;
  38901. private _shadowsEnabled;
  38902. /**
  38903. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38904. */
  38905. set shadowsEnabled(value: boolean);
  38906. get shadowsEnabled(): boolean;
  38907. private _lightsEnabled;
  38908. /**
  38909. * Gets or sets a boolean indicating if lights are enabled on this scene
  38910. */
  38911. set lightsEnabled(value: boolean);
  38912. get lightsEnabled(): boolean;
  38913. /** All of the active cameras added to this scene. */
  38914. activeCameras: Camera[];
  38915. /** @hidden */
  38916. _activeCamera: Nullable<Camera>;
  38917. /** Gets or sets the current active camera */
  38918. get activeCamera(): Nullable<Camera>;
  38919. set activeCamera(value: Nullable<Camera>);
  38920. private _defaultMaterial;
  38921. /** The default material used on meshes when no material is affected */
  38922. get defaultMaterial(): Material;
  38923. /** The default material used on meshes when no material is affected */
  38924. set defaultMaterial(value: Material);
  38925. private _texturesEnabled;
  38926. /**
  38927. * Gets or sets a boolean indicating if textures are enabled on this scene
  38928. */
  38929. set texturesEnabled(value: boolean);
  38930. get texturesEnabled(): boolean;
  38931. /**
  38932. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38933. */
  38934. physicsEnabled: boolean;
  38935. /**
  38936. * Gets or sets a boolean indicating if particles are enabled on this scene
  38937. */
  38938. particlesEnabled: boolean;
  38939. /**
  38940. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38941. */
  38942. spritesEnabled: boolean;
  38943. private _skeletonsEnabled;
  38944. /**
  38945. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38946. */
  38947. set skeletonsEnabled(value: boolean);
  38948. get skeletonsEnabled(): boolean;
  38949. /**
  38950. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38951. */
  38952. lensFlaresEnabled: boolean;
  38953. /**
  38954. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38955. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38956. */
  38957. collisionsEnabled: boolean;
  38958. private _collisionCoordinator;
  38959. /** @hidden */
  38960. get collisionCoordinator(): ICollisionCoordinator;
  38961. /**
  38962. * Defines the gravity applied to this scene (used only for collisions)
  38963. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38964. */
  38965. gravity: Vector3;
  38966. /**
  38967. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38968. */
  38969. postProcessesEnabled: boolean;
  38970. /**
  38971. * The list of postprocesses added to the scene
  38972. */
  38973. postProcesses: PostProcess[];
  38974. /**
  38975. * Gets the current postprocess manager
  38976. */
  38977. postProcessManager: PostProcessManager;
  38978. /**
  38979. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38980. */
  38981. renderTargetsEnabled: boolean;
  38982. /**
  38983. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38984. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38985. */
  38986. dumpNextRenderTargets: boolean;
  38987. /**
  38988. * The list of user defined render targets added to the scene
  38989. */
  38990. customRenderTargets: RenderTargetTexture[];
  38991. /**
  38992. * Defines if texture loading must be delayed
  38993. * If true, textures will only be loaded when they need to be rendered
  38994. */
  38995. useDelayedTextureLoading: boolean;
  38996. /**
  38997. * Gets the list of meshes imported to the scene through SceneLoader
  38998. */
  38999. importedMeshesFiles: String[];
  39000. /**
  39001. * Gets or sets a boolean indicating if probes are enabled on this scene
  39002. */
  39003. probesEnabled: boolean;
  39004. /**
  39005. * Gets or sets the current offline provider to use to store scene data
  39006. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39007. */
  39008. offlineProvider: IOfflineProvider;
  39009. /**
  39010. * Gets or sets the action manager associated with the scene
  39011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39012. */
  39013. actionManager: AbstractActionManager;
  39014. private _meshesForIntersections;
  39015. /**
  39016. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39017. */
  39018. proceduralTexturesEnabled: boolean;
  39019. private _engine;
  39020. private _totalVertices;
  39021. /** @hidden */
  39022. _activeIndices: PerfCounter;
  39023. /** @hidden */
  39024. _activeParticles: PerfCounter;
  39025. /** @hidden */
  39026. _activeBones: PerfCounter;
  39027. private _animationRatio;
  39028. /** @hidden */
  39029. _animationTimeLast: number;
  39030. /** @hidden */
  39031. _animationTime: number;
  39032. /**
  39033. * Gets or sets a general scale for animation speed
  39034. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39035. */
  39036. animationTimeScale: number;
  39037. /** @hidden */
  39038. _cachedMaterial: Nullable<Material>;
  39039. /** @hidden */
  39040. _cachedEffect: Nullable<Effect>;
  39041. /** @hidden */
  39042. _cachedVisibility: Nullable<number>;
  39043. private _renderId;
  39044. private _frameId;
  39045. private _executeWhenReadyTimeoutId;
  39046. private _intermediateRendering;
  39047. private _viewUpdateFlag;
  39048. private _projectionUpdateFlag;
  39049. /** @hidden */
  39050. _toBeDisposed: Nullable<IDisposable>[];
  39051. private _activeRequests;
  39052. /** @hidden */
  39053. _pendingData: any[];
  39054. private _isDisposed;
  39055. /**
  39056. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39057. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39058. */
  39059. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39060. private _activeMeshes;
  39061. private _processedMaterials;
  39062. private _renderTargets;
  39063. /** @hidden */
  39064. _activeParticleSystems: SmartArray<IParticleSystem>;
  39065. private _activeSkeletons;
  39066. private _softwareSkinnedMeshes;
  39067. private _renderingManager;
  39068. /** @hidden */
  39069. _activeAnimatables: Animatable[];
  39070. private _transformMatrix;
  39071. private _sceneUbo;
  39072. /** @hidden */
  39073. _viewMatrix: Matrix;
  39074. private _projectionMatrix;
  39075. /** @hidden */
  39076. _forcedViewPosition: Nullable<Vector3>;
  39077. /** @hidden */
  39078. _frustumPlanes: Plane[];
  39079. /**
  39080. * Gets the list of frustum planes (built from the active camera)
  39081. */
  39082. get frustumPlanes(): Plane[];
  39083. /**
  39084. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39085. * This is useful if there are more lights that the maximum simulteanous authorized
  39086. */
  39087. requireLightSorting: boolean;
  39088. /** @hidden */
  39089. readonly useMaterialMeshMap: boolean;
  39090. /** @hidden */
  39091. readonly useClonedMeshMap: boolean;
  39092. private _externalData;
  39093. private _uid;
  39094. /**
  39095. * @hidden
  39096. * Backing store of defined scene components.
  39097. */
  39098. _components: ISceneComponent[];
  39099. /**
  39100. * @hidden
  39101. * Backing store of defined scene components.
  39102. */
  39103. _serializableComponents: ISceneSerializableComponent[];
  39104. /**
  39105. * List of components to register on the next registration step.
  39106. */
  39107. private _transientComponents;
  39108. /**
  39109. * Registers the transient components if needed.
  39110. */
  39111. private _registerTransientComponents;
  39112. /**
  39113. * @hidden
  39114. * Add a component to the scene.
  39115. * Note that the ccomponent could be registered on th next frame if this is called after
  39116. * the register component stage.
  39117. * @param component Defines the component to add to the scene
  39118. */
  39119. _addComponent(component: ISceneComponent): void;
  39120. /**
  39121. * @hidden
  39122. * Gets a component from the scene.
  39123. * @param name defines the name of the component to retrieve
  39124. * @returns the component or null if not present
  39125. */
  39126. _getComponent(name: string): Nullable<ISceneComponent>;
  39127. /**
  39128. * @hidden
  39129. * Defines the actions happening before camera updates.
  39130. */
  39131. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39132. /**
  39133. * @hidden
  39134. * Defines the actions happening before clear the canvas.
  39135. */
  39136. _beforeClearStage: Stage<SimpleStageAction>;
  39137. /**
  39138. * @hidden
  39139. * Defines the actions when collecting render targets for the frame.
  39140. */
  39141. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39142. /**
  39143. * @hidden
  39144. * Defines the actions happening for one camera in the frame.
  39145. */
  39146. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39147. /**
  39148. * @hidden
  39149. * Defines the actions happening during the per mesh ready checks.
  39150. */
  39151. _isReadyForMeshStage: Stage<MeshStageAction>;
  39152. /**
  39153. * @hidden
  39154. * Defines the actions happening before evaluate active mesh checks.
  39155. */
  39156. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39157. /**
  39158. * @hidden
  39159. * Defines the actions happening during the evaluate sub mesh checks.
  39160. */
  39161. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39162. /**
  39163. * @hidden
  39164. * Defines the actions happening during the active mesh stage.
  39165. */
  39166. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39167. /**
  39168. * @hidden
  39169. * Defines the actions happening during the per camera render target step.
  39170. */
  39171. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39172. /**
  39173. * @hidden
  39174. * Defines the actions happening just before the active camera is drawing.
  39175. */
  39176. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39177. /**
  39178. * @hidden
  39179. * Defines the actions happening just before a render target is drawing.
  39180. */
  39181. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39182. /**
  39183. * @hidden
  39184. * Defines the actions happening just before a rendering group is drawing.
  39185. */
  39186. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39187. /**
  39188. * @hidden
  39189. * Defines the actions happening just before a mesh is drawing.
  39190. */
  39191. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39192. /**
  39193. * @hidden
  39194. * Defines the actions happening just after a mesh has been drawn.
  39195. */
  39196. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39197. /**
  39198. * @hidden
  39199. * Defines the actions happening just after a rendering group has been drawn.
  39200. */
  39201. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39202. /**
  39203. * @hidden
  39204. * Defines the actions happening just after the active camera has been drawn.
  39205. */
  39206. _afterCameraDrawStage: Stage<CameraStageAction>;
  39207. /**
  39208. * @hidden
  39209. * Defines the actions happening just after a render target has been drawn.
  39210. */
  39211. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39212. /**
  39213. * @hidden
  39214. * Defines the actions happening just after rendering all cameras and computing intersections.
  39215. */
  39216. _afterRenderStage: Stage<SimpleStageAction>;
  39217. /**
  39218. * @hidden
  39219. * Defines the actions happening when a pointer move event happens.
  39220. */
  39221. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39222. /**
  39223. * @hidden
  39224. * Defines the actions happening when a pointer down event happens.
  39225. */
  39226. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39227. /**
  39228. * @hidden
  39229. * Defines the actions happening when a pointer up event happens.
  39230. */
  39231. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39232. /**
  39233. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39234. */
  39235. private geometriesByUniqueId;
  39236. /**
  39237. * Creates a new Scene
  39238. * @param engine defines the engine to use to render this scene
  39239. * @param options defines the scene options
  39240. */
  39241. constructor(engine: Engine, options?: SceneOptions);
  39242. /**
  39243. * Gets a string idenfifying the name of the class
  39244. * @returns "Scene" string
  39245. */
  39246. getClassName(): string;
  39247. private _defaultMeshCandidates;
  39248. /**
  39249. * @hidden
  39250. */
  39251. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39252. private _defaultSubMeshCandidates;
  39253. /**
  39254. * @hidden
  39255. */
  39256. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39257. /**
  39258. * Sets the default candidate providers for the scene.
  39259. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39260. * and getCollidingSubMeshCandidates to their default function
  39261. */
  39262. setDefaultCandidateProviders(): void;
  39263. /**
  39264. * Gets the mesh that is currently under the pointer
  39265. */
  39266. get meshUnderPointer(): Nullable<AbstractMesh>;
  39267. /**
  39268. * Gets or sets the current on-screen X position of the pointer
  39269. */
  39270. get pointerX(): number;
  39271. set pointerX(value: number);
  39272. /**
  39273. * Gets or sets the current on-screen Y position of the pointer
  39274. */
  39275. get pointerY(): number;
  39276. set pointerY(value: number);
  39277. /**
  39278. * Gets the cached material (ie. the latest rendered one)
  39279. * @returns the cached material
  39280. */
  39281. getCachedMaterial(): Nullable<Material>;
  39282. /**
  39283. * Gets the cached effect (ie. the latest rendered one)
  39284. * @returns the cached effect
  39285. */
  39286. getCachedEffect(): Nullable<Effect>;
  39287. /**
  39288. * Gets the cached visibility state (ie. the latest rendered one)
  39289. * @returns the cached visibility state
  39290. */
  39291. getCachedVisibility(): Nullable<number>;
  39292. /**
  39293. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39294. * @param material defines the current material
  39295. * @param effect defines the current effect
  39296. * @param visibility defines the current visibility state
  39297. * @returns true if one parameter is not cached
  39298. */
  39299. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39300. /**
  39301. * Gets the engine associated with the scene
  39302. * @returns an Engine
  39303. */
  39304. getEngine(): Engine;
  39305. /**
  39306. * Gets the total number of vertices rendered per frame
  39307. * @returns the total number of vertices rendered per frame
  39308. */
  39309. getTotalVertices(): number;
  39310. /**
  39311. * Gets the performance counter for total vertices
  39312. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39313. */
  39314. get totalVerticesPerfCounter(): PerfCounter;
  39315. /**
  39316. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39317. * @returns the total number of active indices rendered per frame
  39318. */
  39319. getActiveIndices(): number;
  39320. /**
  39321. * Gets the performance counter for active indices
  39322. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39323. */
  39324. get totalActiveIndicesPerfCounter(): PerfCounter;
  39325. /**
  39326. * Gets the total number of active particles rendered per frame
  39327. * @returns the total number of active particles rendered per frame
  39328. */
  39329. getActiveParticles(): number;
  39330. /**
  39331. * Gets the performance counter for active particles
  39332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39333. */
  39334. get activeParticlesPerfCounter(): PerfCounter;
  39335. /**
  39336. * Gets the total number of active bones rendered per frame
  39337. * @returns the total number of active bones rendered per frame
  39338. */
  39339. getActiveBones(): number;
  39340. /**
  39341. * Gets the performance counter for active bones
  39342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39343. */
  39344. get activeBonesPerfCounter(): PerfCounter;
  39345. /**
  39346. * Gets the array of active meshes
  39347. * @returns an array of AbstractMesh
  39348. */
  39349. getActiveMeshes(): SmartArray<AbstractMesh>;
  39350. /**
  39351. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39352. * @returns a number
  39353. */
  39354. getAnimationRatio(): number;
  39355. /**
  39356. * Gets an unique Id for the current render phase
  39357. * @returns a number
  39358. */
  39359. getRenderId(): number;
  39360. /**
  39361. * Gets an unique Id for the current frame
  39362. * @returns a number
  39363. */
  39364. getFrameId(): number;
  39365. /** Call this function if you want to manually increment the render Id*/
  39366. incrementRenderId(): void;
  39367. private _createUbo;
  39368. /**
  39369. * Use this method to simulate a pointer move on a mesh
  39370. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39371. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39372. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39373. * @returns the current scene
  39374. */
  39375. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39376. /**
  39377. * Use this method to simulate a pointer down on a mesh
  39378. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39379. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39380. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39381. * @returns the current scene
  39382. */
  39383. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39384. /**
  39385. * Use this method to simulate a pointer up on a mesh
  39386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39389. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39390. * @returns the current scene
  39391. */
  39392. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39393. /**
  39394. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39395. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39396. * @returns true if the pointer was captured
  39397. */
  39398. isPointerCaptured(pointerId?: number): boolean;
  39399. /**
  39400. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39401. * @param attachUp defines if you want to attach events to pointerup
  39402. * @param attachDown defines if you want to attach events to pointerdown
  39403. * @param attachMove defines if you want to attach events to pointermove
  39404. */
  39405. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39406. /** Detaches all event handlers*/
  39407. detachControl(): void;
  39408. /**
  39409. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39410. * Delay loaded resources are not taking in account
  39411. * @return true if all required resources are ready
  39412. */
  39413. isReady(): boolean;
  39414. /** Resets all cached information relative to material (including effect and visibility) */
  39415. resetCachedMaterial(): void;
  39416. /**
  39417. * Registers a function to be called before every frame render
  39418. * @param func defines the function to register
  39419. */
  39420. registerBeforeRender(func: () => void): void;
  39421. /**
  39422. * Unregisters a function called before every frame render
  39423. * @param func defines the function to unregister
  39424. */
  39425. unregisterBeforeRender(func: () => void): void;
  39426. /**
  39427. * Registers a function to be called after every frame render
  39428. * @param func defines the function to register
  39429. */
  39430. registerAfterRender(func: () => void): void;
  39431. /**
  39432. * Unregisters a function called after every frame render
  39433. * @param func defines the function to unregister
  39434. */
  39435. unregisterAfterRender(func: () => void): void;
  39436. private _executeOnceBeforeRender;
  39437. /**
  39438. * The provided function will run before render once and will be disposed afterwards.
  39439. * A timeout delay can be provided so that the function will be executed in N ms.
  39440. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39441. * @param func The function to be executed.
  39442. * @param timeout optional delay in ms
  39443. */
  39444. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39445. /** @hidden */
  39446. _addPendingData(data: any): void;
  39447. /** @hidden */
  39448. _removePendingData(data: any): void;
  39449. /**
  39450. * Returns the number of items waiting to be loaded
  39451. * @returns the number of items waiting to be loaded
  39452. */
  39453. getWaitingItemsCount(): number;
  39454. /**
  39455. * Returns a boolean indicating if the scene is still loading data
  39456. */
  39457. get isLoading(): boolean;
  39458. /**
  39459. * Registers a function to be executed when the scene is ready
  39460. * @param {Function} func - the function to be executed
  39461. */
  39462. executeWhenReady(func: () => void): void;
  39463. /**
  39464. * Returns a promise that resolves when the scene is ready
  39465. * @returns A promise that resolves when the scene is ready
  39466. */
  39467. whenReadyAsync(): Promise<void>;
  39468. /** @hidden */
  39469. _checkIsReady(): void;
  39470. /**
  39471. * Gets all animatable attached to the scene
  39472. */
  39473. get animatables(): Animatable[];
  39474. /**
  39475. * Resets the last animation time frame.
  39476. * Useful to override when animations start running when loading a scene for the first time.
  39477. */
  39478. resetLastAnimationTimeFrame(): void;
  39479. /**
  39480. * Gets the current view matrix
  39481. * @returns a Matrix
  39482. */
  39483. getViewMatrix(): Matrix;
  39484. /**
  39485. * Gets the current projection matrix
  39486. * @returns a Matrix
  39487. */
  39488. getProjectionMatrix(): Matrix;
  39489. /**
  39490. * Gets the current transform matrix
  39491. * @returns a Matrix made of View * Projection
  39492. */
  39493. getTransformMatrix(): Matrix;
  39494. /**
  39495. * Sets the current transform matrix
  39496. * @param viewL defines the View matrix to use
  39497. * @param projectionL defines the Projection matrix to use
  39498. * @param viewR defines the right View matrix to use (if provided)
  39499. * @param projectionR defines the right Projection matrix to use (if provided)
  39500. */
  39501. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39502. /**
  39503. * Gets the uniform buffer used to store scene data
  39504. * @returns a UniformBuffer
  39505. */
  39506. getSceneUniformBuffer(): UniformBuffer;
  39507. /**
  39508. * Gets an unique (relatively to the current scene) Id
  39509. * @returns an unique number for the scene
  39510. */
  39511. getUniqueId(): number;
  39512. /**
  39513. * Add a mesh to the list of scene's meshes
  39514. * @param newMesh defines the mesh to add
  39515. * @param recursive if all child meshes should also be added to the scene
  39516. */
  39517. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39518. /**
  39519. * Remove a mesh for the list of scene's meshes
  39520. * @param toRemove defines the mesh to remove
  39521. * @param recursive if all child meshes should also be removed from the scene
  39522. * @returns the index where the mesh was in the mesh list
  39523. */
  39524. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39525. /**
  39526. * Add a transform node to the list of scene's transform nodes
  39527. * @param newTransformNode defines the transform node to add
  39528. */
  39529. addTransformNode(newTransformNode: TransformNode): void;
  39530. /**
  39531. * Remove a transform node for the list of scene's transform nodes
  39532. * @param toRemove defines the transform node to remove
  39533. * @returns the index where the transform node was in the transform node list
  39534. */
  39535. removeTransformNode(toRemove: TransformNode): number;
  39536. /**
  39537. * Remove a skeleton for the list of scene's skeletons
  39538. * @param toRemove defines the skeleton to remove
  39539. * @returns the index where the skeleton was in the skeleton list
  39540. */
  39541. removeSkeleton(toRemove: Skeleton): number;
  39542. /**
  39543. * Remove a morph target for the list of scene's morph targets
  39544. * @param toRemove defines the morph target to remove
  39545. * @returns the index where the morph target was in the morph target list
  39546. */
  39547. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39548. /**
  39549. * Remove a light for the list of scene's lights
  39550. * @param toRemove defines the light to remove
  39551. * @returns the index where the light was in the light list
  39552. */
  39553. removeLight(toRemove: Light): number;
  39554. /**
  39555. * Remove a camera for the list of scene's cameras
  39556. * @param toRemove defines the camera to remove
  39557. * @returns the index where the camera was in the camera list
  39558. */
  39559. removeCamera(toRemove: Camera): number;
  39560. /**
  39561. * Remove a particle system for the list of scene's particle systems
  39562. * @param toRemove defines the particle system to remove
  39563. * @returns the index where the particle system was in the particle system list
  39564. */
  39565. removeParticleSystem(toRemove: IParticleSystem): number;
  39566. /**
  39567. * Remove a animation for the list of scene's animations
  39568. * @param toRemove defines the animation to remove
  39569. * @returns the index where the animation was in the animation list
  39570. */
  39571. removeAnimation(toRemove: Animation): number;
  39572. /**
  39573. * Will stop the animation of the given target
  39574. * @param target - the target
  39575. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39576. * @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)
  39577. */
  39578. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39579. /**
  39580. * Removes the given animation group from this scene.
  39581. * @param toRemove The animation group to remove
  39582. * @returns The index of the removed animation group
  39583. */
  39584. removeAnimationGroup(toRemove: AnimationGroup): number;
  39585. /**
  39586. * Removes the given multi-material from this scene.
  39587. * @param toRemove The multi-material to remove
  39588. * @returns The index of the removed multi-material
  39589. */
  39590. removeMultiMaterial(toRemove: MultiMaterial): number;
  39591. /**
  39592. * Removes the given material from this scene.
  39593. * @param toRemove The material to remove
  39594. * @returns The index of the removed material
  39595. */
  39596. removeMaterial(toRemove: Material): number;
  39597. /**
  39598. * Removes the given action manager from this scene.
  39599. * @param toRemove The action manager to remove
  39600. * @returns The index of the removed action manager
  39601. */
  39602. removeActionManager(toRemove: AbstractActionManager): number;
  39603. /**
  39604. * Removes the given texture from this scene.
  39605. * @param toRemove The texture to remove
  39606. * @returns The index of the removed texture
  39607. */
  39608. removeTexture(toRemove: BaseTexture): number;
  39609. /**
  39610. * Adds the given light to this scene
  39611. * @param newLight The light to add
  39612. */
  39613. addLight(newLight: Light): void;
  39614. /**
  39615. * Sorts the list list based on light priorities
  39616. */
  39617. sortLightsByPriority(): void;
  39618. /**
  39619. * Adds the given camera to this scene
  39620. * @param newCamera The camera to add
  39621. */
  39622. addCamera(newCamera: Camera): void;
  39623. /**
  39624. * Adds the given skeleton to this scene
  39625. * @param newSkeleton The skeleton to add
  39626. */
  39627. addSkeleton(newSkeleton: Skeleton): void;
  39628. /**
  39629. * Adds the given particle system to this scene
  39630. * @param newParticleSystem The particle system to add
  39631. */
  39632. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39633. /**
  39634. * Adds the given animation to this scene
  39635. * @param newAnimation The animation to add
  39636. */
  39637. addAnimation(newAnimation: Animation): void;
  39638. /**
  39639. * Adds the given animation group to this scene.
  39640. * @param newAnimationGroup The animation group to add
  39641. */
  39642. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39643. /**
  39644. * Adds the given multi-material to this scene
  39645. * @param newMultiMaterial The multi-material to add
  39646. */
  39647. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39648. /**
  39649. * Adds the given material to this scene
  39650. * @param newMaterial The material to add
  39651. */
  39652. addMaterial(newMaterial: Material): void;
  39653. /**
  39654. * Adds the given morph target to this scene
  39655. * @param newMorphTargetManager The morph target to add
  39656. */
  39657. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39658. /**
  39659. * Adds the given geometry to this scene
  39660. * @param newGeometry The geometry to add
  39661. */
  39662. addGeometry(newGeometry: Geometry): void;
  39663. /**
  39664. * Adds the given action manager to this scene
  39665. * @param newActionManager The action manager to add
  39666. */
  39667. addActionManager(newActionManager: AbstractActionManager): void;
  39668. /**
  39669. * Adds the given texture to this scene.
  39670. * @param newTexture The texture to add
  39671. */
  39672. addTexture(newTexture: BaseTexture): void;
  39673. /**
  39674. * Switch active camera
  39675. * @param newCamera defines the new active camera
  39676. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39677. */
  39678. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39679. /**
  39680. * sets the active camera of the scene using its ID
  39681. * @param id defines the camera's ID
  39682. * @return the new active camera or null if none found.
  39683. */
  39684. setActiveCameraByID(id: string): Nullable<Camera>;
  39685. /**
  39686. * sets the active camera of the scene using its name
  39687. * @param name defines the camera's name
  39688. * @returns the new active camera or null if none found.
  39689. */
  39690. setActiveCameraByName(name: string): Nullable<Camera>;
  39691. /**
  39692. * get an animation group using its name
  39693. * @param name defines the material's name
  39694. * @return the animation group or null if none found.
  39695. */
  39696. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39697. /**
  39698. * Get a material using its unique id
  39699. * @param uniqueId defines the material's unique id
  39700. * @return the material or null if none found.
  39701. */
  39702. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39703. /**
  39704. * get a material using its id
  39705. * @param id defines the material's ID
  39706. * @return the material or null if none found.
  39707. */
  39708. getMaterialByID(id: string): Nullable<Material>;
  39709. /**
  39710. * Gets a the last added material using a given id
  39711. * @param id defines the material's ID
  39712. * @return the last material with the given id or null if none found.
  39713. */
  39714. getLastMaterialByID(id: string): Nullable<Material>;
  39715. /**
  39716. * Gets a material using its name
  39717. * @param name defines the material's name
  39718. * @return the material or null if none found.
  39719. */
  39720. getMaterialByName(name: string): Nullable<Material>;
  39721. /**
  39722. * Get a texture using its unique id
  39723. * @param uniqueId defines the texture's unique id
  39724. * @return the texture or null if none found.
  39725. */
  39726. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39727. /**
  39728. * Gets a camera using its id
  39729. * @param id defines the id to look for
  39730. * @returns the camera or null if not found
  39731. */
  39732. getCameraByID(id: string): Nullable<Camera>;
  39733. /**
  39734. * Gets a camera using its unique id
  39735. * @param uniqueId defines the unique id to look for
  39736. * @returns the camera or null if not found
  39737. */
  39738. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39739. /**
  39740. * Gets a camera using its name
  39741. * @param name defines the camera's name
  39742. * @return the camera or null if none found.
  39743. */
  39744. getCameraByName(name: string): Nullable<Camera>;
  39745. /**
  39746. * Gets a bone using its id
  39747. * @param id defines the bone's id
  39748. * @return the bone or null if not found
  39749. */
  39750. getBoneByID(id: string): Nullable<Bone>;
  39751. /**
  39752. * Gets a bone using its id
  39753. * @param name defines the bone's name
  39754. * @return the bone or null if not found
  39755. */
  39756. getBoneByName(name: string): Nullable<Bone>;
  39757. /**
  39758. * Gets a light node using its name
  39759. * @param name defines the the light's name
  39760. * @return the light or null if none found.
  39761. */
  39762. getLightByName(name: string): Nullable<Light>;
  39763. /**
  39764. * Gets a light node using its id
  39765. * @param id defines the light's id
  39766. * @return the light or null if none found.
  39767. */
  39768. getLightByID(id: string): Nullable<Light>;
  39769. /**
  39770. * Gets a light node using its scene-generated unique ID
  39771. * @param uniqueId defines the light's unique id
  39772. * @return the light or null if none found.
  39773. */
  39774. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39775. /**
  39776. * Gets a particle system by id
  39777. * @param id defines the particle system id
  39778. * @return the corresponding system or null if none found
  39779. */
  39780. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39781. /**
  39782. * Gets a geometry using its ID
  39783. * @param id defines the geometry's id
  39784. * @return the geometry or null if none found.
  39785. */
  39786. getGeometryByID(id: string): Nullable<Geometry>;
  39787. private _getGeometryByUniqueID;
  39788. /**
  39789. * Add a new geometry to this scene
  39790. * @param geometry defines the geometry to be added to the scene.
  39791. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39792. * @return a boolean defining if the geometry was added or not
  39793. */
  39794. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39795. /**
  39796. * Removes an existing geometry
  39797. * @param geometry defines the geometry to be removed from the scene
  39798. * @return a boolean defining if the geometry was removed or not
  39799. */
  39800. removeGeometry(geometry: Geometry): boolean;
  39801. /**
  39802. * Gets the list of geometries attached to the scene
  39803. * @returns an array of Geometry
  39804. */
  39805. getGeometries(): Geometry[];
  39806. /**
  39807. * Gets the first added mesh found of a given ID
  39808. * @param id defines the id to search for
  39809. * @return the mesh found or null if not found at all
  39810. */
  39811. getMeshByID(id: string): Nullable<AbstractMesh>;
  39812. /**
  39813. * Gets a list of meshes using their id
  39814. * @param id defines the id to search for
  39815. * @returns a list of meshes
  39816. */
  39817. getMeshesByID(id: string): Array<AbstractMesh>;
  39818. /**
  39819. * Gets the first added transform node found of a given ID
  39820. * @param id defines the id to search for
  39821. * @return the found transform node or null if not found at all.
  39822. */
  39823. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39824. /**
  39825. * Gets a transform node with its auto-generated unique id
  39826. * @param uniqueId efines the unique id to search for
  39827. * @return the found transform node or null if not found at all.
  39828. */
  39829. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39830. /**
  39831. * Gets a list of transform nodes using their id
  39832. * @param id defines the id to search for
  39833. * @returns a list of transform nodes
  39834. */
  39835. getTransformNodesByID(id: string): Array<TransformNode>;
  39836. /**
  39837. * Gets a mesh with its auto-generated unique id
  39838. * @param uniqueId defines the unique id to search for
  39839. * @return the found mesh or null if not found at all.
  39840. */
  39841. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39842. /**
  39843. * Gets a the last added mesh using a given id
  39844. * @param id defines the id to search for
  39845. * @return the found mesh or null if not found at all.
  39846. */
  39847. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39848. /**
  39849. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39850. * @param id defines the id to search for
  39851. * @return the found node or null if not found at all
  39852. */
  39853. getLastEntryByID(id: string): Nullable<Node>;
  39854. /**
  39855. * Gets a node (Mesh, Camera, Light) using a given id
  39856. * @param id defines the id to search for
  39857. * @return the found node or null if not found at all
  39858. */
  39859. getNodeByID(id: string): Nullable<Node>;
  39860. /**
  39861. * Gets a node (Mesh, Camera, Light) using a given name
  39862. * @param name defines the name to search for
  39863. * @return the found node or null if not found at all.
  39864. */
  39865. getNodeByName(name: string): Nullable<Node>;
  39866. /**
  39867. * Gets a mesh using a given name
  39868. * @param name defines the name to search for
  39869. * @return the found mesh or null if not found at all.
  39870. */
  39871. getMeshByName(name: string): Nullable<AbstractMesh>;
  39872. /**
  39873. * Gets a transform node using a given name
  39874. * @param name defines the name to search for
  39875. * @return the found transform node or null if not found at all.
  39876. */
  39877. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39878. /**
  39879. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39880. * @param id defines the id to search for
  39881. * @return the found skeleton or null if not found at all.
  39882. */
  39883. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39884. /**
  39885. * Gets a skeleton using a given auto generated unique id
  39886. * @param uniqueId defines the unique id to search for
  39887. * @return the found skeleton or null if not found at all.
  39888. */
  39889. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39890. /**
  39891. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39892. * @param id defines the id to search for
  39893. * @return the found skeleton or null if not found at all.
  39894. */
  39895. getSkeletonById(id: string): Nullable<Skeleton>;
  39896. /**
  39897. * Gets a skeleton using a given name
  39898. * @param name defines the name to search for
  39899. * @return the found skeleton or null if not found at all.
  39900. */
  39901. getSkeletonByName(name: string): Nullable<Skeleton>;
  39902. /**
  39903. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39904. * @param id defines the id to search for
  39905. * @return the found morph target manager or null if not found at all.
  39906. */
  39907. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39908. /**
  39909. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39910. * @param id defines the id to search for
  39911. * @return the found morph target or null if not found at all.
  39912. */
  39913. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39914. /**
  39915. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39916. * @param name defines the name to search for
  39917. * @return the found morph target or null if not found at all.
  39918. */
  39919. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39920. /**
  39921. * Gets a boolean indicating if the given mesh is active
  39922. * @param mesh defines the mesh to look for
  39923. * @returns true if the mesh is in the active list
  39924. */
  39925. isActiveMesh(mesh: AbstractMesh): boolean;
  39926. /**
  39927. * Return a unique id as a string which can serve as an identifier for the scene
  39928. */
  39929. get uid(): string;
  39930. /**
  39931. * Add an externaly attached data from its key.
  39932. * This method call will fail and return false, if such key already exists.
  39933. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39934. * @param key the unique key that identifies the data
  39935. * @param data the data object to associate to the key for this Engine instance
  39936. * @return true if no such key were already present and the data was added successfully, false otherwise
  39937. */
  39938. addExternalData<T>(key: string, data: T): boolean;
  39939. /**
  39940. * Get an externaly attached data from its key
  39941. * @param key the unique key that identifies the data
  39942. * @return the associated data, if present (can be null), or undefined if not present
  39943. */
  39944. getExternalData<T>(key: string): Nullable<T>;
  39945. /**
  39946. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39947. * @param key the unique key that identifies the data
  39948. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39949. * @return the associated data, can be null if the factory returned null.
  39950. */
  39951. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39952. /**
  39953. * Remove an externaly attached data from the Engine instance
  39954. * @param key the unique key that identifies the data
  39955. * @return true if the data was successfully removed, false if it doesn't exist
  39956. */
  39957. removeExternalData(key: string): boolean;
  39958. private _evaluateSubMesh;
  39959. /**
  39960. * Clear the processed materials smart array preventing retention point in material dispose.
  39961. */
  39962. freeProcessedMaterials(): void;
  39963. private _preventFreeActiveMeshesAndRenderingGroups;
  39964. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39965. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39966. * when disposing several meshes in a row or a hierarchy of meshes.
  39967. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39968. */
  39969. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39970. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39971. /**
  39972. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39973. */
  39974. freeActiveMeshes(): void;
  39975. /**
  39976. * Clear the info related to rendering groups preventing retention points during dispose.
  39977. */
  39978. freeRenderingGroups(): void;
  39979. /** @hidden */
  39980. _isInIntermediateRendering(): boolean;
  39981. /**
  39982. * Lambda returning the list of potentially active meshes.
  39983. */
  39984. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39985. /**
  39986. * Lambda returning the list of potentially active sub meshes.
  39987. */
  39988. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39989. /**
  39990. * Lambda returning the list of potentially intersecting sub meshes.
  39991. */
  39992. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39993. /**
  39994. * Lambda returning the list of potentially colliding sub meshes.
  39995. */
  39996. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39997. private _activeMeshesFrozen;
  39998. private _skipEvaluateActiveMeshesCompletely;
  39999. /**
  40000. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40001. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40002. * @returns the current scene
  40003. */
  40004. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40005. /**
  40006. * Use this function to restart evaluating active meshes on every frame
  40007. * @returns the current scene
  40008. */
  40009. unfreezeActiveMeshes(): Scene;
  40010. private _evaluateActiveMeshes;
  40011. private _activeMesh;
  40012. /**
  40013. * Update the transform matrix to update from the current active camera
  40014. * @param force defines a boolean used to force the update even if cache is up to date
  40015. */
  40016. updateTransformMatrix(force?: boolean): void;
  40017. private _bindFrameBuffer;
  40018. /** @hidden */
  40019. _allowPostProcessClearColor: boolean;
  40020. /** @hidden */
  40021. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40022. private _processSubCameras;
  40023. private _checkIntersections;
  40024. /** @hidden */
  40025. _advancePhysicsEngineStep(step: number): void;
  40026. /**
  40027. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40028. */
  40029. getDeterministicFrameTime: () => number;
  40030. /** @hidden */
  40031. _animate(): void;
  40032. /** Execute all animations (for a frame) */
  40033. animate(): void;
  40034. /**
  40035. * Render the scene
  40036. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40037. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40038. */
  40039. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40040. /**
  40041. * Freeze all materials
  40042. * A frozen material will not be updatable but should be faster to render
  40043. */
  40044. freezeMaterials(): void;
  40045. /**
  40046. * Unfreeze all materials
  40047. * A frozen material will not be updatable but should be faster to render
  40048. */
  40049. unfreezeMaterials(): void;
  40050. /**
  40051. * Releases all held ressources
  40052. */
  40053. dispose(): void;
  40054. /**
  40055. * Gets if the scene is already disposed
  40056. */
  40057. get isDisposed(): boolean;
  40058. /**
  40059. * Call this function to reduce memory footprint of the scene.
  40060. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40061. */
  40062. clearCachedVertexData(): void;
  40063. /**
  40064. * This function will remove the local cached buffer data from texture.
  40065. * It will save memory but will prevent the texture from being rebuilt
  40066. */
  40067. cleanCachedTextureBuffer(): void;
  40068. /**
  40069. * Get the world extend vectors with an optional filter
  40070. *
  40071. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40072. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40073. */
  40074. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40075. min: Vector3;
  40076. max: Vector3;
  40077. };
  40078. /**
  40079. * Creates a ray that can be used to pick in the scene
  40080. * @param x defines the x coordinate of the origin (on-screen)
  40081. * @param y defines the y coordinate of the origin (on-screen)
  40082. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40083. * @param camera defines the camera to use for the picking
  40084. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40085. * @returns a Ray
  40086. */
  40087. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40088. /**
  40089. * Creates a ray that can be used to pick in the scene
  40090. * @param x defines the x coordinate of the origin (on-screen)
  40091. * @param y defines the y coordinate of the origin (on-screen)
  40092. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40093. * @param result defines the ray where to store the picking ray
  40094. * @param camera defines the camera to use for the picking
  40095. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40096. * @returns the current scene
  40097. */
  40098. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40099. /**
  40100. * Creates a ray that can be used to pick in the scene
  40101. * @param x defines the x coordinate of the origin (on-screen)
  40102. * @param y defines the y coordinate of the origin (on-screen)
  40103. * @param camera defines the camera to use for the picking
  40104. * @returns a Ray
  40105. */
  40106. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40107. /**
  40108. * Creates a ray that can be used to pick in the scene
  40109. * @param x defines the x coordinate of the origin (on-screen)
  40110. * @param y defines the y coordinate of the origin (on-screen)
  40111. * @param result defines the ray where to store the picking ray
  40112. * @param camera defines the camera to use for the picking
  40113. * @returns the current scene
  40114. */
  40115. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40116. /** Launch a ray to try to pick a mesh in the scene
  40117. * @param x position on screen
  40118. * @param y position on screen
  40119. * @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
  40120. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40121. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40122. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40123. * @returns a PickingInfo
  40124. */
  40125. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40126. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40127. * @param x position on screen
  40128. * @param y position on screen
  40129. * @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
  40130. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40131. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40132. * @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)
  40133. */
  40134. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40135. /** Use the given ray to pick a mesh in the scene
  40136. * @param ray The ray to use to pick meshes
  40137. * @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
  40138. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40140. * @returns a PickingInfo
  40141. */
  40142. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40143. /**
  40144. * Launch a ray to try to pick a mesh in the scene
  40145. * @param x X position on screen
  40146. * @param y Y position on screen
  40147. * @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
  40148. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40149. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40150. * @returns an array of PickingInfo
  40151. */
  40152. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40153. /**
  40154. * Launch a ray to try to pick a mesh in the scene
  40155. * @param ray Ray to use
  40156. * @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
  40157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40158. * @returns an array of PickingInfo
  40159. */
  40160. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40161. /**
  40162. * Force the value of meshUnderPointer
  40163. * @param mesh defines the mesh to use
  40164. */
  40165. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40166. /**
  40167. * Gets the mesh under the pointer
  40168. * @returns a Mesh or null if no mesh is under the pointer
  40169. */
  40170. getPointerOverMesh(): Nullable<AbstractMesh>;
  40171. /** @hidden */
  40172. _rebuildGeometries(): void;
  40173. /** @hidden */
  40174. _rebuildTextures(): void;
  40175. private _getByTags;
  40176. /**
  40177. * Get a list of meshes by tags
  40178. * @param tagsQuery defines the tags query to use
  40179. * @param forEach defines a predicate used to filter results
  40180. * @returns an array of Mesh
  40181. */
  40182. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40183. /**
  40184. * Get a list of cameras by tags
  40185. * @param tagsQuery defines the tags query to use
  40186. * @param forEach defines a predicate used to filter results
  40187. * @returns an array of Camera
  40188. */
  40189. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40190. /**
  40191. * Get a list of lights by tags
  40192. * @param tagsQuery defines the tags query to use
  40193. * @param forEach defines a predicate used to filter results
  40194. * @returns an array of Light
  40195. */
  40196. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40197. /**
  40198. * Get a list of materials by tags
  40199. * @param tagsQuery defines the tags query to use
  40200. * @param forEach defines a predicate used to filter results
  40201. * @returns an array of Material
  40202. */
  40203. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40204. /**
  40205. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40206. * This allowed control for front to back rendering or reversly depending of the special needs.
  40207. *
  40208. * @param renderingGroupId The rendering group id corresponding to its index
  40209. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40210. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40211. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40212. */
  40213. 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;
  40214. /**
  40215. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40216. *
  40217. * @param renderingGroupId The rendering group id corresponding to its index
  40218. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40219. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40220. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40221. */
  40222. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40223. /**
  40224. * Gets the current auto clear configuration for one rendering group of the rendering
  40225. * manager.
  40226. * @param index the rendering group index to get the information for
  40227. * @returns The auto clear setup for the requested rendering group
  40228. */
  40229. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40230. private _blockMaterialDirtyMechanism;
  40231. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40232. get blockMaterialDirtyMechanism(): boolean;
  40233. set blockMaterialDirtyMechanism(value: boolean);
  40234. /**
  40235. * Will flag all materials as dirty to trigger new shader compilation
  40236. * @param flag defines the flag used to specify which material part must be marked as dirty
  40237. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40238. */
  40239. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40240. /** @hidden */
  40241. _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;
  40242. /** @hidden */
  40243. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40244. /** @hidden */
  40245. _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;
  40246. /** @hidden */
  40247. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40248. /** @hidden */
  40249. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40250. /** @hidden */
  40251. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40252. }
  40253. }
  40254. declare module BABYLON {
  40255. /**
  40256. * Set of assets to keep when moving a scene into an asset container.
  40257. */
  40258. export class KeepAssets extends AbstractScene {
  40259. }
  40260. /**
  40261. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40262. */
  40263. export class InstantiatedEntries {
  40264. /**
  40265. * List of new root nodes (eg. nodes with no parent)
  40266. */
  40267. rootNodes: TransformNode[];
  40268. /**
  40269. * List of new skeletons
  40270. */
  40271. skeletons: Skeleton[];
  40272. /**
  40273. * List of new animation groups
  40274. */
  40275. animationGroups: AnimationGroup[];
  40276. }
  40277. /**
  40278. * Container with a set of assets that can be added or removed from a scene.
  40279. */
  40280. export class AssetContainer extends AbstractScene {
  40281. private _wasAddedToScene;
  40282. /**
  40283. * The scene the AssetContainer belongs to.
  40284. */
  40285. scene: Scene;
  40286. /**
  40287. * Instantiates an AssetContainer.
  40288. * @param scene The scene the AssetContainer belongs to.
  40289. */
  40290. constructor(scene: Scene);
  40291. /**
  40292. * Instantiate or clone all meshes and add the new ones to the scene.
  40293. * Skeletons and animation groups will all be cloned
  40294. * @param nameFunction defines an optional function used to get new names for clones
  40295. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40296. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40297. */
  40298. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40299. /**
  40300. * Adds all the assets from the container to the scene.
  40301. */
  40302. addAllToScene(): void;
  40303. /**
  40304. * Removes all the assets in the container from the scene
  40305. */
  40306. removeAllFromScene(): void;
  40307. /**
  40308. * Disposes all the assets in the container
  40309. */
  40310. dispose(): void;
  40311. private _moveAssets;
  40312. /**
  40313. * Removes all the assets contained in the scene and adds them to the container.
  40314. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40315. */
  40316. moveAllFromScene(keepAssets?: KeepAssets): void;
  40317. /**
  40318. * 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.
  40319. * @returns the root mesh
  40320. */
  40321. createRootMesh(): Mesh;
  40322. /**
  40323. * Merge animations (direct and animation groups) from this asset container into a scene
  40324. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40325. * @param animatables set of animatables to retarget to a node from the scene
  40326. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40327. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40328. */
  40329. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40330. }
  40331. }
  40332. declare module BABYLON {
  40333. /**
  40334. * Defines how the parser contract is defined.
  40335. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40336. */
  40337. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40338. /**
  40339. * Defines how the individual parser contract is defined.
  40340. * These parser can parse an individual asset
  40341. */
  40342. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40343. /**
  40344. * Base class of the scene acting as a container for the different elements composing a scene.
  40345. * This class is dynamically extended by the different components of the scene increasing
  40346. * flexibility and reducing coupling
  40347. */
  40348. export abstract class AbstractScene {
  40349. /**
  40350. * Stores the list of available parsers in the application.
  40351. */
  40352. private static _BabylonFileParsers;
  40353. /**
  40354. * Stores the list of available individual parsers in the application.
  40355. */
  40356. private static _IndividualBabylonFileParsers;
  40357. /**
  40358. * Adds a parser in the list of available ones
  40359. * @param name Defines the name of the parser
  40360. * @param parser Defines the parser to add
  40361. */
  40362. static AddParser(name: string, parser: BabylonFileParser): void;
  40363. /**
  40364. * Gets a general parser from the list of avaialble ones
  40365. * @param name Defines the name of the parser
  40366. * @returns the requested parser or null
  40367. */
  40368. static GetParser(name: string): Nullable<BabylonFileParser>;
  40369. /**
  40370. * Adds n individual parser in the list of available ones
  40371. * @param name Defines the name of the parser
  40372. * @param parser Defines the parser to add
  40373. */
  40374. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40375. /**
  40376. * Gets an individual parser from the list of avaialble ones
  40377. * @param name Defines the name of the parser
  40378. * @returns the requested parser or null
  40379. */
  40380. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40381. /**
  40382. * Parser json data and populate both a scene and its associated container object
  40383. * @param jsonData Defines the data to parse
  40384. * @param scene Defines the scene to parse the data for
  40385. * @param container Defines the container attached to the parsing sequence
  40386. * @param rootUrl Defines the root url of the data
  40387. */
  40388. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40389. /**
  40390. * Gets the list of root nodes (ie. nodes with no parent)
  40391. */
  40392. rootNodes: Node[];
  40393. /** All of the cameras added to this scene
  40394. * @see https://doc.babylonjs.com/babylon101/cameras
  40395. */
  40396. cameras: Camera[];
  40397. /**
  40398. * All of the lights added to this scene
  40399. * @see https://doc.babylonjs.com/babylon101/lights
  40400. */
  40401. lights: Light[];
  40402. /**
  40403. * All of the (abstract) meshes added to this scene
  40404. */
  40405. meshes: AbstractMesh[];
  40406. /**
  40407. * The list of skeletons added to the scene
  40408. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40409. */
  40410. skeletons: Skeleton[];
  40411. /**
  40412. * All of the particle systems added to this scene
  40413. * @see https://doc.babylonjs.com/babylon101/particles
  40414. */
  40415. particleSystems: IParticleSystem[];
  40416. /**
  40417. * Gets a list of Animations associated with the scene
  40418. */
  40419. animations: Animation[];
  40420. /**
  40421. * All of the animation groups added to this scene
  40422. * @see https://doc.babylonjs.com/how_to/group
  40423. */
  40424. animationGroups: AnimationGroup[];
  40425. /**
  40426. * All of the multi-materials added to this scene
  40427. * @see https://doc.babylonjs.com/how_to/multi_materials
  40428. */
  40429. multiMaterials: MultiMaterial[];
  40430. /**
  40431. * All of the materials added to this scene
  40432. * In the context of a Scene, it is not supposed to be modified manually.
  40433. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40434. * Note also that the order of the Material within the array is not significant and might change.
  40435. * @see https://doc.babylonjs.com/babylon101/materials
  40436. */
  40437. materials: Material[];
  40438. /**
  40439. * The list of morph target managers added to the scene
  40440. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40441. */
  40442. morphTargetManagers: MorphTargetManager[];
  40443. /**
  40444. * The list of geometries used in the scene.
  40445. */
  40446. geometries: Geometry[];
  40447. /**
  40448. * All of the tranform nodes added to this scene
  40449. * In the context of a Scene, it is not supposed to be modified manually.
  40450. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40451. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40452. * @see https://doc.babylonjs.com/how_to/transformnode
  40453. */
  40454. transformNodes: TransformNode[];
  40455. /**
  40456. * ActionManagers available on the scene.
  40457. */
  40458. actionManagers: AbstractActionManager[];
  40459. /**
  40460. * Textures to keep.
  40461. */
  40462. textures: BaseTexture[];
  40463. /**
  40464. * Environment texture for the scene
  40465. */
  40466. environmentTexture: Nullable<BaseTexture>;
  40467. /**
  40468. * @returns all meshes, lights, cameras, transformNodes and bones
  40469. */
  40470. getNodes(): Array<Node>;
  40471. }
  40472. }
  40473. declare module BABYLON {
  40474. /**
  40475. * Interface used to define options for Sound class
  40476. */
  40477. export interface ISoundOptions {
  40478. /**
  40479. * Does the sound autoplay once loaded.
  40480. */
  40481. autoplay?: boolean;
  40482. /**
  40483. * Does the sound loop after it finishes playing once.
  40484. */
  40485. loop?: boolean;
  40486. /**
  40487. * Sound's volume
  40488. */
  40489. volume?: number;
  40490. /**
  40491. * Is it a spatial sound?
  40492. */
  40493. spatialSound?: boolean;
  40494. /**
  40495. * Maximum distance to hear that sound
  40496. */
  40497. maxDistance?: number;
  40498. /**
  40499. * Uses user defined attenuation function
  40500. */
  40501. useCustomAttenuation?: boolean;
  40502. /**
  40503. * Define the roll off factor of spatial sounds.
  40504. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40505. */
  40506. rolloffFactor?: number;
  40507. /**
  40508. * Define the reference distance the sound should be heard perfectly.
  40509. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40510. */
  40511. refDistance?: number;
  40512. /**
  40513. * Define the distance attenuation model the sound will follow.
  40514. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40515. */
  40516. distanceModel?: string;
  40517. /**
  40518. * Defines the playback speed (1 by default)
  40519. */
  40520. playbackRate?: number;
  40521. /**
  40522. * Defines if the sound is from a streaming source
  40523. */
  40524. streaming?: boolean;
  40525. /**
  40526. * Defines an optional length (in seconds) inside the sound file
  40527. */
  40528. length?: number;
  40529. /**
  40530. * Defines an optional offset (in seconds) inside the sound file
  40531. */
  40532. offset?: number;
  40533. /**
  40534. * If true, URLs will not be required to state the audio file codec to use.
  40535. */
  40536. skipCodecCheck?: boolean;
  40537. }
  40538. /**
  40539. * Defines a sound that can be played in the application.
  40540. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40542. */
  40543. export class Sound {
  40544. /**
  40545. * The name of the sound in the scene.
  40546. */
  40547. name: string;
  40548. /**
  40549. * Does the sound autoplay once loaded.
  40550. */
  40551. autoplay: boolean;
  40552. /**
  40553. * Does the sound loop after it finishes playing once.
  40554. */
  40555. loop: boolean;
  40556. /**
  40557. * Does the sound use a custom attenuation curve to simulate the falloff
  40558. * happening when the source gets further away from the camera.
  40559. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40560. */
  40561. useCustomAttenuation: boolean;
  40562. /**
  40563. * The sound track id this sound belongs to.
  40564. */
  40565. soundTrackId: number;
  40566. /**
  40567. * Is this sound currently played.
  40568. */
  40569. isPlaying: boolean;
  40570. /**
  40571. * Is this sound currently paused.
  40572. */
  40573. isPaused: boolean;
  40574. /**
  40575. * Does this sound enables spatial sound.
  40576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40577. */
  40578. spatialSound: boolean;
  40579. /**
  40580. * Define the reference distance the sound should be heard perfectly.
  40581. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40582. */
  40583. refDistance: number;
  40584. /**
  40585. * Define the roll off factor of spatial sounds.
  40586. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40587. */
  40588. rolloffFactor: number;
  40589. /**
  40590. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40591. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40592. */
  40593. maxDistance: number;
  40594. /**
  40595. * Define the distance attenuation model the sound will follow.
  40596. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40597. */
  40598. distanceModel: string;
  40599. /**
  40600. * @hidden
  40601. * Back Compat
  40602. **/
  40603. onended: () => any;
  40604. /**
  40605. * Gets or sets an object used to store user defined information for the sound.
  40606. */
  40607. metadata: any;
  40608. /**
  40609. * Observable event when the current playing sound finishes.
  40610. */
  40611. onEndedObservable: Observable<Sound>;
  40612. private _panningModel;
  40613. private _playbackRate;
  40614. private _streaming;
  40615. private _startTime;
  40616. private _startOffset;
  40617. private _position;
  40618. /** @hidden */
  40619. _positionInEmitterSpace: boolean;
  40620. private _localDirection;
  40621. private _volume;
  40622. private _isReadyToPlay;
  40623. private _isDirectional;
  40624. private _readyToPlayCallback;
  40625. private _audioBuffer;
  40626. private _soundSource;
  40627. private _streamingSource;
  40628. private _soundPanner;
  40629. private _soundGain;
  40630. private _inputAudioNode;
  40631. private _outputAudioNode;
  40632. private _coneInnerAngle;
  40633. private _coneOuterAngle;
  40634. private _coneOuterGain;
  40635. private _scene;
  40636. private _connectedTransformNode;
  40637. private _customAttenuationFunction;
  40638. private _registerFunc;
  40639. private _isOutputConnected;
  40640. private _htmlAudioElement;
  40641. private _urlType;
  40642. private _length?;
  40643. private _offset?;
  40644. /** @hidden */
  40645. static _SceneComponentInitialization: (scene: Scene) => void;
  40646. /**
  40647. * Create a sound and attach it to a scene
  40648. * @param name Name of your sound
  40649. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40650. * @param scene defines the scene the sound belongs to
  40651. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40652. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40653. */
  40654. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40655. /**
  40656. * Release the sound and its associated resources
  40657. */
  40658. dispose(): void;
  40659. /**
  40660. * Gets if the sounds is ready to be played or not.
  40661. * @returns true if ready, otherwise false
  40662. */
  40663. isReady(): boolean;
  40664. private _soundLoaded;
  40665. /**
  40666. * Sets the data of the sound from an audiobuffer
  40667. * @param audioBuffer The audioBuffer containing the data
  40668. */
  40669. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40670. /**
  40671. * Updates the current sounds options such as maxdistance, loop...
  40672. * @param options A JSON object containing values named as the object properties
  40673. */
  40674. updateOptions(options: ISoundOptions): void;
  40675. private _createSpatialParameters;
  40676. private _updateSpatialParameters;
  40677. /**
  40678. * Switch the panning model to HRTF:
  40679. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40680. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40681. */
  40682. switchPanningModelToHRTF(): void;
  40683. /**
  40684. * Switch the panning model to Equal Power:
  40685. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40687. */
  40688. switchPanningModelToEqualPower(): void;
  40689. private _switchPanningModel;
  40690. /**
  40691. * Connect this sound to a sound track audio node like gain...
  40692. * @param soundTrackAudioNode the sound track audio node to connect to
  40693. */
  40694. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40695. /**
  40696. * Transform this sound into a directional source
  40697. * @param coneInnerAngle Size of the inner cone in degree
  40698. * @param coneOuterAngle Size of the outer cone in degree
  40699. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40700. */
  40701. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40702. /**
  40703. * Gets or sets the inner angle for the directional cone.
  40704. */
  40705. get directionalConeInnerAngle(): number;
  40706. /**
  40707. * Gets or sets the inner angle for the directional cone.
  40708. */
  40709. set directionalConeInnerAngle(value: number);
  40710. /**
  40711. * Gets or sets the outer angle for the directional cone.
  40712. */
  40713. get directionalConeOuterAngle(): number;
  40714. /**
  40715. * Gets or sets the outer angle for the directional cone.
  40716. */
  40717. set directionalConeOuterAngle(value: number);
  40718. /**
  40719. * Sets the position of the emitter if spatial sound is enabled
  40720. * @param newPosition Defines the new posisiton
  40721. */
  40722. setPosition(newPosition: Vector3): void;
  40723. /**
  40724. * Sets the local direction of the emitter if spatial sound is enabled
  40725. * @param newLocalDirection Defines the new local direction
  40726. */
  40727. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40728. private _updateDirection;
  40729. /** @hidden */
  40730. updateDistanceFromListener(): void;
  40731. /**
  40732. * Sets a new custom attenuation function for the sound.
  40733. * @param callback Defines the function used for the attenuation
  40734. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40735. */
  40736. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40737. /**
  40738. * Play the sound
  40739. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40740. * @param offset (optional) Start the sound at a specific time in seconds
  40741. * @param length (optional) Sound duration (in seconds)
  40742. */
  40743. play(time?: number, offset?: number, length?: number): void;
  40744. private _onended;
  40745. /**
  40746. * Stop the sound
  40747. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40748. */
  40749. stop(time?: number): void;
  40750. /**
  40751. * Put the sound in pause
  40752. */
  40753. pause(): void;
  40754. /**
  40755. * Sets a dedicated volume for this sounds
  40756. * @param newVolume Define the new volume of the sound
  40757. * @param time Define time for gradual change to new volume
  40758. */
  40759. setVolume(newVolume: number, time?: number): void;
  40760. /**
  40761. * Set the sound play back rate
  40762. * @param newPlaybackRate Define the playback rate the sound should be played at
  40763. */
  40764. setPlaybackRate(newPlaybackRate: number): void;
  40765. /**
  40766. * Gets the volume of the sound.
  40767. * @returns the volume of the sound
  40768. */
  40769. getVolume(): number;
  40770. /**
  40771. * Attach the sound to a dedicated mesh
  40772. * @param transformNode The transform node to connect the sound with
  40773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40774. */
  40775. attachToMesh(transformNode: TransformNode): void;
  40776. /**
  40777. * Detach the sound from the previously attached mesh
  40778. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40779. */
  40780. detachFromMesh(): void;
  40781. private _onRegisterAfterWorldMatrixUpdate;
  40782. /**
  40783. * Clone the current sound in the scene.
  40784. * @returns the new sound clone
  40785. */
  40786. clone(): Nullable<Sound>;
  40787. /**
  40788. * Gets the current underlying audio buffer containing the data
  40789. * @returns the audio buffer
  40790. */
  40791. getAudioBuffer(): Nullable<AudioBuffer>;
  40792. /**
  40793. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40794. * @returns the source node
  40795. */
  40796. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40797. /**
  40798. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40799. * @returns the gain node
  40800. */
  40801. getSoundGain(): Nullable<GainNode>;
  40802. /**
  40803. * Serializes the Sound in a JSON representation
  40804. * @returns the JSON representation of the sound
  40805. */
  40806. serialize(): any;
  40807. /**
  40808. * Parse a JSON representation of a sound to innstantiate in a given scene
  40809. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40810. * @param scene Define the scene the new parsed sound should be created in
  40811. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40812. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40813. * @returns the newly parsed sound
  40814. */
  40815. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40816. }
  40817. }
  40818. declare module BABYLON {
  40819. /**
  40820. * This defines an action helpful to play a defined sound on a triggered action.
  40821. */
  40822. export class PlaySoundAction extends Action {
  40823. private _sound;
  40824. /**
  40825. * Instantiate the action
  40826. * @param triggerOptions defines the trigger options
  40827. * @param sound defines the sound to play
  40828. * @param condition defines the trigger related conditions
  40829. */
  40830. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40831. /** @hidden */
  40832. _prepare(): void;
  40833. /**
  40834. * Execute the action and play the sound.
  40835. */
  40836. execute(): void;
  40837. /**
  40838. * Serializes the actions and its related information.
  40839. * @param parent defines the object to serialize in
  40840. * @returns the serialized object
  40841. */
  40842. serialize(parent: any): any;
  40843. }
  40844. /**
  40845. * This defines an action helpful to stop a defined sound on a triggered action.
  40846. */
  40847. export class StopSoundAction extends Action {
  40848. private _sound;
  40849. /**
  40850. * Instantiate the action
  40851. * @param triggerOptions defines the trigger options
  40852. * @param sound defines the sound to stop
  40853. * @param condition defines the trigger related conditions
  40854. */
  40855. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40856. /** @hidden */
  40857. _prepare(): void;
  40858. /**
  40859. * Execute the action and stop the sound.
  40860. */
  40861. execute(): void;
  40862. /**
  40863. * Serializes the actions and its related information.
  40864. * @param parent defines the object to serialize in
  40865. * @returns the serialized object
  40866. */
  40867. serialize(parent: any): any;
  40868. }
  40869. }
  40870. declare module BABYLON {
  40871. /**
  40872. * This defines an action responsible to change the value of a property
  40873. * by interpolating between its current value and the newly set one once triggered.
  40874. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40875. */
  40876. export class InterpolateValueAction extends Action {
  40877. /**
  40878. * Defines the path of the property where the value should be interpolated
  40879. */
  40880. propertyPath: string;
  40881. /**
  40882. * Defines the target value at the end of the interpolation.
  40883. */
  40884. value: any;
  40885. /**
  40886. * Defines the time it will take for the property to interpolate to the value.
  40887. */
  40888. duration: number;
  40889. /**
  40890. * Defines if the other scene animations should be stopped when the action has been triggered
  40891. */
  40892. stopOtherAnimations?: boolean;
  40893. /**
  40894. * Defines a callback raised once the interpolation animation has been done.
  40895. */
  40896. onInterpolationDone?: () => void;
  40897. /**
  40898. * Observable triggered once the interpolation animation has been done.
  40899. */
  40900. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40901. private _target;
  40902. private _effectiveTarget;
  40903. private _property;
  40904. /**
  40905. * Instantiate the action
  40906. * @param triggerOptions defines the trigger options
  40907. * @param target defines the object containing the value to interpolate
  40908. * @param propertyPath defines the path to the property in the target object
  40909. * @param value defines the target value at the end of the interpolation
  40910. * @param duration deines the time it will take for the property to interpolate to the value.
  40911. * @param condition defines the trigger related conditions
  40912. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40913. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40914. */
  40915. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40916. /** @hidden */
  40917. _prepare(): void;
  40918. /**
  40919. * Execute the action starts the value interpolation.
  40920. */
  40921. execute(): void;
  40922. /**
  40923. * Serializes the actions and its related information.
  40924. * @param parent defines the object to serialize in
  40925. * @returns the serialized object
  40926. */
  40927. serialize(parent: any): any;
  40928. }
  40929. }
  40930. declare module BABYLON {
  40931. /**
  40932. * Options allowed during the creation of a sound track.
  40933. */
  40934. export interface ISoundTrackOptions {
  40935. /**
  40936. * The volume the sound track should take during creation
  40937. */
  40938. volume?: number;
  40939. /**
  40940. * Define if the sound track is the main sound track of the scene
  40941. */
  40942. mainTrack?: boolean;
  40943. }
  40944. /**
  40945. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40946. * It will be also used in a future release to apply effects on a specific track.
  40947. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40948. */
  40949. export class SoundTrack {
  40950. /**
  40951. * The unique identifier of the sound track in the scene.
  40952. */
  40953. id: number;
  40954. /**
  40955. * The list of sounds included in the sound track.
  40956. */
  40957. soundCollection: Array<Sound>;
  40958. private _outputAudioNode;
  40959. private _scene;
  40960. private _connectedAnalyser;
  40961. private _options;
  40962. private _isInitialized;
  40963. /**
  40964. * Creates a new sound track.
  40965. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40966. * @param scene Define the scene the sound track belongs to
  40967. * @param options
  40968. */
  40969. constructor(scene: Scene, options?: ISoundTrackOptions);
  40970. private _initializeSoundTrackAudioGraph;
  40971. /**
  40972. * Release the sound track and its associated resources
  40973. */
  40974. dispose(): void;
  40975. /**
  40976. * Adds a sound to this sound track
  40977. * @param sound define the cound to add
  40978. * @ignoreNaming
  40979. */
  40980. AddSound(sound: Sound): void;
  40981. /**
  40982. * Removes a sound to this sound track
  40983. * @param sound define the cound to remove
  40984. * @ignoreNaming
  40985. */
  40986. RemoveSound(sound: Sound): void;
  40987. /**
  40988. * Set a global volume for the full sound track.
  40989. * @param newVolume Define the new volume of the sound track
  40990. */
  40991. setVolume(newVolume: number): void;
  40992. /**
  40993. * Switch the panning model to HRTF:
  40994. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40995. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40996. */
  40997. switchPanningModelToHRTF(): void;
  40998. /**
  40999. * Switch the panning model to Equal Power:
  41000. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41001. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41002. */
  41003. switchPanningModelToEqualPower(): void;
  41004. /**
  41005. * Connect the sound track to an audio analyser allowing some amazing
  41006. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41008. * @param analyser The analyser to connect to the engine
  41009. */
  41010. connectToAnalyser(analyser: Analyser): void;
  41011. }
  41012. }
  41013. declare module BABYLON {
  41014. interface AbstractScene {
  41015. /**
  41016. * The list of sounds used in the scene.
  41017. */
  41018. sounds: Nullable<Array<Sound>>;
  41019. }
  41020. interface Scene {
  41021. /**
  41022. * @hidden
  41023. * Backing field
  41024. */
  41025. _mainSoundTrack: SoundTrack;
  41026. /**
  41027. * The main sound track played by the scene.
  41028. * It cotains your primary collection of sounds.
  41029. */
  41030. mainSoundTrack: SoundTrack;
  41031. /**
  41032. * The list of sound tracks added to the scene
  41033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41034. */
  41035. soundTracks: Nullable<Array<SoundTrack>>;
  41036. /**
  41037. * Gets a sound using a given name
  41038. * @param name defines the name to search for
  41039. * @return the found sound or null if not found at all.
  41040. */
  41041. getSoundByName(name: string): Nullable<Sound>;
  41042. /**
  41043. * Gets or sets if audio support is enabled
  41044. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41045. */
  41046. audioEnabled: boolean;
  41047. /**
  41048. * Gets or sets if audio will be output to headphones
  41049. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41050. */
  41051. headphone: boolean;
  41052. /**
  41053. * Gets or sets custom audio listener position provider
  41054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41055. */
  41056. audioListenerPositionProvider: Nullable<() => Vector3>;
  41057. /**
  41058. * Gets or sets a refresh rate when using 3D audio positioning
  41059. */
  41060. audioPositioningRefreshRate: number;
  41061. }
  41062. /**
  41063. * Defines the sound scene component responsible to manage any sounds
  41064. * in a given scene.
  41065. */
  41066. export class AudioSceneComponent implements ISceneSerializableComponent {
  41067. /**
  41068. * The component name helpfull to identify the component in the list of scene components.
  41069. */
  41070. readonly name: string;
  41071. /**
  41072. * The scene the component belongs to.
  41073. */
  41074. scene: Scene;
  41075. private _audioEnabled;
  41076. /**
  41077. * Gets whether audio is enabled or not.
  41078. * Please use related enable/disable method to switch state.
  41079. */
  41080. get audioEnabled(): boolean;
  41081. private _headphone;
  41082. /**
  41083. * Gets whether audio is outputing to headphone or not.
  41084. * Please use the according Switch methods to change output.
  41085. */
  41086. get headphone(): boolean;
  41087. /**
  41088. * Gets or sets a refresh rate when using 3D audio positioning
  41089. */
  41090. audioPositioningRefreshRate: number;
  41091. private _audioListenerPositionProvider;
  41092. /**
  41093. * Gets the current audio listener position provider
  41094. */
  41095. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41096. /**
  41097. * Sets a custom listener position for all sounds in the scene
  41098. * By default, this is the position of the first active camera
  41099. */
  41100. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41101. /**
  41102. * Creates a new instance of the component for the given scene
  41103. * @param scene Defines the scene to register the component in
  41104. */
  41105. constructor(scene: Scene);
  41106. /**
  41107. * Registers the component in a given scene
  41108. */
  41109. register(): void;
  41110. /**
  41111. * Rebuilds the elements related to this component in case of
  41112. * context lost for instance.
  41113. */
  41114. rebuild(): void;
  41115. /**
  41116. * Serializes the component data to the specified json object
  41117. * @param serializationObject The object to serialize to
  41118. */
  41119. serialize(serializationObject: any): void;
  41120. /**
  41121. * Adds all the elements from the container to the scene
  41122. * @param container the container holding the elements
  41123. */
  41124. addFromContainer(container: AbstractScene): void;
  41125. /**
  41126. * Removes all the elements in the container from the scene
  41127. * @param container contains the elements to remove
  41128. * @param dispose if the removed element should be disposed (default: false)
  41129. */
  41130. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41131. /**
  41132. * Disposes the component and the associated ressources.
  41133. */
  41134. dispose(): void;
  41135. /**
  41136. * Disables audio in the associated scene.
  41137. */
  41138. disableAudio(): void;
  41139. /**
  41140. * Enables audio in the associated scene.
  41141. */
  41142. enableAudio(): void;
  41143. /**
  41144. * Switch audio to headphone output.
  41145. */
  41146. switchAudioModeForHeadphones(): void;
  41147. /**
  41148. * Switch audio to normal speakers.
  41149. */
  41150. switchAudioModeForNormalSpeakers(): void;
  41151. private _cachedCameraDirection;
  41152. private _cachedCameraPosition;
  41153. private _lastCheck;
  41154. private _afterRender;
  41155. }
  41156. }
  41157. declare module BABYLON {
  41158. /**
  41159. * Wraps one or more Sound objects and selects one with random weight for playback.
  41160. */
  41161. export class WeightedSound {
  41162. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41163. loop: boolean;
  41164. private _coneInnerAngle;
  41165. private _coneOuterAngle;
  41166. private _volume;
  41167. /** A Sound is currently playing. */
  41168. isPlaying: boolean;
  41169. /** A Sound is currently paused. */
  41170. isPaused: boolean;
  41171. private _sounds;
  41172. private _weights;
  41173. private _currentIndex?;
  41174. /**
  41175. * Creates a new WeightedSound from the list of sounds given.
  41176. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41177. * @param sounds Array of Sounds that will be selected from.
  41178. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41179. */
  41180. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41181. /**
  41182. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41183. */
  41184. get directionalConeInnerAngle(): number;
  41185. /**
  41186. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41187. */
  41188. set directionalConeInnerAngle(value: number);
  41189. /**
  41190. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41191. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41192. */
  41193. get directionalConeOuterAngle(): number;
  41194. /**
  41195. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41196. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41197. */
  41198. set directionalConeOuterAngle(value: number);
  41199. /**
  41200. * Playback volume.
  41201. */
  41202. get volume(): number;
  41203. /**
  41204. * Playback volume.
  41205. */
  41206. set volume(value: number);
  41207. private _onended;
  41208. /**
  41209. * Suspend playback
  41210. */
  41211. pause(): void;
  41212. /**
  41213. * Stop playback
  41214. */
  41215. stop(): void;
  41216. /**
  41217. * Start playback.
  41218. * @param startOffset Position the clip head at a specific time in seconds.
  41219. */
  41220. play(startOffset?: number): void;
  41221. }
  41222. }
  41223. declare module BABYLON {
  41224. /**
  41225. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41226. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41227. */
  41228. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41229. /**
  41230. * Gets the name of the behavior.
  41231. */
  41232. get name(): string;
  41233. /**
  41234. * The easing function used by animations
  41235. */
  41236. static EasingFunction: BackEase;
  41237. /**
  41238. * The easing mode used by animations
  41239. */
  41240. static EasingMode: number;
  41241. /**
  41242. * The duration of the animation, in milliseconds
  41243. */
  41244. transitionDuration: number;
  41245. /**
  41246. * Length of the distance animated by the transition when lower radius is reached
  41247. */
  41248. lowerRadiusTransitionRange: number;
  41249. /**
  41250. * Length of the distance animated by the transition when upper radius is reached
  41251. */
  41252. upperRadiusTransitionRange: number;
  41253. private _autoTransitionRange;
  41254. /**
  41255. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41256. */
  41257. get autoTransitionRange(): boolean;
  41258. /**
  41259. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41260. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41261. */
  41262. set autoTransitionRange(value: boolean);
  41263. private _attachedCamera;
  41264. private _onAfterCheckInputsObserver;
  41265. private _onMeshTargetChangedObserver;
  41266. /**
  41267. * Initializes the behavior.
  41268. */
  41269. init(): void;
  41270. /**
  41271. * Attaches the behavior to its arc rotate camera.
  41272. * @param camera Defines the camera to attach the behavior to
  41273. */
  41274. attach(camera: ArcRotateCamera): void;
  41275. /**
  41276. * Detaches the behavior from its current arc rotate camera.
  41277. */
  41278. detach(): void;
  41279. private _radiusIsAnimating;
  41280. private _radiusBounceTransition;
  41281. private _animatables;
  41282. private _cachedWheelPrecision;
  41283. /**
  41284. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41285. * @param radiusLimit The limit to check against.
  41286. * @return Bool to indicate if at limit.
  41287. */
  41288. private _isRadiusAtLimit;
  41289. /**
  41290. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41291. * @param radiusDelta The delta by which to animate to. Can be negative.
  41292. */
  41293. private _applyBoundRadiusAnimation;
  41294. /**
  41295. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41296. */
  41297. protected _clearAnimationLocks(): void;
  41298. /**
  41299. * Stops and removes all animations that have been applied to the camera
  41300. */
  41301. stopAllAnimations(): void;
  41302. }
  41303. }
  41304. declare module BABYLON {
  41305. /**
  41306. * 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.
  41307. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41308. */
  41309. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41310. /**
  41311. * Gets the name of the behavior.
  41312. */
  41313. get name(): string;
  41314. private _mode;
  41315. private _radiusScale;
  41316. private _positionScale;
  41317. private _defaultElevation;
  41318. private _elevationReturnTime;
  41319. private _elevationReturnWaitTime;
  41320. private _zoomStopsAnimation;
  41321. private _framingTime;
  41322. /**
  41323. * The easing function used by animations
  41324. */
  41325. static EasingFunction: ExponentialEase;
  41326. /**
  41327. * The easing mode used by animations
  41328. */
  41329. static EasingMode: number;
  41330. /**
  41331. * Sets the current mode used by the behavior
  41332. */
  41333. set mode(mode: number);
  41334. /**
  41335. * Gets current mode used by the behavior.
  41336. */
  41337. get mode(): number;
  41338. /**
  41339. * Sets the scale applied to the radius (1 by default)
  41340. */
  41341. set radiusScale(radius: number);
  41342. /**
  41343. * Gets the scale applied to the radius
  41344. */
  41345. get radiusScale(): number;
  41346. /**
  41347. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41348. */
  41349. set positionScale(scale: number);
  41350. /**
  41351. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41352. */
  41353. get positionScale(): number;
  41354. /**
  41355. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41356. * behaviour is triggered, in radians.
  41357. */
  41358. set defaultElevation(elevation: number);
  41359. /**
  41360. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41361. * behaviour is triggered, in radians.
  41362. */
  41363. get defaultElevation(): number;
  41364. /**
  41365. * Sets the time (in milliseconds) taken to return to the default beta position.
  41366. * Negative value indicates camera should not return to default.
  41367. */
  41368. set elevationReturnTime(speed: number);
  41369. /**
  41370. * Gets the time (in milliseconds) taken to return to the default beta position.
  41371. * Negative value indicates camera should not return to default.
  41372. */
  41373. get elevationReturnTime(): number;
  41374. /**
  41375. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41376. */
  41377. set elevationReturnWaitTime(time: number);
  41378. /**
  41379. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41380. */
  41381. get elevationReturnWaitTime(): number;
  41382. /**
  41383. * Sets the flag that indicates if user zooming should stop animation.
  41384. */
  41385. set zoomStopsAnimation(flag: boolean);
  41386. /**
  41387. * Gets the flag that indicates if user zooming should stop animation.
  41388. */
  41389. get zoomStopsAnimation(): boolean;
  41390. /**
  41391. * Sets the transition time when framing the mesh, in milliseconds
  41392. */
  41393. set framingTime(time: number);
  41394. /**
  41395. * Gets the transition time when framing the mesh, in milliseconds
  41396. */
  41397. get framingTime(): number;
  41398. /**
  41399. * Define if the behavior should automatically change the configured
  41400. * camera limits and sensibilities.
  41401. */
  41402. autoCorrectCameraLimitsAndSensibility: boolean;
  41403. private _onPrePointerObservableObserver;
  41404. private _onAfterCheckInputsObserver;
  41405. private _onMeshTargetChangedObserver;
  41406. private _attachedCamera;
  41407. private _isPointerDown;
  41408. private _lastInteractionTime;
  41409. /**
  41410. * Initializes the behavior.
  41411. */
  41412. init(): void;
  41413. /**
  41414. * Attaches the behavior to its arc rotate camera.
  41415. * @param camera Defines the camera to attach the behavior to
  41416. */
  41417. attach(camera: ArcRotateCamera): void;
  41418. /**
  41419. * Detaches the behavior from its current arc rotate camera.
  41420. */
  41421. detach(): void;
  41422. private _animatables;
  41423. private _betaIsAnimating;
  41424. private _betaTransition;
  41425. private _radiusTransition;
  41426. private _vectorTransition;
  41427. /**
  41428. * Targets the given mesh and updates zoom level accordingly.
  41429. * @param mesh The mesh to target.
  41430. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41431. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41432. */
  41433. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41434. /**
  41435. * Targets the given mesh with its children and updates zoom level accordingly.
  41436. * @param mesh The mesh to target.
  41437. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41438. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41439. */
  41440. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41441. /**
  41442. * Targets the given meshes with their children and updates zoom level accordingly.
  41443. * @param meshes The mesh to target.
  41444. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41445. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41446. */
  41447. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41448. /**
  41449. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41450. * @param minimumWorld Determines the smaller position of the bounding box extend
  41451. * @param maximumWorld Determines the bigger position of the bounding box extend
  41452. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41453. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41454. */
  41455. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41456. /**
  41457. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41458. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41459. * frustum width.
  41460. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41461. * to fully enclose the mesh in the viewing frustum.
  41462. */
  41463. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41464. /**
  41465. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41466. * is automatically returned to its default position (expected to be above ground plane).
  41467. */
  41468. private _maintainCameraAboveGround;
  41469. /**
  41470. * Returns the frustum slope based on the canvas ratio and camera FOV
  41471. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41472. */
  41473. private _getFrustumSlope;
  41474. /**
  41475. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41476. */
  41477. private _clearAnimationLocks;
  41478. /**
  41479. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41480. */
  41481. private _applyUserInteraction;
  41482. /**
  41483. * Stops and removes all animations that have been applied to the camera
  41484. */
  41485. stopAllAnimations(): void;
  41486. /**
  41487. * Gets a value indicating if the user is moving the camera
  41488. */
  41489. get isUserIsMoving(): boolean;
  41490. /**
  41491. * The camera can move all the way towards the mesh.
  41492. */
  41493. static IgnoreBoundsSizeMode: number;
  41494. /**
  41495. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41496. */
  41497. static FitFrustumSidesMode: number;
  41498. }
  41499. }
  41500. declare module BABYLON {
  41501. /**
  41502. * Base class for Camera Pointer Inputs.
  41503. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41504. * for example usage.
  41505. */
  41506. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41507. /**
  41508. * Defines the camera the input is attached to.
  41509. */
  41510. abstract camera: Camera;
  41511. /**
  41512. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41513. */
  41514. protected _altKey: boolean;
  41515. protected _ctrlKey: boolean;
  41516. protected _metaKey: boolean;
  41517. protected _shiftKey: boolean;
  41518. /**
  41519. * Which mouse buttons were pressed at time of last mouse event.
  41520. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41521. */
  41522. protected _buttonsPressed: number;
  41523. /**
  41524. * Defines the buttons associated with the input to handle camera move.
  41525. */
  41526. buttons: number[];
  41527. /**
  41528. * Attach the input controls to a specific dom element to get the input from.
  41529. * @param element Defines the element the controls should be listened from
  41530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41531. */
  41532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41533. /**
  41534. * Detach the current controls from the specified dom element.
  41535. * @param element Defines the element to stop listening the inputs from
  41536. */
  41537. detachControl(element: Nullable<HTMLElement>): void;
  41538. /**
  41539. * Gets the class name of the current input.
  41540. * @returns the class name
  41541. */
  41542. getClassName(): string;
  41543. /**
  41544. * Get the friendly name associated with the input class.
  41545. * @returns the input friendly name
  41546. */
  41547. getSimpleName(): string;
  41548. /**
  41549. * Called on pointer POINTERDOUBLETAP event.
  41550. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41551. */
  41552. protected onDoubleTap(type: string): void;
  41553. /**
  41554. * Called on pointer POINTERMOVE event if only a single touch is active.
  41555. * Override this method to provide functionality.
  41556. */
  41557. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41558. /**
  41559. * Called on pointer POINTERMOVE event if multiple touches are active.
  41560. * Override this method to provide functionality.
  41561. */
  41562. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41563. /**
  41564. * Called on JS contextmenu event.
  41565. * Override this method to provide functionality.
  41566. */
  41567. protected onContextMenu(evt: PointerEvent): void;
  41568. /**
  41569. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41570. * press.
  41571. * Override this method to provide functionality.
  41572. */
  41573. protected onButtonDown(evt: PointerEvent): void;
  41574. /**
  41575. * Called each time a new POINTERUP event occurs. Ie, for each button
  41576. * release.
  41577. * Override this method to provide functionality.
  41578. */
  41579. protected onButtonUp(evt: PointerEvent): void;
  41580. /**
  41581. * Called when window becomes inactive.
  41582. * Override this method to provide functionality.
  41583. */
  41584. protected onLostFocus(): void;
  41585. private _pointerInput;
  41586. private _observer;
  41587. private _onLostFocus;
  41588. private pointA;
  41589. private pointB;
  41590. }
  41591. }
  41592. declare module BABYLON {
  41593. /**
  41594. * Manage the pointers inputs to control an arc rotate camera.
  41595. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41596. */
  41597. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41598. /**
  41599. * Defines the camera the input is attached to.
  41600. */
  41601. camera: ArcRotateCamera;
  41602. /**
  41603. * Gets the class name of the current input.
  41604. * @returns the class name
  41605. */
  41606. getClassName(): string;
  41607. /**
  41608. * Defines the buttons associated with the input to handle camera move.
  41609. */
  41610. buttons: number[];
  41611. /**
  41612. * Defines the pointer angular sensibility along the X axis or how fast is
  41613. * the camera rotating.
  41614. */
  41615. angularSensibilityX: number;
  41616. /**
  41617. * Defines the pointer angular sensibility along the Y axis or how fast is
  41618. * the camera rotating.
  41619. */
  41620. angularSensibilityY: number;
  41621. /**
  41622. * Defines the pointer pinch precision or how fast is the camera zooming.
  41623. */
  41624. pinchPrecision: number;
  41625. /**
  41626. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41627. * from 0.
  41628. * It defines the percentage of current camera.radius to use as delta when
  41629. * pinch zoom is used.
  41630. */
  41631. pinchDeltaPercentage: number;
  41632. /**
  41633. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41634. * that any object in the plane at the camera's target point will scale
  41635. * perfectly with finger motion.
  41636. * Overrides pinchDeltaPercentage and pinchPrecision.
  41637. */
  41638. useNaturalPinchZoom: boolean;
  41639. /**
  41640. * Defines the pointer panning sensibility or how fast is the camera moving.
  41641. */
  41642. panningSensibility: number;
  41643. /**
  41644. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41645. */
  41646. multiTouchPanning: boolean;
  41647. /**
  41648. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41649. * zoom (pinch) through multitouch.
  41650. */
  41651. multiTouchPanAndZoom: boolean;
  41652. /**
  41653. * Revers pinch action direction.
  41654. */
  41655. pinchInwards: boolean;
  41656. private _isPanClick;
  41657. private _twoFingerActivityCount;
  41658. private _isPinching;
  41659. /**
  41660. * Called on pointer POINTERMOVE event if only a single touch is active.
  41661. */
  41662. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41663. /**
  41664. * Called on pointer POINTERDOUBLETAP event.
  41665. */
  41666. protected onDoubleTap(type: string): void;
  41667. /**
  41668. * Called on pointer POINTERMOVE event if multiple touches are active.
  41669. */
  41670. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41671. /**
  41672. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41673. * press.
  41674. */
  41675. protected onButtonDown(evt: PointerEvent): void;
  41676. /**
  41677. * Called each time a new POINTERUP event occurs. Ie, for each button
  41678. * release.
  41679. */
  41680. protected onButtonUp(evt: PointerEvent): void;
  41681. /**
  41682. * Called when window becomes inactive.
  41683. */
  41684. protected onLostFocus(): void;
  41685. }
  41686. }
  41687. declare module BABYLON {
  41688. /**
  41689. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41690. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41691. */
  41692. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41693. /**
  41694. * Defines the camera the input is attached to.
  41695. */
  41696. camera: ArcRotateCamera;
  41697. /**
  41698. * Defines the list of key codes associated with the up action (increase alpha)
  41699. */
  41700. keysUp: number[];
  41701. /**
  41702. * Defines the list of key codes associated with the down action (decrease alpha)
  41703. */
  41704. keysDown: number[];
  41705. /**
  41706. * Defines the list of key codes associated with the left action (increase beta)
  41707. */
  41708. keysLeft: number[];
  41709. /**
  41710. * Defines the list of key codes associated with the right action (decrease beta)
  41711. */
  41712. keysRight: number[];
  41713. /**
  41714. * Defines the list of key codes associated with the reset action.
  41715. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41716. */
  41717. keysReset: number[];
  41718. /**
  41719. * Defines the panning sensibility of the inputs.
  41720. * (How fast is the camera panning)
  41721. */
  41722. panningSensibility: number;
  41723. /**
  41724. * Defines the zooming sensibility of the inputs.
  41725. * (How fast is the camera zooming)
  41726. */
  41727. zoomingSensibility: number;
  41728. /**
  41729. * Defines whether maintaining the alt key down switch the movement mode from
  41730. * orientation to zoom.
  41731. */
  41732. useAltToZoom: boolean;
  41733. /**
  41734. * Rotation speed of the camera
  41735. */
  41736. angularSpeed: number;
  41737. private _keys;
  41738. private _ctrlPressed;
  41739. private _altPressed;
  41740. private _onCanvasBlurObserver;
  41741. private _onKeyboardObserver;
  41742. private _engine;
  41743. private _scene;
  41744. /**
  41745. * Attach the input controls to a specific dom element to get the input from.
  41746. * @param element Defines the element the controls should be listened from
  41747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41748. */
  41749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41750. /**
  41751. * Detach the current controls from the specified dom element.
  41752. * @param element Defines the element to stop listening the inputs from
  41753. */
  41754. detachControl(element: Nullable<HTMLElement>): void;
  41755. /**
  41756. * Update the current camera state depending on the inputs that have been used this frame.
  41757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41758. */
  41759. checkInputs(): void;
  41760. /**
  41761. * Gets the class name of the current intput.
  41762. * @returns the class name
  41763. */
  41764. getClassName(): string;
  41765. /**
  41766. * Get the friendly name associated with the input class.
  41767. * @returns the input friendly name
  41768. */
  41769. getSimpleName(): string;
  41770. }
  41771. }
  41772. declare module BABYLON {
  41773. /**
  41774. * Manage the mouse wheel inputs to control an arc rotate camera.
  41775. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41776. */
  41777. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41778. /**
  41779. * Defines the camera the input is attached to.
  41780. */
  41781. camera: ArcRotateCamera;
  41782. /**
  41783. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41784. */
  41785. wheelPrecision: number;
  41786. /**
  41787. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41788. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41789. */
  41790. wheelDeltaPercentage: number;
  41791. private _wheel;
  41792. private _observer;
  41793. private computeDeltaFromMouseWheelLegacyEvent;
  41794. /**
  41795. * Attach the input controls to a specific dom element to get the input from.
  41796. * @param element Defines the element the controls should be listened from
  41797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41798. */
  41799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41800. /**
  41801. * Detach the current controls from the specified dom element.
  41802. * @param element Defines the element to stop listening the inputs from
  41803. */
  41804. detachControl(element: Nullable<HTMLElement>): void;
  41805. /**
  41806. * Gets the class name of the current intput.
  41807. * @returns the class name
  41808. */
  41809. getClassName(): string;
  41810. /**
  41811. * Get the friendly name associated with the input class.
  41812. * @returns the input friendly name
  41813. */
  41814. getSimpleName(): string;
  41815. }
  41816. }
  41817. declare module BABYLON {
  41818. /**
  41819. * Default Inputs manager for the ArcRotateCamera.
  41820. * It groups all the default supported inputs for ease of use.
  41821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41822. */
  41823. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41824. /**
  41825. * Instantiates a new ArcRotateCameraInputsManager.
  41826. * @param camera Defines the camera the inputs belong to
  41827. */
  41828. constructor(camera: ArcRotateCamera);
  41829. /**
  41830. * Add mouse wheel input support to the input manager.
  41831. * @returns the current input manager
  41832. */
  41833. addMouseWheel(): ArcRotateCameraInputsManager;
  41834. /**
  41835. * Add pointers input support to the input manager.
  41836. * @returns the current input manager
  41837. */
  41838. addPointers(): ArcRotateCameraInputsManager;
  41839. /**
  41840. * Add keyboard input support to the input manager.
  41841. * @returns the current input manager
  41842. */
  41843. addKeyboard(): ArcRotateCameraInputsManager;
  41844. }
  41845. }
  41846. declare module BABYLON {
  41847. /**
  41848. * This represents an orbital type of camera.
  41849. *
  41850. * 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.
  41851. * 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.
  41852. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41853. */
  41854. export class ArcRotateCamera extends TargetCamera {
  41855. /**
  41856. * Defines the rotation angle of the camera along the longitudinal axis.
  41857. */
  41858. alpha: number;
  41859. /**
  41860. * Defines the rotation angle of the camera along the latitudinal axis.
  41861. */
  41862. beta: number;
  41863. /**
  41864. * Defines the radius of the camera from it s target point.
  41865. */
  41866. radius: number;
  41867. protected _target: Vector3;
  41868. protected _targetHost: Nullable<AbstractMesh>;
  41869. /**
  41870. * Defines the target point of the camera.
  41871. * The camera looks towards it form the radius distance.
  41872. */
  41873. get target(): Vector3;
  41874. set target(value: Vector3);
  41875. /**
  41876. * Define the current local position of the camera in the scene
  41877. */
  41878. get position(): Vector3;
  41879. set position(newPosition: Vector3);
  41880. protected _upVector: Vector3;
  41881. protected _upToYMatrix: Matrix;
  41882. protected _YToUpMatrix: Matrix;
  41883. /**
  41884. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41885. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41886. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41887. */
  41888. set upVector(vec: Vector3);
  41889. get upVector(): Vector3;
  41890. /**
  41891. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41892. */
  41893. setMatUp(): void;
  41894. /**
  41895. * Current inertia value on the longitudinal axis.
  41896. * The bigger this number the longer it will take for the camera to stop.
  41897. */
  41898. inertialAlphaOffset: number;
  41899. /**
  41900. * Current inertia value on the latitudinal axis.
  41901. * The bigger this number the longer it will take for the camera to stop.
  41902. */
  41903. inertialBetaOffset: number;
  41904. /**
  41905. * Current inertia value on the radius axis.
  41906. * The bigger this number the longer it will take for the camera to stop.
  41907. */
  41908. inertialRadiusOffset: number;
  41909. /**
  41910. * Minimum allowed angle on the longitudinal axis.
  41911. * This can help limiting how the Camera is able to move in the scene.
  41912. */
  41913. lowerAlphaLimit: Nullable<number>;
  41914. /**
  41915. * Maximum allowed angle on the longitudinal axis.
  41916. * This can help limiting how the Camera is able to move in the scene.
  41917. */
  41918. upperAlphaLimit: Nullable<number>;
  41919. /**
  41920. * Minimum allowed angle on the latitudinal axis.
  41921. * This can help limiting how the Camera is able to move in the scene.
  41922. */
  41923. lowerBetaLimit: number;
  41924. /**
  41925. * Maximum allowed angle on the latitudinal axis.
  41926. * This can help limiting how the Camera is able to move in the scene.
  41927. */
  41928. upperBetaLimit: number;
  41929. /**
  41930. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41931. * This can help limiting how the Camera is able to move in the scene.
  41932. */
  41933. lowerRadiusLimit: Nullable<number>;
  41934. /**
  41935. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41936. * This can help limiting how the Camera is able to move in the scene.
  41937. */
  41938. upperRadiusLimit: Nullable<number>;
  41939. /**
  41940. * Defines the current inertia value used during panning of the camera along the X axis.
  41941. */
  41942. inertialPanningX: number;
  41943. /**
  41944. * Defines the current inertia value used during panning of the camera along the Y axis.
  41945. */
  41946. inertialPanningY: number;
  41947. /**
  41948. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41949. * Basically if your fingers moves away from more than this distance you will be considered
  41950. * in pinch mode.
  41951. */
  41952. pinchToPanMaxDistance: number;
  41953. /**
  41954. * Defines the maximum distance the camera can pan.
  41955. * This could help keeping the cammera always in your scene.
  41956. */
  41957. panningDistanceLimit: Nullable<number>;
  41958. /**
  41959. * Defines the target of the camera before paning.
  41960. */
  41961. panningOriginTarget: Vector3;
  41962. /**
  41963. * Defines the value of the inertia used during panning.
  41964. * 0 would mean stop inertia and one would mean no decelleration at all.
  41965. */
  41966. panningInertia: number;
  41967. /**
  41968. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41969. */
  41970. get angularSensibilityX(): number;
  41971. set angularSensibilityX(value: number);
  41972. /**
  41973. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41974. */
  41975. get angularSensibilityY(): number;
  41976. set angularSensibilityY(value: number);
  41977. /**
  41978. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41979. */
  41980. get pinchPrecision(): number;
  41981. set pinchPrecision(value: number);
  41982. /**
  41983. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41984. * It will be used instead of pinchDeltaPrecision if different from 0.
  41985. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41986. */
  41987. get pinchDeltaPercentage(): number;
  41988. set pinchDeltaPercentage(value: number);
  41989. /**
  41990. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41991. * and pinch delta percentage.
  41992. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41993. * that any object in the plane at the camera's target point will scale
  41994. * perfectly with finger motion.
  41995. */
  41996. get useNaturalPinchZoom(): boolean;
  41997. set useNaturalPinchZoom(value: boolean);
  41998. /**
  41999. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42000. */
  42001. get panningSensibility(): number;
  42002. set panningSensibility(value: number);
  42003. /**
  42004. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42005. */
  42006. get keysUp(): number[];
  42007. set keysUp(value: number[]);
  42008. /**
  42009. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42010. */
  42011. get keysDown(): number[];
  42012. set keysDown(value: number[]);
  42013. /**
  42014. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42015. */
  42016. get keysLeft(): number[];
  42017. set keysLeft(value: number[]);
  42018. /**
  42019. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42020. */
  42021. get keysRight(): number[];
  42022. set keysRight(value: number[]);
  42023. /**
  42024. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42025. */
  42026. get wheelPrecision(): number;
  42027. set wheelPrecision(value: number);
  42028. /**
  42029. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42030. * It will be used instead of pinchDeltaPrecision if different from 0.
  42031. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42032. */
  42033. get wheelDeltaPercentage(): number;
  42034. set wheelDeltaPercentage(value: number);
  42035. /**
  42036. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42037. */
  42038. zoomOnFactor: number;
  42039. /**
  42040. * Defines a screen offset for the camera position.
  42041. */
  42042. targetScreenOffset: Vector2;
  42043. /**
  42044. * Allows the camera to be completely reversed.
  42045. * If false the camera can not arrive upside down.
  42046. */
  42047. allowUpsideDown: boolean;
  42048. /**
  42049. * Define if double tap/click is used to restore the previously saved state of the camera.
  42050. */
  42051. useInputToRestoreState: boolean;
  42052. /** @hidden */
  42053. _viewMatrix: Matrix;
  42054. /** @hidden */
  42055. _useCtrlForPanning: boolean;
  42056. /** @hidden */
  42057. _panningMouseButton: number;
  42058. /**
  42059. * Defines the input associated to the camera.
  42060. */
  42061. inputs: ArcRotateCameraInputsManager;
  42062. /** @hidden */
  42063. _reset: () => void;
  42064. /**
  42065. * Defines the allowed panning axis.
  42066. */
  42067. panningAxis: Vector3;
  42068. protected _localDirection: Vector3;
  42069. protected _transformedDirection: Vector3;
  42070. private _bouncingBehavior;
  42071. /**
  42072. * Gets the bouncing behavior of the camera if it has been enabled.
  42073. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42074. */
  42075. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42076. /**
  42077. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42078. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42079. */
  42080. get useBouncingBehavior(): boolean;
  42081. set useBouncingBehavior(value: boolean);
  42082. private _framingBehavior;
  42083. /**
  42084. * Gets the framing behavior of the camera if it has been enabled.
  42085. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42086. */
  42087. get framingBehavior(): Nullable<FramingBehavior>;
  42088. /**
  42089. * Defines if the framing behavior of the camera is enabled on the camera.
  42090. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42091. */
  42092. get useFramingBehavior(): boolean;
  42093. set useFramingBehavior(value: boolean);
  42094. private _autoRotationBehavior;
  42095. /**
  42096. * Gets the auto rotation behavior of the camera if it has been enabled.
  42097. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42098. */
  42099. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42100. /**
  42101. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42102. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42103. */
  42104. get useAutoRotationBehavior(): boolean;
  42105. set useAutoRotationBehavior(value: boolean);
  42106. /**
  42107. * Observable triggered when the mesh target has been changed on the camera.
  42108. */
  42109. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42110. /**
  42111. * Event raised when the camera is colliding with a mesh.
  42112. */
  42113. onCollide: (collidedMesh: AbstractMesh) => void;
  42114. /**
  42115. * Defines whether the camera should check collision with the objects oh the scene.
  42116. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42117. */
  42118. checkCollisions: boolean;
  42119. /**
  42120. * Defines the collision radius of the camera.
  42121. * This simulates a sphere around the camera.
  42122. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42123. */
  42124. collisionRadius: Vector3;
  42125. protected _collider: Collider;
  42126. protected _previousPosition: Vector3;
  42127. protected _collisionVelocity: Vector3;
  42128. protected _newPosition: Vector3;
  42129. protected _previousAlpha: number;
  42130. protected _previousBeta: number;
  42131. protected _previousRadius: number;
  42132. protected _collisionTriggered: boolean;
  42133. protected _targetBoundingCenter: Nullable<Vector3>;
  42134. private _computationVector;
  42135. /**
  42136. * Instantiates a new ArcRotateCamera in a given scene
  42137. * @param name Defines the name of the camera
  42138. * @param alpha Defines the camera rotation along the logitudinal axis
  42139. * @param beta Defines the camera rotation along the latitudinal axis
  42140. * @param radius Defines the camera distance from its target
  42141. * @param target Defines the camera target
  42142. * @param scene Defines the scene the camera belongs to
  42143. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42144. */
  42145. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42146. /** @hidden */
  42147. _initCache(): void;
  42148. /** @hidden */
  42149. _updateCache(ignoreParentClass?: boolean): void;
  42150. protected _getTargetPosition(): Vector3;
  42151. private _storedAlpha;
  42152. private _storedBeta;
  42153. private _storedRadius;
  42154. private _storedTarget;
  42155. private _storedTargetScreenOffset;
  42156. /**
  42157. * Stores the current state of the camera (alpha, beta, radius and target)
  42158. * @returns the camera itself
  42159. */
  42160. storeState(): Camera;
  42161. /**
  42162. * @hidden
  42163. * Restored camera state. You must call storeState() first
  42164. */
  42165. _restoreStateValues(): boolean;
  42166. /** @hidden */
  42167. _isSynchronizedViewMatrix(): boolean;
  42168. /**
  42169. * Attached controls to the current camera.
  42170. * @param element Defines the element the controls should be listened from
  42171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42172. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42173. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42174. */
  42175. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42176. /**
  42177. * Detach the current controls from the camera.
  42178. * The camera will stop reacting to inputs.
  42179. * @param element Defines the element to stop listening the inputs from
  42180. */
  42181. detachControl(element: HTMLElement): void;
  42182. /** @hidden */
  42183. _checkInputs(): void;
  42184. protected _checkLimits(): void;
  42185. /**
  42186. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42187. */
  42188. rebuildAnglesAndRadius(): void;
  42189. /**
  42190. * Use a position to define the current camera related information like alpha, beta and radius
  42191. * @param position Defines the position to set the camera at
  42192. */
  42193. setPosition(position: Vector3): void;
  42194. /**
  42195. * Defines the target the camera should look at.
  42196. * This will automatically adapt alpha beta and radius to fit within the new target.
  42197. * @param target Defines the new target as a Vector or a mesh
  42198. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42199. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42200. */
  42201. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42202. /** @hidden */
  42203. _getViewMatrix(): Matrix;
  42204. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42205. /**
  42206. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42207. * @param meshes Defines the mesh to zoom on
  42208. * @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)
  42209. */
  42210. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42211. /**
  42212. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42213. * The target will be changed but the radius
  42214. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42215. * @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)
  42216. */
  42217. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42218. min: Vector3;
  42219. max: Vector3;
  42220. distance: number;
  42221. }, doNotUpdateMaxZ?: boolean): void;
  42222. /**
  42223. * @override
  42224. * Override Camera.createRigCamera
  42225. */
  42226. createRigCamera(name: string, cameraIndex: number): Camera;
  42227. /**
  42228. * @hidden
  42229. * @override
  42230. * Override Camera._updateRigCameras
  42231. */
  42232. _updateRigCameras(): void;
  42233. /**
  42234. * Destroy the camera and release the current resources hold by it.
  42235. */
  42236. dispose(): void;
  42237. /**
  42238. * Gets the current object class name.
  42239. * @return the class name
  42240. */
  42241. getClassName(): string;
  42242. }
  42243. }
  42244. declare module BABYLON {
  42245. /**
  42246. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42247. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42248. */
  42249. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42250. /**
  42251. * Gets the name of the behavior.
  42252. */
  42253. get name(): string;
  42254. private _zoomStopsAnimation;
  42255. private _idleRotationSpeed;
  42256. private _idleRotationWaitTime;
  42257. private _idleRotationSpinupTime;
  42258. /**
  42259. * Sets the flag that indicates if user zooming should stop animation.
  42260. */
  42261. set zoomStopsAnimation(flag: boolean);
  42262. /**
  42263. * Gets the flag that indicates if user zooming should stop animation.
  42264. */
  42265. get zoomStopsAnimation(): boolean;
  42266. /**
  42267. * Sets the default speed at which the camera rotates around the model.
  42268. */
  42269. set idleRotationSpeed(speed: number);
  42270. /**
  42271. * Gets the default speed at which the camera rotates around the model.
  42272. */
  42273. get idleRotationSpeed(): number;
  42274. /**
  42275. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42276. */
  42277. set idleRotationWaitTime(time: number);
  42278. /**
  42279. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42280. */
  42281. get idleRotationWaitTime(): number;
  42282. /**
  42283. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42284. */
  42285. set idleRotationSpinupTime(time: number);
  42286. /**
  42287. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42288. */
  42289. get idleRotationSpinupTime(): number;
  42290. /**
  42291. * Gets a value indicating if the camera is currently rotating because of this behavior
  42292. */
  42293. get rotationInProgress(): boolean;
  42294. private _onPrePointerObservableObserver;
  42295. private _onAfterCheckInputsObserver;
  42296. private _attachedCamera;
  42297. private _isPointerDown;
  42298. private _lastFrameTime;
  42299. private _lastInteractionTime;
  42300. private _cameraRotationSpeed;
  42301. /**
  42302. * Initializes the behavior.
  42303. */
  42304. init(): void;
  42305. /**
  42306. * Attaches the behavior to its arc rotate camera.
  42307. * @param camera Defines the camera to attach the behavior to
  42308. */
  42309. attach(camera: ArcRotateCamera): void;
  42310. /**
  42311. * Detaches the behavior from its current arc rotate camera.
  42312. */
  42313. detach(): void;
  42314. /**
  42315. * Returns true if user is scrolling.
  42316. * @return true if user is scrolling.
  42317. */
  42318. private _userIsZooming;
  42319. private _lastFrameRadius;
  42320. private _shouldAnimationStopForInteraction;
  42321. /**
  42322. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42323. */
  42324. private _applyUserInteraction;
  42325. private _userIsMoving;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42331. */
  42332. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42333. private ui;
  42334. /**
  42335. * The name of the behavior
  42336. */
  42337. name: string;
  42338. /**
  42339. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42340. */
  42341. distanceAwayFromFace: number;
  42342. /**
  42343. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42344. */
  42345. distanceAwayFromBottomOfFace: number;
  42346. private _faceVectors;
  42347. private _target;
  42348. private _scene;
  42349. private _onRenderObserver;
  42350. private _tmpMatrix;
  42351. private _tmpVector;
  42352. /**
  42353. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42354. * @param ui The transform node that should be attched to the mesh
  42355. */
  42356. constructor(ui: TransformNode);
  42357. /**
  42358. * Initializes the behavior
  42359. */
  42360. init(): void;
  42361. private _closestFace;
  42362. private _zeroVector;
  42363. private _lookAtTmpMatrix;
  42364. private _lookAtToRef;
  42365. /**
  42366. * Attaches the AttachToBoxBehavior to the passed in mesh
  42367. * @param target The mesh that the specified node will be attached to
  42368. */
  42369. attach(target: Mesh): void;
  42370. /**
  42371. * Detaches the behavior from the mesh
  42372. */
  42373. detach(): void;
  42374. }
  42375. }
  42376. declare module BABYLON {
  42377. /**
  42378. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42379. */
  42380. export class FadeInOutBehavior implements Behavior<Mesh> {
  42381. /**
  42382. * Time in milliseconds to delay before fading in (Default: 0)
  42383. */
  42384. delay: number;
  42385. /**
  42386. * Time in milliseconds for the mesh to fade in (Default: 300)
  42387. */
  42388. fadeInTime: number;
  42389. private _millisecondsPerFrame;
  42390. private _hovered;
  42391. private _hoverValue;
  42392. private _ownerNode;
  42393. /**
  42394. * Instatiates the FadeInOutBehavior
  42395. */
  42396. constructor();
  42397. /**
  42398. * The name of the behavior
  42399. */
  42400. get name(): string;
  42401. /**
  42402. * Initializes the behavior
  42403. */
  42404. init(): void;
  42405. /**
  42406. * Attaches the fade behavior on the passed in mesh
  42407. * @param ownerNode The mesh that will be faded in/out once attached
  42408. */
  42409. attach(ownerNode: Mesh): void;
  42410. /**
  42411. * Detaches the behavior from the mesh
  42412. */
  42413. detach(): void;
  42414. /**
  42415. * Triggers the mesh to begin fading in or out
  42416. * @param value if the object should fade in or out (true to fade in)
  42417. */
  42418. fadeIn(value: boolean): void;
  42419. private _update;
  42420. private _setAllVisibility;
  42421. }
  42422. }
  42423. declare module BABYLON {
  42424. /**
  42425. * Class containing a set of static utilities functions for managing Pivots
  42426. * @hidden
  42427. */
  42428. export class PivotTools {
  42429. private static _PivotCached;
  42430. private static _OldPivotPoint;
  42431. private static _PivotTranslation;
  42432. private static _PivotTmpVector;
  42433. /** @hidden */
  42434. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42435. /** @hidden */
  42436. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42437. }
  42438. }
  42439. declare module BABYLON {
  42440. /**
  42441. * Class containing static functions to help procedurally build meshes
  42442. */
  42443. export class PlaneBuilder {
  42444. /**
  42445. * Creates a plane mesh
  42446. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42447. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42448. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42450. * * 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
  42451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42452. * @param name defines the name of the mesh
  42453. * @param options defines the options used to create the mesh
  42454. * @param scene defines the hosting scene
  42455. * @returns the plane mesh
  42456. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42457. */
  42458. static CreatePlane(name: string, options: {
  42459. size?: number;
  42460. width?: number;
  42461. height?: number;
  42462. sideOrientation?: number;
  42463. frontUVs?: Vector4;
  42464. backUVs?: Vector4;
  42465. updatable?: boolean;
  42466. sourcePlane?: Plane;
  42467. }, scene?: Nullable<Scene>): Mesh;
  42468. }
  42469. }
  42470. declare module BABYLON {
  42471. /**
  42472. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42473. */
  42474. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42475. private static _AnyMouseID;
  42476. /**
  42477. * Abstract mesh the behavior is set on
  42478. */
  42479. attachedNode: AbstractMesh;
  42480. private _dragPlane;
  42481. private _scene;
  42482. private _pointerObserver;
  42483. private _beforeRenderObserver;
  42484. private static _planeScene;
  42485. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42486. /**
  42487. * 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)
  42488. */
  42489. maxDragAngle: number;
  42490. /**
  42491. * @hidden
  42492. */
  42493. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42494. /**
  42495. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42496. */
  42497. currentDraggingPointerID: number;
  42498. /**
  42499. * The last position where the pointer hit the drag plane in world space
  42500. */
  42501. lastDragPosition: Vector3;
  42502. /**
  42503. * If the behavior is currently in a dragging state
  42504. */
  42505. dragging: boolean;
  42506. /**
  42507. * 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)
  42508. */
  42509. dragDeltaRatio: number;
  42510. /**
  42511. * If the drag plane orientation should be updated during the dragging (Default: true)
  42512. */
  42513. updateDragPlane: boolean;
  42514. private _debugMode;
  42515. private _moving;
  42516. /**
  42517. * Fires each time the attached mesh is dragged with the pointer
  42518. * * delta between last drag position and current drag position in world space
  42519. * * dragDistance along the drag axis
  42520. * * dragPlaneNormal normal of the current drag plane used during the drag
  42521. * * dragPlanePoint in world space where the drag intersects the drag plane
  42522. */
  42523. onDragObservable: Observable<{
  42524. delta: Vector3;
  42525. dragPlanePoint: Vector3;
  42526. dragPlaneNormal: Vector3;
  42527. dragDistance: number;
  42528. pointerId: number;
  42529. }>;
  42530. /**
  42531. * Fires each time a drag begins (eg. mouse down on mesh)
  42532. */
  42533. onDragStartObservable: Observable<{
  42534. dragPlanePoint: Vector3;
  42535. pointerId: number;
  42536. }>;
  42537. /**
  42538. * Fires each time a drag ends (eg. mouse release after drag)
  42539. */
  42540. onDragEndObservable: Observable<{
  42541. dragPlanePoint: Vector3;
  42542. pointerId: number;
  42543. }>;
  42544. /**
  42545. * If the attached mesh should be moved when dragged
  42546. */
  42547. moveAttached: boolean;
  42548. /**
  42549. * If the drag behavior will react to drag events (Default: true)
  42550. */
  42551. enabled: boolean;
  42552. /**
  42553. * If pointer events should start and release the drag (Default: true)
  42554. */
  42555. startAndReleaseDragOnPointerEvents: boolean;
  42556. /**
  42557. * If camera controls should be detached during the drag
  42558. */
  42559. detachCameraControls: boolean;
  42560. /**
  42561. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42562. */
  42563. useObjectOrientationForDragging: boolean;
  42564. private _options;
  42565. /**
  42566. * Gets the options used by the behavior
  42567. */
  42568. get options(): {
  42569. dragAxis?: Vector3;
  42570. dragPlaneNormal?: Vector3;
  42571. };
  42572. /**
  42573. * Sets the options used by the behavior
  42574. */
  42575. set options(options: {
  42576. dragAxis?: Vector3;
  42577. dragPlaneNormal?: Vector3;
  42578. });
  42579. /**
  42580. * Creates a pointer drag behavior that can be attached to a mesh
  42581. * @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)
  42582. */
  42583. constructor(options?: {
  42584. dragAxis?: Vector3;
  42585. dragPlaneNormal?: Vector3;
  42586. });
  42587. /**
  42588. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42589. */
  42590. validateDrag: (targetPosition: Vector3) => boolean;
  42591. /**
  42592. * The name of the behavior
  42593. */
  42594. get name(): string;
  42595. /**
  42596. * Initializes the behavior
  42597. */
  42598. init(): void;
  42599. private _tmpVector;
  42600. private _alternatePickedPoint;
  42601. private _worldDragAxis;
  42602. private _targetPosition;
  42603. private _attachedElement;
  42604. /**
  42605. * Attaches the drag behavior the passed in mesh
  42606. * @param ownerNode The mesh that will be dragged around once attached
  42607. * @param predicate Predicate to use for pick filtering
  42608. */
  42609. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42610. /**
  42611. * Force relase the drag action by code.
  42612. */
  42613. releaseDrag(): void;
  42614. private _startDragRay;
  42615. private _lastPointerRay;
  42616. /**
  42617. * Simulates the start of a pointer drag event on the behavior
  42618. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42619. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42620. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42621. */
  42622. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42623. private _startDrag;
  42624. private _dragDelta;
  42625. private _moveDrag;
  42626. private _pickWithRayOnDragPlane;
  42627. private _pointA;
  42628. private _pointB;
  42629. private _pointC;
  42630. private _lineA;
  42631. private _lineB;
  42632. private _localAxis;
  42633. private _lookAt;
  42634. private _updateDragPlanePosition;
  42635. /**
  42636. * Detaches the behavior from the mesh
  42637. */
  42638. detach(): void;
  42639. }
  42640. }
  42641. declare module BABYLON {
  42642. /**
  42643. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42644. */
  42645. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42646. private _dragBehaviorA;
  42647. private _dragBehaviorB;
  42648. private _startDistance;
  42649. private _initialScale;
  42650. private _targetScale;
  42651. private _ownerNode;
  42652. private _sceneRenderObserver;
  42653. /**
  42654. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42655. */
  42656. constructor();
  42657. /**
  42658. * The name of the behavior
  42659. */
  42660. get name(): string;
  42661. /**
  42662. * Initializes the behavior
  42663. */
  42664. init(): void;
  42665. private _getCurrentDistance;
  42666. /**
  42667. * Attaches the scale behavior the passed in mesh
  42668. * @param ownerNode The mesh that will be scaled around once attached
  42669. */
  42670. attach(ownerNode: Mesh): void;
  42671. /**
  42672. * Detaches the behavior from the mesh
  42673. */
  42674. detach(): void;
  42675. }
  42676. }
  42677. declare module BABYLON {
  42678. /**
  42679. * 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
  42680. */
  42681. export class SixDofDragBehavior implements Behavior<Mesh> {
  42682. private static _virtualScene;
  42683. private _ownerNode;
  42684. private _sceneRenderObserver;
  42685. private _scene;
  42686. private _targetPosition;
  42687. private _virtualOriginMesh;
  42688. private _virtualDragMesh;
  42689. private _pointerObserver;
  42690. private _moving;
  42691. private _startingOrientation;
  42692. private _attachedElement;
  42693. /**
  42694. * 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)
  42695. */
  42696. private zDragFactor;
  42697. /**
  42698. * If the object should rotate to face the drag origin
  42699. */
  42700. rotateDraggedObject: boolean;
  42701. /**
  42702. * If the behavior is currently in a dragging state
  42703. */
  42704. dragging: boolean;
  42705. /**
  42706. * 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)
  42707. */
  42708. dragDeltaRatio: number;
  42709. /**
  42710. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42711. */
  42712. currentDraggingPointerID: number;
  42713. /**
  42714. * If camera controls should be detached during the drag
  42715. */
  42716. detachCameraControls: boolean;
  42717. /**
  42718. * Fires each time a drag starts
  42719. */
  42720. onDragStartObservable: Observable<{}>;
  42721. /**
  42722. * Fires each time a drag ends (eg. mouse release after drag)
  42723. */
  42724. onDragEndObservable: Observable<{}>;
  42725. /**
  42726. * 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
  42727. */
  42728. constructor();
  42729. /**
  42730. * The name of the behavior
  42731. */
  42732. get name(): string;
  42733. /**
  42734. * Initializes the behavior
  42735. */
  42736. init(): void;
  42737. /**
  42738. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42739. */
  42740. private get _pointerCamera();
  42741. /**
  42742. * Attaches the scale behavior the passed in mesh
  42743. * @param ownerNode The mesh that will be scaled around once attached
  42744. */
  42745. attach(ownerNode: Mesh): void;
  42746. /**
  42747. * Detaches the behavior from the mesh
  42748. */
  42749. detach(): void;
  42750. }
  42751. }
  42752. declare module BABYLON {
  42753. /**
  42754. * Class used to apply inverse kinematics to bones
  42755. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42756. */
  42757. export class BoneIKController {
  42758. private static _tmpVecs;
  42759. private static _tmpQuat;
  42760. private static _tmpMats;
  42761. /**
  42762. * Gets or sets the target mesh
  42763. */
  42764. targetMesh: AbstractMesh;
  42765. /** Gets or sets the mesh used as pole */
  42766. poleTargetMesh: AbstractMesh;
  42767. /**
  42768. * Gets or sets the bone used as pole
  42769. */
  42770. poleTargetBone: Nullable<Bone>;
  42771. /**
  42772. * Gets or sets the target position
  42773. */
  42774. targetPosition: Vector3;
  42775. /**
  42776. * Gets or sets the pole target position
  42777. */
  42778. poleTargetPosition: Vector3;
  42779. /**
  42780. * Gets or sets the pole target local offset
  42781. */
  42782. poleTargetLocalOffset: Vector3;
  42783. /**
  42784. * Gets or sets the pole angle
  42785. */
  42786. poleAngle: number;
  42787. /**
  42788. * Gets or sets the mesh associated with the controller
  42789. */
  42790. mesh: AbstractMesh;
  42791. /**
  42792. * 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)
  42793. */
  42794. slerpAmount: number;
  42795. private _bone1Quat;
  42796. private _bone1Mat;
  42797. private _bone2Ang;
  42798. private _bone1;
  42799. private _bone2;
  42800. private _bone1Length;
  42801. private _bone2Length;
  42802. private _maxAngle;
  42803. private _maxReach;
  42804. private _rightHandedSystem;
  42805. private _bendAxis;
  42806. private _slerping;
  42807. private _adjustRoll;
  42808. /**
  42809. * Gets or sets maximum allowed angle
  42810. */
  42811. get maxAngle(): number;
  42812. set maxAngle(value: number);
  42813. /**
  42814. * Creates a new BoneIKController
  42815. * @param mesh defines the mesh to control
  42816. * @param bone defines the bone to control
  42817. * @param options defines options to set up the controller
  42818. */
  42819. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42820. targetMesh?: AbstractMesh;
  42821. poleTargetMesh?: AbstractMesh;
  42822. poleTargetBone?: Bone;
  42823. poleTargetLocalOffset?: Vector3;
  42824. poleAngle?: number;
  42825. bendAxis?: Vector3;
  42826. maxAngle?: number;
  42827. slerpAmount?: number;
  42828. });
  42829. private _setMaxAngle;
  42830. /**
  42831. * Force the controller to update the bones
  42832. */
  42833. update(): void;
  42834. }
  42835. }
  42836. declare module BABYLON {
  42837. /**
  42838. * Class used to make a bone look toward a point in space
  42839. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42840. */
  42841. export class BoneLookController {
  42842. private static _tmpVecs;
  42843. private static _tmpQuat;
  42844. private static _tmpMats;
  42845. /**
  42846. * The target Vector3 that the bone will look at
  42847. */
  42848. target: Vector3;
  42849. /**
  42850. * The mesh that the bone is attached to
  42851. */
  42852. mesh: AbstractMesh;
  42853. /**
  42854. * The bone that will be looking to the target
  42855. */
  42856. bone: Bone;
  42857. /**
  42858. * The up axis of the coordinate system that is used when the bone is rotated
  42859. */
  42860. upAxis: Vector3;
  42861. /**
  42862. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42863. */
  42864. upAxisSpace: Space;
  42865. /**
  42866. * Used to make an adjustment to the yaw of the bone
  42867. */
  42868. adjustYaw: number;
  42869. /**
  42870. * Used to make an adjustment to the pitch of the bone
  42871. */
  42872. adjustPitch: number;
  42873. /**
  42874. * Used to make an adjustment to the roll of the bone
  42875. */
  42876. adjustRoll: number;
  42877. /**
  42878. * 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)
  42879. */
  42880. slerpAmount: number;
  42881. private _minYaw;
  42882. private _maxYaw;
  42883. private _minPitch;
  42884. private _maxPitch;
  42885. private _minYawSin;
  42886. private _minYawCos;
  42887. private _maxYawSin;
  42888. private _maxYawCos;
  42889. private _midYawConstraint;
  42890. private _minPitchTan;
  42891. private _maxPitchTan;
  42892. private _boneQuat;
  42893. private _slerping;
  42894. private _transformYawPitch;
  42895. private _transformYawPitchInv;
  42896. private _firstFrameSkipped;
  42897. private _yawRange;
  42898. private _fowardAxis;
  42899. /**
  42900. * Gets or sets the minimum yaw angle that the bone can look to
  42901. */
  42902. get minYaw(): number;
  42903. set minYaw(value: number);
  42904. /**
  42905. * Gets or sets the maximum yaw angle that the bone can look to
  42906. */
  42907. get maxYaw(): number;
  42908. set maxYaw(value: number);
  42909. /**
  42910. * Gets or sets the minimum pitch angle that the bone can look to
  42911. */
  42912. get minPitch(): number;
  42913. set minPitch(value: number);
  42914. /**
  42915. * Gets or sets the maximum pitch angle that the bone can look to
  42916. */
  42917. get maxPitch(): number;
  42918. set maxPitch(value: number);
  42919. /**
  42920. * Create a BoneLookController
  42921. * @param mesh the mesh that the bone belongs to
  42922. * @param bone the bone that will be looking to the target
  42923. * @param target the target Vector3 to look at
  42924. * @param options optional settings:
  42925. * * maxYaw: the maximum angle the bone will yaw to
  42926. * * minYaw: the minimum angle the bone will yaw to
  42927. * * maxPitch: the maximum angle the bone will pitch to
  42928. * * minPitch: the minimum angle the bone will yaw to
  42929. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42930. * * upAxis: the up axis of the coordinate system
  42931. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42932. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42933. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42934. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42935. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42936. * * adjustRoll: used to make an adjustment to the roll of the bone
  42937. **/
  42938. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42939. maxYaw?: number;
  42940. minYaw?: number;
  42941. maxPitch?: number;
  42942. minPitch?: number;
  42943. slerpAmount?: number;
  42944. upAxis?: Vector3;
  42945. upAxisSpace?: Space;
  42946. yawAxis?: Vector3;
  42947. pitchAxis?: Vector3;
  42948. adjustYaw?: number;
  42949. adjustPitch?: number;
  42950. adjustRoll?: number;
  42951. });
  42952. /**
  42953. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42954. */
  42955. update(): void;
  42956. private _getAngleDiff;
  42957. private _getAngleBetween;
  42958. private _isAngleBetween;
  42959. }
  42960. }
  42961. declare module BABYLON {
  42962. /**
  42963. * Manage the gamepad inputs to control an arc rotate camera.
  42964. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42965. */
  42966. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42967. /**
  42968. * Defines the camera the input is attached to.
  42969. */
  42970. camera: ArcRotateCamera;
  42971. /**
  42972. * Defines the gamepad the input is gathering event from.
  42973. */
  42974. gamepad: Nullable<Gamepad>;
  42975. /**
  42976. * Defines the gamepad rotation sensiblity.
  42977. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42978. */
  42979. gamepadRotationSensibility: number;
  42980. /**
  42981. * Defines the gamepad move sensiblity.
  42982. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42983. */
  42984. gamepadMoveSensibility: number;
  42985. private _yAxisScale;
  42986. /**
  42987. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42988. */
  42989. get invertYAxis(): boolean;
  42990. set invertYAxis(value: boolean);
  42991. private _onGamepadConnectedObserver;
  42992. private _onGamepadDisconnectedObserver;
  42993. /**
  42994. * Attach the input controls to a specific dom element to get the input from.
  42995. * @param element Defines the element the controls should be listened from
  42996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42997. */
  42998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42999. /**
  43000. * Detach the current controls from the specified dom element.
  43001. * @param element Defines the element to stop listening the inputs from
  43002. */
  43003. detachControl(element: Nullable<HTMLElement>): void;
  43004. /**
  43005. * Update the current camera state depending on the inputs that have been used this frame.
  43006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43007. */
  43008. checkInputs(): void;
  43009. /**
  43010. * Gets the class name of the current intput.
  43011. * @returns the class name
  43012. */
  43013. getClassName(): string;
  43014. /**
  43015. * Get the friendly name associated with the input class.
  43016. * @returns the input friendly name
  43017. */
  43018. getSimpleName(): string;
  43019. }
  43020. }
  43021. declare module BABYLON {
  43022. interface ArcRotateCameraInputsManager {
  43023. /**
  43024. * Add orientation input support to the input manager.
  43025. * @returns the current input manager
  43026. */
  43027. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43028. }
  43029. /**
  43030. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43031. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43032. */
  43033. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43034. /**
  43035. * Defines the camera the input is attached to.
  43036. */
  43037. camera: ArcRotateCamera;
  43038. /**
  43039. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43040. */
  43041. alphaCorrection: number;
  43042. /**
  43043. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43044. */
  43045. gammaCorrection: number;
  43046. private _alpha;
  43047. private _gamma;
  43048. private _dirty;
  43049. private _deviceOrientationHandler;
  43050. /**
  43051. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43052. */
  43053. constructor();
  43054. /**
  43055. * Attach the input controls to a specific dom element to get the input from.
  43056. * @param element Defines the element the controls should be listened from
  43057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43058. */
  43059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43060. /** @hidden */
  43061. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43062. /**
  43063. * Update the current camera state depending on the inputs that have been used this frame.
  43064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43065. */
  43066. checkInputs(): void;
  43067. /**
  43068. * Detach the current controls from the specified dom element.
  43069. * @param element Defines the element to stop listening the inputs from
  43070. */
  43071. detachControl(element: Nullable<HTMLElement>): void;
  43072. /**
  43073. * Gets the class name of the current intput.
  43074. * @returns the class name
  43075. */
  43076. getClassName(): string;
  43077. /**
  43078. * Get the friendly name associated with the input class.
  43079. * @returns the input friendly name
  43080. */
  43081. getSimpleName(): string;
  43082. }
  43083. }
  43084. declare module BABYLON {
  43085. /**
  43086. * Listen to mouse events to control the camera.
  43087. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43088. */
  43089. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43090. /**
  43091. * Defines the camera the input is attached to.
  43092. */
  43093. camera: FlyCamera;
  43094. /**
  43095. * Defines if touch is enabled. (Default is true.)
  43096. */
  43097. touchEnabled: boolean;
  43098. /**
  43099. * Defines the buttons associated with the input to handle camera rotation.
  43100. */
  43101. buttons: number[];
  43102. /**
  43103. * Assign buttons for Yaw control.
  43104. */
  43105. buttonsYaw: number[];
  43106. /**
  43107. * Assign buttons for Pitch control.
  43108. */
  43109. buttonsPitch: number[];
  43110. /**
  43111. * Assign buttons for Roll control.
  43112. */
  43113. buttonsRoll: number[];
  43114. /**
  43115. * Detect if any button is being pressed while mouse is moved.
  43116. * -1 = Mouse locked.
  43117. * 0 = Left button.
  43118. * 1 = Middle Button.
  43119. * 2 = Right Button.
  43120. */
  43121. activeButton: number;
  43122. /**
  43123. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43124. * Higher values reduce its sensitivity.
  43125. */
  43126. angularSensibility: number;
  43127. private _mousemoveCallback;
  43128. private _observer;
  43129. private _rollObserver;
  43130. private previousPosition;
  43131. private noPreventDefault;
  43132. private element;
  43133. /**
  43134. * Listen to mouse events to control the camera.
  43135. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43136. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43137. */
  43138. constructor(touchEnabled?: boolean);
  43139. /**
  43140. * Attach the mouse control to the HTML DOM element.
  43141. * @param element Defines the element that listens to the input events.
  43142. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43143. */
  43144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43145. /**
  43146. * Detach the current controls from the specified dom element.
  43147. * @param element Defines the element to stop listening the inputs from
  43148. */
  43149. detachControl(element: Nullable<HTMLElement>): void;
  43150. /**
  43151. * Gets the class name of the current input.
  43152. * @returns the class name.
  43153. */
  43154. getClassName(): string;
  43155. /**
  43156. * Get the friendly name associated with the input class.
  43157. * @returns the input's friendly name.
  43158. */
  43159. getSimpleName(): string;
  43160. private _pointerInput;
  43161. private _onMouseMove;
  43162. /**
  43163. * Rotate camera by mouse offset.
  43164. */
  43165. private rotateCamera;
  43166. }
  43167. }
  43168. declare module BABYLON {
  43169. /**
  43170. * Default Inputs manager for the FlyCamera.
  43171. * It groups all the default supported inputs for ease of use.
  43172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43173. */
  43174. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43175. /**
  43176. * Instantiates a new FlyCameraInputsManager.
  43177. * @param camera Defines the camera the inputs belong to.
  43178. */
  43179. constructor(camera: FlyCamera);
  43180. /**
  43181. * Add keyboard input support to the input manager.
  43182. * @returns the new FlyCameraKeyboardMoveInput().
  43183. */
  43184. addKeyboard(): FlyCameraInputsManager;
  43185. /**
  43186. * Add mouse input support to the input manager.
  43187. * @param touchEnabled Enable touch screen support.
  43188. * @returns the new FlyCameraMouseInput().
  43189. */
  43190. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43191. }
  43192. }
  43193. declare module BABYLON {
  43194. /**
  43195. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43196. * such as in a 3D Space Shooter or a Flight Simulator.
  43197. */
  43198. export class FlyCamera extends TargetCamera {
  43199. /**
  43200. * Define the collision ellipsoid of the camera.
  43201. * This is helpful for simulating a camera body, like a player's body.
  43202. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43203. */
  43204. ellipsoid: Vector3;
  43205. /**
  43206. * Define an offset for the position of the ellipsoid around the camera.
  43207. * This can be helpful if the camera is attached away from the player's body center,
  43208. * such as at its head.
  43209. */
  43210. ellipsoidOffset: Vector3;
  43211. /**
  43212. * Enable or disable collisions of the camera with the rest of the scene objects.
  43213. */
  43214. checkCollisions: boolean;
  43215. /**
  43216. * Enable or disable gravity on the camera.
  43217. */
  43218. applyGravity: boolean;
  43219. /**
  43220. * Define the current direction the camera is moving to.
  43221. */
  43222. cameraDirection: Vector3;
  43223. /**
  43224. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43225. * This overrides and empties cameraRotation.
  43226. */
  43227. rotationQuaternion: Quaternion;
  43228. /**
  43229. * Track Roll to maintain the wanted Rolling when looking around.
  43230. */
  43231. _trackRoll: number;
  43232. /**
  43233. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43234. */
  43235. rollCorrect: number;
  43236. /**
  43237. * Mimic a banked turn, Rolling the camera when Yawing.
  43238. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43239. */
  43240. bankedTurn: boolean;
  43241. /**
  43242. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43243. */
  43244. bankedTurnLimit: number;
  43245. /**
  43246. * Value of 0 disables the banked Roll.
  43247. * Value of 1 is equal to the Yaw angle in radians.
  43248. */
  43249. bankedTurnMultiplier: number;
  43250. /**
  43251. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43252. */
  43253. inputs: FlyCameraInputsManager;
  43254. /**
  43255. * Gets the input sensibility for mouse input.
  43256. * Higher values reduce sensitivity.
  43257. */
  43258. get angularSensibility(): number;
  43259. /**
  43260. * Sets the input sensibility for a mouse input.
  43261. * Higher values reduce sensitivity.
  43262. */
  43263. set angularSensibility(value: number);
  43264. /**
  43265. * Get the keys for camera movement forward.
  43266. */
  43267. get keysForward(): number[];
  43268. /**
  43269. * Set the keys for camera movement forward.
  43270. */
  43271. set keysForward(value: number[]);
  43272. /**
  43273. * Get the keys for camera movement backward.
  43274. */
  43275. get keysBackward(): number[];
  43276. set keysBackward(value: number[]);
  43277. /**
  43278. * Get the keys for camera movement up.
  43279. */
  43280. get keysUp(): number[];
  43281. /**
  43282. * Set the keys for camera movement up.
  43283. */
  43284. set keysUp(value: number[]);
  43285. /**
  43286. * Get the keys for camera movement down.
  43287. */
  43288. get keysDown(): number[];
  43289. /**
  43290. * Set the keys for camera movement down.
  43291. */
  43292. set keysDown(value: number[]);
  43293. /**
  43294. * Get the keys for camera movement left.
  43295. */
  43296. get keysLeft(): number[];
  43297. /**
  43298. * Set the keys for camera movement left.
  43299. */
  43300. set keysLeft(value: number[]);
  43301. /**
  43302. * Set the keys for camera movement right.
  43303. */
  43304. get keysRight(): number[];
  43305. /**
  43306. * Set the keys for camera movement right.
  43307. */
  43308. set keysRight(value: number[]);
  43309. /**
  43310. * Event raised when the camera collides with a mesh in the scene.
  43311. */
  43312. onCollide: (collidedMesh: AbstractMesh) => void;
  43313. private _collider;
  43314. private _needMoveForGravity;
  43315. private _oldPosition;
  43316. private _diffPosition;
  43317. private _newPosition;
  43318. /** @hidden */
  43319. _localDirection: Vector3;
  43320. /** @hidden */
  43321. _transformedDirection: Vector3;
  43322. /**
  43323. * Instantiates a FlyCamera.
  43324. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43325. * such as in a 3D Space Shooter or a Flight Simulator.
  43326. * @param name Define the name of the camera in the scene.
  43327. * @param position Define the starting position of the camera in the scene.
  43328. * @param scene Define the scene the camera belongs to.
  43329. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43330. */
  43331. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43332. /**
  43333. * Attach a control to the HTML DOM element.
  43334. * @param element Defines the element that listens to the input events.
  43335. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43336. */
  43337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43338. /**
  43339. * Detach a control from the HTML DOM element.
  43340. * The camera will stop reacting to that input.
  43341. * @param element Defines the element that listens to the input events.
  43342. */
  43343. detachControl(element: HTMLElement): void;
  43344. private _collisionMask;
  43345. /**
  43346. * Get the mask that the camera ignores in collision events.
  43347. */
  43348. get collisionMask(): number;
  43349. /**
  43350. * Set the mask that the camera ignores in collision events.
  43351. */
  43352. set collisionMask(mask: number);
  43353. /** @hidden */
  43354. _collideWithWorld(displacement: Vector3): void;
  43355. /** @hidden */
  43356. private _onCollisionPositionChange;
  43357. /** @hidden */
  43358. _checkInputs(): void;
  43359. /** @hidden */
  43360. _decideIfNeedsToMove(): boolean;
  43361. /** @hidden */
  43362. _updatePosition(): void;
  43363. /**
  43364. * Restore the Roll to its target value at the rate specified.
  43365. * @param rate - Higher means slower restoring.
  43366. * @hidden
  43367. */
  43368. restoreRoll(rate: number): void;
  43369. /**
  43370. * Destroy the camera and release the current resources held by it.
  43371. */
  43372. dispose(): void;
  43373. /**
  43374. * Get the current object class name.
  43375. * @returns the class name.
  43376. */
  43377. getClassName(): string;
  43378. }
  43379. }
  43380. declare module BABYLON {
  43381. /**
  43382. * Listen to keyboard events to control the camera.
  43383. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43384. */
  43385. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43386. /**
  43387. * Defines the camera the input is attached to.
  43388. */
  43389. camera: FlyCamera;
  43390. /**
  43391. * The list of keyboard keys used to control the forward move of the camera.
  43392. */
  43393. keysForward: number[];
  43394. /**
  43395. * The list of keyboard keys used to control the backward move of the camera.
  43396. */
  43397. keysBackward: number[];
  43398. /**
  43399. * The list of keyboard keys used to control the forward move of the camera.
  43400. */
  43401. keysUp: number[];
  43402. /**
  43403. * The list of keyboard keys used to control the backward move of the camera.
  43404. */
  43405. keysDown: number[];
  43406. /**
  43407. * The list of keyboard keys used to control the right strafe move of the camera.
  43408. */
  43409. keysRight: number[];
  43410. /**
  43411. * The list of keyboard keys used to control the left strafe move of the camera.
  43412. */
  43413. keysLeft: number[];
  43414. private _keys;
  43415. private _onCanvasBlurObserver;
  43416. private _onKeyboardObserver;
  43417. private _engine;
  43418. private _scene;
  43419. /**
  43420. * Attach the input controls to a specific dom element to get the input from.
  43421. * @param element Defines the element the controls should be listened from
  43422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43423. */
  43424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43425. /**
  43426. * Detach the current controls from the specified dom element.
  43427. * @param element Defines the element to stop listening the inputs from
  43428. */
  43429. detachControl(element: Nullable<HTMLElement>): void;
  43430. /**
  43431. * Gets the class name of the current intput.
  43432. * @returns the class name
  43433. */
  43434. getClassName(): string;
  43435. /** @hidden */
  43436. _onLostFocus(e: FocusEvent): void;
  43437. /**
  43438. * Get the friendly name associated with the input class.
  43439. * @returns the input friendly name
  43440. */
  43441. getSimpleName(): string;
  43442. /**
  43443. * Update the current camera state depending on the inputs that have been used this frame.
  43444. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43445. */
  43446. checkInputs(): void;
  43447. }
  43448. }
  43449. declare module BABYLON {
  43450. /**
  43451. * Manage the mouse wheel inputs to control a follow camera.
  43452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43453. */
  43454. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43455. /**
  43456. * Defines the camera the input is attached to.
  43457. */
  43458. camera: FollowCamera;
  43459. /**
  43460. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43461. */
  43462. axisControlRadius: boolean;
  43463. /**
  43464. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43465. */
  43466. axisControlHeight: boolean;
  43467. /**
  43468. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43469. */
  43470. axisControlRotation: boolean;
  43471. /**
  43472. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43473. * relation to mouseWheel events.
  43474. */
  43475. wheelPrecision: number;
  43476. /**
  43477. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43478. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43479. */
  43480. wheelDeltaPercentage: number;
  43481. private _wheel;
  43482. private _observer;
  43483. /**
  43484. * Attach the input controls to a specific dom element to get the input from.
  43485. * @param element Defines the element the controls should be listened from
  43486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43487. */
  43488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43489. /**
  43490. * Detach the current controls from the specified dom element.
  43491. * @param element Defines the element to stop listening the inputs from
  43492. */
  43493. detachControl(element: Nullable<HTMLElement>): void;
  43494. /**
  43495. * Gets the class name of the current intput.
  43496. * @returns the class name
  43497. */
  43498. getClassName(): string;
  43499. /**
  43500. * Get the friendly name associated with the input class.
  43501. * @returns the input friendly name
  43502. */
  43503. getSimpleName(): string;
  43504. }
  43505. }
  43506. declare module BABYLON {
  43507. /**
  43508. * Manage the pointers inputs to control an follow camera.
  43509. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43510. */
  43511. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43512. /**
  43513. * Defines the camera the input is attached to.
  43514. */
  43515. camera: FollowCamera;
  43516. /**
  43517. * Gets the class name of the current input.
  43518. * @returns the class name
  43519. */
  43520. getClassName(): string;
  43521. /**
  43522. * Defines the pointer angular sensibility along the X axis or how fast is
  43523. * the camera rotating.
  43524. * A negative number will reverse the axis direction.
  43525. */
  43526. angularSensibilityX: number;
  43527. /**
  43528. * Defines the pointer angular sensibility along the Y axis or how fast is
  43529. * the camera rotating.
  43530. * A negative number will reverse the axis direction.
  43531. */
  43532. angularSensibilityY: number;
  43533. /**
  43534. * Defines the pointer pinch precision or how fast is the camera zooming.
  43535. * A negative number will reverse the axis direction.
  43536. */
  43537. pinchPrecision: number;
  43538. /**
  43539. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43540. * from 0.
  43541. * It defines the percentage of current camera.radius to use as delta when
  43542. * pinch zoom is used.
  43543. */
  43544. pinchDeltaPercentage: number;
  43545. /**
  43546. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43547. */
  43548. axisXControlRadius: boolean;
  43549. /**
  43550. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43551. */
  43552. axisXControlHeight: boolean;
  43553. /**
  43554. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43555. */
  43556. axisXControlRotation: boolean;
  43557. /**
  43558. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43559. */
  43560. axisYControlRadius: boolean;
  43561. /**
  43562. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43563. */
  43564. axisYControlHeight: boolean;
  43565. /**
  43566. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43567. */
  43568. axisYControlRotation: boolean;
  43569. /**
  43570. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43571. */
  43572. axisPinchControlRadius: boolean;
  43573. /**
  43574. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43575. */
  43576. axisPinchControlHeight: boolean;
  43577. /**
  43578. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43579. */
  43580. axisPinchControlRotation: boolean;
  43581. /**
  43582. * Log error messages if basic misconfiguration has occurred.
  43583. */
  43584. warningEnable: boolean;
  43585. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43586. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43587. private _warningCounter;
  43588. private _warning;
  43589. }
  43590. }
  43591. declare module BABYLON {
  43592. /**
  43593. * Default Inputs manager for the FollowCamera.
  43594. * It groups all the default supported inputs for ease of use.
  43595. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43596. */
  43597. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43598. /**
  43599. * Instantiates a new FollowCameraInputsManager.
  43600. * @param camera Defines the camera the inputs belong to
  43601. */
  43602. constructor(camera: FollowCamera);
  43603. /**
  43604. * Add keyboard input support to the input manager.
  43605. * @returns the current input manager
  43606. */
  43607. addKeyboard(): FollowCameraInputsManager;
  43608. /**
  43609. * Add mouse wheel input support to the input manager.
  43610. * @returns the current input manager
  43611. */
  43612. addMouseWheel(): FollowCameraInputsManager;
  43613. /**
  43614. * Add pointers input support to the input manager.
  43615. * @returns the current input manager
  43616. */
  43617. addPointers(): FollowCameraInputsManager;
  43618. /**
  43619. * Add orientation input support to the input manager.
  43620. * @returns the current input manager
  43621. */
  43622. addVRDeviceOrientation(): FollowCameraInputsManager;
  43623. }
  43624. }
  43625. declare module BABYLON {
  43626. /**
  43627. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43628. * an arc rotate version arcFollowCamera are available.
  43629. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43630. */
  43631. export class FollowCamera extends TargetCamera {
  43632. /**
  43633. * Distance the follow camera should follow an object at
  43634. */
  43635. radius: number;
  43636. /**
  43637. * Minimum allowed distance of the camera to the axis of rotation
  43638. * (The camera can not get closer).
  43639. * This can help limiting how the Camera is able to move in the scene.
  43640. */
  43641. lowerRadiusLimit: Nullable<number>;
  43642. /**
  43643. * Maximum allowed distance of the camera to the axis of rotation
  43644. * (The camera can not get further).
  43645. * This can help limiting how the Camera is able to move in the scene.
  43646. */
  43647. upperRadiusLimit: Nullable<number>;
  43648. /**
  43649. * Define a rotation offset between the camera and the object it follows
  43650. */
  43651. rotationOffset: number;
  43652. /**
  43653. * Minimum allowed angle to camera position relative to target object.
  43654. * This can help limiting how the Camera is able to move in the scene.
  43655. */
  43656. lowerRotationOffsetLimit: Nullable<number>;
  43657. /**
  43658. * Maximum allowed angle to camera position relative to target object.
  43659. * This can help limiting how the Camera is able to move in the scene.
  43660. */
  43661. upperRotationOffsetLimit: Nullable<number>;
  43662. /**
  43663. * Define a height offset between the camera and the object it follows.
  43664. * It can help following an object from the top (like a car chaing a plane)
  43665. */
  43666. heightOffset: number;
  43667. /**
  43668. * Minimum allowed height of camera position relative to target object.
  43669. * This can help limiting how the Camera is able to move in the scene.
  43670. */
  43671. lowerHeightOffsetLimit: Nullable<number>;
  43672. /**
  43673. * Maximum allowed height of camera position relative to target object.
  43674. * This can help limiting how the Camera is able to move in the scene.
  43675. */
  43676. upperHeightOffsetLimit: Nullable<number>;
  43677. /**
  43678. * Define how fast the camera can accelerate to follow it s target.
  43679. */
  43680. cameraAcceleration: number;
  43681. /**
  43682. * Define the speed limit of the camera following an object.
  43683. */
  43684. maxCameraSpeed: number;
  43685. /**
  43686. * Define the target of the camera.
  43687. */
  43688. lockedTarget: Nullable<AbstractMesh>;
  43689. /**
  43690. * Defines the input associated with the camera.
  43691. */
  43692. inputs: FollowCameraInputsManager;
  43693. /**
  43694. * Instantiates the follow camera.
  43695. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43696. * @param name Define the name of the camera in the scene
  43697. * @param position Define the position of the camera
  43698. * @param scene Define the scene the camera belong to
  43699. * @param lockedTarget Define the target of the camera
  43700. */
  43701. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43702. private _follow;
  43703. /**
  43704. * Attached controls to the current camera.
  43705. * @param element Defines the element the controls should be listened from
  43706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43707. */
  43708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43709. /**
  43710. * Detach the current controls from the camera.
  43711. * The camera will stop reacting to inputs.
  43712. * @param element Defines the element to stop listening the inputs from
  43713. */
  43714. detachControl(element: HTMLElement): void;
  43715. /** @hidden */
  43716. _checkInputs(): void;
  43717. private _checkLimits;
  43718. /**
  43719. * Gets the camera class name.
  43720. * @returns the class name
  43721. */
  43722. getClassName(): string;
  43723. }
  43724. /**
  43725. * Arc Rotate version of the follow camera.
  43726. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43727. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43728. */
  43729. export class ArcFollowCamera extends TargetCamera {
  43730. /** The longitudinal angle of the camera */
  43731. alpha: number;
  43732. /** The latitudinal angle of the camera */
  43733. beta: number;
  43734. /** The radius of the camera from its target */
  43735. radius: number;
  43736. /** Define the camera target (the mesh it should follow) */
  43737. target: Nullable<AbstractMesh>;
  43738. private _cartesianCoordinates;
  43739. /**
  43740. * Instantiates a new ArcFollowCamera
  43741. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43742. * @param name Define the name of the camera
  43743. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43744. * @param beta Define the rotation angle of the camera around the elevation axis
  43745. * @param radius Define the radius of the camera from its target point
  43746. * @param target Define the target of the camera
  43747. * @param scene Define the scene the camera belongs to
  43748. */
  43749. constructor(name: string,
  43750. /** The longitudinal angle of the camera */
  43751. alpha: number,
  43752. /** The latitudinal angle of the camera */
  43753. beta: number,
  43754. /** The radius of the camera from its target */
  43755. radius: number,
  43756. /** Define the camera target (the mesh it should follow) */
  43757. target: Nullable<AbstractMesh>, scene: Scene);
  43758. private _follow;
  43759. /** @hidden */
  43760. _checkInputs(): void;
  43761. /**
  43762. * Returns the class name of the object.
  43763. * It is mostly used internally for serialization purposes.
  43764. */
  43765. getClassName(): string;
  43766. }
  43767. }
  43768. declare module BABYLON {
  43769. /**
  43770. * Manage the keyboard inputs to control the movement of a follow camera.
  43771. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43772. */
  43773. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43774. /**
  43775. * Defines the camera the input is attached to.
  43776. */
  43777. camera: FollowCamera;
  43778. /**
  43779. * Defines the list of key codes associated with the up action (increase heightOffset)
  43780. */
  43781. keysHeightOffsetIncr: number[];
  43782. /**
  43783. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43784. */
  43785. keysHeightOffsetDecr: number[];
  43786. /**
  43787. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43788. */
  43789. keysHeightOffsetModifierAlt: boolean;
  43790. /**
  43791. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43792. */
  43793. keysHeightOffsetModifierCtrl: boolean;
  43794. /**
  43795. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43796. */
  43797. keysHeightOffsetModifierShift: boolean;
  43798. /**
  43799. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43800. */
  43801. keysRotationOffsetIncr: number[];
  43802. /**
  43803. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43804. */
  43805. keysRotationOffsetDecr: number[];
  43806. /**
  43807. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43808. */
  43809. keysRotationOffsetModifierAlt: boolean;
  43810. /**
  43811. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43812. */
  43813. keysRotationOffsetModifierCtrl: boolean;
  43814. /**
  43815. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43816. */
  43817. keysRotationOffsetModifierShift: boolean;
  43818. /**
  43819. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43820. */
  43821. keysRadiusIncr: number[];
  43822. /**
  43823. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43824. */
  43825. keysRadiusDecr: number[];
  43826. /**
  43827. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43828. */
  43829. keysRadiusModifierAlt: boolean;
  43830. /**
  43831. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43832. */
  43833. keysRadiusModifierCtrl: boolean;
  43834. /**
  43835. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43836. */
  43837. keysRadiusModifierShift: boolean;
  43838. /**
  43839. * Defines the rate of change of heightOffset.
  43840. */
  43841. heightSensibility: number;
  43842. /**
  43843. * Defines the rate of change of rotationOffset.
  43844. */
  43845. rotationSensibility: number;
  43846. /**
  43847. * Defines the rate of change of radius.
  43848. */
  43849. radiusSensibility: number;
  43850. private _keys;
  43851. private _ctrlPressed;
  43852. private _altPressed;
  43853. private _shiftPressed;
  43854. private _onCanvasBlurObserver;
  43855. private _onKeyboardObserver;
  43856. private _engine;
  43857. private _scene;
  43858. /**
  43859. * Attach the input controls to a specific dom element to get the input from.
  43860. * @param element Defines the element the controls should be listened from
  43861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43862. */
  43863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43864. /**
  43865. * Detach the current controls from the specified dom element.
  43866. * @param element Defines the element to stop listening the inputs from
  43867. */
  43868. detachControl(element: Nullable<HTMLElement>): void;
  43869. /**
  43870. * Update the current camera state depending on the inputs that have been used this frame.
  43871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43872. */
  43873. checkInputs(): void;
  43874. /**
  43875. * Gets the class name of the current input.
  43876. * @returns the class name
  43877. */
  43878. getClassName(): string;
  43879. /**
  43880. * Get the friendly name associated with the input class.
  43881. * @returns the input friendly name
  43882. */
  43883. getSimpleName(): string;
  43884. /**
  43885. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43886. * allow modification of the heightOffset value.
  43887. */
  43888. private _modifierHeightOffset;
  43889. /**
  43890. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43891. * allow modification of the rotationOffset value.
  43892. */
  43893. private _modifierRotationOffset;
  43894. /**
  43895. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43896. * allow modification of the radius value.
  43897. */
  43898. private _modifierRadius;
  43899. }
  43900. }
  43901. declare module BABYLON {
  43902. interface FreeCameraInputsManager {
  43903. /**
  43904. * @hidden
  43905. */
  43906. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43907. /**
  43908. * Add orientation input support to the input manager.
  43909. * @returns the current input manager
  43910. */
  43911. addDeviceOrientation(): FreeCameraInputsManager;
  43912. }
  43913. /**
  43914. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43915. * Screen rotation is taken into account.
  43916. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43917. */
  43918. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43919. private _camera;
  43920. private _screenOrientationAngle;
  43921. private _constantTranform;
  43922. private _screenQuaternion;
  43923. private _alpha;
  43924. private _beta;
  43925. private _gamma;
  43926. /**
  43927. * Can be used to detect if a device orientation sensor is available on a device
  43928. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43929. * @returns a promise that will resolve on orientation change
  43930. */
  43931. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43932. /**
  43933. * @hidden
  43934. */
  43935. _onDeviceOrientationChangedObservable: Observable<void>;
  43936. /**
  43937. * Instantiates a new input
  43938. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43939. */
  43940. constructor();
  43941. /**
  43942. * Define the camera controlled by the input.
  43943. */
  43944. get camera(): FreeCamera;
  43945. set camera(camera: FreeCamera);
  43946. /**
  43947. * Attach the input controls to a specific dom element to get the input from.
  43948. * @param element Defines the element the controls should be listened from
  43949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43950. */
  43951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43952. private _orientationChanged;
  43953. private _deviceOrientation;
  43954. /**
  43955. * Detach the current controls from the specified dom element.
  43956. * @param element Defines the element to stop listening the inputs from
  43957. */
  43958. detachControl(element: Nullable<HTMLElement>): void;
  43959. /**
  43960. * Update the current camera state depending on the inputs that have been used this frame.
  43961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43962. */
  43963. checkInputs(): void;
  43964. /**
  43965. * Gets the class name of the current intput.
  43966. * @returns the class name
  43967. */
  43968. getClassName(): string;
  43969. /**
  43970. * Get the friendly name associated with the input class.
  43971. * @returns the input friendly name
  43972. */
  43973. getSimpleName(): string;
  43974. }
  43975. }
  43976. declare module BABYLON {
  43977. /**
  43978. * Manage the gamepad inputs to control a free camera.
  43979. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43980. */
  43981. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43982. /**
  43983. * Define the camera the input is attached to.
  43984. */
  43985. camera: FreeCamera;
  43986. /**
  43987. * Define the Gamepad controlling the input
  43988. */
  43989. gamepad: Nullable<Gamepad>;
  43990. /**
  43991. * Defines the gamepad rotation sensiblity.
  43992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43993. */
  43994. gamepadAngularSensibility: number;
  43995. /**
  43996. * Defines the gamepad move sensiblity.
  43997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43998. */
  43999. gamepadMoveSensibility: number;
  44000. private _yAxisScale;
  44001. /**
  44002. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44003. */
  44004. get invertYAxis(): boolean;
  44005. set invertYAxis(value: boolean);
  44006. private _onGamepadConnectedObserver;
  44007. private _onGamepadDisconnectedObserver;
  44008. private _cameraTransform;
  44009. private _deltaTransform;
  44010. private _vector3;
  44011. private _vector2;
  44012. /**
  44013. * Attach the input controls to a specific dom element to get the input from.
  44014. * @param element Defines the element the controls should be listened from
  44015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44016. */
  44017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44018. /**
  44019. * Detach the current controls from the specified dom element.
  44020. * @param element Defines the element to stop listening the inputs from
  44021. */
  44022. detachControl(element: Nullable<HTMLElement>): void;
  44023. /**
  44024. * Update the current camera state depending on the inputs that have been used this frame.
  44025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44026. */
  44027. checkInputs(): void;
  44028. /**
  44029. * Gets the class name of the current intput.
  44030. * @returns the class name
  44031. */
  44032. getClassName(): string;
  44033. /**
  44034. * Get the friendly name associated with the input class.
  44035. * @returns the input friendly name
  44036. */
  44037. getSimpleName(): string;
  44038. }
  44039. }
  44040. declare module BABYLON {
  44041. /**
  44042. * Defines the potential axis of a Joystick
  44043. */
  44044. export enum JoystickAxis {
  44045. /** X axis */
  44046. X = 0,
  44047. /** Y axis */
  44048. Y = 1,
  44049. /** Z axis */
  44050. Z = 2
  44051. }
  44052. /**
  44053. * Represents the different customization options available
  44054. * for VirtualJoystick
  44055. */
  44056. interface VirtualJoystickCustomizations {
  44057. /**
  44058. * Size of the joystick's puck
  44059. */
  44060. puckSize: number;
  44061. /**
  44062. * Size of the joystick's container
  44063. */
  44064. containerSize: number;
  44065. /**
  44066. * Color of the joystick && puck
  44067. */
  44068. color: string;
  44069. /**
  44070. * Image URL for the joystick's puck
  44071. */
  44072. puckImage?: string;
  44073. /**
  44074. * Image URL for the joystick's container
  44075. */
  44076. containerImage?: string;
  44077. /**
  44078. * Defines the unmoving position of the joystick container
  44079. */
  44080. position?: {
  44081. x: number;
  44082. y: number;
  44083. };
  44084. /**
  44085. * Defines whether or not the joystick container is always visible
  44086. */
  44087. alwaysVisible: boolean;
  44088. /**
  44089. * Defines whether or not to limit the movement of the puck to the joystick's container
  44090. */
  44091. limitToContainer: boolean;
  44092. }
  44093. /**
  44094. * Class used to define virtual joystick (used in touch mode)
  44095. */
  44096. export class VirtualJoystick {
  44097. /**
  44098. * Gets or sets a boolean indicating that left and right values must be inverted
  44099. */
  44100. reverseLeftRight: boolean;
  44101. /**
  44102. * Gets or sets a boolean indicating that up and down values must be inverted
  44103. */
  44104. reverseUpDown: boolean;
  44105. /**
  44106. * Gets the offset value for the position (ie. the change of the position value)
  44107. */
  44108. deltaPosition: Vector3;
  44109. /**
  44110. * Gets a boolean indicating if the virtual joystick was pressed
  44111. */
  44112. pressed: boolean;
  44113. /**
  44114. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44115. */
  44116. static Canvas: Nullable<HTMLCanvasElement>;
  44117. /**
  44118. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44119. */
  44120. limitToContainer: boolean;
  44121. private static _globalJoystickIndex;
  44122. private static _alwaysVisibleSticks;
  44123. private static vjCanvasContext;
  44124. private static vjCanvasWidth;
  44125. private static vjCanvasHeight;
  44126. private static halfWidth;
  44127. private static _GetDefaultOptions;
  44128. private _action;
  44129. private _axisTargetedByLeftAndRight;
  44130. private _axisTargetedByUpAndDown;
  44131. private _joystickSensibility;
  44132. private _inversedSensibility;
  44133. private _joystickPointerID;
  44134. private _joystickColor;
  44135. private _joystickPointerPos;
  44136. private _joystickPreviousPointerPos;
  44137. private _joystickPointerStartPos;
  44138. private _deltaJoystickVector;
  44139. private _leftJoystick;
  44140. private _touches;
  44141. private _joystickPosition;
  44142. private _alwaysVisible;
  44143. private _puckImage;
  44144. private _containerImage;
  44145. private _joystickPuckSize;
  44146. private _joystickContainerSize;
  44147. private _clearPuckSize;
  44148. private _clearContainerSize;
  44149. private _clearPuckSizeOffset;
  44150. private _clearContainerSizeOffset;
  44151. private _onPointerDownHandlerRef;
  44152. private _onPointerMoveHandlerRef;
  44153. private _onPointerUpHandlerRef;
  44154. private _onResize;
  44155. /**
  44156. * Creates a new virtual joystick
  44157. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44158. * @param customizations Defines the options we want to customize the VirtualJoystick
  44159. */
  44160. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44161. /**
  44162. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44163. * @param newJoystickSensibility defines the new sensibility
  44164. */
  44165. setJoystickSensibility(newJoystickSensibility: number): void;
  44166. private _onPointerDown;
  44167. private _onPointerMove;
  44168. private _onPointerUp;
  44169. /**
  44170. * Change the color of the virtual joystick
  44171. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44172. */
  44173. setJoystickColor(newColor: string): void;
  44174. /**
  44175. * Size of the joystick's container
  44176. */
  44177. set containerSize(newSize: number);
  44178. get containerSize(): number;
  44179. /**
  44180. * Size of the joystick's puck
  44181. */
  44182. set puckSize(newSize: number);
  44183. get puckSize(): number;
  44184. /**
  44185. * Clears the set position of the joystick
  44186. */
  44187. clearPosition(): void;
  44188. /**
  44189. * Defines whether or not the joystick container is always visible
  44190. */
  44191. set alwaysVisible(value: boolean);
  44192. get alwaysVisible(): boolean;
  44193. /**
  44194. * Sets the constant position of the Joystick container
  44195. * @param x X axis coordinate
  44196. * @param y Y axis coordinate
  44197. */
  44198. setPosition(x: number, y: number): void;
  44199. /**
  44200. * Defines a callback to call when the joystick is touched
  44201. * @param action defines the callback
  44202. */
  44203. setActionOnTouch(action: () => any): void;
  44204. /**
  44205. * Defines which axis you'd like to control for left & right
  44206. * @param axis defines the axis to use
  44207. */
  44208. setAxisForLeftRight(axis: JoystickAxis): void;
  44209. /**
  44210. * Defines which axis you'd like to control for up & down
  44211. * @param axis defines the axis to use
  44212. */
  44213. setAxisForUpDown(axis: JoystickAxis): void;
  44214. /**
  44215. * Clears the canvas from the previous puck / container draw
  44216. */
  44217. private _clearPreviousDraw;
  44218. /**
  44219. * Loads `urlPath` to be used for the container's image
  44220. * @param urlPath defines the urlPath of an image to use
  44221. */
  44222. setContainerImage(urlPath: string): void;
  44223. /**
  44224. * Loads `urlPath` to be used for the puck's image
  44225. * @param urlPath defines the urlPath of an image to use
  44226. */
  44227. setPuckImage(urlPath: string): void;
  44228. /**
  44229. * Draws the Virtual Joystick's container
  44230. */
  44231. private _drawContainer;
  44232. /**
  44233. * Draws the Virtual Joystick's puck
  44234. */
  44235. private _drawPuck;
  44236. private _drawVirtualJoystick;
  44237. /**
  44238. * Release internal HTML canvas
  44239. */
  44240. releaseCanvas(): void;
  44241. }
  44242. }
  44243. declare module BABYLON {
  44244. interface FreeCameraInputsManager {
  44245. /**
  44246. * Add virtual joystick input support to the input manager.
  44247. * @returns the current input manager
  44248. */
  44249. addVirtualJoystick(): FreeCameraInputsManager;
  44250. }
  44251. /**
  44252. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44253. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44254. */
  44255. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44256. /**
  44257. * Defines the camera the input is attached to.
  44258. */
  44259. camera: FreeCamera;
  44260. private _leftjoystick;
  44261. private _rightjoystick;
  44262. /**
  44263. * Gets the left stick of the virtual joystick.
  44264. * @returns The virtual Joystick
  44265. */
  44266. getLeftJoystick(): VirtualJoystick;
  44267. /**
  44268. * Gets the right stick of the virtual joystick.
  44269. * @returns The virtual Joystick
  44270. */
  44271. getRightJoystick(): VirtualJoystick;
  44272. /**
  44273. * Update the current camera state depending on the inputs that have been used this frame.
  44274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44275. */
  44276. checkInputs(): void;
  44277. /**
  44278. * Attach the input controls to a specific dom element to get the input from.
  44279. * @param element Defines the element the controls should be listened from
  44280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44281. */
  44282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44283. /**
  44284. * Detach the current controls from the specified dom element.
  44285. * @param element Defines the element to stop listening the inputs from
  44286. */
  44287. detachControl(element: Nullable<HTMLElement>): void;
  44288. /**
  44289. * Gets the class name of the current intput.
  44290. * @returns the class name
  44291. */
  44292. getClassName(): string;
  44293. /**
  44294. * Get the friendly name associated with the input class.
  44295. * @returns the input friendly name
  44296. */
  44297. getSimpleName(): string;
  44298. }
  44299. }
  44300. declare module BABYLON {
  44301. /**
  44302. * This represents a FPS type of camera controlled by touch.
  44303. * This is like a universal camera minus the Gamepad controls.
  44304. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44305. */
  44306. export class TouchCamera extends FreeCamera {
  44307. /**
  44308. * Defines the touch sensibility for rotation.
  44309. * The higher the faster.
  44310. */
  44311. get touchAngularSensibility(): number;
  44312. set touchAngularSensibility(value: number);
  44313. /**
  44314. * Defines the touch sensibility for move.
  44315. * The higher the faster.
  44316. */
  44317. get touchMoveSensibility(): number;
  44318. set touchMoveSensibility(value: number);
  44319. /**
  44320. * Instantiates a new touch camera.
  44321. * This represents a FPS type of camera controlled by touch.
  44322. * This is like a universal camera minus the Gamepad controls.
  44323. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44324. * @param name Define the name of the camera in the scene
  44325. * @param position Define the start position of the camera in the scene
  44326. * @param scene Define the scene the camera belongs to
  44327. */
  44328. constructor(name: string, position: Vector3, scene: Scene);
  44329. /**
  44330. * Gets the current object class name.
  44331. * @return the class name
  44332. */
  44333. getClassName(): string;
  44334. /** @hidden */
  44335. _setupInputs(): void;
  44336. }
  44337. }
  44338. declare module BABYLON {
  44339. /**
  44340. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44341. * being tilted forward or back and left or right.
  44342. */
  44343. export class DeviceOrientationCamera extends FreeCamera {
  44344. private _initialQuaternion;
  44345. private _quaternionCache;
  44346. private _tmpDragQuaternion;
  44347. private _disablePointerInputWhenUsingDeviceOrientation;
  44348. /**
  44349. * Creates a new device orientation camera
  44350. * @param name The name of the camera
  44351. * @param position The start position camera
  44352. * @param scene The scene the camera belongs to
  44353. */
  44354. constructor(name: string, position: Vector3, scene: Scene);
  44355. /**
  44356. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44357. */
  44358. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44359. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44360. private _dragFactor;
  44361. /**
  44362. * Enabled turning on the y axis when the orientation sensor is active
  44363. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44364. */
  44365. enableHorizontalDragging(dragFactor?: number): void;
  44366. /**
  44367. * Gets the current instance class name ("DeviceOrientationCamera").
  44368. * This helps avoiding instanceof at run time.
  44369. * @returns the class name
  44370. */
  44371. getClassName(): string;
  44372. /**
  44373. * @hidden
  44374. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44375. */
  44376. _checkInputs(): void;
  44377. /**
  44378. * Reset the camera to its default orientation on the specified axis only.
  44379. * @param axis The axis to reset
  44380. */
  44381. resetToCurrentRotation(axis?: Axis): void;
  44382. }
  44383. }
  44384. declare module BABYLON {
  44385. /**
  44386. * Defines supported buttons for XBox360 compatible gamepads
  44387. */
  44388. export enum Xbox360Button {
  44389. /** A */
  44390. A = 0,
  44391. /** B */
  44392. B = 1,
  44393. /** X */
  44394. X = 2,
  44395. /** Y */
  44396. Y = 3,
  44397. /** Left button */
  44398. LB = 4,
  44399. /** Right button */
  44400. RB = 5,
  44401. /** Back */
  44402. Back = 8,
  44403. /** Start */
  44404. Start = 9,
  44405. /** Left stick */
  44406. LeftStick = 10,
  44407. /** Right stick */
  44408. RightStick = 11
  44409. }
  44410. /** Defines values for XBox360 DPad */
  44411. export enum Xbox360Dpad {
  44412. /** Up */
  44413. Up = 12,
  44414. /** Down */
  44415. Down = 13,
  44416. /** Left */
  44417. Left = 14,
  44418. /** Right */
  44419. Right = 15
  44420. }
  44421. /**
  44422. * Defines a XBox360 gamepad
  44423. */
  44424. export class Xbox360Pad extends Gamepad {
  44425. private _leftTrigger;
  44426. private _rightTrigger;
  44427. private _onlefttriggerchanged;
  44428. private _onrighttriggerchanged;
  44429. private _onbuttondown;
  44430. private _onbuttonup;
  44431. private _ondpaddown;
  44432. private _ondpadup;
  44433. /** Observable raised when a button is pressed */
  44434. onButtonDownObservable: Observable<Xbox360Button>;
  44435. /** Observable raised when a button is released */
  44436. onButtonUpObservable: Observable<Xbox360Button>;
  44437. /** Observable raised when a pad is pressed */
  44438. onPadDownObservable: Observable<Xbox360Dpad>;
  44439. /** Observable raised when a pad is released */
  44440. onPadUpObservable: Observable<Xbox360Dpad>;
  44441. private _buttonA;
  44442. private _buttonB;
  44443. private _buttonX;
  44444. private _buttonY;
  44445. private _buttonBack;
  44446. private _buttonStart;
  44447. private _buttonLB;
  44448. private _buttonRB;
  44449. private _buttonLeftStick;
  44450. private _buttonRightStick;
  44451. private _dPadUp;
  44452. private _dPadDown;
  44453. private _dPadLeft;
  44454. private _dPadRight;
  44455. private _isXboxOnePad;
  44456. /**
  44457. * Creates a new XBox360 gamepad object
  44458. * @param id defines the id of this gamepad
  44459. * @param index defines its index
  44460. * @param gamepad defines the internal HTML gamepad object
  44461. * @param xboxOne defines if it is a XBox One gamepad
  44462. */
  44463. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44464. /**
  44465. * Defines the callback to call when left trigger is pressed
  44466. * @param callback defines the callback to use
  44467. */
  44468. onlefttriggerchanged(callback: (value: number) => void): void;
  44469. /**
  44470. * Defines the callback to call when right trigger is pressed
  44471. * @param callback defines the callback to use
  44472. */
  44473. onrighttriggerchanged(callback: (value: number) => void): void;
  44474. /**
  44475. * Gets the left trigger value
  44476. */
  44477. get leftTrigger(): number;
  44478. /**
  44479. * Sets the left trigger value
  44480. */
  44481. set leftTrigger(newValue: number);
  44482. /**
  44483. * Gets the right trigger value
  44484. */
  44485. get rightTrigger(): number;
  44486. /**
  44487. * Sets the right trigger value
  44488. */
  44489. set rightTrigger(newValue: number);
  44490. /**
  44491. * Defines the callback to call when a button is pressed
  44492. * @param callback defines the callback to use
  44493. */
  44494. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44495. /**
  44496. * Defines the callback to call when a button is released
  44497. * @param callback defines the callback to use
  44498. */
  44499. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44500. /**
  44501. * Defines the callback to call when a pad is pressed
  44502. * @param callback defines the callback to use
  44503. */
  44504. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44505. /**
  44506. * Defines the callback to call when a pad is released
  44507. * @param callback defines the callback to use
  44508. */
  44509. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44510. private _setButtonValue;
  44511. private _setDPadValue;
  44512. /**
  44513. * Gets the value of the `A` button
  44514. */
  44515. get buttonA(): number;
  44516. /**
  44517. * Sets the value of the `A` button
  44518. */
  44519. set buttonA(value: number);
  44520. /**
  44521. * Gets the value of the `B` button
  44522. */
  44523. get buttonB(): number;
  44524. /**
  44525. * Sets the value of the `B` button
  44526. */
  44527. set buttonB(value: number);
  44528. /**
  44529. * Gets the value of the `X` button
  44530. */
  44531. get buttonX(): number;
  44532. /**
  44533. * Sets the value of the `X` button
  44534. */
  44535. set buttonX(value: number);
  44536. /**
  44537. * Gets the value of the `Y` button
  44538. */
  44539. get buttonY(): number;
  44540. /**
  44541. * Sets the value of the `Y` button
  44542. */
  44543. set buttonY(value: number);
  44544. /**
  44545. * Gets the value of the `Start` button
  44546. */
  44547. get buttonStart(): number;
  44548. /**
  44549. * Sets the value of the `Start` button
  44550. */
  44551. set buttonStart(value: number);
  44552. /**
  44553. * Gets the value of the `Back` button
  44554. */
  44555. get buttonBack(): number;
  44556. /**
  44557. * Sets the value of the `Back` button
  44558. */
  44559. set buttonBack(value: number);
  44560. /**
  44561. * Gets the value of the `Left` button
  44562. */
  44563. get buttonLB(): number;
  44564. /**
  44565. * Sets the value of the `Left` button
  44566. */
  44567. set buttonLB(value: number);
  44568. /**
  44569. * Gets the value of the `Right` button
  44570. */
  44571. get buttonRB(): number;
  44572. /**
  44573. * Sets the value of the `Right` button
  44574. */
  44575. set buttonRB(value: number);
  44576. /**
  44577. * Gets the value of the Left joystick
  44578. */
  44579. get buttonLeftStick(): number;
  44580. /**
  44581. * Sets the value of the Left joystick
  44582. */
  44583. set buttonLeftStick(value: number);
  44584. /**
  44585. * Gets the value of the Right joystick
  44586. */
  44587. get buttonRightStick(): number;
  44588. /**
  44589. * Sets the value of the Right joystick
  44590. */
  44591. set buttonRightStick(value: number);
  44592. /**
  44593. * Gets the value of D-pad up
  44594. */
  44595. get dPadUp(): number;
  44596. /**
  44597. * Sets the value of D-pad up
  44598. */
  44599. set dPadUp(value: number);
  44600. /**
  44601. * Gets the value of D-pad down
  44602. */
  44603. get dPadDown(): number;
  44604. /**
  44605. * Sets the value of D-pad down
  44606. */
  44607. set dPadDown(value: number);
  44608. /**
  44609. * Gets the value of D-pad left
  44610. */
  44611. get dPadLeft(): number;
  44612. /**
  44613. * Sets the value of D-pad left
  44614. */
  44615. set dPadLeft(value: number);
  44616. /**
  44617. * Gets the value of D-pad right
  44618. */
  44619. get dPadRight(): number;
  44620. /**
  44621. * Sets the value of D-pad right
  44622. */
  44623. set dPadRight(value: number);
  44624. /**
  44625. * Force the gamepad to synchronize with device values
  44626. */
  44627. update(): void;
  44628. /**
  44629. * Disposes the gamepad
  44630. */
  44631. dispose(): void;
  44632. }
  44633. }
  44634. declare module BABYLON {
  44635. /**
  44636. * Defines supported buttons for DualShock compatible gamepads
  44637. */
  44638. export enum DualShockButton {
  44639. /** Cross */
  44640. Cross = 0,
  44641. /** Circle */
  44642. Circle = 1,
  44643. /** Square */
  44644. Square = 2,
  44645. /** Triangle */
  44646. Triangle = 3,
  44647. /** L1 */
  44648. L1 = 4,
  44649. /** R1 */
  44650. R1 = 5,
  44651. /** Share */
  44652. Share = 8,
  44653. /** Options */
  44654. Options = 9,
  44655. /** Left stick */
  44656. LeftStick = 10,
  44657. /** Right stick */
  44658. RightStick = 11
  44659. }
  44660. /** Defines values for DualShock DPad */
  44661. export enum DualShockDpad {
  44662. /** Up */
  44663. Up = 12,
  44664. /** Down */
  44665. Down = 13,
  44666. /** Left */
  44667. Left = 14,
  44668. /** Right */
  44669. Right = 15
  44670. }
  44671. /**
  44672. * Defines a DualShock gamepad
  44673. */
  44674. export class DualShockPad extends Gamepad {
  44675. private _leftTrigger;
  44676. private _rightTrigger;
  44677. private _onlefttriggerchanged;
  44678. private _onrighttriggerchanged;
  44679. private _onbuttondown;
  44680. private _onbuttonup;
  44681. private _ondpaddown;
  44682. private _ondpadup;
  44683. /** Observable raised when a button is pressed */
  44684. onButtonDownObservable: Observable<DualShockButton>;
  44685. /** Observable raised when a button is released */
  44686. onButtonUpObservable: Observable<DualShockButton>;
  44687. /** Observable raised when a pad is pressed */
  44688. onPadDownObservable: Observable<DualShockDpad>;
  44689. /** Observable raised when a pad is released */
  44690. onPadUpObservable: Observable<DualShockDpad>;
  44691. private _buttonCross;
  44692. private _buttonCircle;
  44693. private _buttonSquare;
  44694. private _buttonTriangle;
  44695. private _buttonShare;
  44696. private _buttonOptions;
  44697. private _buttonL1;
  44698. private _buttonR1;
  44699. private _buttonLeftStick;
  44700. private _buttonRightStick;
  44701. private _dPadUp;
  44702. private _dPadDown;
  44703. private _dPadLeft;
  44704. private _dPadRight;
  44705. /**
  44706. * Creates a new DualShock gamepad object
  44707. * @param id defines the id of this gamepad
  44708. * @param index defines its index
  44709. * @param gamepad defines the internal HTML gamepad object
  44710. */
  44711. constructor(id: string, index: number, gamepad: any);
  44712. /**
  44713. * Defines the callback to call when left trigger is pressed
  44714. * @param callback defines the callback to use
  44715. */
  44716. onlefttriggerchanged(callback: (value: number) => void): void;
  44717. /**
  44718. * Defines the callback to call when right trigger is pressed
  44719. * @param callback defines the callback to use
  44720. */
  44721. onrighttriggerchanged(callback: (value: number) => void): void;
  44722. /**
  44723. * Gets the left trigger value
  44724. */
  44725. get leftTrigger(): number;
  44726. /**
  44727. * Sets the left trigger value
  44728. */
  44729. set leftTrigger(newValue: number);
  44730. /**
  44731. * Gets the right trigger value
  44732. */
  44733. get rightTrigger(): number;
  44734. /**
  44735. * Sets the right trigger value
  44736. */
  44737. set rightTrigger(newValue: number);
  44738. /**
  44739. * Defines the callback to call when a button is pressed
  44740. * @param callback defines the callback to use
  44741. */
  44742. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44743. /**
  44744. * Defines the callback to call when a button is released
  44745. * @param callback defines the callback to use
  44746. */
  44747. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44748. /**
  44749. * Defines the callback to call when a pad is pressed
  44750. * @param callback defines the callback to use
  44751. */
  44752. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44753. /**
  44754. * Defines the callback to call when a pad is released
  44755. * @param callback defines the callback to use
  44756. */
  44757. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44758. private _setButtonValue;
  44759. private _setDPadValue;
  44760. /**
  44761. * Gets the value of the `Cross` button
  44762. */
  44763. get buttonCross(): number;
  44764. /**
  44765. * Sets the value of the `Cross` button
  44766. */
  44767. set buttonCross(value: number);
  44768. /**
  44769. * Gets the value of the `Circle` button
  44770. */
  44771. get buttonCircle(): number;
  44772. /**
  44773. * Sets the value of the `Circle` button
  44774. */
  44775. set buttonCircle(value: number);
  44776. /**
  44777. * Gets the value of the `Square` button
  44778. */
  44779. get buttonSquare(): number;
  44780. /**
  44781. * Sets the value of the `Square` button
  44782. */
  44783. set buttonSquare(value: number);
  44784. /**
  44785. * Gets the value of the `Triangle` button
  44786. */
  44787. get buttonTriangle(): number;
  44788. /**
  44789. * Sets the value of the `Triangle` button
  44790. */
  44791. set buttonTriangle(value: number);
  44792. /**
  44793. * Gets the value of the `Options` button
  44794. */
  44795. get buttonOptions(): number;
  44796. /**
  44797. * Sets the value of the `Options` button
  44798. */
  44799. set buttonOptions(value: number);
  44800. /**
  44801. * Gets the value of the `Share` button
  44802. */
  44803. get buttonShare(): number;
  44804. /**
  44805. * Sets the value of the `Share` button
  44806. */
  44807. set buttonShare(value: number);
  44808. /**
  44809. * Gets the value of the `L1` button
  44810. */
  44811. get buttonL1(): number;
  44812. /**
  44813. * Sets the value of the `L1` button
  44814. */
  44815. set buttonL1(value: number);
  44816. /**
  44817. * Gets the value of the `R1` button
  44818. */
  44819. get buttonR1(): number;
  44820. /**
  44821. * Sets the value of the `R1` button
  44822. */
  44823. set buttonR1(value: number);
  44824. /**
  44825. * Gets the value of the Left joystick
  44826. */
  44827. get buttonLeftStick(): number;
  44828. /**
  44829. * Sets the value of the Left joystick
  44830. */
  44831. set buttonLeftStick(value: number);
  44832. /**
  44833. * Gets the value of the Right joystick
  44834. */
  44835. get buttonRightStick(): number;
  44836. /**
  44837. * Sets the value of the Right joystick
  44838. */
  44839. set buttonRightStick(value: number);
  44840. /**
  44841. * Gets the value of D-pad up
  44842. */
  44843. get dPadUp(): number;
  44844. /**
  44845. * Sets the value of D-pad up
  44846. */
  44847. set dPadUp(value: number);
  44848. /**
  44849. * Gets the value of D-pad down
  44850. */
  44851. get dPadDown(): number;
  44852. /**
  44853. * Sets the value of D-pad down
  44854. */
  44855. set dPadDown(value: number);
  44856. /**
  44857. * Gets the value of D-pad left
  44858. */
  44859. get dPadLeft(): number;
  44860. /**
  44861. * Sets the value of D-pad left
  44862. */
  44863. set dPadLeft(value: number);
  44864. /**
  44865. * Gets the value of D-pad right
  44866. */
  44867. get dPadRight(): number;
  44868. /**
  44869. * Sets the value of D-pad right
  44870. */
  44871. set dPadRight(value: number);
  44872. /**
  44873. * Force the gamepad to synchronize with device values
  44874. */
  44875. update(): void;
  44876. /**
  44877. * Disposes the gamepad
  44878. */
  44879. dispose(): void;
  44880. }
  44881. }
  44882. declare module BABYLON {
  44883. /**
  44884. * Manager for handling gamepads
  44885. */
  44886. export class GamepadManager {
  44887. private _scene?;
  44888. private _babylonGamepads;
  44889. private _oneGamepadConnected;
  44890. /** @hidden */
  44891. _isMonitoring: boolean;
  44892. private _gamepadEventSupported;
  44893. private _gamepadSupport?;
  44894. /**
  44895. * observable to be triggered when the gamepad controller has been connected
  44896. */
  44897. onGamepadConnectedObservable: Observable<Gamepad>;
  44898. /**
  44899. * observable to be triggered when the gamepad controller has been disconnected
  44900. */
  44901. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44902. private _onGamepadConnectedEvent;
  44903. private _onGamepadDisconnectedEvent;
  44904. /**
  44905. * Initializes the gamepad manager
  44906. * @param _scene BabylonJS scene
  44907. */
  44908. constructor(_scene?: Scene | undefined);
  44909. /**
  44910. * The gamepads in the game pad manager
  44911. */
  44912. get gamepads(): Gamepad[];
  44913. /**
  44914. * Get the gamepad controllers based on type
  44915. * @param type The type of gamepad controller
  44916. * @returns Nullable gamepad
  44917. */
  44918. getGamepadByType(type?: number): Nullable<Gamepad>;
  44919. /**
  44920. * Disposes the gamepad manager
  44921. */
  44922. dispose(): void;
  44923. private _addNewGamepad;
  44924. private _startMonitoringGamepads;
  44925. private _stopMonitoringGamepads;
  44926. /** @hidden */
  44927. _checkGamepadsStatus(): void;
  44928. private _updateGamepadObjects;
  44929. }
  44930. }
  44931. declare module BABYLON {
  44932. interface Scene {
  44933. /** @hidden */
  44934. _gamepadManager: Nullable<GamepadManager>;
  44935. /**
  44936. * Gets the gamepad manager associated with the scene
  44937. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  44938. */
  44939. gamepadManager: GamepadManager;
  44940. }
  44941. /**
  44942. * Interface representing a free camera inputs manager
  44943. */
  44944. interface FreeCameraInputsManager {
  44945. /**
  44946. * Adds gamepad input support to the FreeCameraInputsManager.
  44947. * @returns the FreeCameraInputsManager
  44948. */
  44949. addGamepad(): FreeCameraInputsManager;
  44950. }
  44951. /**
  44952. * Interface representing an arc rotate camera inputs manager
  44953. */
  44954. interface ArcRotateCameraInputsManager {
  44955. /**
  44956. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44957. * @returns the camera inputs manager
  44958. */
  44959. addGamepad(): ArcRotateCameraInputsManager;
  44960. }
  44961. /**
  44962. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44963. */
  44964. export class GamepadSystemSceneComponent implements ISceneComponent {
  44965. /**
  44966. * The component name helpfull to identify the component in the list of scene components.
  44967. */
  44968. readonly name: string;
  44969. /**
  44970. * The scene the component belongs to.
  44971. */
  44972. scene: Scene;
  44973. /**
  44974. * Creates a new instance of the component for the given scene
  44975. * @param scene Defines the scene to register the component in
  44976. */
  44977. constructor(scene: Scene);
  44978. /**
  44979. * Registers the component in a given scene
  44980. */
  44981. register(): void;
  44982. /**
  44983. * Rebuilds the elements related to this component in case of
  44984. * context lost for instance.
  44985. */
  44986. rebuild(): void;
  44987. /**
  44988. * Disposes the component and the associated ressources
  44989. */
  44990. dispose(): void;
  44991. private _beforeCameraUpdate;
  44992. }
  44993. }
  44994. declare module BABYLON {
  44995. /**
  44996. * 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,
  44997. * which still works and will still be found in many Playgrounds.
  44998. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44999. */
  45000. export class UniversalCamera extends TouchCamera {
  45001. /**
  45002. * Defines the gamepad rotation sensiblity.
  45003. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45004. */
  45005. get gamepadAngularSensibility(): number;
  45006. set gamepadAngularSensibility(value: number);
  45007. /**
  45008. * Defines the gamepad move sensiblity.
  45009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45010. */
  45011. get gamepadMoveSensibility(): number;
  45012. set gamepadMoveSensibility(value: number);
  45013. /**
  45014. * 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,
  45015. * which still works and will still be found in many Playgrounds.
  45016. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45017. * @param name Define the name of the camera in the scene
  45018. * @param position Define the start position of the camera in the scene
  45019. * @param scene Define the scene the camera belongs to
  45020. */
  45021. constructor(name: string, position: Vector3, scene: Scene);
  45022. /**
  45023. * Gets the current object class name.
  45024. * @return the class name
  45025. */
  45026. getClassName(): string;
  45027. }
  45028. }
  45029. declare module BABYLON {
  45030. /**
  45031. * This represents a FPS type of camera. This is only here for back compat purpose.
  45032. * Please use the UniversalCamera instead as both are identical.
  45033. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45034. */
  45035. export class GamepadCamera extends UniversalCamera {
  45036. /**
  45037. * Instantiates a new Gamepad Camera
  45038. * This represents a FPS type of camera. This is only here for back compat purpose.
  45039. * Please use the UniversalCamera instead as both are identical.
  45040. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45041. * @param name Define the name of the camera in the scene
  45042. * @param position Define the start position of the camera in the scene
  45043. * @param scene Define the scene the camera belongs to
  45044. */
  45045. constructor(name: string, position: Vector3, scene: Scene);
  45046. /**
  45047. * Gets the current object class name.
  45048. * @return the class name
  45049. */
  45050. getClassName(): string;
  45051. }
  45052. }
  45053. declare module BABYLON {
  45054. /** @hidden */
  45055. export var passPixelShader: {
  45056. name: string;
  45057. shader: string;
  45058. };
  45059. }
  45060. declare module BABYLON {
  45061. /** @hidden */
  45062. export var passCubePixelShader: {
  45063. name: string;
  45064. shader: string;
  45065. };
  45066. }
  45067. declare module BABYLON {
  45068. /**
  45069. * PassPostProcess which produces an output the same as it's input
  45070. */
  45071. export class PassPostProcess extends PostProcess {
  45072. /**
  45073. * Creates the PassPostProcess
  45074. * @param name The name of the effect.
  45075. * @param options The required width/height ratio to downsize to before computing the render pass.
  45076. * @param camera The camera to apply the render pass to.
  45077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45078. * @param engine The engine which the post process will be applied. (default: current engine)
  45079. * @param reusable If the post process can be reused on the same frame. (default: false)
  45080. * @param textureType The type of texture to be used when performing the post processing.
  45081. * @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)
  45082. */
  45083. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45084. }
  45085. /**
  45086. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45087. */
  45088. export class PassCubePostProcess extends PostProcess {
  45089. private _face;
  45090. /**
  45091. * Gets or sets the cube face to display.
  45092. * * 0 is +X
  45093. * * 1 is -X
  45094. * * 2 is +Y
  45095. * * 3 is -Y
  45096. * * 4 is +Z
  45097. * * 5 is -Z
  45098. */
  45099. get face(): number;
  45100. set face(value: number);
  45101. /**
  45102. * Creates the PassCubePostProcess
  45103. * @param name The name of the effect.
  45104. * @param options The required width/height ratio to downsize to before computing the render pass.
  45105. * @param camera The camera to apply the render pass to.
  45106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45107. * @param engine The engine which the post process will be applied. (default: current engine)
  45108. * @param reusable If the post process can be reused on the same frame. (default: false)
  45109. * @param textureType The type of texture to be used when performing the post processing.
  45110. * @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)
  45111. */
  45112. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45113. }
  45114. }
  45115. declare module BABYLON {
  45116. /** @hidden */
  45117. export var anaglyphPixelShader: {
  45118. name: string;
  45119. shader: string;
  45120. };
  45121. }
  45122. declare module BABYLON {
  45123. /**
  45124. * Postprocess used to generate anaglyphic rendering
  45125. */
  45126. export class AnaglyphPostProcess extends PostProcess {
  45127. private _passedProcess;
  45128. /**
  45129. * Creates a new AnaglyphPostProcess
  45130. * @param name defines postprocess name
  45131. * @param options defines creation options or target ratio scale
  45132. * @param rigCameras defines cameras using this postprocess
  45133. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45134. * @param engine defines hosting engine
  45135. * @param reusable defines if the postprocess will be reused multiple times per frame
  45136. */
  45137. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45138. }
  45139. }
  45140. declare module BABYLON {
  45141. /**
  45142. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45143. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45144. */
  45145. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45146. /**
  45147. * Creates a new AnaglyphArcRotateCamera
  45148. * @param name defines camera name
  45149. * @param alpha defines alpha angle (in radians)
  45150. * @param beta defines beta angle (in radians)
  45151. * @param radius defines radius
  45152. * @param target defines camera target
  45153. * @param interaxialDistance defines distance between each color axis
  45154. * @param scene defines the hosting scene
  45155. */
  45156. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45157. /**
  45158. * Gets camera class name
  45159. * @returns AnaglyphArcRotateCamera
  45160. */
  45161. getClassName(): string;
  45162. }
  45163. }
  45164. declare module BABYLON {
  45165. /**
  45166. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45167. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45168. */
  45169. export class AnaglyphFreeCamera extends FreeCamera {
  45170. /**
  45171. * Creates a new AnaglyphFreeCamera
  45172. * @param name defines camera name
  45173. * @param position defines initial position
  45174. * @param interaxialDistance defines distance between each color axis
  45175. * @param scene defines the hosting scene
  45176. */
  45177. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45178. /**
  45179. * Gets camera class name
  45180. * @returns AnaglyphFreeCamera
  45181. */
  45182. getClassName(): string;
  45183. }
  45184. }
  45185. declare module BABYLON {
  45186. /**
  45187. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45188. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45189. */
  45190. export class AnaglyphGamepadCamera extends GamepadCamera {
  45191. /**
  45192. * Creates a new AnaglyphGamepadCamera
  45193. * @param name defines camera name
  45194. * @param position defines initial position
  45195. * @param interaxialDistance defines distance between each color axis
  45196. * @param scene defines the hosting scene
  45197. */
  45198. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45199. /**
  45200. * Gets camera class name
  45201. * @returns AnaglyphGamepadCamera
  45202. */
  45203. getClassName(): string;
  45204. }
  45205. }
  45206. declare module BABYLON {
  45207. /**
  45208. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45209. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45210. */
  45211. export class AnaglyphUniversalCamera extends UniversalCamera {
  45212. /**
  45213. * Creates a new AnaglyphUniversalCamera
  45214. * @param name defines camera name
  45215. * @param position defines initial position
  45216. * @param interaxialDistance defines distance between each color axis
  45217. * @param scene defines the hosting scene
  45218. */
  45219. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45220. /**
  45221. * Gets camera class name
  45222. * @returns AnaglyphUniversalCamera
  45223. */
  45224. getClassName(): string;
  45225. }
  45226. }
  45227. declare module BABYLON {
  45228. /**
  45229. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45230. * @see https://doc.babylonjs.com/features/cameras
  45231. */
  45232. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45233. /**
  45234. * Creates a new StereoscopicArcRotateCamera
  45235. * @param name defines camera name
  45236. * @param alpha defines alpha angle (in radians)
  45237. * @param beta defines beta angle (in radians)
  45238. * @param radius defines radius
  45239. * @param target defines camera target
  45240. * @param interaxialDistance defines distance between each color axis
  45241. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45242. * @param scene defines the hosting scene
  45243. */
  45244. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45245. /**
  45246. * Gets camera class name
  45247. * @returns StereoscopicArcRotateCamera
  45248. */
  45249. getClassName(): string;
  45250. }
  45251. }
  45252. declare module BABYLON {
  45253. /**
  45254. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45255. * @see https://doc.babylonjs.com/features/cameras
  45256. */
  45257. export class StereoscopicFreeCamera extends FreeCamera {
  45258. /**
  45259. * Creates a new StereoscopicFreeCamera
  45260. * @param name defines camera name
  45261. * @param position defines initial position
  45262. * @param interaxialDistance defines distance between each color axis
  45263. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45264. * @param scene defines the hosting scene
  45265. */
  45266. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45267. /**
  45268. * Gets camera class name
  45269. * @returns StereoscopicFreeCamera
  45270. */
  45271. getClassName(): string;
  45272. }
  45273. }
  45274. declare module BABYLON {
  45275. /**
  45276. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45277. * @see https://doc.babylonjs.com/features/cameras
  45278. */
  45279. export class StereoscopicGamepadCamera extends GamepadCamera {
  45280. /**
  45281. * Creates a new StereoscopicGamepadCamera
  45282. * @param name defines camera name
  45283. * @param position defines initial position
  45284. * @param interaxialDistance defines distance between each color axis
  45285. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45286. * @param scene defines the hosting scene
  45287. */
  45288. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45289. /**
  45290. * Gets camera class name
  45291. * @returns StereoscopicGamepadCamera
  45292. */
  45293. getClassName(): string;
  45294. }
  45295. }
  45296. declare module BABYLON {
  45297. /**
  45298. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45299. * @see https://doc.babylonjs.com/features/cameras
  45300. */
  45301. export class StereoscopicUniversalCamera extends UniversalCamera {
  45302. /**
  45303. * Creates a new StereoscopicUniversalCamera
  45304. * @param name defines camera name
  45305. * @param position defines initial position
  45306. * @param interaxialDistance defines distance between each color axis
  45307. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45308. * @param scene defines the hosting scene
  45309. */
  45310. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45311. /**
  45312. * Gets camera class name
  45313. * @returns StereoscopicUniversalCamera
  45314. */
  45315. getClassName(): string;
  45316. }
  45317. }
  45318. declare module BABYLON {
  45319. /**
  45320. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45321. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45322. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45323. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45324. */
  45325. export class VirtualJoysticksCamera extends FreeCamera {
  45326. /**
  45327. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45328. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45329. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45330. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45331. * @param name Define the name of the camera in the scene
  45332. * @param position Define the start position of the camera in the scene
  45333. * @param scene Define the scene the camera belongs to
  45334. */
  45335. constructor(name: string, position: Vector3, scene: Scene);
  45336. /**
  45337. * Gets the current object class name.
  45338. * @return the class name
  45339. */
  45340. getClassName(): string;
  45341. }
  45342. }
  45343. declare module BABYLON {
  45344. /**
  45345. * This represents all the required metrics to create a VR camera.
  45346. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45347. */
  45348. export class VRCameraMetrics {
  45349. /**
  45350. * Define the horizontal resolution off the screen.
  45351. */
  45352. hResolution: number;
  45353. /**
  45354. * Define the vertical resolution off the screen.
  45355. */
  45356. vResolution: number;
  45357. /**
  45358. * Define the horizontal screen size.
  45359. */
  45360. hScreenSize: number;
  45361. /**
  45362. * Define the vertical screen size.
  45363. */
  45364. vScreenSize: number;
  45365. /**
  45366. * Define the vertical screen center position.
  45367. */
  45368. vScreenCenter: number;
  45369. /**
  45370. * Define the distance of the eyes to the screen.
  45371. */
  45372. eyeToScreenDistance: number;
  45373. /**
  45374. * Define the distance between both lenses
  45375. */
  45376. lensSeparationDistance: number;
  45377. /**
  45378. * Define the distance between both viewer's eyes.
  45379. */
  45380. interpupillaryDistance: number;
  45381. /**
  45382. * Define the distortion factor of the VR postprocess.
  45383. * Please, touch with care.
  45384. */
  45385. distortionK: number[];
  45386. /**
  45387. * Define the chromatic aberration correction factors for the VR post process.
  45388. */
  45389. chromaAbCorrection: number[];
  45390. /**
  45391. * Define the scale factor of the post process.
  45392. * The smaller the better but the slower.
  45393. */
  45394. postProcessScaleFactor: number;
  45395. /**
  45396. * Define an offset for the lens center.
  45397. */
  45398. lensCenterOffset: number;
  45399. /**
  45400. * Define if the current vr camera should compensate the distortion of the lense or not.
  45401. */
  45402. compensateDistortion: boolean;
  45403. /**
  45404. * Defines if multiview should be enabled when rendering (Default: false)
  45405. */
  45406. multiviewEnabled: boolean;
  45407. /**
  45408. * Gets the rendering aspect ratio based on the provided resolutions.
  45409. */
  45410. get aspectRatio(): number;
  45411. /**
  45412. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45413. */
  45414. get aspectRatioFov(): number;
  45415. /**
  45416. * @hidden
  45417. */
  45418. get leftHMatrix(): Matrix;
  45419. /**
  45420. * @hidden
  45421. */
  45422. get rightHMatrix(): Matrix;
  45423. /**
  45424. * @hidden
  45425. */
  45426. get leftPreViewMatrix(): Matrix;
  45427. /**
  45428. * @hidden
  45429. */
  45430. get rightPreViewMatrix(): Matrix;
  45431. /**
  45432. * Get the default VRMetrics based on the most generic setup.
  45433. * @returns the default vr metrics
  45434. */
  45435. static GetDefault(): VRCameraMetrics;
  45436. }
  45437. }
  45438. declare module BABYLON {
  45439. /** @hidden */
  45440. export var vrDistortionCorrectionPixelShader: {
  45441. name: string;
  45442. shader: string;
  45443. };
  45444. }
  45445. declare module BABYLON {
  45446. /**
  45447. * VRDistortionCorrectionPostProcess used for mobile VR
  45448. */
  45449. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45450. private _isRightEye;
  45451. private _distortionFactors;
  45452. private _postProcessScaleFactor;
  45453. private _lensCenterOffset;
  45454. private _scaleIn;
  45455. private _scaleFactor;
  45456. private _lensCenter;
  45457. /**
  45458. * Initializes the VRDistortionCorrectionPostProcess
  45459. * @param name The name of the effect.
  45460. * @param camera The camera to apply the render pass to.
  45461. * @param isRightEye If this is for the right eye distortion
  45462. * @param vrMetrics All the required metrics for the VR camera
  45463. */
  45464. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45465. }
  45466. }
  45467. declare module BABYLON {
  45468. /**
  45469. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45470. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45471. */
  45472. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45473. /**
  45474. * Creates a new VRDeviceOrientationArcRotateCamera
  45475. * @param name defines camera name
  45476. * @param alpha defines the camera rotation along the logitudinal axis
  45477. * @param beta defines the camera rotation along the latitudinal axis
  45478. * @param radius defines the camera distance from its target
  45479. * @param target defines the camera target
  45480. * @param scene defines the scene the camera belongs to
  45481. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45482. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45483. */
  45484. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45485. /**
  45486. * Gets camera class name
  45487. * @returns VRDeviceOrientationArcRotateCamera
  45488. */
  45489. getClassName(): string;
  45490. }
  45491. }
  45492. declare module BABYLON {
  45493. /**
  45494. * Camera used to simulate VR rendering (based on FreeCamera)
  45495. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45496. */
  45497. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45498. /**
  45499. * Creates a new VRDeviceOrientationFreeCamera
  45500. * @param name defines camera name
  45501. * @param position defines the start position of the camera
  45502. * @param scene defines the scene the camera belongs to
  45503. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45504. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45505. */
  45506. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45507. /**
  45508. * Gets camera class name
  45509. * @returns VRDeviceOrientationFreeCamera
  45510. */
  45511. getClassName(): string;
  45512. }
  45513. }
  45514. declare module BABYLON {
  45515. /**
  45516. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45517. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45518. */
  45519. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45520. /**
  45521. * Creates a new VRDeviceOrientationGamepadCamera
  45522. * @param name defines camera name
  45523. * @param position defines the start position of the camera
  45524. * @param scene defines the scene the camera belongs to
  45525. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45526. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45527. */
  45528. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45529. /**
  45530. * Gets camera class name
  45531. * @returns VRDeviceOrientationGamepadCamera
  45532. */
  45533. getClassName(): string;
  45534. }
  45535. }
  45536. declare module BABYLON {
  45537. /**
  45538. * A class extending Texture allowing drawing on a texture
  45539. * @see https://doc.babylonjs.com/how_to/dynamictexture
  45540. */
  45541. export class DynamicTexture extends Texture {
  45542. private _generateMipMaps;
  45543. private _canvas;
  45544. private _context;
  45545. /**
  45546. * Creates a DynamicTexture
  45547. * @param name defines the name of the texture
  45548. * @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
  45549. * @param scene defines the scene where you want the texture
  45550. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45551. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  45552. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  45553. */
  45554. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45555. /**
  45556. * Get the current class name of the texture useful for serialization or dynamic coding.
  45557. * @returns "DynamicTexture"
  45558. */
  45559. getClassName(): string;
  45560. /**
  45561. * Gets the current state of canRescale
  45562. */
  45563. get canRescale(): boolean;
  45564. private _recreate;
  45565. /**
  45566. * Scales the texture
  45567. * @param ratio the scale factor to apply to both width and height
  45568. */
  45569. scale(ratio: number): void;
  45570. /**
  45571. * Resizes the texture
  45572. * @param width the new width
  45573. * @param height the new height
  45574. */
  45575. scaleTo(width: number, height: number): void;
  45576. /**
  45577. * Gets the context of the canvas used by the texture
  45578. * @returns the canvas context of the dynamic texture
  45579. */
  45580. getContext(): CanvasRenderingContext2D;
  45581. /**
  45582. * Clears the texture
  45583. */
  45584. clear(): void;
  45585. /**
  45586. * Updates the texture
  45587. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45588. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45589. */
  45590. update(invertY?: boolean, premulAlpha?: boolean): void;
  45591. /**
  45592. * Draws text onto the texture
  45593. * @param text defines the text to be drawn
  45594. * @param x defines the placement of the text from the left
  45595. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45596. * @param font defines the font to be used with font-style, font-size, font-name
  45597. * @param color defines the color used for the text
  45598. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45599. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45600. * @param update defines whether texture is immediately update (default is true)
  45601. */
  45602. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  45603. /**
  45604. * Clones the texture
  45605. * @returns the clone of the texture.
  45606. */
  45607. clone(): DynamicTexture;
  45608. /**
  45609. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45610. * @returns a serialized dynamic texture object
  45611. */
  45612. serialize(): any;
  45613. private _IsCanvasElement;
  45614. /** @hidden */
  45615. _rebuild(): void;
  45616. }
  45617. }
  45618. declare module BABYLON {
  45619. /** @hidden */
  45620. export var imageProcessingPixelShader: {
  45621. name: string;
  45622. shader: string;
  45623. };
  45624. }
  45625. declare module BABYLON {
  45626. /**
  45627. * ImageProcessingPostProcess
  45628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45629. */
  45630. export class ImageProcessingPostProcess extends PostProcess {
  45631. /**
  45632. * Default configuration related to image processing available in the PBR Material.
  45633. */
  45634. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45635. /**
  45636. * Gets the image processing configuration used either in this material.
  45637. */
  45638. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45639. /**
  45640. * Sets the Default image processing configuration used either in the this material.
  45641. *
  45642. * If sets to null, the scene one is in use.
  45643. */
  45644. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45645. /**
  45646. * Keep track of the image processing observer to allow dispose and replace.
  45647. */
  45648. private _imageProcessingObserver;
  45649. /**
  45650. * Attaches a new image processing configuration to the PBR Material.
  45651. * @param configuration
  45652. */
  45653. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45654. /**
  45655. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45656. */
  45657. get colorCurves(): Nullable<ColorCurves>;
  45658. /**
  45659. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45660. */
  45661. set colorCurves(value: Nullable<ColorCurves>);
  45662. /**
  45663. * Gets wether the color curves effect is enabled.
  45664. */
  45665. get colorCurvesEnabled(): boolean;
  45666. /**
  45667. * Sets wether the color curves effect is enabled.
  45668. */
  45669. set colorCurvesEnabled(value: boolean);
  45670. /**
  45671. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45672. */
  45673. get colorGradingTexture(): Nullable<BaseTexture>;
  45674. /**
  45675. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45676. */
  45677. set colorGradingTexture(value: Nullable<BaseTexture>);
  45678. /**
  45679. * Gets wether the color grading effect is enabled.
  45680. */
  45681. get colorGradingEnabled(): boolean;
  45682. /**
  45683. * Gets wether the color grading effect is enabled.
  45684. */
  45685. set colorGradingEnabled(value: boolean);
  45686. /**
  45687. * Gets exposure used in the effect.
  45688. */
  45689. get exposure(): number;
  45690. /**
  45691. * Sets exposure used in the effect.
  45692. */
  45693. set exposure(value: number);
  45694. /**
  45695. * Gets wether tonemapping is enabled or not.
  45696. */
  45697. get toneMappingEnabled(): boolean;
  45698. /**
  45699. * Sets wether tonemapping is enabled or not
  45700. */
  45701. set toneMappingEnabled(value: boolean);
  45702. /**
  45703. * Gets the type of tone mapping effect.
  45704. */
  45705. get toneMappingType(): number;
  45706. /**
  45707. * Sets the type of tone mapping effect.
  45708. */
  45709. set toneMappingType(value: number);
  45710. /**
  45711. * Gets contrast used in the effect.
  45712. */
  45713. get contrast(): number;
  45714. /**
  45715. * Sets contrast used in the effect.
  45716. */
  45717. set contrast(value: number);
  45718. /**
  45719. * Gets Vignette stretch size.
  45720. */
  45721. get vignetteStretch(): number;
  45722. /**
  45723. * Sets Vignette stretch size.
  45724. */
  45725. set vignetteStretch(value: number);
  45726. /**
  45727. * Gets Vignette centre X Offset.
  45728. */
  45729. get vignetteCentreX(): number;
  45730. /**
  45731. * Sets Vignette centre X Offset.
  45732. */
  45733. set vignetteCentreX(value: number);
  45734. /**
  45735. * Gets Vignette centre Y Offset.
  45736. */
  45737. get vignetteCentreY(): number;
  45738. /**
  45739. * Sets Vignette centre Y Offset.
  45740. */
  45741. set vignetteCentreY(value: number);
  45742. /**
  45743. * Gets Vignette weight or intensity of the vignette effect.
  45744. */
  45745. get vignetteWeight(): number;
  45746. /**
  45747. * Sets Vignette weight or intensity of the vignette effect.
  45748. */
  45749. set vignetteWeight(value: number);
  45750. /**
  45751. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45752. * if vignetteEnabled is set to true.
  45753. */
  45754. get vignetteColor(): Color4;
  45755. /**
  45756. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45757. * if vignetteEnabled is set to true.
  45758. */
  45759. set vignetteColor(value: Color4);
  45760. /**
  45761. * Gets Camera field of view used by the Vignette effect.
  45762. */
  45763. get vignetteCameraFov(): number;
  45764. /**
  45765. * Sets Camera field of view used by the Vignette effect.
  45766. */
  45767. set vignetteCameraFov(value: number);
  45768. /**
  45769. * Gets the vignette blend mode allowing different kind of effect.
  45770. */
  45771. get vignetteBlendMode(): number;
  45772. /**
  45773. * Sets the vignette blend mode allowing different kind of effect.
  45774. */
  45775. set vignetteBlendMode(value: number);
  45776. /**
  45777. * Gets wether the vignette effect is enabled.
  45778. */
  45779. get vignetteEnabled(): boolean;
  45780. /**
  45781. * Sets wether the vignette effect is enabled.
  45782. */
  45783. set vignetteEnabled(value: boolean);
  45784. private _fromLinearSpace;
  45785. /**
  45786. * Gets wether the input of the processing is in Gamma or Linear Space.
  45787. */
  45788. get fromLinearSpace(): boolean;
  45789. /**
  45790. * Sets wether the input of the processing is in Gamma or Linear Space.
  45791. */
  45792. set fromLinearSpace(value: boolean);
  45793. /**
  45794. * Defines cache preventing GC.
  45795. */
  45796. private _defines;
  45797. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45798. /**
  45799. * "ImageProcessingPostProcess"
  45800. * @returns "ImageProcessingPostProcess"
  45801. */
  45802. getClassName(): string;
  45803. protected _updateParameters(): void;
  45804. dispose(camera?: Camera): void;
  45805. }
  45806. }
  45807. declare module BABYLON {
  45808. /**
  45809. * Class containing static functions to help procedurally build meshes
  45810. */
  45811. export class GroundBuilder {
  45812. /**
  45813. * Creates a ground mesh
  45814. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45815. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45817. * @param name defines the name of the mesh
  45818. * @param options defines the options used to create the mesh
  45819. * @param scene defines the hosting scene
  45820. * @returns the ground mesh
  45821. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45822. */
  45823. static CreateGround(name: string, options: {
  45824. width?: number;
  45825. height?: number;
  45826. subdivisions?: number;
  45827. subdivisionsX?: number;
  45828. subdivisionsY?: number;
  45829. updatable?: boolean;
  45830. }, scene: any): Mesh;
  45831. /**
  45832. * Creates a tiled ground mesh
  45833. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45834. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45835. * * 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
  45836. * * 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
  45837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45838. * @param name defines the name of the mesh
  45839. * @param options defines the options used to create the mesh
  45840. * @param scene defines the hosting scene
  45841. * @returns the tiled ground mesh
  45842. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45843. */
  45844. static CreateTiledGround(name: string, options: {
  45845. xmin: number;
  45846. zmin: number;
  45847. xmax: number;
  45848. zmax: number;
  45849. subdivisions?: {
  45850. w: number;
  45851. h: number;
  45852. };
  45853. precision?: {
  45854. w: number;
  45855. h: number;
  45856. };
  45857. updatable?: boolean;
  45858. }, scene?: Nullable<Scene>): Mesh;
  45859. /**
  45860. * Creates a ground mesh from a height map
  45861. * * The parameter `url` sets the URL of the height map image resource.
  45862. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45863. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45864. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45865. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45866. * * 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.
  45867. * * 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).
  45868. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45870. * @param name defines the name of the mesh
  45871. * @param url defines the url to the height map
  45872. * @param options defines the options used to create the mesh
  45873. * @param scene defines the hosting scene
  45874. * @returns the ground mesh
  45875. * @see https://doc.babylonjs.com/babylon101/height_map
  45876. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45877. */
  45878. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45879. width?: number;
  45880. height?: number;
  45881. subdivisions?: number;
  45882. minHeight?: number;
  45883. maxHeight?: number;
  45884. colorFilter?: Color3;
  45885. alphaFilter?: number;
  45886. updatable?: boolean;
  45887. onReady?: (mesh: GroundMesh) => void;
  45888. }, scene?: Nullable<Scene>): GroundMesh;
  45889. }
  45890. }
  45891. declare module BABYLON {
  45892. /**
  45893. * Class containing static functions to help procedurally build meshes
  45894. */
  45895. export class TorusBuilder {
  45896. /**
  45897. * Creates a torus mesh
  45898. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45899. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45900. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45902. * * 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
  45903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45904. * @param name defines the name of the mesh
  45905. * @param options defines the options used to create the mesh
  45906. * @param scene defines the hosting scene
  45907. * @returns the torus mesh
  45908. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45909. */
  45910. static CreateTorus(name: string, options: {
  45911. diameter?: number;
  45912. thickness?: number;
  45913. tessellation?: number;
  45914. updatable?: boolean;
  45915. sideOrientation?: number;
  45916. frontUVs?: Vector4;
  45917. backUVs?: Vector4;
  45918. }, scene: any): Mesh;
  45919. }
  45920. }
  45921. declare module BABYLON {
  45922. /**
  45923. * Class containing static functions to help procedurally build meshes
  45924. */
  45925. export class CylinderBuilder {
  45926. /**
  45927. * Creates a cylinder or a cone mesh
  45928. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45929. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45930. * * 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.
  45931. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45932. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45933. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45934. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45935. * * 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).
  45936. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45937. * * 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).
  45938. * * 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
  45939. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45940. * * 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
  45941. * * 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.
  45942. * * If `enclose` is false, a ring surface is one element.
  45943. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45944. * * 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
  45945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45946. * * 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
  45947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45948. * @param name defines the name of the mesh
  45949. * @param options defines the options used to create the mesh
  45950. * @param scene defines the hosting scene
  45951. * @returns the cylinder mesh
  45952. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45953. */
  45954. static CreateCylinder(name: string, options: {
  45955. height?: number;
  45956. diameterTop?: number;
  45957. diameterBottom?: number;
  45958. diameter?: number;
  45959. tessellation?: number;
  45960. subdivisions?: number;
  45961. arc?: number;
  45962. faceColors?: Color4[];
  45963. faceUV?: Vector4[];
  45964. updatable?: boolean;
  45965. hasRings?: boolean;
  45966. enclose?: boolean;
  45967. cap?: number;
  45968. sideOrientation?: number;
  45969. frontUVs?: Vector4;
  45970. backUVs?: Vector4;
  45971. }, scene: any): Mesh;
  45972. }
  45973. }
  45974. declare module BABYLON {
  45975. /**
  45976. * States of the webXR experience
  45977. */
  45978. export enum WebXRState {
  45979. /**
  45980. * Transitioning to being in XR mode
  45981. */
  45982. ENTERING_XR = 0,
  45983. /**
  45984. * Transitioning to non XR mode
  45985. */
  45986. EXITING_XR = 1,
  45987. /**
  45988. * In XR mode and presenting
  45989. */
  45990. IN_XR = 2,
  45991. /**
  45992. * Not entered XR mode
  45993. */
  45994. NOT_IN_XR = 3
  45995. }
  45996. /**
  45997. * Abstraction of the XR render target
  45998. */
  45999. export interface WebXRRenderTarget extends IDisposable {
  46000. /**
  46001. * xrpresent context of the canvas which can be used to display/mirror xr content
  46002. */
  46003. canvasContext: WebGLRenderingContext;
  46004. /**
  46005. * xr layer for the canvas
  46006. */
  46007. xrLayer: Nullable<XRWebGLLayer>;
  46008. /**
  46009. * Initializes the xr layer for the session
  46010. * @param xrSession xr session
  46011. * @returns a promise that will resolve once the XR Layer has been created
  46012. */
  46013. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46014. }
  46015. }
  46016. declare module BABYLON {
  46017. /**
  46018. * COnfiguration object for WebXR output canvas
  46019. */
  46020. export class WebXRManagedOutputCanvasOptions {
  46021. /**
  46022. * An optional canvas in case you wish to create it yourself and provide it here.
  46023. * If not provided, a new canvas will be created
  46024. */
  46025. canvasElement?: HTMLCanvasElement;
  46026. /**
  46027. * Options for this XR Layer output
  46028. */
  46029. canvasOptions?: XRWebGLLayerOptions;
  46030. /**
  46031. * CSS styling for a newly created canvas (if not provided)
  46032. */
  46033. newCanvasCssStyle?: string;
  46034. /**
  46035. * Get the default values of the configuration object
  46036. * @returns default values of this configuration object
  46037. */
  46038. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46039. }
  46040. /**
  46041. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46042. */
  46043. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46044. private _options;
  46045. private _canvas;
  46046. private _engine;
  46047. private _originalCanvasSize;
  46048. /**
  46049. * Rendering context of the canvas which can be used to display/mirror xr content
  46050. */
  46051. canvasContext: WebGLRenderingContext;
  46052. /**
  46053. * xr layer for the canvas
  46054. */
  46055. xrLayer: Nullable<XRWebGLLayer>;
  46056. /**
  46057. * Obseervers registered here will be triggered when the xr layer was initialized
  46058. */
  46059. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46060. /**
  46061. * Initializes the canvas to be added/removed upon entering/exiting xr
  46062. * @param _xrSessionManager The XR Session manager
  46063. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46064. */
  46065. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46066. /**
  46067. * Disposes of the object
  46068. */
  46069. dispose(): void;
  46070. /**
  46071. * Initializes the xr layer for the session
  46072. * @param xrSession xr session
  46073. * @returns a promise that will resolve once the XR Layer has been created
  46074. */
  46075. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46076. private _addCanvas;
  46077. private _removeCanvas;
  46078. private _setCanvasSize;
  46079. private _setManagedOutputCanvas;
  46080. }
  46081. }
  46082. declare module BABYLON {
  46083. /**
  46084. * Manages an XRSession to work with Babylon's engine
  46085. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46086. */
  46087. export class WebXRSessionManager implements IDisposable {
  46088. /** The scene which the session should be created for */
  46089. scene: Scene;
  46090. private _referenceSpace;
  46091. private _rttProvider;
  46092. private _sessionEnded;
  46093. private _xrNavigator;
  46094. private baseLayer;
  46095. /**
  46096. * The base reference space from which the session started. good if you want to reset your
  46097. * reference space
  46098. */
  46099. baseReferenceSpace: XRReferenceSpace;
  46100. /**
  46101. * Current XR frame
  46102. */
  46103. currentFrame: Nullable<XRFrame>;
  46104. /** WebXR timestamp updated every frame */
  46105. currentTimestamp: number;
  46106. /**
  46107. * Used just in case of a failure to initialize an immersive session.
  46108. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46109. */
  46110. defaultHeightCompensation: number;
  46111. /**
  46112. * Fires every time a new xrFrame arrives which can be used to update the camera
  46113. */
  46114. onXRFrameObservable: Observable<XRFrame>;
  46115. /**
  46116. * Fires when the reference space changed
  46117. */
  46118. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46119. /**
  46120. * Fires when the xr session is ended either by the device or manually done
  46121. */
  46122. onXRSessionEnded: Observable<any>;
  46123. /**
  46124. * Fires when the xr session is ended either by the device or manually done
  46125. */
  46126. onXRSessionInit: Observable<XRSession>;
  46127. /**
  46128. * Underlying xr session
  46129. */
  46130. session: XRSession;
  46131. /**
  46132. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46133. * or get the offset the player is currently at.
  46134. */
  46135. viewerReferenceSpace: XRReferenceSpace;
  46136. /**
  46137. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46138. * @param scene The scene which the session should be created for
  46139. */
  46140. constructor(
  46141. /** The scene which the session should be created for */
  46142. scene: Scene);
  46143. /**
  46144. * The current reference space used in this session. This reference space can constantly change!
  46145. * It is mainly used to offset the camera's position.
  46146. */
  46147. get referenceSpace(): XRReferenceSpace;
  46148. /**
  46149. * Set a new reference space and triggers the observable
  46150. */
  46151. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46152. /**
  46153. * Disposes of the session manager
  46154. */
  46155. dispose(): void;
  46156. /**
  46157. * Stops the xrSession and restores the render loop
  46158. * @returns Promise which resolves after it exits XR
  46159. */
  46160. exitXRAsync(): Promise<void>;
  46161. /**
  46162. * Gets the correct render target texture to be rendered this frame for this eye
  46163. * @param eye the eye for which to get the render target
  46164. * @returns the render target for the specified eye
  46165. */
  46166. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46167. /**
  46168. * Creates a WebXRRenderTarget object for the XR session
  46169. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46170. * @param options optional options to provide when creating a new render target
  46171. * @returns a WebXR render target to which the session can render
  46172. */
  46173. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46174. /**
  46175. * Initializes the manager
  46176. * After initialization enterXR can be called to start an XR session
  46177. * @returns Promise which resolves after it is initialized
  46178. */
  46179. initializeAsync(): Promise<void>;
  46180. /**
  46181. * Initializes an xr session
  46182. * @param xrSessionMode mode to initialize
  46183. * @param xrSessionInit defines optional and required values to pass to the session builder
  46184. * @returns a promise which will resolve once the session has been initialized
  46185. */
  46186. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46187. /**
  46188. * Checks if a session would be supported for the creation options specified
  46189. * @param sessionMode session mode to check if supported eg. immersive-vr
  46190. * @returns A Promise that resolves to true if supported and false if not
  46191. */
  46192. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46193. /**
  46194. * Resets the reference space to the one started the session
  46195. */
  46196. resetReferenceSpace(): void;
  46197. /**
  46198. * Starts rendering to the xr layer
  46199. */
  46200. runXRRenderLoop(): void;
  46201. /**
  46202. * Sets the reference space on the xr session
  46203. * @param referenceSpaceType space to set
  46204. * @returns a promise that will resolve once the reference space has been set
  46205. */
  46206. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46207. /**
  46208. * Updates the render state of the session
  46209. * @param state state to set
  46210. * @returns a promise that resolves once the render state has been updated
  46211. */
  46212. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46213. /**
  46214. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46215. * @param sessionMode defines the session to test
  46216. * @returns a promise with boolean as final value
  46217. */
  46218. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46219. private _createRenderTargetTexture;
  46220. }
  46221. }
  46222. declare module BABYLON {
  46223. /**
  46224. * WebXR Camera which holds the views for the xrSession
  46225. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46226. */
  46227. export class WebXRCamera extends FreeCamera {
  46228. private _xrSessionManager;
  46229. private _firstFrame;
  46230. private _referenceQuaternion;
  46231. private _referencedPosition;
  46232. private _xrInvPositionCache;
  46233. private _xrInvQuaternionCache;
  46234. /**
  46235. * Should position compensation execute on first frame.
  46236. * This is used when copying the position from a native (non XR) camera
  46237. */
  46238. compensateOnFirstFrame: boolean;
  46239. /**
  46240. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46241. * @param name the name of the camera
  46242. * @param scene the scene to add the camera to
  46243. * @param _xrSessionManager a constructed xr session manager
  46244. */
  46245. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46246. /**
  46247. * Return the user's height, unrelated to the current ground.
  46248. * This will be the y position of this camera, when ground level is 0.
  46249. */
  46250. get realWorldHeight(): number;
  46251. /** @hidden */
  46252. _updateForDualEyeDebugging(): void;
  46253. /**
  46254. * Sets this camera's transformation based on a non-vr camera
  46255. * @param otherCamera the non-vr camera to copy the transformation from
  46256. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46257. */
  46258. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46259. /**
  46260. * Gets the current instance class name ("WebXRCamera").
  46261. * @returns the class name
  46262. */
  46263. getClassName(): string;
  46264. /**
  46265. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46266. */
  46267. _getViewMatrix(): Matrix;
  46268. private _rotate180;
  46269. private _updateFromXRSession;
  46270. private _updateNumberOfRigCameras;
  46271. private _updateReferenceSpace;
  46272. private _updateReferenceSpaceOffset;
  46273. }
  46274. }
  46275. declare module BABYLON {
  46276. /**
  46277. * Defining the interface required for a (webxr) feature
  46278. */
  46279. export interface IWebXRFeature extends IDisposable {
  46280. /**
  46281. * Is this feature attached
  46282. */
  46283. attached: boolean;
  46284. /**
  46285. * Should auto-attach be disabled?
  46286. */
  46287. disableAutoAttach: boolean;
  46288. /**
  46289. * Attach the feature to the session
  46290. * Will usually be called by the features manager
  46291. *
  46292. * @param force should attachment be forced (even when already attached)
  46293. * @returns true if successful.
  46294. */
  46295. attach(force?: boolean): boolean;
  46296. /**
  46297. * Detach the feature from the session
  46298. * Will usually be called by the features manager
  46299. *
  46300. * @returns true if successful.
  46301. */
  46302. detach(): boolean;
  46303. }
  46304. /**
  46305. * A list of the currently available features without referencing them
  46306. */
  46307. export class WebXRFeatureName {
  46308. /**
  46309. * The name of the anchor system feature
  46310. */
  46311. static ANCHOR_SYSTEM: string;
  46312. /**
  46313. * The name of the background remover feature
  46314. */
  46315. static BACKGROUND_REMOVER: string;
  46316. /**
  46317. * The name of the hit test feature
  46318. */
  46319. static HIT_TEST: string;
  46320. /**
  46321. * physics impostors for xr controllers feature
  46322. */
  46323. static PHYSICS_CONTROLLERS: string;
  46324. /**
  46325. * The name of the plane detection feature
  46326. */
  46327. static PLANE_DETECTION: string;
  46328. /**
  46329. * The name of the pointer selection feature
  46330. */
  46331. static POINTER_SELECTION: string;
  46332. /**
  46333. * The name of the teleportation feature
  46334. */
  46335. static TELEPORTATION: string;
  46336. }
  46337. /**
  46338. * Defining the constructor of a feature. Used to register the modules.
  46339. */
  46340. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46341. /**
  46342. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46343. * It is mainly used in AR sessions.
  46344. *
  46345. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46346. */
  46347. export class WebXRFeaturesManager implements IDisposable {
  46348. private _xrSessionManager;
  46349. private static readonly _AvailableFeatures;
  46350. private _features;
  46351. /**
  46352. * constructs a new features manages.
  46353. *
  46354. * @param _xrSessionManager an instance of WebXRSessionManager
  46355. */
  46356. constructor(_xrSessionManager: WebXRSessionManager);
  46357. /**
  46358. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46359. * Mainly used internally.
  46360. *
  46361. * @param featureName the name of the feature to register
  46362. * @param constructorFunction the function used to construct the module
  46363. * @param version the (babylon) version of the module
  46364. * @param stable is that a stable version of this module
  46365. */
  46366. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46367. /**
  46368. * Returns a constructor of a specific feature.
  46369. *
  46370. * @param featureName the name of the feature to construct
  46371. * @param version the version of the feature to load
  46372. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46373. * @param options optional options provided to the module.
  46374. * @returns a function that, when called, will return a new instance of this feature
  46375. */
  46376. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46377. /**
  46378. * Can be used to return the list of features currently registered
  46379. *
  46380. * @returns an Array of available features
  46381. */
  46382. static GetAvailableFeatures(): string[];
  46383. /**
  46384. * Gets the versions available for a specific feature
  46385. * @param featureName the name of the feature
  46386. * @returns an array with the available versions
  46387. */
  46388. static GetAvailableVersions(featureName: string): string[];
  46389. /**
  46390. * Return the latest unstable version of this feature
  46391. * @param featureName the name of the feature to search
  46392. * @returns the version number. if not found will return -1
  46393. */
  46394. static GetLatestVersionOfFeature(featureName: string): number;
  46395. /**
  46396. * Return the latest stable version of this feature
  46397. * @param featureName the name of the feature to search
  46398. * @returns the version number. if not found will return -1
  46399. */
  46400. static GetStableVersionOfFeature(featureName: string): number;
  46401. /**
  46402. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46403. * Can be used during a session to start a feature
  46404. * @param featureName the name of feature to attach
  46405. */
  46406. attachFeature(featureName: string): void;
  46407. /**
  46408. * Can be used inside a session or when the session ends to detach a specific feature
  46409. * @param featureName the name of the feature to detach
  46410. */
  46411. detachFeature(featureName: string): void;
  46412. /**
  46413. * Used to disable an already-enabled feature
  46414. * The feature will be disposed and will be recreated once enabled.
  46415. * @param featureName the feature to disable
  46416. * @returns true if disable was successful
  46417. */
  46418. disableFeature(featureName: string | {
  46419. Name: string;
  46420. }): boolean;
  46421. /**
  46422. * dispose this features manager
  46423. */
  46424. dispose(): void;
  46425. /**
  46426. * 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.
  46427. * 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.
  46428. *
  46429. * @param featureName the name of the feature to load or the class of the feature
  46430. * @param version optional version to load. if not provided the latest version will be enabled
  46431. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46432. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46433. * @returns a new constructed feature or throws an error if feature not found.
  46434. */
  46435. enableFeature(featureName: string | {
  46436. Name: string;
  46437. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46438. /**
  46439. * get the implementation of an enabled feature.
  46440. * @param featureName the name of the feature to load
  46441. * @returns the feature class, if found
  46442. */
  46443. getEnabledFeature(featureName: string): IWebXRFeature;
  46444. /**
  46445. * Get the list of enabled features
  46446. * @returns an array of enabled features
  46447. */
  46448. getEnabledFeatures(): string[];
  46449. }
  46450. }
  46451. declare module BABYLON {
  46452. /**
  46453. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46454. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  46455. */
  46456. export class WebXRExperienceHelper implements IDisposable {
  46457. private scene;
  46458. private _nonVRCamera;
  46459. private _originalSceneAutoClear;
  46460. private _supported;
  46461. /**
  46462. * Camera used to render xr content
  46463. */
  46464. camera: WebXRCamera;
  46465. /** A features manager for this xr session */
  46466. featuresManager: WebXRFeaturesManager;
  46467. /**
  46468. * Observers registered here will be triggered after the camera's initial transformation is set
  46469. * This can be used to set a different ground level or an extra rotation.
  46470. *
  46471. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46472. * to the position set after this observable is done executing.
  46473. */
  46474. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46475. /**
  46476. * Fires when the state of the experience helper has changed
  46477. */
  46478. onStateChangedObservable: Observable<WebXRState>;
  46479. /** Session manager used to keep track of xr session */
  46480. sessionManager: WebXRSessionManager;
  46481. /**
  46482. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46483. */
  46484. state: WebXRState;
  46485. /**
  46486. * Creates a WebXRExperienceHelper
  46487. * @param scene The scene the helper should be created in
  46488. */
  46489. private constructor();
  46490. /**
  46491. * Creates the experience helper
  46492. * @param scene the scene to attach the experience helper to
  46493. * @returns a promise for the experience helper
  46494. */
  46495. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46496. /**
  46497. * Disposes of the experience helper
  46498. */
  46499. dispose(): void;
  46500. /**
  46501. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46502. * @param sessionMode options for the XR session
  46503. * @param referenceSpaceType frame of reference of the XR session
  46504. * @param renderTarget the output canvas that will be used to enter XR mode
  46505. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46506. * @returns promise that resolves after xr mode has entered
  46507. */
  46508. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46509. /**
  46510. * Exits XR mode and returns the scene to its original state
  46511. * @returns promise that resolves after xr mode has exited
  46512. */
  46513. exitXRAsync(): Promise<void>;
  46514. private _nonXRToXRCamera;
  46515. private _setState;
  46516. }
  46517. }
  46518. declare module BABYLON {
  46519. /**
  46520. * X-Y values for axes in WebXR
  46521. */
  46522. export interface IWebXRMotionControllerAxesValue {
  46523. /**
  46524. * The value of the x axis
  46525. */
  46526. x: number;
  46527. /**
  46528. * The value of the y-axis
  46529. */
  46530. y: number;
  46531. }
  46532. /**
  46533. * changed / previous values for the values of this component
  46534. */
  46535. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46536. /**
  46537. * current (this frame) value
  46538. */
  46539. current: T;
  46540. /**
  46541. * previous (last change) value
  46542. */
  46543. previous: T;
  46544. }
  46545. /**
  46546. * Represents changes in the component between current frame and last values recorded
  46547. */
  46548. export interface IWebXRMotionControllerComponentChanges {
  46549. /**
  46550. * will be populated with previous and current values if axes changed
  46551. */
  46552. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46553. /**
  46554. * will be populated with previous and current values if pressed changed
  46555. */
  46556. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46557. /**
  46558. * will be populated with previous and current values if touched changed
  46559. */
  46560. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46561. /**
  46562. * will be populated with previous and current values if value changed
  46563. */
  46564. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46565. }
  46566. /**
  46567. * This class represents a single component (for example button or thumbstick) of a motion controller
  46568. */
  46569. export class WebXRControllerComponent implements IDisposable {
  46570. /**
  46571. * the id of this component
  46572. */
  46573. id: string;
  46574. /**
  46575. * the type of the component
  46576. */
  46577. type: MotionControllerComponentType;
  46578. private _buttonIndex;
  46579. private _axesIndices;
  46580. private _axes;
  46581. private _changes;
  46582. private _currentValue;
  46583. private _hasChanges;
  46584. private _pressed;
  46585. private _touched;
  46586. /**
  46587. * button component type
  46588. */
  46589. static BUTTON_TYPE: MotionControllerComponentType;
  46590. /**
  46591. * squeeze component type
  46592. */
  46593. static SQUEEZE_TYPE: MotionControllerComponentType;
  46594. /**
  46595. * Thumbstick component type
  46596. */
  46597. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46598. /**
  46599. * Touchpad component type
  46600. */
  46601. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46602. /**
  46603. * trigger component type
  46604. */
  46605. static TRIGGER_TYPE: MotionControllerComponentType;
  46606. /**
  46607. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46608. * the axes data changes
  46609. */
  46610. onAxisValueChangedObservable: Observable<{
  46611. x: number;
  46612. y: number;
  46613. }>;
  46614. /**
  46615. * Observers registered here will be triggered when the state of a button changes
  46616. * State change is either pressed / touched / value
  46617. */
  46618. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46619. /**
  46620. * Creates a new component for a motion controller.
  46621. * It is created by the motion controller itself
  46622. *
  46623. * @param id the id of this component
  46624. * @param type the type of the component
  46625. * @param _buttonIndex index in the buttons array of the gamepad
  46626. * @param _axesIndices indices of the values in the axes array of the gamepad
  46627. */
  46628. constructor(
  46629. /**
  46630. * the id of this component
  46631. */
  46632. id: string,
  46633. /**
  46634. * the type of the component
  46635. */
  46636. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46637. /**
  46638. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46639. */
  46640. get axes(): IWebXRMotionControllerAxesValue;
  46641. /**
  46642. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46643. */
  46644. get changes(): IWebXRMotionControllerComponentChanges;
  46645. /**
  46646. * Return whether or not the component changed the last frame
  46647. */
  46648. get hasChanges(): boolean;
  46649. /**
  46650. * is the button currently pressed
  46651. */
  46652. get pressed(): boolean;
  46653. /**
  46654. * is the button currently touched
  46655. */
  46656. get touched(): boolean;
  46657. /**
  46658. * Get the current value of this component
  46659. */
  46660. get value(): number;
  46661. /**
  46662. * Dispose this component
  46663. */
  46664. dispose(): void;
  46665. /**
  46666. * Are there axes correlating to this component
  46667. * @return true is axes data is available
  46668. */
  46669. isAxes(): boolean;
  46670. /**
  46671. * Is this component a button (hence - pressable)
  46672. * @returns true if can be pressed
  46673. */
  46674. isButton(): boolean;
  46675. /**
  46676. * update this component using the gamepad object it is in. Called on every frame
  46677. * @param nativeController the native gamepad controller object
  46678. */
  46679. update(nativeController: IMinimalMotionControllerObject): void;
  46680. }
  46681. }
  46682. declare module BABYLON {
  46683. /**
  46684. * Interface used to represent data loading progression
  46685. */
  46686. export interface ISceneLoaderProgressEvent {
  46687. /**
  46688. * Defines if data length to load can be evaluated
  46689. */
  46690. readonly lengthComputable: boolean;
  46691. /**
  46692. * Defines the loaded data length
  46693. */
  46694. readonly loaded: number;
  46695. /**
  46696. * Defines the data length to load
  46697. */
  46698. readonly total: number;
  46699. }
  46700. /**
  46701. * Interface used by SceneLoader plugins to define supported file extensions
  46702. */
  46703. export interface ISceneLoaderPluginExtensions {
  46704. /**
  46705. * Defines the list of supported extensions
  46706. */
  46707. [extension: string]: {
  46708. isBinary: boolean;
  46709. };
  46710. }
  46711. /**
  46712. * Interface used by SceneLoader plugin factory
  46713. */
  46714. export interface ISceneLoaderPluginFactory {
  46715. /**
  46716. * Defines the name of the factory
  46717. */
  46718. name: string;
  46719. /**
  46720. * Function called to create a new plugin
  46721. * @return the new plugin
  46722. */
  46723. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46724. /**
  46725. * The callback that returns true if the data can be directly loaded.
  46726. * @param data string containing the file data
  46727. * @returns if the data can be loaded directly
  46728. */
  46729. canDirectLoad?(data: string): boolean;
  46730. }
  46731. /**
  46732. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46733. */
  46734. export interface ISceneLoaderPluginBase {
  46735. /**
  46736. * The friendly name of this plugin.
  46737. */
  46738. name: string;
  46739. /**
  46740. * The file extensions supported by this plugin.
  46741. */
  46742. extensions: string | ISceneLoaderPluginExtensions;
  46743. /**
  46744. * The callback called when loading from a url.
  46745. * @param scene scene loading this url
  46746. * @param url url to load
  46747. * @param onSuccess callback called when the file successfully loads
  46748. * @param onProgress callback called while file is loading (if the server supports this mode)
  46749. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46750. * @param onError callback called when the file fails to load
  46751. * @returns a file request object
  46752. */
  46753. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46754. /**
  46755. * The callback called when loading from a file object.
  46756. * @param scene scene loading this file
  46757. * @param file defines the file to load
  46758. * @param onSuccess defines the callback to call when data is loaded
  46759. * @param onProgress defines the callback to call during loading process
  46760. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46761. * @param onError defines the callback to call when an error occurs
  46762. * @returns a file request object
  46763. */
  46764. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46765. /**
  46766. * The callback that returns true if the data can be directly loaded.
  46767. * @param data string containing the file data
  46768. * @returns if the data can be loaded directly
  46769. */
  46770. canDirectLoad?(data: string): boolean;
  46771. /**
  46772. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46773. * @param scene scene loading this data
  46774. * @param data string containing the data
  46775. * @returns data to pass to the plugin
  46776. */
  46777. directLoad?(scene: Scene, data: string): any;
  46778. /**
  46779. * The callback that allows custom handling of the root url based on the response url.
  46780. * @param rootUrl the original root url
  46781. * @param responseURL the response url if available
  46782. * @returns the new root url
  46783. */
  46784. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46785. }
  46786. /**
  46787. * Interface used to define a SceneLoader plugin
  46788. */
  46789. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46790. /**
  46791. * Import meshes into a scene.
  46792. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46793. * @param scene The scene to import into
  46794. * @param data The data to import
  46795. * @param rootUrl The root url for scene and resources
  46796. * @param meshes The meshes array to import into
  46797. * @param particleSystems The particle systems array to import into
  46798. * @param skeletons The skeletons array to import into
  46799. * @param onError The callback when import fails
  46800. * @returns True if successful or false otherwise
  46801. */
  46802. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46803. /**
  46804. * Load into a scene.
  46805. * @param scene The scene to load into
  46806. * @param data The data to import
  46807. * @param rootUrl The root url for scene and resources
  46808. * @param onError The callback when import fails
  46809. * @returns True if successful or false otherwise
  46810. */
  46811. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46812. /**
  46813. * Load into an asset container.
  46814. * @param scene The scene to load into
  46815. * @param data The data to import
  46816. * @param rootUrl The root url for scene and resources
  46817. * @param onError The callback when import fails
  46818. * @returns The loaded asset container
  46819. */
  46820. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46821. }
  46822. /**
  46823. * Interface used to define an async SceneLoader plugin
  46824. */
  46825. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46826. /**
  46827. * Import meshes into a scene.
  46828. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46829. * @param scene The scene to import into
  46830. * @param data The data to import
  46831. * @param rootUrl The root url for scene and resources
  46832. * @param onProgress The callback when the load progresses
  46833. * @param fileName Defines the name of the file to load
  46834. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46835. */
  46836. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46837. meshes: AbstractMesh[];
  46838. particleSystems: IParticleSystem[];
  46839. skeletons: Skeleton[];
  46840. animationGroups: AnimationGroup[];
  46841. }>;
  46842. /**
  46843. * Load into a scene.
  46844. * @param scene The scene to load into
  46845. * @param data The data to import
  46846. * @param rootUrl The root url for scene and resources
  46847. * @param onProgress The callback when the load progresses
  46848. * @param fileName Defines the name of the file to load
  46849. * @returns Nothing
  46850. */
  46851. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46852. /**
  46853. * Load into an asset container.
  46854. * @param scene The scene to load into
  46855. * @param data The data to import
  46856. * @param rootUrl The root url for scene and resources
  46857. * @param onProgress The callback when the load progresses
  46858. * @param fileName Defines the name of the file to load
  46859. * @returns The loaded asset container
  46860. */
  46861. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46862. }
  46863. /**
  46864. * Mode that determines how to handle old animation groups before loading new ones.
  46865. */
  46866. export enum SceneLoaderAnimationGroupLoadingMode {
  46867. /**
  46868. * Reset all old animations to initial state then dispose them.
  46869. */
  46870. Clean = 0,
  46871. /**
  46872. * Stop all old animations.
  46873. */
  46874. Stop = 1,
  46875. /**
  46876. * Restart old animations from first frame.
  46877. */
  46878. Sync = 2,
  46879. /**
  46880. * Old animations remains untouched.
  46881. */
  46882. NoSync = 3
  46883. }
  46884. /**
  46885. * Class used to load scene from various file formats using registered plugins
  46886. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  46887. */
  46888. export class SceneLoader {
  46889. /**
  46890. * No logging while loading
  46891. */
  46892. static readonly NO_LOGGING: number;
  46893. /**
  46894. * Minimal logging while loading
  46895. */
  46896. static readonly MINIMAL_LOGGING: number;
  46897. /**
  46898. * Summary logging while loading
  46899. */
  46900. static readonly SUMMARY_LOGGING: number;
  46901. /**
  46902. * Detailled logging while loading
  46903. */
  46904. static readonly DETAILED_LOGGING: number;
  46905. /**
  46906. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46907. */
  46908. static get ForceFullSceneLoadingForIncremental(): boolean;
  46909. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46910. /**
  46911. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46912. */
  46913. static get ShowLoadingScreen(): boolean;
  46914. static set ShowLoadingScreen(value: boolean);
  46915. /**
  46916. * Defines the current logging level (while loading the scene)
  46917. * @ignorenaming
  46918. */
  46919. static get loggingLevel(): number;
  46920. static set loggingLevel(value: number);
  46921. /**
  46922. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46923. */
  46924. static get CleanBoneMatrixWeights(): boolean;
  46925. static set CleanBoneMatrixWeights(value: boolean);
  46926. /**
  46927. * Event raised when a plugin is used to load a scene
  46928. */
  46929. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46930. private static _registeredPlugins;
  46931. private static _getDefaultPlugin;
  46932. private static _getPluginForExtension;
  46933. private static _getPluginForDirectLoad;
  46934. private static _getPluginForFilename;
  46935. private static _getDirectLoad;
  46936. private static _loadData;
  46937. private static _getFileInfo;
  46938. /**
  46939. * Gets a plugin that can load the given extension
  46940. * @param extension defines the extension to load
  46941. * @returns a plugin or null if none works
  46942. */
  46943. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46944. /**
  46945. * Gets a boolean indicating that the given extension can be loaded
  46946. * @param extension defines the extension to load
  46947. * @returns true if the extension is supported
  46948. */
  46949. static IsPluginForExtensionAvailable(extension: string): boolean;
  46950. /**
  46951. * Adds a new plugin to the list of registered plugins
  46952. * @param plugin defines the plugin to add
  46953. */
  46954. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46955. /**
  46956. * Import meshes into a scene
  46957. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46958. * @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)
  46959. * @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)
  46960. * @param scene the instance of BABYLON.Scene to append to
  46961. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46962. * @param onProgress a callback with a progress event for each file being loaded
  46963. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46964. * @param pluginExtension the extension used to determine the plugin
  46965. * @returns The loaded plugin
  46966. */
  46967. 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>;
  46968. /**
  46969. * Import meshes into a scene
  46970. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46971. * @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)
  46972. * @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)
  46973. * @param scene the instance of BABYLON.Scene to append to
  46974. * @param onProgress a callback with a progress event for each file being loaded
  46975. * @param pluginExtension the extension used to determine the plugin
  46976. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46977. */
  46978. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46979. meshes: AbstractMesh[];
  46980. particleSystems: IParticleSystem[];
  46981. skeletons: Skeleton[];
  46982. animationGroups: AnimationGroup[];
  46983. }>;
  46984. /**
  46985. * Load a scene
  46986. * @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)
  46987. * @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)
  46988. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46989. * @param onSuccess a callback with the scene when import succeeds
  46990. * @param onProgress a callback with a progress event for each file being loaded
  46991. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46992. * @param pluginExtension the extension used to determine the plugin
  46993. * @returns The loaded plugin
  46994. */
  46995. 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>;
  46996. /**
  46997. * Load a scene
  46998. * @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)
  46999. * @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)
  47000. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47001. * @param onProgress a callback with a progress event for each file being loaded
  47002. * @param pluginExtension the extension used to determine the plugin
  47003. * @returns The loaded scene
  47004. */
  47005. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47006. /**
  47007. * Append a scene
  47008. * @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)
  47009. * @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)
  47010. * @param scene is the instance of BABYLON.Scene to append to
  47011. * @param onSuccess a callback with the scene when import succeeds
  47012. * @param onProgress a callback with a progress event for each file being loaded
  47013. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47014. * @param pluginExtension the extension used to determine the plugin
  47015. * @returns The loaded plugin
  47016. */
  47017. 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>;
  47018. /**
  47019. * Append a scene
  47020. * @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)
  47021. * @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)
  47022. * @param scene is the instance of BABYLON.Scene to append to
  47023. * @param onProgress a callback with a progress event for each file being loaded
  47024. * @param pluginExtension the extension used to determine the plugin
  47025. * @returns The given scene
  47026. */
  47027. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47028. /**
  47029. * Load a scene into an asset container
  47030. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47031. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  47032. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47033. * @param onSuccess a callback with the scene when import succeeds
  47034. * @param onProgress a callback with a progress event for each file being loaded
  47035. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47036. * @param pluginExtension the extension used to determine the plugin
  47037. * @returns The loaded plugin
  47038. */
  47039. 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>;
  47040. /**
  47041. * Load a scene into an asset container
  47042. * @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)
  47043. * @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)
  47044. * @param scene is the instance of Scene to append to
  47045. * @param onProgress a callback with a progress event for each file being loaded
  47046. * @param pluginExtension the extension used to determine the plugin
  47047. * @returns The loaded asset container
  47048. */
  47049. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47050. /**
  47051. * Import animations from a file into a scene
  47052. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47053. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  47054. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47055. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47056. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47057. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47058. * @param onSuccess a callback with the scene when import succeeds
  47059. * @param onProgress a callback with a progress event for each file being loaded
  47060. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47061. * @param pluginExtension the extension used to determine the plugin
  47062. */
  47063. 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;
  47064. /**
  47065. * Import animations from a file into a scene
  47066. * @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)
  47067. * @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)
  47068. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47069. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47070. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47071. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47072. * @param onSuccess a callback with the scene when import succeeds
  47073. * @param onProgress a callback with a progress event for each file being loaded
  47074. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47075. * @param pluginExtension the extension used to determine the plugin
  47076. * @returns the updated scene with imported animations
  47077. */
  47078. 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>;
  47079. }
  47080. }
  47081. declare module BABYLON {
  47082. /**
  47083. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47084. */
  47085. export type MotionControllerHandedness = "none" | "left" | "right";
  47086. /**
  47087. * The type of components available in motion controllers.
  47088. * This is not the name of the component.
  47089. */
  47090. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47091. /**
  47092. * The state of a controller component
  47093. */
  47094. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47095. /**
  47096. * The schema of motion controller layout.
  47097. * No object will be initialized using this interface
  47098. * This is used just to define the profile.
  47099. */
  47100. export interface IMotionControllerLayout {
  47101. /**
  47102. * Path to load the assets. Usually relative to the base path
  47103. */
  47104. assetPath: string;
  47105. /**
  47106. * Available components (unsorted)
  47107. */
  47108. components: {
  47109. /**
  47110. * A map of component Ids
  47111. */
  47112. [componentId: string]: {
  47113. /**
  47114. * The type of input the component outputs
  47115. */
  47116. type: MotionControllerComponentType;
  47117. /**
  47118. * The indices of this component in the gamepad object
  47119. */
  47120. gamepadIndices: {
  47121. /**
  47122. * Index of button
  47123. */
  47124. button?: number;
  47125. /**
  47126. * If available, index of x-axis
  47127. */
  47128. xAxis?: number;
  47129. /**
  47130. * If available, index of y-axis
  47131. */
  47132. yAxis?: number;
  47133. };
  47134. /**
  47135. * The mesh's root node name
  47136. */
  47137. rootNodeName: string;
  47138. /**
  47139. * Animation definitions for this model
  47140. */
  47141. visualResponses: {
  47142. [stateKey: string]: {
  47143. /**
  47144. * What property will be animated
  47145. */
  47146. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47147. /**
  47148. * What states influence this visual response
  47149. */
  47150. states: MotionControllerComponentStateType[];
  47151. /**
  47152. * Type of animation - movement or visibility
  47153. */
  47154. valueNodeProperty: "transform" | "visibility";
  47155. /**
  47156. * Base node name to move. Its position will be calculated according to the min and max nodes
  47157. */
  47158. valueNodeName?: string;
  47159. /**
  47160. * Minimum movement node
  47161. */
  47162. minNodeName?: string;
  47163. /**
  47164. * Max movement node
  47165. */
  47166. maxNodeName?: string;
  47167. };
  47168. };
  47169. /**
  47170. * If touch enabled, what is the name of node to display user feedback
  47171. */
  47172. touchPointNodeName?: string;
  47173. };
  47174. };
  47175. /**
  47176. * Is it xr standard mapping or not
  47177. */
  47178. gamepadMapping: "" | "xr-standard";
  47179. /**
  47180. * Base root node of this entire model
  47181. */
  47182. rootNodeName: string;
  47183. /**
  47184. * Defines the main button component id
  47185. */
  47186. selectComponentId: string;
  47187. }
  47188. /**
  47189. * A definition for the layout map in the input profile
  47190. */
  47191. export interface IMotionControllerLayoutMap {
  47192. /**
  47193. * Layouts with handedness type as a key
  47194. */
  47195. [handedness: string]: IMotionControllerLayout;
  47196. }
  47197. /**
  47198. * The XR Input profile schema
  47199. * Profiles can be found here:
  47200. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47201. */
  47202. export interface IMotionControllerProfile {
  47203. /**
  47204. * fallback profiles for this profileId
  47205. */
  47206. fallbackProfileIds: string[];
  47207. /**
  47208. * The layout map, with handedness as key
  47209. */
  47210. layouts: IMotionControllerLayoutMap;
  47211. /**
  47212. * The id of this profile
  47213. * correlates to the profile(s) in the xrInput.profiles array
  47214. */
  47215. profileId: string;
  47216. }
  47217. /**
  47218. * A helper-interface for the 3 meshes needed for controller button animation
  47219. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47220. */
  47221. export interface IMotionControllerButtonMeshMap {
  47222. /**
  47223. * the mesh that defines the pressed value mesh position.
  47224. * This is used to find the max-position of this button
  47225. */
  47226. pressedMesh: AbstractMesh;
  47227. /**
  47228. * the mesh that defines the unpressed value mesh position.
  47229. * This is used to find the min (or initial) position of this button
  47230. */
  47231. unpressedMesh: AbstractMesh;
  47232. /**
  47233. * The mesh that will be changed when value changes
  47234. */
  47235. valueMesh: AbstractMesh;
  47236. }
  47237. /**
  47238. * A helper-interface for the 3 meshes needed for controller axis animation.
  47239. * This will be expanded when touchpad animations are fully supported
  47240. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47241. */
  47242. export interface IMotionControllerMeshMap {
  47243. /**
  47244. * the mesh that defines the maximum value mesh position.
  47245. */
  47246. maxMesh?: AbstractMesh;
  47247. /**
  47248. * the mesh that defines the minimum value mesh position.
  47249. */
  47250. minMesh?: AbstractMesh;
  47251. /**
  47252. * The mesh that will be changed when axis value changes
  47253. */
  47254. valueMesh: AbstractMesh;
  47255. }
  47256. /**
  47257. * The elements needed for change-detection of the gamepad objects in motion controllers
  47258. */
  47259. export interface IMinimalMotionControllerObject {
  47260. /**
  47261. * Available axes of this controller
  47262. */
  47263. axes: number[];
  47264. /**
  47265. * An array of available buttons
  47266. */
  47267. buttons: Array<{
  47268. /**
  47269. * Value of the button/trigger
  47270. */
  47271. value: number;
  47272. /**
  47273. * If the button/trigger is currently touched
  47274. */
  47275. touched: boolean;
  47276. /**
  47277. * If the button/trigger is currently pressed
  47278. */
  47279. pressed: boolean;
  47280. }>;
  47281. /**
  47282. * EXPERIMENTAL haptic support.
  47283. */
  47284. hapticActuators?: Array<{
  47285. pulse: (value: number, duration: number) => Promise<boolean>;
  47286. }>;
  47287. }
  47288. /**
  47289. * An Abstract Motion controller
  47290. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47291. * Each component has an observable to check for changes in value and state
  47292. */
  47293. export abstract class WebXRAbstractMotionController implements IDisposable {
  47294. protected scene: Scene;
  47295. protected layout: IMotionControllerLayout;
  47296. /**
  47297. * The gamepad object correlating to this controller
  47298. */
  47299. gamepadObject: IMinimalMotionControllerObject;
  47300. /**
  47301. * handedness (left/right/none) of this controller
  47302. */
  47303. handedness: MotionControllerHandedness;
  47304. private _initComponent;
  47305. private _modelReady;
  47306. /**
  47307. * A map of components (WebXRControllerComponent) in this motion controller
  47308. * Components have a ComponentType and can also have both button and axis definitions
  47309. */
  47310. readonly components: {
  47311. [id: string]: WebXRControllerComponent;
  47312. };
  47313. /**
  47314. * Disable the model's animation. Can be set at any time.
  47315. */
  47316. disableAnimation: boolean;
  47317. /**
  47318. * Observers registered here will be triggered when the model of this controller is done loading
  47319. */
  47320. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47321. /**
  47322. * The profile id of this motion controller
  47323. */
  47324. abstract profileId: string;
  47325. /**
  47326. * The root mesh of the model. It is null if the model was not yet initialized
  47327. */
  47328. rootMesh: Nullable<AbstractMesh>;
  47329. /**
  47330. * constructs a new abstract motion controller
  47331. * @param scene the scene to which the model of the controller will be added
  47332. * @param layout The profile layout to load
  47333. * @param gamepadObject The gamepad object correlating to this controller
  47334. * @param handedness handedness (left/right/none) of this controller
  47335. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47336. */
  47337. constructor(scene: Scene, layout: IMotionControllerLayout,
  47338. /**
  47339. * The gamepad object correlating to this controller
  47340. */
  47341. gamepadObject: IMinimalMotionControllerObject,
  47342. /**
  47343. * handedness (left/right/none) of this controller
  47344. */
  47345. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47346. /**
  47347. * Dispose this controller, the model mesh and all its components
  47348. */
  47349. dispose(): void;
  47350. /**
  47351. * Returns all components of specific type
  47352. * @param type the type to search for
  47353. * @return an array of components with this type
  47354. */
  47355. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47356. /**
  47357. * get a component based an its component id as defined in layout.components
  47358. * @param id the id of the component
  47359. * @returns the component correlates to the id or undefined if not found
  47360. */
  47361. getComponent(id: string): WebXRControllerComponent;
  47362. /**
  47363. * Get the list of components available in this motion controller
  47364. * @returns an array of strings correlating to available components
  47365. */
  47366. getComponentIds(): string[];
  47367. /**
  47368. * Get the first component of specific type
  47369. * @param type type of component to find
  47370. * @return a controller component or null if not found
  47371. */
  47372. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47373. /**
  47374. * Get the main (Select) component of this controller as defined in the layout
  47375. * @returns the main component of this controller
  47376. */
  47377. getMainComponent(): WebXRControllerComponent;
  47378. /**
  47379. * Loads the model correlating to this controller
  47380. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47381. * @returns A promise fulfilled with the result of the model loading
  47382. */
  47383. loadModel(): Promise<boolean>;
  47384. /**
  47385. * Update this model using the current XRFrame
  47386. * @param xrFrame the current xr frame to use and update the model
  47387. */
  47388. updateFromXRFrame(xrFrame: XRFrame): void;
  47389. /**
  47390. * Backwards compatibility due to a deeply-integrated typo
  47391. */
  47392. get handness(): XREye;
  47393. /**
  47394. * Pulse (vibrate) this controller
  47395. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47396. * Consecutive calls to this function will cancel the last pulse call
  47397. *
  47398. * @param value the strength of the pulse in 0.0...1.0 range
  47399. * @param duration Duration of the pulse in milliseconds
  47400. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47401. * @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
  47402. */
  47403. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47404. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47405. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47406. /**
  47407. * Moves the axis on the controller mesh based on its current state
  47408. * @param axis the index of the axis
  47409. * @param axisValue the value of the axis which determines the meshes new position
  47410. * @hidden
  47411. */
  47412. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47413. /**
  47414. * Update the model itself with the current frame data
  47415. * @param xrFrame the frame to use for updating the model mesh
  47416. */
  47417. protected updateModel(xrFrame: XRFrame): void;
  47418. /**
  47419. * Get the filename and path for this controller's model
  47420. * @returns a map of filename and path
  47421. */
  47422. protected abstract _getFilenameAndPath(): {
  47423. filename: string;
  47424. path: string;
  47425. };
  47426. /**
  47427. * This function is called before the mesh is loaded. It checks for loading constraints.
  47428. * For example, this function can check if the GLB loader is available
  47429. * If this function returns false, the generic controller will be loaded instead
  47430. * @returns Is the client ready to load the mesh
  47431. */
  47432. protected abstract _getModelLoadingConstraints(): boolean;
  47433. /**
  47434. * This function will be called after the model was successfully loaded and can be used
  47435. * for mesh transformations before it is available for the user
  47436. * @param meshes the loaded meshes
  47437. */
  47438. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47439. /**
  47440. * Set the root mesh for this controller. Important for the WebXR controller class
  47441. * @param meshes the loaded meshes
  47442. */
  47443. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47444. /**
  47445. * A function executed each frame that updates the mesh (if needed)
  47446. * @param xrFrame the current xrFrame
  47447. */
  47448. protected abstract _updateModel(xrFrame: XRFrame): void;
  47449. private _getGenericFilenameAndPath;
  47450. private _getGenericParentMesh;
  47451. }
  47452. }
  47453. declare module BABYLON {
  47454. /**
  47455. * A generic trigger-only motion controller for WebXR
  47456. */
  47457. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47458. /**
  47459. * Static version of the profile id of this controller
  47460. */
  47461. static ProfileId: string;
  47462. profileId: string;
  47463. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47464. protected _getFilenameAndPath(): {
  47465. filename: string;
  47466. path: string;
  47467. };
  47468. protected _getModelLoadingConstraints(): boolean;
  47469. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47470. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47471. protected _updateModel(): void;
  47472. }
  47473. }
  47474. declare module BABYLON {
  47475. /**
  47476. * Class containing static functions to help procedurally build meshes
  47477. */
  47478. export class SphereBuilder {
  47479. /**
  47480. * Creates a sphere mesh
  47481. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47482. * * 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`)
  47483. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47484. * * 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
  47485. * * 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)
  47486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47487. * * 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
  47488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47489. * @param name defines the name of the mesh
  47490. * @param options defines the options used to create the mesh
  47491. * @param scene defines the hosting scene
  47492. * @returns the sphere mesh
  47493. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47494. */
  47495. static CreateSphere(name: string, options: {
  47496. segments?: number;
  47497. diameter?: number;
  47498. diameterX?: number;
  47499. diameterY?: number;
  47500. diameterZ?: number;
  47501. arc?: number;
  47502. slice?: number;
  47503. sideOrientation?: number;
  47504. frontUVs?: Vector4;
  47505. backUVs?: Vector4;
  47506. updatable?: boolean;
  47507. }, scene?: Nullable<Scene>): Mesh;
  47508. }
  47509. }
  47510. declare module BABYLON {
  47511. /**
  47512. * A profiled motion controller has its profile loaded from an online repository.
  47513. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47514. */
  47515. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47516. private _repositoryUrl;
  47517. private _buttonMeshMapping;
  47518. private _touchDots;
  47519. /**
  47520. * The profile ID of this controller. Will be populated when the controller initializes.
  47521. */
  47522. profileId: string;
  47523. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47524. dispose(): void;
  47525. protected _getFilenameAndPath(): {
  47526. filename: string;
  47527. path: string;
  47528. };
  47529. protected _getModelLoadingConstraints(): boolean;
  47530. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47531. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47532. protected _updateModel(_xrFrame: XRFrame): void;
  47533. }
  47534. }
  47535. declare module BABYLON {
  47536. /**
  47537. * A construction function type to create a new controller based on an xrInput object
  47538. */
  47539. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47540. /**
  47541. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47542. *
  47543. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47544. * it should be replaced with auto-loaded controllers.
  47545. *
  47546. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47547. */
  47548. export class WebXRMotionControllerManager {
  47549. private static _AvailableControllers;
  47550. private static _Fallbacks;
  47551. private static _ProfileLoadingPromises;
  47552. private static _ProfilesList;
  47553. /**
  47554. * The base URL of the online controller repository. Can be changed at any time.
  47555. */
  47556. static BaseRepositoryUrl: string;
  47557. /**
  47558. * Which repository gets priority - local or online
  47559. */
  47560. static PrioritizeOnlineRepository: boolean;
  47561. /**
  47562. * Use the online repository, or use only locally-defined controllers
  47563. */
  47564. static UseOnlineRepository: boolean;
  47565. /**
  47566. * Clear the cache used for profile loading and reload when requested again
  47567. */
  47568. static ClearProfilesCache(): void;
  47569. /**
  47570. * Register the default fallbacks.
  47571. * This function is called automatically when this file is imported.
  47572. */
  47573. static DefaultFallbacks(): void;
  47574. /**
  47575. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47576. * @param profileId the profile to which a fallback needs to be found
  47577. * @return an array with corresponding fallback profiles
  47578. */
  47579. static FindFallbackWithProfileId(profileId: string): string[];
  47580. /**
  47581. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47582. * The order of search:
  47583. *
  47584. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47585. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47586. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47587. * 4) return the generic trigger controller if none were found
  47588. *
  47589. * @param xrInput the xrInput to which a new controller is initialized
  47590. * @param scene the scene to which the model will be added
  47591. * @param forceProfile force a certain profile for this controller
  47592. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47593. */
  47594. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47595. /**
  47596. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47597. *
  47598. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47599. *
  47600. * @param type the profile type to register
  47601. * @param constructFunction the function to be called when loading this profile
  47602. */
  47603. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47604. /**
  47605. * Register a fallback to a specific profile.
  47606. * @param profileId the profileId that will receive the fallbacks
  47607. * @param fallbacks A list of fallback profiles
  47608. */
  47609. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47610. /**
  47611. * Will update the list of profiles available in the repository
  47612. * @return a promise that resolves to a map of profiles available online
  47613. */
  47614. static UpdateProfilesList(): Promise<{
  47615. [profile: string]: string;
  47616. }>;
  47617. private static _LoadProfileFromRepository;
  47618. private static _LoadProfilesFromAvailableControllers;
  47619. }
  47620. }
  47621. declare module BABYLON {
  47622. /**
  47623. * Configuration options for the WebXR controller creation
  47624. */
  47625. export interface IWebXRControllerOptions {
  47626. /**
  47627. * Should the controller mesh be animated when a user interacts with it
  47628. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47629. */
  47630. disableMotionControllerAnimation?: boolean;
  47631. /**
  47632. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47633. */
  47634. doNotLoadControllerMesh?: boolean;
  47635. /**
  47636. * Force a specific controller type for this controller.
  47637. * This can be used when creating your own profile or when testing different controllers
  47638. */
  47639. forceControllerProfile?: string;
  47640. /**
  47641. * Defines a rendering group ID for meshes that will be loaded.
  47642. * This is for the default controllers only.
  47643. */
  47644. renderingGroupId?: number;
  47645. }
  47646. /**
  47647. * Represents an XR controller
  47648. */
  47649. export class WebXRInputSource {
  47650. private _scene;
  47651. /** The underlying input source for the controller */
  47652. inputSource: XRInputSource;
  47653. private _options;
  47654. private _tmpVector;
  47655. private _uniqueId;
  47656. /**
  47657. * 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
  47658. */
  47659. grip?: AbstractMesh;
  47660. /**
  47661. * If available, this is the gamepad object related to this controller.
  47662. * Using this object it is possible to get click events and trackpad changes of the
  47663. * webxr controller that is currently being used.
  47664. */
  47665. motionController?: WebXRAbstractMotionController;
  47666. /**
  47667. * Event that fires when the controller is removed/disposed.
  47668. * The object provided as event data is this controller, after associated assets were disposed.
  47669. * uniqueId is still available.
  47670. */
  47671. onDisposeObservable: Observable<WebXRInputSource>;
  47672. /**
  47673. * Will be triggered when the mesh associated with the motion controller is done loading.
  47674. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47675. * A shortened version of controller -> motion controller -> on mesh loaded.
  47676. */
  47677. onMeshLoadedObservable: Observable<AbstractMesh>;
  47678. /**
  47679. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47680. */
  47681. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47682. /**
  47683. * Pointer which can be used to select objects or attach a visible laser to
  47684. */
  47685. pointer: AbstractMesh;
  47686. /**
  47687. * Creates the input source object
  47688. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  47689. * @param _scene the scene which the controller should be associated to
  47690. * @param inputSource the underlying input source for the controller
  47691. * @param _options options for this controller creation
  47692. */
  47693. constructor(_scene: Scene,
  47694. /** The underlying input source for the controller */
  47695. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47696. /**
  47697. * Get this controllers unique id
  47698. */
  47699. get uniqueId(): string;
  47700. /**
  47701. * Disposes of the object
  47702. */
  47703. dispose(): void;
  47704. /**
  47705. * Gets a world space ray coming from the pointer or grip
  47706. * @param result the resulting ray
  47707. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47708. */
  47709. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47710. /**
  47711. * Updates the controller pose based on the given XRFrame
  47712. * @param xrFrame xr frame to update the pose with
  47713. * @param referenceSpace reference space to use
  47714. */
  47715. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47716. }
  47717. }
  47718. declare module BABYLON {
  47719. /**
  47720. * The schema for initialization options of the XR Input class
  47721. */
  47722. export interface IWebXRInputOptions {
  47723. /**
  47724. * If set to true no model will be automatically loaded
  47725. */
  47726. doNotLoadControllerMeshes?: boolean;
  47727. /**
  47728. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47729. * If not found, the xr input profile data will be used.
  47730. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47731. */
  47732. forceInputProfile?: string;
  47733. /**
  47734. * Do not send a request to the controller repository to load the profile.
  47735. *
  47736. * Instead, use the controllers available in babylon itself.
  47737. */
  47738. disableOnlineControllerRepository?: boolean;
  47739. /**
  47740. * A custom URL for the controllers repository
  47741. */
  47742. customControllersRepositoryURL?: string;
  47743. /**
  47744. * Should the controller model's components not move according to the user input
  47745. */
  47746. disableControllerAnimation?: boolean;
  47747. /**
  47748. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47749. */
  47750. controllerOptions?: IWebXRControllerOptions;
  47751. }
  47752. /**
  47753. * XR input used to track XR inputs such as controllers/rays
  47754. */
  47755. export class WebXRInput implements IDisposable {
  47756. /**
  47757. * the xr session manager for this session
  47758. */
  47759. xrSessionManager: WebXRSessionManager;
  47760. /**
  47761. * the WebXR camera for this session. Mainly used for teleportation
  47762. */
  47763. xrCamera: WebXRCamera;
  47764. private readonly options;
  47765. /**
  47766. * XR controllers being tracked
  47767. */
  47768. controllers: Array<WebXRInputSource>;
  47769. private _frameObserver;
  47770. private _sessionEndedObserver;
  47771. private _sessionInitObserver;
  47772. /**
  47773. * Event when a controller has been connected/added
  47774. */
  47775. onControllerAddedObservable: Observable<WebXRInputSource>;
  47776. /**
  47777. * Event when a controller has been removed/disconnected
  47778. */
  47779. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47780. /**
  47781. * Initializes the WebXRInput
  47782. * @param xrSessionManager the xr session manager for this session
  47783. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47784. * @param options = initialization options for this xr input
  47785. */
  47786. constructor(
  47787. /**
  47788. * the xr session manager for this session
  47789. */
  47790. xrSessionManager: WebXRSessionManager,
  47791. /**
  47792. * the WebXR camera for this session. Mainly used for teleportation
  47793. */
  47794. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47795. private _onInputSourcesChange;
  47796. private _addAndRemoveControllers;
  47797. /**
  47798. * Disposes of the object
  47799. */
  47800. dispose(): void;
  47801. }
  47802. }
  47803. declare module BABYLON {
  47804. /**
  47805. * This is the base class for all WebXR features.
  47806. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47807. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47808. */
  47809. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47810. protected _xrSessionManager: WebXRSessionManager;
  47811. private _attached;
  47812. private _removeOnDetach;
  47813. /**
  47814. * Should auto-attach be disabled?
  47815. */
  47816. disableAutoAttach: boolean;
  47817. /**
  47818. * Construct a new (abstract) WebXR feature
  47819. * @param _xrSessionManager the xr session manager for this feature
  47820. */
  47821. constructor(_xrSessionManager: WebXRSessionManager);
  47822. /**
  47823. * Is this feature attached
  47824. */
  47825. get attached(): boolean;
  47826. /**
  47827. * attach this feature
  47828. *
  47829. * @param force should attachment be forced (even when already attached)
  47830. * @returns true if successful, false is failed or already attached
  47831. */
  47832. attach(force?: boolean): boolean;
  47833. /**
  47834. * detach this feature.
  47835. *
  47836. * @returns true if successful, false if failed or already detached
  47837. */
  47838. detach(): boolean;
  47839. /**
  47840. * Dispose this feature and all of the resources attached
  47841. */
  47842. dispose(): void;
  47843. /**
  47844. * This is used to register callbacks that will automatically be removed when detach is called.
  47845. * @param observable the observable to which the observer will be attached
  47846. * @param callback the callback to register
  47847. */
  47848. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47849. /**
  47850. * Code in this function will be executed on each xrFrame received from the browser.
  47851. * This function will not execute after the feature is detached.
  47852. * @param _xrFrame the current frame
  47853. */
  47854. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47855. }
  47856. }
  47857. declare module BABYLON {
  47858. /**
  47859. * Renders a layer on top of an existing scene
  47860. */
  47861. export class UtilityLayerRenderer implements IDisposable {
  47862. /** the original scene that will be rendered on top of */
  47863. originalScene: Scene;
  47864. private _pointerCaptures;
  47865. private _lastPointerEvents;
  47866. private static _DefaultUtilityLayer;
  47867. private static _DefaultKeepDepthUtilityLayer;
  47868. private _sharedGizmoLight;
  47869. private _renderCamera;
  47870. /**
  47871. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47872. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47873. * @returns the camera that is used when rendering the utility layer
  47874. */
  47875. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47876. /**
  47877. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47878. * @param cam the camera that should be used when rendering the utility layer
  47879. */
  47880. setRenderCamera(cam: Nullable<Camera>): void;
  47881. /**
  47882. * @hidden
  47883. * Light which used by gizmos to get light shading
  47884. */
  47885. _getSharedGizmoLight(): HemisphericLight;
  47886. /**
  47887. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47888. */
  47889. pickUtilitySceneFirst: boolean;
  47890. /**
  47891. * 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)
  47892. */
  47893. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47894. /**
  47895. * 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)
  47896. */
  47897. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47898. /**
  47899. * The scene that is rendered on top of the original scene
  47900. */
  47901. utilityLayerScene: Scene;
  47902. /**
  47903. * If the utility layer should automatically be rendered on top of existing scene
  47904. */
  47905. shouldRender: boolean;
  47906. /**
  47907. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47908. */
  47909. onlyCheckPointerDownEvents: boolean;
  47910. /**
  47911. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47912. */
  47913. processAllEvents: boolean;
  47914. /**
  47915. * Observable raised when the pointer move from the utility layer scene to the main scene
  47916. */
  47917. onPointerOutObservable: Observable<number>;
  47918. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47919. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47920. private _afterRenderObserver;
  47921. private _sceneDisposeObserver;
  47922. private _originalPointerObserver;
  47923. /**
  47924. * Instantiates a UtilityLayerRenderer
  47925. * @param originalScene the original scene that will be rendered on top of
  47926. * @param handleEvents boolean indicating if the utility layer should handle events
  47927. */
  47928. constructor(
  47929. /** the original scene that will be rendered on top of */
  47930. originalScene: Scene, handleEvents?: boolean);
  47931. private _notifyObservers;
  47932. /**
  47933. * Renders the utility layers scene on top of the original scene
  47934. */
  47935. render(): void;
  47936. /**
  47937. * Disposes of the renderer
  47938. */
  47939. dispose(): void;
  47940. private _updateCamera;
  47941. }
  47942. }
  47943. declare module BABYLON {
  47944. /**
  47945. * Options interface for the pointer selection module
  47946. */
  47947. export interface IWebXRControllerPointerSelectionOptions {
  47948. /**
  47949. * if provided, this scene will be used to render meshes.
  47950. */
  47951. customUtilityLayerScene?: Scene;
  47952. /**
  47953. * 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)
  47954. * If not disabled, the last picked point will be used to execute a pointer up event
  47955. * If disabled, pointer up event will be triggered right after the pointer down event.
  47956. * Used in screen and gaze target ray mode only
  47957. */
  47958. disablePointerUpOnTouchOut: boolean;
  47959. /**
  47960. * For gaze mode (time to select instead of press)
  47961. */
  47962. forceGazeMode: boolean;
  47963. /**
  47964. * 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
  47965. * to start a new countdown to the pointer down event.
  47966. * Defaults to 1.
  47967. */
  47968. gazeModePointerMovedFactor?: number;
  47969. /**
  47970. * Different button type to use instead of the main component
  47971. */
  47972. overrideButtonId?: string;
  47973. /**
  47974. * use this rendering group id for the meshes (optional)
  47975. */
  47976. renderingGroupId?: number;
  47977. /**
  47978. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47979. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47980. * 3000 means 3 seconds between pointing at something and selecting it
  47981. */
  47982. timeToSelect?: number;
  47983. /**
  47984. * Should meshes created here be added to a utility layer or the main scene
  47985. */
  47986. useUtilityLayer?: boolean;
  47987. /**
  47988. * the xr input to use with this pointer selection
  47989. */
  47990. xrInput: WebXRInput;
  47991. }
  47992. /**
  47993. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47994. */
  47995. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47996. private readonly _options;
  47997. private static _idCounter;
  47998. private _attachController;
  47999. private _controllers;
  48000. private _scene;
  48001. private _tmpVectorForPickCompare;
  48002. /**
  48003. * The module's name
  48004. */
  48005. static readonly Name: string;
  48006. /**
  48007. * The (Babylon) version of this module.
  48008. * This is an integer representing the implementation version.
  48009. * This number does not correspond to the WebXR specs version
  48010. */
  48011. static readonly Version: number;
  48012. /**
  48013. * Disable lighting on the laser pointer (so it will always be visible)
  48014. */
  48015. disablePointerLighting: boolean;
  48016. /**
  48017. * Disable lighting on the selection mesh (so it will always be visible)
  48018. */
  48019. disableSelectionMeshLighting: boolean;
  48020. /**
  48021. * Should the laser pointer be displayed
  48022. */
  48023. displayLaserPointer: boolean;
  48024. /**
  48025. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48026. */
  48027. displaySelectionMesh: boolean;
  48028. /**
  48029. * This color will be set to the laser pointer when selection is triggered
  48030. */
  48031. laserPointerPickedColor: Color3;
  48032. /**
  48033. * Default color of the laser pointer
  48034. */
  48035. laserPointerDefaultColor: Color3;
  48036. /**
  48037. * default color of the selection ring
  48038. */
  48039. selectionMeshDefaultColor: Color3;
  48040. /**
  48041. * This color will be applied to the selection ring when selection is triggered
  48042. */
  48043. selectionMeshPickedColor: Color3;
  48044. /**
  48045. * Optional filter to be used for ray selection. This predicate shares behavior with
  48046. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48047. */
  48048. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48049. /**
  48050. * constructs a new background remover module
  48051. * @param _xrSessionManager the session manager for this module
  48052. * @param _options read-only options to be used in this module
  48053. */
  48054. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48055. /**
  48056. * attach this feature
  48057. * Will usually be called by the features manager
  48058. *
  48059. * @returns true if successful.
  48060. */
  48061. attach(): boolean;
  48062. /**
  48063. * detach this feature.
  48064. * Will usually be called by the features manager
  48065. *
  48066. * @returns true if successful.
  48067. */
  48068. detach(): boolean;
  48069. /**
  48070. * Will get the mesh under a specific pointer.
  48071. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48072. * @param controllerId the controllerId to check
  48073. * @returns The mesh under pointer or null if no mesh is under the pointer
  48074. */
  48075. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48076. /**
  48077. * Get the xr controller that correlates to the pointer id in the pointer event
  48078. *
  48079. * @param id the pointer id to search for
  48080. * @returns the controller that correlates to this id or null if not found
  48081. */
  48082. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48083. protected _onXRFrame(_xrFrame: XRFrame): void;
  48084. private _attachGazeMode;
  48085. private _attachScreenRayMode;
  48086. private _attachTrackedPointerRayMode;
  48087. private _convertNormalToDirectionOfRay;
  48088. private _detachController;
  48089. private _generateNewMeshPair;
  48090. private _pickingMoved;
  48091. private _updatePointerDistance;
  48092. /** @hidden */
  48093. get lasterPointerDefaultColor(): Color3;
  48094. }
  48095. }
  48096. declare module BABYLON {
  48097. /**
  48098. * Button which can be used to enter a different mode of XR
  48099. */
  48100. export class WebXREnterExitUIButton {
  48101. /** button element */
  48102. element: HTMLElement;
  48103. /** XR initialization options for the button */
  48104. sessionMode: XRSessionMode;
  48105. /** Reference space type */
  48106. referenceSpaceType: XRReferenceSpaceType;
  48107. /**
  48108. * Creates a WebXREnterExitUIButton
  48109. * @param element button element
  48110. * @param sessionMode XR initialization session mode
  48111. * @param referenceSpaceType the type of reference space to be used
  48112. */
  48113. constructor(
  48114. /** button element */
  48115. element: HTMLElement,
  48116. /** XR initialization options for the button */
  48117. sessionMode: XRSessionMode,
  48118. /** Reference space type */
  48119. referenceSpaceType: XRReferenceSpaceType);
  48120. /**
  48121. * Extendable function which can be used to update the button's visuals when the state changes
  48122. * @param activeButton the current active button in the UI
  48123. */
  48124. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48125. }
  48126. /**
  48127. * Options to create the webXR UI
  48128. */
  48129. export class WebXREnterExitUIOptions {
  48130. /**
  48131. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48132. */
  48133. customButtons?: Array<WebXREnterExitUIButton>;
  48134. /**
  48135. * A reference space type to use when creating the default button.
  48136. * Default is local-floor
  48137. */
  48138. referenceSpaceType?: XRReferenceSpaceType;
  48139. /**
  48140. * Context to enter xr with
  48141. */
  48142. renderTarget?: Nullable<WebXRRenderTarget>;
  48143. /**
  48144. * A session mode to use when creating the default button.
  48145. * Default is immersive-vr
  48146. */
  48147. sessionMode?: XRSessionMode;
  48148. /**
  48149. * A list of optional features to init the session with
  48150. */
  48151. optionalFeatures?: string[];
  48152. }
  48153. /**
  48154. * UI to allow the user to enter/exit XR mode
  48155. */
  48156. export class WebXREnterExitUI implements IDisposable {
  48157. private scene;
  48158. /** version of the options passed to this UI */
  48159. options: WebXREnterExitUIOptions;
  48160. private _activeButton;
  48161. private _buttons;
  48162. private _overlay;
  48163. /**
  48164. * Fired every time the active button is changed.
  48165. *
  48166. * When xr is entered via a button that launches xr that button will be the callback parameter
  48167. *
  48168. * When exiting xr the callback parameter will be null)
  48169. */
  48170. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48171. /**
  48172. *
  48173. * @param scene babylon scene object to use
  48174. * @param options (read-only) version of the options passed to this UI
  48175. */
  48176. private constructor();
  48177. /**
  48178. * Creates UI to allow the user to enter/exit XR mode
  48179. * @param scene the scene to add the ui to
  48180. * @param helper the xr experience helper to enter/exit xr with
  48181. * @param options options to configure the UI
  48182. * @returns the created ui
  48183. */
  48184. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48185. /**
  48186. * Disposes of the XR UI component
  48187. */
  48188. dispose(): void;
  48189. private _updateButtons;
  48190. }
  48191. }
  48192. declare module BABYLON {
  48193. /**
  48194. * Class containing static functions to help procedurally build meshes
  48195. */
  48196. export class LinesBuilder {
  48197. /**
  48198. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48199. * * 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
  48200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48201. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48202. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48203. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48205. * * 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
  48206. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48209. * @param name defines the name of the new line system
  48210. * @param options defines the options used to create the line system
  48211. * @param scene defines the hosting scene
  48212. * @returns a new line system mesh
  48213. */
  48214. static CreateLineSystem(name: string, options: {
  48215. lines: Vector3[][];
  48216. updatable?: boolean;
  48217. instance?: Nullable<LinesMesh>;
  48218. colors?: Nullable<Color4[][]>;
  48219. useVertexAlpha?: boolean;
  48220. }, scene: Nullable<Scene>): LinesMesh;
  48221. /**
  48222. * Creates a line mesh
  48223. * 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
  48224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48225. * * The parameter `points` is an array successive Vector3
  48226. * * 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
  48227. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48228. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48229. * * When updating an instance, remember that only point positions can change, not the number of points
  48230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48232. * @param name defines the name of the new line system
  48233. * @param options defines the options used to create the line system
  48234. * @param scene defines the hosting scene
  48235. * @returns a new line mesh
  48236. */
  48237. static CreateLines(name: string, options: {
  48238. points: Vector3[];
  48239. updatable?: boolean;
  48240. instance?: Nullable<LinesMesh>;
  48241. colors?: Color4[];
  48242. useVertexAlpha?: boolean;
  48243. }, scene?: Nullable<Scene>): LinesMesh;
  48244. /**
  48245. * Creates a dashed line mesh
  48246. * * 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
  48247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48248. * * The parameter `points` is an array successive Vector3
  48249. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48250. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48251. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48252. * * 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
  48253. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48254. * * When updating an instance, remember that only point positions can change, not the number of points
  48255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48256. * @param name defines the name of the mesh
  48257. * @param options defines the options used to create the mesh
  48258. * @param scene defines the hosting scene
  48259. * @returns the dashed line mesh
  48260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48261. */
  48262. static CreateDashedLines(name: string, options: {
  48263. points: Vector3[];
  48264. dashSize?: number;
  48265. gapSize?: number;
  48266. dashNb?: number;
  48267. updatable?: boolean;
  48268. instance?: LinesMesh;
  48269. useVertexAlpha?: boolean;
  48270. }, scene?: Nullable<Scene>): LinesMesh;
  48271. }
  48272. }
  48273. declare module BABYLON {
  48274. /**
  48275. * Construction options for a timer
  48276. */
  48277. export interface ITimerOptions<T> {
  48278. /**
  48279. * Time-to-end
  48280. */
  48281. timeout: number;
  48282. /**
  48283. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48284. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48285. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48286. */
  48287. contextObservable: Observable<T>;
  48288. /**
  48289. * Optional parameters when adding an observer to the observable
  48290. */
  48291. observableParameters?: {
  48292. mask?: number;
  48293. insertFirst?: boolean;
  48294. scope?: any;
  48295. };
  48296. /**
  48297. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48298. */
  48299. breakCondition?: (data?: ITimerData<T>) => boolean;
  48300. /**
  48301. * Will be triggered when the time condition has met
  48302. */
  48303. onEnded?: (data: ITimerData<any>) => void;
  48304. /**
  48305. * Will be triggered when the break condition has met (prematurely ended)
  48306. */
  48307. onAborted?: (data: ITimerData<any>) => void;
  48308. /**
  48309. * Optional function to execute on each tick (or count)
  48310. */
  48311. onTick?: (data: ITimerData<any>) => void;
  48312. }
  48313. /**
  48314. * An interface defining the data sent by the timer
  48315. */
  48316. export interface ITimerData<T> {
  48317. /**
  48318. * When did it start
  48319. */
  48320. startTime: number;
  48321. /**
  48322. * Time now
  48323. */
  48324. currentTime: number;
  48325. /**
  48326. * Time passed since started
  48327. */
  48328. deltaTime: number;
  48329. /**
  48330. * How much is completed, in [0.0...1.0].
  48331. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48332. */
  48333. completeRate: number;
  48334. /**
  48335. * What the registered observable sent in the last count
  48336. */
  48337. payload: T;
  48338. }
  48339. /**
  48340. * The current state of the timer
  48341. */
  48342. export enum TimerState {
  48343. /**
  48344. * Timer initialized, not yet started
  48345. */
  48346. INIT = 0,
  48347. /**
  48348. * Timer started and counting
  48349. */
  48350. STARTED = 1,
  48351. /**
  48352. * Timer ended (whether aborted or time reached)
  48353. */
  48354. ENDED = 2
  48355. }
  48356. /**
  48357. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48358. *
  48359. * @param options options with which to initialize this timer
  48360. */
  48361. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48362. /**
  48363. * An advanced implementation of a timer class
  48364. */
  48365. export class AdvancedTimer<T = any> implements IDisposable {
  48366. /**
  48367. * Will notify each time the timer calculates the remaining time
  48368. */
  48369. onEachCountObservable: Observable<ITimerData<T>>;
  48370. /**
  48371. * Will trigger when the timer was aborted due to the break condition
  48372. */
  48373. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48374. /**
  48375. * Will trigger when the timer ended successfully
  48376. */
  48377. onTimerEndedObservable: Observable<ITimerData<T>>;
  48378. /**
  48379. * Will trigger when the timer state has changed
  48380. */
  48381. onStateChangedObservable: Observable<TimerState>;
  48382. private _observer;
  48383. private _contextObservable;
  48384. private _observableParameters;
  48385. private _startTime;
  48386. private _timer;
  48387. private _state;
  48388. private _breakCondition;
  48389. private _timeToEnd;
  48390. private _breakOnNextTick;
  48391. /**
  48392. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48393. * @param options construction options for this advanced timer
  48394. */
  48395. constructor(options: ITimerOptions<T>);
  48396. /**
  48397. * set a breaking condition for this timer. Default is to never break during count
  48398. * @param predicate the new break condition. Returns true to break, false otherwise
  48399. */
  48400. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48401. /**
  48402. * Reset ALL associated observables in this advanced timer
  48403. */
  48404. clearObservables(): void;
  48405. /**
  48406. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48407. *
  48408. * @param timeToEnd how much time to measure until timer ended
  48409. */
  48410. start(timeToEnd?: number): void;
  48411. /**
  48412. * Will force a stop on the next tick.
  48413. */
  48414. stop(): void;
  48415. /**
  48416. * Dispose this timer, clearing all resources
  48417. */
  48418. dispose(): void;
  48419. private _setState;
  48420. private _tick;
  48421. private _stop;
  48422. }
  48423. }
  48424. declare module BABYLON {
  48425. /**
  48426. * The options container for the teleportation module
  48427. */
  48428. export interface IWebXRTeleportationOptions {
  48429. /**
  48430. * if provided, this scene will be used to render meshes.
  48431. */
  48432. customUtilityLayerScene?: Scene;
  48433. /**
  48434. * Values to configure the default target mesh
  48435. */
  48436. defaultTargetMeshOptions?: {
  48437. /**
  48438. * Fill color of the teleportation area
  48439. */
  48440. teleportationFillColor?: string;
  48441. /**
  48442. * Border color for the teleportation area
  48443. */
  48444. teleportationBorderColor?: string;
  48445. /**
  48446. * Disable the mesh's animation sequence
  48447. */
  48448. disableAnimation?: boolean;
  48449. /**
  48450. * Disable lighting on the material or the ring and arrow
  48451. */
  48452. disableLighting?: boolean;
  48453. /**
  48454. * Override the default material of the torus and arrow
  48455. */
  48456. torusArrowMaterial?: Material;
  48457. };
  48458. /**
  48459. * A list of meshes to use as floor meshes.
  48460. * Meshes can be added and removed after initializing the feature using the
  48461. * addFloorMesh and removeFloorMesh functions
  48462. * If empty, rotation will still work
  48463. */
  48464. floorMeshes?: AbstractMesh[];
  48465. /**
  48466. * use this rendering group id for the meshes (optional)
  48467. */
  48468. renderingGroupId?: number;
  48469. /**
  48470. * Should teleportation move only to snap points
  48471. */
  48472. snapPointsOnly?: boolean;
  48473. /**
  48474. * An array of points to which the teleportation will snap to.
  48475. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48476. */
  48477. snapPositions?: Vector3[];
  48478. /**
  48479. * How close should the teleportation ray be in order to snap to position.
  48480. * Default to 0.8 units (meters)
  48481. */
  48482. snapToPositionRadius?: number;
  48483. /**
  48484. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48485. * If you want to support rotation, make sure your mesh has a direction indicator.
  48486. *
  48487. * When left untouched, the default mesh will be initialized.
  48488. */
  48489. teleportationTargetMesh?: AbstractMesh;
  48490. /**
  48491. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48492. */
  48493. timeToTeleport?: number;
  48494. /**
  48495. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48496. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48497. */
  48498. useMainComponentOnly?: boolean;
  48499. /**
  48500. * Should meshes created here be added to a utility layer or the main scene
  48501. */
  48502. useUtilityLayer?: boolean;
  48503. /**
  48504. * Babylon XR Input class for controller
  48505. */
  48506. xrInput: WebXRInput;
  48507. }
  48508. /**
  48509. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48510. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48511. * the input of the attached controllers.
  48512. */
  48513. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48514. private _options;
  48515. private _controllers;
  48516. private _currentTeleportationControllerId;
  48517. private _floorMeshes;
  48518. private _quadraticBezierCurve;
  48519. private _selectionFeature;
  48520. private _snapToPositions;
  48521. private _snappedToPoint;
  48522. private _teleportationRingMaterial?;
  48523. private _tmpRay;
  48524. private _tmpVector;
  48525. /**
  48526. * The module's name
  48527. */
  48528. static readonly Name: string;
  48529. /**
  48530. * The (Babylon) version of this module.
  48531. * This is an integer representing the implementation version.
  48532. * This number does not correspond to the webxr specs version
  48533. */
  48534. static readonly Version: number;
  48535. /**
  48536. * Is movement backwards enabled
  48537. */
  48538. backwardsMovementEnabled: boolean;
  48539. /**
  48540. * Distance to travel when moving backwards
  48541. */
  48542. backwardsTeleportationDistance: number;
  48543. /**
  48544. * The distance from the user to the inspection point in the direction of the controller
  48545. * A higher number will allow the user to move further
  48546. * defaults to 5 (meters, in xr units)
  48547. */
  48548. parabolicCheckRadius: number;
  48549. /**
  48550. * Should the module support parabolic ray on top of direct ray
  48551. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48552. * Very helpful when moving between floors / different heights
  48553. */
  48554. parabolicRayEnabled: boolean;
  48555. /**
  48556. * How much rotation should be applied when rotating right and left
  48557. */
  48558. rotationAngle: number;
  48559. /**
  48560. * Is rotation enabled when moving forward?
  48561. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48562. */
  48563. rotationEnabled: boolean;
  48564. /**
  48565. * constructs a new anchor system
  48566. * @param _xrSessionManager an instance of WebXRSessionManager
  48567. * @param _options configuration object for this feature
  48568. */
  48569. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48570. /**
  48571. * Get the snapPointsOnly flag
  48572. */
  48573. get snapPointsOnly(): boolean;
  48574. /**
  48575. * Sets the snapPointsOnly flag
  48576. * @param snapToPoints should teleportation be exclusively to snap points
  48577. */
  48578. set snapPointsOnly(snapToPoints: boolean);
  48579. /**
  48580. * Add a new mesh to the floor meshes array
  48581. * @param mesh the mesh to use as floor mesh
  48582. */
  48583. addFloorMesh(mesh: AbstractMesh): void;
  48584. /**
  48585. * Add a new snap-to point to fix teleportation to this position
  48586. * @param newSnapPoint The new Snap-To point
  48587. */
  48588. addSnapPoint(newSnapPoint: Vector3): void;
  48589. attach(): boolean;
  48590. detach(): boolean;
  48591. dispose(): void;
  48592. /**
  48593. * Remove a mesh from the floor meshes array
  48594. * @param mesh the mesh to remove
  48595. */
  48596. removeFloorMesh(mesh: AbstractMesh): void;
  48597. /**
  48598. * Remove a mesh from the floor meshes array using its name
  48599. * @param name the mesh name to remove
  48600. */
  48601. removeFloorMeshByName(name: string): void;
  48602. /**
  48603. * 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
  48604. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48605. * @returns was the point found and removed or not
  48606. */
  48607. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48608. /**
  48609. * This function sets a selection feature that will be disabled when
  48610. * the forward ray is shown and will be reattached when hidden.
  48611. * This is used to remove the selection rays when moving.
  48612. * @param selectionFeature the feature to disable when forward movement is enabled
  48613. */
  48614. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48615. protected _onXRFrame(_xrFrame: XRFrame): void;
  48616. private _attachController;
  48617. private _createDefaultTargetMesh;
  48618. private _detachController;
  48619. private _findClosestSnapPointWithRadius;
  48620. private _setTargetMeshPosition;
  48621. private _setTargetMeshVisibility;
  48622. private _showParabolicPath;
  48623. private _teleportForward;
  48624. }
  48625. }
  48626. declare module BABYLON {
  48627. /**
  48628. * Options for the default xr helper
  48629. */
  48630. export class WebXRDefaultExperienceOptions {
  48631. /**
  48632. * Enable or disable default UI to enter XR
  48633. */
  48634. disableDefaultUI?: boolean;
  48635. /**
  48636. * Should teleportation not initialize. defaults to false.
  48637. */
  48638. disableTeleportation?: boolean;
  48639. /**
  48640. * Floor meshes that will be used for teleport
  48641. */
  48642. floorMeshes?: Array<AbstractMesh>;
  48643. /**
  48644. * If set to true, the first frame will not be used to reset position
  48645. * The first frame is mainly used when copying transformation from the old camera
  48646. * Mainly used in AR
  48647. */
  48648. ignoreNativeCameraTransformation?: boolean;
  48649. /**
  48650. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48651. */
  48652. inputOptions?: IWebXRInputOptions;
  48653. /**
  48654. * optional configuration for the output canvas
  48655. */
  48656. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48657. /**
  48658. * optional UI options. This can be used among other to change session mode and reference space type
  48659. */
  48660. uiOptions?: WebXREnterExitUIOptions;
  48661. /**
  48662. * When loading teleportation and pointer select, use stable versions instead of latest.
  48663. */
  48664. useStablePlugins?: boolean;
  48665. /**
  48666. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48667. */
  48668. renderingGroupId?: number;
  48669. /**
  48670. * A list of optional features to init the session with
  48671. * If set to true, all features we support will be added
  48672. */
  48673. optionalFeatures?: boolean | string[];
  48674. }
  48675. /**
  48676. * Default experience which provides a similar setup to the previous webVRExperience
  48677. */
  48678. export class WebXRDefaultExperience {
  48679. /**
  48680. * Base experience
  48681. */
  48682. baseExperience: WebXRExperienceHelper;
  48683. /**
  48684. * Enables ui for entering/exiting xr
  48685. */
  48686. enterExitUI: WebXREnterExitUI;
  48687. /**
  48688. * Input experience extension
  48689. */
  48690. input: WebXRInput;
  48691. /**
  48692. * Enables laser pointer and selection
  48693. */
  48694. pointerSelection: WebXRControllerPointerSelection;
  48695. /**
  48696. * Default target xr should render to
  48697. */
  48698. renderTarget: WebXRRenderTarget;
  48699. /**
  48700. * Enables teleportation
  48701. */
  48702. teleportation: WebXRMotionControllerTeleportation;
  48703. private constructor();
  48704. /**
  48705. * Creates the default xr experience
  48706. * @param scene scene
  48707. * @param options options for basic configuration
  48708. * @returns resulting WebXRDefaultExperience
  48709. */
  48710. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48711. /**
  48712. * DIsposes of the experience helper
  48713. */
  48714. dispose(): void;
  48715. }
  48716. }
  48717. declare module BABYLON {
  48718. /**
  48719. * Options to modify the vr teleportation behavior.
  48720. */
  48721. export interface VRTeleportationOptions {
  48722. /**
  48723. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48724. */
  48725. floorMeshName?: string;
  48726. /**
  48727. * A list of meshes to be used as the teleportation floor. (default: empty)
  48728. */
  48729. floorMeshes?: Mesh[];
  48730. /**
  48731. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48732. */
  48733. teleportationMode?: number;
  48734. /**
  48735. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48736. */
  48737. teleportationTime?: number;
  48738. /**
  48739. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48740. */
  48741. teleportationSpeed?: number;
  48742. /**
  48743. * The easing function used in the animation or null for Linear. (default CircleEase)
  48744. */
  48745. easingFunction?: EasingFunction;
  48746. }
  48747. /**
  48748. * Options to modify the vr experience helper's behavior.
  48749. */
  48750. export interface VRExperienceHelperOptions extends WebVROptions {
  48751. /**
  48752. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48753. */
  48754. createDeviceOrientationCamera?: boolean;
  48755. /**
  48756. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48757. */
  48758. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48759. /**
  48760. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48761. */
  48762. laserToggle?: boolean;
  48763. /**
  48764. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48765. */
  48766. floorMeshes?: Mesh[];
  48767. /**
  48768. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48769. */
  48770. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48771. /**
  48772. * Defines if WebXR should be used instead of WebVR (if available)
  48773. */
  48774. useXR?: boolean;
  48775. }
  48776. /**
  48777. * Event containing information after VR has been entered
  48778. */
  48779. export class OnAfterEnteringVRObservableEvent {
  48780. /**
  48781. * If entering vr was successful
  48782. */
  48783. success: boolean;
  48784. }
  48785. /**
  48786. * Helps to quickly add VR support to an existing scene.
  48787. * See https://doc.babylonjs.com/how_to/webvr_helper
  48788. */
  48789. export class VRExperienceHelper {
  48790. /** Options to modify the vr experience helper's behavior. */
  48791. webVROptions: VRExperienceHelperOptions;
  48792. private _scene;
  48793. private _position;
  48794. private _btnVR;
  48795. private _btnVRDisplayed;
  48796. private _webVRsupported;
  48797. private _webVRready;
  48798. private _webVRrequesting;
  48799. private _webVRpresenting;
  48800. private _hasEnteredVR;
  48801. private _fullscreenVRpresenting;
  48802. private _inputElement;
  48803. private _webVRCamera;
  48804. private _vrDeviceOrientationCamera;
  48805. private _deviceOrientationCamera;
  48806. private _existingCamera;
  48807. private _onKeyDown;
  48808. private _onVrDisplayPresentChange;
  48809. private _onVRDisplayChanged;
  48810. private _onVRRequestPresentStart;
  48811. private _onVRRequestPresentComplete;
  48812. /**
  48813. * 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)
  48814. */
  48815. enableGazeEvenWhenNoPointerLock: boolean;
  48816. /**
  48817. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48818. */
  48819. exitVROnDoubleTap: boolean;
  48820. /**
  48821. * Observable raised right before entering VR.
  48822. */
  48823. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48824. /**
  48825. * Observable raised when entering VR has completed.
  48826. */
  48827. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48828. /**
  48829. * Observable raised when exiting VR.
  48830. */
  48831. onExitingVRObservable: Observable<VRExperienceHelper>;
  48832. /**
  48833. * Observable raised when controller mesh is loaded.
  48834. */
  48835. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48836. /** Return this.onEnteringVRObservable
  48837. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48838. */
  48839. get onEnteringVR(): Observable<VRExperienceHelper>;
  48840. /** Return this.onExitingVRObservable
  48841. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48842. */
  48843. get onExitingVR(): Observable<VRExperienceHelper>;
  48844. /** Return this.onControllerMeshLoadedObservable
  48845. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48846. */
  48847. get onControllerMeshLoaded(): Observable<WebVRController>;
  48848. private _rayLength;
  48849. private _useCustomVRButton;
  48850. private _teleportationRequested;
  48851. private _teleportActive;
  48852. private _floorMeshName;
  48853. private _floorMeshesCollection;
  48854. private _teleportationMode;
  48855. private _teleportationTime;
  48856. private _teleportationSpeed;
  48857. private _teleportationEasing;
  48858. private _rotationAllowed;
  48859. private _teleportBackwardsVector;
  48860. private _teleportationTarget;
  48861. private _isDefaultTeleportationTarget;
  48862. private _postProcessMove;
  48863. private _teleportationFillColor;
  48864. private _teleportationBorderColor;
  48865. private _rotationAngle;
  48866. private _haloCenter;
  48867. private _cameraGazer;
  48868. private _padSensibilityUp;
  48869. private _padSensibilityDown;
  48870. private _leftController;
  48871. private _rightController;
  48872. private _gazeColor;
  48873. private _laserColor;
  48874. private _pickedLaserColor;
  48875. private _pickedGazeColor;
  48876. /**
  48877. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48878. */
  48879. onNewMeshSelected: Observable<AbstractMesh>;
  48880. /**
  48881. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48882. * This observable will provide the mesh and the controller used to select the mesh
  48883. */
  48884. onMeshSelectedWithController: Observable<{
  48885. mesh: AbstractMesh;
  48886. controller: WebVRController;
  48887. }>;
  48888. /**
  48889. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48890. */
  48891. onNewMeshPicked: Observable<PickingInfo>;
  48892. private _circleEase;
  48893. /**
  48894. * Observable raised before camera teleportation
  48895. */
  48896. onBeforeCameraTeleport: Observable<Vector3>;
  48897. /**
  48898. * Observable raised after camera teleportation
  48899. */
  48900. onAfterCameraTeleport: Observable<Vector3>;
  48901. /**
  48902. * Observable raised when current selected mesh gets unselected
  48903. */
  48904. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48905. private _raySelectionPredicate;
  48906. /**
  48907. * To be optionaly changed by user to define custom ray selection
  48908. */
  48909. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48910. /**
  48911. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48912. */
  48913. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48914. /**
  48915. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48916. */
  48917. teleportationEnabled: boolean;
  48918. private _defaultHeight;
  48919. private _teleportationInitialized;
  48920. private _interactionsEnabled;
  48921. private _interactionsRequested;
  48922. private _displayGaze;
  48923. private _displayLaserPointer;
  48924. /**
  48925. * The mesh used to display where the user is going to teleport.
  48926. */
  48927. get teleportationTarget(): Mesh;
  48928. /**
  48929. * Sets the mesh to be used to display where the user is going to teleport.
  48930. */
  48931. set teleportationTarget(value: Mesh);
  48932. /**
  48933. * 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
  48934. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48935. * See https://doc.babylonjs.com/resources/baking_transformations
  48936. */
  48937. get gazeTrackerMesh(): Mesh;
  48938. set gazeTrackerMesh(value: Mesh);
  48939. /**
  48940. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48941. */
  48942. updateGazeTrackerScale: boolean;
  48943. /**
  48944. * If the gaze trackers color should be updated when selecting meshes
  48945. */
  48946. updateGazeTrackerColor: boolean;
  48947. /**
  48948. * If the controller laser color should be updated when selecting meshes
  48949. */
  48950. updateControllerLaserColor: boolean;
  48951. /**
  48952. * The gaze tracking mesh corresponding to the left controller
  48953. */
  48954. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48955. /**
  48956. * The gaze tracking mesh corresponding to the right controller
  48957. */
  48958. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48959. /**
  48960. * If the ray of the gaze should be displayed.
  48961. */
  48962. get displayGaze(): boolean;
  48963. /**
  48964. * Sets if the ray of the gaze should be displayed.
  48965. */
  48966. set displayGaze(value: boolean);
  48967. /**
  48968. * If the ray of the LaserPointer should be displayed.
  48969. */
  48970. get displayLaserPointer(): boolean;
  48971. /**
  48972. * Sets if the ray of the LaserPointer should be displayed.
  48973. */
  48974. set displayLaserPointer(value: boolean);
  48975. /**
  48976. * The deviceOrientationCamera used as the camera when not in VR.
  48977. */
  48978. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48979. /**
  48980. * Based on the current WebVR support, returns the current VR camera used.
  48981. */
  48982. get currentVRCamera(): Nullable<Camera>;
  48983. /**
  48984. * The webVRCamera which is used when in VR.
  48985. */
  48986. get webVRCamera(): WebVRFreeCamera;
  48987. /**
  48988. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48989. */
  48990. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48991. /**
  48992. * The html button that is used to trigger entering into VR.
  48993. */
  48994. get vrButton(): Nullable<HTMLButtonElement>;
  48995. private get _teleportationRequestInitiated();
  48996. /**
  48997. * Defines whether or not Pointer lock should be requested when switching to
  48998. * full screen.
  48999. */
  49000. requestPointerLockOnFullScreen: boolean;
  49001. /**
  49002. * If asking to force XR, this will be populated with the default xr experience
  49003. */
  49004. xr: WebXRDefaultExperience;
  49005. /**
  49006. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49007. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49008. */
  49009. xrTestDone: boolean;
  49010. /**
  49011. * Instantiates a VRExperienceHelper.
  49012. * Helps to quickly add VR support to an existing scene.
  49013. * @param scene The scene the VRExperienceHelper belongs to.
  49014. * @param webVROptions Options to modify the vr experience helper's behavior.
  49015. */
  49016. constructor(scene: Scene,
  49017. /** Options to modify the vr experience helper's behavior. */
  49018. webVROptions?: VRExperienceHelperOptions);
  49019. private completeVRInit;
  49020. private _onDefaultMeshLoaded;
  49021. private _onResize;
  49022. private _onFullscreenChange;
  49023. /**
  49024. * Gets a value indicating if we are currently in VR mode.
  49025. */
  49026. get isInVRMode(): boolean;
  49027. private onVrDisplayPresentChange;
  49028. private onVRDisplayChanged;
  49029. private moveButtonToBottomRight;
  49030. private displayVRButton;
  49031. private updateButtonVisibility;
  49032. private _cachedAngularSensibility;
  49033. /**
  49034. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49035. * Otherwise, will use the fullscreen API.
  49036. */
  49037. enterVR(): void;
  49038. /**
  49039. * Attempt to exit VR, or fullscreen.
  49040. */
  49041. exitVR(): void;
  49042. /**
  49043. * The position of the vr experience helper.
  49044. */
  49045. get position(): Vector3;
  49046. /**
  49047. * Sets the position of the vr experience helper.
  49048. */
  49049. set position(value: Vector3);
  49050. /**
  49051. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49052. */
  49053. enableInteractions(): void;
  49054. private get _noControllerIsActive();
  49055. private beforeRender;
  49056. private _isTeleportationFloor;
  49057. /**
  49058. * Adds a floor mesh to be used for teleportation.
  49059. * @param floorMesh the mesh to be used for teleportation.
  49060. */
  49061. addFloorMesh(floorMesh: Mesh): void;
  49062. /**
  49063. * Removes a floor mesh from being used for teleportation.
  49064. * @param floorMesh the mesh to be removed.
  49065. */
  49066. removeFloorMesh(floorMesh: Mesh): void;
  49067. /**
  49068. * Enables interactions and teleportation using the VR controllers and gaze.
  49069. * @param vrTeleportationOptions options to modify teleportation behavior.
  49070. */
  49071. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49072. private _onNewGamepadConnected;
  49073. private _tryEnableInteractionOnController;
  49074. private _onNewGamepadDisconnected;
  49075. private _enableInteractionOnController;
  49076. private _checkTeleportWithRay;
  49077. private _checkRotate;
  49078. private _checkTeleportBackwards;
  49079. private _enableTeleportationOnController;
  49080. private _createTeleportationCircles;
  49081. private _displayTeleportationTarget;
  49082. private _hideTeleportationTarget;
  49083. private _rotateCamera;
  49084. private _moveTeleportationSelectorTo;
  49085. private _workingVector;
  49086. private _workingQuaternion;
  49087. private _workingMatrix;
  49088. /**
  49089. * Time Constant Teleportation Mode
  49090. */
  49091. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49092. /**
  49093. * Speed Constant Teleportation Mode
  49094. */
  49095. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49096. /**
  49097. * Teleports the users feet to the desired location
  49098. * @param location The location where the user's feet should be placed
  49099. */
  49100. teleportCamera(location: Vector3): void;
  49101. private _convertNormalToDirectionOfRay;
  49102. private _castRayAndSelectObject;
  49103. private _notifySelectedMeshUnselected;
  49104. /**
  49105. * Permanently set new colors for the laser pointer
  49106. * @param color the new laser color
  49107. * @param pickedColor the new laser color when picked mesh detected
  49108. */
  49109. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49110. /**
  49111. * Set lighting enabled / disabled on the laser pointer of both controllers
  49112. * @param enabled should the lighting be enabled on the laser pointer
  49113. */
  49114. setLaserLightingState(enabled?: boolean): void;
  49115. /**
  49116. * Permanently set new colors for the gaze pointer
  49117. * @param color the new gaze color
  49118. * @param pickedColor the new gaze color when picked mesh detected
  49119. */
  49120. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49121. /**
  49122. * Sets the color of the laser ray from the vr controllers.
  49123. * @param color new color for the ray.
  49124. */
  49125. changeLaserColor(color: Color3): void;
  49126. /**
  49127. * Sets the color of the ray from the vr headsets gaze.
  49128. * @param color new color for the ray.
  49129. */
  49130. changeGazeColor(color: Color3): void;
  49131. /**
  49132. * Exits VR and disposes of the vr experience helper
  49133. */
  49134. dispose(): void;
  49135. /**
  49136. * Gets the name of the VRExperienceHelper class
  49137. * @returns "VRExperienceHelper"
  49138. */
  49139. getClassName(): string;
  49140. }
  49141. }
  49142. declare module BABYLON {
  49143. /**
  49144. * Contains an array of blocks representing the octree
  49145. */
  49146. export interface IOctreeContainer<T> {
  49147. /**
  49148. * Blocks within the octree
  49149. */
  49150. blocks: Array<OctreeBlock<T>>;
  49151. }
  49152. /**
  49153. * Class used to store a cell in an octree
  49154. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49155. */
  49156. export class OctreeBlock<T> {
  49157. /**
  49158. * Gets the content of the current block
  49159. */
  49160. entries: T[];
  49161. /**
  49162. * Gets the list of block children
  49163. */
  49164. blocks: Array<OctreeBlock<T>>;
  49165. private _depth;
  49166. private _maxDepth;
  49167. private _capacity;
  49168. private _minPoint;
  49169. private _maxPoint;
  49170. private _boundingVectors;
  49171. private _creationFunc;
  49172. /**
  49173. * Creates a new block
  49174. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49175. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49176. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49177. * @param depth defines the current depth of this block in the octree
  49178. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49179. * @param creationFunc defines a callback to call when an element is added to the block
  49180. */
  49181. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49182. /**
  49183. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49184. */
  49185. get capacity(): number;
  49186. /**
  49187. * Gets the minimum vector (in world space) of the block's bounding box
  49188. */
  49189. get minPoint(): Vector3;
  49190. /**
  49191. * Gets the maximum vector (in world space) of the block's bounding box
  49192. */
  49193. get maxPoint(): Vector3;
  49194. /**
  49195. * Add a new element to this block
  49196. * @param entry defines the element to add
  49197. */
  49198. addEntry(entry: T): void;
  49199. /**
  49200. * Remove an element from this block
  49201. * @param entry defines the element to remove
  49202. */
  49203. removeEntry(entry: T): void;
  49204. /**
  49205. * Add an array of elements to this block
  49206. * @param entries defines the array of elements to add
  49207. */
  49208. addEntries(entries: T[]): void;
  49209. /**
  49210. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49211. * @param frustumPlanes defines the frustum planes to test
  49212. * @param selection defines the array to store current content if selection is positive
  49213. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49214. */
  49215. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49216. /**
  49217. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49218. * @param sphereCenter defines the bounding sphere center
  49219. * @param sphereRadius defines the bounding sphere radius
  49220. * @param selection defines the array to store current content if selection is positive
  49221. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49222. */
  49223. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49224. /**
  49225. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49226. * @param ray defines the ray to test with
  49227. * @param selection defines the array to store current content if selection is positive
  49228. */
  49229. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49230. /**
  49231. * Subdivide the content into child blocks (this block will then be empty)
  49232. */
  49233. createInnerBlocks(): void;
  49234. /**
  49235. * @hidden
  49236. */
  49237. 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;
  49238. }
  49239. }
  49240. declare module BABYLON {
  49241. /**
  49242. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49243. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49244. */
  49245. export class Octree<T> {
  49246. /** 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.) */
  49247. maxDepth: number;
  49248. /**
  49249. * Blocks within the octree containing objects
  49250. */
  49251. blocks: Array<OctreeBlock<T>>;
  49252. /**
  49253. * Content stored in the octree
  49254. */
  49255. dynamicContent: T[];
  49256. private _maxBlockCapacity;
  49257. private _selectionContent;
  49258. private _creationFunc;
  49259. /**
  49260. * Creates a octree
  49261. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49262. * @param creationFunc function to be used to instatiate the octree
  49263. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49264. * @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.)
  49265. */
  49266. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49267. /** 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.) */
  49268. maxDepth?: number);
  49269. /**
  49270. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49271. * @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);
  49272. * @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);
  49273. * @param entries meshes to be added to the octree blocks
  49274. */
  49275. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49276. /**
  49277. * Adds a mesh to the octree
  49278. * @param entry Mesh to add to the octree
  49279. */
  49280. addMesh(entry: T): void;
  49281. /**
  49282. * Remove an element from the octree
  49283. * @param entry defines the element to remove
  49284. */
  49285. removeMesh(entry: T): void;
  49286. /**
  49287. * Selects an array of meshes within the frustum
  49288. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49289. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49290. * @returns array of meshes within the frustum
  49291. */
  49292. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49293. /**
  49294. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49295. * @param sphereCenter defines the bounding sphere center
  49296. * @param sphereRadius defines the bounding sphere radius
  49297. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49298. * @returns an array of objects that intersect the sphere
  49299. */
  49300. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49301. /**
  49302. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49303. * @param ray defines the ray to test with
  49304. * @returns array of intersected objects
  49305. */
  49306. intersectsRay(ray: Ray): SmartArray<T>;
  49307. /**
  49308. * Adds a mesh into the octree block if it intersects the block
  49309. */
  49310. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49311. /**
  49312. * Adds a submesh into the octree block if it intersects the block
  49313. */
  49314. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49315. }
  49316. }
  49317. declare module BABYLON {
  49318. interface Scene {
  49319. /**
  49320. * @hidden
  49321. * Backing Filed
  49322. */
  49323. _selectionOctree: Octree<AbstractMesh>;
  49324. /**
  49325. * Gets the octree used to boost mesh selection (picking)
  49326. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49327. */
  49328. selectionOctree: Octree<AbstractMesh>;
  49329. /**
  49330. * Creates or updates the octree used to boost selection (picking)
  49331. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49332. * @param maxCapacity defines the maximum capacity per leaf
  49333. * @param maxDepth defines the maximum depth of the octree
  49334. * @returns an octree of AbstractMesh
  49335. */
  49336. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49337. }
  49338. interface AbstractMesh {
  49339. /**
  49340. * @hidden
  49341. * Backing Field
  49342. */
  49343. _submeshesOctree: Octree<SubMesh>;
  49344. /**
  49345. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49346. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49347. * @param maxCapacity defines the maximum size of each block (64 by default)
  49348. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49349. * @returns the new octree
  49350. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49351. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49352. */
  49353. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49354. }
  49355. /**
  49356. * Defines the octree scene component responsible to manage any octrees
  49357. * in a given scene.
  49358. */
  49359. export class OctreeSceneComponent {
  49360. /**
  49361. * The component name help to identify the component in the list of scene components.
  49362. */
  49363. readonly name: string;
  49364. /**
  49365. * The scene the component belongs to.
  49366. */
  49367. scene: Scene;
  49368. /**
  49369. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49370. */
  49371. readonly checksIsEnabled: boolean;
  49372. /**
  49373. * Creates a new instance of the component for the given scene
  49374. * @param scene Defines the scene to register the component in
  49375. */
  49376. constructor(scene: Scene);
  49377. /**
  49378. * Registers the component in a given scene
  49379. */
  49380. register(): void;
  49381. /**
  49382. * Return the list of active meshes
  49383. * @returns the list of active meshes
  49384. */
  49385. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49386. /**
  49387. * Return the list of active sub meshes
  49388. * @param mesh The mesh to get the candidates sub meshes from
  49389. * @returns the list of active sub meshes
  49390. */
  49391. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49392. private _tempRay;
  49393. /**
  49394. * Return the list of sub meshes intersecting with a given local ray
  49395. * @param mesh defines the mesh to find the submesh for
  49396. * @param localRay defines the ray in local space
  49397. * @returns the list of intersecting sub meshes
  49398. */
  49399. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49400. /**
  49401. * Return the list of sub meshes colliding with a collider
  49402. * @param mesh defines the mesh to find the submesh for
  49403. * @param collider defines the collider to evaluate the collision against
  49404. * @returns the list of colliding sub meshes
  49405. */
  49406. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49407. /**
  49408. * Rebuilds the elements related to this component in case of
  49409. * context lost for instance.
  49410. */
  49411. rebuild(): void;
  49412. /**
  49413. * Disposes the component and the associated ressources.
  49414. */
  49415. dispose(): void;
  49416. }
  49417. }
  49418. declare module BABYLON {
  49419. /**
  49420. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49421. */
  49422. export class Gizmo implements IDisposable {
  49423. /** The utility layer the gizmo will be added to */
  49424. gizmoLayer: UtilityLayerRenderer;
  49425. /**
  49426. * The root mesh of the gizmo
  49427. */
  49428. _rootMesh: Mesh;
  49429. private _attachedMesh;
  49430. /**
  49431. * Ratio for the scale of the gizmo (Default: 1)
  49432. */
  49433. scaleRatio: number;
  49434. /**
  49435. * If a custom mesh has been set (Default: false)
  49436. */
  49437. protected _customMeshSet: boolean;
  49438. /**
  49439. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49440. * * When set, interactions will be enabled
  49441. */
  49442. get attachedMesh(): Nullable<AbstractMesh>;
  49443. set attachedMesh(value: Nullable<AbstractMesh>);
  49444. /**
  49445. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49446. * @param mesh The mesh to replace the default mesh of the gizmo
  49447. */
  49448. setCustomMesh(mesh: Mesh): void;
  49449. /**
  49450. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49451. */
  49452. updateGizmoRotationToMatchAttachedMesh: boolean;
  49453. /**
  49454. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49455. */
  49456. updateGizmoPositionToMatchAttachedMesh: boolean;
  49457. /**
  49458. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49459. */
  49460. updateScale: boolean;
  49461. protected _interactionsEnabled: boolean;
  49462. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49463. private _beforeRenderObserver;
  49464. private _tempVector;
  49465. /**
  49466. * Creates a gizmo
  49467. * @param gizmoLayer The utility layer the gizmo will be added to
  49468. */
  49469. constructor(
  49470. /** The utility layer the gizmo will be added to */
  49471. gizmoLayer?: UtilityLayerRenderer);
  49472. /**
  49473. * Updates the gizmo to match the attached mesh's position/rotation
  49474. */
  49475. protected _update(): void;
  49476. /**
  49477. * Disposes of the gizmo
  49478. */
  49479. dispose(): void;
  49480. }
  49481. }
  49482. declare module BABYLON {
  49483. /**
  49484. * Single plane drag gizmo
  49485. */
  49486. export class PlaneDragGizmo extends Gizmo {
  49487. /**
  49488. * Drag behavior responsible for the gizmos dragging interactions
  49489. */
  49490. dragBehavior: PointerDragBehavior;
  49491. private _pointerObserver;
  49492. /**
  49493. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49494. */
  49495. snapDistance: number;
  49496. /**
  49497. * Event that fires each time the gizmo snaps to a new location.
  49498. * * snapDistance is the the change in distance
  49499. */
  49500. onSnapObservable: Observable<{
  49501. snapDistance: number;
  49502. }>;
  49503. private _plane;
  49504. private _coloredMaterial;
  49505. private _hoverMaterial;
  49506. private _isEnabled;
  49507. private _parent;
  49508. /** @hidden */
  49509. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49510. /** @hidden */
  49511. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49512. /**
  49513. * Creates a PlaneDragGizmo
  49514. * @param gizmoLayer The utility layer the gizmo will be added to
  49515. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49516. * @param color The color of the gizmo
  49517. */
  49518. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49519. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49520. /**
  49521. * If the gizmo is enabled
  49522. */
  49523. set isEnabled(value: boolean);
  49524. get isEnabled(): boolean;
  49525. /**
  49526. * Disposes of the gizmo
  49527. */
  49528. dispose(): void;
  49529. }
  49530. }
  49531. declare module BABYLON {
  49532. /**
  49533. * Gizmo that enables dragging a mesh along 3 axis
  49534. */
  49535. export class PositionGizmo extends Gizmo {
  49536. /**
  49537. * Internal gizmo used for interactions on the x axis
  49538. */
  49539. xGizmo: AxisDragGizmo;
  49540. /**
  49541. * Internal gizmo used for interactions on the y axis
  49542. */
  49543. yGizmo: AxisDragGizmo;
  49544. /**
  49545. * Internal gizmo used for interactions on the z axis
  49546. */
  49547. zGizmo: AxisDragGizmo;
  49548. /**
  49549. * Internal gizmo used for interactions on the yz plane
  49550. */
  49551. xPlaneGizmo: PlaneDragGizmo;
  49552. /**
  49553. * Internal gizmo used for interactions on the xz plane
  49554. */
  49555. yPlaneGizmo: PlaneDragGizmo;
  49556. /**
  49557. * Internal gizmo used for interactions on the xy plane
  49558. */
  49559. zPlaneGizmo: PlaneDragGizmo;
  49560. /**
  49561. * private variables
  49562. */
  49563. private _meshAttached;
  49564. private _updateGizmoRotationToMatchAttachedMesh;
  49565. private _snapDistance;
  49566. private _scaleRatio;
  49567. /** Fires an event when any of it's sub gizmos are dragged */
  49568. onDragStartObservable: Observable<unknown>;
  49569. /** Fires an event when any of it's sub gizmos are released from dragging */
  49570. onDragEndObservable: Observable<unknown>;
  49571. /**
  49572. * If set to true, planar drag is enabled
  49573. */
  49574. private _planarGizmoEnabled;
  49575. get attachedMesh(): Nullable<AbstractMesh>;
  49576. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49577. /**
  49578. * Creates a PositionGizmo
  49579. * @param gizmoLayer The utility layer the gizmo will be added to
  49580. */
  49581. constructor(gizmoLayer?: UtilityLayerRenderer);
  49582. /**
  49583. * If the planar drag gizmo is enabled
  49584. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49585. */
  49586. set planarGizmoEnabled(value: boolean);
  49587. get planarGizmoEnabled(): boolean;
  49588. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49589. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49590. /**
  49591. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49592. */
  49593. set snapDistance(value: number);
  49594. get snapDistance(): number;
  49595. /**
  49596. * Ratio for the scale of the gizmo (Default: 1)
  49597. */
  49598. set scaleRatio(value: number);
  49599. get scaleRatio(): number;
  49600. /**
  49601. * Disposes of the gizmo
  49602. */
  49603. dispose(): void;
  49604. /**
  49605. * CustomMeshes are not supported by this gizmo
  49606. * @param mesh The mesh to replace the default mesh of the gizmo
  49607. */
  49608. setCustomMesh(mesh: Mesh): void;
  49609. }
  49610. }
  49611. declare module BABYLON {
  49612. /**
  49613. * Single axis drag gizmo
  49614. */
  49615. export class AxisDragGizmo extends Gizmo {
  49616. /**
  49617. * Drag behavior responsible for the gizmos dragging interactions
  49618. */
  49619. dragBehavior: PointerDragBehavior;
  49620. private _pointerObserver;
  49621. /**
  49622. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49623. */
  49624. snapDistance: number;
  49625. /**
  49626. * Event that fires each time the gizmo snaps to a new location.
  49627. * * snapDistance is the the change in distance
  49628. */
  49629. onSnapObservable: Observable<{
  49630. snapDistance: number;
  49631. }>;
  49632. private _isEnabled;
  49633. private _parent;
  49634. private _arrow;
  49635. private _coloredMaterial;
  49636. private _hoverMaterial;
  49637. /** @hidden */
  49638. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49639. /** @hidden */
  49640. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49641. /**
  49642. * Creates an AxisDragGizmo
  49643. * @param gizmoLayer The utility layer the gizmo will be added to
  49644. * @param dragAxis The axis which the gizmo will be able to drag on
  49645. * @param color The color of the gizmo
  49646. */
  49647. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49648. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49649. /**
  49650. * If the gizmo is enabled
  49651. */
  49652. set isEnabled(value: boolean);
  49653. get isEnabled(): boolean;
  49654. /**
  49655. * Disposes of the gizmo
  49656. */
  49657. dispose(): void;
  49658. }
  49659. }
  49660. declare module BABYLON.Debug {
  49661. /**
  49662. * The Axes viewer will show 3 axes in a specific point in space
  49663. */
  49664. export class AxesViewer {
  49665. private _xAxis;
  49666. private _yAxis;
  49667. private _zAxis;
  49668. private _scaleLinesFactor;
  49669. private _instanced;
  49670. /**
  49671. * Gets the hosting scene
  49672. */
  49673. scene: Scene;
  49674. /**
  49675. * Gets or sets a number used to scale line length
  49676. */
  49677. scaleLines: number;
  49678. /** Gets the node hierarchy used to render x-axis */
  49679. get xAxis(): TransformNode;
  49680. /** Gets the node hierarchy used to render y-axis */
  49681. get yAxis(): TransformNode;
  49682. /** Gets the node hierarchy used to render z-axis */
  49683. get zAxis(): TransformNode;
  49684. /**
  49685. * Creates a new AxesViewer
  49686. * @param scene defines the hosting scene
  49687. * @param scaleLines defines a number used to scale line length (1 by default)
  49688. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49689. * @param xAxis defines the node hierarchy used to render the x-axis
  49690. * @param yAxis defines the node hierarchy used to render the y-axis
  49691. * @param zAxis defines the node hierarchy used to render the z-axis
  49692. */
  49693. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49694. /**
  49695. * Force the viewer to update
  49696. * @param position defines the position of the viewer
  49697. * @param xaxis defines the x axis of the viewer
  49698. * @param yaxis defines the y axis of the viewer
  49699. * @param zaxis defines the z axis of the viewer
  49700. */
  49701. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49702. /**
  49703. * Creates an instance of this axes viewer.
  49704. * @returns a new axes viewer with instanced meshes
  49705. */
  49706. createInstance(): AxesViewer;
  49707. /** Releases resources */
  49708. dispose(): void;
  49709. private static _SetRenderingGroupId;
  49710. }
  49711. }
  49712. declare module BABYLON.Debug {
  49713. /**
  49714. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49715. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49716. */
  49717. export class BoneAxesViewer extends AxesViewer {
  49718. /**
  49719. * Gets or sets the target mesh where to display the axes viewer
  49720. */
  49721. mesh: Nullable<Mesh>;
  49722. /**
  49723. * Gets or sets the target bone where to display the axes viewer
  49724. */
  49725. bone: Nullable<Bone>;
  49726. /** Gets current position */
  49727. pos: Vector3;
  49728. /** Gets direction of X axis */
  49729. xaxis: Vector3;
  49730. /** Gets direction of Y axis */
  49731. yaxis: Vector3;
  49732. /** Gets direction of Z axis */
  49733. zaxis: Vector3;
  49734. /**
  49735. * Creates a new BoneAxesViewer
  49736. * @param scene defines the hosting scene
  49737. * @param bone defines the target bone
  49738. * @param mesh defines the target mesh
  49739. * @param scaleLines defines a scaling factor for line length (1 by default)
  49740. */
  49741. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49742. /**
  49743. * Force the viewer to update
  49744. */
  49745. update(): void;
  49746. /** Releases resources */
  49747. dispose(): void;
  49748. }
  49749. }
  49750. declare module BABYLON {
  49751. /**
  49752. * Interface used to define scene explorer extensibility option
  49753. */
  49754. export interface IExplorerExtensibilityOption {
  49755. /**
  49756. * Define the option label
  49757. */
  49758. label: string;
  49759. /**
  49760. * Defines the action to execute on click
  49761. */
  49762. action: (entity: any) => void;
  49763. }
  49764. /**
  49765. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49766. */
  49767. export interface IExplorerExtensibilityGroup {
  49768. /**
  49769. * Defines a predicate to test if a given type mut be extended
  49770. */
  49771. predicate: (entity: any) => boolean;
  49772. /**
  49773. * Gets the list of options added to a type
  49774. */
  49775. entries: IExplorerExtensibilityOption[];
  49776. }
  49777. /**
  49778. * Interface used to define the options to use to create the Inspector
  49779. */
  49780. export interface IInspectorOptions {
  49781. /**
  49782. * Display in overlay mode (default: false)
  49783. */
  49784. overlay?: boolean;
  49785. /**
  49786. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49787. */
  49788. globalRoot?: HTMLElement;
  49789. /**
  49790. * Display the Scene explorer
  49791. */
  49792. showExplorer?: boolean;
  49793. /**
  49794. * Display the property inspector
  49795. */
  49796. showInspector?: boolean;
  49797. /**
  49798. * Display in embed mode (both panes on the right)
  49799. */
  49800. embedMode?: boolean;
  49801. /**
  49802. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49803. */
  49804. handleResize?: boolean;
  49805. /**
  49806. * Allow the panes to popup (default: true)
  49807. */
  49808. enablePopup?: boolean;
  49809. /**
  49810. * Allow the panes to be closed by users (default: true)
  49811. */
  49812. enableClose?: boolean;
  49813. /**
  49814. * Optional list of extensibility entries
  49815. */
  49816. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49817. /**
  49818. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49819. */
  49820. inspectorURL?: string;
  49821. /**
  49822. * Optional initial tab (default to DebugLayerTab.Properties)
  49823. */
  49824. initialTab?: DebugLayerTab;
  49825. }
  49826. interface Scene {
  49827. /**
  49828. * @hidden
  49829. * Backing field
  49830. */
  49831. _debugLayer: DebugLayer;
  49832. /**
  49833. * Gets the debug layer (aka Inspector) associated with the scene
  49834. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49835. */
  49836. debugLayer: DebugLayer;
  49837. }
  49838. /**
  49839. * Enum of inspector action tab
  49840. */
  49841. export enum DebugLayerTab {
  49842. /**
  49843. * Properties tag (default)
  49844. */
  49845. Properties = 0,
  49846. /**
  49847. * Debug tab
  49848. */
  49849. Debug = 1,
  49850. /**
  49851. * Statistics tab
  49852. */
  49853. Statistics = 2,
  49854. /**
  49855. * Tools tab
  49856. */
  49857. Tools = 3,
  49858. /**
  49859. * Settings tab
  49860. */
  49861. Settings = 4
  49862. }
  49863. /**
  49864. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49865. * what is happening in your scene
  49866. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49867. */
  49868. export class DebugLayer {
  49869. /**
  49870. * Define the url to get the inspector script from.
  49871. * By default it uses the babylonjs CDN.
  49872. * @ignoreNaming
  49873. */
  49874. static InspectorURL: string;
  49875. private _scene;
  49876. private BJSINSPECTOR;
  49877. private _onPropertyChangedObservable?;
  49878. /**
  49879. * Observable triggered when a property is changed through the inspector.
  49880. */
  49881. get onPropertyChangedObservable(): any;
  49882. /**
  49883. * Instantiates a new debug layer.
  49884. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49885. * what is happening in your scene
  49886. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49887. * @param scene Defines the scene to inspect
  49888. */
  49889. constructor(scene: Scene);
  49890. /** Creates the inspector window. */
  49891. private _createInspector;
  49892. /**
  49893. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49894. * @param entity defines the entity to select
  49895. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49896. */
  49897. select(entity: any, lineContainerTitles?: string | string[]): void;
  49898. /** Get the inspector from bundle or global */
  49899. private _getGlobalInspector;
  49900. /**
  49901. * Get if the inspector is visible or not.
  49902. * @returns true if visible otherwise, false
  49903. */
  49904. isVisible(): boolean;
  49905. /**
  49906. * Hide the inspector and close its window.
  49907. */
  49908. hide(): void;
  49909. /**
  49910. * Update the scene in the inspector
  49911. */
  49912. setAsActiveScene(): void;
  49913. /**
  49914. * Launch the debugLayer.
  49915. * @param config Define the configuration of the inspector
  49916. * @return a promise fulfilled when the debug layer is visible
  49917. */
  49918. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49919. }
  49920. }
  49921. declare module BABYLON {
  49922. /**
  49923. * Class containing static functions to help procedurally build meshes
  49924. */
  49925. export class BoxBuilder {
  49926. /**
  49927. * Creates a box mesh
  49928. * * The parameter `size` sets the size (float) of each box side (default 1)
  49929. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49930. * * 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)
  49931. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49933. * * 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
  49934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49935. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49936. * @param name defines the name of the mesh
  49937. * @param options defines the options used to create the mesh
  49938. * @param scene defines the hosting scene
  49939. * @returns the box mesh
  49940. */
  49941. static CreateBox(name: string, options: {
  49942. size?: number;
  49943. width?: number;
  49944. height?: number;
  49945. depth?: number;
  49946. faceUV?: Vector4[];
  49947. faceColors?: Color4[];
  49948. sideOrientation?: number;
  49949. frontUVs?: Vector4;
  49950. backUVs?: Vector4;
  49951. wrap?: boolean;
  49952. topBaseAt?: number;
  49953. bottomBaseAt?: number;
  49954. updatable?: boolean;
  49955. }, scene?: Nullable<Scene>): Mesh;
  49956. }
  49957. }
  49958. declare module BABYLON.Debug {
  49959. /**
  49960. * Used to show the physics impostor around the specific mesh
  49961. */
  49962. export class PhysicsViewer {
  49963. /** @hidden */
  49964. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49965. /** @hidden */
  49966. protected _meshes: Array<Nullable<AbstractMesh>>;
  49967. /** @hidden */
  49968. protected _scene: Nullable<Scene>;
  49969. /** @hidden */
  49970. protected _numMeshes: number;
  49971. /** @hidden */
  49972. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49973. private _renderFunction;
  49974. private _utilityLayer;
  49975. private _debugBoxMesh;
  49976. private _debugSphereMesh;
  49977. private _debugCylinderMesh;
  49978. private _debugMaterial;
  49979. private _debugMeshMeshes;
  49980. /**
  49981. * Creates a new PhysicsViewer
  49982. * @param scene defines the hosting scene
  49983. */
  49984. constructor(scene: Scene);
  49985. /** @hidden */
  49986. protected _updateDebugMeshes(): void;
  49987. /**
  49988. * Renders a specified physic impostor
  49989. * @param impostor defines the impostor to render
  49990. * @param targetMesh defines the mesh represented by the impostor
  49991. * @returns the new debug mesh used to render the impostor
  49992. */
  49993. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49994. /**
  49995. * Hides a specified physic impostor
  49996. * @param impostor defines the impostor to hide
  49997. */
  49998. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49999. private _getDebugMaterial;
  50000. private _getDebugBoxMesh;
  50001. private _getDebugSphereMesh;
  50002. private _getDebugCylinderMesh;
  50003. private _getDebugMeshMesh;
  50004. private _getDebugMesh;
  50005. /** Releases all resources */
  50006. dispose(): void;
  50007. }
  50008. }
  50009. declare module BABYLON {
  50010. /**
  50011. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50012. * in order to better appreciate the issue one might have.
  50013. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50014. */
  50015. export class RayHelper {
  50016. /**
  50017. * Defines the ray we are currently tryin to visualize.
  50018. */
  50019. ray: Nullable<Ray>;
  50020. private _renderPoints;
  50021. private _renderLine;
  50022. private _renderFunction;
  50023. private _scene;
  50024. private _updateToMeshFunction;
  50025. private _attachedToMesh;
  50026. private _meshSpaceDirection;
  50027. private _meshSpaceOrigin;
  50028. /**
  50029. * Helper function to create a colored helper in a scene in one line.
  50030. * @param ray Defines the ray we are currently tryin to visualize
  50031. * @param scene Defines the scene the ray is used in
  50032. * @param color Defines the color we want to see the ray in
  50033. * @returns The newly created ray helper.
  50034. */
  50035. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50036. /**
  50037. * Instantiate a new ray helper.
  50038. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50039. * in order to better appreciate the issue one might have.
  50040. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50041. * @param ray Defines the ray we are currently tryin to visualize
  50042. */
  50043. constructor(ray: Ray);
  50044. /**
  50045. * Shows the ray we are willing to debug.
  50046. * @param scene Defines the scene the ray needs to be rendered in
  50047. * @param color Defines the color the ray needs to be rendered in
  50048. */
  50049. show(scene: Scene, color?: Color3): void;
  50050. /**
  50051. * Hides the ray we are debugging.
  50052. */
  50053. hide(): void;
  50054. private _render;
  50055. /**
  50056. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50057. * @param mesh Defines the mesh we want the helper attached to
  50058. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50059. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50060. * @param length Defines the length of the ray
  50061. */
  50062. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50063. /**
  50064. * Detach the ray helper from the mesh it has previously been attached to.
  50065. */
  50066. detachFromMesh(): void;
  50067. private _updateToMesh;
  50068. /**
  50069. * Dispose the helper and release its associated resources.
  50070. */
  50071. dispose(): void;
  50072. }
  50073. }
  50074. declare module BABYLON.Debug {
  50075. /**
  50076. * Class used to render a debug view of a given skeleton
  50077. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50078. */
  50079. export class SkeletonViewer {
  50080. /** defines the skeleton to render */
  50081. skeleton: Skeleton;
  50082. /** defines the mesh attached to the skeleton */
  50083. mesh: AbstractMesh;
  50084. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50085. autoUpdateBonesMatrices: boolean;
  50086. /** defines the rendering group id to use with the viewer */
  50087. renderingGroupId: number;
  50088. /** Gets or sets the color used to render the skeleton */
  50089. color: Color3;
  50090. private _scene;
  50091. private _debugLines;
  50092. private _debugMesh;
  50093. private _isEnabled;
  50094. private _renderFunction;
  50095. private _utilityLayer;
  50096. /**
  50097. * Returns the mesh used to render the bones
  50098. */
  50099. get debugMesh(): Nullable<LinesMesh>;
  50100. /**
  50101. * Creates a new SkeletonViewer
  50102. * @param skeleton defines the skeleton to render
  50103. * @param mesh defines the mesh attached to the skeleton
  50104. * @param scene defines the hosting scene
  50105. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50106. * @param renderingGroupId defines the rendering group id to use with the viewer
  50107. */
  50108. constructor(
  50109. /** defines the skeleton to render */
  50110. skeleton: Skeleton,
  50111. /** defines the mesh attached to the skeleton */
  50112. mesh: AbstractMesh, scene: Scene,
  50113. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50114. autoUpdateBonesMatrices?: boolean,
  50115. /** defines the rendering group id to use with the viewer */
  50116. renderingGroupId?: number);
  50117. /** Gets or sets a boolean indicating if the viewer is enabled */
  50118. set isEnabled(value: boolean);
  50119. get isEnabled(): boolean;
  50120. private _getBonePosition;
  50121. private _getLinesForBonesWithLength;
  50122. private _getLinesForBonesNoLength;
  50123. /** Update the viewer to sync with current skeleton state */
  50124. update(): void;
  50125. /** Release associated resources */
  50126. dispose(): void;
  50127. }
  50128. }
  50129. declare module BABYLON {
  50130. /**
  50131. * Enum for Device Types
  50132. */
  50133. export enum DeviceType {
  50134. /** Generic */
  50135. Generic = 0,
  50136. /** Keyboard */
  50137. Keyboard = 1,
  50138. /** Mouse */
  50139. Mouse = 2,
  50140. /** Touch Pointers */
  50141. Touch = 3,
  50142. /** PS4 Dual Shock */
  50143. DualShock = 4,
  50144. /** Xbox */
  50145. Xbox = 5,
  50146. /** Switch Controller */
  50147. Switch = 6
  50148. }
  50149. /**
  50150. * Enum for All Pointers (Touch/Mouse)
  50151. */
  50152. export enum PointerInput {
  50153. /** Horizontal Axis */
  50154. Horizontal = 0,
  50155. /** Vertical Axis */
  50156. Vertical = 1,
  50157. /** Left Click or Touch */
  50158. LeftClick = 2,
  50159. /** Middle Click */
  50160. MiddleClick = 3,
  50161. /** Right Click */
  50162. RightClick = 4,
  50163. /** Browser Back */
  50164. BrowserBack = 5,
  50165. /** Browser Forward */
  50166. BrowserForward = 6
  50167. }
  50168. /**
  50169. * Enum for Dual Shock Gamepad
  50170. */
  50171. export enum DualShockInput {
  50172. /** Cross */
  50173. Cross = 0,
  50174. /** Circle */
  50175. Circle = 1,
  50176. /** Square */
  50177. Square = 2,
  50178. /** Triangle */
  50179. Triangle = 3,
  50180. /** L1 */
  50181. L1 = 4,
  50182. /** R1 */
  50183. R1 = 5,
  50184. /** L2 */
  50185. L2 = 6,
  50186. /** R2 */
  50187. R2 = 7,
  50188. /** Share */
  50189. Share = 8,
  50190. /** Options */
  50191. Options = 9,
  50192. /** L3 */
  50193. L3 = 10,
  50194. /** R3 */
  50195. R3 = 11,
  50196. /** DPadUp */
  50197. DPadUp = 12,
  50198. /** DPadDown */
  50199. DPadDown = 13,
  50200. /** DPadLeft */
  50201. DPadLeft = 14,
  50202. /** DRight */
  50203. DPadRight = 15,
  50204. /** Home */
  50205. Home = 16,
  50206. /** TouchPad */
  50207. TouchPad = 17,
  50208. /** LStickXAxis */
  50209. LStickXAxis = 18,
  50210. /** LStickYAxis */
  50211. LStickYAxis = 19,
  50212. /** RStickXAxis */
  50213. RStickXAxis = 20,
  50214. /** RStickYAxis */
  50215. RStickYAxis = 21
  50216. }
  50217. /**
  50218. * Enum for Xbox Gamepad
  50219. */
  50220. export enum XboxInput {
  50221. /** A */
  50222. A = 0,
  50223. /** B */
  50224. B = 1,
  50225. /** X */
  50226. X = 2,
  50227. /** Y */
  50228. Y = 3,
  50229. /** LB */
  50230. LB = 4,
  50231. /** RB */
  50232. RB = 5,
  50233. /** LT */
  50234. LT = 6,
  50235. /** RT */
  50236. RT = 7,
  50237. /** Back */
  50238. Back = 8,
  50239. /** Start */
  50240. Start = 9,
  50241. /** LS */
  50242. LS = 10,
  50243. /** RS */
  50244. RS = 11,
  50245. /** DPadUp */
  50246. DPadUp = 12,
  50247. /** DPadDown */
  50248. DPadDown = 13,
  50249. /** DPadLeft */
  50250. DPadLeft = 14,
  50251. /** DRight */
  50252. DPadRight = 15,
  50253. /** Home */
  50254. Home = 16,
  50255. /** LStickXAxis */
  50256. LStickXAxis = 17,
  50257. /** LStickYAxis */
  50258. LStickYAxis = 18,
  50259. /** RStickXAxis */
  50260. RStickXAxis = 19,
  50261. /** RStickYAxis */
  50262. RStickYAxis = 20
  50263. }
  50264. /**
  50265. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50266. */
  50267. export enum SwitchInput {
  50268. /** B */
  50269. B = 0,
  50270. /** A */
  50271. A = 1,
  50272. /** Y */
  50273. Y = 2,
  50274. /** X */
  50275. X = 3,
  50276. /** L */
  50277. L = 4,
  50278. /** R */
  50279. R = 5,
  50280. /** ZL */
  50281. ZL = 6,
  50282. /** ZR */
  50283. ZR = 7,
  50284. /** Minus */
  50285. Minus = 8,
  50286. /** Plus */
  50287. Plus = 9,
  50288. /** LS */
  50289. LS = 10,
  50290. /** RS */
  50291. RS = 11,
  50292. /** DPadUp */
  50293. DPadUp = 12,
  50294. /** DPadDown */
  50295. DPadDown = 13,
  50296. /** DPadLeft */
  50297. DPadLeft = 14,
  50298. /** DRight */
  50299. DPadRight = 15,
  50300. /** Home */
  50301. Home = 16,
  50302. /** Capture */
  50303. Capture = 17,
  50304. /** LStickXAxis */
  50305. LStickXAxis = 18,
  50306. /** LStickYAxis */
  50307. LStickYAxis = 19,
  50308. /** RStickXAxis */
  50309. RStickXAxis = 20,
  50310. /** RStickYAxis */
  50311. RStickYAxis = 21
  50312. }
  50313. }
  50314. declare module BABYLON {
  50315. /**
  50316. * This class will take all inputs from Keyboard, Pointer, and
  50317. * any Gamepads and provide a polling system that all devices
  50318. * will use. This class assumes that there will only be one
  50319. * pointer device and one keyboard.
  50320. */
  50321. export class DeviceInputSystem implements IDisposable {
  50322. /**
  50323. * Callback to be triggered when a device is connected
  50324. */
  50325. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50326. /**
  50327. * Callback to be triggered when a device is disconnected
  50328. */
  50329. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50330. /**
  50331. * Callback to be triggered when event driven input is updated
  50332. */
  50333. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50334. private _inputs;
  50335. private _gamepads;
  50336. private _keyboardActive;
  50337. private _pointerActive;
  50338. private _elementToAttachTo;
  50339. private _keyboardDownEvent;
  50340. private _keyboardUpEvent;
  50341. private _pointerMoveEvent;
  50342. private _pointerDownEvent;
  50343. private _pointerUpEvent;
  50344. private _gamepadConnectedEvent;
  50345. private _gamepadDisconnectedEvent;
  50346. private static _MAX_KEYCODES;
  50347. private static _MAX_POINTER_INPUTS;
  50348. private constructor();
  50349. /**
  50350. * Creates a new DeviceInputSystem instance
  50351. * @param engine Engine to pull input element from
  50352. * @returns The new instance
  50353. */
  50354. static Create(engine: Engine): DeviceInputSystem;
  50355. /**
  50356. * Checks for current device input value, given an id and input index
  50357. * @param deviceName Id of connected device
  50358. * @param inputIndex Index of device input
  50359. * @returns Current value of input
  50360. */
  50361. /**
  50362. * Checks for current device input value, given an id and input index
  50363. * @param deviceType Enum specifiying device type
  50364. * @param deviceSlot "Slot" or index that device is referenced in
  50365. * @param inputIndex Id of input to be checked
  50366. * @returns Current value of input
  50367. */
  50368. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50369. /**
  50370. * Dispose of all the eventlisteners
  50371. */
  50372. dispose(): void;
  50373. /**
  50374. * Add device and inputs to device array
  50375. * @param deviceType Enum specifiying device type
  50376. * @param deviceSlot "Slot" or index that device is referenced in
  50377. * @param numberOfInputs Number of input entries to create for given device
  50378. */
  50379. private _registerDevice;
  50380. /**
  50381. * Given a specific device name, remove that device from the device map
  50382. * @param deviceType Enum specifiying device type
  50383. * @param deviceSlot "Slot" or index that device is referenced in
  50384. */
  50385. private _unregisterDevice;
  50386. /**
  50387. * Handle all actions that come from keyboard interaction
  50388. */
  50389. private _handleKeyActions;
  50390. /**
  50391. * Handle all actions that come from pointer interaction
  50392. */
  50393. private _handlePointerActions;
  50394. /**
  50395. * Handle all actions that come from gamepad interaction
  50396. */
  50397. private _handleGamepadActions;
  50398. /**
  50399. * Update all non-event based devices with each frame
  50400. * @param deviceType Enum specifiying device type
  50401. * @param deviceSlot "Slot" or index that device is referenced in
  50402. * @param inputIndex Id of input to be checked
  50403. */
  50404. private _updateDevice;
  50405. /**
  50406. * Gets DeviceType from the device name
  50407. * @param deviceName Name of Device from DeviceInputSystem
  50408. * @returns DeviceType enum value
  50409. */
  50410. private _getGamepadDeviceType;
  50411. }
  50412. }
  50413. declare module BABYLON {
  50414. /**
  50415. * Type to handle enforcement of inputs
  50416. */
  50417. 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;
  50418. }
  50419. declare module BABYLON {
  50420. /**
  50421. * Class that handles all input for a specific device
  50422. */
  50423. export class DeviceSource<T extends DeviceType> {
  50424. /** Type of device */
  50425. readonly deviceType: DeviceType;
  50426. /** "Slot" or index that device is referenced in */
  50427. readonly deviceSlot: number;
  50428. /**
  50429. * Observable to handle device input changes per device
  50430. */
  50431. readonly onInputChangedObservable: Observable<{
  50432. inputIndex: DeviceInput<T>;
  50433. previousState: Nullable<number>;
  50434. currentState: Nullable<number>;
  50435. }>;
  50436. private readonly _deviceInputSystem;
  50437. /**
  50438. * Default Constructor
  50439. * @param deviceInputSystem Reference to DeviceInputSystem
  50440. * @param deviceType Type of device
  50441. * @param deviceSlot "Slot" or index that device is referenced in
  50442. */
  50443. constructor(deviceInputSystem: DeviceInputSystem,
  50444. /** Type of device */
  50445. deviceType: DeviceType,
  50446. /** "Slot" or index that device is referenced in */
  50447. deviceSlot?: number);
  50448. /**
  50449. * Get input for specific input
  50450. * @param inputIndex index of specific input on device
  50451. * @returns Input value from DeviceInputSystem
  50452. */
  50453. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50454. }
  50455. /**
  50456. * Class to keep track of devices
  50457. */
  50458. export class DeviceSourceManager implements IDisposable {
  50459. /**
  50460. * Observable to be triggered when before a device is connected
  50461. */
  50462. readonly onBeforeDeviceConnectedObservable: Observable<{
  50463. deviceType: DeviceType;
  50464. deviceSlot: number;
  50465. }>;
  50466. /**
  50467. * Observable to be triggered when before a device is disconnected
  50468. */
  50469. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50470. deviceType: DeviceType;
  50471. deviceSlot: number;
  50472. }>;
  50473. /**
  50474. * Observable to be triggered when after a device is connected
  50475. */
  50476. readonly onAfterDeviceConnectedObservable: Observable<{
  50477. deviceType: DeviceType;
  50478. deviceSlot: number;
  50479. }>;
  50480. /**
  50481. * Observable to be triggered when after a device is disconnected
  50482. */
  50483. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50484. deviceType: DeviceType;
  50485. deviceSlot: number;
  50486. }>;
  50487. private readonly _devices;
  50488. private readonly _firstDevice;
  50489. private readonly _deviceInputSystem;
  50490. /**
  50491. * Default Constructor
  50492. * @param engine engine to pull input element from
  50493. */
  50494. constructor(engine: Engine);
  50495. /**
  50496. * Gets a DeviceSource, given a type and slot
  50497. * @param deviceType Enum specifying device type
  50498. * @param deviceSlot "Slot" or index that device is referenced in
  50499. * @returns DeviceSource object
  50500. */
  50501. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50502. /**
  50503. * Gets an array of DeviceSource objects for a given device type
  50504. * @param deviceType Enum specifying device type
  50505. * @returns Array of DeviceSource objects
  50506. */
  50507. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50508. /**
  50509. * Dispose of DeviceInputSystem and other parts
  50510. */
  50511. dispose(): void;
  50512. /**
  50513. * Function to add device name to device list
  50514. * @param deviceType Enum specifying device type
  50515. * @param deviceSlot "Slot" or index that device is referenced in
  50516. */
  50517. private _addDevice;
  50518. /**
  50519. * Function to remove device name to device list
  50520. * @param deviceType Enum specifying device type
  50521. * @param deviceSlot "Slot" or index that device is referenced in
  50522. */
  50523. private _removeDevice;
  50524. /**
  50525. * Updates array storing first connected device of each type
  50526. * @param type Type of Device
  50527. */
  50528. private _updateFirstDevices;
  50529. }
  50530. }
  50531. declare module BABYLON {
  50532. /**
  50533. * Options to create the null engine
  50534. */
  50535. export class NullEngineOptions {
  50536. /**
  50537. * Render width (Default: 512)
  50538. */
  50539. renderWidth: number;
  50540. /**
  50541. * Render height (Default: 256)
  50542. */
  50543. renderHeight: number;
  50544. /**
  50545. * Texture size (Default: 512)
  50546. */
  50547. textureSize: number;
  50548. /**
  50549. * If delta time between frames should be constant
  50550. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50551. */
  50552. deterministicLockstep: boolean;
  50553. /**
  50554. * Maximum about of steps between frames (Default: 4)
  50555. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50556. */
  50557. lockstepMaxSteps: number;
  50558. }
  50559. /**
  50560. * The null engine class provides support for headless version of babylon.js.
  50561. * This can be used in server side scenario or for testing purposes
  50562. */
  50563. export class NullEngine extends Engine {
  50564. private _options;
  50565. /**
  50566. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50567. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50568. * @returns true if engine is in deterministic lock step mode
  50569. */
  50570. isDeterministicLockStep(): boolean;
  50571. /**
  50572. * Gets the max steps when engine is running in deterministic lock step
  50573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50574. * @returns the max steps
  50575. */
  50576. getLockstepMaxSteps(): number;
  50577. /**
  50578. * Gets the current hardware scaling level.
  50579. * By default the hardware scaling level is computed from the window device ratio.
  50580. * 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.
  50581. * @returns a number indicating the current hardware scaling level
  50582. */
  50583. getHardwareScalingLevel(): number;
  50584. constructor(options?: NullEngineOptions);
  50585. /**
  50586. * Creates a vertex buffer
  50587. * @param vertices the data for the vertex buffer
  50588. * @returns the new WebGL static buffer
  50589. */
  50590. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50591. /**
  50592. * Creates a new index buffer
  50593. * @param indices defines the content of the index buffer
  50594. * @param updatable defines if the index buffer must be updatable
  50595. * @returns a new webGL buffer
  50596. */
  50597. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50598. /**
  50599. * Clear the current render buffer or the current render target (if any is set up)
  50600. * @param color defines the color to use
  50601. * @param backBuffer defines if the back buffer must be cleared
  50602. * @param depth defines if the depth buffer must be cleared
  50603. * @param stencil defines if the stencil buffer must be cleared
  50604. */
  50605. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50606. /**
  50607. * Gets the current render width
  50608. * @param useScreen defines if screen size must be used (or the current render target if any)
  50609. * @returns a number defining the current render width
  50610. */
  50611. getRenderWidth(useScreen?: boolean): number;
  50612. /**
  50613. * Gets the current render height
  50614. * @param useScreen defines if screen size must be used (or the current render target if any)
  50615. * @returns a number defining the current render height
  50616. */
  50617. getRenderHeight(useScreen?: boolean): number;
  50618. /**
  50619. * Set the WebGL's viewport
  50620. * @param viewport defines the viewport element to be used
  50621. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50622. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50623. */
  50624. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50625. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50626. /**
  50627. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50628. * @param pipelineContext defines the pipeline context to use
  50629. * @param uniformsNames defines the list of uniform names
  50630. * @returns an array of webGL uniform locations
  50631. */
  50632. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50633. /**
  50634. * Gets the lsit of active attributes for a given webGL program
  50635. * @param pipelineContext defines the pipeline context to use
  50636. * @param attributesNames defines the list of attribute names to get
  50637. * @returns an array of indices indicating the offset of each attribute
  50638. */
  50639. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50640. /**
  50641. * Binds an effect to the webGL context
  50642. * @param effect defines the effect to bind
  50643. */
  50644. bindSamplers(effect: Effect): void;
  50645. /**
  50646. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50647. * @param effect defines the effect to activate
  50648. */
  50649. enableEffect(effect: Effect): void;
  50650. /**
  50651. * Set various states to the webGL context
  50652. * @param culling defines backface culling state
  50653. * @param zOffset defines the value to apply to zOffset (0 by default)
  50654. * @param force defines if states must be applied even if cache is up to date
  50655. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50656. */
  50657. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50658. /**
  50659. * Set the value of an uniform to an array of int32
  50660. * @param uniform defines the webGL uniform location where to store the value
  50661. * @param array defines the array of int32 to store
  50662. */
  50663. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50664. /**
  50665. * Set the value of an uniform to an array of int32 (stored as vec2)
  50666. * @param uniform defines the webGL uniform location where to store the value
  50667. * @param array defines the array of int32 to store
  50668. */
  50669. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50670. /**
  50671. * Set the value of an uniform to an array of int32 (stored as vec3)
  50672. * @param uniform defines the webGL uniform location where to store the value
  50673. * @param array defines the array of int32 to store
  50674. */
  50675. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50676. /**
  50677. * Set the value of an uniform to an array of int32 (stored as vec4)
  50678. * @param uniform defines the webGL uniform location where to store the value
  50679. * @param array defines the array of int32 to store
  50680. */
  50681. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50682. /**
  50683. * Set the value of an uniform to an array of float32
  50684. * @param uniform defines the webGL uniform location where to store the value
  50685. * @param array defines the array of float32 to store
  50686. */
  50687. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50688. /**
  50689. * Set the value of an uniform to an array of float32 (stored as vec2)
  50690. * @param uniform defines the webGL uniform location where to store the value
  50691. * @param array defines the array of float32 to store
  50692. */
  50693. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50694. /**
  50695. * Set the value of an uniform to an array of float32 (stored as vec3)
  50696. * @param uniform defines the webGL uniform location where to store the value
  50697. * @param array defines the array of float32 to store
  50698. */
  50699. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50700. /**
  50701. * Set the value of an uniform to an array of float32 (stored as vec4)
  50702. * @param uniform defines the webGL uniform location where to store the value
  50703. * @param array defines the array of float32 to store
  50704. */
  50705. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50706. /**
  50707. * Set the value of an uniform to an array of number
  50708. * @param uniform defines the webGL uniform location where to store the value
  50709. * @param array defines the array of number to store
  50710. */
  50711. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50712. /**
  50713. * Set the value of an uniform to an array of number (stored as vec2)
  50714. * @param uniform defines the webGL uniform location where to store the value
  50715. * @param array defines the array of number to store
  50716. */
  50717. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50718. /**
  50719. * Set the value of an uniform to an array of number (stored as vec3)
  50720. * @param uniform defines the webGL uniform location where to store the value
  50721. * @param array defines the array of number to store
  50722. */
  50723. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50724. /**
  50725. * Set the value of an uniform to an array of number (stored as vec4)
  50726. * @param uniform defines the webGL uniform location where to store the value
  50727. * @param array defines the array of number to store
  50728. */
  50729. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50730. /**
  50731. * Set the value of an uniform to an array of float32 (stored as matrices)
  50732. * @param uniform defines the webGL uniform location where to store the value
  50733. * @param matrices defines the array of float32 to store
  50734. */
  50735. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50736. /**
  50737. * Set the value of an uniform to a matrix (3x3)
  50738. * @param uniform defines the webGL uniform location where to store the value
  50739. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50740. */
  50741. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50742. /**
  50743. * Set the value of an uniform to a matrix (2x2)
  50744. * @param uniform defines the webGL uniform location where to store the value
  50745. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50746. */
  50747. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50748. /**
  50749. * Set the value of an uniform to a number (float)
  50750. * @param uniform defines the webGL uniform location where to store the value
  50751. * @param value defines the float number to store
  50752. */
  50753. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50754. /**
  50755. * Set the value of an uniform to a vec2
  50756. * @param uniform defines the webGL uniform location where to store the value
  50757. * @param x defines the 1st component of the value
  50758. * @param y defines the 2nd component of the value
  50759. */
  50760. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50761. /**
  50762. * Set the value of an uniform to a vec3
  50763. * @param uniform defines the webGL uniform location where to store the value
  50764. * @param x defines the 1st component of the value
  50765. * @param y defines the 2nd component of the value
  50766. * @param z defines the 3rd component of the value
  50767. */
  50768. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50769. /**
  50770. * Set the value of an uniform to a boolean
  50771. * @param uniform defines the webGL uniform location where to store the value
  50772. * @param bool defines the boolean to store
  50773. */
  50774. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50775. /**
  50776. * Set the value of an uniform to a vec4
  50777. * @param uniform defines the webGL uniform location where to store the value
  50778. * @param x defines the 1st component of the value
  50779. * @param y defines the 2nd component of the value
  50780. * @param z defines the 3rd component of the value
  50781. * @param w defines the 4th component of the value
  50782. */
  50783. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50784. /**
  50785. * Sets the current alpha mode
  50786. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50787. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50788. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50789. */
  50790. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50791. /**
  50792. * Bind webGl buffers directly to the webGL context
  50793. * @param vertexBuffers defines the vertex buffer to bind
  50794. * @param indexBuffer defines the index buffer to bind
  50795. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50796. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50797. * @param effect defines the effect associated with the vertex buffer
  50798. */
  50799. bindBuffers(vertexBuffers: {
  50800. [key: string]: VertexBuffer;
  50801. }, indexBuffer: DataBuffer, effect: Effect): void;
  50802. /**
  50803. * Force the entire cache to be cleared
  50804. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50805. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50806. */
  50807. wipeCaches(bruteForce?: boolean): void;
  50808. /**
  50809. * Send a draw order
  50810. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50811. * @param indexStart defines the starting index
  50812. * @param indexCount defines the number of index to draw
  50813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50814. */
  50815. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50816. /**
  50817. * Draw a list of indexed primitives
  50818. * @param fillMode defines the primitive to use
  50819. * @param indexStart defines the starting index
  50820. * @param indexCount defines the number of index to draw
  50821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50822. */
  50823. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50824. /**
  50825. * Draw a list of unindexed primitives
  50826. * @param fillMode defines the primitive to use
  50827. * @param verticesStart defines the index of first vertex to draw
  50828. * @param verticesCount defines the count of vertices to draw
  50829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50830. */
  50831. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50832. /** @hidden */
  50833. _createTexture(): WebGLTexture;
  50834. /** @hidden */
  50835. _releaseTexture(texture: InternalTexture): void;
  50836. /**
  50837. * Usually called from Texture.ts.
  50838. * Passed information to create a WebGLTexture
  50839. * @param urlArg defines a value which contains one of the following:
  50840. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50841. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50842. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50844. * @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)
  50845. * @param scene needed for loading to the correct scene
  50846. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50847. * @param onLoad optional callback to be called upon successful completion
  50848. * @param onError optional callback to be called upon failure
  50849. * @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
  50850. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50851. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50852. * @param forcedExtension defines the extension to use to pick the right loader
  50853. * @param mimeType defines an optional mime type
  50854. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50855. */
  50856. 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;
  50857. /**
  50858. * Creates a new render target texture
  50859. * @param size defines the size of the texture
  50860. * @param options defines the options used to create the texture
  50861. * @returns a new render target texture stored in an InternalTexture
  50862. */
  50863. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50864. /**
  50865. * Update the sampling mode of a given texture
  50866. * @param samplingMode defines the required sampling mode
  50867. * @param texture defines the texture to update
  50868. */
  50869. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50870. /**
  50871. * Binds the frame buffer to the specified texture.
  50872. * @param texture The texture to render to or null for the default canvas
  50873. * @param faceIndex The face of the texture to render to in case of cube texture
  50874. * @param requiredWidth The width of the target to render to
  50875. * @param requiredHeight The height of the target to render to
  50876. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50877. * @param lodLevel defines le lod level to bind to the frame buffer
  50878. */
  50879. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50880. /**
  50881. * Unbind the current render target texture from the webGL context
  50882. * @param texture defines the render target texture to unbind
  50883. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50884. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50885. */
  50886. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50887. /**
  50888. * Creates a dynamic vertex buffer
  50889. * @param vertices the data for the dynamic vertex buffer
  50890. * @returns the new WebGL dynamic buffer
  50891. */
  50892. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50893. /**
  50894. * Update the content of a dynamic texture
  50895. * @param texture defines the texture to update
  50896. * @param canvas defines the canvas containing the source
  50897. * @param invertY defines if data must be stored with Y axis inverted
  50898. * @param premulAlpha defines if alpha is stored as premultiplied
  50899. * @param format defines the format of the data
  50900. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50901. */
  50902. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50903. /**
  50904. * Gets a boolean indicating if all created effects are ready
  50905. * @returns true if all effects are ready
  50906. */
  50907. areAllEffectsReady(): boolean;
  50908. /**
  50909. * @hidden
  50910. * Get the current error code of the webGL context
  50911. * @returns the error code
  50912. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50913. */
  50914. getError(): number;
  50915. /** @hidden */
  50916. _getUnpackAlignement(): number;
  50917. /** @hidden */
  50918. _unpackFlipY(value: boolean): void;
  50919. /**
  50920. * Update a dynamic index buffer
  50921. * @param indexBuffer defines the target index buffer
  50922. * @param indices defines the data to update
  50923. * @param offset defines the offset in the target index buffer where update should start
  50924. */
  50925. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50926. /**
  50927. * Updates a dynamic vertex buffer.
  50928. * @param vertexBuffer the vertex buffer to update
  50929. * @param vertices the data used to update the vertex buffer
  50930. * @param byteOffset the byte offset of the data (optional)
  50931. * @param byteLength the byte length of the data (optional)
  50932. */
  50933. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50934. /** @hidden */
  50935. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50936. /** @hidden */
  50937. _bindTexture(channel: number, texture: InternalTexture): void;
  50938. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50939. /**
  50940. * 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
  50941. */
  50942. releaseEffects(): void;
  50943. displayLoadingUI(): void;
  50944. hideLoadingUI(): void;
  50945. /** @hidden */
  50946. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50947. /** @hidden */
  50948. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50949. /** @hidden */
  50950. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50951. /** @hidden */
  50952. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50953. }
  50954. }
  50955. declare module BABYLON {
  50956. /**
  50957. * @hidden
  50958. **/
  50959. export class _TimeToken {
  50960. _startTimeQuery: Nullable<WebGLQuery>;
  50961. _endTimeQuery: Nullable<WebGLQuery>;
  50962. _timeElapsedQuery: Nullable<WebGLQuery>;
  50963. _timeElapsedQueryEnded: boolean;
  50964. }
  50965. }
  50966. declare module BABYLON {
  50967. /** @hidden */
  50968. export class _OcclusionDataStorage {
  50969. /** @hidden */
  50970. occlusionInternalRetryCounter: number;
  50971. /** @hidden */
  50972. isOcclusionQueryInProgress: boolean;
  50973. /** @hidden */
  50974. isOccluded: boolean;
  50975. /** @hidden */
  50976. occlusionRetryCount: number;
  50977. /** @hidden */
  50978. occlusionType: number;
  50979. /** @hidden */
  50980. occlusionQueryAlgorithmType: number;
  50981. }
  50982. interface Engine {
  50983. /**
  50984. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50985. * @return the new query
  50986. */
  50987. createQuery(): WebGLQuery;
  50988. /**
  50989. * Delete and release a webGL query
  50990. * @param query defines the query to delete
  50991. * @return the current engine
  50992. */
  50993. deleteQuery(query: WebGLQuery): Engine;
  50994. /**
  50995. * Check if a given query has resolved and got its value
  50996. * @param query defines the query to check
  50997. * @returns true if the query got its value
  50998. */
  50999. isQueryResultAvailable(query: WebGLQuery): boolean;
  51000. /**
  51001. * Gets the value of a given query
  51002. * @param query defines the query to check
  51003. * @returns the value of the query
  51004. */
  51005. getQueryResult(query: WebGLQuery): number;
  51006. /**
  51007. * Initiates an occlusion query
  51008. * @param algorithmType defines the algorithm to use
  51009. * @param query defines the query to use
  51010. * @returns the current engine
  51011. * @see https://doc.babylonjs.com/features/occlusionquery
  51012. */
  51013. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51014. /**
  51015. * Ends an occlusion query
  51016. * @see https://doc.babylonjs.com/features/occlusionquery
  51017. * @param algorithmType defines the algorithm to use
  51018. * @returns the current engine
  51019. */
  51020. endOcclusionQuery(algorithmType: number): Engine;
  51021. /**
  51022. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51023. * Please note that only one query can be issued at a time
  51024. * @returns a time token used to track the time span
  51025. */
  51026. startTimeQuery(): Nullable<_TimeToken>;
  51027. /**
  51028. * Ends a time query
  51029. * @param token defines the token used to measure the time span
  51030. * @returns the time spent (in ns)
  51031. */
  51032. endTimeQuery(token: _TimeToken): int;
  51033. /** @hidden */
  51034. _currentNonTimestampToken: Nullable<_TimeToken>;
  51035. /** @hidden */
  51036. _createTimeQuery(): WebGLQuery;
  51037. /** @hidden */
  51038. _deleteTimeQuery(query: WebGLQuery): void;
  51039. /** @hidden */
  51040. _getGlAlgorithmType(algorithmType: number): number;
  51041. /** @hidden */
  51042. _getTimeQueryResult(query: WebGLQuery): any;
  51043. /** @hidden */
  51044. _getTimeQueryAvailability(query: WebGLQuery): any;
  51045. }
  51046. interface AbstractMesh {
  51047. /**
  51048. * Backing filed
  51049. * @hidden
  51050. */
  51051. __occlusionDataStorage: _OcclusionDataStorage;
  51052. /**
  51053. * Access property
  51054. * @hidden
  51055. */
  51056. _occlusionDataStorage: _OcclusionDataStorage;
  51057. /**
  51058. * 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.
  51059. * The default value is -1 which means don't break the query and wait till the result
  51060. * @see https://doc.babylonjs.com/features/occlusionquery
  51061. */
  51062. occlusionRetryCount: number;
  51063. /**
  51064. * 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:
  51065. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51066. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51067. * * 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.
  51068. * @see https://doc.babylonjs.com/features/occlusionquery
  51069. */
  51070. occlusionType: number;
  51071. /**
  51072. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51073. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51074. * * 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.
  51075. * @see https://doc.babylonjs.com/features/occlusionquery
  51076. */
  51077. occlusionQueryAlgorithmType: number;
  51078. /**
  51079. * 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
  51080. * @see https://doc.babylonjs.com/features/occlusionquery
  51081. */
  51082. isOccluded: boolean;
  51083. /**
  51084. * Flag to check the progress status of the query
  51085. * @see https://doc.babylonjs.com/features/occlusionquery
  51086. */
  51087. isOcclusionQueryInProgress: boolean;
  51088. }
  51089. }
  51090. declare module BABYLON {
  51091. /** @hidden */
  51092. export var _forceTransformFeedbackToBundle: boolean;
  51093. interface Engine {
  51094. /**
  51095. * Creates a webGL transform feedback object
  51096. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51097. * @returns the webGL transform feedback object
  51098. */
  51099. createTransformFeedback(): WebGLTransformFeedback;
  51100. /**
  51101. * Delete a webGL transform feedback object
  51102. * @param value defines the webGL transform feedback object to delete
  51103. */
  51104. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51105. /**
  51106. * Bind a webGL transform feedback object to the webgl context
  51107. * @param value defines the webGL transform feedback object to bind
  51108. */
  51109. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51110. /**
  51111. * Begins a transform feedback operation
  51112. * @param usePoints defines if points or triangles must be used
  51113. */
  51114. beginTransformFeedback(usePoints: boolean): void;
  51115. /**
  51116. * Ends a transform feedback operation
  51117. */
  51118. endTransformFeedback(): void;
  51119. /**
  51120. * Specify the varyings to use with transform feedback
  51121. * @param program defines the associated webGL program
  51122. * @param value defines the list of strings representing the varying names
  51123. */
  51124. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51125. /**
  51126. * Bind a webGL buffer for a transform feedback operation
  51127. * @param value defines the webGL buffer to bind
  51128. */
  51129. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51130. }
  51131. }
  51132. declare module BABYLON {
  51133. /**
  51134. * Creation options of the multi render target texture.
  51135. */
  51136. export interface IMultiRenderTargetOptions {
  51137. /**
  51138. * Define if the texture needs to create mip maps after render.
  51139. */
  51140. generateMipMaps?: boolean;
  51141. /**
  51142. * Define the types of all the draw buffers we want to create
  51143. */
  51144. types?: number[];
  51145. /**
  51146. * Define the sampling modes of all the draw buffers we want to create
  51147. */
  51148. samplingModes?: number[];
  51149. /**
  51150. * Define if a depth buffer is required
  51151. */
  51152. generateDepthBuffer?: boolean;
  51153. /**
  51154. * Define if a stencil buffer is required
  51155. */
  51156. generateStencilBuffer?: boolean;
  51157. /**
  51158. * Define if a depth texture is required instead of a depth buffer
  51159. */
  51160. generateDepthTexture?: boolean;
  51161. /**
  51162. * Define the number of desired draw buffers
  51163. */
  51164. textureCount?: number;
  51165. /**
  51166. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51167. */
  51168. doNotChangeAspectRatio?: boolean;
  51169. /**
  51170. * Define the default type of the buffers we are creating
  51171. */
  51172. defaultType?: number;
  51173. }
  51174. /**
  51175. * A multi render target, like a render target provides the ability to render to a texture.
  51176. * Unlike the render target, it can render to several draw buffers in one draw.
  51177. * This is specially interesting in deferred rendering or for any effects requiring more than
  51178. * just one color from a single pass.
  51179. */
  51180. export class MultiRenderTarget extends RenderTargetTexture {
  51181. private _internalTextures;
  51182. private _textures;
  51183. private _multiRenderTargetOptions;
  51184. private _count;
  51185. /**
  51186. * Get if draw buffers are currently supported by the used hardware and browser.
  51187. */
  51188. get isSupported(): boolean;
  51189. /**
  51190. * Get the list of textures generated by the multi render target.
  51191. */
  51192. get textures(): Texture[];
  51193. /**
  51194. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  51195. */
  51196. get count(): number;
  51197. /**
  51198. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51199. */
  51200. get depthTexture(): Texture;
  51201. /**
  51202. * Set the wrapping mode on U of all the textures we are rendering to.
  51203. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51204. */
  51205. set wrapU(wrap: number);
  51206. /**
  51207. * Set the wrapping mode on V of all the textures we are rendering to.
  51208. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51209. */
  51210. set wrapV(wrap: number);
  51211. /**
  51212. * Instantiate a new multi render target texture.
  51213. * A multi render target, like a render target provides the ability to render to a texture.
  51214. * Unlike the render target, it can render to several draw buffers in one draw.
  51215. * This is specially interesting in deferred rendering or for any effects requiring more than
  51216. * just one color from a single pass.
  51217. * @param name Define the name of the texture
  51218. * @param size Define the size of the buffers to render to
  51219. * @param count Define the number of target we are rendering into
  51220. * @param scene Define the scene the texture belongs to
  51221. * @param options Define the options used to create the multi render target
  51222. */
  51223. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51224. /** @hidden */
  51225. _rebuild(): void;
  51226. private _createInternalTextures;
  51227. private _createTextures;
  51228. /**
  51229. * Define the number of samples used if MSAA is enabled.
  51230. */
  51231. get samples(): number;
  51232. set samples(value: number);
  51233. /**
  51234. * Resize all the textures in the multi render target.
  51235. * Be carrefull as it will recreate all the data in the new texture.
  51236. * @param size Define the new size
  51237. */
  51238. resize(size: any): void;
  51239. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51240. /**
  51241. * Dispose the render targets and their associated resources
  51242. */
  51243. dispose(): void;
  51244. /**
  51245. * Release all the underlying texture used as draw buffers.
  51246. */
  51247. releaseInternalTextures(): void;
  51248. }
  51249. }
  51250. declare module BABYLON {
  51251. interface ThinEngine {
  51252. /**
  51253. * Unbind a list of render target textures from the webGL context
  51254. * This is used only when drawBuffer extension or webGL2 are active
  51255. * @param textures defines the render target textures to unbind
  51256. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51257. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51258. */
  51259. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51260. /**
  51261. * Create a multi render target texture
  51262. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  51263. * @param size defines the size of the texture
  51264. * @param options defines the creation options
  51265. * @returns the cube texture as an InternalTexture
  51266. */
  51267. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51268. /**
  51269. * Update the sample count for a given multiple render target texture
  51270. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51271. * @param textures defines the textures to update
  51272. * @param samples defines the sample count to set
  51273. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51274. */
  51275. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51276. /**
  51277. * Select a subsets of attachments to draw to.
  51278. * @param attachments gl attachments
  51279. */
  51280. bindAttachments(attachments: number[]): void;
  51281. }
  51282. }
  51283. declare module BABYLON {
  51284. /**
  51285. * Class used to define an additional view for the engine
  51286. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51287. */
  51288. export class EngineView {
  51289. /** Defines the canvas where to render the view */
  51290. target: HTMLCanvasElement;
  51291. /** Defines an optional camera used to render the view (will use active camera else) */
  51292. camera?: Camera;
  51293. }
  51294. interface Engine {
  51295. /**
  51296. * Gets or sets the HTML element to use for attaching events
  51297. */
  51298. inputElement: Nullable<HTMLElement>;
  51299. /**
  51300. * Gets the current engine view
  51301. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51302. */
  51303. activeView: Nullable<EngineView>;
  51304. /** Gets or sets the list of views */
  51305. views: EngineView[];
  51306. /**
  51307. * Register a new child canvas
  51308. * @param canvas defines the canvas to register
  51309. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51310. * @returns the associated view
  51311. */
  51312. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51313. /**
  51314. * Remove a registered child canvas
  51315. * @param canvas defines the canvas to remove
  51316. * @returns the current engine
  51317. */
  51318. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51319. }
  51320. }
  51321. declare module BABYLON {
  51322. interface Engine {
  51323. /** @hidden */
  51324. _excludedCompressedTextures: string[];
  51325. /** @hidden */
  51326. _textureFormatInUse: string;
  51327. /**
  51328. * Gets the list of texture formats supported
  51329. */
  51330. readonly texturesSupported: Array<string>;
  51331. /**
  51332. * Gets the texture format in use
  51333. */
  51334. readonly textureFormatInUse: Nullable<string>;
  51335. /**
  51336. * Set the compressed texture extensions or file names to skip.
  51337. *
  51338. * @param skippedFiles defines the list of those texture files you want to skip
  51339. * Example: [".dds", ".env", "myfile.png"]
  51340. */
  51341. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51342. /**
  51343. * Set the compressed texture format to use, based on the formats you have, and the formats
  51344. * supported by the hardware / browser.
  51345. *
  51346. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51347. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51348. * to API arguments needed to compressed textures. This puts the burden on the container
  51349. * generator to house the arcane code for determining these for current & future formats.
  51350. *
  51351. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51352. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51353. *
  51354. * Note: The result of this call is not taken into account when a texture is base64.
  51355. *
  51356. * @param formatsAvailable defines the list of those format families you have created
  51357. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51358. *
  51359. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51360. * @returns The extension selected.
  51361. */
  51362. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51363. }
  51364. }
  51365. declare module BABYLON {
  51366. /**
  51367. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51368. */
  51369. export interface CubeMapInfo {
  51370. /**
  51371. * The pixel array for the front face.
  51372. * This is stored in format, left to right, up to down format.
  51373. */
  51374. front: Nullable<ArrayBufferView>;
  51375. /**
  51376. * The pixel array for the back face.
  51377. * This is stored in format, left to right, up to down format.
  51378. */
  51379. back: Nullable<ArrayBufferView>;
  51380. /**
  51381. * The pixel array for the left face.
  51382. * This is stored in format, left to right, up to down format.
  51383. */
  51384. left: Nullable<ArrayBufferView>;
  51385. /**
  51386. * The pixel array for the right face.
  51387. * This is stored in format, left to right, up to down format.
  51388. */
  51389. right: Nullable<ArrayBufferView>;
  51390. /**
  51391. * The pixel array for the up face.
  51392. * This is stored in format, left to right, up to down format.
  51393. */
  51394. up: Nullable<ArrayBufferView>;
  51395. /**
  51396. * The pixel array for the down face.
  51397. * This is stored in format, left to right, up to down format.
  51398. */
  51399. down: Nullable<ArrayBufferView>;
  51400. /**
  51401. * The size of the cubemap stored.
  51402. *
  51403. * Each faces will be size * size pixels.
  51404. */
  51405. size: number;
  51406. /**
  51407. * The format of the texture.
  51408. *
  51409. * RGBA, RGB.
  51410. */
  51411. format: number;
  51412. /**
  51413. * The type of the texture data.
  51414. *
  51415. * UNSIGNED_INT, FLOAT.
  51416. */
  51417. type: number;
  51418. /**
  51419. * Specifies whether the texture is in gamma space.
  51420. */
  51421. gammaSpace: boolean;
  51422. }
  51423. /**
  51424. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51425. */
  51426. export class PanoramaToCubeMapTools {
  51427. private static FACE_LEFT;
  51428. private static FACE_RIGHT;
  51429. private static FACE_FRONT;
  51430. private static FACE_BACK;
  51431. private static FACE_DOWN;
  51432. private static FACE_UP;
  51433. /**
  51434. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51435. *
  51436. * @param float32Array The source data.
  51437. * @param inputWidth The width of the input panorama.
  51438. * @param inputHeight The height of the input panorama.
  51439. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51440. * @return The cubemap data
  51441. */
  51442. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51443. private static CreateCubemapTexture;
  51444. private static CalcProjectionSpherical;
  51445. }
  51446. }
  51447. declare module BABYLON {
  51448. /**
  51449. * Helper class dealing with the extraction of spherical polynomial dataArray
  51450. * from a cube map.
  51451. */
  51452. export class CubeMapToSphericalPolynomialTools {
  51453. private static FileFaces;
  51454. /**
  51455. * Converts a texture to the according Spherical Polynomial data.
  51456. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51457. *
  51458. * @param texture The texture to extract the information from.
  51459. * @return The Spherical Polynomial data.
  51460. */
  51461. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51462. /**
  51463. * Converts a cubemap to the according Spherical Polynomial data.
  51464. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51465. *
  51466. * @param cubeInfo The Cube map to extract the information from.
  51467. * @return The Spherical Polynomial data.
  51468. */
  51469. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51470. }
  51471. }
  51472. declare module BABYLON {
  51473. interface BaseTexture {
  51474. /**
  51475. * Get the polynomial representation of the texture data.
  51476. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51477. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51478. */
  51479. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51480. }
  51481. }
  51482. declare module BABYLON {
  51483. /** @hidden */
  51484. export var rgbdEncodePixelShader: {
  51485. name: string;
  51486. shader: string;
  51487. };
  51488. }
  51489. declare module BABYLON {
  51490. /** @hidden */
  51491. export var rgbdDecodePixelShader: {
  51492. name: string;
  51493. shader: string;
  51494. };
  51495. }
  51496. declare module BABYLON {
  51497. /**
  51498. * Raw texture data and descriptor sufficient for WebGL texture upload
  51499. */
  51500. export interface EnvironmentTextureInfo {
  51501. /**
  51502. * Version of the environment map
  51503. */
  51504. version: number;
  51505. /**
  51506. * Width of image
  51507. */
  51508. width: number;
  51509. /**
  51510. * Irradiance information stored in the file.
  51511. */
  51512. irradiance: any;
  51513. /**
  51514. * Specular information stored in the file.
  51515. */
  51516. specular: any;
  51517. }
  51518. /**
  51519. * Defines One Image in the file. It requires only the position in the file
  51520. * as well as the length.
  51521. */
  51522. interface BufferImageData {
  51523. /**
  51524. * Length of the image data.
  51525. */
  51526. length: number;
  51527. /**
  51528. * Position of the data from the null terminator delimiting the end of the JSON.
  51529. */
  51530. position: number;
  51531. }
  51532. /**
  51533. * Defines the specular data enclosed in the file.
  51534. * This corresponds to the version 1 of the data.
  51535. */
  51536. export interface EnvironmentTextureSpecularInfoV1 {
  51537. /**
  51538. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51539. */
  51540. specularDataPosition?: number;
  51541. /**
  51542. * This contains all the images data needed to reconstruct the cubemap.
  51543. */
  51544. mipmaps: Array<BufferImageData>;
  51545. /**
  51546. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51547. */
  51548. lodGenerationScale: number;
  51549. }
  51550. /**
  51551. * Sets of helpers addressing the serialization and deserialization of environment texture
  51552. * stored in a BabylonJS env file.
  51553. * Those files are usually stored as .env files.
  51554. */
  51555. export class EnvironmentTextureTools {
  51556. /**
  51557. * Magic number identifying the env file.
  51558. */
  51559. private static _MagicBytes;
  51560. /**
  51561. * Gets the environment info from an env file.
  51562. * @param data The array buffer containing the .env bytes.
  51563. * @returns the environment file info (the json header) if successfully parsed.
  51564. */
  51565. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51566. /**
  51567. * Creates an environment texture from a loaded cube texture.
  51568. * @param texture defines the cube texture to convert in env file
  51569. * @return a promise containing the environment data if succesfull.
  51570. */
  51571. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51572. /**
  51573. * Creates a JSON representation of the spherical data.
  51574. * @param texture defines the texture containing the polynomials
  51575. * @return the JSON representation of the spherical info
  51576. */
  51577. private static _CreateEnvTextureIrradiance;
  51578. /**
  51579. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51580. * @param data the image data
  51581. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51582. * @return the views described by info providing access to the underlying buffer
  51583. */
  51584. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51585. /**
  51586. * Uploads the texture info contained in the env file to the GPU.
  51587. * @param texture defines the internal texture to upload to
  51588. * @param data defines the data to load
  51589. * @param info defines the texture info retrieved through the GetEnvInfo method
  51590. * @returns a promise
  51591. */
  51592. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51593. private static _OnImageReadyAsync;
  51594. /**
  51595. * Uploads the levels of image data to the GPU.
  51596. * @param texture defines the internal texture to upload to
  51597. * @param imageData defines the array buffer views of image data [mipmap][face]
  51598. * @returns a promise
  51599. */
  51600. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51601. /**
  51602. * Uploads spherical polynomials information to the texture.
  51603. * @param texture defines the texture we are trying to upload the information to
  51604. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51605. */
  51606. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51607. /** @hidden */
  51608. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51609. }
  51610. }
  51611. declare module BABYLON {
  51612. /**
  51613. * Class used to inline functions in shader code
  51614. */
  51615. export class ShaderCodeInliner {
  51616. private static readonly _RegexpFindFunctionNameAndType;
  51617. private _sourceCode;
  51618. private _functionDescr;
  51619. private _numMaxIterations;
  51620. /** Gets or sets the token used to mark the functions to inline */
  51621. inlineToken: string;
  51622. /** Gets or sets the debug mode */
  51623. debug: boolean;
  51624. /** Gets the code after the inlining process */
  51625. get code(): string;
  51626. /**
  51627. * Initializes the inliner
  51628. * @param sourceCode shader code source to inline
  51629. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51630. */
  51631. constructor(sourceCode: string, numMaxIterations?: number);
  51632. /**
  51633. * Start the processing of the shader code
  51634. */
  51635. processCode(): void;
  51636. private _collectFunctions;
  51637. private _processInlining;
  51638. private _extractBetweenMarkers;
  51639. private _skipWhitespaces;
  51640. private _removeComments;
  51641. private _replaceFunctionCallsByCode;
  51642. private _findBackward;
  51643. private _escapeRegExp;
  51644. private _replaceNames;
  51645. }
  51646. }
  51647. declare module BABYLON {
  51648. /**
  51649. * Container for accessors for natively-stored mesh data buffers.
  51650. */
  51651. class NativeDataBuffer extends DataBuffer {
  51652. /**
  51653. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51654. */
  51655. nativeIndexBuffer?: any;
  51656. /**
  51657. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51658. */
  51659. nativeVertexBuffer?: any;
  51660. }
  51661. /** @hidden */
  51662. class NativeTexture extends InternalTexture {
  51663. getInternalTexture(): InternalTexture;
  51664. getViewCount(): number;
  51665. }
  51666. /** @hidden */
  51667. export class NativeEngine extends Engine {
  51668. private readonly _native;
  51669. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51670. private readonly INVALID_HANDLE;
  51671. getHardwareScalingLevel(): number;
  51672. constructor();
  51673. dispose(): void;
  51674. /**
  51675. * Can be used to override the current requestAnimationFrame requester.
  51676. * @hidden
  51677. */
  51678. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51679. /**
  51680. * Override default engine behavior.
  51681. * @param color
  51682. * @param backBuffer
  51683. * @param depth
  51684. * @param stencil
  51685. */
  51686. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51687. /**
  51688. * Gets host document
  51689. * @returns the host document object
  51690. */
  51691. getHostDocument(): Nullable<Document>;
  51692. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51693. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51694. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51695. recordVertexArrayObject(vertexBuffers: {
  51696. [key: string]: VertexBuffer;
  51697. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51698. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51699. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51700. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51701. /**
  51702. * Draw a list of indexed primitives
  51703. * @param fillMode defines the primitive to use
  51704. * @param indexStart defines the starting index
  51705. * @param indexCount defines the number of index to draw
  51706. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51707. */
  51708. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51709. /**
  51710. * Draw a list of unindexed primitives
  51711. * @param fillMode defines the primitive to use
  51712. * @param verticesStart defines the index of first vertex to draw
  51713. * @param verticesCount defines the count of vertices to draw
  51714. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51715. */
  51716. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51717. createPipelineContext(): IPipelineContext;
  51718. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51719. /** @hidden */
  51720. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51721. /** @hidden */
  51722. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51723. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51724. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51725. protected _setProgram(program: WebGLProgram): void;
  51726. _releaseEffect(effect: Effect): void;
  51727. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51728. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51729. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51730. bindSamplers(effect: Effect): void;
  51731. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51732. getRenderWidth(useScreen?: boolean): number;
  51733. getRenderHeight(useScreen?: boolean): number;
  51734. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51735. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51736. /**
  51737. * Set the z offset to apply to current rendering
  51738. * @param value defines the offset to apply
  51739. */
  51740. setZOffset(value: number): void;
  51741. /**
  51742. * Gets the current value of the zOffset
  51743. * @returns the current zOffset state
  51744. */
  51745. getZOffset(): number;
  51746. /**
  51747. * Enable or disable depth buffering
  51748. * @param enable defines the state to set
  51749. */
  51750. setDepthBuffer(enable: boolean): void;
  51751. /**
  51752. * Gets a boolean indicating if depth writing is enabled
  51753. * @returns the current depth writing state
  51754. */
  51755. getDepthWrite(): boolean;
  51756. /**
  51757. * Enable or disable depth writing
  51758. * @param enable defines the state to set
  51759. */
  51760. setDepthWrite(enable: boolean): void;
  51761. /**
  51762. * Enable or disable color writing
  51763. * @param enable defines the state to set
  51764. */
  51765. setColorWrite(enable: boolean): void;
  51766. /**
  51767. * Gets a boolean indicating if color writing is enabled
  51768. * @returns the current color writing state
  51769. */
  51770. getColorWrite(): boolean;
  51771. /**
  51772. * Sets alpha constants used by some alpha blending modes
  51773. * @param r defines the red component
  51774. * @param g defines the green component
  51775. * @param b defines the blue component
  51776. * @param a defines the alpha component
  51777. */
  51778. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51779. /**
  51780. * Sets the current alpha mode
  51781. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51782. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51783. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51784. */
  51785. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51786. /**
  51787. * Gets the current alpha mode
  51788. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51789. * @returns the current alpha mode
  51790. */
  51791. getAlphaMode(): number;
  51792. setInt(uniform: WebGLUniformLocation, int: number): void;
  51793. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51794. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51795. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51796. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51797. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51798. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51799. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51800. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51801. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51802. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51803. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51804. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51805. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51806. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51807. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51808. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51809. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51810. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51811. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51812. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51813. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51814. wipeCaches(bruteForce?: boolean): void;
  51815. _createTexture(): WebGLTexture;
  51816. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51817. /**
  51818. * Usually called from Texture.ts.
  51819. * Passed information to create a WebGLTexture
  51820. * @param url defines a value which contains one of the following:
  51821. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51822. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51823. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51824. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51825. * @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)
  51826. * @param scene needed for loading to the correct scene
  51827. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51828. * @param onLoad optional callback to be called upon successful completion
  51829. * @param onError optional callback to be called upon failure
  51830. * @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
  51831. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51832. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51833. * @param forcedExtension defines the extension to use to pick the right loader
  51834. * @param mimeType defines an optional mime type
  51835. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51836. */
  51837. 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;
  51838. /**
  51839. * Creates a cube texture
  51840. * @param rootUrl defines the url where the files to load is located
  51841. * @param scene defines the current scene
  51842. * @param files defines the list of files to load (1 per face)
  51843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51844. * @param onLoad defines an optional callback raised when the texture is loaded
  51845. * @param onError defines an optional callback raised if there is an issue to load the texture
  51846. * @param format defines the format of the data
  51847. * @param forcedExtension defines the extension to use to pick the right loader
  51848. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51849. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51850. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51851. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51852. * @returns the cube texture as an InternalTexture
  51853. */
  51854. 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;
  51855. private _getSamplingFilter;
  51856. private static _GetNativeTextureFormat;
  51857. createRenderTargetTexture(size: number | {
  51858. width: number;
  51859. height: number;
  51860. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51861. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51862. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51863. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51864. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51865. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51866. /**
  51867. * Updates a dynamic vertex buffer.
  51868. * @param vertexBuffer the vertex buffer to update
  51869. * @param data the data used to update the vertex buffer
  51870. * @param byteOffset the byte offset of the data (optional)
  51871. * @param byteLength the byte length of the data (optional)
  51872. */
  51873. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51874. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51875. private _updateAnisotropicLevel;
  51876. private _getAddressMode;
  51877. /** @hidden */
  51878. _bindTexture(channel: number, texture: InternalTexture): void;
  51879. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51880. releaseEffects(): void;
  51881. /** @hidden */
  51882. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51883. /** @hidden */
  51884. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51885. /** @hidden */
  51886. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51887. /** @hidden */
  51888. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51889. }
  51890. }
  51891. declare module BABYLON {
  51892. /**
  51893. * Gather the list of clipboard event types as constants.
  51894. */
  51895. export class ClipboardEventTypes {
  51896. /**
  51897. * The clipboard event is fired when a copy command is active (pressed).
  51898. */
  51899. static readonly COPY: number;
  51900. /**
  51901. * The clipboard event is fired when a cut command is active (pressed).
  51902. */
  51903. static readonly CUT: number;
  51904. /**
  51905. * The clipboard event is fired when a paste command is active (pressed).
  51906. */
  51907. static readonly PASTE: number;
  51908. }
  51909. /**
  51910. * This class is used to store clipboard related info for the onClipboardObservable event.
  51911. */
  51912. export class ClipboardInfo {
  51913. /**
  51914. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51915. */
  51916. type: number;
  51917. /**
  51918. * Defines the related dom event
  51919. */
  51920. event: ClipboardEvent;
  51921. /**
  51922. *Creates an instance of ClipboardInfo.
  51923. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51924. * @param event Defines the related dom event
  51925. */
  51926. constructor(
  51927. /**
  51928. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51929. */
  51930. type: number,
  51931. /**
  51932. * Defines the related dom event
  51933. */
  51934. event: ClipboardEvent);
  51935. /**
  51936. * Get the clipboard event's type from the keycode.
  51937. * @param keyCode Defines the keyCode for the current keyboard event.
  51938. * @return {number}
  51939. */
  51940. static GetTypeFromCharacter(keyCode: number): number;
  51941. }
  51942. }
  51943. declare module BABYLON {
  51944. /**
  51945. * Google Daydream controller
  51946. */
  51947. export class DaydreamController extends WebVRController {
  51948. /**
  51949. * Base Url for the controller model.
  51950. */
  51951. static MODEL_BASE_URL: string;
  51952. /**
  51953. * File name for the controller model.
  51954. */
  51955. static MODEL_FILENAME: string;
  51956. /**
  51957. * Gamepad Id prefix used to identify Daydream Controller.
  51958. */
  51959. static readonly GAMEPAD_ID_PREFIX: string;
  51960. /**
  51961. * Creates a new DaydreamController from a gamepad
  51962. * @param vrGamepad the gamepad that the controller should be created from
  51963. */
  51964. constructor(vrGamepad: any);
  51965. /**
  51966. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51967. * @param scene scene in which to add meshes
  51968. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51969. */
  51970. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51971. /**
  51972. * Called once for each button that changed state since the last frame
  51973. * @param buttonIdx Which button index changed
  51974. * @param state New state of the button
  51975. * @param changes Which properties on the state changed since last frame
  51976. */
  51977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51978. }
  51979. }
  51980. declare module BABYLON {
  51981. /**
  51982. * Gear VR Controller
  51983. */
  51984. export class GearVRController extends WebVRController {
  51985. /**
  51986. * Base Url for the controller model.
  51987. */
  51988. static MODEL_BASE_URL: string;
  51989. /**
  51990. * File name for the controller model.
  51991. */
  51992. static MODEL_FILENAME: string;
  51993. /**
  51994. * Gamepad Id prefix used to identify this controller.
  51995. */
  51996. static readonly GAMEPAD_ID_PREFIX: string;
  51997. private readonly _buttonIndexToObservableNameMap;
  51998. /**
  51999. * Creates a new GearVRController from a gamepad
  52000. * @param vrGamepad the gamepad that the controller should be created from
  52001. */
  52002. constructor(vrGamepad: any);
  52003. /**
  52004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52005. * @param scene scene in which to add meshes
  52006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52007. */
  52008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52009. /**
  52010. * Called once for each button that changed state since the last frame
  52011. * @param buttonIdx Which button index changed
  52012. * @param state New state of the button
  52013. * @param changes Which properties on the state changed since last frame
  52014. */
  52015. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52016. }
  52017. }
  52018. declare module BABYLON {
  52019. /**
  52020. * Generic Controller
  52021. */
  52022. export class GenericController extends WebVRController {
  52023. /**
  52024. * Base Url for the controller model.
  52025. */
  52026. static readonly MODEL_BASE_URL: string;
  52027. /**
  52028. * File name for the controller model.
  52029. */
  52030. static readonly MODEL_FILENAME: string;
  52031. /**
  52032. * Creates a new GenericController from a gamepad
  52033. * @param vrGamepad the gamepad that the controller should be created from
  52034. */
  52035. constructor(vrGamepad: any);
  52036. /**
  52037. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52038. * @param scene scene in which to add meshes
  52039. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52040. */
  52041. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52042. /**
  52043. * Called once for each button that changed state since the last frame
  52044. * @param buttonIdx Which button index changed
  52045. * @param state New state of the button
  52046. * @param changes Which properties on the state changed since last frame
  52047. */
  52048. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52049. }
  52050. }
  52051. declare module BABYLON {
  52052. /**
  52053. * Oculus Touch Controller
  52054. */
  52055. export class OculusTouchController extends WebVRController {
  52056. /**
  52057. * Base Url for the controller model.
  52058. */
  52059. static MODEL_BASE_URL: string;
  52060. /**
  52061. * File name for the left controller model.
  52062. */
  52063. static MODEL_LEFT_FILENAME: string;
  52064. /**
  52065. * File name for the right controller model.
  52066. */
  52067. static MODEL_RIGHT_FILENAME: string;
  52068. /**
  52069. * Base Url for the Quest controller model.
  52070. */
  52071. static QUEST_MODEL_BASE_URL: string;
  52072. /**
  52073. * @hidden
  52074. * If the controllers are running on a device that needs the updated Quest controller models
  52075. */
  52076. static _IsQuest: boolean;
  52077. /**
  52078. * Fired when the secondary trigger on this controller is modified
  52079. */
  52080. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52081. /**
  52082. * Fired when the thumb rest on this controller is modified
  52083. */
  52084. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52085. /**
  52086. * Creates a new OculusTouchController from a gamepad
  52087. * @param vrGamepad the gamepad that the controller should be created from
  52088. */
  52089. constructor(vrGamepad: any);
  52090. /**
  52091. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52092. * @param scene scene in which to add meshes
  52093. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52094. */
  52095. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52096. /**
  52097. * Fired when the A button on this controller is modified
  52098. */
  52099. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52100. /**
  52101. * Fired when the B button on this controller is modified
  52102. */
  52103. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52104. /**
  52105. * Fired when the X button on this controller is modified
  52106. */
  52107. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52108. /**
  52109. * Fired when the Y button on this controller is modified
  52110. */
  52111. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52112. /**
  52113. * Called once for each button that changed state since the last frame
  52114. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52115. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52116. * 2) secondary trigger (same)
  52117. * 3) A (right) X (left), touch, pressed = value
  52118. * 4) B / Y
  52119. * 5) thumb rest
  52120. * @param buttonIdx Which button index changed
  52121. * @param state New state of the button
  52122. * @param changes Which properties on the state changed since last frame
  52123. */
  52124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52125. }
  52126. }
  52127. declare module BABYLON {
  52128. /**
  52129. * Vive Controller
  52130. */
  52131. export class ViveController extends WebVRController {
  52132. /**
  52133. * Base Url for the controller model.
  52134. */
  52135. static MODEL_BASE_URL: string;
  52136. /**
  52137. * File name for the controller model.
  52138. */
  52139. static MODEL_FILENAME: string;
  52140. /**
  52141. * Creates a new ViveController from a gamepad
  52142. * @param vrGamepad the gamepad that the controller should be created from
  52143. */
  52144. constructor(vrGamepad: any);
  52145. /**
  52146. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52147. * @param scene scene in which to add meshes
  52148. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52149. */
  52150. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52151. /**
  52152. * Fired when the left button on this controller is modified
  52153. */
  52154. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52155. /**
  52156. * Fired when the right button on this controller is modified
  52157. */
  52158. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52159. /**
  52160. * Fired when the menu button on this controller is modified
  52161. */
  52162. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52163. /**
  52164. * Called once for each button that changed state since the last frame
  52165. * Vive mapping:
  52166. * 0: touchpad
  52167. * 1: trigger
  52168. * 2: left AND right buttons
  52169. * 3: menu button
  52170. * @param buttonIdx Which button index changed
  52171. * @param state New state of the button
  52172. * @param changes Which properties on the state changed since last frame
  52173. */
  52174. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52175. }
  52176. }
  52177. declare module BABYLON {
  52178. /**
  52179. * Defines the WindowsMotionController object that the state of the windows motion controller
  52180. */
  52181. export class WindowsMotionController extends WebVRController {
  52182. /**
  52183. * The base url used to load the left and right controller models
  52184. */
  52185. static MODEL_BASE_URL: string;
  52186. /**
  52187. * The name of the left controller model file
  52188. */
  52189. static MODEL_LEFT_FILENAME: string;
  52190. /**
  52191. * The name of the right controller model file
  52192. */
  52193. static MODEL_RIGHT_FILENAME: string;
  52194. /**
  52195. * The controller name prefix for this controller type
  52196. */
  52197. static readonly GAMEPAD_ID_PREFIX: string;
  52198. /**
  52199. * The controller id pattern for this controller type
  52200. */
  52201. private static readonly GAMEPAD_ID_PATTERN;
  52202. private _loadedMeshInfo;
  52203. protected readonly _mapping: {
  52204. buttons: string[];
  52205. buttonMeshNames: {
  52206. trigger: string;
  52207. menu: string;
  52208. grip: string;
  52209. thumbstick: string;
  52210. trackpad: string;
  52211. };
  52212. buttonObservableNames: {
  52213. trigger: string;
  52214. menu: string;
  52215. grip: string;
  52216. thumbstick: string;
  52217. trackpad: string;
  52218. };
  52219. axisMeshNames: string[];
  52220. pointingPoseMeshName: string;
  52221. };
  52222. /**
  52223. * Fired when the trackpad on this controller is clicked
  52224. */
  52225. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52226. /**
  52227. * Fired when the trackpad on this controller is modified
  52228. */
  52229. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52230. /**
  52231. * The current x and y values of this controller's trackpad
  52232. */
  52233. trackpad: StickValues;
  52234. /**
  52235. * Creates a new WindowsMotionController from a gamepad
  52236. * @param vrGamepad the gamepad that the controller should be created from
  52237. */
  52238. constructor(vrGamepad: any);
  52239. /**
  52240. * Fired when the trigger on this controller is modified
  52241. */
  52242. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52243. /**
  52244. * Fired when the menu button on this controller is modified
  52245. */
  52246. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52247. /**
  52248. * Fired when the grip button on this controller is modified
  52249. */
  52250. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52251. /**
  52252. * Fired when the thumbstick button on this controller is modified
  52253. */
  52254. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52255. /**
  52256. * Fired when the touchpad button on this controller is modified
  52257. */
  52258. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52259. /**
  52260. * Fired when the touchpad values on this controller are modified
  52261. */
  52262. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52263. protected _updateTrackpad(): void;
  52264. /**
  52265. * Called once per frame by the engine.
  52266. */
  52267. update(): void;
  52268. /**
  52269. * Called once for each button that changed state since the last frame
  52270. * @param buttonIdx Which button index changed
  52271. * @param state New state of the button
  52272. * @param changes Which properties on the state changed since last frame
  52273. */
  52274. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52275. /**
  52276. * Moves the buttons on the controller mesh based on their current state
  52277. * @param buttonName the name of the button to move
  52278. * @param buttonValue the value of the button which determines the buttons new position
  52279. */
  52280. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52281. /**
  52282. * Moves the axis on the controller mesh based on its current state
  52283. * @param axis the index of the axis
  52284. * @param axisValue the value of the axis which determines the meshes new position
  52285. * @hidden
  52286. */
  52287. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52288. /**
  52289. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52290. * @param scene scene in which to add meshes
  52291. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52292. */
  52293. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52294. /**
  52295. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52296. * can be transformed by button presses and axes values, based on this._mapping.
  52297. *
  52298. * @param scene scene in which the meshes exist
  52299. * @param meshes list of meshes that make up the controller model to process
  52300. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52301. */
  52302. private processModel;
  52303. private createMeshInfo;
  52304. /**
  52305. * Gets the ray of the controller in the direction the controller is pointing
  52306. * @param length the length the resulting ray should be
  52307. * @returns a ray in the direction the controller is pointing
  52308. */
  52309. getForwardRay(length?: number): Ray;
  52310. /**
  52311. * Disposes of the controller
  52312. */
  52313. dispose(): void;
  52314. }
  52315. /**
  52316. * This class represents a new windows motion controller in XR.
  52317. */
  52318. export class XRWindowsMotionController extends WindowsMotionController {
  52319. /**
  52320. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52321. */
  52322. protected readonly _mapping: {
  52323. buttons: string[];
  52324. buttonMeshNames: {
  52325. trigger: string;
  52326. menu: string;
  52327. grip: string;
  52328. thumbstick: string;
  52329. trackpad: string;
  52330. };
  52331. buttonObservableNames: {
  52332. trigger: string;
  52333. menu: string;
  52334. grip: string;
  52335. thumbstick: string;
  52336. trackpad: string;
  52337. };
  52338. axisMeshNames: string[];
  52339. pointingPoseMeshName: string;
  52340. };
  52341. /**
  52342. * Construct a new XR-Based windows motion controller
  52343. *
  52344. * @param gamepadInfo the gamepad object from the browser
  52345. */
  52346. constructor(gamepadInfo: any);
  52347. /**
  52348. * holds the thumbstick values (X,Y)
  52349. */
  52350. thumbstickValues: StickValues;
  52351. /**
  52352. * Fired when the thumbstick on this controller is clicked
  52353. */
  52354. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52355. /**
  52356. * Fired when the thumbstick on this controller is modified
  52357. */
  52358. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52359. /**
  52360. * Fired when the touchpad button on this controller is modified
  52361. */
  52362. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52363. /**
  52364. * Fired when the touchpad values on this controller are modified
  52365. */
  52366. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52367. /**
  52368. * Fired when the thumbstick button on this controller is modified
  52369. * here to prevent breaking changes
  52370. */
  52371. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52372. /**
  52373. * updating the thumbstick(!) and not the trackpad.
  52374. * This is named this way due to the difference between WebVR and XR and to avoid
  52375. * changing the parent class.
  52376. */
  52377. protected _updateTrackpad(): void;
  52378. /**
  52379. * Disposes the class with joy
  52380. */
  52381. dispose(): void;
  52382. }
  52383. }
  52384. declare module BABYLON {
  52385. /**
  52386. * Class containing static functions to help procedurally build meshes
  52387. */
  52388. export class PolyhedronBuilder {
  52389. /**
  52390. * Creates a polyhedron mesh
  52391. * * 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
  52392. * * The parameter `size` (positive float, default 1) sets the polygon size
  52393. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52394. * * 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`
  52395. * * 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
  52396. * * 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)`)
  52397. * * 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
  52398. * * 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
  52399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52400. * * 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
  52401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52402. * @param name defines the name of the mesh
  52403. * @param options defines the options used to create the mesh
  52404. * @param scene defines the hosting scene
  52405. * @returns the polyhedron mesh
  52406. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52407. */
  52408. static CreatePolyhedron(name: string, options: {
  52409. type?: number;
  52410. size?: number;
  52411. sizeX?: number;
  52412. sizeY?: number;
  52413. sizeZ?: number;
  52414. custom?: any;
  52415. faceUV?: Vector4[];
  52416. faceColors?: Color4[];
  52417. flat?: boolean;
  52418. updatable?: boolean;
  52419. sideOrientation?: number;
  52420. frontUVs?: Vector4;
  52421. backUVs?: Vector4;
  52422. }, scene?: Nullable<Scene>): Mesh;
  52423. }
  52424. }
  52425. declare module BABYLON {
  52426. /**
  52427. * Gizmo that enables scaling a mesh along 3 axis
  52428. */
  52429. export class ScaleGizmo extends Gizmo {
  52430. /**
  52431. * Internal gizmo used for interactions on the x axis
  52432. */
  52433. xGizmo: AxisScaleGizmo;
  52434. /**
  52435. * Internal gizmo used for interactions on the y axis
  52436. */
  52437. yGizmo: AxisScaleGizmo;
  52438. /**
  52439. * Internal gizmo used for interactions on the z axis
  52440. */
  52441. zGizmo: AxisScaleGizmo;
  52442. /**
  52443. * Internal gizmo used to scale all axis equally
  52444. */
  52445. uniformScaleGizmo: AxisScaleGizmo;
  52446. private _meshAttached;
  52447. private _updateGizmoRotationToMatchAttachedMesh;
  52448. private _snapDistance;
  52449. private _scaleRatio;
  52450. private _uniformScalingMesh;
  52451. private _octahedron;
  52452. private _sensitivity;
  52453. /** Fires an event when any of it's sub gizmos are dragged */
  52454. onDragStartObservable: Observable<unknown>;
  52455. /** Fires an event when any of it's sub gizmos are released from dragging */
  52456. onDragEndObservable: Observable<unknown>;
  52457. get attachedMesh(): Nullable<AbstractMesh>;
  52458. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52459. /**
  52460. * Creates a ScaleGizmo
  52461. * @param gizmoLayer The utility layer the gizmo will be added to
  52462. */
  52463. constructor(gizmoLayer?: UtilityLayerRenderer);
  52464. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52465. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52466. /**
  52467. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52468. */
  52469. set snapDistance(value: number);
  52470. get snapDistance(): number;
  52471. /**
  52472. * Ratio for the scale of the gizmo (Default: 1)
  52473. */
  52474. set scaleRatio(value: number);
  52475. get scaleRatio(): number;
  52476. /**
  52477. * Sensitivity factor for dragging (Default: 1)
  52478. */
  52479. set sensitivity(value: number);
  52480. get sensitivity(): number;
  52481. /**
  52482. * Disposes of the gizmo
  52483. */
  52484. dispose(): void;
  52485. }
  52486. }
  52487. declare module BABYLON {
  52488. /**
  52489. * Single axis scale gizmo
  52490. */
  52491. export class AxisScaleGizmo extends Gizmo {
  52492. /**
  52493. * Drag behavior responsible for the gizmos dragging interactions
  52494. */
  52495. dragBehavior: PointerDragBehavior;
  52496. private _pointerObserver;
  52497. /**
  52498. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52499. */
  52500. snapDistance: number;
  52501. /**
  52502. * Event that fires each time the gizmo snaps to a new location.
  52503. * * snapDistance is the the change in distance
  52504. */
  52505. onSnapObservable: Observable<{
  52506. snapDistance: number;
  52507. }>;
  52508. /**
  52509. * If the scaling operation should be done on all axis (default: false)
  52510. */
  52511. uniformScaling: boolean;
  52512. /**
  52513. * Custom sensitivity value for the drag strength
  52514. */
  52515. sensitivity: number;
  52516. private _isEnabled;
  52517. private _parent;
  52518. private _arrow;
  52519. private _coloredMaterial;
  52520. private _hoverMaterial;
  52521. /**
  52522. * Creates an AxisScaleGizmo
  52523. * @param gizmoLayer The utility layer the gizmo will be added to
  52524. * @param dragAxis The axis which the gizmo will be able to scale on
  52525. * @param color The color of the gizmo
  52526. */
  52527. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52529. /**
  52530. * If the gizmo is enabled
  52531. */
  52532. set isEnabled(value: boolean);
  52533. get isEnabled(): boolean;
  52534. /**
  52535. * Disposes of the gizmo
  52536. */
  52537. dispose(): void;
  52538. /**
  52539. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52540. * @param mesh The mesh to replace the default mesh of the gizmo
  52541. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52542. */
  52543. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52544. }
  52545. }
  52546. declare module BABYLON {
  52547. /**
  52548. * Bounding box gizmo
  52549. */
  52550. export class BoundingBoxGizmo extends Gizmo {
  52551. private _lineBoundingBox;
  52552. private _rotateSpheresParent;
  52553. private _scaleBoxesParent;
  52554. private _boundingDimensions;
  52555. private _renderObserver;
  52556. private _pointerObserver;
  52557. private _scaleDragSpeed;
  52558. private _tmpQuaternion;
  52559. private _tmpVector;
  52560. private _tmpRotationMatrix;
  52561. /**
  52562. * 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)
  52563. */
  52564. ignoreChildren: boolean;
  52565. /**
  52566. * 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)
  52567. */
  52568. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52569. /**
  52570. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52571. */
  52572. rotationSphereSize: number;
  52573. /**
  52574. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52575. */
  52576. scaleBoxSize: number;
  52577. /**
  52578. * 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)
  52579. */
  52580. fixedDragMeshScreenSize: boolean;
  52581. /**
  52582. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52583. */
  52584. fixedDragMeshScreenSizeDistanceFactor: number;
  52585. /**
  52586. * Fired when a rotation sphere or scale box is dragged
  52587. */
  52588. onDragStartObservable: Observable<{}>;
  52589. /**
  52590. * Fired when a scale box is dragged
  52591. */
  52592. onScaleBoxDragObservable: Observable<{}>;
  52593. /**
  52594. * Fired when a scale box drag is ended
  52595. */
  52596. onScaleBoxDragEndObservable: Observable<{}>;
  52597. /**
  52598. * Fired when a rotation sphere is dragged
  52599. */
  52600. onRotationSphereDragObservable: Observable<{}>;
  52601. /**
  52602. * Fired when a rotation sphere drag is ended
  52603. */
  52604. onRotationSphereDragEndObservable: Observable<{}>;
  52605. /**
  52606. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  52607. */
  52608. scalePivot: Nullable<Vector3>;
  52609. /**
  52610. * Mesh used as a pivot to rotate the attached mesh
  52611. */
  52612. private _anchorMesh;
  52613. private _existingMeshScale;
  52614. private _dragMesh;
  52615. private pointerDragBehavior;
  52616. private coloredMaterial;
  52617. private hoverColoredMaterial;
  52618. /**
  52619. * Sets the color of the bounding box gizmo
  52620. * @param color the color to set
  52621. */
  52622. setColor(color: Color3): void;
  52623. /**
  52624. * Creates an BoundingBoxGizmo
  52625. * @param gizmoLayer The utility layer the gizmo will be added to
  52626. * @param color The color of the gizmo
  52627. */
  52628. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52629. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52630. private _selectNode;
  52631. /**
  52632. * Updates the bounding box information for the Gizmo
  52633. */
  52634. updateBoundingBox(): void;
  52635. private _updateRotationSpheres;
  52636. private _updateScaleBoxes;
  52637. /**
  52638. * Enables rotation on the specified axis and disables rotation on the others
  52639. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52640. */
  52641. setEnabledRotationAxis(axis: string): void;
  52642. /**
  52643. * Enables/disables scaling
  52644. * @param enable if scaling should be enabled
  52645. * @param homogeneousScaling defines if scaling should only be homogeneous
  52646. */
  52647. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52648. private _updateDummy;
  52649. /**
  52650. * Enables a pointer drag behavior on the bounding box of the gizmo
  52651. */
  52652. enableDragBehavior(): void;
  52653. /**
  52654. * Disposes of the gizmo
  52655. */
  52656. dispose(): void;
  52657. /**
  52658. * 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)
  52659. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52660. * @returns the bounding box mesh with the passed in mesh as a child
  52661. */
  52662. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52663. /**
  52664. * CustomMeshes are not supported by this gizmo
  52665. * @param mesh The mesh to replace the default mesh of the gizmo
  52666. */
  52667. setCustomMesh(mesh: Mesh): void;
  52668. }
  52669. }
  52670. declare module BABYLON {
  52671. /**
  52672. * Single plane rotation gizmo
  52673. */
  52674. export class PlaneRotationGizmo extends Gizmo {
  52675. /**
  52676. * Drag behavior responsible for the gizmos dragging interactions
  52677. */
  52678. dragBehavior: PointerDragBehavior;
  52679. private _pointerObserver;
  52680. /**
  52681. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52682. */
  52683. snapDistance: number;
  52684. /**
  52685. * Event that fires each time the gizmo snaps to a new location.
  52686. * * snapDistance is the the change in distance
  52687. */
  52688. onSnapObservable: Observable<{
  52689. snapDistance: number;
  52690. }>;
  52691. private _isEnabled;
  52692. private _parent;
  52693. /**
  52694. * Creates a PlaneRotationGizmo
  52695. * @param gizmoLayer The utility layer the gizmo will be added to
  52696. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52697. * @param color The color of the gizmo
  52698. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52699. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52700. */
  52701. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52702. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52703. /**
  52704. * If the gizmo is enabled
  52705. */
  52706. set isEnabled(value: boolean);
  52707. get isEnabled(): boolean;
  52708. /**
  52709. * Disposes of the gizmo
  52710. */
  52711. dispose(): void;
  52712. }
  52713. }
  52714. declare module BABYLON {
  52715. /**
  52716. * Gizmo that enables rotating a mesh along 3 axis
  52717. */
  52718. export class RotationGizmo extends Gizmo {
  52719. /**
  52720. * Internal gizmo used for interactions on the x axis
  52721. */
  52722. xGizmo: PlaneRotationGizmo;
  52723. /**
  52724. * Internal gizmo used for interactions on the y axis
  52725. */
  52726. yGizmo: PlaneRotationGizmo;
  52727. /**
  52728. * Internal gizmo used for interactions on the z axis
  52729. */
  52730. zGizmo: PlaneRotationGizmo;
  52731. /** Fires an event when any of it's sub gizmos are dragged */
  52732. onDragStartObservable: Observable<unknown>;
  52733. /** Fires an event when any of it's sub gizmos are released from dragging */
  52734. onDragEndObservable: Observable<unknown>;
  52735. private _meshAttached;
  52736. get attachedMesh(): Nullable<AbstractMesh>;
  52737. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52738. /**
  52739. * Creates a RotationGizmo
  52740. * @param gizmoLayer The utility layer the gizmo will be added to
  52741. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52742. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52743. */
  52744. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52745. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52746. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52747. /**
  52748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52749. */
  52750. set snapDistance(value: number);
  52751. get snapDistance(): number;
  52752. /**
  52753. * Ratio for the scale of the gizmo (Default: 1)
  52754. */
  52755. set scaleRatio(value: number);
  52756. get scaleRatio(): number;
  52757. /**
  52758. * Disposes of the gizmo
  52759. */
  52760. dispose(): void;
  52761. /**
  52762. * CustomMeshes are not supported by this gizmo
  52763. * @param mesh The mesh to replace the default mesh of the gizmo
  52764. */
  52765. setCustomMesh(mesh: Mesh): void;
  52766. }
  52767. }
  52768. declare module BABYLON {
  52769. /**
  52770. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52771. */
  52772. export class GizmoManager implements IDisposable {
  52773. private scene;
  52774. /**
  52775. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52776. */
  52777. gizmos: {
  52778. positionGizmo: Nullable<PositionGizmo>;
  52779. rotationGizmo: Nullable<RotationGizmo>;
  52780. scaleGizmo: Nullable<ScaleGizmo>;
  52781. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52782. };
  52783. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52784. clearGizmoOnEmptyPointerEvent: boolean;
  52785. /** Fires an event when the manager is attached to a mesh */
  52786. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52787. private _gizmosEnabled;
  52788. private _pointerObserver;
  52789. private _attachedMesh;
  52790. private _boundingBoxColor;
  52791. private _defaultUtilityLayer;
  52792. private _defaultKeepDepthUtilityLayer;
  52793. /**
  52794. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52795. */
  52796. boundingBoxDragBehavior: SixDofDragBehavior;
  52797. /**
  52798. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52799. */
  52800. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52801. /**
  52802. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52803. */
  52804. usePointerToAttachGizmos: boolean;
  52805. /**
  52806. * Utility layer that the bounding box gizmo belongs to
  52807. */
  52808. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52809. /**
  52810. * Utility layer that all gizmos besides bounding box belong to
  52811. */
  52812. get utilityLayer(): UtilityLayerRenderer;
  52813. /**
  52814. * Instatiates a gizmo manager
  52815. * @param scene the scene to overlay the gizmos on top of
  52816. */
  52817. constructor(scene: Scene);
  52818. /**
  52819. * Attaches a set of gizmos to the specified mesh
  52820. * @param mesh The mesh the gizmo's should be attached to
  52821. */
  52822. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52823. /**
  52824. * If the position gizmo is enabled
  52825. */
  52826. set positionGizmoEnabled(value: boolean);
  52827. get positionGizmoEnabled(): boolean;
  52828. /**
  52829. * If the rotation gizmo is enabled
  52830. */
  52831. set rotationGizmoEnabled(value: boolean);
  52832. get rotationGizmoEnabled(): boolean;
  52833. /**
  52834. * If the scale gizmo is enabled
  52835. */
  52836. set scaleGizmoEnabled(value: boolean);
  52837. get scaleGizmoEnabled(): boolean;
  52838. /**
  52839. * If the boundingBox gizmo is enabled
  52840. */
  52841. set boundingBoxGizmoEnabled(value: boolean);
  52842. get boundingBoxGizmoEnabled(): boolean;
  52843. /**
  52844. * Disposes of the gizmo manager
  52845. */
  52846. dispose(): void;
  52847. }
  52848. }
  52849. declare module BABYLON {
  52850. /**
  52851. * A directional light is defined by a direction (what a surprise!).
  52852. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52853. * 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.
  52854. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52855. */
  52856. export class DirectionalLight extends ShadowLight {
  52857. private _shadowFrustumSize;
  52858. /**
  52859. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52860. */
  52861. get shadowFrustumSize(): number;
  52862. /**
  52863. * Specifies a fix frustum size for the shadow generation.
  52864. */
  52865. set shadowFrustumSize(value: number);
  52866. private _shadowOrthoScale;
  52867. /**
  52868. * Gets the shadow projection scale against the optimal computed one.
  52869. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52870. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52871. */
  52872. get shadowOrthoScale(): number;
  52873. /**
  52874. * Sets the shadow projection scale against the optimal computed one.
  52875. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52876. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52877. */
  52878. set shadowOrthoScale(value: number);
  52879. /**
  52880. * Automatically compute the projection matrix to best fit (including all the casters)
  52881. * on each frame.
  52882. */
  52883. autoUpdateExtends: boolean;
  52884. /**
  52885. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52886. * on each frame. autoUpdateExtends must be set to true for this to work
  52887. */
  52888. autoCalcShadowZBounds: boolean;
  52889. private _orthoLeft;
  52890. private _orthoRight;
  52891. private _orthoTop;
  52892. private _orthoBottom;
  52893. /**
  52894. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52895. * The directional light is emitted from everywhere in the given direction.
  52896. * It can cast shadows.
  52897. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52898. * @param name The friendly name of the light
  52899. * @param direction The direction of the light
  52900. * @param scene The scene the light belongs to
  52901. */
  52902. constructor(name: string, direction: Vector3, scene: Scene);
  52903. /**
  52904. * Returns the string "DirectionalLight".
  52905. * @return The class name
  52906. */
  52907. getClassName(): string;
  52908. /**
  52909. * Returns the integer 1.
  52910. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52911. */
  52912. getTypeID(): number;
  52913. /**
  52914. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52915. * Returns the DirectionalLight Shadow projection matrix.
  52916. */
  52917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52918. /**
  52919. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52920. * Returns the DirectionalLight Shadow projection matrix.
  52921. */
  52922. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52923. /**
  52924. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52925. * Returns the DirectionalLight Shadow projection matrix.
  52926. */
  52927. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52928. protected _buildUniformLayout(): void;
  52929. /**
  52930. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52931. * @param effect The effect to update
  52932. * @param lightIndex The index of the light in the effect to update
  52933. * @returns The directional light
  52934. */
  52935. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52936. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52937. /**
  52938. * Gets the minZ used for shadow according to both the scene and the light.
  52939. *
  52940. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52941. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52942. * @param activeCamera The camera we are returning the min for
  52943. * @returns the depth min z
  52944. */
  52945. getDepthMinZ(activeCamera: Camera): number;
  52946. /**
  52947. * Gets the maxZ used for shadow according to both the scene and the light.
  52948. *
  52949. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52950. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52951. * @param activeCamera The camera we are returning the max for
  52952. * @returns the depth max z
  52953. */
  52954. getDepthMaxZ(activeCamera: Camera): number;
  52955. /**
  52956. * Prepares the list of defines specific to the light type.
  52957. * @param defines the list of defines
  52958. * @param lightIndex defines the index of the light for the effect
  52959. */
  52960. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52961. }
  52962. }
  52963. declare module BABYLON {
  52964. /**
  52965. * Class containing static functions to help procedurally build meshes
  52966. */
  52967. export class HemisphereBuilder {
  52968. /**
  52969. * Creates a hemisphere mesh
  52970. * @param name defines the name of the mesh
  52971. * @param options defines the options used to create the mesh
  52972. * @param scene defines the hosting scene
  52973. * @returns the hemisphere mesh
  52974. */
  52975. static CreateHemisphere(name: string, options: {
  52976. segments?: number;
  52977. diameter?: number;
  52978. sideOrientation?: number;
  52979. }, scene: any): Mesh;
  52980. }
  52981. }
  52982. declare module BABYLON {
  52983. /**
  52984. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52985. * These values define a cone of light starting from the position, emitting toward the direction.
  52986. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52987. * and the exponent defines the speed of the decay of the light with distance (reach).
  52988. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52989. */
  52990. export class SpotLight extends ShadowLight {
  52991. private _angle;
  52992. private _innerAngle;
  52993. private _cosHalfAngle;
  52994. private _lightAngleScale;
  52995. private _lightAngleOffset;
  52996. /**
  52997. * Gets the cone angle of the spot light in Radians.
  52998. */
  52999. get angle(): number;
  53000. /**
  53001. * Sets the cone angle of the spot light in Radians.
  53002. */
  53003. set angle(value: number);
  53004. /**
  53005. * Only used in gltf falloff mode, this defines the angle where
  53006. * the directional falloff will start before cutting at angle which could be seen
  53007. * as outer angle.
  53008. */
  53009. get innerAngle(): number;
  53010. /**
  53011. * Only used in gltf falloff mode, this defines the angle where
  53012. * the directional falloff will start before cutting at angle which could be seen
  53013. * as outer angle.
  53014. */
  53015. set innerAngle(value: number);
  53016. private _shadowAngleScale;
  53017. /**
  53018. * Allows scaling the angle of the light for shadow generation only.
  53019. */
  53020. get shadowAngleScale(): number;
  53021. /**
  53022. * Allows scaling the angle of the light for shadow generation only.
  53023. */
  53024. set shadowAngleScale(value: number);
  53025. /**
  53026. * The light decay speed with the distance from the emission spot.
  53027. */
  53028. exponent: number;
  53029. private _projectionTextureMatrix;
  53030. /**
  53031. * Allows reading the projecton texture
  53032. */
  53033. get projectionTextureMatrix(): Matrix;
  53034. protected _projectionTextureLightNear: number;
  53035. /**
  53036. * Gets the near clip of the Spotlight for texture projection.
  53037. */
  53038. get projectionTextureLightNear(): number;
  53039. /**
  53040. * Sets the near clip of the Spotlight for texture projection.
  53041. */
  53042. set projectionTextureLightNear(value: number);
  53043. protected _projectionTextureLightFar: number;
  53044. /**
  53045. * Gets the far clip of the Spotlight for texture projection.
  53046. */
  53047. get projectionTextureLightFar(): number;
  53048. /**
  53049. * Sets the far clip of the Spotlight for texture projection.
  53050. */
  53051. set projectionTextureLightFar(value: number);
  53052. protected _projectionTextureUpDirection: Vector3;
  53053. /**
  53054. * Gets the Up vector of the Spotlight for texture projection.
  53055. */
  53056. get projectionTextureUpDirection(): Vector3;
  53057. /**
  53058. * Sets the Up vector of the Spotlight for texture projection.
  53059. */
  53060. set projectionTextureUpDirection(value: Vector3);
  53061. private _projectionTexture;
  53062. /**
  53063. * Gets the projection texture of the light.
  53064. */
  53065. get projectionTexture(): Nullable<BaseTexture>;
  53066. /**
  53067. * Sets the projection texture of the light.
  53068. */
  53069. set projectionTexture(value: Nullable<BaseTexture>);
  53070. private _projectionTextureViewLightDirty;
  53071. private _projectionTextureProjectionLightDirty;
  53072. private _projectionTextureDirty;
  53073. private _projectionTextureViewTargetVector;
  53074. private _projectionTextureViewLightMatrix;
  53075. private _projectionTextureProjectionLightMatrix;
  53076. private _projectionTextureScalingMatrix;
  53077. /**
  53078. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53079. * It can cast shadows.
  53080. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53081. * @param name The light friendly name
  53082. * @param position The position of the spot light in the scene
  53083. * @param direction The direction of the light in the scene
  53084. * @param angle The cone angle of the light in Radians
  53085. * @param exponent The light decay speed with the distance from the emission spot
  53086. * @param scene The scene the lights belongs to
  53087. */
  53088. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53089. /**
  53090. * Returns the string "SpotLight".
  53091. * @returns the class name
  53092. */
  53093. getClassName(): string;
  53094. /**
  53095. * Returns the integer 2.
  53096. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53097. */
  53098. getTypeID(): number;
  53099. /**
  53100. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53101. */
  53102. protected _setDirection(value: Vector3): void;
  53103. /**
  53104. * Overrides the position setter to recompute the projection texture view light Matrix.
  53105. */
  53106. protected _setPosition(value: Vector3): void;
  53107. /**
  53108. * 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.
  53109. * Returns the SpotLight.
  53110. */
  53111. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53112. protected _computeProjectionTextureViewLightMatrix(): void;
  53113. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53114. /**
  53115. * Main function for light texture projection matrix computing.
  53116. */
  53117. protected _computeProjectionTextureMatrix(): void;
  53118. protected _buildUniformLayout(): void;
  53119. private _computeAngleValues;
  53120. /**
  53121. * Sets the passed Effect "effect" with the Light textures.
  53122. * @param effect The effect to update
  53123. * @param lightIndex The index of the light in the effect to update
  53124. * @returns The light
  53125. */
  53126. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53127. /**
  53128. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53129. * @param effect The effect to update
  53130. * @param lightIndex The index of the light in the effect to update
  53131. * @returns The spot light
  53132. */
  53133. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53134. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53135. /**
  53136. * Disposes the light and the associated resources.
  53137. */
  53138. dispose(): void;
  53139. /**
  53140. * Prepares the list of defines specific to the light type.
  53141. * @param defines the list of defines
  53142. * @param lightIndex defines the index of the light for the effect
  53143. */
  53144. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53145. }
  53146. }
  53147. declare module BABYLON {
  53148. /**
  53149. * Gizmo that enables viewing a light
  53150. */
  53151. export class LightGizmo extends Gizmo {
  53152. private _lightMesh;
  53153. private _material;
  53154. private _cachedPosition;
  53155. private _cachedForward;
  53156. private _attachedMeshParent;
  53157. /**
  53158. * Creates a LightGizmo
  53159. * @param gizmoLayer The utility layer the gizmo will be added to
  53160. */
  53161. constructor(gizmoLayer?: UtilityLayerRenderer);
  53162. private _light;
  53163. /**
  53164. * The light that the gizmo is attached to
  53165. */
  53166. set light(light: Nullable<Light>);
  53167. get light(): Nullable<Light>;
  53168. /**
  53169. * Gets the material used to render the light gizmo
  53170. */
  53171. get material(): StandardMaterial;
  53172. /**
  53173. * @hidden
  53174. * Updates the gizmo to match the attached mesh's position/rotation
  53175. */
  53176. protected _update(): void;
  53177. private static _Scale;
  53178. /**
  53179. * Creates the lines for a light mesh
  53180. */
  53181. private static _CreateLightLines;
  53182. /**
  53183. * Disposes of the light gizmo
  53184. */
  53185. dispose(): void;
  53186. private static _CreateHemisphericLightMesh;
  53187. private static _CreatePointLightMesh;
  53188. private static _CreateSpotLightMesh;
  53189. private static _CreateDirectionalLightMesh;
  53190. }
  53191. }
  53192. declare module BABYLON {
  53193. /** @hidden */
  53194. export var backgroundFragmentDeclaration: {
  53195. name: string;
  53196. shader: string;
  53197. };
  53198. }
  53199. declare module BABYLON {
  53200. /** @hidden */
  53201. export var backgroundUboDeclaration: {
  53202. name: string;
  53203. shader: string;
  53204. };
  53205. }
  53206. declare module BABYLON {
  53207. /** @hidden */
  53208. export var backgroundPixelShader: {
  53209. name: string;
  53210. shader: string;
  53211. };
  53212. }
  53213. declare module BABYLON {
  53214. /** @hidden */
  53215. export var backgroundVertexDeclaration: {
  53216. name: string;
  53217. shader: string;
  53218. };
  53219. }
  53220. declare module BABYLON {
  53221. /** @hidden */
  53222. export var backgroundVertexShader: {
  53223. name: string;
  53224. shader: string;
  53225. };
  53226. }
  53227. declare module BABYLON {
  53228. /**
  53229. * Background material used to create an efficient environement around your scene.
  53230. */
  53231. export class BackgroundMaterial extends PushMaterial {
  53232. /**
  53233. * Standard reflectance value at parallel view angle.
  53234. */
  53235. static StandardReflectance0: number;
  53236. /**
  53237. * Standard reflectance value at grazing angle.
  53238. */
  53239. static StandardReflectance90: number;
  53240. protected _primaryColor: Color3;
  53241. /**
  53242. * Key light Color (multiply against the environement texture)
  53243. */
  53244. primaryColor: Color3;
  53245. protected __perceptualColor: Nullable<Color3>;
  53246. /**
  53247. * Experimental Internal Use Only.
  53248. *
  53249. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53250. * This acts as a helper to set the primary color to a more "human friendly" value.
  53251. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53252. * output color as close as possible from the chosen value.
  53253. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53254. * part of lighting setup.)
  53255. */
  53256. get _perceptualColor(): Nullable<Color3>;
  53257. set _perceptualColor(value: Nullable<Color3>);
  53258. protected _primaryColorShadowLevel: float;
  53259. /**
  53260. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53261. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53262. */
  53263. get primaryColorShadowLevel(): float;
  53264. set primaryColorShadowLevel(value: float);
  53265. protected _primaryColorHighlightLevel: float;
  53266. /**
  53267. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53268. * The primary color is used at the level chosen to define what the white area would look.
  53269. */
  53270. get primaryColorHighlightLevel(): float;
  53271. set primaryColorHighlightLevel(value: float);
  53272. protected _reflectionTexture: Nullable<BaseTexture>;
  53273. /**
  53274. * Reflection Texture used in the material.
  53275. * Should be author in a specific way for the best result (refer to the documentation).
  53276. */
  53277. reflectionTexture: Nullable<BaseTexture>;
  53278. protected _reflectionBlur: float;
  53279. /**
  53280. * Reflection Texture level of blur.
  53281. *
  53282. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53283. * texture twice.
  53284. */
  53285. reflectionBlur: float;
  53286. protected _diffuseTexture: Nullable<BaseTexture>;
  53287. /**
  53288. * Diffuse Texture used in the material.
  53289. * Should be author in a specific way for the best result (refer to the documentation).
  53290. */
  53291. diffuseTexture: Nullable<BaseTexture>;
  53292. protected _shadowLights: Nullable<IShadowLight[]>;
  53293. /**
  53294. * Specify the list of lights casting shadow on the material.
  53295. * All scene shadow lights will be included if null.
  53296. */
  53297. shadowLights: Nullable<IShadowLight[]>;
  53298. protected _shadowLevel: float;
  53299. /**
  53300. * Helps adjusting the shadow to a softer level if required.
  53301. * 0 means black shadows and 1 means no shadows.
  53302. */
  53303. shadowLevel: float;
  53304. protected _sceneCenter: Vector3;
  53305. /**
  53306. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53307. * It is usually zero but might be interesting to modify according to your setup.
  53308. */
  53309. sceneCenter: Vector3;
  53310. protected _opacityFresnel: boolean;
  53311. /**
  53312. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53313. * This helps ensuring a nice transition when the camera goes under the ground.
  53314. */
  53315. opacityFresnel: boolean;
  53316. protected _reflectionFresnel: boolean;
  53317. /**
  53318. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53319. * This helps adding a mirror texture on the ground.
  53320. */
  53321. reflectionFresnel: boolean;
  53322. protected _reflectionFalloffDistance: number;
  53323. /**
  53324. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53325. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53326. */
  53327. reflectionFalloffDistance: number;
  53328. protected _reflectionAmount: number;
  53329. /**
  53330. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53331. */
  53332. reflectionAmount: number;
  53333. protected _reflectionReflectance0: number;
  53334. /**
  53335. * This specifies the weight of the reflection at grazing angle.
  53336. */
  53337. reflectionReflectance0: number;
  53338. protected _reflectionReflectance90: number;
  53339. /**
  53340. * This specifies the weight of the reflection at a perpendicular point of view.
  53341. */
  53342. reflectionReflectance90: number;
  53343. /**
  53344. * Sets the reflection reflectance fresnel values according to the default standard
  53345. * empirically know to work well :-)
  53346. */
  53347. set reflectionStandardFresnelWeight(value: number);
  53348. protected _useRGBColor: boolean;
  53349. /**
  53350. * Helps to directly use the maps channels instead of their level.
  53351. */
  53352. useRGBColor: boolean;
  53353. protected _enableNoise: boolean;
  53354. /**
  53355. * This helps reducing the banding effect that could occur on the background.
  53356. */
  53357. enableNoise: boolean;
  53358. /**
  53359. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53360. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53361. * Recommended to be keep at 1.0 except for special cases.
  53362. */
  53363. get fovMultiplier(): number;
  53364. set fovMultiplier(value: number);
  53365. private _fovMultiplier;
  53366. /**
  53367. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53368. */
  53369. useEquirectangularFOV: boolean;
  53370. private _maxSimultaneousLights;
  53371. /**
  53372. * Number of Simultaneous lights allowed on the material.
  53373. */
  53374. maxSimultaneousLights: int;
  53375. private _shadowOnly;
  53376. /**
  53377. * Make the material only render shadows
  53378. */
  53379. shadowOnly: boolean;
  53380. /**
  53381. * Default configuration related to image processing available in the Background Material.
  53382. */
  53383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53384. /**
  53385. * Keep track of the image processing observer to allow dispose and replace.
  53386. */
  53387. private _imageProcessingObserver;
  53388. /**
  53389. * Attaches a new image processing configuration to the PBR Material.
  53390. * @param configuration (if null the scene configuration will be use)
  53391. */
  53392. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53393. /**
  53394. * Gets the image processing configuration used either in this material.
  53395. */
  53396. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53397. /**
  53398. * Sets the Default image processing configuration used either in the this material.
  53399. *
  53400. * If sets to null, the scene one is in use.
  53401. */
  53402. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53403. /**
  53404. * Gets wether the color curves effect is enabled.
  53405. */
  53406. get cameraColorCurvesEnabled(): boolean;
  53407. /**
  53408. * Sets wether the color curves effect is enabled.
  53409. */
  53410. set cameraColorCurvesEnabled(value: boolean);
  53411. /**
  53412. * Gets wether the color grading effect is enabled.
  53413. */
  53414. get cameraColorGradingEnabled(): boolean;
  53415. /**
  53416. * Gets wether the color grading effect is enabled.
  53417. */
  53418. set cameraColorGradingEnabled(value: boolean);
  53419. /**
  53420. * Gets wether tonemapping is enabled or not.
  53421. */
  53422. get cameraToneMappingEnabled(): boolean;
  53423. /**
  53424. * Sets wether tonemapping is enabled or not
  53425. */
  53426. set cameraToneMappingEnabled(value: boolean);
  53427. /**
  53428. * The camera exposure used on this material.
  53429. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53430. * This corresponds to a photographic exposure.
  53431. */
  53432. get cameraExposure(): float;
  53433. /**
  53434. * The camera exposure used on this material.
  53435. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53436. * This corresponds to a photographic exposure.
  53437. */
  53438. set cameraExposure(value: float);
  53439. /**
  53440. * Gets The camera contrast used on this material.
  53441. */
  53442. get cameraContrast(): float;
  53443. /**
  53444. * Sets The camera contrast used on this material.
  53445. */
  53446. set cameraContrast(value: float);
  53447. /**
  53448. * Gets the Color Grading 2D Lookup Texture.
  53449. */
  53450. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53451. /**
  53452. * Sets the Color Grading 2D Lookup Texture.
  53453. */
  53454. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53455. /**
  53456. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53457. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53458. * 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;
  53459. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53460. */
  53461. get cameraColorCurves(): Nullable<ColorCurves>;
  53462. /**
  53463. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53464. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53465. * 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;
  53466. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53467. */
  53468. set cameraColorCurves(value: Nullable<ColorCurves>);
  53469. /**
  53470. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53471. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53472. */
  53473. switchToBGR: boolean;
  53474. private _renderTargets;
  53475. private _reflectionControls;
  53476. private _white;
  53477. private _primaryShadowColor;
  53478. private _primaryHighlightColor;
  53479. /**
  53480. * Instantiates a Background Material in the given scene
  53481. * @param name The friendly name of the material
  53482. * @param scene The scene to add the material to
  53483. */
  53484. constructor(name: string, scene: Scene);
  53485. /**
  53486. * Gets a boolean indicating that current material needs to register RTT
  53487. */
  53488. get hasRenderTargetTextures(): boolean;
  53489. /**
  53490. * The entire material has been created in order to prevent overdraw.
  53491. * @returns false
  53492. */
  53493. needAlphaTesting(): boolean;
  53494. /**
  53495. * The entire material has been created in order to prevent overdraw.
  53496. * @returns true if blending is enable
  53497. */
  53498. needAlphaBlending(): boolean;
  53499. /**
  53500. * Checks wether the material is ready to be rendered for a given mesh.
  53501. * @param mesh The mesh to render
  53502. * @param subMesh The submesh to check against
  53503. * @param useInstances Specify wether or not the material is used with instances
  53504. * @returns true if all the dependencies are ready (Textures, Effects...)
  53505. */
  53506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53507. /**
  53508. * Compute the primary color according to the chosen perceptual color.
  53509. */
  53510. private _computePrimaryColorFromPerceptualColor;
  53511. /**
  53512. * Compute the highlights and shadow colors according to their chosen levels.
  53513. */
  53514. private _computePrimaryColors;
  53515. /**
  53516. * Build the uniform buffer used in the material.
  53517. */
  53518. buildUniformLayout(): void;
  53519. /**
  53520. * Unbind the material.
  53521. */
  53522. unbind(): void;
  53523. /**
  53524. * Bind only the world matrix to the material.
  53525. * @param world The world matrix to bind.
  53526. */
  53527. bindOnlyWorldMatrix(world: Matrix): void;
  53528. /**
  53529. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53530. * @param world The world matrix to bind.
  53531. * @param subMesh The submesh to bind for.
  53532. */
  53533. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53534. /**
  53535. * Checks to see if a texture is used in the material.
  53536. * @param texture - Base texture to use.
  53537. * @returns - Boolean specifying if a texture is used in the material.
  53538. */
  53539. hasTexture(texture: BaseTexture): boolean;
  53540. /**
  53541. * Dispose the material.
  53542. * @param forceDisposeEffect Force disposal of the associated effect.
  53543. * @param forceDisposeTextures Force disposal of the associated textures.
  53544. */
  53545. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53546. /**
  53547. * Clones the material.
  53548. * @param name The cloned name.
  53549. * @returns The cloned material.
  53550. */
  53551. clone(name: string): BackgroundMaterial;
  53552. /**
  53553. * Serializes the current material to its JSON representation.
  53554. * @returns The JSON representation.
  53555. */
  53556. serialize(): any;
  53557. /**
  53558. * Gets the class name of the material
  53559. * @returns "BackgroundMaterial"
  53560. */
  53561. getClassName(): string;
  53562. /**
  53563. * Parse a JSON input to create back a background material.
  53564. * @param source The JSON data to parse
  53565. * @param scene The scene to create the parsed material in
  53566. * @param rootUrl The root url of the assets the material depends upon
  53567. * @returns the instantiated BackgroundMaterial.
  53568. */
  53569. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53570. }
  53571. }
  53572. declare module BABYLON {
  53573. /**
  53574. * Represents the different options available during the creation of
  53575. * a Environment helper.
  53576. *
  53577. * This can control the default ground, skybox and image processing setup of your scene.
  53578. */
  53579. export interface IEnvironmentHelperOptions {
  53580. /**
  53581. * Specifies whether or not to create a ground.
  53582. * True by default.
  53583. */
  53584. createGround: boolean;
  53585. /**
  53586. * Specifies the ground size.
  53587. * 15 by default.
  53588. */
  53589. groundSize: number;
  53590. /**
  53591. * The texture used on the ground for the main color.
  53592. * Comes from the BabylonJS CDN by default.
  53593. *
  53594. * Remarks: Can be either a texture or a url.
  53595. */
  53596. groundTexture: string | BaseTexture;
  53597. /**
  53598. * The color mixed in the ground texture by default.
  53599. * BabylonJS clearColor by default.
  53600. */
  53601. groundColor: Color3;
  53602. /**
  53603. * Specifies the ground opacity.
  53604. * 1 by default.
  53605. */
  53606. groundOpacity: number;
  53607. /**
  53608. * Enables the ground to receive shadows.
  53609. * True by default.
  53610. */
  53611. enableGroundShadow: boolean;
  53612. /**
  53613. * Helps preventing the shadow to be fully black on the ground.
  53614. * 0.5 by default.
  53615. */
  53616. groundShadowLevel: number;
  53617. /**
  53618. * Creates a mirror texture attach to the ground.
  53619. * false by default.
  53620. */
  53621. enableGroundMirror: boolean;
  53622. /**
  53623. * Specifies the ground mirror size ratio.
  53624. * 0.3 by default as the default kernel is 64.
  53625. */
  53626. groundMirrorSizeRatio: number;
  53627. /**
  53628. * Specifies the ground mirror blur kernel size.
  53629. * 64 by default.
  53630. */
  53631. groundMirrorBlurKernel: number;
  53632. /**
  53633. * Specifies the ground mirror visibility amount.
  53634. * 1 by default
  53635. */
  53636. groundMirrorAmount: number;
  53637. /**
  53638. * Specifies the ground mirror reflectance weight.
  53639. * This uses the standard weight of the background material to setup the fresnel effect
  53640. * of the mirror.
  53641. * 1 by default.
  53642. */
  53643. groundMirrorFresnelWeight: number;
  53644. /**
  53645. * Specifies the ground mirror Falloff distance.
  53646. * This can helps reducing the size of the reflection.
  53647. * 0 by Default.
  53648. */
  53649. groundMirrorFallOffDistance: number;
  53650. /**
  53651. * Specifies the ground mirror texture type.
  53652. * Unsigned Int by Default.
  53653. */
  53654. groundMirrorTextureType: number;
  53655. /**
  53656. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53657. * the shown objects.
  53658. */
  53659. groundYBias: number;
  53660. /**
  53661. * Specifies whether or not to create a skybox.
  53662. * True by default.
  53663. */
  53664. createSkybox: boolean;
  53665. /**
  53666. * Specifies the skybox size.
  53667. * 20 by default.
  53668. */
  53669. skyboxSize: number;
  53670. /**
  53671. * The texture used on the skybox for the main color.
  53672. * Comes from the BabylonJS CDN by default.
  53673. *
  53674. * Remarks: Can be either a texture or a url.
  53675. */
  53676. skyboxTexture: string | BaseTexture;
  53677. /**
  53678. * The color mixed in the skybox texture by default.
  53679. * BabylonJS clearColor by default.
  53680. */
  53681. skyboxColor: Color3;
  53682. /**
  53683. * The background rotation around the Y axis of the scene.
  53684. * This helps aligning the key lights of your scene with the background.
  53685. * 0 by default.
  53686. */
  53687. backgroundYRotation: number;
  53688. /**
  53689. * Compute automatically the size of the elements to best fit with the scene.
  53690. */
  53691. sizeAuto: boolean;
  53692. /**
  53693. * Default position of the rootMesh if autoSize is not true.
  53694. */
  53695. rootPosition: Vector3;
  53696. /**
  53697. * Sets up the image processing in the scene.
  53698. * true by default.
  53699. */
  53700. setupImageProcessing: boolean;
  53701. /**
  53702. * The texture used as your environment texture in the scene.
  53703. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53704. *
  53705. * Remarks: Can be either a texture or a url.
  53706. */
  53707. environmentTexture: string | BaseTexture;
  53708. /**
  53709. * The value of the exposure to apply to the scene.
  53710. * 0.6 by default if setupImageProcessing is true.
  53711. */
  53712. cameraExposure: number;
  53713. /**
  53714. * The value of the contrast to apply to the scene.
  53715. * 1.6 by default if setupImageProcessing is true.
  53716. */
  53717. cameraContrast: number;
  53718. /**
  53719. * Specifies whether or not tonemapping should be enabled in the scene.
  53720. * true by default if setupImageProcessing is true.
  53721. */
  53722. toneMappingEnabled: boolean;
  53723. }
  53724. /**
  53725. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53726. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53727. * It also helps with the default setup of your imageProcessing configuration.
  53728. */
  53729. export class EnvironmentHelper {
  53730. /**
  53731. * Default ground texture URL.
  53732. */
  53733. private static _groundTextureCDNUrl;
  53734. /**
  53735. * Default skybox texture URL.
  53736. */
  53737. private static _skyboxTextureCDNUrl;
  53738. /**
  53739. * Default environment texture URL.
  53740. */
  53741. private static _environmentTextureCDNUrl;
  53742. /**
  53743. * Creates the default options for the helper.
  53744. */
  53745. private static _getDefaultOptions;
  53746. private _rootMesh;
  53747. /**
  53748. * Gets the root mesh created by the helper.
  53749. */
  53750. get rootMesh(): Mesh;
  53751. private _skybox;
  53752. /**
  53753. * Gets the skybox created by the helper.
  53754. */
  53755. get skybox(): Nullable<Mesh>;
  53756. private _skyboxTexture;
  53757. /**
  53758. * Gets the skybox texture created by the helper.
  53759. */
  53760. get skyboxTexture(): Nullable<BaseTexture>;
  53761. private _skyboxMaterial;
  53762. /**
  53763. * Gets the skybox material created by the helper.
  53764. */
  53765. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53766. private _ground;
  53767. /**
  53768. * Gets the ground mesh created by the helper.
  53769. */
  53770. get ground(): Nullable<Mesh>;
  53771. private _groundTexture;
  53772. /**
  53773. * Gets the ground texture created by the helper.
  53774. */
  53775. get groundTexture(): Nullable<BaseTexture>;
  53776. private _groundMirror;
  53777. /**
  53778. * Gets the ground mirror created by the helper.
  53779. */
  53780. get groundMirror(): Nullable<MirrorTexture>;
  53781. /**
  53782. * Gets the ground mirror render list to helps pushing the meshes
  53783. * you wish in the ground reflection.
  53784. */
  53785. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53786. private _groundMaterial;
  53787. /**
  53788. * Gets the ground material created by the helper.
  53789. */
  53790. get groundMaterial(): Nullable<BackgroundMaterial>;
  53791. /**
  53792. * Stores the creation options.
  53793. */
  53794. private readonly _scene;
  53795. private _options;
  53796. /**
  53797. * This observable will be notified with any error during the creation of the environment,
  53798. * mainly texture creation errors.
  53799. */
  53800. onErrorObservable: Observable<{
  53801. message?: string;
  53802. exception?: any;
  53803. }>;
  53804. /**
  53805. * constructor
  53806. * @param options Defines the options we want to customize the helper
  53807. * @param scene The scene to add the material to
  53808. */
  53809. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53810. /**
  53811. * Updates the background according to the new options
  53812. * @param options
  53813. */
  53814. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53815. /**
  53816. * Sets the primary color of all the available elements.
  53817. * @param color the main color to affect to the ground and the background
  53818. */
  53819. setMainColor(color: Color3): void;
  53820. /**
  53821. * Setup the image processing according to the specified options.
  53822. */
  53823. private _setupImageProcessing;
  53824. /**
  53825. * Setup the environment texture according to the specified options.
  53826. */
  53827. private _setupEnvironmentTexture;
  53828. /**
  53829. * Setup the background according to the specified options.
  53830. */
  53831. private _setupBackground;
  53832. /**
  53833. * Get the scene sizes according to the setup.
  53834. */
  53835. private _getSceneSize;
  53836. /**
  53837. * Setup the ground according to the specified options.
  53838. */
  53839. private _setupGround;
  53840. /**
  53841. * Setup the ground material according to the specified options.
  53842. */
  53843. private _setupGroundMaterial;
  53844. /**
  53845. * Setup the ground diffuse texture according to the specified options.
  53846. */
  53847. private _setupGroundDiffuseTexture;
  53848. /**
  53849. * Setup the ground mirror texture according to the specified options.
  53850. */
  53851. private _setupGroundMirrorTexture;
  53852. /**
  53853. * Setup the ground to receive the mirror texture.
  53854. */
  53855. private _setupMirrorInGroundMaterial;
  53856. /**
  53857. * Setup the skybox according to the specified options.
  53858. */
  53859. private _setupSkybox;
  53860. /**
  53861. * Setup the skybox material according to the specified options.
  53862. */
  53863. private _setupSkyboxMaterial;
  53864. /**
  53865. * Setup the skybox reflection texture according to the specified options.
  53866. */
  53867. private _setupSkyboxReflectionTexture;
  53868. private _errorHandler;
  53869. /**
  53870. * Dispose all the elements created by the Helper.
  53871. */
  53872. dispose(): void;
  53873. }
  53874. }
  53875. declare module BABYLON {
  53876. /**
  53877. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53878. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53879. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53880. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53881. */
  53882. export class PhotoDome extends TransformNode {
  53883. /**
  53884. * Define the image as a Monoscopic panoramic 360 image.
  53885. */
  53886. static readonly MODE_MONOSCOPIC: number;
  53887. /**
  53888. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53889. */
  53890. static readonly MODE_TOPBOTTOM: number;
  53891. /**
  53892. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53893. */
  53894. static readonly MODE_SIDEBYSIDE: number;
  53895. private _useDirectMapping;
  53896. /**
  53897. * The texture being displayed on the sphere
  53898. */
  53899. protected _photoTexture: Texture;
  53900. /**
  53901. * Gets or sets the texture being displayed on the sphere
  53902. */
  53903. get photoTexture(): Texture;
  53904. set photoTexture(value: Texture);
  53905. /**
  53906. * Observable raised when an error occured while loading the 360 image
  53907. */
  53908. onLoadErrorObservable: Observable<string>;
  53909. /**
  53910. * The skybox material
  53911. */
  53912. protected _material: BackgroundMaterial;
  53913. /**
  53914. * The surface used for the skybox
  53915. */
  53916. protected _mesh: Mesh;
  53917. /**
  53918. * Gets the mesh used for the skybox.
  53919. */
  53920. get mesh(): Mesh;
  53921. /**
  53922. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53923. * Also see the options.resolution property.
  53924. */
  53925. get fovMultiplier(): number;
  53926. set fovMultiplier(value: number);
  53927. private _imageMode;
  53928. /**
  53929. * Gets or set the current video mode for the video. It can be:
  53930. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53931. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53932. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53933. */
  53934. get imageMode(): number;
  53935. set imageMode(value: number);
  53936. /**
  53937. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53938. * @param name Element's name, child elements will append suffixes for their own names.
  53939. * @param urlsOfPhoto defines the url of the photo to display
  53940. * @param options defines an object containing optional or exposed sub element properties
  53941. * @param onError defines a callback called when an error occured while loading the texture
  53942. */
  53943. constructor(name: string, urlOfPhoto: string, options: {
  53944. resolution?: number;
  53945. size?: number;
  53946. useDirectMapping?: boolean;
  53947. faceForward?: boolean;
  53948. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53949. private _onBeforeCameraRenderObserver;
  53950. private _changeImageMode;
  53951. /**
  53952. * Releases resources associated with this node.
  53953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53955. */
  53956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53957. }
  53958. }
  53959. declare module BABYLON {
  53960. /**
  53961. * Class used to host RGBD texture specific utilities
  53962. */
  53963. export class RGBDTextureTools {
  53964. /**
  53965. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53966. * @param texture the texture to expand.
  53967. */
  53968. static ExpandRGBDTexture(texture: Texture): void;
  53969. }
  53970. }
  53971. declare module BABYLON {
  53972. /**
  53973. * Class used to host texture specific utilities
  53974. */
  53975. export class BRDFTextureTools {
  53976. /**
  53977. * Prevents texture cache collision
  53978. */
  53979. private static _instanceNumber;
  53980. /**
  53981. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53982. * @param scene defines the hosting scene
  53983. * @returns the environment BRDF texture
  53984. */
  53985. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53986. private static _environmentBRDFBase64Texture;
  53987. }
  53988. }
  53989. declare module BABYLON {
  53990. /**
  53991. * @hidden
  53992. */
  53993. export interface IMaterialClearCoatDefines {
  53994. CLEARCOAT: boolean;
  53995. CLEARCOAT_DEFAULTIOR: boolean;
  53996. CLEARCOAT_TEXTURE: boolean;
  53997. CLEARCOAT_TEXTUREDIRECTUV: number;
  53998. CLEARCOAT_BUMP: boolean;
  53999. CLEARCOAT_BUMPDIRECTUV: number;
  54000. CLEARCOAT_TINT: boolean;
  54001. CLEARCOAT_TINT_TEXTURE: boolean;
  54002. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54003. /** @hidden */
  54004. _areTexturesDirty: boolean;
  54005. }
  54006. /**
  54007. * Define the code related to the clear coat parameters of the pbr material.
  54008. */
  54009. export class PBRClearCoatConfiguration {
  54010. /**
  54011. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54012. * The default fits with a polyurethane material.
  54013. */
  54014. private static readonly _DefaultIndexOfRefraction;
  54015. private _isEnabled;
  54016. /**
  54017. * Defines if the clear coat is enabled in the material.
  54018. */
  54019. isEnabled: boolean;
  54020. /**
  54021. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54022. */
  54023. intensity: number;
  54024. /**
  54025. * Defines the clear coat layer roughness.
  54026. */
  54027. roughness: number;
  54028. private _indexOfRefraction;
  54029. /**
  54030. * Defines the index of refraction of the clear coat.
  54031. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54032. * The default fits with a polyurethane material.
  54033. * Changing the default value is more performance intensive.
  54034. */
  54035. indexOfRefraction: number;
  54036. private _texture;
  54037. /**
  54038. * Stores the clear coat values in a texture.
  54039. */
  54040. texture: Nullable<BaseTexture>;
  54041. private _bumpTexture;
  54042. /**
  54043. * Define the clear coat specific bump texture.
  54044. */
  54045. bumpTexture: Nullable<BaseTexture>;
  54046. private _isTintEnabled;
  54047. /**
  54048. * Defines if the clear coat tint is enabled in the material.
  54049. */
  54050. isTintEnabled: boolean;
  54051. /**
  54052. * Defines the clear coat tint of the material.
  54053. * This is only use if tint is enabled
  54054. */
  54055. tintColor: Color3;
  54056. /**
  54057. * Defines the distance at which the tint color should be found in the
  54058. * clear coat media.
  54059. * This is only use if tint is enabled
  54060. */
  54061. tintColorAtDistance: number;
  54062. /**
  54063. * Defines the clear coat layer thickness.
  54064. * This is only use if tint is enabled
  54065. */
  54066. tintThickness: number;
  54067. private _tintTexture;
  54068. /**
  54069. * Stores the clear tint values in a texture.
  54070. * rgb is tint
  54071. * a is a thickness factor
  54072. */
  54073. tintTexture: Nullable<BaseTexture>;
  54074. /** @hidden */
  54075. private _internalMarkAllSubMeshesAsTexturesDirty;
  54076. /** @hidden */
  54077. _markAllSubMeshesAsTexturesDirty(): void;
  54078. /**
  54079. * Instantiate a new istance of clear coat configuration.
  54080. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54081. */
  54082. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54083. /**
  54084. * Gets wehter the submesh is ready to be used or not.
  54085. * @param defines the list of "defines" to update.
  54086. * @param scene defines the scene the material belongs to.
  54087. * @param engine defines the engine the material belongs to.
  54088. * @param disableBumpMap defines wether the material disables bump or not.
  54089. * @returns - boolean indicating that the submesh is ready or not.
  54090. */
  54091. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54092. /**
  54093. * Checks to see if a texture is used in the material.
  54094. * @param defines the list of "defines" to update.
  54095. * @param scene defines the scene to the material belongs to.
  54096. */
  54097. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54098. /**
  54099. * Binds the material data.
  54100. * @param uniformBuffer defines the Uniform buffer to fill in.
  54101. * @param scene defines the scene the material belongs to.
  54102. * @param engine defines the engine the material belongs to.
  54103. * @param disableBumpMap defines wether the material disables bump or not.
  54104. * @param isFrozen defines wether the material is frozen or not.
  54105. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54106. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54107. */
  54108. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54109. /**
  54110. * Checks to see if a texture is used in the material.
  54111. * @param texture - Base texture to use.
  54112. * @returns - Boolean specifying if a texture is used in the material.
  54113. */
  54114. hasTexture(texture: BaseTexture): boolean;
  54115. /**
  54116. * Returns an array of the actively used textures.
  54117. * @param activeTextures Array of BaseTextures
  54118. */
  54119. getActiveTextures(activeTextures: BaseTexture[]): void;
  54120. /**
  54121. * Returns the animatable textures.
  54122. * @param animatables Array of animatable textures.
  54123. */
  54124. getAnimatables(animatables: IAnimatable[]): void;
  54125. /**
  54126. * Disposes the resources of the material.
  54127. * @param forceDisposeTextures - Forces the disposal of all textures.
  54128. */
  54129. dispose(forceDisposeTextures?: boolean): void;
  54130. /**
  54131. * Get the current class name of the texture useful for serialization or dynamic coding.
  54132. * @returns "PBRClearCoatConfiguration"
  54133. */
  54134. getClassName(): string;
  54135. /**
  54136. * Add fallbacks to the effect fallbacks list.
  54137. * @param defines defines the Base texture to use.
  54138. * @param fallbacks defines the current fallback list.
  54139. * @param currentRank defines the current fallback rank.
  54140. * @returns the new fallback rank.
  54141. */
  54142. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54143. /**
  54144. * Add the required uniforms to the current list.
  54145. * @param uniforms defines the current uniform list.
  54146. */
  54147. static AddUniforms(uniforms: string[]): void;
  54148. /**
  54149. * Add the required samplers to the current list.
  54150. * @param samplers defines the current sampler list.
  54151. */
  54152. static AddSamplers(samplers: string[]): void;
  54153. /**
  54154. * Add the required uniforms to the current buffer.
  54155. * @param uniformBuffer defines the current uniform buffer.
  54156. */
  54157. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54158. /**
  54159. * Makes a duplicate of the current configuration into another one.
  54160. * @param clearCoatConfiguration define the config where to copy the info
  54161. */
  54162. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54163. /**
  54164. * Serializes this clear coat configuration.
  54165. * @returns - An object with the serialized config.
  54166. */
  54167. serialize(): any;
  54168. /**
  54169. * Parses a anisotropy Configuration from a serialized object.
  54170. * @param source - Serialized object.
  54171. * @param scene Defines the scene we are parsing for
  54172. * @param rootUrl Defines the rootUrl to load from
  54173. */
  54174. parse(source: any, scene: Scene, rootUrl: string): void;
  54175. }
  54176. }
  54177. declare module BABYLON {
  54178. /**
  54179. * @hidden
  54180. */
  54181. export interface IMaterialAnisotropicDefines {
  54182. ANISOTROPIC: boolean;
  54183. ANISOTROPIC_TEXTURE: boolean;
  54184. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54185. MAINUV1: boolean;
  54186. _areTexturesDirty: boolean;
  54187. _needUVs: boolean;
  54188. }
  54189. /**
  54190. * Define the code related to the anisotropic parameters of the pbr material.
  54191. */
  54192. export class PBRAnisotropicConfiguration {
  54193. private _isEnabled;
  54194. /**
  54195. * Defines if the anisotropy is enabled in the material.
  54196. */
  54197. isEnabled: boolean;
  54198. /**
  54199. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54200. */
  54201. intensity: number;
  54202. /**
  54203. * Defines if the effect is along the tangents, bitangents or in between.
  54204. * By default, the effect is "strectching" the highlights along the tangents.
  54205. */
  54206. direction: Vector2;
  54207. private _texture;
  54208. /**
  54209. * Stores the anisotropy values in a texture.
  54210. * rg is direction (like normal from -1 to 1)
  54211. * b is a intensity
  54212. */
  54213. texture: Nullable<BaseTexture>;
  54214. /** @hidden */
  54215. private _internalMarkAllSubMeshesAsTexturesDirty;
  54216. /** @hidden */
  54217. _markAllSubMeshesAsTexturesDirty(): void;
  54218. /**
  54219. * Instantiate a new istance of anisotropy configuration.
  54220. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54221. */
  54222. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54223. /**
  54224. * Specifies that the submesh is ready to be used.
  54225. * @param defines the list of "defines" to update.
  54226. * @param scene defines the scene the material belongs to.
  54227. * @returns - boolean indicating that the submesh is ready or not.
  54228. */
  54229. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54230. /**
  54231. * Checks to see if a texture is used in the material.
  54232. * @param defines the list of "defines" to update.
  54233. * @param mesh the mesh we are preparing the defines for.
  54234. * @param scene defines the scene the material belongs to.
  54235. */
  54236. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54237. /**
  54238. * Binds the material data.
  54239. * @param uniformBuffer defines the Uniform buffer to fill in.
  54240. * @param scene defines the scene the material belongs to.
  54241. * @param isFrozen defines wether the material is frozen or not.
  54242. */
  54243. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54244. /**
  54245. * Checks to see if a texture is used in the material.
  54246. * @param texture - Base texture to use.
  54247. * @returns - Boolean specifying if a texture is used in the material.
  54248. */
  54249. hasTexture(texture: BaseTexture): boolean;
  54250. /**
  54251. * Returns an array of the actively used textures.
  54252. * @param activeTextures Array of BaseTextures
  54253. */
  54254. getActiveTextures(activeTextures: BaseTexture[]): void;
  54255. /**
  54256. * Returns the animatable textures.
  54257. * @param animatables Array of animatable textures.
  54258. */
  54259. getAnimatables(animatables: IAnimatable[]): void;
  54260. /**
  54261. * Disposes the resources of the material.
  54262. * @param forceDisposeTextures - Forces the disposal of all textures.
  54263. */
  54264. dispose(forceDisposeTextures?: boolean): void;
  54265. /**
  54266. * Get the current class name of the texture useful for serialization or dynamic coding.
  54267. * @returns "PBRAnisotropicConfiguration"
  54268. */
  54269. getClassName(): string;
  54270. /**
  54271. * Add fallbacks to the effect fallbacks list.
  54272. * @param defines defines the Base texture to use.
  54273. * @param fallbacks defines the current fallback list.
  54274. * @param currentRank defines the current fallback rank.
  54275. * @returns the new fallback rank.
  54276. */
  54277. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54278. /**
  54279. * Add the required uniforms to the current list.
  54280. * @param uniforms defines the current uniform list.
  54281. */
  54282. static AddUniforms(uniforms: string[]): void;
  54283. /**
  54284. * Add the required uniforms to the current buffer.
  54285. * @param uniformBuffer defines the current uniform buffer.
  54286. */
  54287. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54288. /**
  54289. * Add the required samplers to the current list.
  54290. * @param samplers defines the current sampler list.
  54291. */
  54292. static AddSamplers(samplers: string[]): void;
  54293. /**
  54294. * Makes a duplicate of the current configuration into another one.
  54295. * @param anisotropicConfiguration define the config where to copy the info
  54296. */
  54297. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54298. /**
  54299. * Serializes this anisotropy configuration.
  54300. * @returns - An object with the serialized config.
  54301. */
  54302. serialize(): any;
  54303. /**
  54304. * Parses a anisotropy Configuration from a serialized object.
  54305. * @param source - Serialized object.
  54306. * @param scene Defines the scene we are parsing for
  54307. * @param rootUrl Defines the rootUrl to load from
  54308. */
  54309. parse(source: any, scene: Scene, rootUrl: string): void;
  54310. }
  54311. }
  54312. declare module BABYLON {
  54313. /**
  54314. * @hidden
  54315. */
  54316. export interface IMaterialBRDFDefines {
  54317. BRDF_V_HEIGHT_CORRELATED: boolean;
  54318. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54319. SPHERICAL_HARMONICS: boolean;
  54320. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54321. /** @hidden */
  54322. _areMiscDirty: boolean;
  54323. }
  54324. /**
  54325. * Define the code related to the BRDF parameters of the pbr material.
  54326. */
  54327. export class PBRBRDFConfiguration {
  54328. /**
  54329. * Default value used for the energy conservation.
  54330. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54331. */
  54332. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54333. /**
  54334. * Default value used for the Smith Visibility Height Correlated mode.
  54335. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54336. */
  54337. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54338. /**
  54339. * Default value used for the IBL diffuse part.
  54340. * This can help switching back to the polynomials mode globally which is a tiny bit
  54341. * less GPU intensive at the drawback of a lower quality.
  54342. */
  54343. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54344. /**
  54345. * Default value used for activating energy conservation for the specular workflow.
  54346. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54347. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54348. */
  54349. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54350. private _useEnergyConservation;
  54351. /**
  54352. * Defines if the material uses energy conservation.
  54353. */
  54354. useEnergyConservation: boolean;
  54355. private _useSmithVisibilityHeightCorrelated;
  54356. /**
  54357. * LEGACY Mode set to false
  54358. * Defines if the material uses height smith correlated visibility term.
  54359. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54360. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54361. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54362. * Not relying on height correlated will also disable energy conservation.
  54363. */
  54364. useSmithVisibilityHeightCorrelated: boolean;
  54365. private _useSphericalHarmonics;
  54366. /**
  54367. * LEGACY Mode set to false
  54368. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54369. * diffuse part of the IBL.
  54370. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54371. * to the ground truth.
  54372. */
  54373. useSphericalHarmonics: boolean;
  54374. private _useSpecularGlossinessInputEnergyConservation;
  54375. /**
  54376. * Defines if the material uses energy conservation, when the specular workflow is active.
  54377. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54378. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54379. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54380. */
  54381. useSpecularGlossinessInputEnergyConservation: boolean;
  54382. /** @hidden */
  54383. private _internalMarkAllSubMeshesAsMiscDirty;
  54384. /** @hidden */
  54385. _markAllSubMeshesAsMiscDirty(): void;
  54386. /**
  54387. * Instantiate a new istance of clear coat configuration.
  54388. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54389. */
  54390. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54391. /**
  54392. * Checks to see if a texture is used in the material.
  54393. * @param defines the list of "defines" to update.
  54394. */
  54395. prepareDefines(defines: IMaterialBRDFDefines): void;
  54396. /**
  54397. * Get the current class name of the texture useful for serialization or dynamic coding.
  54398. * @returns "PBRClearCoatConfiguration"
  54399. */
  54400. getClassName(): string;
  54401. /**
  54402. * Makes a duplicate of the current configuration into another one.
  54403. * @param brdfConfiguration define the config where to copy the info
  54404. */
  54405. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54406. /**
  54407. * Serializes this BRDF configuration.
  54408. * @returns - An object with the serialized config.
  54409. */
  54410. serialize(): any;
  54411. /**
  54412. * Parses a anisotropy Configuration from a serialized object.
  54413. * @param source - Serialized object.
  54414. * @param scene Defines the scene we are parsing for
  54415. * @param rootUrl Defines the rootUrl to load from
  54416. */
  54417. parse(source: any, scene: Scene, rootUrl: string): void;
  54418. }
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * @hidden
  54423. */
  54424. export interface IMaterialSheenDefines {
  54425. SHEEN: boolean;
  54426. SHEEN_TEXTURE: boolean;
  54427. SHEEN_TEXTUREDIRECTUV: number;
  54428. SHEEN_LINKWITHALBEDO: boolean;
  54429. SHEEN_ROUGHNESS: boolean;
  54430. SHEEN_ALBEDOSCALING: boolean;
  54431. /** @hidden */
  54432. _areTexturesDirty: boolean;
  54433. }
  54434. /**
  54435. * Define the code related to the Sheen parameters of the pbr material.
  54436. */
  54437. export class PBRSheenConfiguration {
  54438. private _isEnabled;
  54439. /**
  54440. * Defines if the material uses sheen.
  54441. */
  54442. isEnabled: boolean;
  54443. private _linkSheenWithAlbedo;
  54444. /**
  54445. * Defines if the sheen is linked to the sheen color.
  54446. */
  54447. linkSheenWithAlbedo: boolean;
  54448. /**
  54449. * Defines the sheen intensity.
  54450. */
  54451. intensity: number;
  54452. /**
  54453. * Defines the sheen color.
  54454. */
  54455. color: Color3;
  54456. private _texture;
  54457. /**
  54458. * Stores the sheen tint values in a texture.
  54459. * rgb is tint
  54460. * a is a intensity or roughness if roughness has been defined
  54461. */
  54462. texture: Nullable<BaseTexture>;
  54463. private _roughness;
  54464. /**
  54465. * Defines the sheen roughness.
  54466. * It is not taken into account if linkSheenWithAlbedo is true.
  54467. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54468. */
  54469. roughness: Nullable<number>;
  54470. private _albedoScaling;
  54471. /**
  54472. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54473. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54474. * making it easier to setup and tweak the effect
  54475. */
  54476. albedoScaling: boolean;
  54477. /** @hidden */
  54478. private _internalMarkAllSubMeshesAsTexturesDirty;
  54479. /** @hidden */
  54480. _markAllSubMeshesAsTexturesDirty(): void;
  54481. /**
  54482. * Instantiate a new istance of clear coat configuration.
  54483. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54484. */
  54485. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54486. /**
  54487. * Specifies that the submesh is ready to be used.
  54488. * @param defines the list of "defines" to update.
  54489. * @param scene defines the scene the material belongs to.
  54490. * @returns - boolean indicating that the submesh is ready or not.
  54491. */
  54492. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54493. /**
  54494. * Checks to see if a texture is used in the material.
  54495. * @param defines the list of "defines" to update.
  54496. * @param scene defines the scene the material belongs to.
  54497. */
  54498. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54499. /**
  54500. * Binds the material data.
  54501. * @param uniformBuffer defines the Uniform buffer to fill in.
  54502. * @param scene defines the scene the material belongs to.
  54503. * @param isFrozen defines wether the material is frozen or not.
  54504. */
  54505. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54506. /**
  54507. * Checks to see if a texture is used in the material.
  54508. * @param texture - Base texture to use.
  54509. * @returns - Boolean specifying if a texture is used in the material.
  54510. */
  54511. hasTexture(texture: BaseTexture): boolean;
  54512. /**
  54513. * Returns an array of the actively used textures.
  54514. * @param activeTextures Array of BaseTextures
  54515. */
  54516. getActiveTextures(activeTextures: BaseTexture[]): void;
  54517. /**
  54518. * Returns the animatable textures.
  54519. * @param animatables Array of animatable textures.
  54520. */
  54521. getAnimatables(animatables: IAnimatable[]): void;
  54522. /**
  54523. * Disposes the resources of the material.
  54524. * @param forceDisposeTextures - Forces the disposal of all textures.
  54525. */
  54526. dispose(forceDisposeTextures?: boolean): void;
  54527. /**
  54528. * Get the current class name of the texture useful for serialization or dynamic coding.
  54529. * @returns "PBRSheenConfiguration"
  54530. */
  54531. getClassName(): string;
  54532. /**
  54533. * Add fallbacks to the effect fallbacks list.
  54534. * @param defines defines the Base texture to use.
  54535. * @param fallbacks defines the current fallback list.
  54536. * @param currentRank defines the current fallback rank.
  54537. * @returns the new fallback rank.
  54538. */
  54539. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54540. /**
  54541. * Add the required uniforms to the current list.
  54542. * @param uniforms defines the current uniform list.
  54543. */
  54544. static AddUniforms(uniforms: string[]): void;
  54545. /**
  54546. * Add the required uniforms to the current buffer.
  54547. * @param uniformBuffer defines the current uniform buffer.
  54548. */
  54549. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54550. /**
  54551. * Add the required samplers to the current list.
  54552. * @param samplers defines the current sampler list.
  54553. */
  54554. static AddSamplers(samplers: string[]): void;
  54555. /**
  54556. * Makes a duplicate of the current configuration into another one.
  54557. * @param sheenConfiguration define the config where to copy the info
  54558. */
  54559. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54560. /**
  54561. * Serializes this BRDF configuration.
  54562. * @returns - An object with the serialized config.
  54563. */
  54564. serialize(): any;
  54565. /**
  54566. * Parses a anisotropy Configuration from a serialized object.
  54567. * @param source - Serialized object.
  54568. * @param scene Defines the scene we are parsing for
  54569. * @param rootUrl Defines the rootUrl to load from
  54570. */
  54571. parse(source: any, scene: Scene, rootUrl: string): void;
  54572. }
  54573. }
  54574. declare module BABYLON {
  54575. /**
  54576. * @hidden
  54577. */
  54578. export interface IMaterialSubSurfaceDefines {
  54579. SUBSURFACE: boolean;
  54580. SS_REFRACTION: boolean;
  54581. SS_TRANSLUCENCY: boolean;
  54582. SS_SCATTERING: boolean;
  54583. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54584. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54585. SS_REFRACTIONMAP_3D: boolean;
  54586. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54587. SS_LODINREFRACTIONALPHA: boolean;
  54588. SS_GAMMAREFRACTION: boolean;
  54589. SS_RGBDREFRACTION: boolean;
  54590. SS_LINEARSPECULARREFRACTION: boolean;
  54591. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54592. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54593. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54594. /** @hidden */
  54595. _areTexturesDirty: boolean;
  54596. }
  54597. /**
  54598. * Define the code related to the sub surface parameters of the pbr material.
  54599. */
  54600. export class PBRSubSurfaceConfiguration {
  54601. private _isRefractionEnabled;
  54602. /**
  54603. * Defines if the refraction is enabled in the material.
  54604. */
  54605. isRefractionEnabled: boolean;
  54606. private _isTranslucencyEnabled;
  54607. /**
  54608. * Defines if the translucency is enabled in the material.
  54609. */
  54610. isTranslucencyEnabled: boolean;
  54611. private _isScatteringEnabled;
  54612. /**
  54613. * Defines if the sub surface scattering is enabled in the material.
  54614. */
  54615. isScatteringEnabled: boolean;
  54616. private _scatteringDiffusionProfileIndex;
  54617. /**
  54618. * Diffusion profile for subsurface scattering.
  54619. * Useful for better scattering in the skins or foliages.
  54620. */
  54621. get scatteringDiffusionProfile(): Nullable<Color3>;
  54622. set scatteringDiffusionProfile(c: Nullable<Color3>);
  54623. /**
  54624. * Defines the refraction intensity of the material.
  54625. * The refraction when enabled replaces the Diffuse part of the material.
  54626. * The intensity helps transitionning between diffuse and refraction.
  54627. */
  54628. refractionIntensity: number;
  54629. /**
  54630. * Defines the translucency intensity of the material.
  54631. * When translucency has been enabled, this defines how much of the "translucency"
  54632. * is addded to the diffuse part of the material.
  54633. */
  54634. translucencyIntensity: number;
  54635. /**
  54636. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54637. */
  54638. useAlbedoToTintRefraction: boolean;
  54639. private _thicknessTexture;
  54640. /**
  54641. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54642. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54643. * 0 would mean minimumThickness
  54644. * 1 would mean maximumThickness
  54645. * The other channels might be use as a mask to vary the different effects intensity.
  54646. */
  54647. thicknessTexture: Nullable<BaseTexture>;
  54648. private _refractionTexture;
  54649. /**
  54650. * Defines the texture to use for refraction.
  54651. */
  54652. refractionTexture: Nullable<BaseTexture>;
  54653. private _indexOfRefraction;
  54654. /**
  54655. * Index of refraction of the material base layer.
  54656. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54657. *
  54658. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54659. *
  54660. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54661. */
  54662. indexOfRefraction: number;
  54663. private _volumeIndexOfRefraction;
  54664. /**
  54665. * Index of refraction of the material's volume.
  54666. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54667. *
  54668. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54669. * the volume will use the same IOR as the surface.
  54670. */
  54671. get volumeIndexOfRefraction(): number;
  54672. set volumeIndexOfRefraction(value: number);
  54673. private _invertRefractionY;
  54674. /**
  54675. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54676. */
  54677. invertRefractionY: boolean;
  54678. private _linkRefractionWithTransparency;
  54679. /**
  54680. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54681. * Materials half opaque for instance using refraction could benefit from this control.
  54682. */
  54683. linkRefractionWithTransparency: boolean;
  54684. /**
  54685. * Defines the minimum thickness stored in the thickness map.
  54686. * If no thickness map is defined, this value will be used to simulate thickness.
  54687. */
  54688. minimumThickness: number;
  54689. /**
  54690. * Defines the maximum thickness stored in the thickness map.
  54691. */
  54692. maximumThickness: number;
  54693. /**
  54694. * Defines the volume tint of the material.
  54695. * This is used for both translucency and scattering.
  54696. */
  54697. tintColor: Color3;
  54698. /**
  54699. * Defines the distance at which the tint color should be found in the media.
  54700. * This is used for refraction only.
  54701. */
  54702. tintColorAtDistance: number;
  54703. /**
  54704. * Defines how far each channel transmit through the media.
  54705. * It is defined as a color to simplify it selection.
  54706. */
  54707. diffusionDistance: Color3;
  54708. private _useMaskFromThicknessTexture;
  54709. /**
  54710. * Stores the intensity of the different subsurface effects in the thickness texture.
  54711. * * the green channel is the translucency intensity.
  54712. * * the blue channel is the scattering intensity.
  54713. * * the alpha channel is the refraction intensity.
  54714. */
  54715. useMaskFromThicknessTexture: boolean;
  54716. private _scene;
  54717. /** @hidden */
  54718. private _internalMarkAllSubMeshesAsTexturesDirty;
  54719. private _internalMarkScenePrePassDirty;
  54720. /** @hidden */
  54721. _markAllSubMeshesAsTexturesDirty(): void;
  54722. /** @hidden */
  54723. _markScenePrePassDirty(): void;
  54724. /**
  54725. * Instantiate a new istance of sub surface configuration.
  54726. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54727. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  54728. * @param scene The scene
  54729. */
  54730. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  54731. /**
  54732. * Gets wehter the submesh is ready to be used or not.
  54733. * @param defines the list of "defines" to update.
  54734. * @param scene defines the scene the material belongs to.
  54735. * @returns - boolean indicating that the submesh is ready or not.
  54736. */
  54737. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54738. /**
  54739. * Checks to see if a texture is used in the material.
  54740. * @param defines the list of "defines" to update.
  54741. * @param scene defines the scene to the material belongs to.
  54742. */
  54743. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54744. /**
  54745. * Binds the material data.
  54746. * @param uniformBuffer defines the Uniform buffer to fill in.
  54747. * @param scene defines the scene the material belongs to.
  54748. * @param engine defines the engine the material belongs to.
  54749. * @param isFrozen defines whether the material is frozen or not.
  54750. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54751. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54752. */
  54753. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54754. /**
  54755. * Unbinds the material from the mesh.
  54756. * @param activeEffect defines the effect that should be unbound from.
  54757. * @returns true if unbound, otherwise false
  54758. */
  54759. unbind(activeEffect: Effect): boolean;
  54760. /**
  54761. * Returns the texture used for refraction or null if none is used.
  54762. * @param scene defines the scene the material belongs to.
  54763. * @returns - Refraction texture if present. If no refraction texture and refraction
  54764. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54765. */
  54766. private _getRefractionTexture;
  54767. /**
  54768. * Returns true if alpha blending should be disabled.
  54769. */
  54770. get disableAlphaBlending(): boolean;
  54771. /**
  54772. * Fills the list of render target textures.
  54773. * @param renderTargets the list of render targets to update
  54774. */
  54775. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54776. /**
  54777. * Checks to see if a texture is used in the material.
  54778. * @param texture - Base texture to use.
  54779. * @returns - Boolean specifying if a texture is used in the material.
  54780. */
  54781. hasTexture(texture: BaseTexture): boolean;
  54782. /**
  54783. * Gets a boolean indicating that current material needs to register RTT
  54784. * @returns true if this uses a render target otherwise false.
  54785. */
  54786. hasRenderTargetTextures(): boolean;
  54787. /**
  54788. * Returns an array of the actively used textures.
  54789. * @param activeTextures Array of BaseTextures
  54790. */
  54791. getActiveTextures(activeTextures: BaseTexture[]): void;
  54792. /**
  54793. * Returns the animatable textures.
  54794. * @param animatables Array of animatable textures.
  54795. */
  54796. getAnimatables(animatables: IAnimatable[]): void;
  54797. /**
  54798. * Disposes the resources of the material.
  54799. * @param forceDisposeTextures - Forces the disposal of all textures.
  54800. */
  54801. dispose(forceDisposeTextures?: boolean): void;
  54802. /**
  54803. * Get the current class name of the texture useful for serialization or dynamic coding.
  54804. * @returns "PBRSubSurfaceConfiguration"
  54805. */
  54806. getClassName(): string;
  54807. /**
  54808. * Add fallbacks to the effect fallbacks list.
  54809. * @param defines defines the Base texture to use.
  54810. * @param fallbacks defines the current fallback list.
  54811. * @param currentRank defines the current fallback rank.
  54812. * @returns the new fallback rank.
  54813. */
  54814. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54815. /**
  54816. * Add the required uniforms to the current list.
  54817. * @param uniforms defines the current uniform list.
  54818. */
  54819. static AddUniforms(uniforms: string[]): void;
  54820. /**
  54821. * Add the required samplers to the current list.
  54822. * @param samplers defines the current sampler list.
  54823. */
  54824. static AddSamplers(samplers: string[]): void;
  54825. /**
  54826. * Add the required uniforms to the current buffer.
  54827. * @param uniformBuffer defines the current uniform buffer.
  54828. */
  54829. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54830. /**
  54831. * Makes a duplicate of the current configuration into another one.
  54832. * @param configuration define the config where to copy the info
  54833. */
  54834. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54835. /**
  54836. * Serializes this Sub Surface configuration.
  54837. * @returns - An object with the serialized config.
  54838. */
  54839. serialize(): any;
  54840. /**
  54841. * Parses a anisotropy Configuration from a serialized object.
  54842. * @param source - Serialized object.
  54843. * @param scene Defines the scene we are parsing for
  54844. * @param rootUrl Defines the rootUrl to load from
  54845. */
  54846. parse(source: any, scene: Scene, rootUrl: string): void;
  54847. }
  54848. }
  54849. declare module BABYLON {
  54850. /** @hidden */
  54851. export var prePassDeclaration: {
  54852. name: string;
  54853. shader: string;
  54854. };
  54855. }
  54856. declare module BABYLON {
  54857. /** @hidden */
  54858. export var pbrFragmentDeclaration: {
  54859. name: string;
  54860. shader: string;
  54861. };
  54862. }
  54863. declare module BABYLON {
  54864. /** @hidden */
  54865. export var pbrUboDeclaration: {
  54866. name: string;
  54867. shader: string;
  54868. };
  54869. }
  54870. declare module BABYLON {
  54871. /** @hidden */
  54872. export var pbrFragmentExtraDeclaration: {
  54873. name: string;
  54874. shader: string;
  54875. };
  54876. }
  54877. declare module BABYLON {
  54878. /** @hidden */
  54879. export var pbrFragmentSamplersDeclaration: {
  54880. name: string;
  54881. shader: string;
  54882. };
  54883. }
  54884. declare module BABYLON {
  54885. /** @hidden */
  54886. export var subSurfaceScatteringFunctions: {
  54887. name: string;
  54888. shader: string;
  54889. };
  54890. }
  54891. declare module BABYLON {
  54892. /** @hidden */
  54893. export var importanceSampling: {
  54894. name: string;
  54895. shader: string;
  54896. };
  54897. }
  54898. declare module BABYLON {
  54899. /** @hidden */
  54900. export var pbrHelperFunctions: {
  54901. name: string;
  54902. shader: string;
  54903. };
  54904. }
  54905. declare module BABYLON {
  54906. /** @hidden */
  54907. export var harmonicsFunctions: {
  54908. name: string;
  54909. shader: string;
  54910. };
  54911. }
  54912. declare module BABYLON {
  54913. /** @hidden */
  54914. export var pbrDirectLightingSetupFunctions: {
  54915. name: string;
  54916. shader: string;
  54917. };
  54918. }
  54919. declare module BABYLON {
  54920. /** @hidden */
  54921. export var pbrDirectLightingFalloffFunctions: {
  54922. name: string;
  54923. shader: string;
  54924. };
  54925. }
  54926. declare module BABYLON {
  54927. /** @hidden */
  54928. export var pbrBRDFFunctions: {
  54929. name: string;
  54930. shader: string;
  54931. };
  54932. }
  54933. declare module BABYLON {
  54934. /** @hidden */
  54935. export var hdrFilteringFunctions: {
  54936. name: string;
  54937. shader: string;
  54938. };
  54939. }
  54940. declare module BABYLON {
  54941. /** @hidden */
  54942. export var pbrDirectLightingFunctions: {
  54943. name: string;
  54944. shader: string;
  54945. };
  54946. }
  54947. declare module BABYLON {
  54948. /** @hidden */
  54949. export var pbrIBLFunctions: {
  54950. name: string;
  54951. shader: string;
  54952. };
  54953. }
  54954. declare module BABYLON {
  54955. /** @hidden */
  54956. export var pbrBlockAlbedoOpacity: {
  54957. name: string;
  54958. shader: string;
  54959. };
  54960. }
  54961. declare module BABYLON {
  54962. /** @hidden */
  54963. export var pbrBlockReflectivity: {
  54964. name: string;
  54965. shader: string;
  54966. };
  54967. }
  54968. declare module BABYLON {
  54969. /** @hidden */
  54970. export var pbrBlockAmbientOcclusion: {
  54971. name: string;
  54972. shader: string;
  54973. };
  54974. }
  54975. declare module BABYLON {
  54976. /** @hidden */
  54977. export var pbrBlockAlphaFresnel: {
  54978. name: string;
  54979. shader: string;
  54980. };
  54981. }
  54982. declare module BABYLON {
  54983. /** @hidden */
  54984. export var pbrBlockAnisotropic: {
  54985. name: string;
  54986. shader: string;
  54987. };
  54988. }
  54989. declare module BABYLON {
  54990. /** @hidden */
  54991. export var pbrBlockReflection: {
  54992. name: string;
  54993. shader: string;
  54994. };
  54995. }
  54996. declare module BABYLON {
  54997. /** @hidden */
  54998. export var pbrBlockSheen: {
  54999. name: string;
  55000. shader: string;
  55001. };
  55002. }
  55003. declare module BABYLON {
  55004. /** @hidden */
  55005. export var pbrBlockClearcoat: {
  55006. name: string;
  55007. shader: string;
  55008. };
  55009. }
  55010. declare module BABYLON {
  55011. /** @hidden */
  55012. export var pbrBlockSubSurface: {
  55013. name: string;
  55014. shader: string;
  55015. };
  55016. }
  55017. declare module BABYLON {
  55018. /** @hidden */
  55019. export var pbrBlockNormalGeometric: {
  55020. name: string;
  55021. shader: string;
  55022. };
  55023. }
  55024. declare module BABYLON {
  55025. /** @hidden */
  55026. export var pbrBlockNormalFinal: {
  55027. name: string;
  55028. shader: string;
  55029. };
  55030. }
  55031. declare module BABYLON {
  55032. /** @hidden */
  55033. export var pbrBlockGeometryInfo: {
  55034. name: string;
  55035. shader: string;
  55036. };
  55037. }
  55038. declare module BABYLON {
  55039. /** @hidden */
  55040. export var pbrBlockReflectance0: {
  55041. name: string;
  55042. shader: string;
  55043. };
  55044. }
  55045. declare module BABYLON {
  55046. /** @hidden */
  55047. export var pbrBlockReflectance: {
  55048. name: string;
  55049. shader: string;
  55050. };
  55051. }
  55052. declare module BABYLON {
  55053. /** @hidden */
  55054. export var pbrBlockDirectLighting: {
  55055. name: string;
  55056. shader: string;
  55057. };
  55058. }
  55059. declare module BABYLON {
  55060. /** @hidden */
  55061. export var pbrBlockFinalLitComponents: {
  55062. name: string;
  55063. shader: string;
  55064. };
  55065. }
  55066. declare module BABYLON {
  55067. /** @hidden */
  55068. export var pbrBlockFinalUnlitComponents: {
  55069. name: string;
  55070. shader: string;
  55071. };
  55072. }
  55073. declare module BABYLON {
  55074. /** @hidden */
  55075. export var pbrBlockFinalColorComposition: {
  55076. name: string;
  55077. shader: string;
  55078. };
  55079. }
  55080. declare module BABYLON {
  55081. /** @hidden */
  55082. export var pbrBlockImageProcessing: {
  55083. name: string;
  55084. shader: string;
  55085. };
  55086. }
  55087. declare module BABYLON {
  55088. /** @hidden */
  55089. export var pbrDebug: {
  55090. name: string;
  55091. shader: string;
  55092. };
  55093. }
  55094. declare module BABYLON {
  55095. /** @hidden */
  55096. export var pbrPixelShader: {
  55097. name: string;
  55098. shader: string;
  55099. };
  55100. }
  55101. declare module BABYLON {
  55102. /** @hidden */
  55103. export var pbrVertexDeclaration: {
  55104. name: string;
  55105. shader: string;
  55106. };
  55107. }
  55108. declare module BABYLON {
  55109. /** @hidden */
  55110. export var pbrVertexShader: {
  55111. name: string;
  55112. shader: string;
  55113. };
  55114. }
  55115. declare module BABYLON {
  55116. /**
  55117. * Manages the defines for the PBR Material.
  55118. * @hidden
  55119. */
  55120. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55121. PBR: boolean;
  55122. NUM_SAMPLES: string;
  55123. REALTIME_FILTERING: boolean;
  55124. MAINUV1: boolean;
  55125. MAINUV2: boolean;
  55126. UV1: boolean;
  55127. UV2: boolean;
  55128. ALBEDO: boolean;
  55129. GAMMAALBEDO: boolean;
  55130. ALBEDODIRECTUV: number;
  55131. VERTEXCOLOR: boolean;
  55132. DETAIL: boolean;
  55133. DETAILDIRECTUV: number;
  55134. DETAIL_NORMALBLENDMETHOD: number;
  55135. AMBIENT: boolean;
  55136. AMBIENTDIRECTUV: number;
  55137. AMBIENTINGRAYSCALE: boolean;
  55138. OPACITY: boolean;
  55139. VERTEXALPHA: boolean;
  55140. OPACITYDIRECTUV: number;
  55141. OPACITYRGB: boolean;
  55142. ALPHATEST: boolean;
  55143. DEPTHPREPASS: boolean;
  55144. ALPHABLEND: boolean;
  55145. ALPHAFROMALBEDO: boolean;
  55146. ALPHATESTVALUE: string;
  55147. SPECULAROVERALPHA: boolean;
  55148. RADIANCEOVERALPHA: boolean;
  55149. ALPHAFRESNEL: boolean;
  55150. LINEARALPHAFRESNEL: boolean;
  55151. PREMULTIPLYALPHA: boolean;
  55152. EMISSIVE: boolean;
  55153. EMISSIVEDIRECTUV: number;
  55154. REFLECTIVITY: boolean;
  55155. REFLECTIVITYDIRECTUV: number;
  55156. SPECULARTERM: boolean;
  55157. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55158. MICROSURFACEAUTOMATIC: boolean;
  55159. LODBASEDMICROSFURACE: boolean;
  55160. MICROSURFACEMAP: boolean;
  55161. MICROSURFACEMAPDIRECTUV: number;
  55162. METALLICWORKFLOW: boolean;
  55163. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55164. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55165. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55166. AOSTOREINMETALMAPRED: boolean;
  55167. METALLIC_REFLECTANCE: boolean;
  55168. METALLIC_REFLECTANCEDIRECTUV: number;
  55169. ENVIRONMENTBRDF: boolean;
  55170. ENVIRONMENTBRDF_RGBD: boolean;
  55171. NORMAL: boolean;
  55172. TANGENT: boolean;
  55173. BUMP: boolean;
  55174. BUMPDIRECTUV: number;
  55175. OBJECTSPACE_NORMALMAP: boolean;
  55176. PARALLAX: boolean;
  55177. PARALLAXOCCLUSION: boolean;
  55178. NORMALXYSCALE: boolean;
  55179. LIGHTMAP: boolean;
  55180. LIGHTMAPDIRECTUV: number;
  55181. USELIGHTMAPASSHADOWMAP: boolean;
  55182. GAMMALIGHTMAP: boolean;
  55183. RGBDLIGHTMAP: boolean;
  55184. REFLECTION: boolean;
  55185. REFLECTIONMAP_3D: boolean;
  55186. REFLECTIONMAP_SPHERICAL: boolean;
  55187. REFLECTIONMAP_PLANAR: boolean;
  55188. REFLECTIONMAP_CUBIC: boolean;
  55189. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55190. REFLECTIONMAP_PROJECTION: boolean;
  55191. REFLECTIONMAP_SKYBOX: boolean;
  55192. REFLECTIONMAP_EXPLICIT: boolean;
  55193. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55194. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55195. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55196. INVERTCUBICMAP: boolean;
  55197. USESPHERICALFROMREFLECTIONMAP: boolean;
  55198. USEIRRADIANCEMAP: boolean;
  55199. SPHERICAL_HARMONICS: boolean;
  55200. USESPHERICALINVERTEX: boolean;
  55201. REFLECTIONMAP_OPPOSITEZ: boolean;
  55202. LODINREFLECTIONALPHA: boolean;
  55203. GAMMAREFLECTION: boolean;
  55204. RGBDREFLECTION: boolean;
  55205. LINEARSPECULARREFLECTION: boolean;
  55206. RADIANCEOCCLUSION: boolean;
  55207. HORIZONOCCLUSION: boolean;
  55208. INSTANCES: boolean;
  55209. THIN_INSTANCES: boolean;
  55210. PREPASS: boolean;
  55211. SCENE_MRT_COUNT: number;
  55212. NUM_BONE_INFLUENCERS: number;
  55213. BonesPerMesh: number;
  55214. BONETEXTURE: boolean;
  55215. NONUNIFORMSCALING: boolean;
  55216. MORPHTARGETS: boolean;
  55217. MORPHTARGETS_NORMAL: boolean;
  55218. MORPHTARGETS_TANGENT: boolean;
  55219. MORPHTARGETS_UV: boolean;
  55220. NUM_MORPH_INFLUENCERS: number;
  55221. IMAGEPROCESSING: boolean;
  55222. VIGNETTE: boolean;
  55223. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55224. VIGNETTEBLENDMODEOPAQUE: boolean;
  55225. TONEMAPPING: boolean;
  55226. TONEMAPPING_ACES: boolean;
  55227. CONTRAST: boolean;
  55228. COLORCURVES: boolean;
  55229. COLORGRADING: boolean;
  55230. COLORGRADING3D: boolean;
  55231. SAMPLER3DGREENDEPTH: boolean;
  55232. SAMPLER3DBGRMAP: boolean;
  55233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55234. EXPOSURE: boolean;
  55235. MULTIVIEW: boolean;
  55236. USEPHYSICALLIGHTFALLOFF: boolean;
  55237. USEGLTFLIGHTFALLOFF: boolean;
  55238. TWOSIDEDLIGHTING: boolean;
  55239. SHADOWFLOAT: boolean;
  55240. CLIPPLANE: boolean;
  55241. CLIPPLANE2: boolean;
  55242. CLIPPLANE3: boolean;
  55243. CLIPPLANE4: boolean;
  55244. CLIPPLANE5: boolean;
  55245. CLIPPLANE6: boolean;
  55246. POINTSIZE: boolean;
  55247. FOG: boolean;
  55248. LOGARITHMICDEPTH: boolean;
  55249. FORCENORMALFORWARD: boolean;
  55250. SPECULARAA: boolean;
  55251. CLEARCOAT: boolean;
  55252. CLEARCOAT_DEFAULTIOR: boolean;
  55253. CLEARCOAT_TEXTURE: boolean;
  55254. CLEARCOAT_TEXTUREDIRECTUV: number;
  55255. CLEARCOAT_BUMP: boolean;
  55256. CLEARCOAT_BUMPDIRECTUV: number;
  55257. CLEARCOAT_TINT: boolean;
  55258. CLEARCOAT_TINT_TEXTURE: boolean;
  55259. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55260. ANISOTROPIC: boolean;
  55261. ANISOTROPIC_TEXTURE: boolean;
  55262. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55263. BRDF_V_HEIGHT_CORRELATED: boolean;
  55264. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55265. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55266. SHEEN: boolean;
  55267. SHEEN_TEXTURE: boolean;
  55268. SHEEN_TEXTUREDIRECTUV: number;
  55269. SHEEN_LINKWITHALBEDO: boolean;
  55270. SHEEN_ROUGHNESS: boolean;
  55271. SHEEN_ALBEDOSCALING: boolean;
  55272. SUBSURFACE: boolean;
  55273. SS_REFRACTION: boolean;
  55274. SS_TRANSLUCENCY: boolean;
  55275. SS_SCATTERING: boolean;
  55276. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55277. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55278. SS_REFRACTIONMAP_3D: boolean;
  55279. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55280. SS_LODINREFRACTIONALPHA: boolean;
  55281. SS_GAMMAREFRACTION: boolean;
  55282. SS_RGBDREFRACTION: boolean;
  55283. SS_LINEARSPECULARREFRACTION: boolean;
  55284. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55285. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55286. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55287. UNLIT: boolean;
  55288. DEBUGMODE: number;
  55289. /**
  55290. * Initializes the PBR Material defines.
  55291. */
  55292. constructor();
  55293. /**
  55294. * Resets the PBR Material defines.
  55295. */
  55296. reset(): void;
  55297. }
  55298. /**
  55299. * The Physically based material base class of BJS.
  55300. *
  55301. * This offers the main features of a standard PBR material.
  55302. * For more information, please refer to the documentation :
  55303. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55304. */
  55305. export abstract class PBRBaseMaterial extends PushMaterial {
  55306. /**
  55307. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55308. */
  55309. static readonly PBRMATERIAL_OPAQUE: number;
  55310. /**
  55311. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55312. */
  55313. static readonly PBRMATERIAL_ALPHATEST: number;
  55314. /**
  55315. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55316. */
  55317. static readonly PBRMATERIAL_ALPHABLEND: number;
  55318. /**
  55319. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55320. * They are also discarded below the alpha cutoff threshold to improve performances.
  55321. */
  55322. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55323. /**
  55324. * Defines the default value of how much AO map is occluding the analytical lights
  55325. * (point spot...).
  55326. */
  55327. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55328. /**
  55329. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55330. */
  55331. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55332. /**
  55333. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55334. * to enhance interoperability with other engines.
  55335. */
  55336. static readonly LIGHTFALLOFF_GLTF: number;
  55337. /**
  55338. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55339. * to enhance interoperability with other materials.
  55340. */
  55341. static readonly LIGHTFALLOFF_STANDARD: number;
  55342. /**
  55343. * Intensity of the direct lights e.g. the four lights available in your scene.
  55344. * This impacts both the direct diffuse and specular highlights.
  55345. */
  55346. protected _directIntensity: number;
  55347. /**
  55348. * Intensity of the emissive part of the material.
  55349. * This helps controlling the emissive effect without modifying the emissive color.
  55350. */
  55351. protected _emissiveIntensity: number;
  55352. /**
  55353. * Intensity of the environment e.g. how much the environment will light the object
  55354. * either through harmonics for rough material or through the refelction for shiny ones.
  55355. */
  55356. protected _environmentIntensity: number;
  55357. /**
  55358. * This is a special control allowing the reduction of the specular highlights coming from the
  55359. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55360. */
  55361. protected _specularIntensity: number;
  55362. /**
  55363. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55364. */
  55365. private _lightingInfos;
  55366. /**
  55367. * Debug Control allowing disabling the bump map on this material.
  55368. */
  55369. protected _disableBumpMap: boolean;
  55370. /**
  55371. * AKA Diffuse Texture in standard nomenclature.
  55372. */
  55373. protected _albedoTexture: Nullable<BaseTexture>;
  55374. /**
  55375. * AKA Occlusion Texture in other nomenclature.
  55376. */
  55377. protected _ambientTexture: Nullable<BaseTexture>;
  55378. /**
  55379. * AKA Occlusion Texture Intensity in other nomenclature.
  55380. */
  55381. protected _ambientTextureStrength: number;
  55382. /**
  55383. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55384. * 1 means it completely occludes it
  55385. * 0 mean it has no impact
  55386. */
  55387. protected _ambientTextureImpactOnAnalyticalLights: number;
  55388. /**
  55389. * Stores the alpha values in a texture.
  55390. */
  55391. protected _opacityTexture: Nullable<BaseTexture>;
  55392. /**
  55393. * Stores the reflection values in a texture.
  55394. */
  55395. protected _reflectionTexture: Nullable<BaseTexture>;
  55396. /**
  55397. * Stores the emissive values in a texture.
  55398. */
  55399. protected _emissiveTexture: Nullable<BaseTexture>;
  55400. /**
  55401. * AKA Specular texture in other nomenclature.
  55402. */
  55403. protected _reflectivityTexture: Nullable<BaseTexture>;
  55404. /**
  55405. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55406. */
  55407. protected _metallicTexture: Nullable<BaseTexture>;
  55408. /**
  55409. * Specifies the metallic scalar of the metallic/roughness workflow.
  55410. * Can also be used to scale the metalness values of the metallic texture.
  55411. */
  55412. protected _metallic: Nullable<number>;
  55413. /**
  55414. * Specifies the roughness scalar of the metallic/roughness workflow.
  55415. * Can also be used to scale the roughness values of the metallic texture.
  55416. */
  55417. protected _roughness: Nullable<number>;
  55418. /**
  55419. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55420. * By default the indexOfrefraction is used to compute F0;
  55421. *
  55422. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55423. *
  55424. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55425. * F90 = metallicReflectanceColor;
  55426. */
  55427. protected _metallicF0Factor: number;
  55428. /**
  55429. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55430. * By default the F90 is always 1;
  55431. *
  55432. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55433. *
  55434. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55435. * F90 = metallicReflectanceColor;
  55436. */
  55437. protected _metallicReflectanceColor: Color3;
  55438. /**
  55439. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55440. * This is multiply against the scalar values defined in the material.
  55441. */
  55442. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55443. /**
  55444. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55445. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55446. */
  55447. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55448. /**
  55449. * Stores surface normal data used to displace a mesh in a texture.
  55450. */
  55451. protected _bumpTexture: Nullable<BaseTexture>;
  55452. /**
  55453. * Stores the pre-calculated light information of a mesh in a texture.
  55454. */
  55455. protected _lightmapTexture: Nullable<BaseTexture>;
  55456. /**
  55457. * The color of a material in ambient lighting.
  55458. */
  55459. protected _ambientColor: Color3;
  55460. /**
  55461. * AKA Diffuse Color in other nomenclature.
  55462. */
  55463. protected _albedoColor: Color3;
  55464. /**
  55465. * AKA Specular Color in other nomenclature.
  55466. */
  55467. protected _reflectivityColor: Color3;
  55468. /**
  55469. * The color applied when light is reflected from a material.
  55470. */
  55471. protected _reflectionColor: Color3;
  55472. /**
  55473. * The color applied when light is emitted from a material.
  55474. */
  55475. protected _emissiveColor: Color3;
  55476. /**
  55477. * AKA Glossiness in other nomenclature.
  55478. */
  55479. protected _microSurface: number;
  55480. /**
  55481. * Specifies that the material will use the light map as a show map.
  55482. */
  55483. protected _useLightmapAsShadowmap: boolean;
  55484. /**
  55485. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55486. * makes the reflect vector face the model (under horizon).
  55487. */
  55488. protected _useHorizonOcclusion: boolean;
  55489. /**
  55490. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55491. * too much the area relying on ambient texture to define their ambient occlusion.
  55492. */
  55493. protected _useRadianceOcclusion: boolean;
  55494. /**
  55495. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55496. */
  55497. protected _useAlphaFromAlbedoTexture: boolean;
  55498. /**
  55499. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55500. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55501. */
  55502. protected _useSpecularOverAlpha: boolean;
  55503. /**
  55504. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55505. */
  55506. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55507. /**
  55508. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55509. */
  55510. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55511. /**
  55512. * Specifies if the metallic texture contains the roughness information in its green channel.
  55513. */
  55514. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55515. /**
  55516. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55517. */
  55518. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55519. /**
  55520. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55521. */
  55522. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55523. /**
  55524. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55525. */
  55526. protected _useAmbientInGrayScale: boolean;
  55527. /**
  55528. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55529. * The material will try to infer what glossiness each pixel should be.
  55530. */
  55531. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55532. /**
  55533. * Defines the falloff type used in this material.
  55534. * It by default is Physical.
  55535. */
  55536. protected _lightFalloff: number;
  55537. /**
  55538. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55539. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55540. */
  55541. protected _useRadianceOverAlpha: boolean;
  55542. /**
  55543. * Allows using an object space normal map (instead of tangent space).
  55544. */
  55545. protected _useObjectSpaceNormalMap: boolean;
  55546. /**
  55547. * Allows using the bump map in parallax mode.
  55548. */
  55549. protected _useParallax: boolean;
  55550. /**
  55551. * Allows using the bump map in parallax occlusion mode.
  55552. */
  55553. protected _useParallaxOcclusion: boolean;
  55554. /**
  55555. * Controls the scale bias of the parallax mode.
  55556. */
  55557. protected _parallaxScaleBias: number;
  55558. /**
  55559. * If sets to true, disables all the lights affecting the material.
  55560. */
  55561. protected _disableLighting: boolean;
  55562. /**
  55563. * Number of Simultaneous lights allowed on the material.
  55564. */
  55565. protected _maxSimultaneousLights: number;
  55566. /**
  55567. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55568. */
  55569. protected _invertNormalMapX: boolean;
  55570. /**
  55571. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55572. */
  55573. protected _invertNormalMapY: boolean;
  55574. /**
  55575. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55576. */
  55577. protected _twoSidedLighting: boolean;
  55578. /**
  55579. * Defines the alpha limits in alpha test mode.
  55580. */
  55581. protected _alphaCutOff: number;
  55582. /**
  55583. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55584. */
  55585. protected _forceAlphaTest: boolean;
  55586. /**
  55587. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55588. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55589. */
  55590. protected _useAlphaFresnel: boolean;
  55591. /**
  55592. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55593. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55594. */
  55595. protected _useLinearAlphaFresnel: boolean;
  55596. /**
  55597. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55598. * from cos thetav and roughness:
  55599. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55600. */
  55601. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55602. /**
  55603. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55604. */
  55605. protected _forceIrradianceInFragment: boolean;
  55606. private _realTimeFiltering;
  55607. /**
  55608. * Enables realtime filtering on the texture.
  55609. */
  55610. get realTimeFiltering(): boolean;
  55611. set realTimeFiltering(b: boolean);
  55612. private _realTimeFilteringQuality;
  55613. /**
  55614. * Quality switch for realtime filtering
  55615. */
  55616. get realTimeFilteringQuality(): number;
  55617. set realTimeFilteringQuality(n: number);
  55618. /**
  55619. * Should this material render to several textures at once
  55620. */
  55621. get shouldRenderToMRT(): boolean;
  55622. /**
  55623. * Force normal to face away from face.
  55624. */
  55625. protected _forceNormalForward: boolean;
  55626. /**
  55627. * Enables specular anti aliasing in the PBR shader.
  55628. * It will both interacts on the Geometry for analytical and IBL lighting.
  55629. * It also prefilter the roughness map based on the bump values.
  55630. */
  55631. protected _enableSpecularAntiAliasing: boolean;
  55632. /**
  55633. * Default configuration related to image processing available in the PBR Material.
  55634. */
  55635. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55636. /**
  55637. * Keep track of the image processing observer to allow dispose and replace.
  55638. */
  55639. private _imageProcessingObserver;
  55640. /**
  55641. * Attaches a new image processing configuration to the PBR Material.
  55642. * @param configuration
  55643. */
  55644. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55645. /**
  55646. * Stores the available render targets.
  55647. */
  55648. private _renderTargets;
  55649. /**
  55650. * Sets the global ambient color for the material used in lighting calculations.
  55651. */
  55652. private _globalAmbientColor;
  55653. /**
  55654. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55655. */
  55656. private _useLogarithmicDepth;
  55657. /**
  55658. * If set to true, no lighting calculations will be applied.
  55659. */
  55660. private _unlit;
  55661. private _debugMode;
  55662. /**
  55663. * @hidden
  55664. * This is reserved for the inspector.
  55665. * Defines the material debug mode.
  55666. * It helps seeing only some components of the material while troubleshooting.
  55667. */
  55668. debugMode: number;
  55669. /**
  55670. * @hidden
  55671. * This is reserved for the inspector.
  55672. * Specify from where on screen the debug mode should start.
  55673. * The value goes from -1 (full screen) to 1 (not visible)
  55674. * It helps with side by side comparison against the final render
  55675. * This defaults to -1
  55676. */
  55677. private debugLimit;
  55678. /**
  55679. * @hidden
  55680. * This is reserved for the inspector.
  55681. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55682. * You can use the factor to better multiply the final value.
  55683. */
  55684. private debugFactor;
  55685. /**
  55686. * Defines the clear coat layer parameters for the material.
  55687. */
  55688. readonly clearCoat: PBRClearCoatConfiguration;
  55689. /**
  55690. * Defines the anisotropic parameters for the material.
  55691. */
  55692. readonly anisotropy: PBRAnisotropicConfiguration;
  55693. /**
  55694. * Defines the BRDF parameters for the material.
  55695. */
  55696. readonly brdf: PBRBRDFConfiguration;
  55697. /**
  55698. * Defines the Sheen parameters for the material.
  55699. */
  55700. readonly sheen: PBRSheenConfiguration;
  55701. /**
  55702. * Defines the SubSurface parameters for the material.
  55703. */
  55704. readonly subSurface: PBRSubSurfaceConfiguration;
  55705. /**
  55706. * Defines the detail map parameters for the material.
  55707. */
  55708. readonly detailMap: DetailMapConfiguration;
  55709. protected _rebuildInParallel: boolean;
  55710. /**
  55711. * Instantiates a new PBRMaterial instance.
  55712. *
  55713. * @param name The material name
  55714. * @param scene The scene the material will be use in.
  55715. */
  55716. constructor(name: string, scene: Scene);
  55717. /**
  55718. * Gets a boolean indicating that current material needs to register RTT
  55719. */
  55720. get hasRenderTargetTextures(): boolean;
  55721. /**
  55722. * Gets the name of the material class.
  55723. */
  55724. getClassName(): string;
  55725. /**
  55726. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55727. */
  55728. get useLogarithmicDepth(): boolean;
  55729. /**
  55730. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55731. */
  55732. set useLogarithmicDepth(value: boolean);
  55733. /**
  55734. * Returns true if alpha blending should be disabled.
  55735. */
  55736. protected get _disableAlphaBlending(): boolean;
  55737. /**
  55738. * Specifies whether or not this material should be rendered in alpha blend mode.
  55739. */
  55740. needAlphaBlending(): boolean;
  55741. /**
  55742. * Specifies whether or not this material should be rendered in alpha test mode.
  55743. */
  55744. needAlphaTesting(): boolean;
  55745. /**
  55746. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55747. */
  55748. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55749. /**
  55750. * Gets the texture used for the alpha test.
  55751. */
  55752. getAlphaTestTexture(): Nullable<BaseTexture>;
  55753. /**
  55754. * Specifies that the submesh is ready to be used.
  55755. * @param mesh - BJS mesh.
  55756. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55757. * @param useInstances - Specifies that instances should be used.
  55758. * @returns - boolean indicating that the submesh is ready or not.
  55759. */
  55760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55761. /**
  55762. * Specifies if the material uses metallic roughness workflow.
  55763. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55764. */
  55765. isMetallicWorkflow(): boolean;
  55766. private _prepareEffect;
  55767. private _prepareDefines;
  55768. /**
  55769. * Force shader compilation
  55770. */
  55771. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55772. /**
  55773. * Initializes the uniform buffer layout for the shader.
  55774. */
  55775. buildUniformLayout(): void;
  55776. /**
  55777. * Unbinds the material from the mesh
  55778. */
  55779. unbind(): void;
  55780. /**
  55781. * Binds the submesh data.
  55782. * @param world - The world matrix.
  55783. * @param mesh - The BJS mesh.
  55784. * @param subMesh - A submesh of the BJS mesh.
  55785. */
  55786. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55787. /**
  55788. * Returns the animatable textures.
  55789. * @returns - Array of animatable textures.
  55790. */
  55791. getAnimatables(): IAnimatable[];
  55792. /**
  55793. * Returns the texture used for reflections.
  55794. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55795. */
  55796. private _getReflectionTexture;
  55797. /**
  55798. * Returns an array of the actively used textures.
  55799. * @returns - Array of BaseTextures
  55800. */
  55801. getActiveTextures(): BaseTexture[];
  55802. /**
  55803. * Checks to see if a texture is used in the material.
  55804. * @param texture - Base texture to use.
  55805. * @returns - Boolean specifying if a texture is used in the material.
  55806. */
  55807. hasTexture(texture: BaseTexture): boolean;
  55808. /**
  55809. * Disposes the resources of the material.
  55810. * @param forceDisposeEffect - Forces the disposal of effects.
  55811. * @param forceDisposeTextures - Forces the disposal of all textures.
  55812. */
  55813. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55814. }
  55815. }
  55816. declare module BABYLON {
  55817. /**
  55818. * The Physically based material of BJS.
  55819. *
  55820. * This offers the main features of a standard PBR material.
  55821. * For more information, please refer to the documentation :
  55822. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55823. */
  55824. export class PBRMaterial extends PBRBaseMaterial {
  55825. /**
  55826. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55827. */
  55828. static readonly PBRMATERIAL_OPAQUE: number;
  55829. /**
  55830. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55831. */
  55832. static readonly PBRMATERIAL_ALPHATEST: number;
  55833. /**
  55834. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55835. */
  55836. static readonly PBRMATERIAL_ALPHABLEND: number;
  55837. /**
  55838. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55839. * They are also discarded below the alpha cutoff threshold to improve performances.
  55840. */
  55841. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55842. /**
  55843. * Defines the default value of how much AO map is occluding the analytical lights
  55844. * (point spot...).
  55845. */
  55846. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55847. /**
  55848. * Intensity of the direct lights e.g. the four lights available in your scene.
  55849. * This impacts both the direct diffuse and specular highlights.
  55850. */
  55851. directIntensity: number;
  55852. /**
  55853. * Intensity of the emissive part of the material.
  55854. * This helps controlling the emissive effect without modifying the emissive color.
  55855. */
  55856. emissiveIntensity: number;
  55857. /**
  55858. * Intensity of the environment e.g. how much the environment will light the object
  55859. * either through harmonics for rough material or through the refelction for shiny ones.
  55860. */
  55861. environmentIntensity: number;
  55862. /**
  55863. * This is a special control allowing the reduction of the specular highlights coming from the
  55864. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55865. */
  55866. specularIntensity: number;
  55867. /**
  55868. * Debug Control allowing disabling the bump map on this material.
  55869. */
  55870. disableBumpMap: boolean;
  55871. /**
  55872. * AKA Diffuse Texture in standard nomenclature.
  55873. */
  55874. albedoTexture: BaseTexture;
  55875. /**
  55876. * AKA Occlusion Texture in other nomenclature.
  55877. */
  55878. ambientTexture: BaseTexture;
  55879. /**
  55880. * AKA Occlusion Texture Intensity in other nomenclature.
  55881. */
  55882. ambientTextureStrength: number;
  55883. /**
  55884. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55885. * 1 means it completely occludes it
  55886. * 0 mean it has no impact
  55887. */
  55888. ambientTextureImpactOnAnalyticalLights: number;
  55889. /**
  55890. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55891. */
  55892. opacityTexture: BaseTexture;
  55893. /**
  55894. * Stores the reflection values in a texture.
  55895. */
  55896. reflectionTexture: Nullable<BaseTexture>;
  55897. /**
  55898. * Stores the emissive values in a texture.
  55899. */
  55900. emissiveTexture: BaseTexture;
  55901. /**
  55902. * AKA Specular texture in other nomenclature.
  55903. */
  55904. reflectivityTexture: BaseTexture;
  55905. /**
  55906. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55907. */
  55908. metallicTexture: BaseTexture;
  55909. /**
  55910. * Specifies the metallic scalar of the metallic/roughness workflow.
  55911. * Can also be used to scale the metalness values of the metallic texture.
  55912. */
  55913. metallic: Nullable<number>;
  55914. /**
  55915. * Specifies the roughness scalar of the metallic/roughness workflow.
  55916. * Can also be used to scale the roughness values of the metallic texture.
  55917. */
  55918. roughness: Nullable<number>;
  55919. /**
  55920. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55921. * By default the indexOfrefraction is used to compute F0;
  55922. *
  55923. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55924. *
  55925. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55926. * F90 = metallicReflectanceColor;
  55927. */
  55928. metallicF0Factor: number;
  55929. /**
  55930. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55931. * By default the F90 is always 1;
  55932. *
  55933. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55934. *
  55935. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55936. * F90 = metallicReflectanceColor;
  55937. */
  55938. metallicReflectanceColor: Color3;
  55939. /**
  55940. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55941. * This is multiply against the scalar values defined in the material.
  55942. */
  55943. metallicReflectanceTexture: Nullable<BaseTexture>;
  55944. /**
  55945. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55946. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55947. */
  55948. microSurfaceTexture: BaseTexture;
  55949. /**
  55950. * Stores surface normal data used to displace a mesh in a texture.
  55951. */
  55952. bumpTexture: BaseTexture;
  55953. /**
  55954. * Stores the pre-calculated light information of a mesh in a texture.
  55955. */
  55956. lightmapTexture: BaseTexture;
  55957. /**
  55958. * Stores the refracted light information in a texture.
  55959. */
  55960. get refractionTexture(): Nullable<BaseTexture>;
  55961. set refractionTexture(value: Nullable<BaseTexture>);
  55962. /**
  55963. * The color of a material in ambient lighting.
  55964. */
  55965. ambientColor: Color3;
  55966. /**
  55967. * AKA Diffuse Color in other nomenclature.
  55968. */
  55969. albedoColor: Color3;
  55970. /**
  55971. * AKA Specular Color in other nomenclature.
  55972. */
  55973. reflectivityColor: Color3;
  55974. /**
  55975. * The color reflected from the material.
  55976. */
  55977. reflectionColor: Color3;
  55978. /**
  55979. * The color emitted from the material.
  55980. */
  55981. emissiveColor: Color3;
  55982. /**
  55983. * AKA Glossiness in other nomenclature.
  55984. */
  55985. microSurface: number;
  55986. /**
  55987. * Index of refraction of the material base layer.
  55988. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55989. *
  55990. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55991. *
  55992. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55993. */
  55994. get indexOfRefraction(): number;
  55995. set indexOfRefraction(value: number);
  55996. /**
  55997. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55998. */
  55999. get invertRefractionY(): boolean;
  56000. set invertRefractionY(value: boolean);
  56001. /**
  56002. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56003. * Materials half opaque for instance using refraction could benefit from this control.
  56004. */
  56005. get linkRefractionWithTransparency(): boolean;
  56006. set linkRefractionWithTransparency(value: boolean);
  56007. /**
  56008. * If true, the light map contains occlusion information instead of lighting info.
  56009. */
  56010. useLightmapAsShadowmap: boolean;
  56011. /**
  56012. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56013. */
  56014. useAlphaFromAlbedoTexture: boolean;
  56015. /**
  56016. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56017. */
  56018. forceAlphaTest: boolean;
  56019. /**
  56020. * Defines the alpha limits in alpha test mode.
  56021. */
  56022. alphaCutOff: number;
  56023. /**
  56024. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56025. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56026. */
  56027. useSpecularOverAlpha: boolean;
  56028. /**
  56029. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56030. */
  56031. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56032. /**
  56033. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56034. */
  56035. useRoughnessFromMetallicTextureAlpha: boolean;
  56036. /**
  56037. * Specifies if the metallic texture contains the roughness information in its green channel.
  56038. */
  56039. useRoughnessFromMetallicTextureGreen: boolean;
  56040. /**
  56041. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56042. */
  56043. useMetallnessFromMetallicTextureBlue: boolean;
  56044. /**
  56045. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56046. */
  56047. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56048. /**
  56049. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56050. */
  56051. useAmbientInGrayScale: boolean;
  56052. /**
  56053. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56054. * The material will try to infer what glossiness each pixel should be.
  56055. */
  56056. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56057. /**
  56058. * BJS is using an harcoded light falloff based on a manually sets up range.
  56059. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56060. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56061. */
  56062. get usePhysicalLightFalloff(): boolean;
  56063. /**
  56064. * BJS is using an harcoded light falloff based on a manually sets up range.
  56065. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56066. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56067. */
  56068. set usePhysicalLightFalloff(value: boolean);
  56069. /**
  56070. * In order to support the falloff compatibility with gltf, a special mode has been added
  56071. * to reproduce the gltf light falloff.
  56072. */
  56073. get useGLTFLightFalloff(): boolean;
  56074. /**
  56075. * In order to support the falloff compatibility with gltf, a special mode has been added
  56076. * to reproduce the gltf light falloff.
  56077. */
  56078. set useGLTFLightFalloff(value: boolean);
  56079. /**
  56080. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56081. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56082. */
  56083. useRadianceOverAlpha: boolean;
  56084. /**
  56085. * Allows using an object space normal map (instead of tangent space).
  56086. */
  56087. useObjectSpaceNormalMap: boolean;
  56088. /**
  56089. * Allows using the bump map in parallax mode.
  56090. */
  56091. useParallax: boolean;
  56092. /**
  56093. * Allows using the bump map in parallax occlusion mode.
  56094. */
  56095. useParallaxOcclusion: boolean;
  56096. /**
  56097. * Controls the scale bias of the parallax mode.
  56098. */
  56099. parallaxScaleBias: number;
  56100. /**
  56101. * If sets to true, disables all the lights affecting the material.
  56102. */
  56103. disableLighting: boolean;
  56104. /**
  56105. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56106. */
  56107. forceIrradianceInFragment: boolean;
  56108. /**
  56109. * Number of Simultaneous lights allowed on the material.
  56110. */
  56111. maxSimultaneousLights: number;
  56112. /**
  56113. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56114. */
  56115. invertNormalMapX: boolean;
  56116. /**
  56117. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56118. */
  56119. invertNormalMapY: boolean;
  56120. /**
  56121. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56122. */
  56123. twoSidedLighting: boolean;
  56124. /**
  56125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56126. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56127. */
  56128. useAlphaFresnel: boolean;
  56129. /**
  56130. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56131. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56132. */
  56133. useLinearAlphaFresnel: boolean;
  56134. /**
  56135. * Let user defines the brdf lookup texture used for IBL.
  56136. * A default 8bit version is embedded but you could point at :
  56137. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56138. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56139. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56140. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56141. */
  56142. environmentBRDFTexture: Nullable<BaseTexture>;
  56143. /**
  56144. * Force normal to face away from face.
  56145. */
  56146. forceNormalForward: boolean;
  56147. /**
  56148. * Enables specular anti aliasing in the PBR shader.
  56149. * It will both interacts on the Geometry for analytical and IBL lighting.
  56150. * It also prefilter the roughness map based on the bump values.
  56151. */
  56152. enableSpecularAntiAliasing: boolean;
  56153. /**
  56154. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56155. * makes the reflect vector face the model (under horizon).
  56156. */
  56157. useHorizonOcclusion: boolean;
  56158. /**
  56159. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56160. * too much the area relying on ambient texture to define their ambient occlusion.
  56161. */
  56162. useRadianceOcclusion: boolean;
  56163. /**
  56164. * If set to true, no lighting calculations will be applied.
  56165. */
  56166. unlit: boolean;
  56167. /**
  56168. * Gets the image processing configuration used either in this material.
  56169. */
  56170. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56171. /**
  56172. * Sets the Default image processing configuration used either in the this material.
  56173. *
  56174. * If sets to null, the scene one is in use.
  56175. */
  56176. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56177. /**
  56178. * Gets wether the color curves effect is enabled.
  56179. */
  56180. get cameraColorCurvesEnabled(): boolean;
  56181. /**
  56182. * Sets wether the color curves effect is enabled.
  56183. */
  56184. set cameraColorCurvesEnabled(value: boolean);
  56185. /**
  56186. * Gets wether the color grading effect is enabled.
  56187. */
  56188. get cameraColorGradingEnabled(): boolean;
  56189. /**
  56190. * Gets wether the color grading effect is enabled.
  56191. */
  56192. set cameraColorGradingEnabled(value: boolean);
  56193. /**
  56194. * Gets wether tonemapping is enabled or not.
  56195. */
  56196. get cameraToneMappingEnabled(): boolean;
  56197. /**
  56198. * Sets wether tonemapping is enabled or not
  56199. */
  56200. set cameraToneMappingEnabled(value: boolean);
  56201. /**
  56202. * The camera exposure used on this material.
  56203. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56204. * This corresponds to a photographic exposure.
  56205. */
  56206. get cameraExposure(): number;
  56207. /**
  56208. * The camera exposure used on this material.
  56209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56210. * This corresponds to a photographic exposure.
  56211. */
  56212. set cameraExposure(value: number);
  56213. /**
  56214. * Gets The camera contrast used on this material.
  56215. */
  56216. get cameraContrast(): number;
  56217. /**
  56218. * Sets The camera contrast used on this material.
  56219. */
  56220. set cameraContrast(value: number);
  56221. /**
  56222. * Gets the Color Grading 2D Lookup Texture.
  56223. */
  56224. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56225. /**
  56226. * Sets the Color Grading 2D Lookup Texture.
  56227. */
  56228. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56229. /**
  56230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56232. * 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;
  56233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56234. */
  56235. get cameraColorCurves(): Nullable<ColorCurves>;
  56236. /**
  56237. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56238. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56239. * 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;
  56240. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56241. */
  56242. set cameraColorCurves(value: Nullable<ColorCurves>);
  56243. /**
  56244. * Instantiates a new PBRMaterial instance.
  56245. *
  56246. * @param name The material name
  56247. * @param scene The scene the material will be use in.
  56248. */
  56249. constructor(name: string, scene: Scene);
  56250. /**
  56251. * Returns the name of this material class.
  56252. */
  56253. getClassName(): string;
  56254. /**
  56255. * Makes a duplicate of the current material.
  56256. * @param name - name to use for the new material.
  56257. */
  56258. clone(name: string): PBRMaterial;
  56259. /**
  56260. * Serializes this PBR Material.
  56261. * @returns - An object with the serialized material.
  56262. */
  56263. serialize(): any;
  56264. /**
  56265. * Parses a PBR Material from a serialized object.
  56266. * @param source - Serialized object.
  56267. * @param scene - BJS scene instance.
  56268. * @param rootUrl - url for the scene object
  56269. * @returns - PBRMaterial
  56270. */
  56271. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56272. }
  56273. }
  56274. declare module BABYLON {
  56275. /**
  56276. * Direct draw surface info
  56277. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56278. */
  56279. export interface DDSInfo {
  56280. /**
  56281. * Width of the texture
  56282. */
  56283. width: number;
  56284. /**
  56285. * Width of the texture
  56286. */
  56287. height: number;
  56288. /**
  56289. * Number of Mipmaps for the texture
  56290. * @see https://en.wikipedia.org/wiki/Mipmap
  56291. */
  56292. mipmapCount: number;
  56293. /**
  56294. * If the textures format is a known fourCC format
  56295. * @see https://www.fourcc.org/
  56296. */
  56297. isFourCC: boolean;
  56298. /**
  56299. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56300. */
  56301. isRGB: boolean;
  56302. /**
  56303. * If the texture is a lumincance format
  56304. */
  56305. isLuminance: boolean;
  56306. /**
  56307. * If this is a cube texture
  56308. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56309. */
  56310. isCube: boolean;
  56311. /**
  56312. * If the texture is a compressed format eg. FOURCC_DXT1
  56313. */
  56314. isCompressed: boolean;
  56315. /**
  56316. * The dxgiFormat of the texture
  56317. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56318. */
  56319. dxgiFormat: number;
  56320. /**
  56321. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56322. */
  56323. textureType: number;
  56324. /**
  56325. * Sphericle polynomial created for the dds texture
  56326. */
  56327. sphericalPolynomial?: SphericalPolynomial;
  56328. }
  56329. /**
  56330. * Class used to provide DDS decompression tools
  56331. */
  56332. export class DDSTools {
  56333. /**
  56334. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56335. */
  56336. static StoreLODInAlphaChannel: boolean;
  56337. /**
  56338. * Gets DDS information from an array buffer
  56339. * @param data defines the array buffer view to read data from
  56340. * @returns the DDS information
  56341. */
  56342. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56343. private static _FloatView;
  56344. private static _Int32View;
  56345. private static _ToHalfFloat;
  56346. private static _FromHalfFloat;
  56347. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56348. private static _GetHalfFloatRGBAArrayBuffer;
  56349. private static _GetFloatRGBAArrayBuffer;
  56350. private static _GetFloatAsUIntRGBAArrayBuffer;
  56351. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56352. private static _GetRGBAArrayBuffer;
  56353. private static _ExtractLongWordOrder;
  56354. private static _GetRGBArrayBuffer;
  56355. private static _GetLuminanceArrayBuffer;
  56356. /**
  56357. * Uploads DDS Levels to a Babylon Texture
  56358. * @hidden
  56359. */
  56360. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56361. }
  56362. interface ThinEngine {
  56363. /**
  56364. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56365. * @param rootUrl defines the url where the file to load is located
  56366. * @param scene defines the current scene
  56367. * @param lodScale defines scale to apply to the mip map selection
  56368. * @param lodOffset defines offset to apply to the mip map selection
  56369. * @param onLoad defines an optional callback raised when the texture is loaded
  56370. * @param onError defines an optional callback raised if there is an issue to load the texture
  56371. * @param format defines the format of the data
  56372. * @param forcedExtension defines the extension to use to pick the right loader
  56373. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56374. * @returns the cube texture as an InternalTexture
  56375. */
  56376. 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;
  56377. }
  56378. }
  56379. declare module BABYLON {
  56380. /**
  56381. * Implementation of the DDS Texture Loader.
  56382. * @hidden
  56383. */
  56384. export class _DDSTextureLoader implements IInternalTextureLoader {
  56385. /**
  56386. * Defines wether the loader supports cascade loading the different faces.
  56387. */
  56388. readonly supportCascades: boolean;
  56389. /**
  56390. * This returns if the loader support the current file information.
  56391. * @param extension defines the file extension of the file being loaded
  56392. * @returns true if the loader can load the specified file
  56393. */
  56394. canLoad(extension: string): boolean;
  56395. /**
  56396. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56397. * @param data contains the texture data
  56398. * @param texture defines the BabylonJS internal texture
  56399. * @param createPolynomials will be true if polynomials have been requested
  56400. * @param onLoad defines the callback to trigger once the texture is ready
  56401. * @param onError defines the callback to trigger in case of error
  56402. */
  56403. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56404. /**
  56405. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56406. * @param data contains the texture data
  56407. * @param texture defines the BabylonJS internal texture
  56408. * @param callback defines the method to call once ready to upload
  56409. */
  56410. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56411. }
  56412. }
  56413. declare module BABYLON {
  56414. /**
  56415. * Implementation of the ENV Texture Loader.
  56416. * @hidden
  56417. */
  56418. export class _ENVTextureLoader implements IInternalTextureLoader {
  56419. /**
  56420. * Defines wether the loader supports cascade loading the different faces.
  56421. */
  56422. readonly supportCascades: boolean;
  56423. /**
  56424. * This returns if the loader support the current file information.
  56425. * @param extension defines the file extension of the file being loaded
  56426. * @returns true if the loader can load the specified file
  56427. */
  56428. canLoad(extension: string): boolean;
  56429. /**
  56430. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56431. * @param data contains the texture data
  56432. * @param texture defines the BabylonJS internal texture
  56433. * @param createPolynomials will be true if polynomials have been requested
  56434. * @param onLoad defines the callback to trigger once the texture is ready
  56435. * @param onError defines the callback to trigger in case of error
  56436. */
  56437. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56438. /**
  56439. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56440. * @param data contains the texture data
  56441. * @param texture defines the BabylonJS internal texture
  56442. * @param callback defines the method to call once ready to upload
  56443. */
  56444. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56445. }
  56446. }
  56447. declare module BABYLON {
  56448. /**
  56449. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56450. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56451. */
  56452. export class KhronosTextureContainer {
  56453. /** contents of the KTX container file */
  56454. data: ArrayBufferView;
  56455. private static HEADER_LEN;
  56456. private static COMPRESSED_2D;
  56457. private static COMPRESSED_3D;
  56458. private static TEX_2D;
  56459. private static TEX_3D;
  56460. /**
  56461. * Gets the openGL type
  56462. */
  56463. glType: number;
  56464. /**
  56465. * Gets the openGL type size
  56466. */
  56467. glTypeSize: number;
  56468. /**
  56469. * Gets the openGL format
  56470. */
  56471. glFormat: number;
  56472. /**
  56473. * Gets the openGL internal format
  56474. */
  56475. glInternalFormat: number;
  56476. /**
  56477. * Gets the base internal format
  56478. */
  56479. glBaseInternalFormat: number;
  56480. /**
  56481. * Gets image width in pixel
  56482. */
  56483. pixelWidth: number;
  56484. /**
  56485. * Gets image height in pixel
  56486. */
  56487. pixelHeight: number;
  56488. /**
  56489. * Gets image depth in pixels
  56490. */
  56491. pixelDepth: number;
  56492. /**
  56493. * Gets the number of array elements
  56494. */
  56495. numberOfArrayElements: number;
  56496. /**
  56497. * Gets the number of faces
  56498. */
  56499. numberOfFaces: number;
  56500. /**
  56501. * Gets the number of mipmap levels
  56502. */
  56503. numberOfMipmapLevels: number;
  56504. /**
  56505. * Gets the bytes of key value data
  56506. */
  56507. bytesOfKeyValueData: number;
  56508. /**
  56509. * Gets the load type
  56510. */
  56511. loadType: number;
  56512. /**
  56513. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56514. */
  56515. isInvalid: boolean;
  56516. /**
  56517. * Creates a new KhronosTextureContainer
  56518. * @param data contents of the KTX container file
  56519. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56520. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56521. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56522. */
  56523. constructor(
  56524. /** contents of the KTX container file */
  56525. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56526. /**
  56527. * Uploads KTX content to a Babylon Texture.
  56528. * It is assumed that the texture has already been created & is currently bound
  56529. * @hidden
  56530. */
  56531. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56532. private _upload2DCompressedLevels;
  56533. /**
  56534. * Checks if the given data starts with a KTX file identifier.
  56535. * @param data the data to check
  56536. * @returns true if the data is a KTX file or false otherwise
  56537. */
  56538. static IsValid(data: ArrayBufferView): boolean;
  56539. }
  56540. }
  56541. declare module BABYLON {
  56542. /**
  56543. * Class for loading KTX2 files
  56544. * !!! Experimental Extension Subject to Changes !!!
  56545. * @hidden
  56546. */
  56547. export class KhronosTextureContainer2 {
  56548. private static _ModulePromise;
  56549. private static _TranscodeFormat;
  56550. constructor(engine: ThinEngine);
  56551. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56552. private _determineTranscodeFormat;
  56553. /**
  56554. * Checks if the given data starts with a KTX2 file identifier.
  56555. * @param data the data to check
  56556. * @returns true if the data is a KTX2 file or false otherwise
  56557. */
  56558. static IsValid(data: ArrayBufferView): boolean;
  56559. }
  56560. }
  56561. declare module BABYLON {
  56562. /**
  56563. * Implementation of the KTX Texture Loader.
  56564. * @hidden
  56565. */
  56566. export class _KTXTextureLoader implements IInternalTextureLoader {
  56567. /**
  56568. * Defines wether the loader supports cascade loading the different faces.
  56569. */
  56570. readonly supportCascades: boolean;
  56571. /**
  56572. * This returns if the loader support the current file information.
  56573. * @param extension defines the file extension of the file being loaded
  56574. * @param mimeType defines the optional mime type of the file being loaded
  56575. * @returns true if the loader can load the specified file
  56576. */
  56577. canLoad(extension: string, mimeType?: string): boolean;
  56578. /**
  56579. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56580. * @param data contains the texture data
  56581. * @param texture defines the BabylonJS internal texture
  56582. * @param createPolynomials will be true if polynomials have been requested
  56583. * @param onLoad defines the callback to trigger once the texture is ready
  56584. * @param onError defines the callback to trigger in case of error
  56585. */
  56586. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56587. /**
  56588. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56589. * @param data contains the texture data
  56590. * @param texture defines the BabylonJS internal texture
  56591. * @param callback defines the method to call once ready to upload
  56592. */
  56593. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56594. }
  56595. }
  56596. declare module BABYLON {
  56597. /** @hidden */
  56598. export var _forceSceneHelpersToBundle: boolean;
  56599. interface Scene {
  56600. /**
  56601. * Creates a default light for the scene.
  56602. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56603. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56604. */
  56605. createDefaultLight(replace?: boolean): void;
  56606. /**
  56607. * Creates a default camera for the scene.
  56608. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56609. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56610. * @param replace has default false, when true replaces the active camera in the scene
  56611. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56612. */
  56613. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56614. /**
  56615. * Creates a default camera and a default light.
  56616. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56617. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56618. * @param replace has the default false, when true replaces the active camera/light in the scene
  56619. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56620. */
  56621. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56622. /**
  56623. * Creates a new sky box
  56624. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56625. * @param environmentTexture defines the texture to use as environment texture
  56626. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56627. * @param scale defines the overall scale of the skybox
  56628. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56629. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56630. * @returns a new mesh holding the sky box
  56631. */
  56632. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56633. /**
  56634. * Creates a new environment
  56635. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56636. * @param options defines the options you can use to configure the environment
  56637. * @returns the new EnvironmentHelper
  56638. */
  56639. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56640. /**
  56641. * Creates a new VREXperienceHelper
  56642. * @see https://doc.babylonjs.com/how_to/webvr_helper
  56643. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56644. * @returns a new VREXperienceHelper
  56645. */
  56646. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56647. /**
  56648. * Creates a new WebXRDefaultExperience
  56649. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  56650. * @param options experience options
  56651. * @returns a promise for a new WebXRDefaultExperience
  56652. */
  56653. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56654. }
  56655. }
  56656. declare module BABYLON {
  56657. /**
  56658. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56659. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56660. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56661. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56662. */
  56663. export class VideoDome extends TransformNode {
  56664. /**
  56665. * Define the video source as a Monoscopic panoramic 360 video.
  56666. */
  56667. static readonly MODE_MONOSCOPIC: number;
  56668. /**
  56669. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56670. */
  56671. static readonly MODE_TOPBOTTOM: number;
  56672. /**
  56673. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56674. */
  56675. static readonly MODE_SIDEBYSIDE: number;
  56676. private _halfDome;
  56677. private _useDirectMapping;
  56678. /**
  56679. * The video texture being displayed on the sphere
  56680. */
  56681. protected _videoTexture: VideoTexture;
  56682. /**
  56683. * Gets the video texture being displayed on the sphere
  56684. */
  56685. get videoTexture(): VideoTexture;
  56686. /**
  56687. * The skybox material
  56688. */
  56689. protected _material: BackgroundMaterial;
  56690. /**
  56691. * The surface used for the skybox
  56692. */
  56693. protected _mesh: Mesh;
  56694. /**
  56695. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56696. */
  56697. private _halfDomeMask;
  56698. /**
  56699. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56700. * Also see the options.resolution property.
  56701. */
  56702. get fovMultiplier(): number;
  56703. set fovMultiplier(value: number);
  56704. private _videoMode;
  56705. /**
  56706. * Gets or set the current video mode for the video. It can be:
  56707. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56708. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56709. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56710. */
  56711. get videoMode(): number;
  56712. set videoMode(value: number);
  56713. /**
  56714. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56715. *
  56716. */
  56717. get halfDome(): boolean;
  56718. /**
  56719. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56720. */
  56721. set halfDome(enabled: boolean);
  56722. /**
  56723. * Oberserver used in Stereoscopic VR Mode.
  56724. */
  56725. private _onBeforeCameraRenderObserver;
  56726. /**
  56727. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56728. * @param name Element's name, child elements will append suffixes for their own names.
  56729. * @param urlsOrVideo defines the url(s) or the video element to use
  56730. * @param options An object containing optional or exposed sub element properties
  56731. */
  56732. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56733. resolution?: number;
  56734. clickToPlay?: boolean;
  56735. autoPlay?: boolean;
  56736. loop?: boolean;
  56737. size?: number;
  56738. poster?: string;
  56739. faceForward?: boolean;
  56740. useDirectMapping?: boolean;
  56741. halfDomeMode?: boolean;
  56742. }, scene: Scene);
  56743. private _changeVideoMode;
  56744. /**
  56745. * Releases resources associated with this node.
  56746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56748. */
  56749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56750. }
  56751. }
  56752. declare module BABYLON {
  56753. /**
  56754. * This class can be used to get instrumentation data from a Babylon engine
  56755. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56756. */
  56757. export class EngineInstrumentation implements IDisposable {
  56758. /**
  56759. * Define the instrumented engine.
  56760. */
  56761. engine: Engine;
  56762. private _captureGPUFrameTime;
  56763. private _gpuFrameTimeToken;
  56764. private _gpuFrameTime;
  56765. private _captureShaderCompilationTime;
  56766. private _shaderCompilationTime;
  56767. private _onBeginFrameObserver;
  56768. private _onEndFrameObserver;
  56769. private _onBeforeShaderCompilationObserver;
  56770. private _onAfterShaderCompilationObserver;
  56771. /**
  56772. * Gets the perf counter used for GPU frame time
  56773. */
  56774. get gpuFrameTimeCounter(): PerfCounter;
  56775. /**
  56776. * Gets the GPU frame time capture status
  56777. */
  56778. get captureGPUFrameTime(): boolean;
  56779. /**
  56780. * Enable or disable the GPU frame time capture
  56781. */
  56782. set captureGPUFrameTime(value: boolean);
  56783. /**
  56784. * Gets the perf counter used for shader compilation time
  56785. */
  56786. get shaderCompilationTimeCounter(): PerfCounter;
  56787. /**
  56788. * Gets the shader compilation time capture status
  56789. */
  56790. get captureShaderCompilationTime(): boolean;
  56791. /**
  56792. * Enable or disable the shader compilation time capture
  56793. */
  56794. set captureShaderCompilationTime(value: boolean);
  56795. /**
  56796. * Instantiates a new engine instrumentation.
  56797. * This class can be used to get instrumentation data from a Babylon engine
  56798. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56799. * @param engine Defines the engine to instrument
  56800. */
  56801. constructor(
  56802. /**
  56803. * Define the instrumented engine.
  56804. */
  56805. engine: Engine);
  56806. /**
  56807. * Dispose and release associated resources.
  56808. */
  56809. dispose(): void;
  56810. }
  56811. }
  56812. declare module BABYLON {
  56813. /**
  56814. * This class can be used to get instrumentation data from a Babylon engine
  56815. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56816. */
  56817. export class SceneInstrumentation implements IDisposable {
  56818. /**
  56819. * Defines the scene to instrument
  56820. */
  56821. scene: Scene;
  56822. private _captureActiveMeshesEvaluationTime;
  56823. private _activeMeshesEvaluationTime;
  56824. private _captureRenderTargetsRenderTime;
  56825. private _renderTargetsRenderTime;
  56826. private _captureFrameTime;
  56827. private _frameTime;
  56828. private _captureRenderTime;
  56829. private _renderTime;
  56830. private _captureInterFrameTime;
  56831. private _interFrameTime;
  56832. private _captureParticlesRenderTime;
  56833. private _particlesRenderTime;
  56834. private _captureSpritesRenderTime;
  56835. private _spritesRenderTime;
  56836. private _capturePhysicsTime;
  56837. private _physicsTime;
  56838. private _captureAnimationsTime;
  56839. private _animationsTime;
  56840. private _captureCameraRenderTime;
  56841. private _cameraRenderTime;
  56842. private _onBeforeActiveMeshesEvaluationObserver;
  56843. private _onAfterActiveMeshesEvaluationObserver;
  56844. private _onBeforeRenderTargetsRenderObserver;
  56845. private _onAfterRenderTargetsRenderObserver;
  56846. private _onAfterRenderObserver;
  56847. private _onBeforeDrawPhaseObserver;
  56848. private _onAfterDrawPhaseObserver;
  56849. private _onBeforeAnimationsObserver;
  56850. private _onBeforeParticlesRenderingObserver;
  56851. private _onAfterParticlesRenderingObserver;
  56852. private _onBeforeSpritesRenderingObserver;
  56853. private _onAfterSpritesRenderingObserver;
  56854. private _onBeforePhysicsObserver;
  56855. private _onAfterPhysicsObserver;
  56856. private _onAfterAnimationsObserver;
  56857. private _onBeforeCameraRenderObserver;
  56858. private _onAfterCameraRenderObserver;
  56859. /**
  56860. * Gets the perf counter used for active meshes evaluation time
  56861. */
  56862. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56863. /**
  56864. * Gets the active meshes evaluation time capture status
  56865. */
  56866. get captureActiveMeshesEvaluationTime(): boolean;
  56867. /**
  56868. * Enable or disable the active meshes evaluation time capture
  56869. */
  56870. set captureActiveMeshesEvaluationTime(value: boolean);
  56871. /**
  56872. * Gets the perf counter used for render targets render time
  56873. */
  56874. get renderTargetsRenderTimeCounter(): PerfCounter;
  56875. /**
  56876. * Gets the render targets render time capture status
  56877. */
  56878. get captureRenderTargetsRenderTime(): boolean;
  56879. /**
  56880. * Enable or disable the render targets render time capture
  56881. */
  56882. set captureRenderTargetsRenderTime(value: boolean);
  56883. /**
  56884. * Gets the perf counter used for particles render time
  56885. */
  56886. get particlesRenderTimeCounter(): PerfCounter;
  56887. /**
  56888. * Gets the particles render time capture status
  56889. */
  56890. get captureParticlesRenderTime(): boolean;
  56891. /**
  56892. * Enable or disable the particles render time capture
  56893. */
  56894. set captureParticlesRenderTime(value: boolean);
  56895. /**
  56896. * Gets the perf counter used for sprites render time
  56897. */
  56898. get spritesRenderTimeCounter(): PerfCounter;
  56899. /**
  56900. * Gets the sprites render time capture status
  56901. */
  56902. get captureSpritesRenderTime(): boolean;
  56903. /**
  56904. * Enable or disable the sprites render time capture
  56905. */
  56906. set captureSpritesRenderTime(value: boolean);
  56907. /**
  56908. * Gets the perf counter used for physics time
  56909. */
  56910. get physicsTimeCounter(): PerfCounter;
  56911. /**
  56912. * Gets the physics time capture status
  56913. */
  56914. get capturePhysicsTime(): boolean;
  56915. /**
  56916. * Enable or disable the physics time capture
  56917. */
  56918. set capturePhysicsTime(value: boolean);
  56919. /**
  56920. * Gets the perf counter used for animations time
  56921. */
  56922. get animationsTimeCounter(): PerfCounter;
  56923. /**
  56924. * Gets the animations time capture status
  56925. */
  56926. get captureAnimationsTime(): boolean;
  56927. /**
  56928. * Enable or disable the animations time capture
  56929. */
  56930. set captureAnimationsTime(value: boolean);
  56931. /**
  56932. * Gets the perf counter used for frame time capture
  56933. */
  56934. get frameTimeCounter(): PerfCounter;
  56935. /**
  56936. * Gets the frame time capture status
  56937. */
  56938. get captureFrameTime(): boolean;
  56939. /**
  56940. * Enable or disable the frame time capture
  56941. */
  56942. set captureFrameTime(value: boolean);
  56943. /**
  56944. * Gets the perf counter used for inter-frames time capture
  56945. */
  56946. get interFrameTimeCounter(): PerfCounter;
  56947. /**
  56948. * Gets the inter-frames time capture status
  56949. */
  56950. get captureInterFrameTime(): boolean;
  56951. /**
  56952. * Enable or disable the inter-frames time capture
  56953. */
  56954. set captureInterFrameTime(value: boolean);
  56955. /**
  56956. * Gets the perf counter used for render time capture
  56957. */
  56958. get renderTimeCounter(): PerfCounter;
  56959. /**
  56960. * Gets the render time capture status
  56961. */
  56962. get captureRenderTime(): boolean;
  56963. /**
  56964. * Enable or disable the render time capture
  56965. */
  56966. set captureRenderTime(value: boolean);
  56967. /**
  56968. * Gets the perf counter used for camera render time capture
  56969. */
  56970. get cameraRenderTimeCounter(): PerfCounter;
  56971. /**
  56972. * Gets the camera render time capture status
  56973. */
  56974. get captureCameraRenderTime(): boolean;
  56975. /**
  56976. * Enable or disable the camera render time capture
  56977. */
  56978. set captureCameraRenderTime(value: boolean);
  56979. /**
  56980. * Gets the perf counter used for draw calls
  56981. */
  56982. get drawCallsCounter(): PerfCounter;
  56983. /**
  56984. * Instantiates a new scene instrumentation.
  56985. * This class can be used to get instrumentation data from a Babylon engine
  56986. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56987. * @param scene Defines the scene to instrument
  56988. */
  56989. constructor(
  56990. /**
  56991. * Defines the scene to instrument
  56992. */
  56993. scene: Scene);
  56994. /**
  56995. * Dispose and release associated resources.
  56996. */
  56997. dispose(): void;
  56998. }
  56999. }
  57000. declare module BABYLON {
  57001. /** @hidden */
  57002. export var glowMapGenerationPixelShader: {
  57003. name: string;
  57004. shader: string;
  57005. };
  57006. }
  57007. declare module BABYLON {
  57008. /** @hidden */
  57009. export var glowMapGenerationVertexShader: {
  57010. name: string;
  57011. shader: string;
  57012. };
  57013. }
  57014. declare module BABYLON {
  57015. /**
  57016. * Effect layer options. This helps customizing the behaviour
  57017. * of the effect layer.
  57018. */
  57019. export interface IEffectLayerOptions {
  57020. /**
  57021. * Multiplication factor apply to the canvas size to compute the render target size
  57022. * used to generated the objects (the smaller the faster).
  57023. */
  57024. mainTextureRatio: number;
  57025. /**
  57026. * Enforces a fixed size texture to ensure effect stability across devices.
  57027. */
  57028. mainTextureFixedSize?: number;
  57029. /**
  57030. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57031. */
  57032. alphaBlendingMode: number;
  57033. /**
  57034. * The camera attached to the layer.
  57035. */
  57036. camera: Nullable<Camera>;
  57037. /**
  57038. * The rendering group to draw the layer in.
  57039. */
  57040. renderingGroupId: number;
  57041. }
  57042. /**
  57043. * The effect layer Helps adding post process effect blended with the main pass.
  57044. *
  57045. * This can be for instance use to generate glow or higlight effects on the scene.
  57046. *
  57047. * The effect layer class can not be used directly and is intented to inherited from to be
  57048. * customized per effects.
  57049. */
  57050. export abstract class EffectLayer {
  57051. private _vertexBuffers;
  57052. private _indexBuffer;
  57053. private _cachedDefines;
  57054. private _effectLayerMapGenerationEffect;
  57055. private _effectLayerOptions;
  57056. private _mergeEffect;
  57057. protected _scene: Scene;
  57058. protected _engine: Engine;
  57059. protected _maxSize: number;
  57060. protected _mainTextureDesiredSize: ISize;
  57061. protected _mainTexture: RenderTargetTexture;
  57062. protected _shouldRender: boolean;
  57063. protected _postProcesses: PostProcess[];
  57064. protected _textures: BaseTexture[];
  57065. protected _emissiveTextureAndColor: {
  57066. texture: Nullable<BaseTexture>;
  57067. color: Color4;
  57068. };
  57069. /**
  57070. * The name of the layer
  57071. */
  57072. name: string;
  57073. /**
  57074. * The clear color of the texture used to generate the glow map.
  57075. */
  57076. neutralColor: Color4;
  57077. /**
  57078. * Specifies whether the highlight layer is enabled or not.
  57079. */
  57080. isEnabled: boolean;
  57081. /**
  57082. * Gets the camera attached to the layer.
  57083. */
  57084. get camera(): Nullable<Camera>;
  57085. /**
  57086. * Gets the rendering group id the layer should render in.
  57087. */
  57088. get renderingGroupId(): number;
  57089. set renderingGroupId(renderingGroupId: number);
  57090. /**
  57091. * An event triggered when the effect layer has been disposed.
  57092. */
  57093. onDisposeObservable: Observable<EffectLayer>;
  57094. /**
  57095. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57096. */
  57097. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57098. /**
  57099. * An event triggered when the generated texture is being merged in the scene.
  57100. */
  57101. onBeforeComposeObservable: Observable<EffectLayer>;
  57102. /**
  57103. * An event triggered when the mesh is rendered into the effect render target.
  57104. */
  57105. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57106. /**
  57107. * An event triggered after the mesh has been rendered into the effect render target.
  57108. */
  57109. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57110. /**
  57111. * An event triggered when the generated texture has been merged in the scene.
  57112. */
  57113. onAfterComposeObservable: Observable<EffectLayer>;
  57114. /**
  57115. * An event triggered when the efffect layer changes its size.
  57116. */
  57117. onSizeChangedObservable: Observable<EffectLayer>;
  57118. /** @hidden */
  57119. static _SceneComponentInitialization: (scene: Scene) => void;
  57120. /**
  57121. * Instantiates a new effect Layer and references it in the scene.
  57122. * @param name The name of the layer
  57123. * @param scene The scene to use the layer in
  57124. */
  57125. constructor(
  57126. /** The Friendly of the effect in the scene */
  57127. name: string, scene: Scene);
  57128. /**
  57129. * Get the effect name of the layer.
  57130. * @return The effect name
  57131. */
  57132. abstract getEffectName(): string;
  57133. /**
  57134. * Checks for the readiness of the element composing the layer.
  57135. * @param subMesh the mesh to check for
  57136. * @param useInstances specify whether or not to use instances to render the mesh
  57137. * @return true if ready otherwise, false
  57138. */
  57139. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57140. /**
  57141. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57142. * @returns true if the effect requires stencil during the main canvas render pass.
  57143. */
  57144. abstract needStencil(): boolean;
  57145. /**
  57146. * Create the merge effect. This is the shader use to blit the information back
  57147. * to the main canvas at the end of the scene rendering.
  57148. * @returns The effect containing the shader used to merge the effect on the main canvas
  57149. */
  57150. protected abstract _createMergeEffect(): Effect;
  57151. /**
  57152. * Creates the render target textures and post processes used in the effect layer.
  57153. */
  57154. protected abstract _createTextureAndPostProcesses(): void;
  57155. /**
  57156. * Implementation specific of rendering the generating effect on the main canvas.
  57157. * @param effect The effect used to render through
  57158. */
  57159. protected abstract _internalRender(effect: Effect): void;
  57160. /**
  57161. * Sets the required values for both the emissive texture and and the main color.
  57162. */
  57163. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57164. /**
  57165. * Free any resources and references associated to a mesh.
  57166. * Internal use
  57167. * @param mesh The mesh to free.
  57168. */
  57169. abstract _disposeMesh(mesh: Mesh): void;
  57170. /**
  57171. * Serializes this layer (Glow or Highlight for example)
  57172. * @returns a serialized layer object
  57173. */
  57174. abstract serialize?(): any;
  57175. /**
  57176. * Initializes the effect layer with the required options.
  57177. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57178. */
  57179. protected _init(options: Partial<IEffectLayerOptions>): void;
  57180. /**
  57181. * Generates the index buffer of the full screen quad blending to the main canvas.
  57182. */
  57183. private _generateIndexBuffer;
  57184. /**
  57185. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57186. */
  57187. private _generateVertexBuffer;
  57188. /**
  57189. * Sets the main texture desired size which is the closest power of two
  57190. * of the engine canvas size.
  57191. */
  57192. private _setMainTextureSize;
  57193. /**
  57194. * Creates the main texture for the effect layer.
  57195. */
  57196. protected _createMainTexture(): void;
  57197. /**
  57198. * Adds specific effects defines.
  57199. * @param defines The defines to add specifics to.
  57200. */
  57201. protected _addCustomEffectDefines(defines: string[]): void;
  57202. /**
  57203. * Checks for the readiness of the element composing the layer.
  57204. * @param subMesh the mesh to check for
  57205. * @param useInstances specify whether or not to use instances to render the mesh
  57206. * @param emissiveTexture the associated emissive texture used to generate the glow
  57207. * @return true if ready otherwise, false
  57208. */
  57209. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57210. /**
  57211. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57212. */
  57213. render(): void;
  57214. /**
  57215. * Determine if a given mesh will be used in the current effect.
  57216. * @param mesh mesh to test
  57217. * @returns true if the mesh will be used
  57218. */
  57219. hasMesh(mesh: AbstractMesh): boolean;
  57220. /**
  57221. * Returns true if the layer contains information to display, otherwise false.
  57222. * @returns true if the glow layer should be rendered
  57223. */
  57224. shouldRender(): boolean;
  57225. /**
  57226. * Returns true if the mesh should render, otherwise false.
  57227. * @param mesh The mesh to render
  57228. * @returns true if it should render otherwise false
  57229. */
  57230. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57231. /**
  57232. * Returns true if the mesh can be rendered, otherwise false.
  57233. * @param mesh The mesh to render
  57234. * @param material The material used on the mesh
  57235. * @returns true if it can be rendered otherwise false
  57236. */
  57237. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57238. /**
  57239. * Returns true if the mesh should render, otherwise false.
  57240. * @param mesh The mesh to render
  57241. * @returns true if it should render otherwise false
  57242. */
  57243. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57244. /**
  57245. * Renders the submesh passed in parameter to the generation map.
  57246. */
  57247. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57248. /**
  57249. * Defines whether the current material of the mesh should be use to render the effect.
  57250. * @param mesh defines the current mesh to render
  57251. */
  57252. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57253. /**
  57254. * Rebuild the required buffers.
  57255. * @hidden Internal use only.
  57256. */
  57257. _rebuild(): void;
  57258. /**
  57259. * Dispose only the render target textures and post process.
  57260. */
  57261. private _disposeTextureAndPostProcesses;
  57262. /**
  57263. * Dispose the highlight layer and free resources.
  57264. */
  57265. dispose(): void;
  57266. /**
  57267. * Gets the class name of the effect layer
  57268. * @returns the string with the class name of the effect layer
  57269. */
  57270. getClassName(): string;
  57271. /**
  57272. * Creates an effect layer from parsed effect layer data
  57273. * @param parsedEffectLayer defines effect layer data
  57274. * @param scene defines the current scene
  57275. * @param rootUrl defines the root URL containing the effect layer information
  57276. * @returns a parsed effect Layer
  57277. */
  57278. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57279. }
  57280. }
  57281. declare module BABYLON {
  57282. interface AbstractScene {
  57283. /**
  57284. * The list of effect layers (highlights/glow) added to the scene
  57285. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57286. * @see https://doc.babylonjs.com/how_to/glow_layer
  57287. */
  57288. effectLayers: Array<EffectLayer>;
  57289. /**
  57290. * Removes the given effect layer from this scene.
  57291. * @param toRemove defines the effect layer to remove
  57292. * @returns the index of the removed effect layer
  57293. */
  57294. removeEffectLayer(toRemove: EffectLayer): number;
  57295. /**
  57296. * Adds the given effect layer to this scene
  57297. * @param newEffectLayer defines the effect layer to add
  57298. */
  57299. addEffectLayer(newEffectLayer: EffectLayer): void;
  57300. }
  57301. /**
  57302. * Defines the layer scene component responsible to manage any effect layers
  57303. * in a given scene.
  57304. */
  57305. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57306. /**
  57307. * The component name helpfull to identify the component in the list of scene components.
  57308. */
  57309. readonly name: string;
  57310. /**
  57311. * The scene the component belongs to.
  57312. */
  57313. scene: Scene;
  57314. private _engine;
  57315. private _renderEffects;
  57316. private _needStencil;
  57317. private _previousStencilState;
  57318. /**
  57319. * Creates a new instance of the component for the given scene
  57320. * @param scene Defines the scene to register the component in
  57321. */
  57322. constructor(scene: Scene);
  57323. /**
  57324. * Registers the component in a given scene
  57325. */
  57326. register(): void;
  57327. /**
  57328. * Rebuilds the elements related to this component in case of
  57329. * context lost for instance.
  57330. */
  57331. rebuild(): void;
  57332. /**
  57333. * Serializes the component data to the specified json object
  57334. * @param serializationObject The object to serialize to
  57335. */
  57336. serialize(serializationObject: any): void;
  57337. /**
  57338. * Adds all the elements from the container to the scene
  57339. * @param container the container holding the elements
  57340. */
  57341. addFromContainer(container: AbstractScene): void;
  57342. /**
  57343. * Removes all the elements in the container from the scene
  57344. * @param container contains the elements to remove
  57345. * @param dispose if the removed element should be disposed (default: false)
  57346. */
  57347. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57348. /**
  57349. * Disposes the component and the associated ressources.
  57350. */
  57351. dispose(): void;
  57352. private _isReadyForMesh;
  57353. private _renderMainTexture;
  57354. private _setStencil;
  57355. private _setStencilBack;
  57356. private _draw;
  57357. private _drawCamera;
  57358. private _drawRenderingGroup;
  57359. }
  57360. }
  57361. declare module BABYLON {
  57362. /** @hidden */
  57363. export var glowMapMergePixelShader: {
  57364. name: string;
  57365. shader: string;
  57366. };
  57367. }
  57368. declare module BABYLON {
  57369. /** @hidden */
  57370. export var glowMapMergeVertexShader: {
  57371. name: string;
  57372. shader: string;
  57373. };
  57374. }
  57375. declare module BABYLON {
  57376. interface AbstractScene {
  57377. /**
  57378. * Return a the first highlight layer of the scene with a given name.
  57379. * @param name The name of the highlight layer to look for.
  57380. * @return The highlight layer if found otherwise null.
  57381. */
  57382. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57383. }
  57384. /**
  57385. * Glow layer options. This helps customizing the behaviour
  57386. * of the glow layer.
  57387. */
  57388. export interface IGlowLayerOptions {
  57389. /**
  57390. * Multiplication factor apply to the canvas size to compute the render target size
  57391. * used to generated the glowing objects (the smaller the faster).
  57392. */
  57393. mainTextureRatio: number;
  57394. /**
  57395. * Enforces a fixed size texture to ensure resize independant blur.
  57396. */
  57397. mainTextureFixedSize?: number;
  57398. /**
  57399. * How big is the kernel of the blur texture.
  57400. */
  57401. blurKernelSize: number;
  57402. /**
  57403. * The camera attached to the layer.
  57404. */
  57405. camera: Nullable<Camera>;
  57406. /**
  57407. * Enable MSAA by chosing the number of samples.
  57408. */
  57409. mainTextureSamples?: number;
  57410. /**
  57411. * The rendering group to draw the layer in.
  57412. */
  57413. renderingGroupId: number;
  57414. }
  57415. /**
  57416. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57417. *
  57418. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57419. *
  57420. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57421. */
  57422. export class GlowLayer extends EffectLayer {
  57423. /**
  57424. * Effect Name of the layer.
  57425. */
  57426. static readonly EffectName: string;
  57427. /**
  57428. * The default blur kernel size used for the glow.
  57429. */
  57430. static DefaultBlurKernelSize: number;
  57431. /**
  57432. * The default texture size ratio used for the glow.
  57433. */
  57434. static DefaultTextureRatio: number;
  57435. /**
  57436. * Sets the kernel size of the blur.
  57437. */
  57438. set blurKernelSize(value: number);
  57439. /**
  57440. * Gets the kernel size of the blur.
  57441. */
  57442. get blurKernelSize(): number;
  57443. /**
  57444. * Sets the glow intensity.
  57445. */
  57446. set intensity(value: number);
  57447. /**
  57448. * Gets the glow intensity.
  57449. */
  57450. get intensity(): number;
  57451. private _options;
  57452. private _intensity;
  57453. private _horizontalBlurPostprocess1;
  57454. private _verticalBlurPostprocess1;
  57455. private _horizontalBlurPostprocess2;
  57456. private _verticalBlurPostprocess2;
  57457. private _blurTexture1;
  57458. private _blurTexture2;
  57459. private _postProcesses1;
  57460. private _postProcesses2;
  57461. private _includedOnlyMeshes;
  57462. private _excludedMeshes;
  57463. private _meshesUsingTheirOwnMaterials;
  57464. /**
  57465. * Callback used to let the user override the color selection on a per mesh basis
  57466. */
  57467. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57468. /**
  57469. * Callback used to let the user override the texture selection on a per mesh basis
  57470. */
  57471. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57472. /**
  57473. * Instantiates a new glow Layer and references it to the scene.
  57474. * @param name The name of the layer
  57475. * @param scene The scene to use the layer in
  57476. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57477. */
  57478. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57479. /**
  57480. * Get the effect name of the layer.
  57481. * @return The effect name
  57482. */
  57483. getEffectName(): string;
  57484. /**
  57485. * Create the merge effect. This is the shader use to blit the information back
  57486. * to the main canvas at the end of the scene rendering.
  57487. */
  57488. protected _createMergeEffect(): Effect;
  57489. /**
  57490. * Creates the render target textures and post processes used in the glow layer.
  57491. */
  57492. protected _createTextureAndPostProcesses(): void;
  57493. /**
  57494. * Checks for the readiness of the element composing the layer.
  57495. * @param subMesh the mesh to check for
  57496. * @param useInstances specify wether or not to use instances to render the mesh
  57497. * @param emissiveTexture the associated emissive texture used to generate the glow
  57498. * @return true if ready otherwise, false
  57499. */
  57500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57501. /**
  57502. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57503. */
  57504. needStencil(): boolean;
  57505. /**
  57506. * Returns true if the mesh can be rendered, otherwise false.
  57507. * @param mesh The mesh to render
  57508. * @param material The material used on the mesh
  57509. * @returns true if it can be rendered otherwise false
  57510. */
  57511. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57512. /**
  57513. * Implementation specific of rendering the generating effect on the main canvas.
  57514. * @param effect The effect used to render through
  57515. */
  57516. protected _internalRender(effect: Effect): void;
  57517. /**
  57518. * Sets the required values for both the emissive texture and and the main color.
  57519. */
  57520. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57521. /**
  57522. * Returns true if the mesh should render, otherwise false.
  57523. * @param mesh The mesh to render
  57524. * @returns true if it should render otherwise false
  57525. */
  57526. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57527. /**
  57528. * Adds specific effects defines.
  57529. * @param defines The defines to add specifics to.
  57530. */
  57531. protected _addCustomEffectDefines(defines: string[]): void;
  57532. /**
  57533. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57534. * @param mesh The mesh to exclude from the glow layer
  57535. */
  57536. addExcludedMesh(mesh: Mesh): void;
  57537. /**
  57538. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57539. * @param mesh The mesh to remove
  57540. */
  57541. removeExcludedMesh(mesh: Mesh): void;
  57542. /**
  57543. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57544. * @param mesh The mesh to include in the glow layer
  57545. */
  57546. addIncludedOnlyMesh(mesh: Mesh): void;
  57547. /**
  57548. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57549. * @param mesh The mesh to remove
  57550. */
  57551. removeIncludedOnlyMesh(mesh: Mesh): void;
  57552. /**
  57553. * Determine if a given mesh will be used in the glow layer
  57554. * @param mesh The mesh to test
  57555. * @returns true if the mesh will be highlighted by the current glow layer
  57556. */
  57557. hasMesh(mesh: AbstractMesh): boolean;
  57558. /**
  57559. * Defines whether the current material of the mesh should be use to render the effect.
  57560. * @param mesh defines the current mesh to render
  57561. */
  57562. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57563. /**
  57564. * Add a mesh to be rendered through its own material and not with emissive only.
  57565. * @param mesh The mesh for which we need to use its material
  57566. */
  57567. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57568. /**
  57569. * Remove a mesh from being rendered through its own material and not with emissive only.
  57570. * @param mesh The mesh for which we need to not use its material
  57571. */
  57572. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57573. /**
  57574. * Free any resources and references associated to a mesh.
  57575. * Internal use
  57576. * @param mesh The mesh to free.
  57577. * @hidden
  57578. */
  57579. _disposeMesh(mesh: Mesh): void;
  57580. /**
  57581. * Gets the class name of the effect layer
  57582. * @returns the string with the class name of the effect layer
  57583. */
  57584. getClassName(): string;
  57585. /**
  57586. * Serializes this glow layer
  57587. * @returns a serialized glow layer object
  57588. */
  57589. serialize(): any;
  57590. /**
  57591. * Creates a Glow Layer from parsed glow layer data
  57592. * @param parsedGlowLayer defines glow layer data
  57593. * @param scene defines the current scene
  57594. * @param rootUrl defines the root URL containing the glow layer information
  57595. * @returns a parsed Glow Layer
  57596. */
  57597. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57598. }
  57599. }
  57600. declare module BABYLON {
  57601. /** @hidden */
  57602. export var glowBlurPostProcessPixelShader: {
  57603. name: string;
  57604. shader: string;
  57605. };
  57606. }
  57607. declare module BABYLON {
  57608. interface AbstractScene {
  57609. /**
  57610. * Return a the first highlight layer of the scene with a given name.
  57611. * @param name The name of the highlight layer to look for.
  57612. * @return The highlight layer if found otherwise null.
  57613. */
  57614. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57615. }
  57616. /**
  57617. * Highlight layer options. This helps customizing the behaviour
  57618. * of the highlight layer.
  57619. */
  57620. export interface IHighlightLayerOptions {
  57621. /**
  57622. * Multiplication factor apply to the canvas size to compute the render target size
  57623. * used to generated the glowing objects (the smaller the faster).
  57624. */
  57625. mainTextureRatio: number;
  57626. /**
  57627. * Enforces a fixed size texture to ensure resize independant blur.
  57628. */
  57629. mainTextureFixedSize?: number;
  57630. /**
  57631. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57632. * of the picture to blur (the smaller the faster).
  57633. */
  57634. blurTextureSizeRatio: number;
  57635. /**
  57636. * How big in texel of the blur texture is the vertical blur.
  57637. */
  57638. blurVerticalSize: number;
  57639. /**
  57640. * How big in texel of the blur texture is the horizontal blur.
  57641. */
  57642. blurHorizontalSize: number;
  57643. /**
  57644. * Alpha blending mode used to apply the blur. Default is combine.
  57645. */
  57646. alphaBlendingMode: number;
  57647. /**
  57648. * The camera attached to the layer.
  57649. */
  57650. camera: Nullable<Camera>;
  57651. /**
  57652. * Should we display highlight as a solid stroke?
  57653. */
  57654. isStroke?: boolean;
  57655. /**
  57656. * The rendering group to draw the layer in.
  57657. */
  57658. renderingGroupId: number;
  57659. }
  57660. /**
  57661. * The highlight layer Helps adding a glow effect around a mesh.
  57662. *
  57663. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57664. * glowy meshes to your scene.
  57665. *
  57666. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57667. */
  57668. export class HighlightLayer extends EffectLayer {
  57669. name: string;
  57670. /**
  57671. * Effect Name of the highlight layer.
  57672. */
  57673. static readonly EffectName: string;
  57674. /**
  57675. * The neutral color used during the preparation of the glow effect.
  57676. * This is black by default as the blend operation is a blend operation.
  57677. */
  57678. static NeutralColor: Color4;
  57679. /**
  57680. * Stencil value used for glowing meshes.
  57681. */
  57682. static GlowingMeshStencilReference: number;
  57683. /**
  57684. * Stencil value used for the other meshes in the scene.
  57685. */
  57686. static NormalMeshStencilReference: number;
  57687. /**
  57688. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57689. */
  57690. innerGlow: boolean;
  57691. /**
  57692. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57693. */
  57694. outerGlow: boolean;
  57695. /**
  57696. * Specifies the horizontal size of the blur.
  57697. */
  57698. set blurHorizontalSize(value: number);
  57699. /**
  57700. * Specifies the vertical size of the blur.
  57701. */
  57702. set blurVerticalSize(value: number);
  57703. /**
  57704. * Gets the horizontal size of the blur.
  57705. */
  57706. get blurHorizontalSize(): number;
  57707. /**
  57708. * Gets the vertical size of the blur.
  57709. */
  57710. get blurVerticalSize(): number;
  57711. /**
  57712. * An event triggered when the highlight layer is being blurred.
  57713. */
  57714. onBeforeBlurObservable: Observable<HighlightLayer>;
  57715. /**
  57716. * An event triggered when the highlight layer has been blurred.
  57717. */
  57718. onAfterBlurObservable: Observable<HighlightLayer>;
  57719. private _instanceGlowingMeshStencilReference;
  57720. private _options;
  57721. private _downSamplePostprocess;
  57722. private _horizontalBlurPostprocess;
  57723. private _verticalBlurPostprocess;
  57724. private _blurTexture;
  57725. private _meshes;
  57726. private _excludedMeshes;
  57727. /**
  57728. * Instantiates a new highlight Layer and references it to the scene..
  57729. * @param name The name of the layer
  57730. * @param scene The scene to use the layer in
  57731. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57732. */
  57733. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57734. /**
  57735. * Get the effect name of the layer.
  57736. * @return The effect name
  57737. */
  57738. getEffectName(): string;
  57739. /**
  57740. * Create the merge effect. This is the shader use to blit the information back
  57741. * to the main canvas at the end of the scene rendering.
  57742. */
  57743. protected _createMergeEffect(): Effect;
  57744. /**
  57745. * Creates the render target textures and post processes used in the highlight layer.
  57746. */
  57747. protected _createTextureAndPostProcesses(): void;
  57748. /**
  57749. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57750. */
  57751. needStencil(): boolean;
  57752. /**
  57753. * Checks for the readiness of the element composing the layer.
  57754. * @param subMesh the mesh to check for
  57755. * @param useInstances specify wether or not to use instances to render the mesh
  57756. * @param emissiveTexture the associated emissive texture used to generate the glow
  57757. * @return true if ready otherwise, false
  57758. */
  57759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57760. /**
  57761. * Implementation specific of rendering the generating effect on the main canvas.
  57762. * @param effect The effect used to render through
  57763. */
  57764. protected _internalRender(effect: Effect): void;
  57765. /**
  57766. * Returns true if the layer contains information to display, otherwise false.
  57767. */
  57768. shouldRender(): boolean;
  57769. /**
  57770. * Returns true if the mesh should render, otherwise false.
  57771. * @param mesh The mesh to render
  57772. * @returns true if it should render otherwise false
  57773. */
  57774. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57775. /**
  57776. * Returns true if the mesh can be rendered, otherwise false.
  57777. * @param mesh The mesh to render
  57778. * @param material The material used on the mesh
  57779. * @returns true if it can be rendered otherwise false
  57780. */
  57781. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57782. /**
  57783. * Adds specific effects defines.
  57784. * @param defines The defines to add specifics to.
  57785. */
  57786. protected _addCustomEffectDefines(defines: string[]): void;
  57787. /**
  57788. * Sets the required values for both the emissive texture and and the main color.
  57789. */
  57790. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57791. /**
  57792. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57793. * @param mesh The mesh to exclude from the highlight layer
  57794. */
  57795. addExcludedMesh(mesh: Mesh): void;
  57796. /**
  57797. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57798. * @param mesh The mesh to highlight
  57799. */
  57800. removeExcludedMesh(mesh: Mesh): void;
  57801. /**
  57802. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57803. * @param mesh mesh to test
  57804. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57805. */
  57806. hasMesh(mesh: AbstractMesh): boolean;
  57807. /**
  57808. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57809. * @param mesh The mesh to highlight
  57810. * @param color The color of the highlight
  57811. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57812. */
  57813. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57814. /**
  57815. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57816. * @param mesh The mesh to highlight
  57817. */
  57818. removeMesh(mesh: Mesh): void;
  57819. /**
  57820. * Remove all the meshes currently referenced in the highlight layer
  57821. */
  57822. removeAllMeshes(): void;
  57823. /**
  57824. * Force the stencil to the normal expected value for none glowing parts
  57825. */
  57826. private _defaultStencilReference;
  57827. /**
  57828. * Free any resources and references associated to a mesh.
  57829. * Internal use
  57830. * @param mesh The mesh to free.
  57831. * @hidden
  57832. */
  57833. _disposeMesh(mesh: Mesh): void;
  57834. /**
  57835. * Dispose the highlight layer and free resources.
  57836. */
  57837. dispose(): void;
  57838. /**
  57839. * Gets the class name of the effect layer
  57840. * @returns the string with the class name of the effect layer
  57841. */
  57842. getClassName(): string;
  57843. /**
  57844. * Serializes this Highlight layer
  57845. * @returns a serialized Highlight layer object
  57846. */
  57847. serialize(): any;
  57848. /**
  57849. * Creates a Highlight layer from parsed Highlight layer data
  57850. * @param parsedHightlightLayer defines the Highlight layer data
  57851. * @param scene defines the current scene
  57852. * @param rootUrl defines the root URL containing the Highlight layer information
  57853. * @returns a parsed Highlight layer
  57854. */
  57855. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57856. }
  57857. }
  57858. declare module BABYLON {
  57859. interface AbstractScene {
  57860. /**
  57861. * The list of layers (background and foreground) of the scene
  57862. */
  57863. layers: Array<Layer>;
  57864. }
  57865. /**
  57866. * Defines the layer scene component responsible to manage any layers
  57867. * in a given scene.
  57868. */
  57869. export class LayerSceneComponent implements ISceneComponent {
  57870. /**
  57871. * The component name helpfull to identify the component in the list of scene components.
  57872. */
  57873. readonly name: string;
  57874. /**
  57875. * The scene the component belongs to.
  57876. */
  57877. scene: Scene;
  57878. private _engine;
  57879. /**
  57880. * Creates a new instance of the component for the given scene
  57881. * @param scene Defines the scene to register the component in
  57882. */
  57883. constructor(scene: Scene);
  57884. /**
  57885. * Registers the component in a given scene
  57886. */
  57887. register(): void;
  57888. /**
  57889. * Rebuilds the elements related to this component in case of
  57890. * context lost for instance.
  57891. */
  57892. rebuild(): void;
  57893. /**
  57894. * Disposes the component and the associated ressources.
  57895. */
  57896. dispose(): void;
  57897. private _draw;
  57898. private _drawCameraPredicate;
  57899. private _drawCameraBackground;
  57900. private _drawCameraForeground;
  57901. private _drawRenderTargetPredicate;
  57902. private _drawRenderTargetBackground;
  57903. private _drawRenderTargetForeground;
  57904. /**
  57905. * Adds all the elements from the container to the scene
  57906. * @param container the container holding the elements
  57907. */
  57908. addFromContainer(container: AbstractScene): void;
  57909. /**
  57910. * Removes all the elements in the container from the scene
  57911. * @param container contains the elements to remove
  57912. * @param dispose if the removed element should be disposed (default: false)
  57913. */
  57914. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57915. }
  57916. }
  57917. declare module BABYLON {
  57918. /** @hidden */
  57919. export var layerPixelShader: {
  57920. name: string;
  57921. shader: string;
  57922. };
  57923. }
  57924. declare module BABYLON {
  57925. /** @hidden */
  57926. export var layerVertexShader: {
  57927. name: string;
  57928. shader: string;
  57929. };
  57930. }
  57931. declare module BABYLON {
  57932. /**
  57933. * This represents a full screen 2d layer.
  57934. * This can be useful to display a picture in the background of your scene for instance.
  57935. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57936. */
  57937. export class Layer {
  57938. /**
  57939. * Define the name of the layer.
  57940. */
  57941. name: string;
  57942. /**
  57943. * Define the texture the layer should display.
  57944. */
  57945. texture: Nullable<Texture>;
  57946. /**
  57947. * Is the layer in background or foreground.
  57948. */
  57949. isBackground: boolean;
  57950. /**
  57951. * Define the color of the layer (instead of texture).
  57952. */
  57953. color: Color4;
  57954. /**
  57955. * Define the scale of the layer in order to zoom in out of the texture.
  57956. */
  57957. scale: Vector2;
  57958. /**
  57959. * Define an offset for the layer in order to shift the texture.
  57960. */
  57961. offset: Vector2;
  57962. /**
  57963. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57964. */
  57965. alphaBlendingMode: number;
  57966. /**
  57967. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57968. * Alpha test will not mix with the background color in case of transparency.
  57969. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57970. */
  57971. alphaTest: boolean;
  57972. /**
  57973. * Define a mask to restrict the layer to only some of the scene cameras.
  57974. */
  57975. layerMask: number;
  57976. /**
  57977. * Define the list of render target the layer is visible into.
  57978. */
  57979. renderTargetTextures: RenderTargetTexture[];
  57980. /**
  57981. * Define if the layer is only used in renderTarget or if it also
  57982. * renders in the main frame buffer of the canvas.
  57983. */
  57984. renderOnlyInRenderTargetTextures: boolean;
  57985. private _scene;
  57986. private _vertexBuffers;
  57987. private _indexBuffer;
  57988. private _effect;
  57989. private _previousDefines;
  57990. /**
  57991. * An event triggered when the layer is disposed.
  57992. */
  57993. onDisposeObservable: Observable<Layer>;
  57994. private _onDisposeObserver;
  57995. /**
  57996. * Back compatibility with callback before the onDisposeObservable existed.
  57997. * The set callback will be triggered when the layer has been disposed.
  57998. */
  57999. set onDispose(callback: () => void);
  58000. /**
  58001. * An event triggered before rendering the scene
  58002. */
  58003. onBeforeRenderObservable: Observable<Layer>;
  58004. private _onBeforeRenderObserver;
  58005. /**
  58006. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58007. * The set callback will be triggered just before rendering the layer.
  58008. */
  58009. set onBeforeRender(callback: () => void);
  58010. /**
  58011. * An event triggered after rendering the scene
  58012. */
  58013. onAfterRenderObservable: Observable<Layer>;
  58014. private _onAfterRenderObserver;
  58015. /**
  58016. * Back compatibility with callback before the onAfterRenderObservable existed.
  58017. * The set callback will be triggered just after rendering the layer.
  58018. */
  58019. set onAfterRender(callback: () => void);
  58020. /**
  58021. * Instantiates a new layer.
  58022. * This represents a full screen 2d layer.
  58023. * This can be useful to display a picture in the background of your scene for instance.
  58024. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58025. * @param name Define the name of the layer in the scene
  58026. * @param imgUrl Define the url of the texture to display in the layer
  58027. * @param scene Define the scene the layer belongs to
  58028. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58029. * @param color Defines a color for the layer
  58030. */
  58031. constructor(
  58032. /**
  58033. * Define the name of the layer.
  58034. */
  58035. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58036. private _createIndexBuffer;
  58037. /** @hidden */
  58038. _rebuild(): void;
  58039. /**
  58040. * Renders the layer in the scene.
  58041. */
  58042. render(): void;
  58043. /**
  58044. * Disposes and releases the associated ressources.
  58045. */
  58046. dispose(): void;
  58047. }
  58048. }
  58049. declare module BABYLON {
  58050. /** @hidden */
  58051. export var lensFlarePixelShader: {
  58052. name: string;
  58053. shader: string;
  58054. };
  58055. }
  58056. declare module BABYLON {
  58057. /** @hidden */
  58058. export var lensFlareVertexShader: {
  58059. name: string;
  58060. shader: string;
  58061. };
  58062. }
  58063. declare module BABYLON {
  58064. /**
  58065. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58066. * It is usually composed of several `lensFlare`.
  58067. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58068. */
  58069. export class LensFlareSystem {
  58070. /**
  58071. * Define the name of the lens flare system
  58072. */
  58073. name: string;
  58074. /**
  58075. * List of lens flares used in this system.
  58076. */
  58077. lensFlares: LensFlare[];
  58078. /**
  58079. * Define a limit from the border the lens flare can be visible.
  58080. */
  58081. borderLimit: number;
  58082. /**
  58083. * Define a viewport border we do not want to see the lens flare in.
  58084. */
  58085. viewportBorder: number;
  58086. /**
  58087. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58088. */
  58089. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58090. /**
  58091. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58092. */
  58093. layerMask: number;
  58094. /**
  58095. * Define the id of the lens flare system in the scene.
  58096. * (equal to name by default)
  58097. */
  58098. id: string;
  58099. private _scene;
  58100. private _emitter;
  58101. private _vertexBuffers;
  58102. private _indexBuffer;
  58103. private _effect;
  58104. private _positionX;
  58105. private _positionY;
  58106. private _isEnabled;
  58107. /** @hidden */
  58108. static _SceneComponentInitialization: (scene: Scene) => void;
  58109. /**
  58110. * Instantiates a lens flare system.
  58111. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58112. * It is usually composed of several `lensFlare`.
  58113. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58114. * @param name Define the name of the lens flare system in the scene
  58115. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58116. * @param scene Define the scene the lens flare system belongs to
  58117. */
  58118. constructor(
  58119. /**
  58120. * Define the name of the lens flare system
  58121. */
  58122. name: string, emitter: any, scene: Scene);
  58123. /**
  58124. * Define if the lens flare system is enabled.
  58125. */
  58126. get isEnabled(): boolean;
  58127. set isEnabled(value: boolean);
  58128. /**
  58129. * Get the scene the effects belongs to.
  58130. * @returns the scene holding the lens flare system
  58131. */
  58132. getScene(): Scene;
  58133. /**
  58134. * Get the emitter of the lens flare system.
  58135. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58136. * @returns the emitter of the lens flare system
  58137. */
  58138. getEmitter(): any;
  58139. /**
  58140. * Set the emitter of the lens flare system.
  58141. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58142. * @param newEmitter Define the new emitter of the system
  58143. */
  58144. setEmitter(newEmitter: any): void;
  58145. /**
  58146. * Get the lens flare system emitter position.
  58147. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58148. * @returns the position
  58149. */
  58150. getEmitterPosition(): Vector3;
  58151. /**
  58152. * @hidden
  58153. */
  58154. computeEffectivePosition(globalViewport: Viewport): boolean;
  58155. /** @hidden */
  58156. _isVisible(): boolean;
  58157. /**
  58158. * @hidden
  58159. */
  58160. render(): boolean;
  58161. /**
  58162. * Dispose and release the lens flare with its associated resources.
  58163. */
  58164. dispose(): void;
  58165. /**
  58166. * Parse a lens flare system from a JSON repressentation
  58167. * @param parsedLensFlareSystem Define the JSON to parse
  58168. * @param scene Define the scene the parsed system should be instantiated in
  58169. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58170. * @returns the parsed system
  58171. */
  58172. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58173. /**
  58174. * Serialize the current Lens Flare System into a JSON representation.
  58175. * @returns the serialized JSON
  58176. */
  58177. serialize(): any;
  58178. }
  58179. }
  58180. declare module BABYLON {
  58181. /**
  58182. * This represents one of the lens effect in a `lensFlareSystem`.
  58183. * It controls one of the indiviual texture used in the effect.
  58184. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58185. */
  58186. export class LensFlare {
  58187. /**
  58188. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58189. */
  58190. size: number;
  58191. /**
  58192. * 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.
  58193. */
  58194. position: number;
  58195. /**
  58196. * Define the lens color.
  58197. */
  58198. color: Color3;
  58199. /**
  58200. * Define the lens texture.
  58201. */
  58202. texture: Nullable<Texture>;
  58203. /**
  58204. * Define the alpha mode to render this particular lens.
  58205. */
  58206. alphaMode: number;
  58207. private _system;
  58208. /**
  58209. * Creates a new Lens Flare.
  58210. * This represents one of the lens effect in a `lensFlareSystem`.
  58211. * It controls one of the indiviual texture used in the effect.
  58212. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58213. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58214. * @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.
  58215. * @param color Define the lens color
  58216. * @param imgUrl Define the lens texture url
  58217. * @param system Define the `lensFlareSystem` this flare is part of
  58218. * @returns The newly created Lens Flare
  58219. */
  58220. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58221. /**
  58222. * Instantiates a new Lens Flare.
  58223. * This represents one of the lens effect in a `lensFlareSystem`.
  58224. * It controls one of the indiviual texture used in the effect.
  58225. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58226. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58227. * @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.
  58228. * @param color Define the lens color
  58229. * @param imgUrl Define the lens texture url
  58230. * @param system Define the `lensFlareSystem` this flare is part of
  58231. */
  58232. constructor(
  58233. /**
  58234. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58235. */
  58236. size: number,
  58237. /**
  58238. * 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.
  58239. */
  58240. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58241. /**
  58242. * Dispose and release the lens flare with its associated resources.
  58243. */
  58244. dispose(): void;
  58245. }
  58246. }
  58247. declare module BABYLON {
  58248. interface AbstractScene {
  58249. /**
  58250. * The list of lens flare system added to the scene
  58251. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58252. */
  58253. lensFlareSystems: Array<LensFlareSystem>;
  58254. /**
  58255. * Removes the given lens flare system from this scene.
  58256. * @param toRemove The lens flare system to remove
  58257. * @returns The index of the removed lens flare system
  58258. */
  58259. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58260. /**
  58261. * Adds the given lens flare system to this scene
  58262. * @param newLensFlareSystem The lens flare system to add
  58263. */
  58264. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58265. /**
  58266. * Gets a lens flare system using its name
  58267. * @param name defines the name to look for
  58268. * @returns the lens flare system or null if not found
  58269. */
  58270. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58271. /**
  58272. * Gets a lens flare system using its id
  58273. * @param id defines the id to look for
  58274. * @returns the lens flare system or null if not found
  58275. */
  58276. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58277. }
  58278. /**
  58279. * Defines the lens flare scene component responsible to manage any lens flares
  58280. * in a given scene.
  58281. */
  58282. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58283. /**
  58284. * The component name helpfull to identify the component in the list of scene components.
  58285. */
  58286. readonly name: string;
  58287. /**
  58288. * The scene the component belongs to.
  58289. */
  58290. scene: Scene;
  58291. /**
  58292. * Creates a new instance of the component for the given scene
  58293. * @param scene Defines the scene to register the component in
  58294. */
  58295. constructor(scene: Scene);
  58296. /**
  58297. * Registers the component in a given scene
  58298. */
  58299. register(): void;
  58300. /**
  58301. * Rebuilds the elements related to this component in case of
  58302. * context lost for instance.
  58303. */
  58304. rebuild(): void;
  58305. /**
  58306. * Adds all the elements from the container to the scene
  58307. * @param container the container holding the elements
  58308. */
  58309. addFromContainer(container: AbstractScene): void;
  58310. /**
  58311. * Removes all the elements in the container from the scene
  58312. * @param container contains the elements to remove
  58313. * @param dispose if the removed element should be disposed (default: false)
  58314. */
  58315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58316. /**
  58317. * Serializes the component data to the specified json object
  58318. * @param serializationObject The object to serialize to
  58319. */
  58320. serialize(serializationObject: any): void;
  58321. /**
  58322. * Disposes the component and the associated ressources.
  58323. */
  58324. dispose(): void;
  58325. private _draw;
  58326. }
  58327. }
  58328. declare module BABYLON {
  58329. /** @hidden */
  58330. export var depthPixelShader: {
  58331. name: string;
  58332. shader: string;
  58333. };
  58334. }
  58335. declare module BABYLON {
  58336. /** @hidden */
  58337. export var depthVertexShader: {
  58338. name: string;
  58339. shader: string;
  58340. };
  58341. }
  58342. declare module BABYLON {
  58343. /**
  58344. * This represents a depth renderer in Babylon.
  58345. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58346. */
  58347. export class DepthRenderer {
  58348. private _scene;
  58349. private _depthMap;
  58350. private _effect;
  58351. private readonly _storeNonLinearDepth;
  58352. private readonly _clearColor;
  58353. /** Get if the depth renderer is using packed depth or not */
  58354. readonly isPacked: boolean;
  58355. private _cachedDefines;
  58356. private _camera;
  58357. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58358. enabled: boolean;
  58359. /**
  58360. * Specifiess that the depth renderer will only be used within
  58361. * the camera it is created for.
  58362. * This can help forcing its rendering during the camera processing.
  58363. */
  58364. useOnlyInActiveCamera: boolean;
  58365. /** @hidden */
  58366. static _SceneComponentInitialization: (scene: Scene) => void;
  58367. /**
  58368. * Instantiates a depth renderer
  58369. * @param scene The scene the renderer belongs to
  58370. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58371. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58372. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58373. */
  58374. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58375. /**
  58376. * Creates the depth rendering effect and checks if the effect is ready.
  58377. * @param subMesh The submesh to be used to render the depth map of
  58378. * @param useInstances If multiple world instances should be used
  58379. * @returns if the depth renderer is ready to render the depth map
  58380. */
  58381. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58382. /**
  58383. * Gets the texture which the depth map will be written to.
  58384. * @returns The depth map texture
  58385. */
  58386. getDepthMap(): RenderTargetTexture;
  58387. /**
  58388. * Disposes of the depth renderer.
  58389. */
  58390. dispose(): void;
  58391. }
  58392. }
  58393. declare module BABYLON {
  58394. /** @hidden */
  58395. export var minmaxReduxPixelShader: {
  58396. name: string;
  58397. shader: string;
  58398. };
  58399. }
  58400. declare module BABYLON {
  58401. /**
  58402. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58403. * and maximum values from all values of the texture.
  58404. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58405. * The source values are read from the red channel of the texture.
  58406. */
  58407. export class MinMaxReducer {
  58408. /**
  58409. * Observable triggered when the computation has been performed
  58410. */
  58411. onAfterReductionPerformed: Observable<{
  58412. min: number;
  58413. max: number;
  58414. }>;
  58415. protected _camera: Camera;
  58416. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58417. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58418. protected _postProcessManager: PostProcessManager;
  58419. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58420. protected _forceFullscreenViewport: boolean;
  58421. /**
  58422. * Creates a min/max reducer
  58423. * @param camera The camera to use for the post processes
  58424. */
  58425. constructor(camera: Camera);
  58426. /**
  58427. * Gets the texture used to read the values from.
  58428. */
  58429. get sourceTexture(): Nullable<RenderTargetTexture>;
  58430. /**
  58431. * Sets the source texture to read the values from.
  58432. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58433. * because in such textures '1' value must not be taken into account to compute the maximum
  58434. * as this value is used to clear the texture.
  58435. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58436. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58437. * @param depthRedux Indicates if the texture is a depth texture or not
  58438. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58439. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58440. */
  58441. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58442. /**
  58443. * Defines the refresh rate of the computation.
  58444. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58445. */
  58446. get refreshRate(): number;
  58447. set refreshRate(value: number);
  58448. protected _activated: boolean;
  58449. /**
  58450. * Gets the activation status of the reducer
  58451. */
  58452. get activated(): boolean;
  58453. /**
  58454. * Activates the reduction computation.
  58455. * When activated, the observers registered in onAfterReductionPerformed are
  58456. * called after the compuation is performed
  58457. */
  58458. activate(): void;
  58459. /**
  58460. * Deactivates the reduction computation.
  58461. */
  58462. deactivate(): void;
  58463. /**
  58464. * Disposes the min/max reducer
  58465. * @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.
  58466. */
  58467. dispose(disposeAll?: boolean): void;
  58468. }
  58469. }
  58470. declare module BABYLON {
  58471. /**
  58472. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58473. */
  58474. export class DepthReducer extends MinMaxReducer {
  58475. private _depthRenderer;
  58476. private _depthRendererId;
  58477. /**
  58478. * Gets the depth renderer used for the computation.
  58479. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58480. */
  58481. get depthRenderer(): Nullable<DepthRenderer>;
  58482. /**
  58483. * Creates a depth reducer
  58484. * @param camera The camera used to render the depth texture
  58485. */
  58486. constructor(camera: Camera);
  58487. /**
  58488. * Sets the depth renderer to use to generate the depth map
  58489. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58490. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58491. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58492. */
  58493. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58494. /** @hidden */
  58495. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58496. /**
  58497. * Activates the reduction computation.
  58498. * When activated, the observers registered in onAfterReductionPerformed are
  58499. * called after the compuation is performed
  58500. */
  58501. activate(): void;
  58502. /**
  58503. * Deactivates the reduction computation.
  58504. */
  58505. deactivate(): void;
  58506. /**
  58507. * Disposes the depth reducer
  58508. * @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.
  58509. */
  58510. dispose(disposeAll?: boolean): void;
  58511. }
  58512. }
  58513. declare module BABYLON {
  58514. /**
  58515. * A CSM implementation allowing casting shadows on large scenes.
  58516. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58517. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58518. */
  58519. export class CascadedShadowGenerator extends ShadowGenerator {
  58520. private static readonly frustumCornersNDCSpace;
  58521. /**
  58522. * Name of the CSM class
  58523. */
  58524. static CLASSNAME: string;
  58525. /**
  58526. * Defines the default number of cascades used by the CSM.
  58527. */
  58528. static readonly DEFAULT_CASCADES_COUNT: number;
  58529. /**
  58530. * Defines the minimum number of cascades used by the CSM.
  58531. */
  58532. static readonly MIN_CASCADES_COUNT: number;
  58533. /**
  58534. * Defines the maximum number of cascades used by the CSM.
  58535. */
  58536. static readonly MAX_CASCADES_COUNT: number;
  58537. protected _validateFilter(filter: number): number;
  58538. /**
  58539. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58540. */
  58541. penumbraDarkness: number;
  58542. private _numCascades;
  58543. /**
  58544. * Gets or set the number of cascades used by the CSM.
  58545. */
  58546. get numCascades(): number;
  58547. set numCascades(value: number);
  58548. /**
  58549. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58550. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58551. */
  58552. stabilizeCascades: boolean;
  58553. private _freezeShadowCastersBoundingInfo;
  58554. private _freezeShadowCastersBoundingInfoObservable;
  58555. /**
  58556. * Enables or disables the shadow casters bounding info computation.
  58557. * If your shadow casters don't move, you can disable this feature.
  58558. * If it is enabled, the bounding box computation is done every frame.
  58559. */
  58560. get freezeShadowCastersBoundingInfo(): boolean;
  58561. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58562. private _scbiMin;
  58563. private _scbiMax;
  58564. protected _computeShadowCastersBoundingInfo(): void;
  58565. protected _shadowCastersBoundingInfo: BoundingInfo;
  58566. /**
  58567. * Gets or sets the shadow casters bounding info.
  58568. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58569. * so that the system won't overwrite the bounds you provide
  58570. */
  58571. get shadowCastersBoundingInfo(): BoundingInfo;
  58572. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58573. protected _breaksAreDirty: boolean;
  58574. protected _minDistance: number;
  58575. protected _maxDistance: number;
  58576. /**
  58577. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58578. *
  58579. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58580. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58581. * @param min minimal distance for the breaks (default to 0.)
  58582. * @param max maximal distance for the breaks (default to 1.)
  58583. */
  58584. setMinMaxDistance(min: number, max: number): void;
  58585. /** Gets the minimal distance used in the cascade break computation */
  58586. get minDistance(): number;
  58587. /** Gets the maximal distance used in the cascade break computation */
  58588. get maxDistance(): number;
  58589. /**
  58590. * Gets the class name of that object
  58591. * @returns "CascadedShadowGenerator"
  58592. */
  58593. getClassName(): string;
  58594. private _cascadeMinExtents;
  58595. private _cascadeMaxExtents;
  58596. /**
  58597. * Gets a cascade minimum extents
  58598. * @param cascadeIndex index of the cascade
  58599. * @returns the minimum cascade extents
  58600. */
  58601. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58602. /**
  58603. * Gets a cascade maximum extents
  58604. * @param cascadeIndex index of the cascade
  58605. * @returns the maximum cascade extents
  58606. */
  58607. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58608. private _cascades;
  58609. private _currentLayer;
  58610. private _viewSpaceFrustumsZ;
  58611. private _viewMatrices;
  58612. private _projectionMatrices;
  58613. private _transformMatrices;
  58614. private _transformMatricesAsArray;
  58615. private _frustumLengths;
  58616. private _lightSizeUVCorrection;
  58617. private _depthCorrection;
  58618. private _frustumCornersWorldSpace;
  58619. private _frustumCenter;
  58620. private _shadowCameraPos;
  58621. private _shadowMaxZ;
  58622. /**
  58623. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58624. * It defaults to camera.maxZ
  58625. */
  58626. get shadowMaxZ(): number;
  58627. /**
  58628. * Sets the shadow max z distance.
  58629. */
  58630. set shadowMaxZ(value: number);
  58631. protected _debug: boolean;
  58632. /**
  58633. * Gets or sets the debug flag.
  58634. * When enabled, the cascades are materialized by different colors on the screen.
  58635. */
  58636. get debug(): boolean;
  58637. set debug(dbg: boolean);
  58638. private _depthClamp;
  58639. /**
  58640. * Gets or sets the depth clamping value.
  58641. *
  58642. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58643. * to account for the shadow casters far away.
  58644. *
  58645. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58646. */
  58647. get depthClamp(): boolean;
  58648. set depthClamp(value: boolean);
  58649. private _cascadeBlendPercentage;
  58650. /**
  58651. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58652. * It defaults to 0.1 (10% blending).
  58653. */
  58654. get cascadeBlendPercentage(): number;
  58655. set cascadeBlendPercentage(value: number);
  58656. private _lambda;
  58657. /**
  58658. * Gets or set the lambda parameter.
  58659. * This parameter is used to split the camera frustum and create the cascades.
  58660. * 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.
  58661. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58662. */
  58663. get lambda(): number;
  58664. set lambda(value: number);
  58665. /**
  58666. * Gets the view matrix corresponding to a given cascade
  58667. * @param cascadeNum cascade to retrieve the view matrix from
  58668. * @returns the cascade view matrix
  58669. */
  58670. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58671. /**
  58672. * Gets the projection matrix corresponding to a given cascade
  58673. * @param cascadeNum cascade to retrieve the projection matrix from
  58674. * @returns the cascade projection matrix
  58675. */
  58676. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58677. /**
  58678. * Gets the transformation matrix corresponding to a given cascade
  58679. * @param cascadeNum cascade to retrieve the transformation matrix from
  58680. * @returns the cascade transformation matrix
  58681. */
  58682. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58683. private _depthRenderer;
  58684. /**
  58685. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58686. *
  58687. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58688. *
  58689. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58690. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58691. * @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
  58692. */
  58693. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58694. private _depthReducer;
  58695. private _autoCalcDepthBounds;
  58696. /**
  58697. * Gets or sets the autoCalcDepthBounds property.
  58698. *
  58699. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58700. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58701. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58702. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58703. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58704. */
  58705. get autoCalcDepthBounds(): boolean;
  58706. set autoCalcDepthBounds(value: boolean);
  58707. /**
  58708. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58709. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58710. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58711. * for setting the refresh rate on the renderer yourself!
  58712. */
  58713. get autoCalcDepthBoundsRefreshRate(): number;
  58714. set autoCalcDepthBoundsRefreshRate(value: number);
  58715. /**
  58716. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58717. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58718. * you change the camera near/far planes!
  58719. */
  58720. splitFrustum(): void;
  58721. private _splitFrustum;
  58722. private _computeMatrices;
  58723. private _computeFrustumInWorldSpace;
  58724. private _computeCascadeFrustum;
  58725. /**
  58726. * Support test.
  58727. */
  58728. static get IsSupported(): boolean;
  58729. /** @hidden */
  58730. static _SceneComponentInitialization: (scene: Scene) => void;
  58731. /**
  58732. * Creates a Cascaded Shadow Generator object.
  58733. * A ShadowGenerator is the required tool to use the shadows.
  58734. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58735. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58736. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58737. * @param light The directional light object generating the shadows.
  58738. * @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.
  58739. */
  58740. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58741. protected _initializeGenerator(): void;
  58742. protected _createTargetRenderTexture(): void;
  58743. protected _initializeShadowMap(): void;
  58744. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58745. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58746. /**
  58747. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58748. * @param defines Defines of the material we want to update
  58749. * @param lightIndex Index of the light in the enabled light list of the material
  58750. */
  58751. prepareDefines(defines: any, lightIndex: number): void;
  58752. /**
  58753. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58754. * defined in the generator but impacting the effect).
  58755. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58756. * @param effect The effect we are binfing the information for
  58757. */
  58758. bindShadowLight(lightIndex: string, effect: Effect): void;
  58759. /**
  58760. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58761. * (eq to view projection * shadow projection matrices)
  58762. * @returns The transform matrix used to create the shadow map
  58763. */
  58764. getTransformMatrix(): Matrix;
  58765. /**
  58766. * Disposes the ShadowGenerator.
  58767. * Returns nothing.
  58768. */
  58769. dispose(): void;
  58770. /**
  58771. * Serializes the shadow generator setup to a json object.
  58772. * @returns The serialized JSON object
  58773. */
  58774. serialize(): any;
  58775. /**
  58776. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58777. * @param parsedShadowGenerator The JSON object to parse
  58778. * @param scene The scene to create the shadow map for
  58779. * @returns The parsed shadow generator
  58780. */
  58781. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58782. }
  58783. }
  58784. declare module BABYLON {
  58785. /**
  58786. * Defines the shadow generator component responsible to manage any shadow generators
  58787. * in a given scene.
  58788. */
  58789. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58790. /**
  58791. * The component name helpfull to identify the component in the list of scene components.
  58792. */
  58793. readonly name: string;
  58794. /**
  58795. * The scene the component belongs to.
  58796. */
  58797. scene: Scene;
  58798. /**
  58799. * Creates a new instance of the component for the given scene
  58800. * @param scene Defines the scene to register the component in
  58801. */
  58802. constructor(scene: Scene);
  58803. /**
  58804. * Registers the component in a given scene
  58805. */
  58806. register(): void;
  58807. /**
  58808. * Rebuilds the elements related to this component in case of
  58809. * context lost for instance.
  58810. */
  58811. rebuild(): void;
  58812. /**
  58813. * Serializes the component data to the specified json object
  58814. * @param serializationObject The object to serialize to
  58815. */
  58816. serialize(serializationObject: any): void;
  58817. /**
  58818. * Adds all the elements from the container to the scene
  58819. * @param container the container holding the elements
  58820. */
  58821. addFromContainer(container: AbstractScene): void;
  58822. /**
  58823. * Removes all the elements in the container from the scene
  58824. * @param container contains the elements to remove
  58825. * @param dispose if the removed element should be disposed (default: false)
  58826. */
  58827. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58828. /**
  58829. * Rebuilds the elements related to this component in case of
  58830. * context lost for instance.
  58831. */
  58832. dispose(): void;
  58833. private _gatherRenderTargets;
  58834. }
  58835. }
  58836. declare module BABYLON {
  58837. /**
  58838. * A point light is a light defined by an unique point in world space.
  58839. * The light is emitted in every direction from this point.
  58840. * A good example of a point light is a standard light bulb.
  58841. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58842. */
  58843. export class PointLight extends ShadowLight {
  58844. private _shadowAngle;
  58845. /**
  58846. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58847. * This specifies what angle the shadow will use to be created.
  58848. *
  58849. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58850. */
  58851. get shadowAngle(): number;
  58852. /**
  58853. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58854. * This specifies what angle the shadow will use to be created.
  58855. *
  58856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58857. */
  58858. set shadowAngle(value: number);
  58859. /**
  58860. * Gets the direction if it has been set.
  58861. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58862. */
  58863. get direction(): Vector3;
  58864. /**
  58865. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58866. */
  58867. set direction(value: Vector3);
  58868. /**
  58869. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58870. * A PointLight emits the light in every direction.
  58871. * It can cast shadows.
  58872. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58873. * ```javascript
  58874. * var pointLight = new PointLight("pl", camera.position, scene);
  58875. * ```
  58876. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58877. * @param name The light friendly name
  58878. * @param position The position of the point light in the scene
  58879. * @param scene The scene the lights belongs to
  58880. */
  58881. constructor(name: string, position: Vector3, scene: Scene);
  58882. /**
  58883. * Returns the string "PointLight"
  58884. * @returns the class name
  58885. */
  58886. getClassName(): string;
  58887. /**
  58888. * Returns the integer 0.
  58889. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58890. */
  58891. getTypeID(): number;
  58892. /**
  58893. * Specifies wether or not the shadowmap should be a cube texture.
  58894. * @returns true if the shadowmap needs to be a cube texture.
  58895. */
  58896. needCube(): boolean;
  58897. /**
  58898. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58899. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58900. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58901. */
  58902. getShadowDirection(faceIndex?: number): Vector3;
  58903. /**
  58904. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58905. * - fov = PI / 2
  58906. * - aspect ratio : 1.0
  58907. * - z-near and far equal to the active camera minZ and maxZ.
  58908. * Returns the PointLight.
  58909. */
  58910. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58911. protected _buildUniformLayout(): void;
  58912. /**
  58913. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58914. * @param effect The effect to update
  58915. * @param lightIndex The index of the light in the effect to update
  58916. * @returns The point light
  58917. */
  58918. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58919. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58920. /**
  58921. * Prepares the list of defines specific to the light type.
  58922. * @param defines the list of defines
  58923. * @param lightIndex defines the index of the light for the effect
  58924. */
  58925. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58926. }
  58927. }
  58928. declare module BABYLON {
  58929. /**
  58930. * Header information of HDR texture files.
  58931. */
  58932. export interface HDRInfo {
  58933. /**
  58934. * The height of the texture in pixels.
  58935. */
  58936. height: number;
  58937. /**
  58938. * The width of the texture in pixels.
  58939. */
  58940. width: number;
  58941. /**
  58942. * The index of the beginning of the data in the binary file.
  58943. */
  58944. dataPosition: number;
  58945. }
  58946. /**
  58947. * This groups tools to convert HDR texture to native colors array.
  58948. */
  58949. export class HDRTools {
  58950. private static Ldexp;
  58951. private static Rgbe2float;
  58952. private static readStringLine;
  58953. /**
  58954. * Reads header information from an RGBE texture stored in a native array.
  58955. * More information on this format are available here:
  58956. * https://en.wikipedia.org/wiki/RGBE_image_format
  58957. *
  58958. * @param uint8array The binary file stored in native array.
  58959. * @return The header information.
  58960. */
  58961. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58962. /**
  58963. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58964. * This RGBE texture needs to store the information as a panorama.
  58965. *
  58966. * More information on this format are available here:
  58967. * https://en.wikipedia.org/wiki/RGBE_image_format
  58968. *
  58969. * @param buffer The binary file stored in an array buffer.
  58970. * @param size The expected size of the extracted cubemap.
  58971. * @return The Cube Map information.
  58972. */
  58973. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58974. /**
  58975. * Returns the pixels data extracted from an RGBE texture.
  58976. * This pixels will be stored left to right up to down in the R G B order in one array.
  58977. *
  58978. * More information on this format are available here:
  58979. * https://en.wikipedia.org/wiki/RGBE_image_format
  58980. *
  58981. * @param uint8array The binary file stored in an array buffer.
  58982. * @param hdrInfo The header information of the file.
  58983. * @return The pixels data in RGB right to left up to down order.
  58984. */
  58985. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58986. private static RGBE_ReadPixels_RLE;
  58987. }
  58988. }
  58989. declare module BABYLON {
  58990. /**
  58991. * Effect Render Options
  58992. */
  58993. export interface IEffectRendererOptions {
  58994. /**
  58995. * Defines the vertices positions.
  58996. */
  58997. positions?: number[];
  58998. /**
  58999. * Defines the indices.
  59000. */
  59001. indices?: number[];
  59002. }
  59003. /**
  59004. * Helper class to render one or more effects.
  59005. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59006. */
  59007. export class EffectRenderer {
  59008. private engine;
  59009. private static _DefaultOptions;
  59010. private _vertexBuffers;
  59011. private _indexBuffer;
  59012. private _fullscreenViewport;
  59013. /**
  59014. * Creates an effect renderer
  59015. * @param engine the engine to use for rendering
  59016. * @param options defines the options of the effect renderer
  59017. */
  59018. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59019. /**
  59020. * Sets the current viewport in normalized coordinates 0-1
  59021. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59022. */
  59023. setViewport(viewport?: Viewport): void;
  59024. /**
  59025. * Binds the embedded attributes buffer to the effect.
  59026. * @param effect Defines the effect to bind the attributes for
  59027. */
  59028. bindBuffers(effect: Effect): void;
  59029. /**
  59030. * Sets the current effect wrapper to use during draw.
  59031. * The effect needs to be ready before calling this api.
  59032. * This also sets the default full screen position attribute.
  59033. * @param effectWrapper Defines the effect to draw with
  59034. */
  59035. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59036. /**
  59037. * Restores engine states
  59038. */
  59039. restoreStates(): void;
  59040. /**
  59041. * Draws a full screen quad.
  59042. */
  59043. draw(): void;
  59044. private isRenderTargetTexture;
  59045. /**
  59046. * renders one or more effects to a specified texture
  59047. * @param effectWrapper the effect to renderer
  59048. * @param outputTexture texture to draw to, if null it will render to the screen.
  59049. */
  59050. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59051. /**
  59052. * Disposes of the effect renderer
  59053. */
  59054. dispose(): void;
  59055. }
  59056. /**
  59057. * Options to create an EffectWrapper
  59058. */
  59059. interface EffectWrapperCreationOptions {
  59060. /**
  59061. * Engine to use to create the effect
  59062. */
  59063. engine: ThinEngine;
  59064. /**
  59065. * Fragment shader for the effect
  59066. */
  59067. fragmentShader: string;
  59068. /**
  59069. * Use the shader store instead of direct source code
  59070. */
  59071. useShaderStore?: boolean;
  59072. /**
  59073. * Vertex shader for the effect
  59074. */
  59075. vertexShader?: string;
  59076. /**
  59077. * Attributes to use in the shader
  59078. */
  59079. attributeNames?: Array<string>;
  59080. /**
  59081. * Uniforms to use in the shader
  59082. */
  59083. uniformNames?: Array<string>;
  59084. /**
  59085. * Texture sampler names to use in the shader
  59086. */
  59087. samplerNames?: Array<string>;
  59088. /**
  59089. * Defines to use in the shader
  59090. */
  59091. defines?: Array<string>;
  59092. /**
  59093. * Callback when effect is compiled
  59094. */
  59095. onCompiled?: Nullable<(effect: Effect) => void>;
  59096. /**
  59097. * The friendly name of the effect displayed in Spector.
  59098. */
  59099. name?: string;
  59100. }
  59101. /**
  59102. * Wraps an effect to be used for rendering
  59103. */
  59104. export class EffectWrapper {
  59105. /**
  59106. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59107. */
  59108. onApplyObservable: Observable<{}>;
  59109. /**
  59110. * The underlying effect
  59111. */
  59112. effect: Effect;
  59113. /**
  59114. * Creates an effect to be renderer
  59115. * @param creationOptions options to create the effect
  59116. */
  59117. constructor(creationOptions: EffectWrapperCreationOptions);
  59118. /**
  59119. * Disposes of the effect wrapper
  59120. */
  59121. dispose(): void;
  59122. }
  59123. }
  59124. declare module BABYLON {
  59125. /** @hidden */
  59126. export var hdrFilteringVertexShader: {
  59127. name: string;
  59128. shader: string;
  59129. };
  59130. }
  59131. declare module BABYLON {
  59132. /** @hidden */
  59133. export var hdrFilteringPixelShader: {
  59134. name: string;
  59135. shader: string;
  59136. };
  59137. }
  59138. declare module BABYLON {
  59139. /**
  59140. * Options for texture filtering
  59141. */
  59142. interface IHDRFilteringOptions {
  59143. /**
  59144. * Scales pixel intensity for the input HDR map.
  59145. */
  59146. hdrScale?: number;
  59147. /**
  59148. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59149. */
  59150. quality?: number;
  59151. }
  59152. /**
  59153. * Filters HDR maps to get correct renderings of PBR reflections
  59154. */
  59155. export class HDRFiltering {
  59156. private _engine;
  59157. private _effectRenderer;
  59158. private _effectWrapper;
  59159. private _lodGenerationOffset;
  59160. private _lodGenerationScale;
  59161. /**
  59162. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59163. * you care about baking speed.
  59164. */
  59165. quality: number;
  59166. /**
  59167. * Scales pixel intensity for the input HDR map.
  59168. */
  59169. hdrScale: number;
  59170. /**
  59171. * Instantiates HDR filter for reflection maps
  59172. *
  59173. * @param engine Thin engine
  59174. * @param options Options
  59175. */
  59176. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59177. private _createRenderTarget;
  59178. private _prefilterInternal;
  59179. private _createEffect;
  59180. /**
  59181. * Get a value indicating if the filter is ready to be used
  59182. * @param texture Texture to filter
  59183. * @returns true if the filter is ready
  59184. */
  59185. isReady(texture: BaseTexture): boolean;
  59186. /**
  59187. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59188. * Prefiltering will be invoked at the end of next rendering pass.
  59189. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59190. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59191. * @param texture Texture to filter
  59192. * @param onFinished Callback when filtering is done
  59193. * @return Promise called when prefiltering is done
  59194. */
  59195. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59196. }
  59197. }
  59198. declare module BABYLON {
  59199. /**
  59200. * This represents a texture coming from an HDR input.
  59201. *
  59202. * The only supported format is currently panorama picture stored in RGBE format.
  59203. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59204. */
  59205. export class HDRCubeTexture extends BaseTexture {
  59206. private static _facesMapping;
  59207. private _generateHarmonics;
  59208. private _noMipmap;
  59209. private _prefilterOnLoad;
  59210. private _textureMatrix;
  59211. private _size;
  59212. private _onLoad;
  59213. private _onError;
  59214. /**
  59215. * The texture URL.
  59216. */
  59217. url: string;
  59218. /**
  59219. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59220. */
  59221. coordinatesMode: number;
  59222. protected _isBlocking: boolean;
  59223. /**
  59224. * Sets wether or not the texture is blocking during loading.
  59225. */
  59226. set isBlocking(value: boolean);
  59227. /**
  59228. * Gets wether or not the texture is blocking during loading.
  59229. */
  59230. get isBlocking(): boolean;
  59231. protected _rotationY: number;
  59232. /**
  59233. * Sets texture matrix rotation angle around Y axis in radians.
  59234. */
  59235. set rotationY(value: number);
  59236. /**
  59237. * Gets texture matrix rotation angle around Y axis radians.
  59238. */
  59239. get rotationY(): number;
  59240. /**
  59241. * Gets or sets the center of the bounding box associated with the cube texture
  59242. * It must define where the camera used to render the texture was set
  59243. */
  59244. boundingBoxPosition: Vector3;
  59245. private _boundingBoxSize;
  59246. /**
  59247. * Gets or sets the size of the bounding box associated with the cube texture
  59248. * When defined, the cubemap will switch to local mode
  59249. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59250. * @example https://www.babylonjs-playground.com/#RNASML
  59251. */
  59252. set boundingBoxSize(value: Vector3);
  59253. get boundingBoxSize(): Vector3;
  59254. /**
  59255. * Instantiates an HDRTexture from the following parameters.
  59256. *
  59257. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59258. * @param sceneOrEngine The scene or engine the texture will be used in
  59259. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59260. * @param noMipmap Forces to not generate the mipmap if true
  59261. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59262. * @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)
  59263. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59264. */
  59265. 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>);
  59266. /**
  59267. * Get the current class name of the texture useful for serialization or dynamic coding.
  59268. * @returns "HDRCubeTexture"
  59269. */
  59270. getClassName(): string;
  59271. /**
  59272. * Occurs when the file is raw .hdr file.
  59273. */
  59274. private loadTexture;
  59275. clone(): HDRCubeTexture;
  59276. delayLoad(): void;
  59277. /**
  59278. * Get the texture reflection matrix used to rotate/transform the reflection.
  59279. * @returns the reflection matrix
  59280. */
  59281. getReflectionTextureMatrix(): Matrix;
  59282. /**
  59283. * Set the texture reflection matrix used to rotate/transform the reflection.
  59284. * @param value Define the reflection matrix to set
  59285. */
  59286. setReflectionTextureMatrix(value: Matrix): void;
  59287. /**
  59288. * Parses a JSON representation of an HDR Texture in order to create the texture
  59289. * @param parsedTexture Define the JSON representation
  59290. * @param scene Define the scene the texture should be created in
  59291. * @param rootUrl Define the root url in case we need to load relative dependencies
  59292. * @returns the newly created texture after parsing
  59293. */
  59294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59295. serialize(): any;
  59296. }
  59297. }
  59298. declare module BABYLON {
  59299. /**
  59300. * Class used to control physics engine
  59301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59302. */
  59303. export class PhysicsEngine implements IPhysicsEngine {
  59304. private _physicsPlugin;
  59305. /**
  59306. * Global value used to control the smallest number supported by the simulation
  59307. */
  59308. static Epsilon: number;
  59309. private _impostors;
  59310. private _joints;
  59311. private _subTimeStep;
  59312. /**
  59313. * Gets the gravity vector used by the simulation
  59314. */
  59315. gravity: Vector3;
  59316. /**
  59317. * Factory used to create the default physics plugin.
  59318. * @returns The default physics plugin
  59319. */
  59320. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59321. /**
  59322. * Creates a new Physics Engine
  59323. * @param gravity defines the gravity vector used by the simulation
  59324. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59325. */
  59326. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59327. /**
  59328. * Sets the gravity vector used by the simulation
  59329. * @param gravity defines the gravity vector to use
  59330. */
  59331. setGravity(gravity: Vector3): void;
  59332. /**
  59333. * Set the time step of the physics engine.
  59334. * Default is 1/60.
  59335. * To slow it down, enter 1/600 for example.
  59336. * To speed it up, 1/30
  59337. * @param newTimeStep defines the new timestep to apply to this world.
  59338. */
  59339. setTimeStep(newTimeStep?: number): void;
  59340. /**
  59341. * Get the time step of the physics engine.
  59342. * @returns the current time step
  59343. */
  59344. getTimeStep(): number;
  59345. /**
  59346. * Set the sub time step of the physics engine.
  59347. * Default is 0 meaning there is no sub steps
  59348. * To increase physics resolution precision, set a small value (like 1 ms)
  59349. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59350. */
  59351. setSubTimeStep(subTimeStep?: number): void;
  59352. /**
  59353. * Get the sub time step of the physics engine.
  59354. * @returns the current sub time step
  59355. */
  59356. getSubTimeStep(): number;
  59357. /**
  59358. * Release all resources
  59359. */
  59360. dispose(): void;
  59361. /**
  59362. * Gets the name of the current physics plugin
  59363. * @returns the name of the plugin
  59364. */
  59365. getPhysicsPluginName(): string;
  59366. /**
  59367. * Adding a new impostor for the impostor tracking.
  59368. * This will be done by the impostor itself.
  59369. * @param impostor the impostor to add
  59370. */
  59371. addImpostor(impostor: PhysicsImpostor): void;
  59372. /**
  59373. * Remove an impostor from the engine.
  59374. * This impostor and its mesh will not longer be updated by the physics engine.
  59375. * @param impostor the impostor to remove
  59376. */
  59377. removeImpostor(impostor: PhysicsImpostor): void;
  59378. /**
  59379. * Add a joint to the physics engine
  59380. * @param mainImpostor defines the main impostor to which the joint is added.
  59381. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59382. * @param joint defines the joint that will connect both impostors.
  59383. */
  59384. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59385. /**
  59386. * Removes a joint from the simulation
  59387. * @param mainImpostor defines the impostor used with the joint
  59388. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59389. * @param joint defines the joint to remove
  59390. */
  59391. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59392. /**
  59393. * Called by the scene. No need to call it.
  59394. * @param delta defines the timespam between frames
  59395. */
  59396. _step(delta: number): void;
  59397. /**
  59398. * Gets the current plugin used to run the simulation
  59399. * @returns current plugin
  59400. */
  59401. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59402. /**
  59403. * Gets the list of physic impostors
  59404. * @returns an array of PhysicsImpostor
  59405. */
  59406. getImpostors(): Array<PhysicsImpostor>;
  59407. /**
  59408. * Gets the impostor for a physics enabled object
  59409. * @param object defines the object impersonated by the impostor
  59410. * @returns the PhysicsImpostor or null if not found
  59411. */
  59412. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59413. /**
  59414. * Gets the impostor for a physics body object
  59415. * @param body defines physics body used by the impostor
  59416. * @returns the PhysicsImpostor or null if not found
  59417. */
  59418. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59419. /**
  59420. * Does a raycast in the physics world
  59421. * @param from when should the ray start?
  59422. * @param to when should the ray end?
  59423. * @returns PhysicsRaycastResult
  59424. */
  59425. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59426. }
  59427. }
  59428. declare module BABYLON {
  59429. /** @hidden */
  59430. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59431. private _useDeltaForWorldStep;
  59432. world: any;
  59433. name: string;
  59434. private _physicsMaterials;
  59435. private _fixedTimeStep;
  59436. private _cannonRaycastResult;
  59437. private _raycastResult;
  59438. private _physicsBodysToRemoveAfterStep;
  59439. private _firstFrame;
  59440. BJSCANNON: any;
  59441. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59442. setGravity(gravity: Vector3): void;
  59443. setTimeStep(timeStep: number): void;
  59444. getTimeStep(): number;
  59445. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59446. private _removeMarkedPhysicsBodiesFromWorld;
  59447. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59448. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59449. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59450. private _processChildMeshes;
  59451. removePhysicsBody(impostor: PhysicsImpostor): void;
  59452. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59453. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59454. private _addMaterial;
  59455. private _checkWithEpsilon;
  59456. private _createShape;
  59457. private _createHeightmap;
  59458. private _minus90X;
  59459. private _plus90X;
  59460. private _tmpPosition;
  59461. private _tmpDeltaPosition;
  59462. private _tmpUnityRotation;
  59463. private _updatePhysicsBodyTransformation;
  59464. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59465. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59466. isSupported(): boolean;
  59467. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59468. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59469. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59470. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59471. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59472. getBodyMass(impostor: PhysicsImpostor): number;
  59473. getBodyFriction(impostor: PhysicsImpostor): number;
  59474. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59475. getBodyRestitution(impostor: PhysicsImpostor): number;
  59476. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59477. sleepBody(impostor: PhysicsImpostor): void;
  59478. wakeUpBody(impostor: PhysicsImpostor): void;
  59479. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59480. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59481. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59482. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59483. getRadius(impostor: PhysicsImpostor): number;
  59484. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59485. dispose(): void;
  59486. private _extendNamespace;
  59487. /**
  59488. * Does a raycast in the physics world
  59489. * @param from when should the ray start?
  59490. * @param to when should the ray end?
  59491. * @returns PhysicsRaycastResult
  59492. */
  59493. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59494. }
  59495. }
  59496. declare module BABYLON {
  59497. /** @hidden */
  59498. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59499. private _useDeltaForWorldStep;
  59500. world: any;
  59501. name: string;
  59502. BJSOIMO: any;
  59503. private _raycastResult;
  59504. private _fixedTimeStep;
  59505. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59506. setGravity(gravity: Vector3): void;
  59507. setTimeStep(timeStep: number): void;
  59508. getTimeStep(): number;
  59509. private _tmpImpostorsArray;
  59510. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59511. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59512. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59513. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59514. private _tmpPositionVector;
  59515. removePhysicsBody(impostor: PhysicsImpostor): void;
  59516. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59517. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59518. isSupported(): boolean;
  59519. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59520. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59521. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59522. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59523. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59524. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59525. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59526. getBodyMass(impostor: PhysicsImpostor): number;
  59527. getBodyFriction(impostor: PhysicsImpostor): number;
  59528. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59529. getBodyRestitution(impostor: PhysicsImpostor): number;
  59530. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59531. sleepBody(impostor: PhysicsImpostor): void;
  59532. wakeUpBody(impostor: PhysicsImpostor): void;
  59533. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59534. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59535. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59536. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59537. getRadius(impostor: PhysicsImpostor): number;
  59538. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59539. dispose(): void;
  59540. /**
  59541. * Does a raycast in the physics world
  59542. * @param from when should the ray start?
  59543. * @param to when should the ray end?
  59544. * @returns PhysicsRaycastResult
  59545. */
  59546. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59547. }
  59548. }
  59549. declare module BABYLON {
  59550. /**
  59551. * Class containing static functions to help procedurally build meshes
  59552. */
  59553. export class RibbonBuilder {
  59554. /**
  59555. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59556. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59557. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59558. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59559. * * 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
  59560. * * 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
  59561. * * 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
  59562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59563. * * 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
  59564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59565. * * 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
  59566. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59567. * * 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
  59568. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59570. * @param name defines the name of the mesh
  59571. * @param options defines the options used to create the mesh
  59572. * @param scene defines the hosting scene
  59573. * @returns the ribbon mesh
  59574. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59575. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59576. */
  59577. static CreateRibbon(name: string, options: {
  59578. pathArray: Vector3[][];
  59579. closeArray?: boolean;
  59580. closePath?: boolean;
  59581. offset?: number;
  59582. updatable?: boolean;
  59583. sideOrientation?: number;
  59584. frontUVs?: Vector4;
  59585. backUVs?: Vector4;
  59586. instance?: Mesh;
  59587. invertUV?: boolean;
  59588. uvs?: Vector2[];
  59589. colors?: Color4[];
  59590. }, scene?: Nullable<Scene>): Mesh;
  59591. }
  59592. }
  59593. declare module BABYLON {
  59594. /**
  59595. * Class containing static functions to help procedurally build meshes
  59596. */
  59597. export class ShapeBuilder {
  59598. /**
  59599. * 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.
  59600. * * 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.
  59601. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59602. * * 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.
  59603. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59604. * * 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
  59605. * * 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
  59606. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59608. * * 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
  59609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59611. * @param name defines the name of the mesh
  59612. * @param options defines the options used to create the mesh
  59613. * @param scene defines the hosting scene
  59614. * @returns the extruded shape mesh
  59615. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59617. */
  59618. static ExtrudeShape(name: string, options: {
  59619. shape: Vector3[];
  59620. path: Vector3[];
  59621. scale?: number;
  59622. rotation?: number;
  59623. cap?: number;
  59624. updatable?: boolean;
  59625. sideOrientation?: number;
  59626. frontUVs?: Vector4;
  59627. backUVs?: Vector4;
  59628. instance?: Mesh;
  59629. invertUV?: boolean;
  59630. }, scene?: Nullable<Scene>): Mesh;
  59631. /**
  59632. * Creates an custom extruded shape mesh.
  59633. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59634. * * 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.
  59635. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59636. * * 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
  59637. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59638. * * 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
  59639. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59640. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59641. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59642. * * 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
  59643. * * 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
  59644. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59646. * * 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
  59647. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59649. * @param name defines the name of the mesh
  59650. * @param options defines the options used to create the mesh
  59651. * @param scene defines the hosting scene
  59652. * @returns the custom extruded shape mesh
  59653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59654. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59656. */
  59657. static ExtrudeShapeCustom(name: string, options: {
  59658. shape: Vector3[];
  59659. path: Vector3[];
  59660. scaleFunction?: any;
  59661. rotationFunction?: any;
  59662. ribbonCloseArray?: boolean;
  59663. ribbonClosePath?: boolean;
  59664. cap?: number;
  59665. updatable?: boolean;
  59666. sideOrientation?: number;
  59667. frontUVs?: Vector4;
  59668. backUVs?: Vector4;
  59669. instance?: Mesh;
  59670. invertUV?: boolean;
  59671. }, scene?: Nullable<Scene>): Mesh;
  59672. private static _ExtrudeShapeGeneric;
  59673. }
  59674. }
  59675. declare module BABYLON {
  59676. /**
  59677. * AmmoJS Physics plugin
  59678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59679. * @see https://github.com/kripken/ammo.js/
  59680. */
  59681. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59682. private _useDeltaForWorldStep;
  59683. /**
  59684. * Reference to the Ammo library
  59685. */
  59686. bjsAMMO: any;
  59687. /**
  59688. * Created ammoJS world which physics bodies are added to
  59689. */
  59690. world: any;
  59691. /**
  59692. * Name of the plugin
  59693. */
  59694. name: string;
  59695. private _timeStep;
  59696. private _fixedTimeStep;
  59697. private _maxSteps;
  59698. private _tmpQuaternion;
  59699. private _tmpAmmoTransform;
  59700. private _tmpAmmoQuaternion;
  59701. private _tmpAmmoConcreteContactResultCallback;
  59702. private _collisionConfiguration;
  59703. private _dispatcher;
  59704. private _overlappingPairCache;
  59705. private _solver;
  59706. private _softBodySolver;
  59707. private _tmpAmmoVectorA;
  59708. private _tmpAmmoVectorB;
  59709. private _tmpAmmoVectorC;
  59710. private _tmpAmmoVectorD;
  59711. private _tmpContactCallbackResult;
  59712. private _tmpAmmoVectorRCA;
  59713. private _tmpAmmoVectorRCB;
  59714. private _raycastResult;
  59715. private static readonly DISABLE_COLLISION_FLAG;
  59716. private static readonly KINEMATIC_FLAG;
  59717. private static readonly DISABLE_DEACTIVATION_FLAG;
  59718. /**
  59719. * Initializes the ammoJS plugin
  59720. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59721. * @param ammoInjection can be used to inject your own ammo reference
  59722. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59723. */
  59724. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59725. /**
  59726. * Sets the gravity of the physics world (m/(s^2))
  59727. * @param gravity Gravity to set
  59728. */
  59729. setGravity(gravity: Vector3): void;
  59730. /**
  59731. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59732. * @param timeStep timestep to use in seconds
  59733. */
  59734. setTimeStep(timeStep: number): void;
  59735. /**
  59736. * 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)
  59737. * @param fixedTimeStep fixedTimeStep to use in seconds
  59738. */
  59739. setFixedTimeStep(fixedTimeStep: number): void;
  59740. /**
  59741. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59742. * @param maxSteps the maximum number of steps by the physics engine per frame
  59743. */
  59744. setMaxSteps(maxSteps: number): void;
  59745. /**
  59746. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59747. * @returns the current timestep in seconds
  59748. */
  59749. getTimeStep(): number;
  59750. /**
  59751. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59752. */
  59753. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59754. private _isImpostorInContact;
  59755. private _isImpostorPairInContact;
  59756. private _stepSimulation;
  59757. /**
  59758. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59759. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59760. * After the step the babylon meshes are set to the position of the physics imposters
  59761. * @param delta amount of time to step forward
  59762. * @param impostors array of imposters to update before/after the step
  59763. */
  59764. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59765. /**
  59766. * Update babylon mesh to match physics world object
  59767. * @param impostor imposter to match
  59768. */
  59769. private _afterSoftStep;
  59770. /**
  59771. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59772. * @param impostor imposter to match
  59773. */
  59774. private _ropeStep;
  59775. /**
  59776. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59777. * @param impostor imposter to match
  59778. */
  59779. private _softbodyOrClothStep;
  59780. private _tmpMatrix;
  59781. /**
  59782. * Applies an impulse on the imposter
  59783. * @param impostor imposter to apply impulse to
  59784. * @param force amount of force to be applied to the imposter
  59785. * @param contactPoint the location to apply the impulse on the imposter
  59786. */
  59787. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59788. /**
  59789. * Applies a force on the imposter
  59790. * @param impostor imposter to apply force
  59791. * @param force amount of force to be applied to the imposter
  59792. * @param contactPoint the location to apply the force on the imposter
  59793. */
  59794. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59795. /**
  59796. * Creates a physics body using the plugin
  59797. * @param impostor the imposter to create the physics body on
  59798. */
  59799. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59800. /**
  59801. * Removes the physics body from the imposter and disposes of the body's memory
  59802. * @param impostor imposter to remove the physics body from
  59803. */
  59804. removePhysicsBody(impostor: PhysicsImpostor): void;
  59805. /**
  59806. * Generates a joint
  59807. * @param impostorJoint the imposter joint to create the joint with
  59808. */
  59809. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59810. /**
  59811. * Removes a joint
  59812. * @param impostorJoint the imposter joint to remove the joint from
  59813. */
  59814. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59815. private _addMeshVerts;
  59816. /**
  59817. * Initialise the soft body vertices to match its object's (mesh) vertices
  59818. * Softbody vertices (nodes) are in world space and to match this
  59819. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59820. * @param impostor to create the softbody for
  59821. */
  59822. private _softVertexData;
  59823. /**
  59824. * Create an impostor's soft body
  59825. * @param impostor to create the softbody for
  59826. */
  59827. private _createSoftbody;
  59828. /**
  59829. * Create cloth for an impostor
  59830. * @param impostor to create the softbody for
  59831. */
  59832. private _createCloth;
  59833. /**
  59834. * Create rope for an impostor
  59835. * @param impostor to create the softbody for
  59836. */
  59837. private _createRope;
  59838. /**
  59839. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59840. * @param impostor to create the custom physics shape for
  59841. */
  59842. private _createCustom;
  59843. private _addHullVerts;
  59844. private _createShape;
  59845. /**
  59846. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59847. * @param impostor imposter containing the physics body and babylon object
  59848. */
  59849. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59850. /**
  59851. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59852. * @param impostor imposter containing the physics body and babylon object
  59853. * @param newPosition new position
  59854. * @param newRotation new rotation
  59855. */
  59856. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59857. /**
  59858. * If this plugin is supported
  59859. * @returns true if its supported
  59860. */
  59861. isSupported(): boolean;
  59862. /**
  59863. * Sets the linear velocity of the physics body
  59864. * @param impostor imposter to set the velocity on
  59865. * @param velocity velocity to set
  59866. */
  59867. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59868. /**
  59869. * Sets the angular velocity of the physics body
  59870. * @param impostor imposter to set the velocity on
  59871. * @param velocity velocity to set
  59872. */
  59873. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59874. /**
  59875. * gets the linear velocity
  59876. * @param impostor imposter to get linear velocity from
  59877. * @returns linear velocity
  59878. */
  59879. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59880. /**
  59881. * gets the angular velocity
  59882. * @param impostor imposter to get angular velocity from
  59883. * @returns angular velocity
  59884. */
  59885. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59886. /**
  59887. * Sets the mass of physics body
  59888. * @param impostor imposter to set the mass on
  59889. * @param mass mass to set
  59890. */
  59891. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59892. /**
  59893. * Gets the mass of the physics body
  59894. * @param impostor imposter to get the mass from
  59895. * @returns mass
  59896. */
  59897. getBodyMass(impostor: PhysicsImpostor): number;
  59898. /**
  59899. * Gets friction of the impostor
  59900. * @param impostor impostor to get friction from
  59901. * @returns friction value
  59902. */
  59903. getBodyFriction(impostor: PhysicsImpostor): number;
  59904. /**
  59905. * Sets friction of the impostor
  59906. * @param impostor impostor to set friction on
  59907. * @param friction friction value
  59908. */
  59909. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59910. /**
  59911. * Gets restitution of the impostor
  59912. * @param impostor impostor to get restitution from
  59913. * @returns restitution value
  59914. */
  59915. getBodyRestitution(impostor: PhysicsImpostor): number;
  59916. /**
  59917. * Sets resitution of the impostor
  59918. * @param impostor impostor to set resitution on
  59919. * @param restitution resitution value
  59920. */
  59921. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59922. /**
  59923. * Gets pressure inside the impostor
  59924. * @param impostor impostor to get pressure from
  59925. * @returns pressure value
  59926. */
  59927. getBodyPressure(impostor: PhysicsImpostor): number;
  59928. /**
  59929. * Sets pressure inside a soft body impostor
  59930. * Cloth and rope must remain 0 pressure
  59931. * @param impostor impostor to set pressure on
  59932. * @param pressure pressure value
  59933. */
  59934. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59935. /**
  59936. * Gets stiffness of the impostor
  59937. * @param impostor impostor to get stiffness from
  59938. * @returns pressure value
  59939. */
  59940. getBodyStiffness(impostor: PhysicsImpostor): number;
  59941. /**
  59942. * Sets stiffness of the impostor
  59943. * @param impostor impostor to set stiffness on
  59944. * @param stiffness stiffness value from 0 to 1
  59945. */
  59946. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59947. /**
  59948. * Gets velocityIterations of the impostor
  59949. * @param impostor impostor to get velocity iterations from
  59950. * @returns velocityIterations value
  59951. */
  59952. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59953. /**
  59954. * Sets velocityIterations of the impostor
  59955. * @param impostor impostor to set velocity iterations on
  59956. * @param velocityIterations velocityIterations value
  59957. */
  59958. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59959. /**
  59960. * Gets positionIterations of the impostor
  59961. * @param impostor impostor to get position iterations from
  59962. * @returns positionIterations value
  59963. */
  59964. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59965. /**
  59966. * Sets positionIterations of the impostor
  59967. * @param impostor impostor to set position on
  59968. * @param positionIterations positionIterations value
  59969. */
  59970. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59971. /**
  59972. * Append an anchor to a cloth object
  59973. * @param impostor is the cloth impostor to add anchor to
  59974. * @param otherImpostor is the rigid impostor to anchor to
  59975. * @param width ratio across width from 0 to 1
  59976. * @param height ratio up height from 0 to 1
  59977. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59978. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59979. */
  59980. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59981. /**
  59982. * Append an hook to a rope object
  59983. * @param impostor is the rope impostor to add hook to
  59984. * @param otherImpostor is the rigid impostor to hook to
  59985. * @param length ratio along the rope from 0 to 1
  59986. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59987. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59988. */
  59989. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59990. /**
  59991. * Sleeps the physics body and stops it from being active
  59992. * @param impostor impostor to sleep
  59993. */
  59994. sleepBody(impostor: PhysicsImpostor): void;
  59995. /**
  59996. * Activates the physics body
  59997. * @param impostor impostor to activate
  59998. */
  59999. wakeUpBody(impostor: PhysicsImpostor): void;
  60000. /**
  60001. * Updates the distance parameters of the joint
  60002. * @param joint joint to update
  60003. * @param maxDistance maximum distance of the joint
  60004. * @param minDistance minimum distance of the joint
  60005. */
  60006. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60007. /**
  60008. * Sets a motor on the joint
  60009. * @param joint joint to set motor on
  60010. * @param speed speed of the motor
  60011. * @param maxForce maximum force of the motor
  60012. * @param motorIndex index of the motor
  60013. */
  60014. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60015. /**
  60016. * Sets the motors limit
  60017. * @param joint joint to set limit on
  60018. * @param upperLimit upper limit
  60019. * @param lowerLimit lower limit
  60020. */
  60021. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60022. /**
  60023. * Syncs the position and rotation of a mesh with the impostor
  60024. * @param mesh mesh to sync
  60025. * @param impostor impostor to update the mesh with
  60026. */
  60027. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60028. /**
  60029. * Gets the radius of the impostor
  60030. * @param impostor impostor to get radius from
  60031. * @returns the radius
  60032. */
  60033. getRadius(impostor: PhysicsImpostor): number;
  60034. /**
  60035. * Gets the box size of the impostor
  60036. * @param impostor impostor to get box size from
  60037. * @param result the resulting box size
  60038. */
  60039. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60040. /**
  60041. * Disposes of the impostor
  60042. */
  60043. dispose(): void;
  60044. /**
  60045. * Does a raycast in the physics world
  60046. * @param from when should the ray start?
  60047. * @param to when should the ray end?
  60048. * @returns PhysicsRaycastResult
  60049. */
  60050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60051. }
  60052. }
  60053. declare module BABYLON {
  60054. interface AbstractScene {
  60055. /**
  60056. * The list of reflection probes added to the scene
  60057. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60058. */
  60059. reflectionProbes: Array<ReflectionProbe>;
  60060. /**
  60061. * Removes the given reflection probe from this scene.
  60062. * @param toRemove The reflection probe to remove
  60063. * @returns The index of the removed reflection probe
  60064. */
  60065. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60066. /**
  60067. * Adds the given reflection probe to this scene.
  60068. * @param newReflectionProbe The reflection probe to add
  60069. */
  60070. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60071. }
  60072. /**
  60073. * Class used to generate realtime reflection / refraction cube textures
  60074. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60075. */
  60076. export class ReflectionProbe {
  60077. /** defines the name of the probe */
  60078. name: string;
  60079. private _scene;
  60080. private _renderTargetTexture;
  60081. private _projectionMatrix;
  60082. private _viewMatrix;
  60083. private _target;
  60084. private _add;
  60085. private _attachedMesh;
  60086. private _invertYAxis;
  60087. /** Gets or sets probe position (center of the cube map) */
  60088. position: Vector3;
  60089. /**
  60090. * Creates a new reflection probe
  60091. * @param name defines the name of the probe
  60092. * @param size defines the texture resolution (for each face)
  60093. * @param scene defines the hosting scene
  60094. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60095. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60096. */
  60097. constructor(
  60098. /** defines the name of the probe */
  60099. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60100. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60101. get samples(): number;
  60102. set samples(value: number);
  60103. /** Gets or sets the refresh rate to use (on every frame by default) */
  60104. get refreshRate(): number;
  60105. set refreshRate(value: number);
  60106. /**
  60107. * Gets the hosting scene
  60108. * @returns a Scene
  60109. */
  60110. getScene(): Scene;
  60111. /** Gets the internal CubeTexture used to render to */
  60112. get cubeTexture(): RenderTargetTexture;
  60113. /** Gets the list of meshes to render */
  60114. get renderList(): Nullable<AbstractMesh[]>;
  60115. /**
  60116. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60117. * @param mesh defines the mesh to attach to
  60118. */
  60119. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60120. /**
  60121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60122. * @param renderingGroupId The rendering group id corresponding to its index
  60123. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60124. */
  60125. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60126. /**
  60127. * Clean all associated resources
  60128. */
  60129. dispose(): void;
  60130. /**
  60131. * Converts the reflection probe information to a readable string for debug purpose.
  60132. * @param fullDetails Supports for multiple levels of logging within scene loading
  60133. * @returns the human readable reflection probe info
  60134. */
  60135. toString(fullDetails?: boolean): string;
  60136. /**
  60137. * Get the class name of the relfection probe.
  60138. * @returns "ReflectionProbe"
  60139. */
  60140. getClassName(): string;
  60141. /**
  60142. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60143. * @returns The JSON representation of the texture
  60144. */
  60145. serialize(): any;
  60146. /**
  60147. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60148. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60149. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60150. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60151. * @returns The parsed reflection probe if successful
  60152. */
  60153. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60154. }
  60155. }
  60156. declare module BABYLON {
  60157. /** @hidden */
  60158. export var _BabylonLoaderRegistered: boolean;
  60159. /**
  60160. * Helps setting up some configuration for the babylon file loader.
  60161. */
  60162. export class BabylonFileLoaderConfiguration {
  60163. /**
  60164. * The loader does not allow injecting custom physix engine into the plugins.
  60165. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60166. * So you could set this variable to your engine import to make it work.
  60167. */
  60168. static LoaderInjectedPhysicsEngine: any;
  60169. }
  60170. }
  60171. declare module BABYLON {
  60172. /**
  60173. * The Physically based simple base material of BJS.
  60174. *
  60175. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60176. * It is used as the base class for both the specGloss and metalRough conventions.
  60177. */
  60178. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60179. /**
  60180. * Number of Simultaneous lights allowed on the material.
  60181. */
  60182. maxSimultaneousLights: number;
  60183. /**
  60184. * If sets to true, disables all the lights affecting the material.
  60185. */
  60186. disableLighting: boolean;
  60187. /**
  60188. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60189. */
  60190. environmentTexture: BaseTexture;
  60191. /**
  60192. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60193. */
  60194. invertNormalMapX: boolean;
  60195. /**
  60196. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60197. */
  60198. invertNormalMapY: boolean;
  60199. /**
  60200. * Normal map used in the model.
  60201. */
  60202. normalTexture: BaseTexture;
  60203. /**
  60204. * Emissivie color used to self-illuminate the model.
  60205. */
  60206. emissiveColor: Color3;
  60207. /**
  60208. * Emissivie texture used to self-illuminate the model.
  60209. */
  60210. emissiveTexture: BaseTexture;
  60211. /**
  60212. * Occlusion Channel Strenght.
  60213. */
  60214. occlusionStrength: number;
  60215. /**
  60216. * Occlusion Texture of the material (adding extra occlusion effects).
  60217. */
  60218. occlusionTexture: BaseTexture;
  60219. /**
  60220. * Defines the alpha limits in alpha test mode.
  60221. */
  60222. alphaCutOff: number;
  60223. /**
  60224. * Gets the current double sided mode.
  60225. */
  60226. get doubleSided(): boolean;
  60227. /**
  60228. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60229. */
  60230. set doubleSided(value: boolean);
  60231. /**
  60232. * Stores the pre-calculated light information of a mesh in a texture.
  60233. */
  60234. lightmapTexture: BaseTexture;
  60235. /**
  60236. * If true, the light map contains occlusion information instead of lighting info.
  60237. */
  60238. useLightmapAsShadowmap: boolean;
  60239. /**
  60240. * Instantiates a new PBRMaterial instance.
  60241. *
  60242. * @param name The material name
  60243. * @param scene The scene the material will be use in.
  60244. */
  60245. constructor(name: string, scene: Scene);
  60246. getClassName(): string;
  60247. }
  60248. }
  60249. declare module BABYLON {
  60250. /**
  60251. * The PBR material of BJS following the metal roughness convention.
  60252. *
  60253. * This fits to the PBR convention in the GLTF definition:
  60254. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60255. */
  60256. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60257. /**
  60258. * The base color has two different interpretations depending on the value of metalness.
  60259. * When the material is a metal, the base color is the specific measured reflectance value
  60260. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60261. * of the material.
  60262. */
  60263. baseColor: Color3;
  60264. /**
  60265. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60266. * well as opacity information in the alpha channel.
  60267. */
  60268. baseTexture: BaseTexture;
  60269. /**
  60270. * Specifies the metallic scalar value of the material.
  60271. * Can also be used to scale the metalness values of the metallic texture.
  60272. */
  60273. metallic: number;
  60274. /**
  60275. * Specifies the roughness scalar value of the material.
  60276. * Can also be used to scale the roughness values of the metallic texture.
  60277. */
  60278. roughness: number;
  60279. /**
  60280. * Texture containing both the metallic value in the B channel and the
  60281. * roughness value in the G channel to keep better precision.
  60282. */
  60283. metallicRoughnessTexture: BaseTexture;
  60284. /**
  60285. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60286. *
  60287. * @param name The material name
  60288. * @param scene The scene the material will be use in.
  60289. */
  60290. constructor(name: string, scene: Scene);
  60291. /**
  60292. * Return the currrent class name of the material.
  60293. */
  60294. getClassName(): string;
  60295. /**
  60296. * Makes a duplicate of the current material.
  60297. * @param name - name to use for the new material.
  60298. */
  60299. clone(name: string): PBRMetallicRoughnessMaterial;
  60300. /**
  60301. * Serialize the material to a parsable JSON object.
  60302. */
  60303. serialize(): any;
  60304. /**
  60305. * Parses a JSON object correponding to the serialize function.
  60306. */
  60307. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60308. }
  60309. }
  60310. declare module BABYLON {
  60311. /**
  60312. * The PBR material of BJS following the specular glossiness convention.
  60313. *
  60314. * This fits to the PBR convention in the GLTF definition:
  60315. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60316. */
  60317. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60318. /**
  60319. * Specifies the diffuse color of the material.
  60320. */
  60321. diffuseColor: Color3;
  60322. /**
  60323. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60324. * channel.
  60325. */
  60326. diffuseTexture: BaseTexture;
  60327. /**
  60328. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60329. */
  60330. specularColor: Color3;
  60331. /**
  60332. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60333. */
  60334. glossiness: number;
  60335. /**
  60336. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60337. */
  60338. specularGlossinessTexture: BaseTexture;
  60339. /**
  60340. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60341. *
  60342. * @param name The material name
  60343. * @param scene The scene the material will be use in.
  60344. */
  60345. constructor(name: string, scene: Scene);
  60346. /**
  60347. * Return the currrent class name of the material.
  60348. */
  60349. getClassName(): string;
  60350. /**
  60351. * Makes a duplicate of the current material.
  60352. * @param name - name to use for the new material.
  60353. */
  60354. clone(name: string): PBRSpecularGlossinessMaterial;
  60355. /**
  60356. * Serialize the material to a parsable JSON object.
  60357. */
  60358. serialize(): any;
  60359. /**
  60360. * Parses a JSON object correponding to the serialize function.
  60361. */
  60362. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60363. }
  60364. }
  60365. declare module BABYLON {
  60366. /**
  60367. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60368. * It can help converting any input color in a desired output one. This can then be used to create effects
  60369. * from sepia, black and white to sixties or futuristic rendering...
  60370. *
  60371. * The only supported format is currently 3dl.
  60372. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60373. */
  60374. export class ColorGradingTexture extends BaseTexture {
  60375. /**
  60376. * The texture URL.
  60377. */
  60378. url: string;
  60379. /**
  60380. * Empty line regex stored for GC.
  60381. */
  60382. private static _noneEmptyLineRegex;
  60383. private _textureMatrix;
  60384. private _onLoad;
  60385. /**
  60386. * Instantiates a ColorGradingTexture from the following parameters.
  60387. *
  60388. * @param url The location of the color gradind data (currently only supporting 3dl)
  60389. * @param sceneOrEngine The scene or engine the texture will be used in
  60390. * @param onLoad defines a callback triggered when the texture has been loaded
  60391. */
  60392. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60393. /**
  60394. * Fires the onload event from the constructor if requested.
  60395. */
  60396. private _triggerOnLoad;
  60397. /**
  60398. * Returns the texture matrix used in most of the material.
  60399. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60400. */
  60401. getTextureMatrix(): Matrix;
  60402. /**
  60403. * Occurs when the file being loaded is a .3dl LUT file.
  60404. */
  60405. private load3dlTexture;
  60406. /**
  60407. * Starts the loading process of the texture.
  60408. */
  60409. private loadTexture;
  60410. /**
  60411. * Clones the color gradind texture.
  60412. */
  60413. clone(): ColorGradingTexture;
  60414. /**
  60415. * Called during delayed load for textures.
  60416. */
  60417. delayLoad(): void;
  60418. /**
  60419. * Parses a color grading texture serialized by Babylon.
  60420. * @param parsedTexture The texture information being parsedTexture
  60421. * @param scene The scene to load the texture in
  60422. * @param rootUrl The root url of the data assets to load
  60423. * @return A color gradind texture
  60424. */
  60425. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60426. /**
  60427. * Serializes the LUT texture to json format.
  60428. */
  60429. serialize(): any;
  60430. }
  60431. }
  60432. declare module BABYLON {
  60433. /**
  60434. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60435. */
  60436. export class EquiRectangularCubeTexture extends BaseTexture {
  60437. /** The six faces of the cube. */
  60438. private static _FacesMapping;
  60439. private _noMipmap;
  60440. private _onLoad;
  60441. private _onError;
  60442. /** The size of the cubemap. */
  60443. private _size;
  60444. /** The buffer of the image. */
  60445. private _buffer;
  60446. /** The width of the input image. */
  60447. private _width;
  60448. /** The height of the input image. */
  60449. private _height;
  60450. /** The URL to the image. */
  60451. url: string;
  60452. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60453. coordinatesMode: number;
  60454. /**
  60455. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60456. * @param url The location of the image
  60457. * @param scene The scene the texture will be used in
  60458. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60459. * @param noMipmap Forces to not generate the mipmap if true
  60460. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60461. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60462. * @param onLoad — defines a callback called when texture is loaded
  60463. * @param onError — defines a callback called if there is an error
  60464. */
  60465. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60466. /**
  60467. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60468. */
  60469. private loadImage;
  60470. /**
  60471. * Convert the image buffer into a cubemap and create a CubeTexture.
  60472. */
  60473. private loadTexture;
  60474. /**
  60475. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60476. * @param buffer The ArrayBuffer that should be converted.
  60477. * @returns The buffer as Float32Array.
  60478. */
  60479. private getFloat32ArrayFromArrayBuffer;
  60480. /**
  60481. * Get the current class name of the texture useful for serialization or dynamic coding.
  60482. * @returns "EquiRectangularCubeTexture"
  60483. */
  60484. getClassName(): string;
  60485. /**
  60486. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60487. * @returns A clone of the current EquiRectangularCubeTexture.
  60488. */
  60489. clone(): EquiRectangularCubeTexture;
  60490. }
  60491. }
  60492. declare module BABYLON {
  60493. /**
  60494. * Defines the options related to the creation of an HtmlElementTexture
  60495. */
  60496. export interface IHtmlElementTextureOptions {
  60497. /**
  60498. * Defines wether mip maps should be created or not.
  60499. */
  60500. generateMipMaps?: boolean;
  60501. /**
  60502. * Defines the sampling mode of the texture.
  60503. */
  60504. samplingMode?: number;
  60505. /**
  60506. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60507. */
  60508. engine: Nullable<ThinEngine>;
  60509. /**
  60510. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60511. */
  60512. scene: Nullable<Scene>;
  60513. }
  60514. /**
  60515. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60516. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60517. * is automatically managed.
  60518. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60519. * in your application.
  60520. *
  60521. * As the update is not automatic, you need to call them manually.
  60522. */
  60523. export class HtmlElementTexture extends BaseTexture {
  60524. /**
  60525. * The texture URL.
  60526. */
  60527. element: HTMLVideoElement | HTMLCanvasElement;
  60528. private static readonly DefaultOptions;
  60529. private _textureMatrix;
  60530. private _isVideo;
  60531. private _generateMipMaps;
  60532. private _samplingMode;
  60533. /**
  60534. * Instantiates a HtmlElementTexture from the following parameters.
  60535. *
  60536. * @param name Defines the name of the texture
  60537. * @param element Defines the video or canvas the texture is filled with
  60538. * @param options Defines the other none mandatory texture creation options
  60539. */
  60540. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60541. private _createInternalTexture;
  60542. /**
  60543. * Returns the texture matrix used in most of the material.
  60544. */
  60545. getTextureMatrix(): Matrix;
  60546. /**
  60547. * Updates the content of the texture.
  60548. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60549. */
  60550. update(invertY?: Nullable<boolean>): void;
  60551. }
  60552. }
  60553. declare module BABYLON {
  60554. /**
  60555. * Based on jsTGALoader - Javascript loader for TGA file
  60556. * By Vincent Thibault
  60557. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60558. */
  60559. export class TGATools {
  60560. private static _TYPE_INDEXED;
  60561. private static _TYPE_RGB;
  60562. private static _TYPE_GREY;
  60563. private static _TYPE_RLE_INDEXED;
  60564. private static _TYPE_RLE_RGB;
  60565. private static _TYPE_RLE_GREY;
  60566. private static _ORIGIN_MASK;
  60567. private static _ORIGIN_SHIFT;
  60568. private static _ORIGIN_BL;
  60569. private static _ORIGIN_BR;
  60570. private static _ORIGIN_UL;
  60571. private static _ORIGIN_UR;
  60572. /**
  60573. * Gets the header of a TGA file
  60574. * @param data defines the TGA data
  60575. * @returns the header
  60576. */
  60577. static GetTGAHeader(data: Uint8Array): any;
  60578. /**
  60579. * Uploads TGA content to a Babylon Texture
  60580. * @hidden
  60581. */
  60582. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60583. /** @hidden */
  60584. 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;
  60585. /** @hidden */
  60586. 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;
  60587. /** @hidden */
  60588. 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;
  60589. /** @hidden */
  60590. 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;
  60591. /** @hidden */
  60592. 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;
  60593. /** @hidden */
  60594. 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;
  60595. }
  60596. }
  60597. declare module BABYLON {
  60598. /**
  60599. * Implementation of the TGA Texture Loader.
  60600. * @hidden
  60601. */
  60602. export class _TGATextureLoader implements IInternalTextureLoader {
  60603. /**
  60604. * Defines wether the loader supports cascade loading the different faces.
  60605. */
  60606. readonly supportCascades: boolean;
  60607. /**
  60608. * This returns if the loader support the current file information.
  60609. * @param extension defines the file extension of the file being loaded
  60610. * @returns true if the loader can load the specified file
  60611. */
  60612. canLoad(extension: string): boolean;
  60613. /**
  60614. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60615. * @param data contains the texture data
  60616. * @param texture defines the BabylonJS internal texture
  60617. * @param createPolynomials will be true if polynomials have been requested
  60618. * @param onLoad defines the callback to trigger once the texture is ready
  60619. * @param onError defines the callback to trigger in case of error
  60620. */
  60621. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60622. /**
  60623. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60624. * @param data contains the texture data
  60625. * @param texture defines the BabylonJS internal texture
  60626. * @param callback defines the method to call once ready to upload
  60627. */
  60628. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60629. }
  60630. }
  60631. declare module BABYLON {
  60632. /**
  60633. * Info about the .basis files
  60634. */
  60635. class BasisFileInfo {
  60636. /**
  60637. * If the file has alpha
  60638. */
  60639. hasAlpha: boolean;
  60640. /**
  60641. * Info about each image of the basis file
  60642. */
  60643. images: Array<{
  60644. levels: Array<{
  60645. width: number;
  60646. height: number;
  60647. transcodedPixels: ArrayBufferView;
  60648. }>;
  60649. }>;
  60650. }
  60651. /**
  60652. * Result of transcoding a basis file
  60653. */
  60654. class TranscodeResult {
  60655. /**
  60656. * Info about the .basis file
  60657. */
  60658. fileInfo: BasisFileInfo;
  60659. /**
  60660. * Format to use when loading the file
  60661. */
  60662. format: number;
  60663. }
  60664. /**
  60665. * Configuration options for the Basis transcoder
  60666. */
  60667. export class BasisTranscodeConfiguration {
  60668. /**
  60669. * Supported compression formats used to determine the supported output format of the transcoder
  60670. */
  60671. supportedCompressionFormats?: {
  60672. /**
  60673. * etc1 compression format
  60674. */
  60675. etc1?: boolean;
  60676. /**
  60677. * s3tc compression format
  60678. */
  60679. s3tc?: boolean;
  60680. /**
  60681. * pvrtc compression format
  60682. */
  60683. pvrtc?: boolean;
  60684. /**
  60685. * etc2 compression format
  60686. */
  60687. etc2?: boolean;
  60688. };
  60689. /**
  60690. * If mipmap levels should be loaded for transcoded images (Default: true)
  60691. */
  60692. loadMipmapLevels?: boolean;
  60693. /**
  60694. * Index of a single image to load (Default: all images)
  60695. */
  60696. loadSingleImage?: number;
  60697. }
  60698. /**
  60699. * Used to load .Basis files
  60700. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60701. */
  60702. export class BasisTools {
  60703. private static _IgnoreSupportedFormats;
  60704. /**
  60705. * URL to use when loading the basis transcoder
  60706. */
  60707. static JSModuleURL: string;
  60708. /**
  60709. * URL to use when loading the wasm module for the transcoder
  60710. */
  60711. static WasmModuleURL: string;
  60712. /**
  60713. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60714. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60715. * @returns internal format corresponding to the Basis format
  60716. */
  60717. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60718. private static _WorkerPromise;
  60719. private static _Worker;
  60720. private static _actionId;
  60721. private static _CreateWorkerAsync;
  60722. /**
  60723. * Transcodes a loaded image file to compressed pixel data
  60724. * @param data image data to transcode
  60725. * @param config configuration options for the transcoding
  60726. * @returns a promise resulting in the transcoded image
  60727. */
  60728. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60729. /**
  60730. * Loads a texture from the transcode result
  60731. * @param texture texture load to
  60732. * @param transcodeResult the result of transcoding the basis file to load from
  60733. */
  60734. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60735. }
  60736. }
  60737. declare module BABYLON {
  60738. /**
  60739. * Loader for .basis file format
  60740. */
  60741. export class _BasisTextureLoader implements IInternalTextureLoader {
  60742. /**
  60743. * Defines whether the loader supports cascade loading the different faces.
  60744. */
  60745. readonly supportCascades: boolean;
  60746. /**
  60747. * This returns if the loader support the current file information.
  60748. * @param extension defines the file extension of the file being loaded
  60749. * @returns true if the loader can load the specified file
  60750. */
  60751. canLoad(extension: string): boolean;
  60752. /**
  60753. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60754. * @param data contains the texture data
  60755. * @param texture defines the BabylonJS internal texture
  60756. * @param createPolynomials will be true if polynomials have been requested
  60757. * @param onLoad defines the callback to trigger once the texture is ready
  60758. * @param onError defines the callback to trigger in case of error
  60759. */
  60760. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60761. /**
  60762. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60763. * @param data contains the texture data
  60764. * @param texture defines the BabylonJS internal texture
  60765. * @param callback defines the method to call once ready to upload
  60766. */
  60767. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60768. }
  60769. }
  60770. declare module BABYLON {
  60771. /**
  60772. * Defines the basic options interface of a TexturePacker Frame
  60773. */
  60774. export interface ITexturePackerFrame {
  60775. /**
  60776. * The frame ID
  60777. */
  60778. id: number;
  60779. /**
  60780. * The frames Scale
  60781. */
  60782. scale: Vector2;
  60783. /**
  60784. * The Frames offset
  60785. */
  60786. offset: Vector2;
  60787. }
  60788. /**
  60789. * This is a support class for frame Data on texture packer sets.
  60790. */
  60791. export class TexturePackerFrame implements ITexturePackerFrame {
  60792. /**
  60793. * The frame ID
  60794. */
  60795. id: number;
  60796. /**
  60797. * The frames Scale
  60798. */
  60799. scale: Vector2;
  60800. /**
  60801. * The Frames offset
  60802. */
  60803. offset: Vector2;
  60804. /**
  60805. * Initializes a texture package frame.
  60806. * @param id The numerical frame identifier
  60807. * @param scale Scalar Vector2 for UV frame
  60808. * @param offset Vector2 for the frame position in UV units.
  60809. * @returns TexturePackerFrame
  60810. */
  60811. constructor(id: number, scale: Vector2, offset: Vector2);
  60812. }
  60813. }
  60814. declare module BABYLON {
  60815. /**
  60816. * Defines the basic options interface of a TexturePacker
  60817. */
  60818. export interface ITexturePackerOptions {
  60819. /**
  60820. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60821. */
  60822. map?: string[];
  60823. /**
  60824. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60825. */
  60826. uvsIn?: string;
  60827. /**
  60828. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60829. */
  60830. uvsOut?: string;
  60831. /**
  60832. * number representing the layout style. Defaults to LAYOUT_STRIP
  60833. */
  60834. layout?: number;
  60835. /**
  60836. * number of columns if using custom column count layout(2). This defaults to 4.
  60837. */
  60838. colnum?: number;
  60839. /**
  60840. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60841. */
  60842. updateInputMeshes?: boolean;
  60843. /**
  60844. * boolean flag to dispose all the source textures. Defaults to true.
  60845. */
  60846. disposeSources?: boolean;
  60847. /**
  60848. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60849. */
  60850. fillBlanks?: boolean;
  60851. /**
  60852. * string value representing the context fill style color. Defaults to 'black'.
  60853. */
  60854. customFillColor?: string;
  60855. /**
  60856. * Width and Height Value of each Frame in the TexturePacker Sets
  60857. */
  60858. frameSize?: number;
  60859. /**
  60860. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60861. */
  60862. paddingRatio?: number;
  60863. /**
  60864. * Number that declares the fill method for the padding gutter.
  60865. */
  60866. paddingMode?: number;
  60867. /**
  60868. * If in SUBUV_COLOR padding mode what color to use.
  60869. */
  60870. paddingColor?: Color3 | Color4;
  60871. }
  60872. /**
  60873. * Defines the basic interface of a TexturePacker JSON File
  60874. */
  60875. export interface ITexturePackerJSON {
  60876. /**
  60877. * The frame ID
  60878. */
  60879. name: string;
  60880. /**
  60881. * The base64 channel data
  60882. */
  60883. sets: any;
  60884. /**
  60885. * The options of the Packer
  60886. */
  60887. options: ITexturePackerOptions;
  60888. /**
  60889. * The frame data of the Packer
  60890. */
  60891. frames: Array<number>;
  60892. }
  60893. /**
  60894. * This is a support class that generates a series of packed texture sets.
  60895. * @see https://doc.babylonjs.com/babylon101/materials
  60896. */
  60897. export class TexturePacker {
  60898. /** Packer Layout Constant 0 */
  60899. static readonly LAYOUT_STRIP: number;
  60900. /** Packer Layout Constant 1 */
  60901. static readonly LAYOUT_POWER2: number;
  60902. /** Packer Layout Constant 2 */
  60903. static readonly LAYOUT_COLNUM: number;
  60904. /** Packer Layout Constant 0 */
  60905. static readonly SUBUV_WRAP: number;
  60906. /** Packer Layout Constant 1 */
  60907. static readonly SUBUV_EXTEND: number;
  60908. /** Packer Layout Constant 2 */
  60909. static readonly SUBUV_COLOR: number;
  60910. /** The Name of the Texture Package */
  60911. name: string;
  60912. /** The scene scope of the TexturePacker */
  60913. scene: Scene;
  60914. /** The Meshes to target */
  60915. meshes: AbstractMesh[];
  60916. /** Arguments passed with the Constructor */
  60917. options: ITexturePackerOptions;
  60918. /** The promise that is started upon initialization */
  60919. promise: Nullable<Promise<TexturePacker | string>>;
  60920. /** The Container object for the channel sets that are generated */
  60921. sets: object;
  60922. /** The Container array for the frames that are generated */
  60923. frames: TexturePackerFrame[];
  60924. /** The expected number of textures the system is parsing. */
  60925. private _expecting;
  60926. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60927. private _paddingValue;
  60928. /**
  60929. * Initializes a texture package series from an array of meshes or a single mesh.
  60930. * @param name The name of the package
  60931. * @param meshes The target meshes to compose the package from
  60932. * @param options The arguments that texture packer should follow while building.
  60933. * @param scene The scene which the textures are scoped to.
  60934. * @returns TexturePacker
  60935. */
  60936. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60937. /**
  60938. * Starts the package process
  60939. * @param resolve The promises resolution function
  60940. * @returns TexturePacker
  60941. */
  60942. private _createFrames;
  60943. /**
  60944. * Calculates the Size of the Channel Sets
  60945. * @returns Vector2
  60946. */
  60947. private _calculateSize;
  60948. /**
  60949. * Calculates the UV data for the frames.
  60950. * @param baseSize the base frameSize
  60951. * @param padding the base frame padding
  60952. * @param dtSize size of the Dynamic Texture for that channel
  60953. * @param dtUnits is 1/dtSize
  60954. * @param update flag to update the input meshes
  60955. */
  60956. private _calculateMeshUVFrames;
  60957. /**
  60958. * Calculates the frames Offset.
  60959. * @param index of the frame
  60960. * @returns Vector2
  60961. */
  60962. private _getFrameOffset;
  60963. /**
  60964. * Updates a Mesh to the frame data
  60965. * @param mesh that is the target
  60966. * @param frameID or the frame index
  60967. */
  60968. private _updateMeshUV;
  60969. /**
  60970. * Updates a Meshes materials to use the texture packer channels
  60971. * @param m is the mesh to target
  60972. * @param force all channels on the packer to be set.
  60973. */
  60974. private _updateTextureReferences;
  60975. /**
  60976. * Public method to set a Mesh to a frame
  60977. * @param m that is the target
  60978. * @param frameID or the frame index
  60979. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60980. */
  60981. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60982. /**
  60983. * Starts the async promise to compile the texture packer.
  60984. * @returns Promise<void>
  60985. */
  60986. processAsync(): Promise<void>;
  60987. /**
  60988. * Disposes all textures associated with this packer
  60989. */
  60990. dispose(): void;
  60991. /**
  60992. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60993. * @param imageType is the image type to use.
  60994. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60995. */
  60996. download(imageType?: string, quality?: number): void;
  60997. /**
  60998. * Public method to load a texturePacker JSON file.
  60999. * @param data of the JSON file in string format.
  61000. */
  61001. updateFromJSON(data: string): void;
  61002. }
  61003. }
  61004. declare module BABYLON {
  61005. /**
  61006. * 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.
  61007. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61008. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61009. */
  61010. export class CustomProceduralTexture extends ProceduralTexture {
  61011. private _animate;
  61012. private _time;
  61013. private _config;
  61014. private _texturePath;
  61015. /**
  61016. * Instantiates a new Custom Procedural Texture.
  61017. * 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.
  61018. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61019. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61020. * @param name Define the name of the texture
  61021. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61022. * @param size Define the size of the texture to create
  61023. * @param scene Define the scene the texture belongs to
  61024. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61025. * @param generateMipMaps Define if the texture should creates mip maps or not
  61026. */
  61027. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61028. private _loadJson;
  61029. /**
  61030. * Is the texture ready to be used ? (rendered at least once)
  61031. * @returns true if ready, otherwise, false.
  61032. */
  61033. isReady(): boolean;
  61034. /**
  61035. * Render the texture to its associated render target.
  61036. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61037. */
  61038. render(useCameraPostProcess?: boolean): void;
  61039. /**
  61040. * Update the list of dependant textures samplers in the shader.
  61041. */
  61042. updateTextures(): void;
  61043. /**
  61044. * Update the uniform values of the procedural texture in the shader.
  61045. */
  61046. updateShaderUniforms(): void;
  61047. /**
  61048. * Define if the texture animates or not.
  61049. */
  61050. get animate(): boolean;
  61051. set animate(value: boolean);
  61052. }
  61053. }
  61054. declare module BABYLON {
  61055. /** @hidden */
  61056. export var noisePixelShader: {
  61057. name: string;
  61058. shader: string;
  61059. };
  61060. }
  61061. declare module BABYLON {
  61062. /**
  61063. * Class used to generate noise procedural textures
  61064. */
  61065. export class NoiseProceduralTexture extends ProceduralTexture {
  61066. private _time;
  61067. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61068. brightness: number;
  61069. /** Defines the number of octaves to process */
  61070. octaves: number;
  61071. /** Defines the level of persistence (0.8 by default) */
  61072. persistence: number;
  61073. /** Gets or sets animation speed factor (default is 1) */
  61074. animationSpeedFactor: number;
  61075. /**
  61076. * Creates a new NoiseProceduralTexture
  61077. * @param name defines the name fo the texture
  61078. * @param size defines the size of the texture (default is 256)
  61079. * @param scene defines the hosting scene
  61080. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61081. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61082. */
  61083. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61084. private _updateShaderUniforms;
  61085. protected _getDefines(): string;
  61086. /** Generate the current state of the procedural texture */
  61087. render(useCameraPostProcess?: boolean): void;
  61088. /**
  61089. * Serializes this noise procedural texture
  61090. * @returns a serialized noise procedural texture object
  61091. */
  61092. serialize(): any;
  61093. /**
  61094. * Clone the texture.
  61095. * @returns the cloned texture
  61096. */
  61097. clone(): NoiseProceduralTexture;
  61098. /**
  61099. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61100. * @param parsedTexture defines parsed texture data
  61101. * @param scene defines the current scene
  61102. * @param rootUrl defines the root URL containing noise procedural texture information
  61103. * @returns a parsed NoiseProceduralTexture
  61104. */
  61105. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61106. }
  61107. }
  61108. declare module BABYLON {
  61109. /**
  61110. * Raw cube texture where the raw buffers are passed in
  61111. */
  61112. export class RawCubeTexture extends CubeTexture {
  61113. /**
  61114. * Creates a cube texture where the raw buffers are passed in.
  61115. * @param scene defines the scene the texture is attached to
  61116. * @param data defines the array of data to use to create each face
  61117. * @param size defines the size of the textures
  61118. * @param format defines the format of the data
  61119. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61120. * @param generateMipMaps defines if the engine should generate the mip levels
  61121. * @param invertY defines if data must be stored with Y axis inverted
  61122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61123. * @param compression defines the compression used (null by default)
  61124. */
  61125. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61126. /**
  61127. * Updates the raw cube texture.
  61128. * @param data defines the data to store
  61129. * @param format defines the data format
  61130. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61131. * @param invertY defines if data must be stored with Y axis inverted
  61132. * @param compression defines the compression used (null by default)
  61133. * @param level defines which level of the texture to update
  61134. */
  61135. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61136. /**
  61137. * Updates a raw cube texture with RGBD encoded data.
  61138. * @param data defines the array of data [mipmap][face] to use to create each face
  61139. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61140. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61141. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61142. * @returns a promsie that resolves when the operation is complete
  61143. */
  61144. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61145. /**
  61146. * Clones the raw cube texture.
  61147. * @return a new cube texture
  61148. */
  61149. clone(): CubeTexture;
  61150. /** @hidden */
  61151. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61152. }
  61153. }
  61154. declare module BABYLON {
  61155. /**
  61156. * Class used to store 2D array textures containing user data
  61157. */
  61158. export class RawTexture2DArray extends Texture {
  61159. /** Gets or sets the texture format to use */
  61160. format: number;
  61161. /**
  61162. * Create a new RawTexture2DArray
  61163. * @param data defines the data of the texture
  61164. * @param width defines the width of the texture
  61165. * @param height defines the height of the texture
  61166. * @param depth defines the number of layers of the texture
  61167. * @param format defines the texture format to use
  61168. * @param scene defines the hosting scene
  61169. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61170. * @param invertY defines if texture must be stored with Y axis inverted
  61171. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61172. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61173. */
  61174. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61175. /** Gets or sets the texture format to use */
  61176. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61177. /**
  61178. * Update the texture with new data
  61179. * @param data defines the data to store in the texture
  61180. */
  61181. update(data: ArrayBufferView): void;
  61182. }
  61183. }
  61184. declare module BABYLON {
  61185. /**
  61186. * Class used to store 3D textures containing user data
  61187. */
  61188. export class RawTexture3D extends Texture {
  61189. /** Gets or sets the texture format to use */
  61190. format: number;
  61191. /**
  61192. * Create a new RawTexture3D
  61193. * @param data defines the data of the texture
  61194. * @param width defines the width of the texture
  61195. * @param height defines the height of the texture
  61196. * @param depth defines the depth of the texture
  61197. * @param format defines the texture format to use
  61198. * @param scene defines the hosting scene
  61199. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61200. * @param invertY defines if texture must be stored with Y axis inverted
  61201. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61202. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61203. */
  61204. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61205. /** Gets or sets the texture format to use */
  61206. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61207. /**
  61208. * Update the texture with new data
  61209. * @param data defines the data to store in the texture
  61210. */
  61211. update(data: ArrayBufferView): void;
  61212. }
  61213. }
  61214. declare module BABYLON {
  61215. /**
  61216. * Creates a refraction texture used by refraction channel of the standard material.
  61217. * It is like a mirror but to see through a material.
  61218. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61219. */
  61220. export class RefractionTexture extends RenderTargetTexture {
  61221. /**
  61222. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61223. * 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.
  61224. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61225. */
  61226. refractionPlane: Plane;
  61227. /**
  61228. * Define how deep under the surface we should see.
  61229. */
  61230. depth: number;
  61231. /**
  61232. * Creates a refraction texture used by refraction channel of the standard material.
  61233. * It is like a mirror but to see through a material.
  61234. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61235. * @param name Define the texture name
  61236. * @param size Define the size of the underlying texture
  61237. * @param scene Define the scene the refraction belongs to
  61238. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61239. */
  61240. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61241. /**
  61242. * Clone the refraction texture.
  61243. * @returns the cloned texture
  61244. */
  61245. clone(): RefractionTexture;
  61246. /**
  61247. * Serialize the texture to a JSON representation you could use in Parse later on
  61248. * @returns the serialized JSON representation
  61249. */
  61250. serialize(): any;
  61251. }
  61252. }
  61253. declare module BABYLON {
  61254. /**
  61255. * Block used to add support for vertex skinning (bones)
  61256. */
  61257. export class BonesBlock extends NodeMaterialBlock {
  61258. /**
  61259. * Creates a new BonesBlock
  61260. * @param name defines the block name
  61261. */
  61262. constructor(name: string);
  61263. /**
  61264. * Initialize the block and prepare the context for build
  61265. * @param state defines the state that will be used for the build
  61266. */
  61267. initialize(state: NodeMaterialBuildState): void;
  61268. /**
  61269. * Gets the current class name
  61270. * @returns the class name
  61271. */
  61272. getClassName(): string;
  61273. /**
  61274. * Gets the matrix indices input component
  61275. */
  61276. get matricesIndices(): NodeMaterialConnectionPoint;
  61277. /**
  61278. * Gets the matrix weights input component
  61279. */
  61280. get matricesWeights(): NodeMaterialConnectionPoint;
  61281. /**
  61282. * Gets the extra matrix indices input component
  61283. */
  61284. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61285. /**
  61286. * Gets the extra matrix weights input component
  61287. */
  61288. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61289. /**
  61290. * Gets the world input component
  61291. */
  61292. get world(): NodeMaterialConnectionPoint;
  61293. /**
  61294. * Gets the output component
  61295. */
  61296. get output(): NodeMaterialConnectionPoint;
  61297. autoConfigure(material: NodeMaterial): void;
  61298. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61299. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61301. protected _buildBlock(state: NodeMaterialBuildState): this;
  61302. }
  61303. }
  61304. declare module BABYLON {
  61305. /**
  61306. * Block used to add support for instances
  61307. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61308. */
  61309. export class InstancesBlock extends NodeMaterialBlock {
  61310. /**
  61311. * Creates a new InstancesBlock
  61312. * @param name defines the block name
  61313. */
  61314. constructor(name: string);
  61315. /**
  61316. * Gets the current class name
  61317. * @returns the class name
  61318. */
  61319. getClassName(): string;
  61320. /**
  61321. * Gets the first world row input component
  61322. */
  61323. get world0(): NodeMaterialConnectionPoint;
  61324. /**
  61325. * Gets the second world row input component
  61326. */
  61327. get world1(): NodeMaterialConnectionPoint;
  61328. /**
  61329. * Gets the third world row input component
  61330. */
  61331. get world2(): NodeMaterialConnectionPoint;
  61332. /**
  61333. * Gets the forth world row input component
  61334. */
  61335. get world3(): NodeMaterialConnectionPoint;
  61336. /**
  61337. * Gets the world input component
  61338. */
  61339. get world(): NodeMaterialConnectionPoint;
  61340. /**
  61341. * Gets the output component
  61342. */
  61343. get output(): NodeMaterialConnectionPoint;
  61344. /**
  61345. * Gets the isntanceID component
  61346. */
  61347. get instanceID(): NodeMaterialConnectionPoint;
  61348. autoConfigure(material: NodeMaterial): void;
  61349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61350. protected _buildBlock(state: NodeMaterialBuildState): this;
  61351. }
  61352. }
  61353. declare module BABYLON {
  61354. /**
  61355. * Block used to add morph targets support to vertex shader
  61356. */
  61357. export class MorphTargetsBlock extends NodeMaterialBlock {
  61358. private _repeatableContentAnchor;
  61359. /**
  61360. * Create a new MorphTargetsBlock
  61361. * @param name defines the block name
  61362. */
  61363. constructor(name: string);
  61364. /**
  61365. * Gets the current class name
  61366. * @returns the class name
  61367. */
  61368. getClassName(): string;
  61369. /**
  61370. * Gets the position input component
  61371. */
  61372. get position(): NodeMaterialConnectionPoint;
  61373. /**
  61374. * Gets the normal input component
  61375. */
  61376. get normal(): NodeMaterialConnectionPoint;
  61377. /**
  61378. * Gets the tangent input component
  61379. */
  61380. get tangent(): NodeMaterialConnectionPoint;
  61381. /**
  61382. * Gets the tangent input component
  61383. */
  61384. get uv(): NodeMaterialConnectionPoint;
  61385. /**
  61386. * Gets the position output component
  61387. */
  61388. get positionOutput(): NodeMaterialConnectionPoint;
  61389. /**
  61390. * Gets the normal output component
  61391. */
  61392. get normalOutput(): NodeMaterialConnectionPoint;
  61393. /**
  61394. * Gets the tangent output component
  61395. */
  61396. get tangentOutput(): NodeMaterialConnectionPoint;
  61397. /**
  61398. * Gets the tangent output component
  61399. */
  61400. get uvOutput(): NodeMaterialConnectionPoint;
  61401. initialize(state: NodeMaterialBuildState): void;
  61402. autoConfigure(material: NodeMaterial): void;
  61403. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61405. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61406. protected _buildBlock(state: NodeMaterialBuildState): this;
  61407. }
  61408. }
  61409. declare module BABYLON {
  61410. /**
  61411. * Block used to get data information from a light
  61412. */
  61413. export class LightInformationBlock extends NodeMaterialBlock {
  61414. private _lightDataUniformName;
  61415. private _lightColorUniformName;
  61416. private _lightTypeDefineName;
  61417. /**
  61418. * Gets or sets the light associated with this block
  61419. */
  61420. light: Nullable<Light>;
  61421. /**
  61422. * Creates a new LightInformationBlock
  61423. * @param name defines the block name
  61424. */
  61425. constructor(name: string);
  61426. /**
  61427. * Gets the current class name
  61428. * @returns the class name
  61429. */
  61430. getClassName(): string;
  61431. /**
  61432. * Gets the world position input component
  61433. */
  61434. get worldPosition(): NodeMaterialConnectionPoint;
  61435. /**
  61436. * Gets the direction output component
  61437. */
  61438. get direction(): NodeMaterialConnectionPoint;
  61439. /**
  61440. * Gets the direction output component
  61441. */
  61442. get color(): NodeMaterialConnectionPoint;
  61443. /**
  61444. * Gets the direction output component
  61445. */
  61446. get intensity(): NodeMaterialConnectionPoint;
  61447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61449. protected _buildBlock(state: NodeMaterialBuildState): this;
  61450. serialize(): any;
  61451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61452. }
  61453. }
  61454. declare module BABYLON {
  61455. /**
  61456. * Block used to add image processing support to fragment shader
  61457. */
  61458. export class ImageProcessingBlock extends NodeMaterialBlock {
  61459. /**
  61460. * Create a new ImageProcessingBlock
  61461. * @param name defines the block name
  61462. */
  61463. constructor(name: string);
  61464. /**
  61465. * Gets the current class name
  61466. * @returns the class name
  61467. */
  61468. getClassName(): string;
  61469. /**
  61470. * Gets the color input component
  61471. */
  61472. get color(): NodeMaterialConnectionPoint;
  61473. /**
  61474. * Gets the output component
  61475. */
  61476. get output(): NodeMaterialConnectionPoint;
  61477. /**
  61478. * Initialize the block and prepare the context for build
  61479. * @param state defines the state that will be used for the build
  61480. */
  61481. initialize(state: NodeMaterialBuildState): void;
  61482. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61485. protected _buildBlock(state: NodeMaterialBuildState): this;
  61486. }
  61487. }
  61488. declare module BABYLON {
  61489. /**
  61490. * Block used to pertub normals based on a normal map
  61491. */
  61492. export class PerturbNormalBlock extends NodeMaterialBlock {
  61493. private _tangentSpaceParameterName;
  61494. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61495. invertX: boolean;
  61496. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61497. invertY: boolean;
  61498. /**
  61499. * Create a new PerturbNormalBlock
  61500. * @param name defines the block name
  61501. */
  61502. constructor(name: string);
  61503. /**
  61504. * Gets the current class name
  61505. * @returns the class name
  61506. */
  61507. getClassName(): string;
  61508. /**
  61509. * Gets the world position input component
  61510. */
  61511. get worldPosition(): NodeMaterialConnectionPoint;
  61512. /**
  61513. * Gets the world normal input component
  61514. */
  61515. get worldNormal(): NodeMaterialConnectionPoint;
  61516. /**
  61517. * Gets the world tangent input component
  61518. */
  61519. get worldTangent(): NodeMaterialConnectionPoint;
  61520. /**
  61521. * Gets the uv input component
  61522. */
  61523. get uv(): NodeMaterialConnectionPoint;
  61524. /**
  61525. * Gets the normal map color input component
  61526. */
  61527. get normalMapColor(): NodeMaterialConnectionPoint;
  61528. /**
  61529. * Gets the strength input component
  61530. */
  61531. get strength(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the output component
  61534. */
  61535. get output(): NodeMaterialConnectionPoint;
  61536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61538. autoConfigure(material: NodeMaterial): void;
  61539. protected _buildBlock(state: NodeMaterialBuildState): this;
  61540. protected _dumpPropertiesCode(): string;
  61541. serialize(): any;
  61542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61543. }
  61544. }
  61545. declare module BABYLON {
  61546. /**
  61547. * Block used to discard a pixel if a value is smaller than a cutoff
  61548. */
  61549. export class DiscardBlock extends NodeMaterialBlock {
  61550. /**
  61551. * Create a new DiscardBlock
  61552. * @param name defines the block name
  61553. */
  61554. constructor(name: string);
  61555. /**
  61556. * Gets the current class name
  61557. * @returns the class name
  61558. */
  61559. getClassName(): string;
  61560. /**
  61561. * Gets the color input component
  61562. */
  61563. get value(): NodeMaterialConnectionPoint;
  61564. /**
  61565. * Gets the cutoff input component
  61566. */
  61567. get cutoff(): NodeMaterialConnectionPoint;
  61568. protected _buildBlock(state: NodeMaterialBuildState): this;
  61569. }
  61570. }
  61571. declare module BABYLON {
  61572. /**
  61573. * Block used to test if the fragment shader is front facing
  61574. */
  61575. export class FrontFacingBlock extends NodeMaterialBlock {
  61576. /**
  61577. * Creates a new FrontFacingBlock
  61578. * @param name defines the block name
  61579. */
  61580. constructor(name: string);
  61581. /**
  61582. * Gets the current class name
  61583. * @returns the class name
  61584. */
  61585. getClassName(): string;
  61586. /**
  61587. * Gets the output component
  61588. */
  61589. get output(): NodeMaterialConnectionPoint;
  61590. protected _buildBlock(state: NodeMaterialBuildState): this;
  61591. }
  61592. }
  61593. declare module BABYLON {
  61594. /**
  61595. * Block used to get the derivative value on x and y of a given input
  61596. */
  61597. export class DerivativeBlock extends NodeMaterialBlock {
  61598. /**
  61599. * Create a new DerivativeBlock
  61600. * @param name defines the block name
  61601. */
  61602. constructor(name: string);
  61603. /**
  61604. * Gets the current class name
  61605. * @returns the class name
  61606. */
  61607. getClassName(): string;
  61608. /**
  61609. * Gets the input component
  61610. */
  61611. get input(): NodeMaterialConnectionPoint;
  61612. /**
  61613. * Gets the derivative output on x
  61614. */
  61615. get dx(): NodeMaterialConnectionPoint;
  61616. /**
  61617. * Gets the derivative output on y
  61618. */
  61619. get dy(): NodeMaterialConnectionPoint;
  61620. protected _buildBlock(state: NodeMaterialBuildState): this;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * Block used to make gl_FragCoord available
  61626. */
  61627. export class FragCoordBlock extends NodeMaterialBlock {
  61628. /**
  61629. * Creates a new FragCoordBlock
  61630. * @param name defines the block name
  61631. */
  61632. constructor(name: string);
  61633. /**
  61634. * Gets the current class name
  61635. * @returns the class name
  61636. */
  61637. getClassName(): string;
  61638. /**
  61639. * Gets the xy component
  61640. */
  61641. get xy(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the xyz component
  61644. */
  61645. get xyz(): NodeMaterialConnectionPoint;
  61646. /**
  61647. * Gets the xyzw component
  61648. */
  61649. get xyzw(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the x component
  61652. */
  61653. get x(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the y component
  61656. */
  61657. get y(): NodeMaterialConnectionPoint;
  61658. /**
  61659. * Gets the z component
  61660. */
  61661. get z(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the w component
  61664. */
  61665. get output(): NodeMaterialConnectionPoint;
  61666. protected writeOutputs(state: NodeMaterialBuildState): string;
  61667. protected _buildBlock(state: NodeMaterialBuildState): this;
  61668. }
  61669. }
  61670. declare module BABYLON {
  61671. /**
  61672. * Block used to get the screen sizes
  61673. */
  61674. export class ScreenSizeBlock extends NodeMaterialBlock {
  61675. private _varName;
  61676. private _scene;
  61677. /**
  61678. * Creates a new ScreenSizeBlock
  61679. * @param name defines the block name
  61680. */
  61681. constructor(name: string);
  61682. /**
  61683. * Gets the current class name
  61684. * @returns the class name
  61685. */
  61686. getClassName(): string;
  61687. /**
  61688. * Gets the xy component
  61689. */
  61690. get xy(): NodeMaterialConnectionPoint;
  61691. /**
  61692. * Gets the x component
  61693. */
  61694. get x(): NodeMaterialConnectionPoint;
  61695. /**
  61696. * Gets the y component
  61697. */
  61698. get y(): NodeMaterialConnectionPoint;
  61699. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61700. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61701. protected _buildBlock(state: NodeMaterialBuildState): this;
  61702. }
  61703. }
  61704. declare module BABYLON {
  61705. /**
  61706. * Block used to add support for scene fog
  61707. */
  61708. export class FogBlock extends NodeMaterialBlock {
  61709. private _fogDistanceName;
  61710. private _fogParameters;
  61711. /**
  61712. * Create a new FogBlock
  61713. * @param name defines the block name
  61714. */
  61715. constructor(name: string);
  61716. /**
  61717. * Gets the current class name
  61718. * @returns the class name
  61719. */
  61720. getClassName(): string;
  61721. /**
  61722. * Gets the world position input component
  61723. */
  61724. get worldPosition(): NodeMaterialConnectionPoint;
  61725. /**
  61726. * Gets the view input component
  61727. */
  61728. get view(): NodeMaterialConnectionPoint;
  61729. /**
  61730. * Gets the color input component
  61731. */
  61732. get input(): NodeMaterialConnectionPoint;
  61733. /**
  61734. * Gets the fog color input component
  61735. */
  61736. get fogColor(): NodeMaterialConnectionPoint;
  61737. /**
  61738. * Gets the output component
  61739. */
  61740. get output(): NodeMaterialConnectionPoint;
  61741. autoConfigure(material: NodeMaterial): void;
  61742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61743. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61744. protected _buildBlock(state: NodeMaterialBuildState): this;
  61745. }
  61746. }
  61747. declare module BABYLON {
  61748. /**
  61749. * Block used to add light in the fragment shader
  61750. */
  61751. export class LightBlock extends NodeMaterialBlock {
  61752. private _lightId;
  61753. /**
  61754. * Gets or sets the light associated with this block
  61755. */
  61756. light: Nullable<Light>;
  61757. /**
  61758. * Create a new LightBlock
  61759. * @param name defines the block name
  61760. */
  61761. constructor(name: string);
  61762. /**
  61763. * Gets the current class name
  61764. * @returns the class name
  61765. */
  61766. getClassName(): string;
  61767. /**
  61768. * Gets the world position input component
  61769. */
  61770. get worldPosition(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the world normal input component
  61773. */
  61774. get worldNormal(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the camera (or eye) position component
  61777. */
  61778. get cameraPosition(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the glossiness component
  61781. */
  61782. get glossiness(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the glossinness power component
  61785. */
  61786. get glossPower(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the diffuse color component
  61789. */
  61790. get diffuseColor(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the specular color component
  61793. */
  61794. get specularColor(): NodeMaterialConnectionPoint;
  61795. /**
  61796. * Gets the diffuse output component
  61797. */
  61798. get diffuseOutput(): NodeMaterialConnectionPoint;
  61799. /**
  61800. * Gets the specular output component
  61801. */
  61802. get specularOutput(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the shadow output component
  61805. */
  61806. get shadow(): NodeMaterialConnectionPoint;
  61807. autoConfigure(material: NodeMaterial): void;
  61808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61809. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61811. private _injectVertexCode;
  61812. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61813. serialize(): any;
  61814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61815. }
  61816. }
  61817. declare module BABYLON {
  61818. /**
  61819. * Block used to read a reflection texture from a sampler
  61820. */
  61821. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61822. /**
  61823. * Create a new ReflectionTextureBlock
  61824. * @param name defines the block name
  61825. */
  61826. constructor(name: string);
  61827. /**
  61828. * Gets the current class name
  61829. * @returns the class name
  61830. */
  61831. getClassName(): string;
  61832. /**
  61833. * Gets the world position input component
  61834. */
  61835. get position(): NodeMaterialConnectionPoint;
  61836. /**
  61837. * Gets the world position input component
  61838. */
  61839. get worldPosition(): NodeMaterialConnectionPoint;
  61840. /**
  61841. * Gets the world normal input component
  61842. */
  61843. get worldNormal(): NodeMaterialConnectionPoint;
  61844. /**
  61845. * Gets the world input component
  61846. */
  61847. get world(): NodeMaterialConnectionPoint;
  61848. /**
  61849. * Gets the camera (or eye) position component
  61850. */
  61851. get cameraPosition(): NodeMaterialConnectionPoint;
  61852. /**
  61853. * Gets the view input component
  61854. */
  61855. get view(): NodeMaterialConnectionPoint;
  61856. /**
  61857. * Gets the rgb output component
  61858. */
  61859. get rgb(): NodeMaterialConnectionPoint;
  61860. /**
  61861. * Gets the rgba output component
  61862. */
  61863. get rgba(): NodeMaterialConnectionPoint;
  61864. /**
  61865. * Gets the r output component
  61866. */
  61867. get r(): NodeMaterialConnectionPoint;
  61868. /**
  61869. * Gets the g output component
  61870. */
  61871. get g(): NodeMaterialConnectionPoint;
  61872. /**
  61873. * Gets the b output component
  61874. */
  61875. get b(): NodeMaterialConnectionPoint;
  61876. /**
  61877. * Gets the a output component
  61878. */
  61879. get a(): NodeMaterialConnectionPoint;
  61880. autoConfigure(material: NodeMaterial): void;
  61881. protected _buildBlock(state: NodeMaterialBuildState): this;
  61882. }
  61883. }
  61884. declare module BABYLON {
  61885. /**
  61886. * Block used to add 2 vectors
  61887. */
  61888. export class AddBlock extends NodeMaterialBlock {
  61889. /**
  61890. * Creates a new AddBlock
  61891. * @param name defines the block name
  61892. */
  61893. constructor(name: string);
  61894. /**
  61895. * Gets the current class name
  61896. * @returns the class name
  61897. */
  61898. getClassName(): string;
  61899. /**
  61900. * Gets the left operand input component
  61901. */
  61902. get left(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the right operand input component
  61905. */
  61906. get right(): NodeMaterialConnectionPoint;
  61907. /**
  61908. * Gets the output component
  61909. */
  61910. get output(): NodeMaterialConnectionPoint;
  61911. protected _buildBlock(state: NodeMaterialBuildState): this;
  61912. }
  61913. }
  61914. declare module BABYLON {
  61915. /**
  61916. * Block used to scale a vector by a float
  61917. */
  61918. export class ScaleBlock extends NodeMaterialBlock {
  61919. /**
  61920. * Creates a new ScaleBlock
  61921. * @param name defines the block name
  61922. */
  61923. constructor(name: string);
  61924. /**
  61925. * Gets the current class name
  61926. * @returns the class name
  61927. */
  61928. getClassName(): string;
  61929. /**
  61930. * Gets the input component
  61931. */
  61932. get input(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the factor input component
  61935. */
  61936. get factor(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the output component
  61939. */
  61940. get output(): NodeMaterialConnectionPoint;
  61941. protected _buildBlock(state: NodeMaterialBuildState): this;
  61942. }
  61943. }
  61944. declare module BABYLON {
  61945. /**
  61946. * Block used to clamp a float
  61947. */
  61948. export class ClampBlock extends NodeMaterialBlock {
  61949. /** Gets or sets the minimum range */
  61950. minimum: number;
  61951. /** Gets or sets the maximum range */
  61952. maximum: number;
  61953. /**
  61954. * Creates a new ClampBlock
  61955. * @param name defines the block name
  61956. */
  61957. constructor(name: string);
  61958. /**
  61959. * Gets the current class name
  61960. * @returns the class name
  61961. */
  61962. getClassName(): string;
  61963. /**
  61964. * Gets the value input component
  61965. */
  61966. get value(): NodeMaterialConnectionPoint;
  61967. /**
  61968. * Gets the output component
  61969. */
  61970. get output(): NodeMaterialConnectionPoint;
  61971. protected _buildBlock(state: NodeMaterialBuildState): this;
  61972. protected _dumpPropertiesCode(): string;
  61973. serialize(): any;
  61974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61975. }
  61976. }
  61977. declare module BABYLON {
  61978. /**
  61979. * Block used to apply a cross product between 2 vectors
  61980. */
  61981. export class CrossBlock extends NodeMaterialBlock {
  61982. /**
  61983. * Creates a new CrossBlock
  61984. * @param name defines the block name
  61985. */
  61986. constructor(name: string);
  61987. /**
  61988. * Gets the current class name
  61989. * @returns the class name
  61990. */
  61991. getClassName(): string;
  61992. /**
  61993. * Gets the left operand input component
  61994. */
  61995. get left(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the right operand input component
  61998. */
  61999. get right(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the output component
  62002. */
  62003. get output(): NodeMaterialConnectionPoint;
  62004. protected _buildBlock(state: NodeMaterialBuildState): this;
  62005. }
  62006. }
  62007. declare module BABYLON {
  62008. /**
  62009. * Block used to apply a dot product between 2 vectors
  62010. */
  62011. export class DotBlock extends NodeMaterialBlock {
  62012. /**
  62013. * Creates a new DotBlock
  62014. * @param name defines the block name
  62015. */
  62016. constructor(name: string);
  62017. /**
  62018. * Gets the current class name
  62019. * @returns the class name
  62020. */
  62021. getClassName(): string;
  62022. /**
  62023. * Gets the left operand input component
  62024. */
  62025. get left(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the right operand input component
  62028. */
  62029. get right(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the output component
  62032. */
  62033. get output(): NodeMaterialConnectionPoint;
  62034. protected _buildBlock(state: NodeMaterialBuildState): this;
  62035. }
  62036. }
  62037. declare module BABYLON {
  62038. /**
  62039. * Block used to normalize a vector
  62040. */
  62041. export class NormalizeBlock extends NodeMaterialBlock {
  62042. /**
  62043. * Creates a new NormalizeBlock
  62044. * @param name defines the block name
  62045. */
  62046. constructor(name: string);
  62047. /**
  62048. * Gets the current class name
  62049. * @returns the class name
  62050. */
  62051. getClassName(): string;
  62052. /**
  62053. * Gets the input component
  62054. */
  62055. get input(): NodeMaterialConnectionPoint;
  62056. /**
  62057. * Gets the output component
  62058. */
  62059. get output(): NodeMaterialConnectionPoint;
  62060. protected _buildBlock(state: NodeMaterialBuildState): this;
  62061. }
  62062. }
  62063. declare module BABYLON {
  62064. /**
  62065. * Operations supported by the Trigonometry block
  62066. */
  62067. export enum TrigonometryBlockOperations {
  62068. /** Cos */
  62069. Cos = 0,
  62070. /** Sin */
  62071. Sin = 1,
  62072. /** Abs */
  62073. Abs = 2,
  62074. /** Exp */
  62075. Exp = 3,
  62076. /** Exp2 */
  62077. Exp2 = 4,
  62078. /** Round */
  62079. Round = 5,
  62080. /** Floor */
  62081. Floor = 6,
  62082. /** Ceiling */
  62083. Ceiling = 7,
  62084. /** Square root */
  62085. Sqrt = 8,
  62086. /** Log */
  62087. Log = 9,
  62088. /** Tangent */
  62089. Tan = 10,
  62090. /** Arc tangent */
  62091. ArcTan = 11,
  62092. /** Arc cosinus */
  62093. ArcCos = 12,
  62094. /** Arc sinus */
  62095. ArcSin = 13,
  62096. /** Fraction */
  62097. Fract = 14,
  62098. /** Sign */
  62099. Sign = 15,
  62100. /** To radians (from degrees) */
  62101. Radians = 16,
  62102. /** To degrees (from radians) */
  62103. Degrees = 17
  62104. }
  62105. /**
  62106. * Block used to apply trigonometry operation to floats
  62107. */
  62108. export class TrigonometryBlock extends NodeMaterialBlock {
  62109. /**
  62110. * Gets or sets the operation applied by the block
  62111. */
  62112. operation: TrigonometryBlockOperations;
  62113. /**
  62114. * Creates a new TrigonometryBlock
  62115. * @param name defines the block name
  62116. */
  62117. constructor(name: string);
  62118. /**
  62119. * Gets the current class name
  62120. * @returns the class name
  62121. */
  62122. getClassName(): string;
  62123. /**
  62124. * Gets the input component
  62125. */
  62126. get input(): NodeMaterialConnectionPoint;
  62127. /**
  62128. * Gets the output component
  62129. */
  62130. get output(): NodeMaterialConnectionPoint;
  62131. protected _buildBlock(state: NodeMaterialBuildState): this;
  62132. serialize(): any;
  62133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62134. protected _dumpPropertiesCode(): string;
  62135. }
  62136. }
  62137. declare module BABYLON {
  62138. /**
  62139. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62140. */
  62141. export class ColorMergerBlock extends NodeMaterialBlock {
  62142. /**
  62143. * Create a new ColorMergerBlock
  62144. * @param name defines the block name
  62145. */
  62146. constructor(name: string);
  62147. /**
  62148. * Gets the current class name
  62149. * @returns the class name
  62150. */
  62151. getClassName(): string;
  62152. /**
  62153. * Gets the rgb component (input)
  62154. */
  62155. get rgbIn(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the r component (input)
  62158. */
  62159. get r(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the g component (input)
  62162. */
  62163. get g(): NodeMaterialConnectionPoint;
  62164. /**
  62165. * Gets the b component (input)
  62166. */
  62167. get b(): NodeMaterialConnectionPoint;
  62168. /**
  62169. * Gets the a component (input)
  62170. */
  62171. get a(): NodeMaterialConnectionPoint;
  62172. /**
  62173. * Gets the rgba component (output)
  62174. */
  62175. get rgba(): NodeMaterialConnectionPoint;
  62176. /**
  62177. * Gets the rgb component (output)
  62178. */
  62179. get rgbOut(): NodeMaterialConnectionPoint;
  62180. /**
  62181. * Gets the rgb component (output)
  62182. * @deprecated Please use rgbOut instead.
  62183. */
  62184. get rgb(): NodeMaterialConnectionPoint;
  62185. protected _buildBlock(state: NodeMaterialBuildState): this;
  62186. }
  62187. }
  62188. declare module BABYLON {
  62189. /**
  62190. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62191. */
  62192. export class VectorSplitterBlock extends NodeMaterialBlock {
  62193. /**
  62194. * Create a new VectorSplitterBlock
  62195. * @param name defines the block name
  62196. */
  62197. constructor(name: string);
  62198. /**
  62199. * Gets the current class name
  62200. * @returns the class name
  62201. */
  62202. getClassName(): string;
  62203. /**
  62204. * Gets the xyzw component (input)
  62205. */
  62206. get xyzw(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the xyz component (input)
  62209. */
  62210. get xyzIn(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the xy component (input)
  62213. */
  62214. get xyIn(): NodeMaterialConnectionPoint;
  62215. /**
  62216. * Gets the xyz component (output)
  62217. */
  62218. get xyzOut(): NodeMaterialConnectionPoint;
  62219. /**
  62220. * Gets the xy component (output)
  62221. */
  62222. get xyOut(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the x component (output)
  62225. */
  62226. get x(): NodeMaterialConnectionPoint;
  62227. /**
  62228. * Gets the y component (output)
  62229. */
  62230. get y(): NodeMaterialConnectionPoint;
  62231. /**
  62232. * Gets the z component (output)
  62233. */
  62234. get z(): NodeMaterialConnectionPoint;
  62235. /**
  62236. * Gets the w component (output)
  62237. */
  62238. get w(): NodeMaterialConnectionPoint;
  62239. protected _inputRename(name: string): string;
  62240. protected _outputRename(name: string): string;
  62241. protected _buildBlock(state: NodeMaterialBuildState): this;
  62242. }
  62243. }
  62244. declare module BABYLON {
  62245. /**
  62246. * Block used to lerp between 2 values
  62247. */
  62248. export class LerpBlock extends NodeMaterialBlock {
  62249. /**
  62250. * Creates a new LerpBlock
  62251. * @param name defines the block name
  62252. */
  62253. constructor(name: string);
  62254. /**
  62255. * Gets the current class name
  62256. * @returns the class name
  62257. */
  62258. getClassName(): string;
  62259. /**
  62260. * Gets the left operand input component
  62261. */
  62262. get left(): NodeMaterialConnectionPoint;
  62263. /**
  62264. * Gets the right operand input component
  62265. */
  62266. get right(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the gradient operand input component
  62269. */
  62270. get gradient(): NodeMaterialConnectionPoint;
  62271. /**
  62272. * Gets the output component
  62273. */
  62274. get output(): NodeMaterialConnectionPoint;
  62275. protected _buildBlock(state: NodeMaterialBuildState): this;
  62276. }
  62277. }
  62278. declare module BABYLON {
  62279. /**
  62280. * Block used to divide 2 vectors
  62281. */
  62282. export class DivideBlock extends NodeMaterialBlock {
  62283. /**
  62284. * Creates a new DivideBlock
  62285. * @param name defines the block name
  62286. */
  62287. constructor(name: string);
  62288. /**
  62289. * Gets the current class name
  62290. * @returns the class name
  62291. */
  62292. getClassName(): string;
  62293. /**
  62294. * Gets the left operand input component
  62295. */
  62296. get left(): NodeMaterialConnectionPoint;
  62297. /**
  62298. * Gets the right operand input component
  62299. */
  62300. get right(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the output component
  62303. */
  62304. get output(): NodeMaterialConnectionPoint;
  62305. protected _buildBlock(state: NodeMaterialBuildState): this;
  62306. }
  62307. }
  62308. declare module BABYLON {
  62309. /**
  62310. * Block used to subtract 2 vectors
  62311. */
  62312. export class SubtractBlock extends NodeMaterialBlock {
  62313. /**
  62314. * Creates a new SubtractBlock
  62315. * @param name defines the block name
  62316. */
  62317. constructor(name: string);
  62318. /**
  62319. * Gets the current class name
  62320. * @returns the class name
  62321. */
  62322. getClassName(): string;
  62323. /**
  62324. * Gets the left operand input component
  62325. */
  62326. get left(): NodeMaterialConnectionPoint;
  62327. /**
  62328. * Gets the right operand input component
  62329. */
  62330. get right(): NodeMaterialConnectionPoint;
  62331. /**
  62332. * Gets the output component
  62333. */
  62334. get output(): NodeMaterialConnectionPoint;
  62335. protected _buildBlock(state: NodeMaterialBuildState): this;
  62336. }
  62337. }
  62338. declare module BABYLON {
  62339. /**
  62340. * Block used to step a value
  62341. */
  62342. export class StepBlock extends NodeMaterialBlock {
  62343. /**
  62344. * Creates a new StepBlock
  62345. * @param name defines the block name
  62346. */
  62347. constructor(name: string);
  62348. /**
  62349. * Gets the current class name
  62350. * @returns the class name
  62351. */
  62352. getClassName(): string;
  62353. /**
  62354. * Gets the value operand input component
  62355. */
  62356. get value(): NodeMaterialConnectionPoint;
  62357. /**
  62358. * Gets the edge operand input component
  62359. */
  62360. get edge(): NodeMaterialConnectionPoint;
  62361. /**
  62362. * Gets the output component
  62363. */
  62364. get output(): NodeMaterialConnectionPoint;
  62365. protected _buildBlock(state: NodeMaterialBuildState): this;
  62366. }
  62367. }
  62368. declare module BABYLON {
  62369. /**
  62370. * Block used to get the opposite (1 - x) of a value
  62371. */
  62372. export class OneMinusBlock extends NodeMaterialBlock {
  62373. /**
  62374. * Creates a new OneMinusBlock
  62375. * @param name defines the block name
  62376. */
  62377. constructor(name: string);
  62378. /**
  62379. * Gets the current class name
  62380. * @returns the class name
  62381. */
  62382. getClassName(): string;
  62383. /**
  62384. * Gets the input component
  62385. */
  62386. get input(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the output component
  62389. */
  62390. get output(): NodeMaterialConnectionPoint;
  62391. protected _buildBlock(state: NodeMaterialBuildState): this;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * Block used to get the view direction
  62397. */
  62398. export class ViewDirectionBlock extends NodeMaterialBlock {
  62399. /**
  62400. * Creates a new ViewDirectionBlock
  62401. * @param name defines the block name
  62402. */
  62403. constructor(name: string);
  62404. /**
  62405. * Gets the current class name
  62406. * @returns the class name
  62407. */
  62408. getClassName(): string;
  62409. /**
  62410. * Gets the world position component
  62411. */
  62412. get worldPosition(): NodeMaterialConnectionPoint;
  62413. /**
  62414. * Gets the camera position component
  62415. */
  62416. get cameraPosition(): NodeMaterialConnectionPoint;
  62417. /**
  62418. * Gets the output component
  62419. */
  62420. get output(): NodeMaterialConnectionPoint;
  62421. autoConfigure(material: NodeMaterial): void;
  62422. protected _buildBlock(state: NodeMaterialBuildState): this;
  62423. }
  62424. }
  62425. declare module BABYLON {
  62426. /**
  62427. * Block used to compute fresnel value
  62428. */
  62429. export class FresnelBlock extends NodeMaterialBlock {
  62430. /**
  62431. * Create a new FresnelBlock
  62432. * @param name defines the block name
  62433. */
  62434. constructor(name: string);
  62435. /**
  62436. * Gets the current class name
  62437. * @returns the class name
  62438. */
  62439. getClassName(): string;
  62440. /**
  62441. * Gets the world normal input component
  62442. */
  62443. get worldNormal(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the view direction input component
  62446. */
  62447. get viewDirection(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the bias input component
  62450. */
  62451. get bias(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the camera (or eye) position component
  62454. */
  62455. get power(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the fresnel output component
  62458. */
  62459. get fresnel(): NodeMaterialConnectionPoint;
  62460. autoConfigure(material: NodeMaterial): void;
  62461. protected _buildBlock(state: NodeMaterialBuildState): this;
  62462. }
  62463. }
  62464. declare module BABYLON {
  62465. /**
  62466. * Block used to get the max of 2 values
  62467. */
  62468. export class MaxBlock extends NodeMaterialBlock {
  62469. /**
  62470. * Creates a new MaxBlock
  62471. * @param name defines the block name
  62472. */
  62473. constructor(name: string);
  62474. /**
  62475. * Gets the current class name
  62476. * @returns the class name
  62477. */
  62478. getClassName(): string;
  62479. /**
  62480. * Gets the left operand input component
  62481. */
  62482. get left(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the right operand input component
  62485. */
  62486. get right(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the output component
  62489. */
  62490. get output(): NodeMaterialConnectionPoint;
  62491. protected _buildBlock(state: NodeMaterialBuildState): this;
  62492. }
  62493. }
  62494. declare module BABYLON {
  62495. /**
  62496. * Block used to get the min of 2 values
  62497. */
  62498. export class MinBlock extends NodeMaterialBlock {
  62499. /**
  62500. * Creates a new MinBlock
  62501. * @param name defines the block name
  62502. */
  62503. constructor(name: string);
  62504. /**
  62505. * Gets the current class name
  62506. * @returns the class name
  62507. */
  62508. getClassName(): string;
  62509. /**
  62510. * Gets the left operand input component
  62511. */
  62512. get left(): NodeMaterialConnectionPoint;
  62513. /**
  62514. * Gets the right operand input component
  62515. */
  62516. get right(): NodeMaterialConnectionPoint;
  62517. /**
  62518. * Gets the output component
  62519. */
  62520. get output(): NodeMaterialConnectionPoint;
  62521. protected _buildBlock(state: NodeMaterialBuildState): this;
  62522. }
  62523. }
  62524. declare module BABYLON {
  62525. /**
  62526. * Block used to get the distance between 2 values
  62527. */
  62528. export class DistanceBlock extends NodeMaterialBlock {
  62529. /**
  62530. * Creates a new DistanceBlock
  62531. * @param name defines the block name
  62532. */
  62533. constructor(name: string);
  62534. /**
  62535. * Gets the current class name
  62536. * @returns the class name
  62537. */
  62538. getClassName(): string;
  62539. /**
  62540. * Gets the left operand input component
  62541. */
  62542. get left(): NodeMaterialConnectionPoint;
  62543. /**
  62544. * Gets the right operand input component
  62545. */
  62546. get right(): NodeMaterialConnectionPoint;
  62547. /**
  62548. * Gets the output component
  62549. */
  62550. get output(): NodeMaterialConnectionPoint;
  62551. protected _buildBlock(state: NodeMaterialBuildState): this;
  62552. }
  62553. }
  62554. declare module BABYLON {
  62555. /**
  62556. * Block used to get the length of a vector
  62557. */
  62558. export class LengthBlock extends NodeMaterialBlock {
  62559. /**
  62560. * Creates a new LengthBlock
  62561. * @param name defines the block name
  62562. */
  62563. constructor(name: string);
  62564. /**
  62565. * Gets the current class name
  62566. * @returns the class name
  62567. */
  62568. getClassName(): string;
  62569. /**
  62570. * Gets the value input component
  62571. */
  62572. get value(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the output component
  62575. */
  62576. get output(): NodeMaterialConnectionPoint;
  62577. protected _buildBlock(state: NodeMaterialBuildState): this;
  62578. }
  62579. }
  62580. declare module BABYLON {
  62581. /**
  62582. * Block used to get negative version of a value (i.e. x * -1)
  62583. */
  62584. export class NegateBlock extends NodeMaterialBlock {
  62585. /**
  62586. * Creates a new NegateBlock
  62587. * @param name defines the block name
  62588. */
  62589. constructor(name: string);
  62590. /**
  62591. * Gets the current class name
  62592. * @returns the class name
  62593. */
  62594. getClassName(): string;
  62595. /**
  62596. * Gets the value input component
  62597. */
  62598. get value(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Gets the output component
  62601. */
  62602. get output(): NodeMaterialConnectionPoint;
  62603. protected _buildBlock(state: NodeMaterialBuildState): this;
  62604. }
  62605. }
  62606. declare module BABYLON {
  62607. /**
  62608. * Block used to get the value of the first parameter raised to the power of the second
  62609. */
  62610. export class PowBlock extends NodeMaterialBlock {
  62611. /**
  62612. * Creates a new PowBlock
  62613. * @param name defines the block name
  62614. */
  62615. constructor(name: string);
  62616. /**
  62617. * Gets the current class name
  62618. * @returns the class name
  62619. */
  62620. getClassName(): string;
  62621. /**
  62622. * Gets the value operand input component
  62623. */
  62624. get value(): NodeMaterialConnectionPoint;
  62625. /**
  62626. * Gets the power operand input component
  62627. */
  62628. get power(): NodeMaterialConnectionPoint;
  62629. /**
  62630. * Gets the output component
  62631. */
  62632. get output(): NodeMaterialConnectionPoint;
  62633. protected _buildBlock(state: NodeMaterialBuildState): this;
  62634. }
  62635. }
  62636. declare module BABYLON {
  62637. /**
  62638. * Block used to get a random number
  62639. */
  62640. export class RandomNumberBlock extends NodeMaterialBlock {
  62641. /**
  62642. * Creates a new RandomNumberBlock
  62643. * @param name defines the block name
  62644. */
  62645. constructor(name: string);
  62646. /**
  62647. * Gets the current class name
  62648. * @returns the class name
  62649. */
  62650. getClassName(): string;
  62651. /**
  62652. * Gets the seed input component
  62653. */
  62654. get seed(): NodeMaterialConnectionPoint;
  62655. /**
  62656. * Gets the output component
  62657. */
  62658. get output(): NodeMaterialConnectionPoint;
  62659. protected _buildBlock(state: NodeMaterialBuildState): this;
  62660. }
  62661. }
  62662. declare module BABYLON {
  62663. /**
  62664. * Block used to compute arc tangent of 2 values
  62665. */
  62666. export class ArcTan2Block extends NodeMaterialBlock {
  62667. /**
  62668. * Creates a new ArcTan2Block
  62669. * @param name defines the block name
  62670. */
  62671. constructor(name: string);
  62672. /**
  62673. * Gets the current class name
  62674. * @returns the class name
  62675. */
  62676. getClassName(): string;
  62677. /**
  62678. * Gets the x operand input component
  62679. */
  62680. get x(): NodeMaterialConnectionPoint;
  62681. /**
  62682. * Gets the y operand input component
  62683. */
  62684. get y(): NodeMaterialConnectionPoint;
  62685. /**
  62686. * Gets the output component
  62687. */
  62688. get output(): NodeMaterialConnectionPoint;
  62689. protected _buildBlock(state: NodeMaterialBuildState): this;
  62690. }
  62691. }
  62692. declare module BABYLON {
  62693. /**
  62694. * Block used to smooth step a value
  62695. */
  62696. export class SmoothStepBlock extends NodeMaterialBlock {
  62697. /**
  62698. * Creates a new SmoothStepBlock
  62699. * @param name defines the block name
  62700. */
  62701. constructor(name: string);
  62702. /**
  62703. * Gets the current class name
  62704. * @returns the class name
  62705. */
  62706. getClassName(): string;
  62707. /**
  62708. * Gets the value operand input component
  62709. */
  62710. get value(): NodeMaterialConnectionPoint;
  62711. /**
  62712. * Gets the first edge operand input component
  62713. */
  62714. get edge0(): NodeMaterialConnectionPoint;
  62715. /**
  62716. * Gets the second edge operand input component
  62717. */
  62718. get edge1(): NodeMaterialConnectionPoint;
  62719. /**
  62720. * Gets the output component
  62721. */
  62722. get output(): NodeMaterialConnectionPoint;
  62723. protected _buildBlock(state: NodeMaterialBuildState): this;
  62724. }
  62725. }
  62726. declare module BABYLON {
  62727. /**
  62728. * Block used to get the reciprocal (1 / x) of a value
  62729. */
  62730. export class ReciprocalBlock extends NodeMaterialBlock {
  62731. /**
  62732. * Creates a new ReciprocalBlock
  62733. * @param name defines the block name
  62734. */
  62735. constructor(name: string);
  62736. /**
  62737. * Gets the current class name
  62738. * @returns the class name
  62739. */
  62740. getClassName(): string;
  62741. /**
  62742. * Gets the input component
  62743. */
  62744. get input(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the output component
  62747. */
  62748. get output(): NodeMaterialConnectionPoint;
  62749. protected _buildBlock(state: NodeMaterialBuildState): this;
  62750. }
  62751. }
  62752. declare module BABYLON {
  62753. /**
  62754. * Block used to replace a color by another one
  62755. */
  62756. export class ReplaceColorBlock extends NodeMaterialBlock {
  62757. /**
  62758. * Creates a new ReplaceColorBlock
  62759. * @param name defines the block name
  62760. */
  62761. constructor(name: string);
  62762. /**
  62763. * Gets the current class name
  62764. * @returns the class name
  62765. */
  62766. getClassName(): string;
  62767. /**
  62768. * Gets the value input component
  62769. */
  62770. get value(): NodeMaterialConnectionPoint;
  62771. /**
  62772. * Gets the reference input component
  62773. */
  62774. get reference(): NodeMaterialConnectionPoint;
  62775. /**
  62776. * Gets the distance input component
  62777. */
  62778. get distance(): NodeMaterialConnectionPoint;
  62779. /**
  62780. * Gets the replacement input component
  62781. */
  62782. get replacement(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. }
  62789. }
  62790. declare module BABYLON {
  62791. /**
  62792. * Block used to posterize a value
  62793. * @see https://en.wikipedia.org/wiki/Posterization
  62794. */
  62795. export class PosterizeBlock extends NodeMaterialBlock {
  62796. /**
  62797. * Creates a new PosterizeBlock
  62798. * @param name defines the block name
  62799. */
  62800. constructor(name: string);
  62801. /**
  62802. * Gets the current class name
  62803. * @returns the class name
  62804. */
  62805. getClassName(): string;
  62806. /**
  62807. * Gets the value input component
  62808. */
  62809. get value(): NodeMaterialConnectionPoint;
  62810. /**
  62811. * Gets the steps input component
  62812. */
  62813. get steps(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the output component
  62816. */
  62817. get output(): NodeMaterialConnectionPoint;
  62818. protected _buildBlock(state: NodeMaterialBuildState): this;
  62819. }
  62820. }
  62821. declare module BABYLON {
  62822. /**
  62823. * Operations supported by the Wave block
  62824. */
  62825. export enum WaveBlockKind {
  62826. /** SawTooth */
  62827. SawTooth = 0,
  62828. /** Square */
  62829. Square = 1,
  62830. /** Triangle */
  62831. Triangle = 2
  62832. }
  62833. /**
  62834. * Block used to apply wave operation to floats
  62835. */
  62836. export class WaveBlock extends NodeMaterialBlock {
  62837. /**
  62838. * Gets or sets the kibnd of wave to be applied by the block
  62839. */
  62840. kind: WaveBlockKind;
  62841. /**
  62842. * Creates a new WaveBlock
  62843. * @param name defines the block name
  62844. */
  62845. constructor(name: string);
  62846. /**
  62847. * Gets the current class name
  62848. * @returns the class name
  62849. */
  62850. getClassName(): string;
  62851. /**
  62852. * Gets the input component
  62853. */
  62854. get input(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the output component
  62857. */
  62858. get output(): NodeMaterialConnectionPoint;
  62859. protected _buildBlock(state: NodeMaterialBuildState): this;
  62860. serialize(): any;
  62861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62862. }
  62863. }
  62864. declare module BABYLON {
  62865. /**
  62866. * Class used to store a color step for the GradientBlock
  62867. */
  62868. export class GradientBlockColorStep {
  62869. /**
  62870. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62871. */
  62872. step: number;
  62873. /**
  62874. * Gets or sets the color associated with this step
  62875. */
  62876. color: Color3;
  62877. /**
  62878. * Creates a new GradientBlockColorStep
  62879. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62880. * @param color defines the color associated with this step
  62881. */
  62882. constructor(
  62883. /**
  62884. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62885. */
  62886. step: number,
  62887. /**
  62888. * Gets or sets the color associated with this step
  62889. */
  62890. color: Color3);
  62891. }
  62892. /**
  62893. * Block used to return a color from a gradient based on an input value between 0 and 1
  62894. */
  62895. export class GradientBlock extends NodeMaterialBlock {
  62896. /**
  62897. * Gets or sets the list of color steps
  62898. */
  62899. colorSteps: GradientBlockColorStep[];
  62900. /**
  62901. * Creates a new GradientBlock
  62902. * @param name defines the block name
  62903. */
  62904. constructor(name: string);
  62905. /**
  62906. * Gets the current class name
  62907. * @returns the class name
  62908. */
  62909. getClassName(): string;
  62910. /**
  62911. * Gets the gradient input component
  62912. */
  62913. get gradient(): NodeMaterialConnectionPoint;
  62914. /**
  62915. * Gets the output component
  62916. */
  62917. get output(): NodeMaterialConnectionPoint;
  62918. private _writeColorConstant;
  62919. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62920. serialize(): any;
  62921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62922. protected _dumpPropertiesCode(): string;
  62923. }
  62924. }
  62925. declare module BABYLON {
  62926. /**
  62927. * Block used to normalize lerp between 2 values
  62928. */
  62929. export class NLerpBlock extends NodeMaterialBlock {
  62930. /**
  62931. * Creates a new NLerpBlock
  62932. * @param name defines the block name
  62933. */
  62934. constructor(name: string);
  62935. /**
  62936. * Gets the current class name
  62937. * @returns the class name
  62938. */
  62939. getClassName(): string;
  62940. /**
  62941. * Gets the left operand input component
  62942. */
  62943. get left(): NodeMaterialConnectionPoint;
  62944. /**
  62945. * Gets the right operand input component
  62946. */
  62947. get right(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the gradient operand input component
  62950. */
  62951. get gradient(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the output component
  62954. */
  62955. get output(): NodeMaterialConnectionPoint;
  62956. protected _buildBlock(state: NodeMaterialBuildState): this;
  62957. }
  62958. }
  62959. declare module BABYLON {
  62960. /**
  62961. * block used to Generate a Worley Noise 3D Noise Pattern
  62962. */
  62963. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62964. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62965. manhattanDistance: boolean;
  62966. /**
  62967. * Creates a new WorleyNoise3DBlock
  62968. * @param name defines the block name
  62969. */
  62970. constructor(name: string);
  62971. /**
  62972. * Gets the current class name
  62973. * @returns the class name
  62974. */
  62975. getClassName(): string;
  62976. /**
  62977. * Gets the seed input component
  62978. */
  62979. get seed(): NodeMaterialConnectionPoint;
  62980. /**
  62981. * Gets the jitter input component
  62982. */
  62983. get jitter(): NodeMaterialConnectionPoint;
  62984. /**
  62985. * Gets the output component
  62986. */
  62987. get output(): NodeMaterialConnectionPoint;
  62988. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62989. /**
  62990. * Exposes the properties to the UI?
  62991. */
  62992. protected _dumpPropertiesCode(): string;
  62993. /**
  62994. * Exposes the properties to the Seralize?
  62995. */
  62996. serialize(): any;
  62997. /**
  62998. * Exposes the properties to the deseralize?
  62999. */
  63000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63001. }
  63002. }
  63003. declare module BABYLON {
  63004. /**
  63005. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63006. */
  63007. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63008. /**
  63009. * Creates a new SimplexPerlin3DBlock
  63010. * @param name defines the block name
  63011. */
  63012. constructor(name: string);
  63013. /**
  63014. * Gets the current class name
  63015. * @returns the class name
  63016. */
  63017. getClassName(): string;
  63018. /**
  63019. * Gets the seed operand input component
  63020. */
  63021. get seed(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the output component
  63024. */
  63025. get output(): NodeMaterialConnectionPoint;
  63026. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63027. }
  63028. }
  63029. declare module BABYLON {
  63030. /**
  63031. * Block used to blend normals
  63032. */
  63033. export class NormalBlendBlock extends NodeMaterialBlock {
  63034. /**
  63035. * Creates a new NormalBlendBlock
  63036. * @param name defines the block name
  63037. */
  63038. constructor(name: string);
  63039. /**
  63040. * Gets the current class name
  63041. * @returns the class name
  63042. */
  63043. getClassName(): string;
  63044. /**
  63045. * Gets the first input component
  63046. */
  63047. get normalMap0(): NodeMaterialConnectionPoint;
  63048. /**
  63049. * Gets the second input component
  63050. */
  63051. get normalMap1(): NodeMaterialConnectionPoint;
  63052. /**
  63053. * Gets the output component
  63054. */
  63055. get output(): NodeMaterialConnectionPoint;
  63056. protected _buildBlock(state: NodeMaterialBuildState): this;
  63057. }
  63058. }
  63059. declare module BABYLON {
  63060. /**
  63061. * Block used to rotate a 2d vector by a given angle
  63062. */
  63063. export class Rotate2dBlock extends NodeMaterialBlock {
  63064. /**
  63065. * Creates a new Rotate2dBlock
  63066. * @param name defines the block name
  63067. */
  63068. constructor(name: string);
  63069. /**
  63070. * Gets the current class name
  63071. * @returns the class name
  63072. */
  63073. getClassName(): string;
  63074. /**
  63075. * Gets the input vector
  63076. */
  63077. get input(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the input angle
  63080. */
  63081. get angle(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the output component
  63084. */
  63085. get output(): NodeMaterialConnectionPoint;
  63086. autoConfigure(material: NodeMaterial): void;
  63087. protected _buildBlock(state: NodeMaterialBuildState): this;
  63088. }
  63089. }
  63090. declare module BABYLON {
  63091. /**
  63092. * Block used to get the reflected vector from a direction and a normal
  63093. */
  63094. export class ReflectBlock extends NodeMaterialBlock {
  63095. /**
  63096. * Creates a new ReflectBlock
  63097. * @param name defines the block name
  63098. */
  63099. constructor(name: string);
  63100. /**
  63101. * Gets the current class name
  63102. * @returns the class name
  63103. */
  63104. getClassName(): string;
  63105. /**
  63106. * Gets the incident component
  63107. */
  63108. get incident(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the normal component
  63111. */
  63112. get normal(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the output component
  63115. */
  63116. get output(): NodeMaterialConnectionPoint;
  63117. protected _buildBlock(state: NodeMaterialBuildState): this;
  63118. }
  63119. }
  63120. declare module BABYLON {
  63121. /**
  63122. * Block used to get the refracted vector from a direction and a normal
  63123. */
  63124. export class RefractBlock extends NodeMaterialBlock {
  63125. /**
  63126. * Creates a new RefractBlock
  63127. * @param name defines the block name
  63128. */
  63129. constructor(name: string);
  63130. /**
  63131. * Gets the current class name
  63132. * @returns the class name
  63133. */
  63134. getClassName(): string;
  63135. /**
  63136. * Gets the incident component
  63137. */
  63138. get incident(): NodeMaterialConnectionPoint;
  63139. /**
  63140. * Gets the normal component
  63141. */
  63142. get normal(): NodeMaterialConnectionPoint;
  63143. /**
  63144. * Gets the index of refraction component
  63145. */
  63146. get ior(): NodeMaterialConnectionPoint;
  63147. /**
  63148. * Gets the output component
  63149. */
  63150. get output(): NodeMaterialConnectionPoint;
  63151. protected _buildBlock(state: NodeMaterialBuildState): this;
  63152. }
  63153. }
  63154. declare module BABYLON {
  63155. /**
  63156. * Block used to desaturate a color
  63157. */
  63158. export class DesaturateBlock extends NodeMaterialBlock {
  63159. /**
  63160. * Creates a new DesaturateBlock
  63161. * @param name defines the block name
  63162. */
  63163. constructor(name: string);
  63164. /**
  63165. * Gets the current class name
  63166. * @returns the class name
  63167. */
  63168. getClassName(): string;
  63169. /**
  63170. * Gets the color operand input component
  63171. */
  63172. get color(): NodeMaterialConnectionPoint;
  63173. /**
  63174. * Gets the level operand input component
  63175. */
  63176. get level(): NodeMaterialConnectionPoint;
  63177. /**
  63178. * Gets the output component
  63179. */
  63180. get output(): NodeMaterialConnectionPoint;
  63181. protected _buildBlock(state: NodeMaterialBuildState): this;
  63182. }
  63183. }
  63184. declare module BABYLON {
  63185. /**
  63186. * Block used to implement the ambient occlusion module of the PBR material
  63187. */
  63188. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63189. /**
  63190. * Create a new AmbientOcclusionBlock
  63191. * @param name defines the block name
  63192. */
  63193. constructor(name: string);
  63194. /**
  63195. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63196. */
  63197. useAmbientInGrayScale: boolean;
  63198. /**
  63199. * Initialize the block and prepare the context for build
  63200. * @param state defines the state that will be used for the build
  63201. */
  63202. initialize(state: NodeMaterialBuildState): void;
  63203. /**
  63204. * Gets the current class name
  63205. * @returns the class name
  63206. */
  63207. getClassName(): string;
  63208. /**
  63209. * Gets the texture input component
  63210. */
  63211. get texture(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the texture intensity component
  63214. */
  63215. get intensity(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the direct light intensity input component
  63218. */
  63219. get directLightIntensity(): NodeMaterialConnectionPoint;
  63220. /**
  63221. * Gets the ambient occlusion object output component
  63222. */
  63223. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the main code of the block (fragment side)
  63226. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63227. * @returns the shader code
  63228. */
  63229. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63231. protected _buildBlock(state: NodeMaterialBuildState): this;
  63232. protected _dumpPropertiesCode(): string;
  63233. serialize(): any;
  63234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63235. }
  63236. }
  63237. declare module BABYLON {
  63238. /**
  63239. * Block used to implement the reflection module of the PBR material
  63240. */
  63241. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63242. /** @hidden */
  63243. _defineLODReflectionAlpha: string;
  63244. /** @hidden */
  63245. _defineLinearSpecularReflection: string;
  63246. private _vEnvironmentIrradianceName;
  63247. /** @hidden */
  63248. _vReflectionMicrosurfaceInfosName: string;
  63249. /** @hidden */
  63250. _vReflectionInfosName: string;
  63251. /** @hidden */
  63252. _vReflectionFilteringInfoName: string;
  63253. private _scene;
  63254. /**
  63255. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63256. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63257. * It's less burden on the user side in the editor part.
  63258. */
  63259. /** @hidden */
  63260. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63261. /** @hidden */
  63262. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63263. /** @hidden */
  63264. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63265. /**
  63266. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63267. * diffuse part of the IBL.
  63268. */
  63269. useSphericalHarmonics: boolean;
  63270. /**
  63271. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63272. */
  63273. forceIrradianceInFragment: boolean;
  63274. /**
  63275. * Create a new ReflectionBlock
  63276. * @param name defines the block name
  63277. */
  63278. constructor(name: string);
  63279. /**
  63280. * Gets the current class name
  63281. * @returns the class name
  63282. */
  63283. getClassName(): string;
  63284. /**
  63285. * Gets the position input component
  63286. */
  63287. get position(): NodeMaterialConnectionPoint;
  63288. /**
  63289. * Gets the world position input component
  63290. */
  63291. get worldPosition(): NodeMaterialConnectionPoint;
  63292. /**
  63293. * Gets the world normal input component
  63294. */
  63295. get worldNormal(): NodeMaterialConnectionPoint;
  63296. /**
  63297. * Gets the world input component
  63298. */
  63299. get world(): NodeMaterialConnectionPoint;
  63300. /**
  63301. * Gets the camera (or eye) position component
  63302. */
  63303. get cameraPosition(): NodeMaterialConnectionPoint;
  63304. /**
  63305. * Gets the view input component
  63306. */
  63307. get view(): NodeMaterialConnectionPoint;
  63308. /**
  63309. * Gets the color input component
  63310. */
  63311. get color(): NodeMaterialConnectionPoint;
  63312. /**
  63313. * Gets the reflection object output component
  63314. */
  63315. get reflection(): NodeMaterialConnectionPoint;
  63316. /**
  63317. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63318. */
  63319. get hasTexture(): boolean;
  63320. /**
  63321. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63322. */
  63323. get reflectionColor(): string;
  63324. protected _getTexture(): Nullable<BaseTexture>;
  63325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63327. /**
  63328. * Gets the code to inject in the vertex shader
  63329. * @param state current state of the node material building
  63330. * @returns the shader code
  63331. */
  63332. handleVertexSide(state: NodeMaterialBuildState): string;
  63333. /**
  63334. * Gets the main code of the block (fragment side)
  63335. * @param state current state of the node material building
  63336. * @param normalVarName name of the existing variable corresponding to the normal
  63337. * @returns the shader code
  63338. */
  63339. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63340. protected _buildBlock(state: NodeMaterialBuildState): this;
  63341. protected _dumpPropertiesCode(): string;
  63342. serialize(): any;
  63343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63344. }
  63345. }
  63346. declare module BABYLON {
  63347. /**
  63348. * Block used to implement the sheen module of the PBR material
  63349. */
  63350. export class SheenBlock extends NodeMaterialBlock {
  63351. /**
  63352. * Create a new SheenBlock
  63353. * @param name defines the block name
  63354. */
  63355. constructor(name: string);
  63356. /**
  63357. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63358. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63359. * making it easier to setup and tweak the effect
  63360. */
  63361. albedoScaling: boolean;
  63362. /**
  63363. * Defines if the sheen is linked to the sheen color.
  63364. */
  63365. linkSheenWithAlbedo: boolean;
  63366. /**
  63367. * Initialize the block and prepare the context for build
  63368. * @param state defines the state that will be used for the build
  63369. */
  63370. initialize(state: NodeMaterialBuildState): void;
  63371. /**
  63372. * Gets the current class name
  63373. * @returns the class name
  63374. */
  63375. getClassName(): string;
  63376. /**
  63377. * Gets the intensity input component
  63378. */
  63379. get intensity(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the color input component
  63382. */
  63383. get color(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the roughness input component
  63386. */
  63387. get roughness(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the sheen object output component
  63390. */
  63391. get sheen(): NodeMaterialConnectionPoint;
  63392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63393. /**
  63394. * Gets the main code of the block (fragment side)
  63395. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63396. * @returns the shader code
  63397. */
  63398. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63399. protected _buildBlock(state: NodeMaterialBuildState): this;
  63400. protected _dumpPropertiesCode(): string;
  63401. serialize(): any;
  63402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63403. }
  63404. }
  63405. declare module BABYLON {
  63406. /**
  63407. * Block used to implement the reflectivity module of the PBR material
  63408. */
  63409. export class ReflectivityBlock extends NodeMaterialBlock {
  63410. private _metallicReflectanceColor;
  63411. private _metallicF0Factor;
  63412. /** @hidden */
  63413. _vMetallicReflectanceFactorsName: string;
  63414. /**
  63415. * The property below is set by the main PBR block prior to calling methods of this class.
  63416. */
  63417. /** @hidden */
  63418. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63419. /**
  63420. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63421. */
  63422. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63423. /**
  63424. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63425. */
  63426. useMetallnessFromMetallicTextureBlue: boolean;
  63427. /**
  63428. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63429. */
  63430. useRoughnessFromMetallicTextureAlpha: boolean;
  63431. /**
  63432. * Specifies if the metallic texture contains the roughness information in its green channel.
  63433. */
  63434. useRoughnessFromMetallicTextureGreen: boolean;
  63435. /**
  63436. * Create a new ReflectivityBlock
  63437. * @param name defines the block name
  63438. */
  63439. constructor(name: string);
  63440. /**
  63441. * Initialize the block and prepare the context for build
  63442. * @param state defines the state that will be used for the build
  63443. */
  63444. initialize(state: NodeMaterialBuildState): void;
  63445. /**
  63446. * Gets the current class name
  63447. * @returns the class name
  63448. */
  63449. getClassName(): string;
  63450. /**
  63451. * Gets the metallic input component
  63452. */
  63453. get metallic(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the roughness input component
  63456. */
  63457. get roughness(): NodeMaterialConnectionPoint;
  63458. /**
  63459. * Gets the texture input component
  63460. */
  63461. get texture(): NodeMaterialConnectionPoint;
  63462. /**
  63463. * Gets the reflectivity object output component
  63464. */
  63465. get reflectivity(): NodeMaterialConnectionPoint;
  63466. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63467. /**
  63468. * Gets the main code of the block (fragment side)
  63469. * @param state current state of the node material building
  63470. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63471. * @returns the shader code
  63472. */
  63473. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63475. protected _buildBlock(state: NodeMaterialBuildState): this;
  63476. protected _dumpPropertiesCode(): string;
  63477. serialize(): any;
  63478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63479. }
  63480. }
  63481. declare module BABYLON {
  63482. /**
  63483. * Block used to implement the anisotropy module of the PBR material
  63484. */
  63485. export class AnisotropyBlock extends NodeMaterialBlock {
  63486. /**
  63487. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63488. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63489. * It's less burden on the user side in the editor part.
  63490. */
  63491. /** @hidden */
  63492. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63493. /** @hidden */
  63494. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63495. /**
  63496. * Create a new AnisotropyBlock
  63497. * @param name defines the block name
  63498. */
  63499. constructor(name: string);
  63500. /**
  63501. * Initialize the block and prepare the context for build
  63502. * @param state defines the state that will be used for the build
  63503. */
  63504. initialize(state: NodeMaterialBuildState): void;
  63505. /**
  63506. * Gets the current class name
  63507. * @returns the class name
  63508. */
  63509. getClassName(): string;
  63510. /**
  63511. * Gets the intensity input component
  63512. */
  63513. get intensity(): NodeMaterialConnectionPoint;
  63514. /**
  63515. * Gets the direction input component
  63516. */
  63517. get direction(): NodeMaterialConnectionPoint;
  63518. /**
  63519. * Gets the texture input component
  63520. */
  63521. get texture(): NodeMaterialConnectionPoint;
  63522. /**
  63523. * Gets the uv input component
  63524. */
  63525. get uv(): NodeMaterialConnectionPoint;
  63526. /**
  63527. * Gets the worldTangent input component
  63528. */
  63529. get worldTangent(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the anisotropy object output component
  63532. */
  63533. get anisotropy(): NodeMaterialConnectionPoint;
  63534. private _generateTBNSpace;
  63535. /**
  63536. * Gets the main code of the block (fragment side)
  63537. * @param state current state of the node material building
  63538. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63539. * @returns the shader code
  63540. */
  63541. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63543. protected _buildBlock(state: NodeMaterialBuildState): this;
  63544. }
  63545. }
  63546. declare module BABYLON {
  63547. /**
  63548. * Block used to implement the clear coat module of the PBR material
  63549. */
  63550. export class ClearCoatBlock extends NodeMaterialBlock {
  63551. private _scene;
  63552. /**
  63553. * Create a new ClearCoatBlock
  63554. * @param name defines the block name
  63555. */
  63556. constructor(name: string);
  63557. /**
  63558. * Initialize the block and prepare the context for build
  63559. * @param state defines the state that will be used for the build
  63560. */
  63561. initialize(state: NodeMaterialBuildState): void;
  63562. /**
  63563. * Gets the current class name
  63564. * @returns the class name
  63565. */
  63566. getClassName(): string;
  63567. /**
  63568. * Gets the intensity input component
  63569. */
  63570. get intensity(): NodeMaterialConnectionPoint;
  63571. /**
  63572. * Gets the roughness input component
  63573. */
  63574. get roughness(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the ior input component
  63577. */
  63578. get ior(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the texture input component
  63581. */
  63582. get texture(): NodeMaterialConnectionPoint;
  63583. /**
  63584. * Gets the bump texture input component
  63585. */
  63586. get bumpTexture(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the uv input component
  63589. */
  63590. get uv(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the tint color input component
  63593. */
  63594. get tintColor(): NodeMaterialConnectionPoint;
  63595. /**
  63596. * Gets the tint "at distance" input component
  63597. */
  63598. get tintAtDistance(): NodeMaterialConnectionPoint;
  63599. /**
  63600. * Gets the tint thickness input component
  63601. */
  63602. get tintThickness(): NodeMaterialConnectionPoint;
  63603. /**
  63604. * Gets the world tangent input component
  63605. */
  63606. get worldTangent(): NodeMaterialConnectionPoint;
  63607. /**
  63608. * Gets the clear coat object output component
  63609. */
  63610. get clearcoat(): NodeMaterialConnectionPoint;
  63611. autoConfigure(material: NodeMaterial): void;
  63612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63614. private _generateTBNSpace;
  63615. /**
  63616. * Gets the main code of the block (fragment side)
  63617. * @param state current state of the node material building
  63618. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63619. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63620. * @param worldPosVarName name of the variable holding the world position
  63621. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63622. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63623. * @param worldNormalVarName name of the variable holding the world normal
  63624. * @returns the shader code
  63625. */
  63626. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63627. protected _buildBlock(state: NodeMaterialBuildState): this;
  63628. }
  63629. }
  63630. declare module BABYLON {
  63631. /**
  63632. * Block used to implement the sub surface module of the PBR material
  63633. */
  63634. export class SubSurfaceBlock extends NodeMaterialBlock {
  63635. /**
  63636. * Create a new SubSurfaceBlock
  63637. * @param name defines the block name
  63638. */
  63639. constructor(name: string);
  63640. /**
  63641. * Stores the intensity of the different subsurface effects in the thickness texture.
  63642. * * the green channel is the translucency intensity.
  63643. * * the blue channel is the scattering intensity.
  63644. * * the alpha channel is the refraction intensity.
  63645. */
  63646. useMaskFromThicknessTexture: boolean;
  63647. /**
  63648. * Initialize the block and prepare the context for build
  63649. * @param state defines the state that will be used for the build
  63650. */
  63651. initialize(state: NodeMaterialBuildState): void;
  63652. /**
  63653. * Gets the current class name
  63654. * @returns the class name
  63655. */
  63656. getClassName(): string;
  63657. /**
  63658. * Gets the min thickness input component
  63659. */
  63660. get minThickness(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the max thickness input component
  63663. */
  63664. get maxThickness(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the thickness texture component
  63667. */
  63668. get thicknessTexture(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the tint color input component
  63671. */
  63672. get tintColor(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the translucency intensity input component
  63675. */
  63676. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the translucency diffusion distance input component
  63679. */
  63680. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63681. /**
  63682. * Gets the refraction object parameters
  63683. */
  63684. get refraction(): NodeMaterialConnectionPoint;
  63685. /**
  63686. * Gets the sub surface object output component
  63687. */
  63688. get subsurface(): NodeMaterialConnectionPoint;
  63689. autoConfigure(material: NodeMaterial): void;
  63690. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63691. /**
  63692. * Gets the main code of the block (fragment side)
  63693. * @param state current state of the node material building
  63694. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63695. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63696. * @param worldPosVarName name of the variable holding the world position
  63697. * @returns the shader code
  63698. */
  63699. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63700. protected _buildBlock(state: NodeMaterialBuildState): this;
  63701. }
  63702. }
  63703. declare module BABYLON {
  63704. /**
  63705. * Block used to implement the PBR metallic/roughness model
  63706. */
  63707. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63708. /**
  63709. * Gets or sets the light associated with this block
  63710. */
  63711. light: Nullable<Light>;
  63712. private _lightId;
  63713. private _scene;
  63714. private _environmentBRDFTexture;
  63715. private _environmentBrdfSamplerName;
  63716. private _vNormalWName;
  63717. private _invertNormalName;
  63718. /**
  63719. * Create a new ReflectionBlock
  63720. * @param name defines the block name
  63721. */
  63722. constructor(name: string);
  63723. /**
  63724. * Intensity of the direct lights e.g. the four lights available in your scene.
  63725. * This impacts both the direct diffuse and specular highlights.
  63726. */
  63727. directIntensity: number;
  63728. /**
  63729. * Intensity of the environment e.g. how much the environment will light the object
  63730. * either through harmonics for rough material or through the refelction for shiny ones.
  63731. */
  63732. environmentIntensity: number;
  63733. /**
  63734. * This is a special control allowing the reduction of the specular highlights coming from the
  63735. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63736. */
  63737. specularIntensity: number;
  63738. /**
  63739. * Defines the falloff type used in this material.
  63740. * It by default is Physical.
  63741. */
  63742. lightFalloff: number;
  63743. /**
  63744. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63745. */
  63746. useAlphaFromAlbedoTexture: boolean;
  63747. /**
  63748. * Specifies that alpha test should be used
  63749. */
  63750. useAlphaTest: boolean;
  63751. /**
  63752. * Defines the alpha limits in alpha test mode.
  63753. */
  63754. alphaTestCutoff: number;
  63755. /**
  63756. * Specifies that alpha blending should be used
  63757. */
  63758. useAlphaBlending: boolean;
  63759. /**
  63760. * Defines if the alpha value should be determined via the rgb values.
  63761. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63762. */
  63763. opacityRGB: boolean;
  63764. /**
  63765. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63766. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63767. */
  63768. useRadianceOverAlpha: boolean;
  63769. /**
  63770. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63771. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63772. */
  63773. useSpecularOverAlpha: boolean;
  63774. /**
  63775. * Enables specular anti aliasing in the PBR shader.
  63776. * It will both interacts on the Geometry for analytical and IBL lighting.
  63777. * It also prefilter the roughness map based on the bump values.
  63778. */
  63779. enableSpecularAntiAliasing: boolean;
  63780. /**
  63781. * Enables realtime filtering on the texture.
  63782. */
  63783. realTimeFiltering: boolean;
  63784. /**
  63785. * Quality switch for realtime filtering
  63786. */
  63787. realTimeFilteringQuality: number;
  63788. /**
  63789. * Defines if the material uses energy conservation.
  63790. */
  63791. useEnergyConservation: boolean;
  63792. /**
  63793. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63794. * too much the area relying on ambient texture to define their ambient occlusion.
  63795. */
  63796. useRadianceOcclusion: boolean;
  63797. /**
  63798. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63799. * makes the reflect vector face the model (under horizon).
  63800. */
  63801. useHorizonOcclusion: boolean;
  63802. /**
  63803. * If set to true, no lighting calculations will be applied.
  63804. */
  63805. unlit: boolean;
  63806. /**
  63807. * Force normal to face away from face.
  63808. */
  63809. forceNormalForward: boolean;
  63810. /**
  63811. * Defines the material debug mode.
  63812. * It helps seeing only some components of the material while troubleshooting.
  63813. */
  63814. debugMode: number;
  63815. /**
  63816. * Specify from where on screen the debug mode should start.
  63817. * The value goes from -1 (full screen) to 1 (not visible)
  63818. * It helps with side by side comparison against the final render
  63819. * This defaults to 0
  63820. */
  63821. debugLimit: number;
  63822. /**
  63823. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63824. * You can use the factor to better multiply the final value.
  63825. */
  63826. debugFactor: number;
  63827. /**
  63828. * Initialize the block and prepare the context for build
  63829. * @param state defines the state that will be used for the build
  63830. */
  63831. initialize(state: NodeMaterialBuildState): void;
  63832. /**
  63833. * Gets the current class name
  63834. * @returns the class name
  63835. */
  63836. getClassName(): string;
  63837. /**
  63838. * Gets the world position input component
  63839. */
  63840. get worldPosition(): NodeMaterialConnectionPoint;
  63841. /**
  63842. * Gets the world normal input component
  63843. */
  63844. get worldNormal(): NodeMaterialConnectionPoint;
  63845. /**
  63846. * Gets the perturbed normal input component
  63847. */
  63848. get perturbedNormal(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Gets the camera position input component
  63851. */
  63852. get cameraPosition(): NodeMaterialConnectionPoint;
  63853. /**
  63854. * Gets the base color input component
  63855. */
  63856. get baseColor(): NodeMaterialConnectionPoint;
  63857. /**
  63858. * Gets the opacity texture input component
  63859. */
  63860. get opacityTexture(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the ambient color input component
  63863. */
  63864. get ambientColor(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the reflectivity object parameters
  63867. */
  63868. get reflectivity(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the ambient occlusion object parameters
  63871. */
  63872. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the reflection object parameters
  63875. */
  63876. get reflection(): NodeMaterialConnectionPoint;
  63877. /**
  63878. * Gets the sheen object parameters
  63879. */
  63880. get sheen(): NodeMaterialConnectionPoint;
  63881. /**
  63882. * Gets the clear coat object parameters
  63883. */
  63884. get clearcoat(): NodeMaterialConnectionPoint;
  63885. /**
  63886. * Gets the sub surface object parameters
  63887. */
  63888. get subsurface(): NodeMaterialConnectionPoint;
  63889. /**
  63890. * Gets the anisotropy object parameters
  63891. */
  63892. get anisotropy(): NodeMaterialConnectionPoint;
  63893. /**
  63894. * Gets the ambient output component
  63895. */
  63896. get ambient(): NodeMaterialConnectionPoint;
  63897. /**
  63898. * Gets the diffuse output component
  63899. */
  63900. get diffuse(): NodeMaterialConnectionPoint;
  63901. /**
  63902. * Gets the specular output component
  63903. */
  63904. get specular(): NodeMaterialConnectionPoint;
  63905. /**
  63906. * Gets the sheen output component
  63907. */
  63908. get sheenDir(): NodeMaterialConnectionPoint;
  63909. /**
  63910. * Gets the clear coat output component
  63911. */
  63912. get clearcoatDir(): NodeMaterialConnectionPoint;
  63913. /**
  63914. * Gets the indirect diffuse output component
  63915. */
  63916. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63917. /**
  63918. * Gets the indirect specular output component
  63919. */
  63920. get specularIndirect(): NodeMaterialConnectionPoint;
  63921. /**
  63922. * Gets the indirect sheen output component
  63923. */
  63924. get sheenIndirect(): NodeMaterialConnectionPoint;
  63925. /**
  63926. * Gets the indirect clear coat output component
  63927. */
  63928. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63929. /**
  63930. * Gets the refraction output component
  63931. */
  63932. get refraction(): NodeMaterialConnectionPoint;
  63933. /**
  63934. * Gets the global lighting output component
  63935. */
  63936. get lighting(): NodeMaterialConnectionPoint;
  63937. /**
  63938. * Gets the shadow output component
  63939. */
  63940. get shadow(): NodeMaterialConnectionPoint;
  63941. /**
  63942. * Gets the alpha output component
  63943. */
  63944. get alpha(): NodeMaterialConnectionPoint;
  63945. autoConfigure(material: NodeMaterial): void;
  63946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63947. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63949. private _injectVertexCode;
  63950. /**
  63951. * Gets the code corresponding to the albedo/opacity module
  63952. * @returns the shader code
  63953. */
  63954. getAlbedoOpacityCode(): string;
  63955. protected _buildBlock(state: NodeMaterialBuildState): this;
  63956. protected _dumpPropertiesCode(): string;
  63957. serialize(): any;
  63958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /**
  63963. * Block used to compute value of one parameter modulo another
  63964. */
  63965. export class ModBlock extends NodeMaterialBlock {
  63966. /**
  63967. * Creates a new ModBlock
  63968. * @param name defines the block name
  63969. */
  63970. constructor(name: string);
  63971. /**
  63972. * Gets the current class name
  63973. * @returns the class name
  63974. */
  63975. getClassName(): string;
  63976. /**
  63977. * Gets the left operand input component
  63978. */
  63979. get left(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the right operand input component
  63982. */
  63983. get right(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the output component
  63986. */
  63987. get output(): NodeMaterialConnectionPoint;
  63988. protected _buildBlock(state: NodeMaterialBuildState): this;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /**
  63993. * Helper class to push actions to a pool of workers.
  63994. */
  63995. export class WorkerPool implements IDisposable {
  63996. private _workerInfos;
  63997. private _pendingActions;
  63998. /**
  63999. * Constructor
  64000. * @param workers Array of workers to use for actions
  64001. */
  64002. constructor(workers: Array<Worker>);
  64003. /**
  64004. * Terminates all workers and clears any pending actions.
  64005. */
  64006. dispose(): void;
  64007. /**
  64008. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64009. * pended until a worker has completed its action.
  64010. * @param action The action to perform. Call onComplete when the action is complete.
  64011. */
  64012. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64013. private _execute;
  64014. }
  64015. }
  64016. declare module BABYLON {
  64017. /**
  64018. * Configuration for Draco compression
  64019. */
  64020. export interface IDracoCompressionConfiguration {
  64021. /**
  64022. * Configuration for the decoder.
  64023. */
  64024. decoder: {
  64025. /**
  64026. * The url to the WebAssembly module.
  64027. */
  64028. wasmUrl?: string;
  64029. /**
  64030. * The url to the WebAssembly binary.
  64031. */
  64032. wasmBinaryUrl?: string;
  64033. /**
  64034. * The url to the fallback JavaScript module.
  64035. */
  64036. fallbackUrl?: string;
  64037. };
  64038. }
  64039. /**
  64040. * Draco compression (https://google.github.io/draco/)
  64041. *
  64042. * This class wraps the Draco module.
  64043. *
  64044. * **Encoder**
  64045. *
  64046. * The encoder is not currently implemented.
  64047. *
  64048. * **Decoder**
  64049. *
  64050. * 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.
  64051. *
  64052. * To update the configuration, use the following code:
  64053. * ```javascript
  64054. * DracoCompression.Configuration = {
  64055. * decoder: {
  64056. * wasmUrl: "<url to the WebAssembly library>",
  64057. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64058. * fallbackUrl: "<url to the fallback JavaScript library>",
  64059. * }
  64060. * };
  64061. * ```
  64062. *
  64063. * 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.
  64064. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64065. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64066. *
  64067. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64068. * ```javascript
  64069. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64070. * ```
  64071. *
  64072. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64073. */
  64074. export class DracoCompression implements IDisposable {
  64075. private _workerPoolPromise?;
  64076. private _decoderModulePromise?;
  64077. /**
  64078. * The configuration. Defaults to the following urls:
  64079. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64080. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64081. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64082. */
  64083. static Configuration: IDracoCompressionConfiguration;
  64084. /**
  64085. * Returns true if the decoder configuration is available.
  64086. */
  64087. static get DecoderAvailable(): boolean;
  64088. /**
  64089. * Default number of workers to create when creating the draco compression object.
  64090. */
  64091. static DefaultNumWorkers: number;
  64092. private static GetDefaultNumWorkers;
  64093. private static _Default;
  64094. /**
  64095. * Default instance for the draco compression object.
  64096. */
  64097. static get Default(): DracoCompression;
  64098. /**
  64099. * Constructor
  64100. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64101. */
  64102. constructor(numWorkers?: number);
  64103. /**
  64104. * Stop all async operations and release resources.
  64105. */
  64106. dispose(): void;
  64107. /**
  64108. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64109. * @returns a promise that resolves when ready
  64110. */
  64111. whenReadyAsync(): Promise<void>;
  64112. /**
  64113. * Decode Draco compressed mesh data to vertex data.
  64114. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64115. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64116. * @returns A promise that resolves with the decoded vertex data
  64117. */
  64118. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64119. [kind: string]: number;
  64120. }): Promise<VertexData>;
  64121. }
  64122. }
  64123. declare module BABYLON {
  64124. /**
  64125. * Class for building Constructive Solid Geometry
  64126. */
  64127. export class CSG {
  64128. private polygons;
  64129. /**
  64130. * The world matrix
  64131. */
  64132. matrix: Matrix;
  64133. /**
  64134. * Stores the position
  64135. */
  64136. position: Vector3;
  64137. /**
  64138. * Stores the rotation
  64139. */
  64140. rotation: Vector3;
  64141. /**
  64142. * Stores the rotation quaternion
  64143. */
  64144. rotationQuaternion: Nullable<Quaternion>;
  64145. /**
  64146. * Stores the scaling vector
  64147. */
  64148. scaling: Vector3;
  64149. /**
  64150. * Convert the Mesh to CSG
  64151. * @param mesh The Mesh to convert to CSG
  64152. * @returns A new CSG from the Mesh
  64153. */
  64154. static FromMesh(mesh: Mesh): CSG;
  64155. /**
  64156. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64157. * @param polygons Polygons used to construct a CSG solid
  64158. */
  64159. private static FromPolygons;
  64160. /**
  64161. * Clones, or makes a deep copy, of the CSG
  64162. * @returns A new CSG
  64163. */
  64164. clone(): CSG;
  64165. /**
  64166. * Unions this CSG with another CSG
  64167. * @param csg The CSG to union against this CSG
  64168. * @returns The unioned CSG
  64169. */
  64170. union(csg: CSG): CSG;
  64171. /**
  64172. * Unions this CSG with another CSG in place
  64173. * @param csg The CSG to union against this CSG
  64174. */
  64175. unionInPlace(csg: CSG): void;
  64176. /**
  64177. * Subtracts this CSG with another CSG
  64178. * @param csg The CSG to subtract against this CSG
  64179. * @returns A new CSG
  64180. */
  64181. subtract(csg: CSG): CSG;
  64182. /**
  64183. * Subtracts this CSG with another CSG in place
  64184. * @param csg The CSG to subtact against this CSG
  64185. */
  64186. subtractInPlace(csg: CSG): void;
  64187. /**
  64188. * Intersect this CSG with another CSG
  64189. * @param csg The CSG to intersect against this CSG
  64190. * @returns A new CSG
  64191. */
  64192. intersect(csg: CSG): CSG;
  64193. /**
  64194. * Intersects this CSG with another CSG in place
  64195. * @param csg The CSG to intersect against this CSG
  64196. */
  64197. intersectInPlace(csg: CSG): void;
  64198. /**
  64199. * Return a new CSG solid with solid and empty space switched. This solid is
  64200. * not modified.
  64201. * @returns A new CSG solid with solid and empty space switched
  64202. */
  64203. inverse(): CSG;
  64204. /**
  64205. * Inverses the CSG in place
  64206. */
  64207. inverseInPlace(): void;
  64208. /**
  64209. * This is used to keep meshes transformations so they can be restored
  64210. * when we build back a Babylon Mesh
  64211. * NB : All CSG operations are performed in world coordinates
  64212. * @param csg The CSG to copy the transform attributes from
  64213. * @returns This CSG
  64214. */
  64215. copyTransformAttributes(csg: CSG): CSG;
  64216. /**
  64217. * Build Raw mesh from CSG
  64218. * Coordinates here are in world space
  64219. * @param name The name of the mesh geometry
  64220. * @param scene The Scene
  64221. * @param keepSubMeshes Specifies if the submeshes should be kept
  64222. * @returns A new Mesh
  64223. */
  64224. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64225. /**
  64226. * Build Mesh from CSG taking material and transforms into account
  64227. * @param name The name of the Mesh
  64228. * @param material The material of the Mesh
  64229. * @param scene The Scene
  64230. * @param keepSubMeshes Specifies if submeshes should be kept
  64231. * @returns The new Mesh
  64232. */
  64233. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64234. }
  64235. }
  64236. declare module BABYLON {
  64237. /**
  64238. * Class used to create a trail following a mesh
  64239. */
  64240. export class TrailMesh extends Mesh {
  64241. private _generator;
  64242. private _autoStart;
  64243. private _running;
  64244. private _diameter;
  64245. private _length;
  64246. private _sectionPolygonPointsCount;
  64247. private _sectionVectors;
  64248. private _sectionNormalVectors;
  64249. private _beforeRenderObserver;
  64250. /**
  64251. * @constructor
  64252. * @param name The value used by scene.getMeshByName() to do a lookup.
  64253. * @param generator The mesh or transform node to generate a trail.
  64254. * @param scene The scene to add this mesh to.
  64255. * @param diameter Diameter of trailing mesh. Default is 1.
  64256. * @param length Length of trailing mesh. Default is 60.
  64257. * @param autoStart Automatically start trailing mesh. Default true.
  64258. */
  64259. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64260. /**
  64261. * "TrailMesh"
  64262. * @returns "TrailMesh"
  64263. */
  64264. getClassName(): string;
  64265. private _createMesh;
  64266. /**
  64267. * Start trailing mesh.
  64268. */
  64269. start(): void;
  64270. /**
  64271. * Stop trailing mesh.
  64272. */
  64273. stop(): void;
  64274. /**
  64275. * Update trailing mesh geometry.
  64276. */
  64277. update(): void;
  64278. /**
  64279. * Returns a new TrailMesh object.
  64280. * @param name is a string, the name given to the new mesh
  64281. * @param newGenerator use new generator object for cloned trail mesh
  64282. * @returns a new mesh
  64283. */
  64284. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64285. /**
  64286. * Serializes this trail mesh
  64287. * @param serializationObject object to write serialization to
  64288. */
  64289. serialize(serializationObject: any): void;
  64290. /**
  64291. * Parses a serialized trail mesh
  64292. * @param parsedMesh the serialized mesh
  64293. * @param scene the scene to create the trail mesh in
  64294. * @returns the created trail mesh
  64295. */
  64296. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64297. }
  64298. }
  64299. declare module BABYLON {
  64300. /**
  64301. * Class containing static functions to help procedurally build meshes
  64302. */
  64303. export class TiledBoxBuilder {
  64304. /**
  64305. * Creates a box mesh
  64306. * 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)
  64307. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64309. * * 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
  64310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64311. * @param name defines the name of the mesh
  64312. * @param options defines the options used to create the mesh
  64313. * @param scene defines the hosting scene
  64314. * @returns the box mesh
  64315. */
  64316. static CreateTiledBox(name: string, options: {
  64317. pattern?: number;
  64318. width?: number;
  64319. height?: number;
  64320. depth?: number;
  64321. tileSize?: number;
  64322. tileWidth?: number;
  64323. tileHeight?: number;
  64324. alignHorizontal?: number;
  64325. alignVertical?: number;
  64326. faceUV?: Vector4[];
  64327. faceColors?: Color4[];
  64328. sideOrientation?: number;
  64329. updatable?: boolean;
  64330. }, scene?: Nullable<Scene>): Mesh;
  64331. }
  64332. }
  64333. declare module BABYLON {
  64334. /**
  64335. * Class containing static functions to help procedurally build meshes
  64336. */
  64337. export class TorusKnotBuilder {
  64338. /**
  64339. * Creates a torus knot mesh
  64340. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64341. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64342. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64343. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64345. * * 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
  64346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64347. * @param name defines the name of the mesh
  64348. * @param options defines the options used to create the mesh
  64349. * @param scene defines the hosting scene
  64350. * @returns the torus knot mesh
  64351. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64352. */
  64353. static CreateTorusKnot(name: string, options: {
  64354. radius?: number;
  64355. tube?: number;
  64356. radialSegments?: number;
  64357. tubularSegments?: number;
  64358. p?: number;
  64359. q?: number;
  64360. updatable?: boolean;
  64361. sideOrientation?: number;
  64362. frontUVs?: Vector4;
  64363. backUVs?: Vector4;
  64364. }, scene: any): Mesh;
  64365. }
  64366. }
  64367. declare module BABYLON {
  64368. /**
  64369. * Polygon
  64370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64371. */
  64372. export class Polygon {
  64373. /**
  64374. * Creates a rectangle
  64375. * @param xmin bottom X coord
  64376. * @param ymin bottom Y coord
  64377. * @param xmax top X coord
  64378. * @param ymax top Y coord
  64379. * @returns points that make the resulting rectation
  64380. */
  64381. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64382. /**
  64383. * Creates a circle
  64384. * @param radius radius of circle
  64385. * @param cx scale in x
  64386. * @param cy scale in y
  64387. * @param numberOfSides number of sides that make up the circle
  64388. * @returns points that make the resulting circle
  64389. */
  64390. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64391. /**
  64392. * Creates a polygon from input string
  64393. * @param input Input polygon data
  64394. * @returns the parsed points
  64395. */
  64396. static Parse(input: string): Vector2[];
  64397. /**
  64398. * Starts building a polygon from x and y coordinates
  64399. * @param x x coordinate
  64400. * @param y y coordinate
  64401. * @returns the started path2
  64402. */
  64403. static StartingAt(x: number, y: number): Path2;
  64404. }
  64405. /**
  64406. * Builds a polygon
  64407. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64408. */
  64409. export class PolygonMeshBuilder {
  64410. private _points;
  64411. private _outlinepoints;
  64412. private _holes;
  64413. private _name;
  64414. private _scene;
  64415. private _epoints;
  64416. private _eholes;
  64417. private _addToepoint;
  64418. /**
  64419. * Babylon reference to the earcut plugin.
  64420. */
  64421. bjsEarcut: any;
  64422. /**
  64423. * Creates a PolygonMeshBuilder
  64424. * @param name name of the builder
  64425. * @param contours Path of the polygon
  64426. * @param scene scene to add to when creating the mesh
  64427. * @param earcutInjection can be used to inject your own earcut reference
  64428. */
  64429. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64430. /**
  64431. * Adds a whole within the polygon
  64432. * @param hole Array of points defining the hole
  64433. * @returns this
  64434. */
  64435. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64436. /**
  64437. * Creates the polygon
  64438. * @param updatable If the mesh should be updatable
  64439. * @param depth The depth of the mesh created
  64440. * @returns the created mesh
  64441. */
  64442. build(updatable?: boolean, depth?: number): Mesh;
  64443. /**
  64444. * Creates the polygon
  64445. * @param depth The depth of the mesh created
  64446. * @returns the created VertexData
  64447. */
  64448. buildVertexData(depth?: number): VertexData;
  64449. /**
  64450. * Adds a side to the polygon
  64451. * @param positions points that make the polygon
  64452. * @param normals normals of the polygon
  64453. * @param uvs uvs of the polygon
  64454. * @param indices indices of the polygon
  64455. * @param bounds bounds of the polygon
  64456. * @param points points of the polygon
  64457. * @param depth depth of the polygon
  64458. * @param flip flip of the polygon
  64459. */
  64460. private addSide;
  64461. }
  64462. }
  64463. declare module BABYLON {
  64464. /**
  64465. * Class containing static functions to help procedurally build meshes
  64466. */
  64467. export class PolygonBuilder {
  64468. /**
  64469. * Creates a polygon mesh
  64470. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64471. * * 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
  64472. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64474. * * 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)
  64475. * * Remember you can only change the shape positions, not their number when updating a polygon
  64476. * @param name defines the name of the mesh
  64477. * @param options defines the options used to create the mesh
  64478. * @param scene defines the hosting scene
  64479. * @param earcutInjection can be used to inject your own earcut reference
  64480. * @returns the polygon mesh
  64481. */
  64482. static CreatePolygon(name: string, options: {
  64483. shape: Vector3[];
  64484. holes?: Vector3[][];
  64485. depth?: number;
  64486. faceUV?: Vector4[];
  64487. faceColors?: Color4[];
  64488. updatable?: boolean;
  64489. sideOrientation?: number;
  64490. frontUVs?: Vector4;
  64491. backUVs?: Vector4;
  64492. wrap?: boolean;
  64493. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64494. /**
  64495. * Creates an extruded polygon mesh, with depth in the Y direction.
  64496. * * 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)
  64497. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64498. * @param name defines the name of the mesh
  64499. * @param options defines the options used to create the mesh
  64500. * @param scene defines the hosting scene
  64501. * @param earcutInjection can be used to inject your own earcut reference
  64502. * @returns the polygon mesh
  64503. */
  64504. static ExtrudePolygon(name: string, options: {
  64505. shape: Vector3[];
  64506. holes?: Vector3[][];
  64507. depth?: number;
  64508. faceUV?: Vector4[];
  64509. faceColors?: Color4[];
  64510. updatable?: boolean;
  64511. sideOrientation?: number;
  64512. frontUVs?: Vector4;
  64513. backUVs?: Vector4;
  64514. wrap?: boolean;
  64515. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64516. }
  64517. }
  64518. declare module BABYLON {
  64519. /**
  64520. * Class containing static functions to help procedurally build meshes
  64521. */
  64522. export class LatheBuilder {
  64523. /**
  64524. * Creates lathe mesh.
  64525. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64526. * * 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
  64527. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64528. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64529. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64530. * * 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
  64531. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64532. * * 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
  64533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64534. * * 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
  64535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64537. * @param name defines the name of the mesh
  64538. * @param options defines the options used to create the mesh
  64539. * @param scene defines the hosting scene
  64540. * @returns the lathe mesh
  64541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64542. */
  64543. static CreateLathe(name: string, options: {
  64544. shape: Vector3[];
  64545. radius?: number;
  64546. tessellation?: number;
  64547. clip?: number;
  64548. arc?: number;
  64549. closed?: boolean;
  64550. updatable?: boolean;
  64551. sideOrientation?: number;
  64552. frontUVs?: Vector4;
  64553. backUVs?: Vector4;
  64554. cap?: number;
  64555. invertUV?: boolean;
  64556. }, scene?: Nullable<Scene>): Mesh;
  64557. }
  64558. }
  64559. declare module BABYLON {
  64560. /**
  64561. * Class containing static functions to help procedurally build meshes
  64562. */
  64563. export class TiledPlaneBuilder {
  64564. /**
  64565. * Creates a tiled plane mesh
  64566. * * The parameter `pattern` will, depending on value, do nothing or
  64567. * * * flip (reflect about central vertical) alternate tiles across and up
  64568. * * * flip every tile on alternate rows
  64569. * * * rotate (180 degs) alternate tiles across and up
  64570. * * * rotate every tile on alternate rows
  64571. * * * flip and rotate alternate tiles across and up
  64572. * * * flip and rotate every tile on alternate rows
  64573. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64574. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64575. * * 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
  64576. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64577. * * 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)
  64578. * * 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)
  64579. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64580. * @param name defines the name of the mesh
  64581. * @param options defines the options used to create the mesh
  64582. * @param scene defines the hosting scene
  64583. * @returns the box mesh
  64584. */
  64585. static CreateTiledPlane(name: string, options: {
  64586. pattern?: number;
  64587. tileSize?: number;
  64588. tileWidth?: number;
  64589. tileHeight?: number;
  64590. size?: number;
  64591. width?: number;
  64592. height?: number;
  64593. alignHorizontal?: number;
  64594. alignVertical?: number;
  64595. sideOrientation?: number;
  64596. frontUVs?: Vector4;
  64597. backUVs?: Vector4;
  64598. updatable?: boolean;
  64599. }, scene?: Nullable<Scene>): Mesh;
  64600. }
  64601. }
  64602. declare module BABYLON {
  64603. /**
  64604. * Class containing static functions to help procedurally build meshes
  64605. */
  64606. export class TubeBuilder {
  64607. /**
  64608. * Creates a tube mesh.
  64609. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64610. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64611. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64612. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64613. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64614. * * 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)
  64615. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64616. * * 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
  64617. * * 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
  64618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64619. * * 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
  64620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64622. * @param name defines the name of the mesh
  64623. * @param options defines the options used to create the mesh
  64624. * @param scene defines the hosting scene
  64625. * @returns the tube mesh
  64626. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64627. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64628. */
  64629. static CreateTube(name: string, options: {
  64630. path: Vector3[];
  64631. radius?: number;
  64632. tessellation?: number;
  64633. radiusFunction?: {
  64634. (i: number, distance: number): number;
  64635. };
  64636. cap?: number;
  64637. arc?: number;
  64638. updatable?: boolean;
  64639. sideOrientation?: number;
  64640. frontUVs?: Vector4;
  64641. backUVs?: Vector4;
  64642. instance?: Mesh;
  64643. invertUV?: boolean;
  64644. }, scene?: Nullable<Scene>): Mesh;
  64645. }
  64646. }
  64647. declare module BABYLON {
  64648. /**
  64649. * Class containing static functions to help procedurally build meshes
  64650. */
  64651. export class IcoSphereBuilder {
  64652. /**
  64653. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64654. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64655. * * 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`)
  64656. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64657. * * 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
  64658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64659. * * 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
  64660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64661. * @param name defines the name of the mesh
  64662. * @param options defines the options used to create the mesh
  64663. * @param scene defines the hosting scene
  64664. * @returns the icosahedron mesh
  64665. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64666. */
  64667. static CreateIcoSphere(name: string, options: {
  64668. radius?: number;
  64669. radiusX?: number;
  64670. radiusY?: number;
  64671. radiusZ?: number;
  64672. flat?: boolean;
  64673. subdivisions?: number;
  64674. sideOrientation?: number;
  64675. frontUVs?: Vector4;
  64676. backUVs?: Vector4;
  64677. updatable?: boolean;
  64678. }, scene?: Nullable<Scene>): Mesh;
  64679. }
  64680. }
  64681. declare module BABYLON {
  64682. /**
  64683. * Class containing static functions to help procedurally build meshes
  64684. */
  64685. export class DecalBuilder {
  64686. /**
  64687. * Creates a decal mesh.
  64688. * 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
  64689. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64690. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64691. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64692. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64693. * @param name defines the name of the mesh
  64694. * @param sourceMesh defines the mesh where the decal must be applied
  64695. * @param options defines the options used to create the mesh
  64696. * @param scene defines the hosting scene
  64697. * @returns the decal mesh
  64698. * @see https://doc.babylonjs.com/how_to/decals
  64699. */
  64700. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64701. position?: Vector3;
  64702. normal?: Vector3;
  64703. size?: Vector3;
  64704. angle?: number;
  64705. }): Mesh;
  64706. }
  64707. }
  64708. declare module BABYLON {
  64709. /**
  64710. * Class containing static functions to help procedurally build meshes
  64711. */
  64712. export class MeshBuilder {
  64713. /**
  64714. * Creates a box mesh
  64715. * * The parameter `size` sets the size (float) of each box side (default 1)
  64716. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64717. * * 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)
  64718. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64720. * * 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
  64721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64722. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64723. * @param name defines the name of the mesh
  64724. * @param options defines the options used to create the mesh
  64725. * @param scene defines the hosting scene
  64726. * @returns the box mesh
  64727. */
  64728. static CreateBox(name: string, options: {
  64729. size?: number;
  64730. width?: number;
  64731. height?: number;
  64732. depth?: number;
  64733. faceUV?: Vector4[];
  64734. faceColors?: Color4[];
  64735. sideOrientation?: number;
  64736. frontUVs?: Vector4;
  64737. backUVs?: Vector4;
  64738. wrap?: boolean;
  64739. topBaseAt?: number;
  64740. bottomBaseAt?: number;
  64741. updatable?: boolean;
  64742. }, scene?: Nullable<Scene>): Mesh;
  64743. /**
  64744. * Creates a tiled box mesh
  64745. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64747. * @param name defines the name of the mesh
  64748. * @param options defines the options used to create the mesh
  64749. * @param scene defines the hosting scene
  64750. * @returns the tiled box mesh
  64751. */
  64752. static CreateTiledBox(name: string, options: {
  64753. pattern?: number;
  64754. size?: number;
  64755. width?: number;
  64756. height?: number;
  64757. depth: number;
  64758. tileSize?: number;
  64759. tileWidth?: number;
  64760. tileHeight?: number;
  64761. faceUV?: Vector4[];
  64762. faceColors?: Color4[];
  64763. alignHorizontal?: number;
  64764. alignVertical?: number;
  64765. sideOrientation?: number;
  64766. updatable?: boolean;
  64767. }, scene?: Nullable<Scene>): Mesh;
  64768. /**
  64769. * Creates a sphere mesh
  64770. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64771. * * 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`)
  64772. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64773. * * 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
  64774. * * 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)
  64775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64776. * * 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
  64777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64778. * @param name defines the name of the mesh
  64779. * @param options defines the options used to create the mesh
  64780. * @param scene defines the hosting scene
  64781. * @returns the sphere mesh
  64782. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64783. */
  64784. static CreateSphere(name: string, options: {
  64785. segments?: number;
  64786. diameter?: number;
  64787. diameterX?: number;
  64788. diameterY?: number;
  64789. diameterZ?: number;
  64790. arc?: number;
  64791. slice?: number;
  64792. sideOrientation?: number;
  64793. frontUVs?: Vector4;
  64794. backUVs?: Vector4;
  64795. updatable?: boolean;
  64796. }, scene?: Nullable<Scene>): Mesh;
  64797. /**
  64798. * Creates a plane polygonal mesh. By default, this is a disc
  64799. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64800. * * 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
  64801. * * 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
  64802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64803. * * 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
  64804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64805. * @param name defines the name of the mesh
  64806. * @param options defines the options used to create the mesh
  64807. * @param scene defines the hosting scene
  64808. * @returns the plane polygonal mesh
  64809. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64810. */
  64811. static CreateDisc(name: string, options: {
  64812. radius?: number;
  64813. tessellation?: number;
  64814. arc?: number;
  64815. updatable?: boolean;
  64816. sideOrientation?: number;
  64817. frontUVs?: Vector4;
  64818. backUVs?: Vector4;
  64819. }, scene?: Nullable<Scene>): Mesh;
  64820. /**
  64821. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64822. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64823. * * 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`)
  64824. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64825. * * 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
  64826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64827. * * 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
  64828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64829. * @param name defines the name of the mesh
  64830. * @param options defines the options used to create the mesh
  64831. * @param scene defines the hosting scene
  64832. * @returns the icosahedron mesh
  64833. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64834. */
  64835. static CreateIcoSphere(name: string, options: {
  64836. radius?: number;
  64837. radiusX?: number;
  64838. radiusY?: number;
  64839. radiusZ?: number;
  64840. flat?: boolean;
  64841. subdivisions?: number;
  64842. sideOrientation?: number;
  64843. frontUVs?: Vector4;
  64844. backUVs?: Vector4;
  64845. updatable?: boolean;
  64846. }, scene?: Nullable<Scene>): Mesh;
  64847. /**
  64848. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64849. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64850. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64851. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64852. * * 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
  64853. * * 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
  64854. * * 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
  64855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64858. * * 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
  64859. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64860. * * 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
  64861. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64863. * @param name defines the name of the mesh
  64864. * @param options defines the options used to create the mesh
  64865. * @param scene defines the hosting scene
  64866. * @returns the ribbon mesh
  64867. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64869. */
  64870. static CreateRibbon(name: string, options: {
  64871. pathArray: Vector3[][];
  64872. closeArray?: boolean;
  64873. closePath?: boolean;
  64874. offset?: number;
  64875. updatable?: boolean;
  64876. sideOrientation?: number;
  64877. frontUVs?: Vector4;
  64878. backUVs?: Vector4;
  64879. instance?: Mesh;
  64880. invertUV?: boolean;
  64881. uvs?: Vector2[];
  64882. colors?: Color4[];
  64883. }, scene?: Nullable<Scene>): Mesh;
  64884. /**
  64885. * Creates a cylinder or a cone mesh
  64886. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64887. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64888. * * 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.
  64889. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64890. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64891. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64892. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64893. * * 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).
  64894. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64895. * * 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).
  64896. * * 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
  64897. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64898. * * 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
  64899. * * 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.
  64900. * * If `enclose` is false, a ring surface is one element.
  64901. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64902. * * 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
  64903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64904. * * 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
  64905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64906. * @param name defines the name of the mesh
  64907. * @param options defines the options used to create the mesh
  64908. * @param scene defines the hosting scene
  64909. * @returns the cylinder mesh
  64910. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64911. */
  64912. static CreateCylinder(name: string, options: {
  64913. height?: number;
  64914. diameterTop?: number;
  64915. diameterBottom?: number;
  64916. diameter?: number;
  64917. tessellation?: number;
  64918. subdivisions?: number;
  64919. arc?: number;
  64920. faceColors?: Color4[];
  64921. faceUV?: Vector4[];
  64922. updatable?: boolean;
  64923. hasRings?: boolean;
  64924. enclose?: boolean;
  64925. cap?: number;
  64926. sideOrientation?: number;
  64927. frontUVs?: Vector4;
  64928. backUVs?: Vector4;
  64929. }, scene?: Nullable<Scene>): Mesh;
  64930. /**
  64931. * Creates a torus mesh
  64932. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64933. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64934. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64936. * * 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
  64937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64938. * @param name defines the name of the mesh
  64939. * @param options defines the options used to create the mesh
  64940. * @param scene defines the hosting scene
  64941. * @returns the torus mesh
  64942. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64943. */
  64944. static CreateTorus(name: string, options: {
  64945. diameter?: number;
  64946. thickness?: number;
  64947. tessellation?: number;
  64948. updatable?: boolean;
  64949. sideOrientation?: number;
  64950. frontUVs?: Vector4;
  64951. backUVs?: Vector4;
  64952. }, scene?: Nullable<Scene>): Mesh;
  64953. /**
  64954. * Creates a torus knot mesh
  64955. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64956. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64957. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64958. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64960. * * 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
  64961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64962. * @param name defines the name of the mesh
  64963. * @param options defines the options used to create the mesh
  64964. * @param scene defines the hosting scene
  64965. * @returns the torus knot mesh
  64966. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64967. */
  64968. static CreateTorusKnot(name: string, options: {
  64969. radius?: number;
  64970. tube?: number;
  64971. radialSegments?: number;
  64972. tubularSegments?: number;
  64973. p?: number;
  64974. q?: number;
  64975. updatable?: boolean;
  64976. sideOrientation?: number;
  64977. frontUVs?: Vector4;
  64978. backUVs?: Vector4;
  64979. }, scene?: Nullable<Scene>): Mesh;
  64980. /**
  64981. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64982. * * 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
  64983. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64984. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64985. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64986. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64987. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64988. * * 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
  64989. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64992. * @param name defines the name of the new line system
  64993. * @param options defines the options used to create the line system
  64994. * @param scene defines the hosting scene
  64995. * @returns a new line system mesh
  64996. */
  64997. static CreateLineSystem(name: string, options: {
  64998. lines: Vector3[][];
  64999. updatable?: boolean;
  65000. instance?: Nullable<LinesMesh>;
  65001. colors?: Nullable<Color4[][]>;
  65002. useVertexAlpha?: boolean;
  65003. }, scene: Nullable<Scene>): LinesMesh;
  65004. /**
  65005. * Creates a line mesh
  65006. * 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
  65007. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65008. * * The parameter `points` is an array successive Vector3
  65009. * * 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
  65010. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65011. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65012. * * When updating an instance, remember that only point positions can change, not the number of points
  65013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65015. * @param name defines the name of the new line system
  65016. * @param options defines the options used to create the line system
  65017. * @param scene defines the hosting scene
  65018. * @returns a new line mesh
  65019. */
  65020. static CreateLines(name: string, options: {
  65021. points: Vector3[];
  65022. updatable?: boolean;
  65023. instance?: Nullable<LinesMesh>;
  65024. colors?: Color4[];
  65025. useVertexAlpha?: boolean;
  65026. }, scene?: Nullable<Scene>): LinesMesh;
  65027. /**
  65028. * Creates a dashed line mesh
  65029. * * 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
  65030. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65031. * * The parameter `points` is an array successive Vector3
  65032. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65033. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65034. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65035. * * 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
  65036. * * When updating an instance, remember that only point positions can change, not the number of points
  65037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65038. * @param name defines the name of the mesh
  65039. * @param options defines the options used to create the mesh
  65040. * @param scene defines the hosting scene
  65041. * @returns the dashed line mesh
  65042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65043. */
  65044. static CreateDashedLines(name: string, options: {
  65045. points: Vector3[];
  65046. dashSize?: number;
  65047. gapSize?: number;
  65048. dashNb?: number;
  65049. updatable?: boolean;
  65050. instance?: LinesMesh;
  65051. }, scene?: Nullable<Scene>): LinesMesh;
  65052. /**
  65053. * 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.
  65054. * * 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.
  65055. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65056. * * 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.
  65057. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65058. * * 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
  65059. * * 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
  65060. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65062. * * 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
  65063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65065. * @param name defines the name of the mesh
  65066. * @param options defines the options used to create the mesh
  65067. * @param scene defines the hosting scene
  65068. * @returns the extruded shape mesh
  65069. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65071. */
  65072. static ExtrudeShape(name: string, options: {
  65073. shape: Vector3[];
  65074. path: Vector3[];
  65075. scale?: number;
  65076. rotation?: number;
  65077. cap?: number;
  65078. updatable?: boolean;
  65079. sideOrientation?: number;
  65080. frontUVs?: Vector4;
  65081. backUVs?: Vector4;
  65082. instance?: Mesh;
  65083. invertUV?: boolean;
  65084. }, scene?: Nullable<Scene>): Mesh;
  65085. /**
  65086. * Creates an custom extruded shape mesh.
  65087. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65088. * * 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.
  65089. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65090. * * 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
  65091. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65092. * * 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
  65093. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65094. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65095. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65096. * * 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
  65097. * * 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
  65098. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65100. * * 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
  65101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65103. * @param name defines the name of the mesh
  65104. * @param options defines the options used to create the mesh
  65105. * @param scene defines the hosting scene
  65106. * @returns the custom extruded shape mesh
  65107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65108. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65109. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65110. */
  65111. static ExtrudeShapeCustom(name: string, options: {
  65112. shape: Vector3[];
  65113. path: Vector3[];
  65114. scaleFunction?: any;
  65115. rotationFunction?: any;
  65116. ribbonCloseArray?: boolean;
  65117. ribbonClosePath?: boolean;
  65118. cap?: number;
  65119. updatable?: boolean;
  65120. sideOrientation?: number;
  65121. frontUVs?: Vector4;
  65122. backUVs?: Vector4;
  65123. instance?: Mesh;
  65124. invertUV?: boolean;
  65125. }, scene?: Nullable<Scene>): Mesh;
  65126. /**
  65127. * Creates lathe mesh.
  65128. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65129. * * 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
  65130. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65131. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65132. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65133. * * 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
  65134. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65135. * * 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
  65136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65137. * * 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
  65138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65140. * @param name defines the name of the mesh
  65141. * @param options defines the options used to create the mesh
  65142. * @param scene defines the hosting scene
  65143. * @returns the lathe mesh
  65144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65145. */
  65146. static CreateLathe(name: string, options: {
  65147. shape: Vector3[];
  65148. radius?: number;
  65149. tessellation?: number;
  65150. clip?: number;
  65151. arc?: number;
  65152. closed?: boolean;
  65153. updatable?: boolean;
  65154. sideOrientation?: number;
  65155. frontUVs?: Vector4;
  65156. backUVs?: Vector4;
  65157. cap?: number;
  65158. invertUV?: boolean;
  65159. }, scene?: Nullable<Scene>): Mesh;
  65160. /**
  65161. * Creates a tiled plane mesh
  65162. * * You can set a limited pattern arrangement with the tiles
  65163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65164. * * 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
  65165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65166. * @param name defines the name of the mesh
  65167. * @param options defines the options used to create the mesh
  65168. * @param scene defines the hosting scene
  65169. * @returns the plane mesh
  65170. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65171. */
  65172. static CreateTiledPlane(name: string, options: {
  65173. pattern?: number;
  65174. tileSize?: number;
  65175. tileWidth?: number;
  65176. tileHeight?: number;
  65177. size?: number;
  65178. width?: number;
  65179. height?: number;
  65180. alignHorizontal?: number;
  65181. alignVertical?: number;
  65182. sideOrientation?: number;
  65183. frontUVs?: Vector4;
  65184. backUVs?: Vector4;
  65185. updatable?: boolean;
  65186. }, scene?: Nullable<Scene>): Mesh;
  65187. /**
  65188. * Creates a plane mesh
  65189. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65190. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65191. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65195. * @param name defines the name of the mesh
  65196. * @param options defines the options used to create the mesh
  65197. * @param scene defines the hosting scene
  65198. * @returns the plane mesh
  65199. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65200. */
  65201. static CreatePlane(name: string, options: {
  65202. size?: number;
  65203. width?: number;
  65204. height?: number;
  65205. sideOrientation?: number;
  65206. frontUVs?: Vector4;
  65207. backUVs?: Vector4;
  65208. updatable?: boolean;
  65209. sourcePlane?: Plane;
  65210. }, scene?: Nullable<Scene>): Mesh;
  65211. /**
  65212. * Creates a ground mesh
  65213. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65214. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65216. * @param name defines the name of the mesh
  65217. * @param options defines the options used to create the mesh
  65218. * @param scene defines the hosting scene
  65219. * @returns the ground mesh
  65220. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65221. */
  65222. static CreateGround(name: string, options: {
  65223. width?: number;
  65224. height?: number;
  65225. subdivisions?: number;
  65226. subdivisionsX?: number;
  65227. subdivisionsY?: number;
  65228. updatable?: boolean;
  65229. }, scene?: Nullable<Scene>): Mesh;
  65230. /**
  65231. * Creates a tiled ground mesh
  65232. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65233. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65234. * * 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
  65235. * * 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
  65236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65237. * @param name defines the name of the mesh
  65238. * @param options defines the options used to create the mesh
  65239. * @param scene defines the hosting scene
  65240. * @returns the tiled ground mesh
  65241. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65242. */
  65243. static CreateTiledGround(name: string, options: {
  65244. xmin: number;
  65245. zmin: number;
  65246. xmax: number;
  65247. zmax: number;
  65248. subdivisions?: {
  65249. w: number;
  65250. h: number;
  65251. };
  65252. precision?: {
  65253. w: number;
  65254. h: number;
  65255. };
  65256. updatable?: boolean;
  65257. }, scene?: Nullable<Scene>): Mesh;
  65258. /**
  65259. * Creates a ground mesh from a height map
  65260. * * The parameter `url` sets the URL of the height map image resource.
  65261. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65262. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65263. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65264. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65265. * * 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.
  65266. * * 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).
  65267. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65269. * @param name defines the name of the mesh
  65270. * @param url defines the url to the height map
  65271. * @param options defines the options used to create the mesh
  65272. * @param scene defines the hosting scene
  65273. * @returns the ground mesh
  65274. * @see https://doc.babylonjs.com/babylon101/height_map
  65275. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65276. */
  65277. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65278. width?: number;
  65279. height?: number;
  65280. subdivisions?: number;
  65281. minHeight?: number;
  65282. maxHeight?: number;
  65283. colorFilter?: Color3;
  65284. alphaFilter?: number;
  65285. updatable?: boolean;
  65286. onReady?: (mesh: GroundMesh) => void;
  65287. }, scene?: Nullable<Scene>): GroundMesh;
  65288. /**
  65289. * Creates a polygon mesh
  65290. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65291. * * 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
  65292. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65294. * * 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)
  65295. * * Remember you can only change the shape positions, not their number when updating a polygon
  65296. * @param name defines the name of the mesh
  65297. * @param options defines the options used to create the mesh
  65298. * @param scene defines the hosting scene
  65299. * @param earcutInjection can be used to inject your own earcut reference
  65300. * @returns the polygon mesh
  65301. */
  65302. static CreatePolygon(name: string, options: {
  65303. shape: Vector3[];
  65304. holes?: Vector3[][];
  65305. depth?: number;
  65306. faceUV?: Vector4[];
  65307. faceColors?: Color4[];
  65308. updatable?: boolean;
  65309. sideOrientation?: number;
  65310. frontUVs?: Vector4;
  65311. backUVs?: Vector4;
  65312. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65313. /**
  65314. * Creates an extruded polygon mesh, with depth in the Y direction.
  65315. * * 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)
  65316. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65317. * @param name defines the name of the mesh
  65318. * @param options defines the options used to create the mesh
  65319. * @param scene defines the hosting scene
  65320. * @param earcutInjection can be used to inject your own earcut reference
  65321. * @returns the polygon mesh
  65322. */
  65323. static ExtrudePolygon(name: string, options: {
  65324. shape: Vector3[];
  65325. holes?: Vector3[][];
  65326. depth?: number;
  65327. faceUV?: Vector4[];
  65328. faceColors?: Color4[];
  65329. updatable?: boolean;
  65330. sideOrientation?: number;
  65331. frontUVs?: Vector4;
  65332. backUVs?: Vector4;
  65333. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65334. /**
  65335. * Creates a tube mesh.
  65336. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65337. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65338. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65339. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65340. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65341. * * 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)
  65342. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65343. * * 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
  65344. * * 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
  65345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65346. * * 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
  65347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65349. * @param name defines the name of the mesh
  65350. * @param options defines the options used to create the mesh
  65351. * @param scene defines the hosting scene
  65352. * @returns the tube mesh
  65353. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65354. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65355. */
  65356. static CreateTube(name: string, options: {
  65357. path: Vector3[];
  65358. radius?: number;
  65359. tessellation?: number;
  65360. radiusFunction?: {
  65361. (i: number, distance: number): number;
  65362. };
  65363. cap?: number;
  65364. arc?: number;
  65365. updatable?: boolean;
  65366. sideOrientation?: number;
  65367. frontUVs?: Vector4;
  65368. backUVs?: Vector4;
  65369. instance?: Mesh;
  65370. invertUV?: boolean;
  65371. }, scene?: Nullable<Scene>): Mesh;
  65372. /**
  65373. * Creates a polyhedron mesh
  65374. * * 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
  65375. * * The parameter `size` (positive float, default 1) sets the polygon size
  65376. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65377. * * 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`
  65378. * * 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
  65379. * * 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)`)
  65380. * * 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
  65381. * * 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
  65382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65383. * * 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
  65384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65385. * @param name defines the name of the mesh
  65386. * @param options defines the options used to create the mesh
  65387. * @param scene defines the hosting scene
  65388. * @returns the polyhedron mesh
  65389. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65390. */
  65391. static CreatePolyhedron(name: string, options: {
  65392. type?: number;
  65393. size?: number;
  65394. sizeX?: number;
  65395. sizeY?: number;
  65396. sizeZ?: number;
  65397. custom?: any;
  65398. faceUV?: Vector4[];
  65399. faceColors?: Color4[];
  65400. flat?: boolean;
  65401. updatable?: boolean;
  65402. sideOrientation?: number;
  65403. frontUVs?: Vector4;
  65404. backUVs?: Vector4;
  65405. }, scene?: Nullable<Scene>): Mesh;
  65406. /**
  65407. * Creates a decal mesh.
  65408. * 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
  65409. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65410. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65411. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65412. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65413. * @param name defines the name of the mesh
  65414. * @param sourceMesh defines the mesh where the decal must be applied
  65415. * @param options defines the options used to create the mesh
  65416. * @param scene defines the hosting scene
  65417. * @returns the decal mesh
  65418. * @see https://doc.babylonjs.com/how_to/decals
  65419. */
  65420. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65421. position?: Vector3;
  65422. normal?: Vector3;
  65423. size?: Vector3;
  65424. angle?: number;
  65425. }): Mesh;
  65426. }
  65427. }
  65428. declare module BABYLON {
  65429. /**
  65430. * A simplifier interface for future simplification implementations
  65431. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65432. */
  65433. export interface ISimplifier {
  65434. /**
  65435. * Simplification of a given mesh according to the given settings.
  65436. * Since this requires computation, it is assumed that the function runs async.
  65437. * @param settings The settings of the simplification, including quality and distance
  65438. * @param successCallback A callback that will be called after the mesh was simplified.
  65439. * @param errorCallback in case of an error, this callback will be called. optional.
  65440. */
  65441. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65442. }
  65443. /**
  65444. * Expected simplification settings.
  65445. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65446. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65447. */
  65448. export interface ISimplificationSettings {
  65449. /**
  65450. * Gets or sets the expected quality
  65451. */
  65452. quality: number;
  65453. /**
  65454. * Gets or sets the distance when this optimized version should be used
  65455. */
  65456. distance: number;
  65457. /**
  65458. * Gets an already optimized mesh
  65459. */
  65460. optimizeMesh?: boolean;
  65461. }
  65462. /**
  65463. * Class used to specify simplification options
  65464. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65465. */
  65466. export class SimplificationSettings implements ISimplificationSettings {
  65467. /** expected quality */
  65468. quality: number;
  65469. /** distance when this optimized version should be used */
  65470. distance: number;
  65471. /** already optimized mesh */
  65472. optimizeMesh?: boolean | undefined;
  65473. /**
  65474. * Creates a SimplificationSettings
  65475. * @param quality expected quality
  65476. * @param distance distance when this optimized version should be used
  65477. * @param optimizeMesh already optimized mesh
  65478. */
  65479. constructor(
  65480. /** expected quality */
  65481. quality: number,
  65482. /** distance when this optimized version should be used */
  65483. distance: number,
  65484. /** already optimized mesh */
  65485. optimizeMesh?: boolean | undefined);
  65486. }
  65487. /**
  65488. * Interface used to define a simplification task
  65489. */
  65490. export interface ISimplificationTask {
  65491. /**
  65492. * Array of settings
  65493. */
  65494. settings: Array<ISimplificationSettings>;
  65495. /**
  65496. * Simplification type
  65497. */
  65498. simplificationType: SimplificationType;
  65499. /**
  65500. * Mesh to simplify
  65501. */
  65502. mesh: Mesh;
  65503. /**
  65504. * Callback called on success
  65505. */
  65506. successCallback?: () => void;
  65507. /**
  65508. * Defines if parallel processing can be used
  65509. */
  65510. parallelProcessing: boolean;
  65511. }
  65512. /**
  65513. * Queue used to order the simplification tasks
  65514. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65515. */
  65516. export class SimplificationQueue {
  65517. private _simplificationArray;
  65518. /**
  65519. * Gets a boolean indicating that the process is still running
  65520. */
  65521. running: boolean;
  65522. /**
  65523. * Creates a new queue
  65524. */
  65525. constructor();
  65526. /**
  65527. * Adds a new simplification task
  65528. * @param task defines a task to add
  65529. */
  65530. addTask(task: ISimplificationTask): void;
  65531. /**
  65532. * Execute next task
  65533. */
  65534. executeNext(): void;
  65535. /**
  65536. * Execute a simplification task
  65537. * @param task defines the task to run
  65538. */
  65539. runSimplification(task: ISimplificationTask): void;
  65540. private getSimplifier;
  65541. }
  65542. /**
  65543. * The implemented types of simplification
  65544. * At the moment only Quadratic Error Decimation is implemented
  65545. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65546. */
  65547. export enum SimplificationType {
  65548. /** Quadratic error decimation */
  65549. QUADRATIC = 0
  65550. }
  65551. /**
  65552. * An implementation of the Quadratic Error simplification algorithm.
  65553. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65554. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65555. * @author RaananW
  65556. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65557. */
  65558. export class QuadraticErrorSimplification implements ISimplifier {
  65559. private _mesh;
  65560. private triangles;
  65561. private vertices;
  65562. private references;
  65563. private _reconstructedMesh;
  65564. /** Gets or sets the number pf sync interations */
  65565. syncIterations: number;
  65566. /** Gets or sets the aggressiveness of the simplifier */
  65567. aggressiveness: number;
  65568. /** Gets or sets the number of allowed iterations for decimation */
  65569. decimationIterations: number;
  65570. /** Gets or sets the espilon to use for bounding box computation */
  65571. boundingBoxEpsilon: number;
  65572. /**
  65573. * Creates a new QuadraticErrorSimplification
  65574. * @param _mesh defines the target mesh
  65575. */
  65576. constructor(_mesh: Mesh);
  65577. /**
  65578. * Simplification of a given mesh according to the given settings.
  65579. * Since this requires computation, it is assumed that the function runs async.
  65580. * @param settings The settings of the simplification, including quality and distance
  65581. * @param successCallback A callback that will be called after the mesh was simplified.
  65582. */
  65583. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65584. private runDecimation;
  65585. private initWithMesh;
  65586. private init;
  65587. private reconstructMesh;
  65588. private initDecimatedMesh;
  65589. private isFlipped;
  65590. private updateTriangles;
  65591. private identifyBorder;
  65592. private updateMesh;
  65593. private vertexError;
  65594. private calculateError;
  65595. }
  65596. }
  65597. declare module BABYLON {
  65598. interface Scene {
  65599. /** @hidden (Backing field) */
  65600. _simplificationQueue: SimplificationQueue;
  65601. /**
  65602. * Gets or sets the simplification queue attached to the scene
  65603. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65604. */
  65605. simplificationQueue: SimplificationQueue;
  65606. }
  65607. interface Mesh {
  65608. /**
  65609. * Simplify the mesh according to the given array of settings.
  65610. * Function will return immediately and will simplify async
  65611. * @param settings a collection of simplification settings
  65612. * @param parallelProcessing should all levels calculate parallel or one after the other
  65613. * @param simplificationType the type of simplification to run
  65614. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65615. * @returns the current mesh
  65616. */
  65617. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65618. }
  65619. /**
  65620. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65621. * created in a scene
  65622. */
  65623. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65624. /**
  65625. * The component name helpfull to identify the component in the list of scene components.
  65626. */
  65627. readonly name: string;
  65628. /**
  65629. * The scene the component belongs to.
  65630. */
  65631. scene: Scene;
  65632. /**
  65633. * Creates a new instance of the component for the given scene
  65634. * @param scene Defines the scene to register the component in
  65635. */
  65636. constructor(scene: Scene);
  65637. /**
  65638. * Registers the component in a given scene
  65639. */
  65640. register(): void;
  65641. /**
  65642. * Rebuilds the elements related to this component in case of
  65643. * context lost for instance.
  65644. */
  65645. rebuild(): void;
  65646. /**
  65647. * Disposes the component and the associated ressources
  65648. */
  65649. dispose(): void;
  65650. private _beforeCameraUpdate;
  65651. }
  65652. }
  65653. declare module BABYLON {
  65654. interface Mesh {
  65655. /**
  65656. * Creates a new thin instance
  65657. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65658. * @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
  65659. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65660. */
  65661. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65662. /**
  65663. * Adds the transformation (matrix) of the current mesh as a thin instance
  65664. * @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
  65665. * @returns the thin instance index number
  65666. */
  65667. thinInstanceAddSelf(refresh: boolean): number;
  65668. /**
  65669. * Registers a custom attribute to be used with thin instances
  65670. * @param kind name of the attribute
  65671. * @param stride size in floats of the attribute
  65672. */
  65673. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65674. /**
  65675. * Sets the matrix of a thin instance
  65676. * @param index index of the thin instance
  65677. * @param matrix matrix to set
  65678. * @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
  65679. */
  65680. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65681. /**
  65682. * Sets the value of a custom attribute for a thin instance
  65683. * @param kind name of the attribute
  65684. * @param index index of the thin instance
  65685. * @param value value to set
  65686. * @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
  65687. */
  65688. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65689. /**
  65690. * 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.
  65691. */
  65692. thinInstanceCount: number;
  65693. /**
  65694. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65695. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65696. * @param buffer buffer to set
  65697. * @param stride size in floats of each value of the buffer
  65698. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65699. */
  65700. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65701. /**
  65702. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65703. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65704. */
  65705. thinInstanceBufferUpdated(kind: string): void;
  65706. /**
  65707. * Refreshes the bounding info, taking into account all the thin instances defined
  65708. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65709. */
  65710. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65711. /** @hidden */
  65712. _thinInstanceInitializeUserStorage(): void;
  65713. /** @hidden */
  65714. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65715. /** @hidden */
  65716. _userThinInstanceBuffersStorage: {
  65717. data: {
  65718. [key: string]: Float32Array;
  65719. };
  65720. sizes: {
  65721. [key: string]: number;
  65722. };
  65723. vertexBuffers: {
  65724. [key: string]: Nullable<VertexBuffer>;
  65725. };
  65726. strides: {
  65727. [key: string]: number;
  65728. };
  65729. };
  65730. }
  65731. }
  65732. declare module BABYLON {
  65733. /**
  65734. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65735. */
  65736. export interface INavigationEnginePlugin {
  65737. /**
  65738. * plugin name
  65739. */
  65740. name: string;
  65741. /**
  65742. * Creates a navigation mesh
  65743. * @param meshes array of all the geometry used to compute the navigatio mesh
  65744. * @param parameters bunch of parameters used to filter geometry
  65745. */
  65746. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65747. /**
  65748. * Create a navigation mesh debug mesh
  65749. * @param scene is where the mesh will be added
  65750. * @returns debug display mesh
  65751. */
  65752. createDebugNavMesh(scene: Scene): Mesh;
  65753. /**
  65754. * Get a navigation mesh constrained position, closest to the parameter position
  65755. * @param position world position
  65756. * @returns the closest point to position constrained by the navigation mesh
  65757. */
  65758. getClosestPoint(position: Vector3): Vector3;
  65759. /**
  65760. * Get a navigation mesh constrained position, closest to the parameter position
  65761. * @param position world position
  65762. * @param result output the closest point to position constrained by the navigation mesh
  65763. */
  65764. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65765. /**
  65766. * Get a navigation mesh constrained position, within a particular radius
  65767. * @param position world position
  65768. * @param maxRadius the maximum distance to the constrained world position
  65769. * @returns the closest point to position constrained by the navigation mesh
  65770. */
  65771. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65772. /**
  65773. * Get a navigation mesh constrained position, within a particular radius
  65774. * @param position world position
  65775. * @param maxRadius the maximum distance to the constrained world position
  65776. * @param result output the closest point to position constrained by the navigation mesh
  65777. */
  65778. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65779. /**
  65780. * Compute the final position from a segment made of destination-position
  65781. * @param position world position
  65782. * @param destination world position
  65783. * @returns the resulting point along the navmesh
  65784. */
  65785. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65786. /**
  65787. * Compute the final position from a segment made of destination-position
  65788. * @param position world position
  65789. * @param destination world position
  65790. * @param result output the resulting point along the navmesh
  65791. */
  65792. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65793. /**
  65794. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65795. * @param start world position
  65796. * @param end world position
  65797. * @returns array containing world position composing the path
  65798. */
  65799. computePath(start: Vector3, end: Vector3): Vector3[];
  65800. /**
  65801. * If this plugin is supported
  65802. * @returns true if plugin is supported
  65803. */
  65804. isSupported(): boolean;
  65805. /**
  65806. * Create a new Crowd so you can add agents
  65807. * @param maxAgents the maximum agent count in the crowd
  65808. * @param maxAgentRadius the maximum radius an agent can have
  65809. * @param scene to attach the crowd to
  65810. * @returns the crowd you can add agents to
  65811. */
  65812. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65813. /**
  65814. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65815. * The queries will try to find a solution within those bounds
  65816. * default is (1,1,1)
  65817. * @param extent x,y,z value that define the extent around the queries point of reference
  65818. */
  65819. setDefaultQueryExtent(extent: Vector3): void;
  65820. /**
  65821. * Get the Bounding box extent specified by setDefaultQueryExtent
  65822. * @returns the box extent values
  65823. */
  65824. getDefaultQueryExtent(): Vector3;
  65825. /**
  65826. * build the navmesh from a previously saved state using getNavmeshData
  65827. * @param data the Uint8Array returned by getNavmeshData
  65828. */
  65829. buildFromNavmeshData(data: Uint8Array): void;
  65830. /**
  65831. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65832. * @returns data the Uint8Array that can be saved and reused
  65833. */
  65834. getNavmeshData(): Uint8Array;
  65835. /**
  65836. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65837. * @param result output the box extent values
  65838. */
  65839. getDefaultQueryExtentToRef(result: Vector3): void;
  65840. /**
  65841. * Release all resources
  65842. */
  65843. dispose(): void;
  65844. }
  65845. /**
  65846. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65847. */
  65848. export interface ICrowd {
  65849. /**
  65850. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65851. * You can attach anything to that node. The node position is updated in the scene update tick.
  65852. * @param pos world position that will be constrained by the navigation mesh
  65853. * @param parameters agent parameters
  65854. * @param transform hooked to the agent that will be update by the scene
  65855. * @returns agent index
  65856. */
  65857. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65858. /**
  65859. * Returns the agent position in world space
  65860. * @param index agent index returned by addAgent
  65861. * @returns world space position
  65862. */
  65863. getAgentPosition(index: number): Vector3;
  65864. /**
  65865. * Gets the agent position result in world space
  65866. * @param index agent index returned by addAgent
  65867. * @param result output world space position
  65868. */
  65869. getAgentPositionToRef(index: number, result: Vector3): void;
  65870. /**
  65871. * Gets the agent velocity in world space
  65872. * @param index agent index returned by addAgent
  65873. * @returns world space velocity
  65874. */
  65875. getAgentVelocity(index: number): Vector3;
  65876. /**
  65877. * Gets the agent velocity result in world space
  65878. * @param index agent index returned by addAgent
  65879. * @param result output world space velocity
  65880. */
  65881. getAgentVelocityToRef(index: number, result: Vector3): void;
  65882. /**
  65883. * remove a particular agent previously created
  65884. * @param index agent index returned by addAgent
  65885. */
  65886. removeAgent(index: number): void;
  65887. /**
  65888. * get the list of all agents attached to this crowd
  65889. * @returns list of agent indices
  65890. */
  65891. getAgents(): number[];
  65892. /**
  65893. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65894. * @param deltaTime in seconds
  65895. */
  65896. update(deltaTime: number): void;
  65897. /**
  65898. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65899. * @param index agent index returned by addAgent
  65900. * @param destination targeted world position
  65901. */
  65902. agentGoto(index: number, destination: Vector3): void;
  65903. /**
  65904. * Teleport the agent to a new position
  65905. * @param index agent index returned by addAgent
  65906. * @param destination targeted world position
  65907. */
  65908. agentTeleport(index: number, destination: Vector3): void;
  65909. /**
  65910. * Update agent parameters
  65911. * @param index agent index returned by addAgent
  65912. * @param parameters agent parameters
  65913. */
  65914. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65915. /**
  65916. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65917. * The queries will try to find a solution within those bounds
  65918. * default is (1,1,1)
  65919. * @param extent x,y,z value that define the extent around the queries point of reference
  65920. */
  65921. setDefaultQueryExtent(extent: Vector3): void;
  65922. /**
  65923. * Get the Bounding box extent specified by setDefaultQueryExtent
  65924. * @returns the box extent values
  65925. */
  65926. getDefaultQueryExtent(): Vector3;
  65927. /**
  65928. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65929. * @param result output the box extent values
  65930. */
  65931. getDefaultQueryExtentToRef(result: Vector3): void;
  65932. /**
  65933. * Release all resources
  65934. */
  65935. dispose(): void;
  65936. }
  65937. /**
  65938. * Configures an agent
  65939. */
  65940. export interface IAgentParameters {
  65941. /**
  65942. * Agent radius. [Limit: >= 0]
  65943. */
  65944. radius: number;
  65945. /**
  65946. * Agent height. [Limit: > 0]
  65947. */
  65948. height: number;
  65949. /**
  65950. * Maximum allowed acceleration. [Limit: >= 0]
  65951. */
  65952. maxAcceleration: number;
  65953. /**
  65954. * Maximum allowed speed. [Limit: >= 0]
  65955. */
  65956. maxSpeed: number;
  65957. /**
  65958. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65959. */
  65960. collisionQueryRange: number;
  65961. /**
  65962. * The path visibility optimization range. [Limit: > 0]
  65963. */
  65964. pathOptimizationRange: number;
  65965. /**
  65966. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65967. */
  65968. separationWeight: number;
  65969. }
  65970. /**
  65971. * Configures the navigation mesh creation
  65972. */
  65973. export interface INavMeshParameters {
  65974. /**
  65975. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65976. */
  65977. cs: number;
  65978. /**
  65979. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65980. */
  65981. ch: number;
  65982. /**
  65983. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65984. */
  65985. walkableSlopeAngle: number;
  65986. /**
  65987. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65988. * be considered walkable. [Limit: >= 3] [Units: vx]
  65989. */
  65990. walkableHeight: number;
  65991. /**
  65992. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65993. */
  65994. walkableClimb: number;
  65995. /**
  65996. * The distance to erode/shrink the walkable area of the heightfield away from
  65997. * obstructions. [Limit: >=0] [Units: vx]
  65998. */
  65999. walkableRadius: number;
  66000. /**
  66001. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66002. */
  66003. maxEdgeLen: number;
  66004. /**
  66005. * The maximum distance a simplfied contour's border edges should deviate
  66006. * the original raw contour. [Limit: >=0] [Units: vx]
  66007. */
  66008. maxSimplificationError: number;
  66009. /**
  66010. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66011. */
  66012. minRegionArea: number;
  66013. /**
  66014. * Any regions with a span count smaller than this value will, if possible,
  66015. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66016. */
  66017. mergeRegionArea: number;
  66018. /**
  66019. * The maximum number of vertices allowed for polygons generated during the
  66020. * contour to polygon conversion process. [Limit: >= 3]
  66021. */
  66022. maxVertsPerPoly: number;
  66023. /**
  66024. * Sets the sampling distance to use when generating the detail mesh.
  66025. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66026. */
  66027. detailSampleDist: number;
  66028. /**
  66029. * The maximum distance the detail mesh surface should deviate from heightfield
  66030. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66031. */
  66032. detailSampleMaxError: number;
  66033. }
  66034. }
  66035. declare module BABYLON {
  66036. /**
  66037. * RecastJS navigation plugin
  66038. */
  66039. export class RecastJSPlugin implements INavigationEnginePlugin {
  66040. /**
  66041. * Reference to the Recast library
  66042. */
  66043. bjsRECAST: any;
  66044. /**
  66045. * plugin name
  66046. */
  66047. name: string;
  66048. /**
  66049. * the first navmesh created. We might extend this to support multiple navmeshes
  66050. */
  66051. navMesh: any;
  66052. /**
  66053. * Initializes the recastJS plugin
  66054. * @param recastInjection can be used to inject your own recast reference
  66055. */
  66056. constructor(recastInjection?: any);
  66057. /**
  66058. * Creates a navigation mesh
  66059. * @param meshes array of all the geometry used to compute the navigatio mesh
  66060. * @param parameters bunch of parameters used to filter geometry
  66061. */
  66062. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66063. /**
  66064. * Create a navigation mesh debug mesh
  66065. * @param scene is where the mesh will be added
  66066. * @returns debug display mesh
  66067. */
  66068. createDebugNavMesh(scene: Scene): Mesh;
  66069. /**
  66070. * Get a navigation mesh constrained position, closest to the parameter position
  66071. * @param position world position
  66072. * @returns the closest point to position constrained by the navigation mesh
  66073. */
  66074. getClosestPoint(position: Vector3): Vector3;
  66075. /**
  66076. * Get a navigation mesh constrained position, closest to the parameter position
  66077. * @param position world position
  66078. * @param result output the closest point to position constrained by the navigation mesh
  66079. */
  66080. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66081. /**
  66082. * Get a navigation mesh constrained position, within a particular radius
  66083. * @param position world position
  66084. * @param maxRadius the maximum distance to the constrained world position
  66085. * @returns the closest point to position constrained by the navigation mesh
  66086. */
  66087. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66088. /**
  66089. * Get a navigation mesh constrained position, within a particular radius
  66090. * @param position world position
  66091. * @param maxRadius the maximum distance to the constrained world position
  66092. * @param result output the closest point to position constrained by the navigation mesh
  66093. */
  66094. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66095. /**
  66096. * Compute the final position from a segment made of destination-position
  66097. * @param position world position
  66098. * @param destination world position
  66099. * @returns the resulting point along the navmesh
  66100. */
  66101. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66102. /**
  66103. * Compute the final position from a segment made of destination-position
  66104. * @param position world position
  66105. * @param destination world position
  66106. * @param result output the resulting point along the navmesh
  66107. */
  66108. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66109. /**
  66110. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66111. * @param start world position
  66112. * @param end world position
  66113. * @returns array containing world position composing the path
  66114. */
  66115. computePath(start: Vector3, end: Vector3): Vector3[];
  66116. /**
  66117. * Create a new Crowd so you can add agents
  66118. * @param maxAgents the maximum agent count in the crowd
  66119. * @param maxAgentRadius the maximum radius an agent can have
  66120. * @param scene to attach the crowd to
  66121. * @returns the crowd you can add agents to
  66122. */
  66123. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66124. /**
  66125. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66126. * The queries will try to find a solution within those bounds
  66127. * default is (1,1,1)
  66128. * @param extent x,y,z value that define the extent around the queries point of reference
  66129. */
  66130. setDefaultQueryExtent(extent: Vector3): void;
  66131. /**
  66132. * Get the Bounding box extent specified by setDefaultQueryExtent
  66133. * @returns the box extent values
  66134. */
  66135. getDefaultQueryExtent(): Vector3;
  66136. /**
  66137. * build the navmesh from a previously saved state using getNavmeshData
  66138. * @param data the Uint8Array returned by getNavmeshData
  66139. */
  66140. buildFromNavmeshData(data: Uint8Array): void;
  66141. /**
  66142. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66143. * @returns data the Uint8Array that can be saved and reused
  66144. */
  66145. getNavmeshData(): Uint8Array;
  66146. /**
  66147. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66148. * @param result output the box extent values
  66149. */
  66150. getDefaultQueryExtentToRef(result: Vector3): void;
  66151. /**
  66152. * Disposes
  66153. */
  66154. dispose(): void;
  66155. /**
  66156. * If this plugin is supported
  66157. * @returns true if plugin is supported
  66158. */
  66159. isSupported(): boolean;
  66160. }
  66161. /**
  66162. * Recast detour crowd implementation
  66163. */
  66164. export class RecastJSCrowd implements ICrowd {
  66165. /**
  66166. * Recast/detour plugin
  66167. */
  66168. bjsRECASTPlugin: RecastJSPlugin;
  66169. /**
  66170. * Link to the detour crowd
  66171. */
  66172. recastCrowd: any;
  66173. /**
  66174. * One transform per agent
  66175. */
  66176. transforms: TransformNode[];
  66177. /**
  66178. * All agents created
  66179. */
  66180. agents: number[];
  66181. /**
  66182. * Link to the scene is kept to unregister the crowd from the scene
  66183. */
  66184. private _scene;
  66185. /**
  66186. * Observer for crowd updates
  66187. */
  66188. private _onBeforeAnimationsObserver;
  66189. /**
  66190. * Constructor
  66191. * @param plugin recastJS plugin
  66192. * @param maxAgents the maximum agent count in the crowd
  66193. * @param maxAgentRadius the maximum radius an agent can have
  66194. * @param scene to attach the crowd to
  66195. * @returns the crowd you can add agents to
  66196. */
  66197. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66198. /**
  66199. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66200. * You can attach anything to that node. The node position is updated in the scene update tick.
  66201. * @param pos world position that will be constrained by the navigation mesh
  66202. * @param parameters agent parameters
  66203. * @param transform hooked to the agent that will be update by the scene
  66204. * @returns agent index
  66205. */
  66206. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66207. /**
  66208. * Returns the agent position in world space
  66209. * @param index agent index returned by addAgent
  66210. * @returns world space position
  66211. */
  66212. getAgentPosition(index: number): Vector3;
  66213. /**
  66214. * Returns the agent position result in world space
  66215. * @param index agent index returned by addAgent
  66216. * @param result output world space position
  66217. */
  66218. getAgentPositionToRef(index: number, result: Vector3): void;
  66219. /**
  66220. * Returns the agent velocity in world space
  66221. * @param index agent index returned by addAgent
  66222. * @returns world space velocity
  66223. */
  66224. getAgentVelocity(index: number): Vector3;
  66225. /**
  66226. * Returns the agent velocity result in world space
  66227. * @param index agent index returned by addAgent
  66228. * @param result output world space velocity
  66229. */
  66230. getAgentVelocityToRef(index: number, result: Vector3): void;
  66231. /**
  66232. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66233. * @param index agent index returned by addAgent
  66234. * @param destination targeted world position
  66235. */
  66236. agentGoto(index: number, destination: Vector3): void;
  66237. /**
  66238. * Teleport the agent to a new position
  66239. * @param index agent index returned by addAgent
  66240. * @param destination targeted world position
  66241. */
  66242. agentTeleport(index: number, destination: Vector3): void;
  66243. /**
  66244. * Update agent parameters
  66245. * @param index agent index returned by addAgent
  66246. * @param parameters agent parameters
  66247. */
  66248. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66249. /**
  66250. * remove a particular agent previously created
  66251. * @param index agent index returned by addAgent
  66252. */
  66253. removeAgent(index: number): void;
  66254. /**
  66255. * get the list of all agents attached to this crowd
  66256. * @returns list of agent indices
  66257. */
  66258. getAgents(): number[];
  66259. /**
  66260. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66261. * @param deltaTime in seconds
  66262. */
  66263. update(deltaTime: number): void;
  66264. /**
  66265. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66266. * The queries will try to find a solution within those bounds
  66267. * default is (1,1,1)
  66268. * @param extent x,y,z value that define the extent around the queries point of reference
  66269. */
  66270. setDefaultQueryExtent(extent: Vector3): void;
  66271. /**
  66272. * Get the Bounding box extent specified by setDefaultQueryExtent
  66273. * @returns the box extent values
  66274. */
  66275. getDefaultQueryExtent(): Vector3;
  66276. /**
  66277. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66278. * @param result output the box extent values
  66279. */
  66280. getDefaultQueryExtentToRef(result: Vector3): void;
  66281. /**
  66282. * Release all resources
  66283. */
  66284. dispose(): void;
  66285. }
  66286. }
  66287. declare module BABYLON {
  66288. /**
  66289. * Class used to enable access to IndexedDB
  66290. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66291. */
  66292. export class Database implements IOfflineProvider {
  66293. private _callbackManifestChecked;
  66294. private _currentSceneUrl;
  66295. private _db;
  66296. private _enableSceneOffline;
  66297. private _enableTexturesOffline;
  66298. private _manifestVersionFound;
  66299. private _mustUpdateRessources;
  66300. private _hasReachedQuota;
  66301. private _isSupported;
  66302. private _idbFactory;
  66303. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66304. private static IsUASupportingBlobStorage;
  66305. /**
  66306. * Gets a boolean indicating if Database storate is enabled (off by default)
  66307. */
  66308. static IDBStorageEnabled: boolean;
  66309. /**
  66310. * Gets a boolean indicating if scene must be saved in the database
  66311. */
  66312. get enableSceneOffline(): boolean;
  66313. /**
  66314. * Gets a boolean indicating if textures must be saved in the database
  66315. */
  66316. get enableTexturesOffline(): boolean;
  66317. /**
  66318. * Creates a new Database
  66319. * @param urlToScene defines the url to load the scene
  66320. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66321. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66322. */
  66323. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66324. private static _ParseURL;
  66325. private static _ReturnFullUrlLocation;
  66326. private _checkManifestFile;
  66327. /**
  66328. * Open the database and make it available
  66329. * @param successCallback defines the callback to call on success
  66330. * @param errorCallback defines the callback to call on error
  66331. */
  66332. open(successCallback: () => void, errorCallback: () => void): void;
  66333. /**
  66334. * Loads an image from the database
  66335. * @param url defines the url to load from
  66336. * @param image defines the target DOM image
  66337. */
  66338. loadImage(url: string, image: HTMLImageElement): void;
  66339. private _loadImageFromDBAsync;
  66340. private _saveImageIntoDBAsync;
  66341. private _checkVersionFromDB;
  66342. private _loadVersionFromDBAsync;
  66343. private _saveVersionIntoDBAsync;
  66344. /**
  66345. * Loads a file from database
  66346. * @param url defines the URL to load from
  66347. * @param sceneLoaded defines a callback to call on success
  66348. * @param progressCallBack defines a callback to call when progress changed
  66349. * @param errorCallback defines a callback to call on error
  66350. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66351. */
  66352. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66353. private _loadFileAsync;
  66354. private _saveFileAsync;
  66355. /**
  66356. * Validates if xhr data is correct
  66357. * @param xhr defines the request to validate
  66358. * @param dataType defines the expected data type
  66359. * @returns true if data is correct
  66360. */
  66361. private static _ValidateXHRData;
  66362. }
  66363. }
  66364. declare module BABYLON {
  66365. /** @hidden */
  66366. export var gpuUpdateParticlesPixelShader: {
  66367. name: string;
  66368. shader: string;
  66369. };
  66370. }
  66371. declare module BABYLON {
  66372. /** @hidden */
  66373. export var gpuUpdateParticlesVertexShader: {
  66374. name: string;
  66375. shader: string;
  66376. };
  66377. }
  66378. declare module BABYLON {
  66379. /** @hidden */
  66380. export var clipPlaneFragmentDeclaration2: {
  66381. name: string;
  66382. shader: string;
  66383. };
  66384. }
  66385. declare module BABYLON {
  66386. /** @hidden */
  66387. export var gpuRenderParticlesPixelShader: {
  66388. name: string;
  66389. shader: string;
  66390. };
  66391. }
  66392. declare module BABYLON {
  66393. /** @hidden */
  66394. export var clipPlaneVertexDeclaration2: {
  66395. name: string;
  66396. shader: string;
  66397. };
  66398. }
  66399. declare module BABYLON {
  66400. /** @hidden */
  66401. export var gpuRenderParticlesVertexShader: {
  66402. name: string;
  66403. shader: string;
  66404. };
  66405. }
  66406. declare module BABYLON {
  66407. /**
  66408. * This represents a GPU particle system in Babylon
  66409. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66410. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66411. */
  66412. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66413. /**
  66414. * The layer mask we are rendering the particles through.
  66415. */
  66416. layerMask: number;
  66417. private _capacity;
  66418. private _activeCount;
  66419. private _currentActiveCount;
  66420. private _accumulatedCount;
  66421. private _renderEffect;
  66422. private _updateEffect;
  66423. private _buffer0;
  66424. private _buffer1;
  66425. private _spriteBuffer;
  66426. private _updateVAO;
  66427. private _renderVAO;
  66428. private _targetIndex;
  66429. private _sourceBuffer;
  66430. private _targetBuffer;
  66431. private _engine;
  66432. private _currentRenderId;
  66433. private _started;
  66434. private _stopped;
  66435. private _timeDelta;
  66436. private _randomTexture;
  66437. private _randomTexture2;
  66438. private _attributesStrideSize;
  66439. private _updateEffectOptions;
  66440. private _randomTextureSize;
  66441. private _actualFrame;
  66442. private _customEffect;
  66443. private readonly _rawTextureWidth;
  66444. /**
  66445. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66446. */
  66447. static get IsSupported(): boolean;
  66448. /**
  66449. * An event triggered when the system is disposed.
  66450. */
  66451. onDisposeObservable: Observable<IParticleSystem>;
  66452. /**
  66453. * Gets the maximum number of particles active at the same time.
  66454. * @returns The max number of active particles.
  66455. */
  66456. getCapacity(): number;
  66457. /**
  66458. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66459. * to override the particles.
  66460. */
  66461. forceDepthWrite: boolean;
  66462. /**
  66463. * Gets or set the number of active particles
  66464. */
  66465. get activeParticleCount(): number;
  66466. set activeParticleCount(value: number);
  66467. private _preWarmDone;
  66468. /**
  66469. * Specifies if the particles are updated in emitter local space or world space.
  66470. */
  66471. isLocal: boolean;
  66472. /**
  66473. * Is this system ready to be used/rendered
  66474. * @return true if the system is ready
  66475. */
  66476. isReady(): boolean;
  66477. /**
  66478. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66479. * @returns True if it has been started, otherwise false.
  66480. */
  66481. isStarted(): boolean;
  66482. /**
  66483. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66484. * @returns True if it has been stopped, otherwise false.
  66485. */
  66486. isStopped(): boolean;
  66487. /**
  66488. * Gets a boolean indicating that the system is stopping
  66489. * @returns true if the system is currently stopping
  66490. */
  66491. isStopping(): boolean;
  66492. /**
  66493. * Gets the number of particles active at the same time.
  66494. * @returns The number of active particles.
  66495. */
  66496. getActiveCount(): number;
  66497. /**
  66498. * Starts the particle system and begins to emit
  66499. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66500. */
  66501. start(delay?: number): void;
  66502. /**
  66503. * Stops the particle system.
  66504. */
  66505. stop(): void;
  66506. /**
  66507. * Remove all active particles
  66508. */
  66509. reset(): void;
  66510. /**
  66511. * Returns the string "GPUParticleSystem"
  66512. * @returns a string containing the class name
  66513. */
  66514. getClassName(): string;
  66515. /**
  66516. * Gets the custom effect used to render the particles
  66517. * @param blendMode Blend mode for which the effect should be retrieved
  66518. * @returns The effect
  66519. */
  66520. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66521. /**
  66522. * Sets the custom effect used to render the particles
  66523. * @param effect The effect to set
  66524. * @param blendMode Blend mode for which the effect should be set
  66525. */
  66526. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66527. /** @hidden */
  66528. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66529. /**
  66530. * Observable that will be called just before the particles are drawn
  66531. */
  66532. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66533. /**
  66534. * Gets the name of the particle vertex shader
  66535. */
  66536. get vertexShaderName(): string;
  66537. private _colorGradientsTexture;
  66538. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66539. /**
  66540. * Adds a new color gradient
  66541. * @param gradient defines the gradient to use (between 0 and 1)
  66542. * @param color1 defines the color to affect to the specified gradient
  66543. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66544. * @returns the current particle system
  66545. */
  66546. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66547. private _refreshColorGradient;
  66548. /** Force the system to rebuild all gradients that need to be resync */
  66549. forceRefreshGradients(): void;
  66550. /**
  66551. * Remove a specific color gradient
  66552. * @param gradient defines the gradient to remove
  66553. * @returns the current particle system
  66554. */
  66555. removeColorGradient(gradient: number): GPUParticleSystem;
  66556. private _angularSpeedGradientsTexture;
  66557. private _sizeGradientsTexture;
  66558. private _velocityGradientsTexture;
  66559. private _limitVelocityGradientsTexture;
  66560. private _dragGradientsTexture;
  66561. private _addFactorGradient;
  66562. /**
  66563. * Adds a new size gradient
  66564. * @param gradient defines the gradient to use (between 0 and 1)
  66565. * @param factor defines the size factor to affect to the specified gradient
  66566. * @returns the current particle system
  66567. */
  66568. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66569. /**
  66570. * Remove a specific size gradient
  66571. * @param gradient defines the gradient to remove
  66572. * @returns the current particle system
  66573. */
  66574. removeSizeGradient(gradient: number): GPUParticleSystem;
  66575. private _refreshFactorGradient;
  66576. /**
  66577. * Adds a new angular speed gradient
  66578. * @param gradient defines the gradient to use (between 0 and 1)
  66579. * @param factor defines the angular speed to affect to the specified gradient
  66580. * @returns the current particle system
  66581. */
  66582. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66583. /**
  66584. * Remove a specific angular speed gradient
  66585. * @param gradient defines the gradient to remove
  66586. * @returns the current particle system
  66587. */
  66588. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66589. /**
  66590. * Adds a new velocity gradient
  66591. * @param gradient defines the gradient to use (between 0 and 1)
  66592. * @param factor defines the velocity to affect to the specified gradient
  66593. * @returns the current particle system
  66594. */
  66595. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66596. /**
  66597. * Remove a specific velocity gradient
  66598. * @param gradient defines the gradient to remove
  66599. * @returns the current particle system
  66600. */
  66601. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66602. /**
  66603. * Adds a new limit velocity gradient
  66604. * @param gradient defines the gradient to use (between 0 and 1)
  66605. * @param factor defines the limit velocity value to affect to the specified gradient
  66606. * @returns the current particle system
  66607. */
  66608. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66609. /**
  66610. * Remove a specific limit velocity gradient
  66611. * @param gradient defines the gradient to remove
  66612. * @returns the current particle system
  66613. */
  66614. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66615. /**
  66616. * Adds a new drag gradient
  66617. * @param gradient defines the gradient to use (between 0 and 1)
  66618. * @param factor defines the drag value to affect to the specified gradient
  66619. * @returns the current particle system
  66620. */
  66621. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66622. /**
  66623. * Remove a specific drag gradient
  66624. * @param gradient defines the gradient to remove
  66625. * @returns the current particle system
  66626. */
  66627. removeDragGradient(gradient: number): GPUParticleSystem;
  66628. /**
  66629. * Not supported by GPUParticleSystem
  66630. * @param gradient defines the gradient to use (between 0 and 1)
  66631. * @param factor defines the emit rate value to affect to the specified gradient
  66632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66633. * @returns the current particle system
  66634. */
  66635. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66636. /**
  66637. * Not supported by GPUParticleSystem
  66638. * @param gradient defines the gradient to remove
  66639. * @returns the current particle system
  66640. */
  66641. removeEmitRateGradient(gradient: number): IParticleSystem;
  66642. /**
  66643. * Not supported by GPUParticleSystem
  66644. * @param gradient defines the gradient to use (between 0 and 1)
  66645. * @param factor defines the start size value to affect to the specified gradient
  66646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66647. * @returns the current particle system
  66648. */
  66649. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66650. /**
  66651. * Not supported by GPUParticleSystem
  66652. * @param gradient defines the gradient to remove
  66653. * @returns the current particle system
  66654. */
  66655. removeStartSizeGradient(gradient: number): IParticleSystem;
  66656. /**
  66657. * Not supported by GPUParticleSystem
  66658. * @param gradient defines the gradient to use (between 0 and 1)
  66659. * @param min defines the color remap minimal range
  66660. * @param max defines the color remap maximal range
  66661. * @returns the current particle system
  66662. */
  66663. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66664. /**
  66665. * Not supported by GPUParticleSystem
  66666. * @param gradient defines the gradient to remove
  66667. * @returns the current particle system
  66668. */
  66669. removeColorRemapGradient(): IParticleSystem;
  66670. /**
  66671. * Not supported by GPUParticleSystem
  66672. * @param gradient defines the gradient to use (between 0 and 1)
  66673. * @param min defines the alpha remap minimal range
  66674. * @param max defines the alpha remap maximal range
  66675. * @returns the current particle system
  66676. */
  66677. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66678. /**
  66679. * Not supported by GPUParticleSystem
  66680. * @param gradient defines the gradient to remove
  66681. * @returns the current particle system
  66682. */
  66683. removeAlphaRemapGradient(): IParticleSystem;
  66684. /**
  66685. * Not supported by GPUParticleSystem
  66686. * @param gradient defines the gradient to use (between 0 and 1)
  66687. * @param color defines the color to affect to the specified gradient
  66688. * @returns the current particle system
  66689. */
  66690. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66691. /**
  66692. * Not supported by GPUParticleSystem
  66693. * @param gradient defines the gradient to remove
  66694. * @returns the current particle system
  66695. */
  66696. removeRampGradient(): IParticleSystem;
  66697. /**
  66698. * Not supported by GPUParticleSystem
  66699. * @returns the list of ramp gradients
  66700. */
  66701. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66702. /**
  66703. * Not supported by GPUParticleSystem
  66704. * Gets or sets a boolean indicating that ramp gradients must be used
  66705. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66706. */
  66707. get useRampGradients(): boolean;
  66708. set useRampGradients(value: boolean);
  66709. /**
  66710. * Not supported by GPUParticleSystem
  66711. * @param gradient defines the gradient to use (between 0 and 1)
  66712. * @param factor defines the life time factor to affect to the specified gradient
  66713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66714. * @returns the current particle system
  66715. */
  66716. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66717. /**
  66718. * Not supported by GPUParticleSystem
  66719. * @param gradient defines the gradient to remove
  66720. * @returns the current particle system
  66721. */
  66722. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66723. /**
  66724. * Instantiates a GPU particle system.
  66725. * 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.
  66726. * @param name The name of the particle system
  66727. * @param options The options used to create the system
  66728. * @param scene The scene the particle system belongs to
  66729. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66730. * @param customEffect a custom effect used to change the way particles are rendered by default
  66731. */
  66732. constructor(name: string, options: Partial<{
  66733. capacity: number;
  66734. randomTextureSize: number;
  66735. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66736. protected _reset(): void;
  66737. private _createUpdateVAO;
  66738. private _createRenderVAO;
  66739. private _initialize;
  66740. /** @hidden */
  66741. _recreateUpdateEffect(): void;
  66742. private _getEffect;
  66743. /**
  66744. * Fill the defines array according to the current settings of the particle system
  66745. * @param defines Array to be updated
  66746. * @param blendMode blend mode to take into account when updating the array
  66747. */
  66748. fillDefines(defines: Array<string>, blendMode?: number): void;
  66749. /**
  66750. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66751. * @param uniforms Uniforms array to fill
  66752. * @param attributes Attributes array to fill
  66753. * @param samplers Samplers array to fill
  66754. */
  66755. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66756. /** @hidden */
  66757. _recreateRenderEffect(): Effect;
  66758. /**
  66759. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66760. * @param preWarm defines if we are in the pre-warmimg phase
  66761. */
  66762. animate(preWarm?: boolean): void;
  66763. private _createFactorGradientTexture;
  66764. private _createSizeGradientTexture;
  66765. private _createAngularSpeedGradientTexture;
  66766. private _createVelocityGradientTexture;
  66767. private _createLimitVelocityGradientTexture;
  66768. private _createDragGradientTexture;
  66769. private _createColorGradientTexture;
  66770. /**
  66771. * Renders the particle system in its current state
  66772. * @param preWarm defines if the system should only update the particles but not render them
  66773. * @returns the current number of particles
  66774. */
  66775. render(preWarm?: boolean): number;
  66776. /**
  66777. * Rebuilds the particle system
  66778. */
  66779. rebuild(): void;
  66780. private _releaseBuffers;
  66781. private _releaseVAOs;
  66782. /**
  66783. * Disposes the particle system and free the associated resources
  66784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66785. */
  66786. dispose(disposeTexture?: boolean): void;
  66787. /**
  66788. * Clones the particle system.
  66789. * @param name The name of the cloned object
  66790. * @param newEmitter The new emitter to use
  66791. * @returns the cloned particle system
  66792. */
  66793. clone(name: string, newEmitter: any): GPUParticleSystem;
  66794. /**
  66795. * Serializes the particle system to a JSON object
  66796. * @param serializeTexture defines if the texture must be serialized as well
  66797. * @returns the JSON object
  66798. */
  66799. serialize(serializeTexture?: boolean): any;
  66800. /**
  66801. * Parses a JSON object to create a GPU particle system.
  66802. * @param parsedParticleSystem The JSON object to parse
  66803. * @param scene The scene to create the particle system in
  66804. * @param rootUrl The root url to use to load external dependencies like texture
  66805. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66806. * @returns the parsed GPU particle system
  66807. */
  66808. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66809. }
  66810. }
  66811. declare module BABYLON {
  66812. /**
  66813. * Represents a set of particle systems working together to create a specific effect
  66814. */
  66815. export class ParticleSystemSet implements IDisposable {
  66816. /**
  66817. * Gets or sets base Assets URL
  66818. */
  66819. static BaseAssetsUrl: string;
  66820. private _emitterCreationOptions;
  66821. private _emitterNode;
  66822. /**
  66823. * Gets the particle system list
  66824. */
  66825. systems: IParticleSystem[];
  66826. /**
  66827. * Gets the emitter node used with this set
  66828. */
  66829. get emitterNode(): Nullable<TransformNode>;
  66830. /**
  66831. * Creates a new emitter mesh as a sphere
  66832. * @param options defines the options used to create the sphere
  66833. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66834. * @param scene defines the hosting scene
  66835. */
  66836. setEmitterAsSphere(options: {
  66837. diameter: number;
  66838. segments: number;
  66839. color: Color3;
  66840. }, renderingGroupId: number, scene: Scene): void;
  66841. /**
  66842. * Starts all particle systems of the set
  66843. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66844. */
  66845. start(emitter?: AbstractMesh): void;
  66846. /**
  66847. * Release all associated resources
  66848. */
  66849. dispose(): void;
  66850. /**
  66851. * Serialize the set into a JSON compatible object
  66852. * @param serializeTexture defines if the texture must be serialized as well
  66853. * @returns a JSON compatible representation of the set
  66854. */
  66855. serialize(serializeTexture?: boolean): any;
  66856. /**
  66857. * Parse a new ParticleSystemSet from a serialized source
  66858. * @param data defines a JSON compatible representation of the set
  66859. * @param scene defines the hosting scene
  66860. * @param gpu defines if we want GPU particles or CPU particles
  66861. * @returns a new ParticleSystemSet
  66862. */
  66863. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66864. }
  66865. }
  66866. declare module BABYLON {
  66867. /**
  66868. * This class is made for on one-liner static method to help creating particle system set.
  66869. */
  66870. export class ParticleHelper {
  66871. /**
  66872. * Gets or sets base Assets URL
  66873. */
  66874. static BaseAssetsUrl: string;
  66875. /** Define the Url to load snippets */
  66876. static SnippetUrl: string;
  66877. /**
  66878. * Create a default particle system that you can tweak
  66879. * @param emitter defines the emitter to use
  66880. * @param capacity defines the system capacity (default is 500 particles)
  66881. * @param scene defines the hosting scene
  66882. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66883. * @returns the new Particle system
  66884. */
  66885. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66886. /**
  66887. * This is the main static method (one-liner) of this helper to create different particle systems
  66888. * @param type This string represents the type to the particle system to create
  66889. * @param scene The scene where the particle system should live
  66890. * @param gpu If the system will use gpu
  66891. * @returns the ParticleSystemSet created
  66892. */
  66893. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66894. /**
  66895. * Static function used to export a particle system to a ParticleSystemSet variable.
  66896. * Please note that the emitter shape is not exported
  66897. * @param systems defines the particle systems to export
  66898. * @returns the created particle system set
  66899. */
  66900. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66901. /**
  66902. * Creates a particle system from a snippet saved in a remote file
  66903. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66904. * @param url defines the url to load from
  66905. * @param scene defines the hosting scene
  66906. * @param gpu If the system will use gpu
  66907. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66908. * @returns a promise that will resolve to the new particle system
  66909. */
  66910. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66911. /**
  66912. * Creates a particle system from a snippet saved by the particle system editor
  66913. * @param snippetId defines the snippet to load
  66914. * @param scene defines the hosting scene
  66915. * @param gpu If the system will use gpu
  66916. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66917. * @returns a promise that will resolve to the new particle system
  66918. */
  66919. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66920. }
  66921. }
  66922. declare module BABYLON {
  66923. interface Engine {
  66924. /**
  66925. * Create an effect to use with particle systems.
  66926. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66927. * the particle system for which you want to create a custom effect in the last parameter
  66928. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66929. * @param uniformsNames defines a list of attribute names
  66930. * @param samplers defines an array of string used to represent textures
  66931. * @param defines defines the string containing the defines to use to compile the shaders
  66932. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66933. * @param onCompiled defines a function to call when the effect creation is successful
  66934. * @param onError defines a function to call when the effect creation has failed
  66935. * @param particleSystem the particle system you want to create the effect for
  66936. * @returns the new Effect
  66937. */
  66938. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66939. }
  66940. interface Mesh {
  66941. /**
  66942. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66943. * @returns an array of IParticleSystem
  66944. */
  66945. getEmittedParticleSystems(): IParticleSystem[];
  66946. /**
  66947. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66948. * @returns an array of IParticleSystem
  66949. */
  66950. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66951. }
  66952. }
  66953. declare module BABYLON {
  66954. /** Defines the 4 color options */
  66955. export enum PointColor {
  66956. /** color value */
  66957. Color = 2,
  66958. /** uv value */
  66959. UV = 1,
  66960. /** random value */
  66961. Random = 0,
  66962. /** stated value */
  66963. Stated = 3
  66964. }
  66965. /**
  66966. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66967. * 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.
  66968. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66969. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66970. *
  66971. * Full documentation here : TO BE ENTERED
  66972. */
  66973. export class PointsCloudSystem implements IDisposable {
  66974. /**
  66975. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66976. * Example : var p = SPS.particles[i];
  66977. */
  66978. particles: CloudPoint[];
  66979. /**
  66980. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66981. */
  66982. nbParticles: number;
  66983. /**
  66984. * This a counter for your own usage. It's not set by any SPS functions.
  66985. */
  66986. counter: number;
  66987. /**
  66988. * The PCS name. This name is also given to the underlying mesh.
  66989. */
  66990. name: string;
  66991. /**
  66992. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66993. */
  66994. mesh: Mesh;
  66995. /**
  66996. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66997. * Please read :
  66998. */
  66999. vars: any;
  67000. /**
  67001. * @hidden
  67002. */
  67003. _size: number;
  67004. private _scene;
  67005. private _promises;
  67006. private _positions;
  67007. private _indices;
  67008. private _normals;
  67009. private _colors;
  67010. private _uvs;
  67011. private _indices32;
  67012. private _positions32;
  67013. private _colors32;
  67014. private _uvs32;
  67015. private _updatable;
  67016. private _isVisibilityBoxLocked;
  67017. private _alwaysVisible;
  67018. private _groups;
  67019. private _groupCounter;
  67020. private _computeParticleColor;
  67021. private _computeParticleTexture;
  67022. private _computeParticleRotation;
  67023. private _computeBoundingBox;
  67024. private _isReady;
  67025. /**
  67026. * Creates a PCS (Points Cloud System) object
  67027. * @param name (String) is the PCS name, this will be the underlying mesh name
  67028. * @param pointSize (number) is the size for each point
  67029. * @param scene (Scene) is the scene in which the PCS is added
  67030. * @param options defines the options of the PCS e.g.
  67031. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67032. */
  67033. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67034. updatable?: boolean;
  67035. });
  67036. /**
  67037. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67038. * If no points were added to the PCS, the returned mesh is just a single point.
  67039. * @returns a promise for the created mesh
  67040. */
  67041. buildMeshAsync(): Promise<Mesh>;
  67042. /**
  67043. * @hidden
  67044. */
  67045. private _buildMesh;
  67046. private _addParticle;
  67047. private _randomUnitVector;
  67048. private _getColorIndicesForCoord;
  67049. private _setPointsColorOrUV;
  67050. private _colorFromTexture;
  67051. private _calculateDensity;
  67052. /**
  67053. * Adds points to the PCS in random positions within a unit sphere
  67054. * @param nb (positive integer) the number of particles to be created from this model
  67055. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67056. * @returns the number of groups in the system
  67057. */
  67058. addPoints(nb: number, pointFunction?: any): number;
  67059. /**
  67060. * Adds points to the PCS from the surface of the model shape
  67061. * @param mesh is any Mesh object that will be used as a surface model for the points
  67062. * @param nb (positive integer) the number of particles to be created from this model
  67063. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67064. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67065. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67066. * @returns the number of groups in the system
  67067. */
  67068. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67069. /**
  67070. * Adds points to the PCS inside the model shape
  67071. * @param mesh is any Mesh object that will be used as a surface model for the points
  67072. * @param nb (positive integer) the number of particles to be created from this model
  67073. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67074. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67075. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67076. * @returns the number of groups in the system
  67077. */
  67078. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67079. /**
  67080. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67081. * This method calls `updateParticle()` for each particle of the SPS.
  67082. * For an animated SPS, it is usually called within the render loop.
  67083. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67084. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67085. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67086. * @returns the PCS.
  67087. */
  67088. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67089. /**
  67090. * Disposes the PCS.
  67091. */
  67092. dispose(): void;
  67093. /**
  67094. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67095. * doc :
  67096. * @returns the PCS.
  67097. */
  67098. refreshVisibleSize(): PointsCloudSystem;
  67099. /**
  67100. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67101. * @param size the size (float) of the visibility box
  67102. * note : this doesn't lock the PCS mesh bounding box.
  67103. * doc :
  67104. */
  67105. setVisibilityBox(size: number): void;
  67106. /**
  67107. * Gets whether the PCS is always visible or not
  67108. * doc :
  67109. */
  67110. get isAlwaysVisible(): boolean;
  67111. /**
  67112. * Sets the PCS as always visible or not
  67113. * doc :
  67114. */
  67115. set isAlwaysVisible(val: boolean);
  67116. /**
  67117. * Tells to `setParticles()` to compute the particle rotations or not
  67118. * Default value : false. The PCS is faster when it's set to false
  67119. * Note : particle rotations are only applied to parent particles
  67120. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67121. */
  67122. set computeParticleRotation(val: boolean);
  67123. /**
  67124. * Tells to `setParticles()` to compute the particle colors or not.
  67125. * Default value : true. The PCS is faster when it's set to false.
  67126. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67127. */
  67128. set computeParticleColor(val: boolean);
  67129. set computeParticleTexture(val: boolean);
  67130. /**
  67131. * Gets if `setParticles()` computes the particle colors or not.
  67132. * Default value : false. The PCS is faster when it's set to false.
  67133. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67134. */
  67135. get computeParticleColor(): boolean;
  67136. /**
  67137. * Gets if `setParticles()` computes the particle textures or not.
  67138. * Default value : false. The PCS is faster when it's set to false.
  67139. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67140. */
  67141. get computeParticleTexture(): boolean;
  67142. /**
  67143. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67144. */
  67145. set computeBoundingBox(val: boolean);
  67146. /**
  67147. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67148. */
  67149. get computeBoundingBox(): boolean;
  67150. /**
  67151. * This function does nothing. It may be overwritten to set all the particle first values.
  67152. * The PCS doesn't call this function, you may have to call it by your own.
  67153. * doc :
  67154. */
  67155. initParticles(): void;
  67156. /**
  67157. * This function does nothing. It may be overwritten to recycle a particle
  67158. * The PCS doesn't call this function, you can to call it
  67159. * doc :
  67160. * @param particle The particle to recycle
  67161. * @returns the recycled particle
  67162. */
  67163. recycleParticle(particle: CloudPoint): CloudPoint;
  67164. /**
  67165. * Updates a particle : this function should be overwritten by the user.
  67166. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67167. * doc :
  67168. * @example : just set a particle position or velocity and recycle conditions
  67169. * @param particle The particle to update
  67170. * @returns the updated particle
  67171. */
  67172. updateParticle(particle: CloudPoint): CloudPoint;
  67173. /**
  67174. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67175. * This does nothing and may be overwritten by the user.
  67176. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67177. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67178. * @param update the boolean update value actually passed to setParticles()
  67179. */
  67180. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67181. /**
  67182. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67183. * This will be passed three parameters.
  67184. * This does nothing and may be overwritten by the user.
  67185. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67186. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67187. * @param update the boolean update value actually passed to setParticles()
  67188. */
  67189. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67190. }
  67191. }
  67192. declare module BABYLON {
  67193. /**
  67194. * Represents one particle of a points cloud system.
  67195. */
  67196. export class CloudPoint {
  67197. /**
  67198. * particle global index
  67199. */
  67200. idx: number;
  67201. /**
  67202. * The color of the particle
  67203. */
  67204. color: Nullable<Color4>;
  67205. /**
  67206. * The world space position of the particle.
  67207. */
  67208. position: Vector3;
  67209. /**
  67210. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67211. */
  67212. rotation: Vector3;
  67213. /**
  67214. * The world space rotation quaternion of the particle.
  67215. */
  67216. rotationQuaternion: Nullable<Quaternion>;
  67217. /**
  67218. * The uv of the particle.
  67219. */
  67220. uv: Nullable<Vector2>;
  67221. /**
  67222. * The current speed of the particle.
  67223. */
  67224. velocity: Vector3;
  67225. /**
  67226. * The pivot point in the particle local space.
  67227. */
  67228. pivot: Vector3;
  67229. /**
  67230. * Must the particle be translated from its pivot point in its local space ?
  67231. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67232. * Default : false
  67233. */
  67234. translateFromPivot: boolean;
  67235. /**
  67236. * Index of this particle in the global "positions" array (Internal use)
  67237. * @hidden
  67238. */
  67239. _pos: number;
  67240. /**
  67241. * @hidden Index of this particle in the global "indices" array (Internal use)
  67242. */
  67243. _ind: number;
  67244. /**
  67245. * Group this particle belongs to
  67246. */
  67247. _group: PointsGroup;
  67248. /**
  67249. * Group id of this particle
  67250. */
  67251. groupId: number;
  67252. /**
  67253. * Index of the particle in its group id (Internal use)
  67254. */
  67255. idxInGroup: number;
  67256. /**
  67257. * @hidden Particle BoundingInfo object (Internal use)
  67258. */
  67259. _boundingInfo: BoundingInfo;
  67260. /**
  67261. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67262. */
  67263. _pcs: PointsCloudSystem;
  67264. /**
  67265. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67266. */
  67267. _stillInvisible: boolean;
  67268. /**
  67269. * @hidden Last computed particle rotation matrix
  67270. */
  67271. _rotationMatrix: number[];
  67272. /**
  67273. * Parent particle Id, if any.
  67274. * Default null.
  67275. */
  67276. parentId: Nullable<number>;
  67277. /**
  67278. * @hidden Internal global position in the PCS.
  67279. */
  67280. _globalPosition: Vector3;
  67281. /**
  67282. * Creates a Point Cloud object.
  67283. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67284. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67285. * @param group (PointsGroup) is the group the particle belongs to
  67286. * @param groupId (integer) is the group identifier in the PCS.
  67287. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67288. * @param pcs defines the PCS it is associated to
  67289. */
  67290. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67291. /**
  67292. * get point size
  67293. */
  67294. get size(): Vector3;
  67295. /**
  67296. * Set point size
  67297. */
  67298. set size(scale: Vector3);
  67299. /**
  67300. * Legacy support, changed quaternion to rotationQuaternion
  67301. */
  67302. get quaternion(): Nullable<Quaternion>;
  67303. /**
  67304. * Legacy support, changed quaternion to rotationQuaternion
  67305. */
  67306. set quaternion(q: Nullable<Quaternion>);
  67307. /**
  67308. * Returns a boolean. True if the particle intersects a mesh, else false
  67309. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67310. * @param target is the object (point or mesh) what the intersection is computed against
  67311. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67312. * @returns true if it intersects
  67313. */
  67314. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67315. /**
  67316. * get the rotation matrix of the particle
  67317. * @hidden
  67318. */
  67319. getRotationMatrix(m: Matrix): void;
  67320. }
  67321. /**
  67322. * Represents a group of points in a points cloud system
  67323. * * PCS internal tool, don't use it manually.
  67324. */
  67325. export class PointsGroup {
  67326. /**
  67327. * The group id
  67328. * @hidden
  67329. */
  67330. groupID: number;
  67331. /**
  67332. * image data for group (internal use)
  67333. * @hidden
  67334. */
  67335. _groupImageData: Nullable<ArrayBufferView>;
  67336. /**
  67337. * Image Width (internal use)
  67338. * @hidden
  67339. */
  67340. _groupImgWidth: number;
  67341. /**
  67342. * Image Height (internal use)
  67343. * @hidden
  67344. */
  67345. _groupImgHeight: number;
  67346. /**
  67347. * Custom position function (internal use)
  67348. * @hidden
  67349. */
  67350. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67351. /**
  67352. * density per facet for surface points
  67353. * @hidden
  67354. */
  67355. _groupDensity: number[];
  67356. /**
  67357. * Only when points are colored by texture carries pointer to texture list array
  67358. * @hidden
  67359. */
  67360. _textureNb: number;
  67361. /**
  67362. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67363. * PCS internal tool, don't use it manually.
  67364. * @hidden
  67365. */
  67366. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67367. }
  67368. }
  67369. declare module BABYLON {
  67370. interface Scene {
  67371. /** @hidden (Backing field) */
  67372. _physicsEngine: Nullable<IPhysicsEngine>;
  67373. /** @hidden */
  67374. _physicsTimeAccumulator: number;
  67375. /**
  67376. * Gets the current physics engine
  67377. * @returns a IPhysicsEngine or null if none attached
  67378. */
  67379. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67380. /**
  67381. * Enables physics to the current scene
  67382. * @param gravity defines the scene's gravity for the physics engine
  67383. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67384. * @return a boolean indicating if the physics engine was initialized
  67385. */
  67386. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67387. /**
  67388. * Disables and disposes the physics engine associated with the scene
  67389. */
  67390. disablePhysicsEngine(): void;
  67391. /**
  67392. * Gets a boolean indicating if there is an active physics engine
  67393. * @returns a boolean indicating if there is an active physics engine
  67394. */
  67395. isPhysicsEnabled(): boolean;
  67396. /**
  67397. * Deletes a physics compound impostor
  67398. * @param compound defines the compound to delete
  67399. */
  67400. deleteCompoundImpostor(compound: any): void;
  67401. /**
  67402. * An event triggered when physic simulation is about to be run
  67403. */
  67404. onBeforePhysicsObservable: Observable<Scene>;
  67405. /**
  67406. * An event triggered when physic simulation has been done
  67407. */
  67408. onAfterPhysicsObservable: Observable<Scene>;
  67409. }
  67410. interface AbstractMesh {
  67411. /** @hidden */
  67412. _physicsImpostor: Nullable<PhysicsImpostor>;
  67413. /**
  67414. * Gets or sets impostor used for physic simulation
  67415. * @see https://doc.babylonjs.com/features/physics_engine
  67416. */
  67417. physicsImpostor: Nullable<PhysicsImpostor>;
  67418. /**
  67419. * Gets the current physics impostor
  67420. * @see https://doc.babylonjs.com/features/physics_engine
  67421. * @returns a physics impostor or null
  67422. */
  67423. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67424. /** Apply a physic impulse to the mesh
  67425. * @param force defines the force to apply
  67426. * @param contactPoint defines where to apply the force
  67427. * @returns the current mesh
  67428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67429. */
  67430. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67431. /**
  67432. * Creates a physic joint between two meshes
  67433. * @param otherMesh defines the other mesh to use
  67434. * @param pivot1 defines the pivot to use on this mesh
  67435. * @param pivot2 defines the pivot to use on the other mesh
  67436. * @param options defines additional options (can be plugin dependent)
  67437. * @returns the current mesh
  67438. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67439. */
  67440. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67441. /** @hidden */
  67442. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67443. }
  67444. /**
  67445. * Defines the physics engine scene component responsible to manage a physics engine
  67446. */
  67447. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67448. /**
  67449. * The component name helpful to identify the component in the list of scene components.
  67450. */
  67451. readonly name: string;
  67452. /**
  67453. * The scene the component belongs to.
  67454. */
  67455. scene: Scene;
  67456. /**
  67457. * Creates a new instance of the component for the given scene
  67458. * @param scene Defines the scene to register the component in
  67459. */
  67460. constructor(scene: Scene);
  67461. /**
  67462. * Registers the component in a given scene
  67463. */
  67464. register(): void;
  67465. /**
  67466. * Rebuilds the elements related to this component in case of
  67467. * context lost for instance.
  67468. */
  67469. rebuild(): void;
  67470. /**
  67471. * Disposes the component and the associated ressources
  67472. */
  67473. dispose(): void;
  67474. }
  67475. }
  67476. declare module BABYLON {
  67477. /**
  67478. * A helper for physics simulations
  67479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67480. */
  67481. export class PhysicsHelper {
  67482. private _scene;
  67483. private _physicsEngine;
  67484. /**
  67485. * Initializes the Physics helper
  67486. * @param scene Babylon.js scene
  67487. */
  67488. constructor(scene: Scene);
  67489. /**
  67490. * Applies a radial explosion impulse
  67491. * @param origin the origin of the explosion
  67492. * @param radiusOrEventOptions the radius or the options of radial explosion
  67493. * @param strength the explosion strength
  67494. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67495. * @returns A physics radial explosion event, or null
  67496. */
  67497. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67498. /**
  67499. * Applies a radial explosion force
  67500. * @param origin the origin of the explosion
  67501. * @param radiusOrEventOptions the radius or the options of radial explosion
  67502. * @param strength the explosion strength
  67503. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67504. * @returns A physics radial explosion event, or null
  67505. */
  67506. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67507. /**
  67508. * Creates a gravitational field
  67509. * @param origin the origin of the explosion
  67510. * @param radiusOrEventOptions the radius or the options of radial explosion
  67511. * @param strength the explosion strength
  67512. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67513. * @returns A physics gravitational field event, or null
  67514. */
  67515. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67516. /**
  67517. * Creates a physics updraft event
  67518. * @param origin the origin of the updraft
  67519. * @param radiusOrEventOptions the radius or the options of the updraft
  67520. * @param strength the strength of the updraft
  67521. * @param height the height of the updraft
  67522. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67523. * @returns A physics updraft event, or null
  67524. */
  67525. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67526. /**
  67527. * Creates a physics vortex event
  67528. * @param origin the of the vortex
  67529. * @param radiusOrEventOptions the radius or the options of the vortex
  67530. * @param strength the strength of the vortex
  67531. * @param height the height of the vortex
  67532. * @returns a Physics vortex event, or null
  67533. * A physics vortex event or null
  67534. */
  67535. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67536. }
  67537. /**
  67538. * Represents a physics radial explosion event
  67539. */
  67540. class PhysicsRadialExplosionEvent {
  67541. private _scene;
  67542. private _options;
  67543. private _sphere;
  67544. private _dataFetched;
  67545. /**
  67546. * Initializes a radial explosioin event
  67547. * @param _scene BabylonJS scene
  67548. * @param _options The options for the vortex event
  67549. */
  67550. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67551. /**
  67552. * Returns the data related to the radial explosion event (sphere).
  67553. * @returns The radial explosion event data
  67554. */
  67555. getData(): PhysicsRadialExplosionEventData;
  67556. /**
  67557. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67558. * @param impostor A physics imposter
  67559. * @param origin the origin of the explosion
  67560. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67561. */
  67562. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67563. /**
  67564. * Triggers affecterd impostors callbacks
  67565. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67566. */
  67567. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67568. /**
  67569. * Disposes the sphere.
  67570. * @param force Specifies if the sphere should be disposed by force
  67571. */
  67572. dispose(force?: boolean): void;
  67573. /*** Helpers ***/
  67574. private _prepareSphere;
  67575. private _intersectsWithSphere;
  67576. }
  67577. /**
  67578. * Represents a gravitational field event
  67579. */
  67580. class PhysicsGravitationalFieldEvent {
  67581. private _physicsHelper;
  67582. private _scene;
  67583. private _origin;
  67584. private _options;
  67585. private _tickCallback;
  67586. private _sphere;
  67587. private _dataFetched;
  67588. /**
  67589. * Initializes the physics gravitational field event
  67590. * @param _physicsHelper A physics helper
  67591. * @param _scene BabylonJS scene
  67592. * @param _origin The origin position of the gravitational field event
  67593. * @param _options The options for the vortex event
  67594. */
  67595. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67596. /**
  67597. * Returns the data related to the gravitational field event (sphere).
  67598. * @returns A gravitational field event
  67599. */
  67600. getData(): PhysicsGravitationalFieldEventData;
  67601. /**
  67602. * Enables the gravitational field.
  67603. */
  67604. enable(): void;
  67605. /**
  67606. * Disables the gravitational field.
  67607. */
  67608. disable(): void;
  67609. /**
  67610. * Disposes the sphere.
  67611. * @param force The force to dispose from the gravitational field event
  67612. */
  67613. dispose(force?: boolean): void;
  67614. private _tick;
  67615. }
  67616. /**
  67617. * Represents a physics updraft event
  67618. */
  67619. class PhysicsUpdraftEvent {
  67620. private _scene;
  67621. private _origin;
  67622. private _options;
  67623. private _physicsEngine;
  67624. private _originTop;
  67625. private _originDirection;
  67626. private _tickCallback;
  67627. private _cylinder;
  67628. private _cylinderPosition;
  67629. private _dataFetched;
  67630. /**
  67631. * Initializes the physics updraft event
  67632. * @param _scene BabylonJS scene
  67633. * @param _origin The origin position of the updraft
  67634. * @param _options The options for the updraft event
  67635. */
  67636. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67637. /**
  67638. * Returns the data related to the updraft event (cylinder).
  67639. * @returns A physics updraft event
  67640. */
  67641. getData(): PhysicsUpdraftEventData;
  67642. /**
  67643. * Enables the updraft.
  67644. */
  67645. enable(): void;
  67646. /**
  67647. * Disables the updraft.
  67648. */
  67649. disable(): void;
  67650. /**
  67651. * Disposes the cylinder.
  67652. * @param force Specifies if the updraft should be disposed by force
  67653. */
  67654. dispose(force?: boolean): void;
  67655. private getImpostorHitData;
  67656. private _tick;
  67657. /*** Helpers ***/
  67658. private _prepareCylinder;
  67659. private _intersectsWithCylinder;
  67660. }
  67661. /**
  67662. * Represents a physics vortex event
  67663. */
  67664. class PhysicsVortexEvent {
  67665. private _scene;
  67666. private _origin;
  67667. private _options;
  67668. private _physicsEngine;
  67669. private _originTop;
  67670. private _tickCallback;
  67671. private _cylinder;
  67672. private _cylinderPosition;
  67673. private _dataFetched;
  67674. /**
  67675. * Initializes the physics vortex event
  67676. * @param _scene The BabylonJS scene
  67677. * @param _origin The origin position of the vortex
  67678. * @param _options The options for the vortex event
  67679. */
  67680. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67681. /**
  67682. * Returns the data related to the vortex event (cylinder).
  67683. * @returns The physics vortex event data
  67684. */
  67685. getData(): PhysicsVortexEventData;
  67686. /**
  67687. * Enables the vortex.
  67688. */
  67689. enable(): void;
  67690. /**
  67691. * Disables the cortex.
  67692. */
  67693. disable(): void;
  67694. /**
  67695. * Disposes the sphere.
  67696. * @param force
  67697. */
  67698. dispose(force?: boolean): void;
  67699. private getImpostorHitData;
  67700. private _tick;
  67701. /*** Helpers ***/
  67702. private _prepareCylinder;
  67703. private _intersectsWithCylinder;
  67704. }
  67705. /**
  67706. * Options fot the radial explosion event
  67707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67708. */
  67709. export class PhysicsRadialExplosionEventOptions {
  67710. /**
  67711. * The radius of the sphere for the radial explosion.
  67712. */
  67713. radius: number;
  67714. /**
  67715. * The strenth of the explosion.
  67716. */
  67717. strength: number;
  67718. /**
  67719. * The strenght of the force in correspondence to the distance of the affected object
  67720. */
  67721. falloff: PhysicsRadialImpulseFalloff;
  67722. /**
  67723. * Sphere options for the radial explosion.
  67724. */
  67725. sphere: {
  67726. segments: number;
  67727. diameter: number;
  67728. };
  67729. /**
  67730. * Sphere options for the radial explosion.
  67731. */
  67732. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67733. }
  67734. /**
  67735. * Options fot the updraft event
  67736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67737. */
  67738. export class PhysicsUpdraftEventOptions {
  67739. /**
  67740. * The radius of the cylinder for the vortex
  67741. */
  67742. radius: number;
  67743. /**
  67744. * The strenth of the updraft.
  67745. */
  67746. strength: number;
  67747. /**
  67748. * The height of the cylinder for the updraft.
  67749. */
  67750. height: number;
  67751. /**
  67752. * The mode for the the updraft.
  67753. */
  67754. updraftMode: PhysicsUpdraftMode;
  67755. }
  67756. /**
  67757. * Options fot the vortex event
  67758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67759. */
  67760. export class PhysicsVortexEventOptions {
  67761. /**
  67762. * The radius of the cylinder for the vortex
  67763. */
  67764. radius: number;
  67765. /**
  67766. * The strenth of the vortex.
  67767. */
  67768. strength: number;
  67769. /**
  67770. * The height of the cylinder for the vortex.
  67771. */
  67772. height: number;
  67773. /**
  67774. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67775. */
  67776. centripetalForceThreshold: number;
  67777. /**
  67778. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67779. */
  67780. centripetalForceMultiplier: number;
  67781. /**
  67782. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67783. */
  67784. centrifugalForceMultiplier: number;
  67785. /**
  67786. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67787. */
  67788. updraftForceMultiplier: number;
  67789. }
  67790. /**
  67791. * The strenght of the force in correspondence to the distance of the affected object
  67792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67793. */
  67794. export enum PhysicsRadialImpulseFalloff {
  67795. /** Defines that impulse is constant in strength across it's whole radius */
  67796. Constant = 0,
  67797. /** Defines that impulse gets weaker if it's further from the origin */
  67798. Linear = 1
  67799. }
  67800. /**
  67801. * The strength of the force in correspondence to the distance of the affected object
  67802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67803. */
  67804. export enum PhysicsUpdraftMode {
  67805. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67806. Center = 0,
  67807. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67808. Perpendicular = 1
  67809. }
  67810. /**
  67811. * Interface for a physics hit data
  67812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67813. */
  67814. export interface PhysicsHitData {
  67815. /**
  67816. * The force applied at the contact point
  67817. */
  67818. force: Vector3;
  67819. /**
  67820. * The contact point
  67821. */
  67822. contactPoint: Vector3;
  67823. /**
  67824. * The distance from the origin to the contact point
  67825. */
  67826. distanceFromOrigin: number;
  67827. }
  67828. /**
  67829. * Interface for radial explosion event data
  67830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67831. */
  67832. export interface PhysicsRadialExplosionEventData {
  67833. /**
  67834. * A sphere used for the radial explosion event
  67835. */
  67836. sphere: Mesh;
  67837. }
  67838. /**
  67839. * Interface for gravitational field event data
  67840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67841. */
  67842. export interface PhysicsGravitationalFieldEventData {
  67843. /**
  67844. * A sphere mesh used for the gravitational field event
  67845. */
  67846. sphere: Mesh;
  67847. }
  67848. /**
  67849. * Interface for updraft event data
  67850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67851. */
  67852. export interface PhysicsUpdraftEventData {
  67853. /**
  67854. * A cylinder used for the updraft event
  67855. */
  67856. cylinder: Mesh;
  67857. }
  67858. /**
  67859. * Interface for vortex event data
  67860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67861. */
  67862. export interface PhysicsVortexEventData {
  67863. /**
  67864. * A cylinder used for the vortex event
  67865. */
  67866. cylinder: Mesh;
  67867. }
  67868. /**
  67869. * Interface for an affected physics impostor
  67870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67871. */
  67872. export interface PhysicsAffectedImpostorWithData {
  67873. /**
  67874. * The impostor affected by the effect
  67875. */
  67876. impostor: PhysicsImpostor;
  67877. /**
  67878. * The data about the hit/horce from the explosion
  67879. */
  67880. hitData: PhysicsHitData;
  67881. }
  67882. }
  67883. declare module BABYLON {
  67884. /** @hidden */
  67885. export var blackAndWhitePixelShader: {
  67886. name: string;
  67887. shader: string;
  67888. };
  67889. }
  67890. declare module BABYLON {
  67891. /**
  67892. * Post process used to render in black and white
  67893. */
  67894. export class BlackAndWhitePostProcess extends PostProcess {
  67895. /**
  67896. * Linear about to convert he result to black and white (default: 1)
  67897. */
  67898. degree: number;
  67899. /**
  67900. * Creates a black and white post process
  67901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67902. * @param name The name of the effect.
  67903. * @param options The required width/height ratio to downsize to before computing the render pass.
  67904. * @param camera The camera to apply the render pass to.
  67905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67906. * @param engine The engine which the post process will be applied. (default: current engine)
  67907. * @param reusable If the post process can be reused on the same frame. (default: false)
  67908. */
  67909. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67910. }
  67911. }
  67912. declare module BABYLON {
  67913. /**
  67914. * This represents a set of one or more post processes in Babylon.
  67915. * A post process can be used to apply a shader to a texture after it is rendered.
  67916. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67917. */
  67918. export class PostProcessRenderEffect {
  67919. private _postProcesses;
  67920. private _getPostProcesses;
  67921. private _singleInstance;
  67922. private _cameras;
  67923. private _indicesForCamera;
  67924. /**
  67925. * Name of the effect
  67926. * @hidden
  67927. */
  67928. _name: string;
  67929. /**
  67930. * Instantiates a post process render effect.
  67931. * A post process can be used to apply a shader to a texture after it is rendered.
  67932. * @param engine The engine the effect is tied to
  67933. * @param name The name of the effect
  67934. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67935. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67936. */
  67937. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67938. /**
  67939. * Checks if all the post processes in the effect are supported.
  67940. */
  67941. get isSupported(): boolean;
  67942. /**
  67943. * Updates the current state of the effect
  67944. * @hidden
  67945. */
  67946. _update(): void;
  67947. /**
  67948. * Attaches the effect on cameras
  67949. * @param cameras The camera to attach to.
  67950. * @hidden
  67951. */
  67952. _attachCameras(cameras: Camera): void;
  67953. /**
  67954. * Attaches the effect on cameras
  67955. * @param cameras The camera to attach to.
  67956. * @hidden
  67957. */
  67958. _attachCameras(cameras: Camera[]): void;
  67959. /**
  67960. * Detaches the effect on cameras
  67961. * @param cameras The camera to detatch from.
  67962. * @hidden
  67963. */
  67964. _detachCameras(cameras: Camera): void;
  67965. /**
  67966. * Detatches the effect on cameras
  67967. * @param cameras The camera to detatch from.
  67968. * @hidden
  67969. */
  67970. _detachCameras(cameras: Camera[]): void;
  67971. /**
  67972. * Enables the effect on given cameras
  67973. * @param cameras The camera to enable.
  67974. * @hidden
  67975. */
  67976. _enable(cameras: Camera): void;
  67977. /**
  67978. * Enables the effect on given cameras
  67979. * @param cameras The camera to enable.
  67980. * @hidden
  67981. */
  67982. _enable(cameras: Nullable<Camera[]>): void;
  67983. /**
  67984. * Disables the effect on the given cameras
  67985. * @param cameras The camera to disable.
  67986. * @hidden
  67987. */
  67988. _disable(cameras: Camera): void;
  67989. /**
  67990. * Disables the effect on the given cameras
  67991. * @param cameras The camera to disable.
  67992. * @hidden
  67993. */
  67994. _disable(cameras: Nullable<Camera[]>): void;
  67995. /**
  67996. * Gets a list of the post processes contained in the effect.
  67997. * @param camera The camera to get the post processes on.
  67998. * @returns The list of the post processes in the effect.
  67999. */
  68000. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68001. }
  68002. }
  68003. declare module BABYLON {
  68004. /** @hidden */
  68005. export var extractHighlightsPixelShader: {
  68006. name: string;
  68007. shader: string;
  68008. };
  68009. }
  68010. declare module BABYLON {
  68011. /**
  68012. * 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.
  68013. */
  68014. export class ExtractHighlightsPostProcess extends PostProcess {
  68015. /**
  68016. * The luminance threshold, pixels below this value will be set to black.
  68017. */
  68018. threshold: number;
  68019. /** @hidden */
  68020. _exposure: number;
  68021. /**
  68022. * Post process which has the input texture to be used when performing highlight extraction
  68023. * @hidden
  68024. */
  68025. _inputPostProcess: Nullable<PostProcess>;
  68026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68027. }
  68028. }
  68029. declare module BABYLON {
  68030. /** @hidden */
  68031. export var bloomMergePixelShader: {
  68032. name: string;
  68033. shader: string;
  68034. };
  68035. }
  68036. declare module BABYLON {
  68037. /**
  68038. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68039. */
  68040. export class BloomMergePostProcess extends PostProcess {
  68041. /** Weight of the bloom to be added to the original input. */
  68042. weight: number;
  68043. /**
  68044. * Creates a new instance of @see BloomMergePostProcess
  68045. * @param name The name of the effect.
  68046. * @param originalFromInput Post process which's input will be used for the merge.
  68047. * @param blurred Blurred highlights post process which's output will be used.
  68048. * @param weight Weight of the bloom to be added to the original input.
  68049. * @param options The required width/height ratio to downsize to before computing the render pass.
  68050. * @param camera The camera to apply the render pass to.
  68051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68052. * @param engine The engine which the post process will be applied. (default: current engine)
  68053. * @param reusable If the post process can be reused on the same frame. (default: false)
  68054. * @param textureType Type of textures used when performing the post process. (default: 0)
  68055. * @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)
  68056. */
  68057. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68058. /** Weight of the bloom to be added to the original input. */
  68059. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68060. }
  68061. }
  68062. declare module BABYLON {
  68063. /**
  68064. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68065. */
  68066. export class BloomEffect extends PostProcessRenderEffect {
  68067. private bloomScale;
  68068. /**
  68069. * @hidden Internal
  68070. */
  68071. _effects: Array<PostProcess>;
  68072. /**
  68073. * @hidden Internal
  68074. */
  68075. _downscale: ExtractHighlightsPostProcess;
  68076. private _blurX;
  68077. private _blurY;
  68078. private _merge;
  68079. /**
  68080. * The luminance threshold to find bright areas of the image to bloom.
  68081. */
  68082. get threshold(): number;
  68083. set threshold(value: number);
  68084. /**
  68085. * The strength of the bloom.
  68086. */
  68087. get weight(): number;
  68088. set weight(value: number);
  68089. /**
  68090. * Specifies the size of the bloom blur kernel, relative to the final output size
  68091. */
  68092. get kernel(): number;
  68093. set kernel(value: number);
  68094. /**
  68095. * Creates a new instance of @see BloomEffect
  68096. * @param scene The scene the effect belongs to.
  68097. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68098. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68099. * @param bloomWeight The the strength of bloom.
  68100. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68101. * @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)
  68102. */
  68103. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68104. /**
  68105. * Disposes each of the internal effects for a given camera.
  68106. * @param camera The camera to dispose the effect on.
  68107. */
  68108. disposeEffects(camera: Camera): void;
  68109. /**
  68110. * @hidden Internal
  68111. */
  68112. _updateEffects(): void;
  68113. /**
  68114. * Internal
  68115. * @returns if all the contained post processes are ready.
  68116. * @hidden
  68117. */
  68118. _isReady(): boolean;
  68119. }
  68120. }
  68121. declare module BABYLON {
  68122. /** @hidden */
  68123. export var chromaticAberrationPixelShader: {
  68124. name: string;
  68125. shader: string;
  68126. };
  68127. }
  68128. declare module BABYLON {
  68129. /**
  68130. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68131. */
  68132. export class ChromaticAberrationPostProcess extends PostProcess {
  68133. /**
  68134. * The amount of seperation of rgb channels (default: 30)
  68135. */
  68136. aberrationAmount: number;
  68137. /**
  68138. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68139. */
  68140. radialIntensity: number;
  68141. /**
  68142. * 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))
  68143. */
  68144. direction: Vector2;
  68145. /**
  68146. * 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))
  68147. */
  68148. centerPosition: Vector2;
  68149. /**
  68150. * Creates a new instance ChromaticAberrationPostProcess
  68151. * @param name The name of the effect.
  68152. * @param screenWidth The width of the screen to apply the effect on.
  68153. * @param screenHeight The height of the screen to apply the effect on.
  68154. * @param options The required width/height ratio to downsize to before computing the render pass.
  68155. * @param camera The camera to apply the render pass to.
  68156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68157. * @param engine The engine which the post process will be applied. (default: current engine)
  68158. * @param reusable If the post process can be reused on the same frame. (default: false)
  68159. * @param textureType Type of textures used when performing the post process. (default: 0)
  68160. * @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)
  68161. */
  68162. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68163. }
  68164. }
  68165. declare module BABYLON {
  68166. /** @hidden */
  68167. export var circleOfConfusionPixelShader: {
  68168. name: string;
  68169. shader: string;
  68170. };
  68171. }
  68172. declare module BABYLON {
  68173. /**
  68174. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68175. */
  68176. export class CircleOfConfusionPostProcess extends PostProcess {
  68177. /**
  68178. * 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.
  68179. */
  68180. lensSize: number;
  68181. /**
  68182. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68183. */
  68184. fStop: number;
  68185. /**
  68186. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68187. */
  68188. focusDistance: number;
  68189. /**
  68190. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68191. */
  68192. focalLength: number;
  68193. private _depthTexture;
  68194. /**
  68195. * Creates a new instance CircleOfConfusionPostProcess
  68196. * @param name The name of the effect.
  68197. * @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.
  68198. * @param options The required width/height ratio to downsize to before computing the render pass.
  68199. * @param camera The camera to apply the render pass to.
  68200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68201. * @param engine The engine which the post process will be applied. (default: current engine)
  68202. * @param reusable If the post process can be reused on the same frame. (default: false)
  68203. * @param textureType Type of textures used when performing the post process. (default: 0)
  68204. * @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)
  68205. */
  68206. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68207. /**
  68208. * 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.
  68209. */
  68210. set depthTexture(value: RenderTargetTexture);
  68211. }
  68212. }
  68213. declare module BABYLON {
  68214. /** @hidden */
  68215. export var colorCorrectionPixelShader: {
  68216. name: string;
  68217. shader: string;
  68218. };
  68219. }
  68220. declare module BABYLON {
  68221. /**
  68222. *
  68223. * This post-process allows the modification of rendered colors by using
  68224. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68225. *
  68226. * The object needs to be provided an url to a texture containing the color
  68227. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68228. * Use an image editing software to tweak the LUT to match your needs.
  68229. *
  68230. * For an example of a color LUT, see here:
  68231. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68232. * For explanations on color grading, see here:
  68233. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68234. *
  68235. */
  68236. export class ColorCorrectionPostProcess extends PostProcess {
  68237. private _colorTableTexture;
  68238. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68239. }
  68240. }
  68241. declare module BABYLON {
  68242. /** @hidden */
  68243. export var convolutionPixelShader: {
  68244. name: string;
  68245. shader: string;
  68246. };
  68247. }
  68248. declare module BABYLON {
  68249. /**
  68250. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68251. * input texture to perform effects such as edge detection or sharpening
  68252. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68253. */
  68254. export class ConvolutionPostProcess extends PostProcess {
  68255. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68256. kernel: number[];
  68257. /**
  68258. * Creates a new instance ConvolutionPostProcess
  68259. * @param name The name of the effect.
  68260. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68261. * @param options The required width/height ratio to downsize to before computing the render pass.
  68262. * @param camera The camera to apply the render pass to.
  68263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68264. * @param engine The engine which the post process will be applied. (default: current engine)
  68265. * @param reusable If the post process can be reused on the same frame. (default: false)
  68266. * @param textureType Type of textures used when performing the post process. (default: 0)
  68267. */
  68268. constructor(name: string,
  68269. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68270. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68271. /**
  68272. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68273. */
  68274. static EdgeDetect0Kernel: number[];
  68275. /**
  68276. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68277. */
  68278. static EdgeDetect1Kernel: number[];
  68279. /**
  68280. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68281. */
  68282. static EdgeDetect2Kernel: number[];
  68283. /**
  68284. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68285. */
  68286. static SharpenKernel: number[];
  68287. /**
  68288. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68289. */
  68290. static EmbossKernel: number[];
  68291. /**
  68292. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68293. */
  68294. static GaussianKernel: number[];
  68295. }
  68296. }
  68297. declare module BABYLON {
  68298. /**
  68299. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68300. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68301. * based on samples that have a large difference in distance than the center pixel.
  68302. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68303. */
  68304. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68305. direction: Vector2;
  68306. /**
  68307. * Creates a new instance CircleOfConfusionPostProcess
  68308. * @param name The name of the effect.
  68309. * @param scene The scene the effect belongs to.
  68310. * @param direction The direction the blur should be applied.
  68311. * @param kernel The size of the kernel used to blur.
  68312. * @param options The required width/height ratio to downsize to before computing the render pass.
  68313. * @param camera The camera to apply the render pass to.
  68314. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68315. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68317. * @param engine The engine which the post process will be applied. (default: current engine)
  68318. * @param reusable If the post process can be reused on the same frame. (default: false)
  68319. * @param textureType Type of textures used when performing the post process. (default: 0)
  68320. * @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)
  68321. */
  68322. 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);
  68323. }
  68324. }
  68325. declare module BABYLON {
  68326. /** @hidden */
  68327. export var depthOfFieldMergePixelShader: {
  68328. name: string;
  68329. shader: string;
  68330. };
  68331. }
  68332. declare module BABYLON {
  68333. /**
  68334. * Options to be set when merging outputs from the default pipeline.
  68335. */
  68336. export class DepthOfFieldMergePostProcessOptions {
  68337. /**
  68338. * The original image to merge on top of
  68339. */
  68340. originalFromInput: PostProcess;
  68341. /**
  68342. * Parameters to perform the merge of the depth of field effect
  68343. */
  68344. depthOfField?: {
  68345. circleOfConfusion: PostProcess;
  68346. blurSteps: Array<PostProcess>;
  68347. };
  68348. /**
  68349. * Parameters to perform the merge of bloom effect
  68350. */
  68351. bloom?: {
  68352. blurred: PostProcess;
  68353. weight: number;
  68354. };
  68355. }
  68356. /**
  68357. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68358. */
  68359. export class DepthOfFieldMergePostProcess extends PostProcess {
  68360. private blurSteps;
  68361. /**
  68362. * Creates a new instance of DepthOfFieldMergePostProcess
  68363. * @param name The name of the effect.
  68364. * @param originalFromInput Post process which's input will be used for the merge.
  68365. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68366. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68367. * @param options The required width/height ratio to downsize to before computing the render pass.
  68368. * @param camera The camera to apply the render pass to.
  68369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68370. * @param engine The engine which the post process will be applied. (default: current engine)
  68371. * @param reusable If the post process can be reused on the same frame. (default: false)
  68372. * @param textureType Type of textures used when performing the post process. (default: 0)
  68373. * @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)
  68374. */
  68375. 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);
  68376. /**
  68377. * Updates the effect with the current post process compile time values and recompiles the shader.
  68378. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68379. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68380. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68381. * @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
  68382. * @param onCompiled Called when the shader has been compiled.
  68383. * @param onError Called if there is an error when compiling a shader.
  68384. */
  68385. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /**
  68390. * Specifies the level of max blur that should be applied when using the depth of field effect
  68391. */
  68392. export enum DepthOfFieldEffectBlurLevel {
  68393. /**
  68394. * Subtle blur
  68395. */
  68396. Low = 0,
  68397. /**
  68398. * Medium blur
  68399. */
  68400. Medium = 1,
  68401. /**
  68402. * Large blur
  68403. */
  68404. High = 2
  68405. }
  68406. /**
  68407. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68408. */
  68409. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68410. private _circleOfConfusion;
  68411. /**
  68412. * @hidden Internal, blurs from high to low
  68413. */
  68414. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68415. private _depthOfFieldBlurY;
  68416. private _dofMerge;
  68417. /**
  68418. * @hidden Internal post processes in depth of field effect
  68419. */
  68420. _effects: Array<PostProcess>;
  68421. /**
  68422. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68423. */
  68424. set focalLength(value: number);
  68425. get focalLength(): number;
  68426. /**
  68427. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68428. */
  68429. set fStop(value: number);
  68430. get fStop(): number;
  68431. /**
  68432. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68433. */
  68434. set focusDistance(value: number);
  68435. get focusDistance(): number;
  68436. /**
  68437. * 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.
  68438. */
  68439. set lensSize(value: number);
  68440. get lensSize(): number;
  68441. /**
  68442. * Creates a new instance DepthOfFieldEffect
  68443. * @param scene The scene the effect belongs to.
  68444. * @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.
  68445. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68446. * @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)
  68447. */
  68448. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68449. /**
  68450. * Get the current class name of the current effet
  68451. * @returns "DepthOfFieldEffect"
  68452. */
  68453. getClassName(): string;
  68454. /**
  68455. * 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.
  68456. */
  68457. set depthTexture(value: RenderTargetTexture);
  68458. /**
  68459. * Disposes each of the internal effects for a given camera.
  68460. * @param camera The camera to dispose the effect on.
  68461. */
  68462. disposeEffects(camera: Camera): void;
  68463. /**
  68464. * @hidden Internal
  68465. */
  68466. _updateEffects(): void;
  68467. /**
  68468. * Internal
  68469. * @returns if all the contained post processes are ready.
  68470. * @hidden
  68471. */
  68472. _isReady(): boolean;
  68473. }
  68474. }
  68475. declare module BABYLON {
  68476. /** @hidden */
  68477. export var displayPassPixelShader: {
  68478. name: string;
  68479. shader: string;
  68480. };
  68481. }
  68482. declare module BABYLON {
  68483. /**
  68484. * DisplayPassPostProcess which produces an output the same as it's input
  68485. */
  68486. export class DisplayPassPostProcess extends PostProcess {
  68487. /**
  68488. * Creates the DisplayPassPostProcess
  68489. * @param name The name of the effect.
  68490. * @param options The required width/height ratio to downsize to before computing the render pass.
  68491. * @param camera The camera to apply the render pass to.
  68492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68493. * @param engine The engine which the post process will be applied. (default: current engine)
  68494. * @param reusable If the post process can be reused on the same frame. (default: false)
  68495. */
  68496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68497. }
  68498. }
  68499. declare module BABYLON {
  68500. /** @hidden */
  68501. export var filterPixelShader: {
  68502. name: string;
  68503. shader: string;
  68504. };
  68505. }
  68506. declare module BABYLON {
  68507. /**
  68508. * Applies a kernel filter to the image
  68509. */
  68510. export class FilterPostProcess extends PostProcess {
  68511. /** The matrix to be applied to the image */
  68512. kernelMatrix: Matrix;
  68513. /**
  68514. *
  68515. * @param name The name of the effect.
  68516. * @param kernelMatrix The matrix to be applied to the image
  68517. * @param options The required width/height ratio to downsize to before computing the render pass.
  68518. * @param camera The camera to apply the render pass to.
  68519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68520. * @param engine The engine which the post process will be applied. (default: current engine)
  68521. * @param reusable If the post process can be reused on the same frame. (default: false)
  68522. */
  68523. constructor(name: string,
  68524. /** The matrix to be applied to the image */
  68525. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68526. }
  68527. }
  68528. declare module BABYLON {
  68529. /** @hidden */
  68530. export var fxaaPixelShader: {
  68531. name: string;
  68532. shader: string;
  68533. };
  68534. }
  68535. declare module BABYLON {
  68536. /** @hidden */
  68537. export var fxaaVertexShader: {
  68538. name: string;
  68539. shader: string;
  68540. };
  68541. }
  68542. declare module BABYLON {
  68543. /**
  68544. * Fxaa post process
  68545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68546. */
  68547. export class FxaaPostProcess extends PostProcess {
  68548. /** @hidden */
  68549. texelWidth: number;
  68550. /** @hidden */
  68551. texelHeight: number;
  68552. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68553. private _getDefines;
  68554. }
  68555. }
  68556. declare module BABYLON {
  68557. /** @hidden */
  68558. export var grainPixelShader: {
  68559. name: string;
  68560. shader: string;
  68561. };
  68562. }
  68563. declare module BABYLON {
  68564. /**
  68565. * The GrainPostProcess adds noise to the image at mid luminance levels
  68566. */
  68567. export class GrainPostProcess extends PostProcess {
  68568. /**
  68569. * The intensity of the grain added (default: 30)
  68570. */
  68571. intensity: number;
  68572. /**
  68573. * If the grain should be randomized on every frame
  68574. */
  68575. animated: boolean;
  68576. /**
  68577. * Creates a new instance of @see GrainPostProcess
  68578. * @param name The name of the effect.
  68579. * @param options The required width/height ratio to downsize to before computing the render pass.
  68580. * @param camera The camera to apply the render pass to.
  68581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68582. * @param engine The engine which the post process will be applied. (default: current engine)
  68583. * @param reusable If the post process can be reused on the same frame. (default: false)
  68584. * @param textureType Type of textures used when performing the post process. (default: 0)
  68585. * @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)
  68586. */
  68587. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68588. }
  68589. }
  68590. declare module BABYLON {
  68591. /** @hidden */
  68592. export var highlightsPixelShader: {
  68593. name: string;
  68594. shader: string;
  68595. };
  68596. }
  68597. declare module BABYLON {
  68598. /**
  68599. * Extracts highlights from the image
  68600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68601. */
  68602. export class HighlightsPostProcess extends PostProcess {
  68603. /**
  68604. * Extracts highlights from the image
  68605. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68606. * @param name The name of the effect.
  68607. * @param options The required width/height ratio to downsize to before computing the render pass.
  68608. * @param camera The camera to apply the render pass to.
  68609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68610. * @param engine The engine which the post process will be applied. (default: current engine)
  68611. * @param reusable If the post process can be reused on the same frame. (default: false)
  68612. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68613. */
  68614. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68615. }
  68616. }
  68617. declare module BABYLON {
  68618. /** @hidden */
  68619. export var mrtFragmentDeclaration: {
  68620. name: string;
  68621. shader: string;
  68622. };
  68623. }
  68624. declare module BABYLON {
  68625. /** @hidden */
  68626. export var geometryPixelShader: {
  68627. name: string;
  68628. shader: string;
  68629. };
  68630. }
  68631. declare module BABYLON {
  68632. /** @hidden */
  68633. export var geometryVertexShader: {
  68634. name: string;
  68635. shader: string;
  68636. };
  68637. }
  68638. declare module BABYLON {
  68639. /** @hidden */
  68640. interface ISavedTransformationMatrix {
  68641. world: Matrix;
  68642. viewProjection: Matrix;
  68643. }
  68644. /**
  68645. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68646. */
  68647. export class GeometryBufferRenderer {
  68648. /**
  68649. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68650. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68651. */
  68652. static readonly POSITION_TEXTURE_TYPE: number;
  68653. /**
  68654. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68655. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68656. */
  68657. static readonly VELOCITY_TEXTURE_TYPE: number;
  68658. /**
  68659. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68660. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68661. */
  68662. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68663. /**
  68664. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68665. * in order to compute objects velocities when enableVelocity is set to "true"
  68666. * @hidden
  68667. */
  68668. _previousTransformationMatrices: {
  68669. [index: number]: ISavedTransformationMatrix;
  68670. };
  68671. /**
  68672. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68673. * in order to compute objects velocities when enableVelocity is set to "true"
  68674. * @hidden
  68675. */
  68676. _previousBonesTransformationMatrices: {
  68677. [index: number]: Float32Array;
  68678. };
  68679. /**
  68680. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68681. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68682. */
  68683. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68684. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68685. renderTransparentMeshes: boolean;
  68686. private _scene;
  68687. private _multiRenderTarget;
  68688. private _ratio;
  68689. private _enablePosition;
  68690. private _enableVelocity;
  68691. private _enableReflectivity;
  68692. private _positionIndex;
  68693. private _velocityIndex;
  68694. private _reflectivityIndex;
  68695. protected _effect: Effect;
  68696. protected _cachedDefines: string;
  68697. /**
  68698. * Set the render list (meshes to be rendered) used in the G buffer.
  68699. */
  68700. set renderList(meshes: Mesh[]);
  68701. /**
  68702. * Gets wether or not G buffer are supported by the running hardware.
  68703. * This requires draw buffer supports
  68704. */
  68705. get isSupported(): boolean;
  68706. /**
  68707. * Returns the index of the given texture type in the G-Buffer textures array
  68708. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68709. * @returns the index of the given texture type in the G-Buffer textures array
  68710. */
  68711. getTextureIndex(textureType: number): number;
  68712. /**
  68713. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68714. */
  68715. get enablePosition(): boolean;
  68716. /**
  68717. * Sets whether or not objects positions are enabled for the G buffer.
  68718. */
  68719. set enablePosition(enable: boolean);
  68720. /**
  68721. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68722. */
  68723. get enableVelocity(): boolean;
  68724. /**
  68725. * Sets wether or not objects velocities are enabled for the G buffer.
  68726. */
  68727. set enableVelocity(enable: boolean);
  68728. /**
  68729. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68730. */
  68731. get enableReflectivity(): boolean;
  68732. /**
  68733. * Sets wether or not objects roughness are enabled for the G buffer.
  68734. */
  68735. set enableReflectivity(enable: boolean);
  68736. /**
  68737. * Gets the scene associated with the buffer.
  68738. */
  68739. get scene(): Scene;
  68740. /**
  68741. * Gets the ratio used by the buffer during its creation.
  68742. * How big is the buffer related to the main canvas.
  68743. */
  68744. get ratio(): number;
  68745. /** @hidden */
  68746. static _SceneComponentInitialization: (scene: Scene) => void;
  68747. /**
  68748. * Creates a new G Buffer for the scene
  68749. * @param scene The scene the buffer belongs to
  68750. * @param ratio How big is the buffer related to the main canvas.
  68751. */
  68752. constructor(scene: Scene, ratio?: number);
  68753. /**
  68754. * Checks wether everything is ready to render a submesh to the G buffer.
  68755. * @param subMesh the submesh to check readiness for
  68756. * @param useInstances is the mesh drawn using instance or not
  68757. * @returns true if ready otherwise false
  68758. */
  68759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68760. /**
  68761. * Gets the current underlying G Buffer.
  68762. * @returns the buffer
  68763. */
  68764. getGBuffer(): MultiRenderTarget;
  68765. /**
  68766. * Gets the number of samples used to render the buffer (anti aliasing).
  68767. */
  68768. get samples(): number;
  68769. /**
  68770. * Sets the number of samples used to render the buffer (anti aliasing).
  68771. */
  68772. set samples(value: number);
  68773. /**
  68774. * Disposes the renderer and frees up associated resources.
  68775. */
  68776. dispose(): void;
  68777. protected _createRenderTargets(): void;
  68778. private _copyBonesTransformationMatrices;
  68779. }
  68780. }
  68781. declare module BABYLON {
  68782. interface Scene {
  68783. /** @hidden (Backing field) */
  68784. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68785. /**
  68786. * Gets or Sets the current geometry buffer associated to the scene.
  68787. */
  68788. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68789. /**
  68790. * Enables a GeometryBufferRender and associates it with the scene
  68791. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68792. * @returns the GeometryBufferRenderer
  68793. */
  68794. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68795. /**
  68796. * Disables the GeometryBufferRender associated with the scene
  68797. */
  68798. disableGeometryBufferRenderer(): void;
  68799. }
  68800. /**
  68801. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68802. * in several rendering techniques.
  68803. */
  68804. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68805. /**
  68806. * The component name helpful to identify the component in the list of scene components.
  68807. */
  68808. readonly name: string;
  68809. /**
  68810. * The scene the component belongs to.
  68811. */
  68812. scene: Scene;
  68813. /**
  68814. * Creates a new instance of the component for the given scene
  68815. * @param scene Defines the scene to register the component in
  68816. */
  68817. constructor(scene: Scene);
  68818. /**
  68819. * Registers the component in a given scene
  68820. */
  68821. register(): void;
  68822. /**
  68823. * Rebuilds the elements related to this component in case of
  68824. * context lost for instance.
  68825. */
  68826. rebuild(): void;
  68827. /**
  68828. * Disposes the component and the associated ressources
  68829. */
  68830. dispose(): void;
  68831. private _gatherRenderTargets;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /** @hidden */
  68836. export var motionBlurPixelShader: {
  68837. name: string;
  68838. shader: string;
  68839. };
  68840. }
  68841. declare module BABYLON {
  68842. /**
  68843. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68844. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68845. * As an example, all you have to do is to create the post-process:
  68846. * var mb = new BABYLON.MotionBlurPostProcess(
  68847. * 'mb', // The name of the effect.
  68848. * scene, // The scene containing the objects to blur according to their velocity.
  68849. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68850. * camera // The camera to apply the render pass to.
  68851. * );
  68852. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68853. */
  68854. export class MotionBlurPostProcess extends PostProcess {
  68855. /**
  68856. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68857. */
  68858. motionStrength: number;
  68859. /**
  68860. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68861. */
  68862. get motionBlurSamples(): number;
  68863. /**
  68864. * Sets the number of iterations to be used for motion blur quality
  68865. */
  68866. set motionBlurSamples(samples: number);
  68867. private _motionBlurSamples;
  68868. private _geometryBufferRenderer;
  68869. /**
  68870. * Creates a new instance MotionBlurPostProcess
  68871. * @param name The name of the effect.
  68872. * @param scene The scene containing the objects to blur according to their velocity.
  68873. * @param options The required width/height ratio to downsize to before computing the render pass.
  68874. * @param camera The camera to apply the render pass to.
  68875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68876. * @param engine The engine which the post process will be applied. (default: current engine)
  68877. * @param reusable If the post process can be reused on the same frame. (default: false)
  68878. * @param textureType Type of textures used when performing the post process. (default: 0)
  68879. * @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)
  68880. */
  68881. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68882. /**
  68883. * Excludes the given skinned mesh from computing bones velocities.
  68884. * 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.
  68885. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68886. */
  68887. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68888. /**
  68889. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68890. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68891. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68892. */
  68893. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68894. /**
  68895. * Disposes the post process.
  68896. * @param camera The camera to dispose the post process on.
  68897. */
  68898. dispose(camera?: Camera): void;
  68899. }
  68900. }
  68901. declare module BABYLON {
  68902. /** @hidden */
  68903. export var refractionPixelShader: {
  68904. name: string;
  68905. shader: string;
  68906. };
  68907. }
  68908. declare module BABYLON {
  68909. /**
  68910. * Post process which applies a refractin texture
  68911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68912. */
  68913. export class RefractionPostProcess extends PostProcess {
  68914. /** the base color of the refraction (used to taint the rendering) */
  68915. color: Color3;
  68916. /** simulated refraction depth */
  68917. depth: number;
  68918. /** the coefficient of the base color (0 to remove base color tainting) */
  68919. colorLevel: number;
  68920. private _refTexture;
  68921. private _ownRefractionTexture;
  68922. /**
  68923. * Gets or sets the refraction texture
  68924. * Please note that you are responsible for disposing the texture if you set it manually
  68925. */
  68926. get refractionTexture(): Texture;
  68927. set refractionTexture(value: Texture);
  68928. /**
  68929. * Initializes the RefractionPostProcess
  68930. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68931. * @param name The name of the effect.
  68932. * @param refractionTextureUrl Url of the refraction texture to use
  68933. * @param color the base color of the refraction (used to taint the rendering)
  68934. * @param depth simulated refraction depth
  68935. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68936. * @param camera The camera to apply the render pass to.
  68937. * @param options The required width/height ratio to downsize to before computing the render pass.
  68938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68939. * @param engine The engine which the post process will be applied. (default: current engine)
  68940. * @param reusable If the post process can be reused on the same frame. (default: false)
  68941. */
  68942. constructor(name: string, refractionTextureUrl: string,
  68943. /** the base color of the refraction (used to taint the rendering) */
  68944. color: Color3,
  68945. /** simulated refraction depth */
  68946. depth: number,
  68947. /** the coefficient of the base color (0 to remove base color tainting) */
  68948. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68949. /**
  68950. * Disposes of the post process
  68951. * @param camera Camera to dispose post process on
  68952. */
  68953. dispose(camera: Camera): void;
  68954. }
  68955. }
  68956. declare module BABYLON {
  68957. /** @hidden */
  68958. export var sharpenPixelShader: {
  68959. name: string;
  68960. shader: string;
  68961. };
  68962. }
  68963. declare module BABYLON {
  68964. /**
  68965. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68966. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68967. */
  68968. export class SharpenPostProcess extends PostProcess {
  68969. /**
  68970. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68971. */
  68972. colorAmount: number;
  68973. /**
  68974. * How much sharpness should be applied (default: 0.3)
  68975. */
  68976. edgeAmount: number;
  68977. /**
  68978. * Creates a new instance ConvolutionPostProcess
  68979. * @param name The name of the effect.
  68980. * @param options The required width/height ratio to downsize to before computing the render pass.
  68981. * @param camera The camera to apply the render pass to.
  68982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68983. * @param engine The engine which the post process will be applied. (default: current engine)
  68984. * @param reusable If the post process can be reused on the same frame. (default: false)
  68985. * @param textureType Type of textures used when performing the post process. (default: 0)
  68986. * @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)
  68987. */
  68988. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68989. }
  68990. }
  68991. declare module BABYLON {
  68992. /**
  68993. * PostProcessRenderPipeline
  68994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68995. */
  68996. export class PostProcessRenderPipeline {
  68997. private engine;
  68998. private _renderEffects;
  68999. private _renderEffectsForIsolatedPass;
  69000. /**
  69001. * List of inspectable custom properties (used by the Inspector)
  69002. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69003. */
  69004. inspectableCustomProperties: IInspectable[];
  69005. /**
  69006. * @hidden
  69007. */
  69008. protected _cameras: Camera[];
  69009. /** @hidden */
  69010. _name: string;
  69011. /**
  69012. * Gets pipeline name
  69013. */
  69014. get name(): string;
  69015. /** Gets the list of attached cameras */
  69016. get cameras(): Camera[];
  69017. /**
  69018. * Initializes a PostProcessRenderPipeline
  69019. * @param engine engine to add the pipeline to
  69020. * @param name name of the pipeline
  69021. */
  69022. constructor(engine: Engine, name: string);
  69023. /**
  69024. * Gets the class name
  69025. * @returns "PostProcessRenderPipeline"
  69026. */
  69027. getClassName(): string;
  69028. /**
  69029. * If all the render effects in the pipeline are supported
  69030. */
  69031. get isSupported(): boolean;
  69032. /**
  69033. * Adds an effect to the pipeline
  69034. * @param renderEffect the effect to add
  69035. */
  69036. addEffect(renderEffect: PostProcessRenderEffect): void;
  69037. /** @hidden */
  69038. _rebuild(): void;
  69039. /** @hidden */
  69040. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69041. /** @hidden */
  69042. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69043. /** @hidden */
  69044. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69045. /** @hidden */
  69046. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69047. /** @hidden */
  69048. _attachCameras(cameras: Camera, unique: boolean): void;
  69049. /** @hidden */
  69050. _attachCameras(cameras: Camera[], unique: boolean): void;
  69051. /** @hidden */
  69052. _detachCameras(cameras: Camera): void;
  69053. /** @hidden */
  69054. _detachCameras(cameras: Nullable<Camera[]>): void;
  69055. /** @hidden */
  69056. _update(): void;
  69057. /** @hidden */
  69058. _reset(): void;
  69059. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69060. /**
  69061. * Disposes of the pipeline
  69062. */
  69063. dispose(): void;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /**
  69068. * PostProcessRenderPipelineManager class
  69069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69070. */
  69071. export class PostProcessRenderPipelineManager {
  69072. private _renderPipelines;
  69073. /**
  69074. * Initializes a PostProcessRenderPipelineManager
  69075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69076. */
  69077. constructor();
  69078. /**
  69079. * Gets the list of supported render pipelines
  69080. */
  69081. get supportedPipelines(): PostProcessRenderPipeline[];
  69082. /**
  69083. * Adds a pipeline to the manager
  69084. * @param renderPipeline The pipeline to add
  69085. */
  69086. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69087. /**
  69088. * Attaches a camera to the pipeline
  69089. * @param renderPipelineName The name of the pipeline to attach to
  69090. * @param cameras the camera to attach
  69091. * @param unique if the camera can be attached multiple times to the pipeline
  69092. */
  69093. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69094. /**
  69095. * Detaches a camera from the pipeline
  69096. * @param renderPipelineName The name of the pipeline to detach from
  69097. * @param cameras the camera to detach
  69098. */
  69099. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69100. /**
  69101. * Enables an effect by name on a pipeline
  69102. * @param renderPipelineName the name of the pipeline to enable the effect in
  69103. * @param renderEffectName the name of the effect to enable
  69104. * @param cameras the cameras that the effect should be enabled on
  69105. */
  69106. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69107. /**
  69108. * Disables an effect by name on a pipeline
  69109. * @param renderPipelineName the name of the pipeline to disable the effect in
  69110. * @param renderEffectName the name of the effect to disable
  69111. * @param cameras the cameras that the effect should be disabled on
  69112. */
  69113. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69114. /**
  69115. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69116. */
  69117. update(): void;
  69118. /** @hidden */
  69119. _rebuild(): void;
  69120. /**
  69121. * Disposes of the manager and pipelines
  69122. */
  69123. dispose(): void;
  69124. }
  69125. }
  69126. declare module BABYLON {
  69127. interface Scene {
  69128. /** @hidden (Backing field) */
  69129. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69130. /**
  69131. * Gets the postprocess render pipeline manager
  69132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69133. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69134. */
  69135. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69136. }
  69137. /**
  69138. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69139. */
  69140. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69141. /**
  69142. * The component name helpfull to identify the component in the list of scene components.
  69143. */
  69144. readonly name: string;
  69145. /**
  69146. * The scene the component belongs to.
  69147. */
  69148. scene: Scene;
  69149. /**
  69150. * Creates a new instance of the component for the given scene
  69151. * @param scene Defines the scene to register the component in
  69152. */
  69153. constructor(scene: Scene);
  69154. /**
  69155. * Registers the component in a given scene
  69156. */
  69157. register(): void;
  69158. /**
  69159. * Rebuilds the elements related to this component in case of
  69160. * context lost for instance.
  69161. */
  69162. rebuild(): void;
  69163. /**
  69164. * Disposes the component and the associated ressources
  69165. */
  69166. dispose(): void;
  69167. private _gatherRenderTargets;
  69168. }
  69169. }
  69170. declare module BABYLON {
  69171. /**
  69172. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69173. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69174. */
  69175. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69176. private _scene;
  69177. private _camerasToBeAttached;
  69178. /**
  69179. * ID of the sharpen post process,
  69180. */
  69181. private readonly SharpenPostProcessId;
  69182. /**
  69183. * @ignore
  69184. * ID of the image processing post process;
  69185. */
  69186. readonly ImageProcessingPostProcessId: string;
  69187. /**
  69188. * @ignore
  69189. * ID of the Fast Approximate Anti-Aliasing post process;
  69190. */
  69191. readonly FxaaPostProcessId: string;
  69192. /**
  69193. * ID of the chromatic aberration post process,
  69194. */
  69195. private readonly ChromaticAberrationPostProcessId;
  69196. /**
  69197. * ID of the grain post process
  69198. */
  69199. private readonly GrainPostProcessId;
  69200. /**
  69201. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69202. */
  69203. sharpen: SharpenPostProcess;
  69204. private _sharpenEffect;
  69205. private bloom;
  69206. /**
  69207. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69208. */
  69209. depthOfField: DepthOfFieldEffect;
  69210. /**
  69211. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69212. */
  69213. fxaa: FxaaPostProcess;
  69214. /**
  69215. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69216. */
  69217. imageProcessing: ImageProcessingPostProcess;
  69218. /**
  69219. * Chromatic aberration post process which will shift rgb colors in the image
  69220. */
  69221. chromaticAberration: ChromaticAberrationPostProcess;
  69222. private _chromaticAberrationEffect;
  69223. /**
  69224. * Grain post process which add noise to the image
  69225. */
  69226. grain: GrainPostProcess;
  69227. private _grainEffect;
  69228. /**
  69229. * Glow post process which adds a glow to emissive areas of the image
  69230. */
  69231. private _glowLayer;
  69232. /**
  69233. * Animations which can be used to tweak settings over a period of time
  69234. */
  69235. animations: Animation[];
  69236. private _imageProcessingConfigurationObserver;
  69237. private _sharpenEnabled;
  69238. private _bloomEnabled;
  69239. private _depthOfFieldEnabled;
  69240. private _depthOfFieldBlurLevel;
  69241. private _fxaaEnabled;
  69242. private _imageProcessingEnabled;
  69243. private _defaultPipelineTextureType;
  69244. private _bloomScale;
  69245. private _chromaticAberrationEnabled;
  69246. private _grainEnabled;
  69247. private _buildAllowed;
  69248. /**
  69249. * Gets active scene
  69250. */
  69251. get scene(): Scene;
  69252. /**
  69253. * Enable or disable the sharpen process from the pipeline
  69254. */
  69255. set sharpenEnabled(enabled: boolean);
  69256. get sharpenEnabled(): boolean;
  69257. private _resizeObserver;
  69258. private _hardwareScaleLevel;
  69259. private _bloomKernel;
  69260. /**
  69261. * Specifies the size of the bloom blur kernel, relative to the final output size
  69262. */
  69263. get bloomKernel(): number;
  69264. set bloomKernel(value: number);
  69265. /**
  69266. * Specifies the weight of the bloom in the final rendering
  69267. */
  69268. private _bloomWeight;
  69269. /**
  69270. * Specifies the luma threshold for the area that will be blurred by the bloom
  69271. */
  69272. private _bloomThreshold;
  69273. private _hdr;
  69274. /**
  69275. * The strength of the bloom.
  69276. */
  69277. set bloomWeight(value: number);
  69278. get bloomWeight(): number;
  69279. /**
  69280. * The strength of the bloom.
  69281. */
  69282. set bloomThreshold(value: number);
  69283. get bloomThreshold(): number;
  69284. /**
  69285. * The scale of the bloom, lower value will provide better performance.
  69286. */
  69287. set bloomScale(value: number);
  69288. get bloomScale(): number;
  69289. /**
  69290. * Enable or disable the bloom from the pipeline
  69291. */
  69292. set bloomEnabled(enabled: boolean);
  69293. get bloomEnabled(): boolean;
  69294. private _rebuildBloom;
  69295. /**
  69296. * If the depth of field is enabled.
  69297. */
  69298. get depthOfFieldEnabled(): boolean;
  69299. set depthOfFieldEnabled(enabled: boolean);
  69300. /**
  69301. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69302. */
  69303. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69304. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69305. /**
  69306. * If the anti aliasing is enabled.
  69307. */
  69308. set fxaaEnabled(enabled: boolean);
  69309. get fxaaEnabled(): boolean;
  69310. private _samples;
  69311. /**
  69312. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69313. */
  69314. set samples(sampleCount: number);
  69315. get samples(): number;
  69316. /**
  69317. * If image processing is enabled.
  69318. */
  69319. set imageProcessingEnabled(enabled: boolean);
  69320. get imageProcessingEnabled(): boolean;
  69321. /**
  69322. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69323. */
  69324. set glowLayerEnabled(enabled: boolean);
  69325. get glowLayerEnabled(): boolean;
  69326. /**
  69327. * Gets the glow layer (or null if not defined)
  69328. */
  69329. get glowLayer(): Nullable<GlowLayer>;
  69330. /**
  69331. * Enable or disable the chromaticAberration process from the pipeline
  69332. */
  69333. set chromaticAberrationEnabled(enabled: boolean);
  69334. get chromaticAberrationEnabled(): boolean;
  69335. /**
  69336. * Enable or disable the grain process from the pipeline
  69337. */
  69338. set grainEnabled(enabled: boolean);
  69339. get grainEnabled(): boolean;
  69340. /**
  69341. * @constructor
  69342. * @param name - The rendering pipeline name (default: "")
  69343. * @param hdr - If high dynamic range textures should be used (default: true)
  69344. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69345. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69346. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69347. */
  69348. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69349. /**
  69350. * Get the class name
  69351. * @returns "DefaultRenderingPipeline"
  69352. */
  69353. getClassName(): string;
  69354. /**
  69355. * Force the compilation of the entire pipeline.
  69356. */
  69357. prepare(): void;
  69358. private _hasCleared;
  69359. private _prevPostProcess;
  69360. private _prevPrevPostProcess;
  69361. private _setAutoClearAndTextureSharing;
  69362. private _depthOfFieldSceneObserver;
  69363. private _buildPipeline;
  69364. private _disposePostProcesses;
  69365. /**
  69366. * Adds a camera to the pipeline
  69367. * @param camera the camera to be added
  69368. */
  69369. addCamera(camera: Camera): void;
  69370. /**
  69371. * Removes a camera from the pipeline
  69372. * @param camera the camera to remove
  69373. */
  69374. removeCamera(camera: Camera): void;
  69375. /**
  69376. * Dispose of the pipeline and stop all post processes
  69377. */
  69378. dispose(): void;
  69379. /**
  69380. * Serialize the rendering pipeline (Used when exporting)
  69381. * @returns the serialized object
  69382. */
  69383. serialize(): any;
  69384. /**
  69385. * Parse the serialized pipeline
  69386. * @param source Source pipeline.
  69387. * @param scene The scene to load the pipeline to.
  69388. * @param rootUrl The URL of the serialized pipeline.
  69389. * @returns An instantiated pipeline from the serialized object.
  69390. */
  69391. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69392. }
  69393. }
  69394. declare module BABYLON {
  69395. /** @hidden */
  69396. export var lensHighlightsPixelShader: {
  69397. name: string;
  69398. shader: string;
  69399. };
  69400. }
  69401. declare module BABYLON {
  69402. /** @hidden */
  69403. export var depthOfFieldPixelShader: {
  69404. name: string;
  69405. shader: string;
  69406. };
  69407. }
  69408. declare module BABYLON {
  69409. /**
  69410. * BABYLON.JS Chromatic Aberration GLSL Shader
  69411. * Author: Olivier Guyot
  69412. * Separates very slightly R, G and B colors on the edges of the screen
  69413. * Inspired by Francois Tarlier & Martins Upitis
  69414. */
  69415. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69416. /**
  69417. * @ignore
  69418. * The chromatic aberration PostProcess id in the pipeline
  69419. */
  69420. LensChromaticAberrationEffect: string;
  69421. /**
  69422. * @ignore
  69423. * The highlights enhancing PostProcess id in the pipeline
  69424. */
  69425. HighlightsEnhancingEffect: string;
  69426. /**
  69427. * @ignore
  69428. * The depth-of-field PostProcess id in the pipeline
  69429. */
  69430. LensDepthOfFieldEffect: string;
  69431. private _scene;
  69432. private _depthTexture;
  69433. private _grainTexture;
  69434. private _chromaticAberrationPostProcess;
  69435. private _highlightsPostProcess;
  69436. private _depthOfFieldPostProcess;
  69437. private _edgeBlur;
  69438. private _grainAmount;
  69439. private _chromaticAberration;
  69440. private _distortion;
  69441. private _highlightsGain;
  69442. private _highlightsThreshold;
  69443. private _dofDistance;
  69444. private _dofAperture;
  69445. private _dofDarken;
  69446. private _dofPentagon;
  69447. private _blurNoise;
  69448. /**
  69449. * @constructor
  69450. *
  69451. * Effect parameters are as follow:
  69452. * {
  69453. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69454. * edge_blur: number; // from 0 to x (1 for realism)
  69455. * distortion: number; // from 0 to x (1 for realism)
  69456. * grain_amount: number; // from 0 to 1
  69457. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69458. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69459. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69460. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69461. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69462. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69463. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69464. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69465. * }
  69466. * Note: if an effect parameter is unset, effect is disabled
  69467. *
  69468. * @param name The rendering pipeline name
  69469. * @param parameters - An object containing all parameters (see above)
  69470. * @param scene The scene linked to this pipeline
  69471. * @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)
  69472. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69473. */
  69474. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69475. /**
  69476. * Get the class name
  69477. * @returns "LensRenderingPipeline"
  69478. */
  69479. getClassName(): string;
  69480. /**
  69481. * Gets associated scene
  69482. */
  69483. get scene(): Scene;
  69484. /**
  69485. * Gets or sets the edge blur
  69486. */
  69487. get edgeBlur(): number;
  69488. set edgeBlur(value: number);
  69489. /**
  69490. * Gets or sets the grain amount
  69491. */
  69492. get grainAmount(): number;
  69493. set grainAmount(value: number);
  69494. /**
  69495. * Gets or sets the chromatic aberration amount
  69496. */
  69497. get chromaticAberration(): number;
  69498. set chromaticAberration(value: number);
  69499. /**
  69500. * Gets or sets the depth of field aperture
  69501. */
  69502. get dofAperture(): number;
  69503. set dofAperture(value: number);
  69504. /**
  69505. * Gets or sets the edge distortion
  69506. */
  69507. get edgeDistortion(): number;
  69508. set edgeDistortion(value: number);
  69509. /**
  69510. * Gets or sets the depth of field distortion
  69511. */
  69512. get dofDistortion(): number;
  69513. set dofDistortion(value: number);
  69514. /**
  69515. * Gets or sets the darken out of focus amount
  69516. */
  69517. get darkenOutOfFocus(): number;
  69518. set darkenOutOfFocus(value: number);
  69519. /**
  69520. * Gets or sets a boolean indicating if blur noise is enabled
  69521. */
  69522. get blurNoise(): boolean;
  69523. set blurNoise(value: boolean);
  69524. /**
  69525. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69526. */
  69527. get pentagonBokeh(): boolean;
  69528. set pentagonBokeh(value: boolean);
  69529. /**
  69530. * Gets or sets the highlight grain amount
  69531. */
  69532. get highlightsGain(): number;
  69533. set highlightsGain(value: number);
  69534. /**
  69535. * Gets or sets the highlight threshold
  69536. */
  69537. get highlightsThreshold(): number;
  69538. set highlightsThreshold(value: number);
  69539. /**
  69540. * Sets the amount of blur at the edges
  69541. * @param amount blur amount
  69542. */
  69543. setEdgeBlur(amount: number): void;
  69544. /**
  69545. * Sets edge blur to 0
  69546. */
  69547. disableEdgeBlur(): void;
  69548. /**
  69549. * Sets the amout of grain
  69550. * @param amount Amount of grain
  69551. */
  69552. setGrainAmount(amount: number): void;
  69553. /**
  69554. * Set grain amount to 0
  69555. */
  69556. disableGrain(): void;
  69557. /**
  69558. * Sets the chromatic aberration amount
  69559. * @param amount amount of chromatic aberration
  69560. */
  69561. setChromaticAberration(amount: number): void;
  69562. /**
  69563. * Sets chromatic aberration amount to 0
  69564. */
  69565. disableChromaticAberration(): void;
  69566. /**
  69567. * Sets the EdgeDistortion amount
  69568. * @param amount amount of EdgeDistortion
  69569. */
  69570. setEdgeDistortion(amount: number): void;
  69571. /**
  69572. * Sets edge distortion to 0
  69573. */
  69574. disableEdgeDistortion(): void;
  69575. /**
  69576. * Sets the FocusDistance amount
  69577. * @param amount amount of FocusDistance
  69578. */
  69579. setFocusDistance(amount: number): void;
  69580. /**
  69581. * Disables depth of field
  69582. */
  69583. disableDepthOfField(): void;
  69584. /**
  69585. * Sets the Aperture amount
  69586. * @param amount amount of Aperture
  69587. */
  69588. setAperture(amount: number): void;
  69589. /**
  69590. * Sets the DarkenOutOfFocus amount
  69591. * @param amount amount of DarkenOutOfFocus
  69592. */
  69593. setDarkenOutOfFocus(amount: number): void;
  69594. private _pentagonBokehIsEnabled;
  69595. /**
  69596. * Creates a pentagon bokeh effect
  69597. */
  69598. enablePentagonBokeh(): void;
  69599. /**
  69600. * Disables the pentagon bokeh effect
  69601. */
  69602. disablePentagonBokeh(): void;
  69603. /**
  69604. * Enables noise blur
  69605. */
  69606. enableNoiseBlur(): void;
  69607. /**
  69608. * Disables noise blur
  69609. */
  69610. disableNoiseBlur(): void;
  69611. /**
  69612. * Sets the HighlightsGain amount
  69613. * @param amount amount of HighlightsGain
  69614. */
  69615. setHighlightsGain(amount: number): void;
  69616. /**
  69617. * Sets the HighlightsThreshold amount
  69618. * @param amount amount of HighlightsThreshold
  69619. */
  69620. setHighlightsThreshold(amount: number): void;
  69621. /**
  69622. * Disables highlights
  69623. */
  69624. disableHighlights(): void;
  69625. /**
  69626. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69627. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69628. */
  69629. dispose(disableDepthRender?: boolean): void;
  69630. private _createChromaticAberrationPostProcess;
  69631. private _createHighlightsPostProcess;
  69632. private _createDepthOfFieldPostProcess;
  69633. private _createGrainTexture;
  69634. }
  69635. }
  69636. declare module BABYLON {
  69637. /** @hidden */
  69638. export var ssao2PixelShader: {
  69639. name: string;
  69640. shader: string;
  69641. };
  69642. }
  69643. declare module BABYLON {
  69644. /** @hidden */
  69645. export var ssaoCombinePixelShader: {
  69646. name: string;
  69647. shader: string;
  69648. };
  69649. }
  69650. declare module BABYLON {
  69651. /**
  69652. * Render pipeline to produce ssao effect
  69653. */
  69654. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69655. /**
  69656. * @ignore
  69657. * The PassPostProcess id in the pipeline that contains the original scene color
  69658. */
  69659. SSAOOriginalSceneColorEffect: string;
  69660. /**
  69661. * @ignore
  69662. * The SSAO PostProcess id in the pipeline
  69663. */
  69664. SSAORenderEffect: string;
  69665. /**
  69666. * @ignore
  69667. * The horizontal blur PostProcess id in the pipeline
  69668. */
  69669. SSAOBlurHRenderEffect: string;
  69670. /**
  69671. * @ignore
  69672. * The vertical blur PostProcess id in the pipeline
  69673. */
  69674. SSAOBlurVRenderEffect: string;
  69675. /**
  69676. * @ignore
  69677. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69678. */
  69679. SSAOCombineRenderEffect: string;
  69680. /**
  69681. * The output strength of the SSAO post-process. Default value is 1.0.
  69682. */
  69683. totalStrength: number;
  69684. /**
  69685. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69686. */
  69687. maxZ: number;
  69688. /**
  69689. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69690. */
  69691. minZAspect: number;
  69692. private _samples;
  69693. /**
  69694. * Number of samples used for the SSAO calculations. Default value is 8
  69695. */
  69696. set samples(n: number);
  69697. get samples(): number;
  69698. private _textureSamples;
  69699. /**
  69700. * Number of samples to use for antialiasing
  69701. */
  69702. set textureSamples(n: number);
  69703. get textureSamples(): number;
  69704. /**
  69705. * Ratio object used for SSAO ratio and blur ratio
  69706. */
  69707. private _ratio;
  69708. /**
  69709. * Dynamically generated sphere sampler.
  69710. */
  69711. private _sampleSphere;
  69712. /**
  69713. * Blur filter offsets
  69714. */
  69715. private _samplerOffsets;
  69716. private _expensiveBlur;
  69717. /**
  69718. * If bilateral blur should be used
  69719. */
  69720. set expensiveBlur(b: boolean);
  69721. get expensiveBlur(): boolean;
  69722. /**
  69723. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69724. */
  69725. radius: number;
  69726. /**
  69727. * The base color of the SSAO post-process
  69728. * The final result is "base + ssao" between [0, 1]
  69729. */
  69730. base: number;
  69731. /**
  69732. * Support test.
  69733. */
  69734. static get IsSupported(): boolean;
  69735. private _scene;
  69736. private _depthTexture;
  69737. private _normalTexture;
  69738. private _randomTexture;
  69739. private _originalColorPostProcess;
  69740. private _ssaoPostProcess;
  69741. private _blurHPostProcess;
  69742. private _blurVPostProcess;
  69743. private _ssaoCombinePostProcess;
  69744. /**
  69745. * Gets active scene
  69746. */
  69747. get scene(): Scene;
  69748. /**
  69749. * @constructor
  69750. * @param name The rendering pipeline name
  69751. * @param scene The scene linked to this pipeline
  69752. * @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 }
  69753. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69754. */
  69755. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69756. /**
  69757. * Get the class name
  69758. * @returns "SSAO2RenderingPipeline"
  69759. */
  69760. getClassName(): string;
  69761. /**
  69762. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69763. */
  69764. dispose(disableGeometryBufferRenderer?: boolean): void;
  69765. private _createBlurPostProcess;
  69766. /** @hidden */
  69767. _rebuild(): void;
  69768. private _bits;
  69769. private _radicalInverse_VdC;
  69770. private _hammersley;
  69771. private _hemisphereSample_uniform;
  69772. private _generateHemisphere;
  69773. private _createSSAOPostProcess;
  69774. private _createSSAOCombinePostProcess;
  69775. private _createRandomTexture;
  69776. /**
  69777. * Serialize the rendering pipeline (Used when exporting)
  69778. * @returns the serialized object
  69779. */
  69780. serialize(): any;
  69781. /**
  69782. * Parse the serialized pipeline
  69783. * @param source Source pipeline.
  69784. * @param scene The scene to load the pipeline to.
  69785. * @param rootUrl The URL of the serialized pipeline.
  69786. * @returns An instantiated pipeline from the serialized object.
  69787. */
  69788. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69789. }
  69790. }
  69791. declare module BABYLON {
  69792. /** @hidden */
  69793. export var ssaoPixelShader: {
  69794. name: string;
  69795. shader: string;
  69796. };
  69797. }
  69798. declare module BABYLON {
  69799. /**
  69800. * Render pipeline to produce ssao effect
  69801. */
  69802. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69803. /**
  69804. * @ignore
  69805. * The PassPostProcess id in the pipeline that contains the original scene color
  69806. */
  69807. SSAOOriginalSceneColorEffect: string;
  69808. /**
  69809. * @ignore
  69810. * The SSAO PostProcess id in the pipeline
  69811. */
  69812. SSAORenderEffect: string;
  69813. /**
  69814. * @ignore
  69815. * The horizontal blur PostProcess id in the pipeline
  69816. */
  69817. SSAOBlurHRenderEffect: string;
  69818. /**
  69819. * @ignore
  69820. * The vertical blur PostProcess id in the pipeline
  69821. */
  69822. SSAOBlurVRenderEffect: string;
  69823. /**
  69824. * @ignore
  69825. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69826. */
  69827. SSAOCombineRenderEffect: string;
  69828. /**
  69829. * The output strength of the SSAO post-process. Default value is 1.0.
  69830. */
  69831. totalStrength: number;
  69832. /**
  69833. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69834. */
  69835. radius: number;
  69836. /**
  69837. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69838. * Must not be equal to fallOff and superior to fallOff.
  69839. * Default value is 0.0075
  69840. */
  69841. area: number;
  69842. /**
  69843. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69844. * Must not be equal to area and inferior to area.
  69845. * Default value is 0.000001
  69846. */
  69847. fallOff: number;
  69848. /**
  69849. * The base color of the SSAO post-process
  69850. * The final result is "base + ssao" between [0, 1]
  69851. */
  69852. base: number;
  69853. private _scene;
  69854. private _depthTexture;
  69855. private _randomTexture;
  69856. private _originalColorPostProcess;
  69857. private _ssaoPostProcess;
  69858. private _blurHPostProcess;
  69859. private _blurVPostProcess;
  69860. private _ssaoCombinePostProcess;
  69861. private _firstUpdate;
  69862. /**
  69863. * Gets active scene
  69864. */
  69865. get scene(): Scene;
  69866. /**
  69867. * @constructor
  69868. * @param name - The rendering pipeline name
  69869. * @param scene - The scene linked to this pipeline
  69870. * @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 }
  69871. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69872. */
  69873. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69874. /**
  69875. * Get the class name
  69876. * @returns "SSAORenderingPipeline"
  69877. */
  69878. getClassName(): string;
  69879. /**
  69880. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69881. */
  69882. dispose(disableDepthRender?: boolean): void;
  69883. private _createBlurPostProcess;
  69884. /** @hidden */
  69885. _rebuild(): void;
  69886. private _createSSAOPostProcess;
  69887. private _createSSAOCombinePostProcess;
  69888. private _createRandomTexture;
  69889. }
  69890. }
  69891. declare module BABYLON {
  69892. /** @hidden */
  69893. export var screenSpaceReflectionPixelShader: {
  69894. name: string;
  69895. shader: string;
  69896. };
  69897. }
  69898. declare module BABYLON {
  69899. /**
  69900. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69901. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69902. */
  69903. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69904. /**
  69905. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69906. */
  69907. threshold: number;
  69908. /**
  69909. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69910. */
  69911. strength: number;
  69912. /**
  69913. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69914. */
  69915. reflectionSpecularFalloffExponent: number;
  69916. /**
  69917. * 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]
  69918. */
  69919. step: number;
  69920. /**
  69921. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69922. */
  69923. roughnessFactor: number;
  69924. private _geometryBufferRenderer;
  69925. private _enableSmoothReflections;
  69926. private _reflectionSamples;
  69927. private _smoothSteps;
  69928. /**
  69929. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69930. * @param name The name of the effect.
  69931. * @param scene The scene containing the objects to calculate reflections.
  69932. * @param options The required width/height ratio to downsize to before computing the render pass.
  69933. * @param camera The camera to apply the render pass to.
  69934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69935. * @param engine The engine which the post process will be applied. (default: current engine)
  69936. * @param reusable If the post process can be reused on the same frame. (default: false)
  69937. * @param textureType Type of textures used when performing the post process. (default: 0)
  69938. * @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)
  69939. */
  69940. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69941. /**
  69942. * Gets wether or not smoothing reflections is enabled.
  69943. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69944. */
  69945. get enableSmoothReflections(): boolean;
  69946. /**
  69947. * Sets wether or not smoothing reflections is enabled.
  69948. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69949. */
  69950. set enableSmoothReflections(enabled: boolean);
  69951. /**
  69952. * Gets the number of samples taken while computing reflections. More samples count is high,
  69953. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69954. */
  69955. get reflectionSamples(): number;
  69956. /**
  69957. * Sets the number of samples taken while computing reflections. More samples count is high,
  69958. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69959. */
  69960. set reflectionSamples(samples: number);
  69961. /**
  69962. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69963. * more the post-process will require GPU power and can generate a drop in FPS.
  69964. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69965. */
  69966. get smoothSteps(): number;
  69967. set smoothSteps(steps: number);
  69968. private _updateEffectDefines;
  69969. }
  69970. }
  69971. declare module BABYLON {
  69972. /** @hidden */
  69973. export var standardPixelShader: {
  69974. name: string;
  69975. shader: string;
  69976. };
  69977. }
  69978. declare module BABYLON {
  69979. /**
  69980. * Standard rendering pipeline
  69981. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69982. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69983. */
  69984. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69985. /**
  69986. * Public members
  69987. */
  69988. /**
  69989. * Post-process which contains the original scene color before the pipeline applies all the effects
  69990. */
  69991. originalPostProcess: Nullable<PostProcess>;
  69992. /**
  69993. * Post-process used to down scale an image x4
  69994. */
  69995. downSampleX4PostProcess: Nullable<PostProcess>;
  69996. /**
  69997. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69998. */
  69999. brightPassPostProcess: Nullable<PostProcess>;
  70000. /**
  70001. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70002. */
  70003. blurHPostProcesses: PostProcess[];
  70004. /**
  70005. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70006. */
  70007. blurVPostProcesses: PostProcess[];
  70008. /**
  70009. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70010. */
  70011. textureAdderPostProcess: Nullable<PostProcess>;
  70012. /**
  70013. * Post-process used to create volumetric lighting effect
  70014. */
  70015. volumetricLightPostProcess: Nullable<PostProcess>;
  70016. /**
  70017. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70018. */
  70019. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70020. /**
  70021. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70022. */
  70023. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70024. /**
  70025. * Post-process used to merge the volumetric light effect and the real scene color
  70026. */
  70027. volumetricLightMergePostProces: Nullable<PostProcess>;
  70028. /**
  70029. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70030. */
  70031. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70032. /**
  70033. * Base post-process used to calculate the average luminance of the final image for HDR
  70034. */
  70035. luminancePostProcess: Nullable<PostProcess>;
  70036. /**
  70037. * Post-processes used to create down sample post-processes in order to get
  70038. * the average luminance of the final image for HDR
  70039. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70040. */
  70041. luminanceDownSamplePostProcesses: PostProcess[];
  70042. /**
  70043. * Post-process used to create a HDR effect (light adaptation)
  70044. */
  70045. hdrPostProcess: Nullable<PostProcess>;
  70046. /**
  70047. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70048. */
  70049. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70050. /**
  70051. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70052. */
  70053. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70054. /**
  70055. * Post-process used to merge the final HDR post-process and the real scene color
  70056. */
  70057. hdrFinalPostProcess: Nullable<PostProcess>;
  70058. /**
  70059. * Post-process used to create a lens flare effect
  70060. */
  70061. lensFlarePostProcess: Nullable<PostProcess>;
  70062. /**
  70063. * Post-process that merges the result of the lens flare post-process and the real scene color
  70064. */
  70065. lensFlareComposePostProcess: Nullable<PostProcess>;
  70066. /**
  70067. * Post-process used to create a motion blur effect
  70068. */
  70069. motionBlurPostProcess: Nullable<PostProcess>;
  70070. /**
  70071. * Post-process used to create a depth of field effect
  70072. */
  70073. depthOfFieldPostProcess: Nullable<PostProcess>;
  70074. /**
  70075. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70076. */
  70077. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70078. /**
  70079. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70080. */
  70081. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70082. /**
  70083. * Represents the brightness threshold in order to configure the illuminated surfaces
  70084. */
  70085. brightThreshold: number;
  70086. /**
  70087. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70088. */
  70089. blurWidth: number;
  70090. /**
  70091. * Sets if the blur for highlighted surfaces must be only horizontal
  70092. */
  70093. horizontalBlur: boolean;
  70094. /**
  70095. * Gets the overall exposure used by the pipeline
  70096. */
  70097. get exposure(): number;
  70098. /**
  70099. * Sets the overall exposure used by the pipeline
  70100. */
  70101. set exposure(value: number);
  70102. /**
  70103. * Texture used typically to simulate "dirty" on camera lens
  70104. */
  70105. lensTexture: Nullable<Texture>;
  70106. /**
  70107. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70108. */
  70109. volumetricLightCoefficient: number;
  70110. /**
  70111. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70112. */
  70113. volumetricLightPower: number;
  70114. /**
  70115. * Used the set the blur intensity to smooth the volumetric lights
  70116. */
  70117. volumetricLightBlurScale: number;
  70118. /**
  70119. * Light (spot or directional) used to generate the volumetric lights rays
  70120. * The source light must have a shadow generate so the pipeline can get its
  70121. * depth map
  70122. */
  70123. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70124. /**
  70125. * For eye adaptation, represents the minimum luminance the eye can see
  70126. */
  70127. hdrMinimumLuminance: number;
  70128. /**
  70129. * For eye adaptation, represents the decrease luminance speed
  70130. */
  70131. hdrDecreaseRate: number;
  70132. /**
  70133. * For eye adaptation, represents the increase luminance speed
  70134. */
  70135. hdrIncreaseRate: number;
  70136. /**
  70137. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70138. */
  70139. get hdrAutoExposure(): boolean;
  70140. /**
  70141. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70142. */
  70143. set hdrAutoExposure(value: boolean);
  70144. /**
  70145. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70146. */
  70147. lensColorTexture: Nullable<Texture>;
  70148. /**
  70149. * The overall strengh for the lens flare effect
  70150. */
  70151. lensFlareStrength: number;
  70152. /**
  70153. * Dispersion coefficient for lens flare ghosts
  70154. */
  70155. lensFlareGhostDispersal: number;
  70156. /**
  70157. * Main lens flare halo width
  70158. */
  70159. lensFlareHaloWidth: number;
  70160. /**
  70161. * Based on the lens distortion effect, defines how much the lens flare result
  70162. * is distorted
  70163. */
  70164. lensFlareDistortionStrength: number;
  70165. /**
  70166. * Configures the blur intensity used for for lens flare (halo)
  70167. */
  70168. lensFlareBlurWidth: number;
  70169. /**
  70170. * Lens star texture must be used to simulate rays on the flares and is available
  70171. * in the documentation
  70172. */
  70173. lensStarTexture: Nullable<Texture>;
  70174. /**
  70175. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70176. * flare effect by taking account of the dirt texture
  70177. */
  70178. lensFlareDirtTexture: Nullable<Texture>;
  70179. /**
  70180. * Represents the focal length for the depth of field effect
  70181. */
  70182. depthOfFieldDistance: number;
  70183. /**
  70184. * Represents the blur intensity for the blurred part of the depth of field effect
  70185. */
  70186. depthOfFieldBlurWidth: number;
  70187. /**
  70188. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70189. */
  70190. get motionStrength(): number;
  70191. /**
  70192. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70193. */
  70194. set motionStrength(strength: number);
  70195. /**
  70196. * Gets wether or not the motion blur post-process is object based or screen based.
  70197. */
  70198. get objectBasedMotionBlur(): boolean;
  70199. /**
  70200. * Sets wether or not the motion blur post-process should be object based or screen based
  70201. */
  70202. set objectBasedMotionBlur(value: boolean);
  70203. /**
  70204. * List of animations for the pipeline (IAnimatable implementation)
  70205. */
  70206. animations: Animation[];
  70207. /**
  70208. * Private members
  70209. */
  70210. private _scene;
  70211. private _currentDepthOfFieldSource;
  70212. private _basePostProcess;
  70213. private _fixedExposure;
  70214. private _currentExposure;
  70215. private _hdrAutoExposure;
  70216. private _hdrCurrentLuminance;
  70217. private _motionStrength;
  70218. private _isObjectBasedMotionBlur;
  70219. private _floatTextureType;
  70220. private _camerasToBeAttached;
  70221. private _ratio;
  70222. private _bloomEnabled;
  70223. private _depthOfFieldEnabled;
  70224. private _vlsEnabled;
  70225. private _lensFlareEnabled;
  70226. private _hdrEnabled;
  70227. private _motionBlurEnabled;
  70228. private _fxaaEnabled;
  70229. private _screenSpaceReflectionsEnabled;
  70230. private _motionBlurSamples;
  70231. private _volumetricLightStepsCount;
  70232. private _samples;
  70233. /**
  70234. * @ignore
  70235. * Specifies if the bloom pipeline is enabled
  70236. */
  70237. get BloomEnabled(): boolean;
  70238. set BloomEnabled(enabled: boolean);
  70239. /**
  70240. * @ignore
  70241. * Specifies if the depth of field pipeline is enabed
  70242. */
  70243. get DepthOfFieldEnabled(): boolean;
  70244. set DepthOfFieldEnabled(enabled: boolean);
  70245. /**
  70246. * @ignore
  70247. * Specifies if the lens flare pipeline is enabed
  70248. */
  70249. get LensFlareEnabled(): boolean;
  70250. set LensFlareEnabled(enabled: boolean);
  70251. /**
  70252. * @ignore
  70253. * Specifies if the HDR pipeline is enabled
  70254. */
  70255. get HDREnabled(): boolean;
  70256. set HDREnabled(enabled: boolean);
  70257. /**
  70258. * @ignore
  70259. * Specifies if the volumetric lights scattering effect is enabled
  70260. */
  70261. get VLSEnabled(): boolean;
  70262. set VLSEnabled(enabled: boolean);
  70263. /**
  70264. * @ignore
  70265. * Specifies if the motion blur effect is enabled
  70266. */
  70267. get MotionBlurEnabled(): boolean;
  70268. set MotionBlurEnabled(enabled: boolean);
  70269. /**
  70270. * Specifies if anti-aliasing is enabled
  70271. */
  70272. get fxaaEnabled(): boolean;
  70273. set fxaaEnabled(enabled: boolean);
  70274. /**
  70275. * Specifies if screen space reflections are enabled.
  70276. */
  70277. get screenSpaceReflectionsEnabled(): boolean;
  70278. set screenSpaceReflectionsEnabled(enabled: boolean);
  70279. /**
  70280. * Specifies the number of steps used to calculate the volumetric lights
  70281. * Typically in interval [50, 200]
  70282. */
  70283. get volumetricLightStepsCount(): number;
  70284. set volumetricLightStepsCount(count: number);
  70285. /**
  70286. * Specifies the number of samples used for the motion blur effect
  70287. * Typically in interval [16, 64]
  70288. */
  70289. get motionBlurSamples(): number;
  70290. set motionBlurSamples(samples: number);
  70291. /**
  70292. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70293. */
  70294. get samples(): number;
  70295. set samples(sampleCount: number);
  70296. /**
  70297. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70298. * @constructor
  70299. * @param name The rendering pipeline name
  70300. * @param scene The scene linked to this pipeline
  70301. * @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)
  70302. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70303. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70304. */
  70305. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70306. private _buildPipeline;
  70307. private _createDownSampleX4PostProcess;
  70308. private _createBrightPassPostProcess;
  70309. private _createBlurPostProcesses;
  70310. private _createTextureAdderPostProcess;
  70311. private _createVolumetricLightPostProcess;
  70312. private _createLuminancePostProcesses;
  70313. private _createHdrPostProcess;
  70314. private _createLensFlarePostProcess;
  70315. private _createDepthOfFieldPostProcess;
  70316. private _createMotionBlurPostProcess;
  70317. private _getDepthTexture;
  70318. private _disposePostProcesses;
  70319. /**
  70320. * Dispose of the pipeline and stop all post processes
  70321. */
  70322. dispose(): void;
  70323. /**
  70324. * Serialize the rendering pipeline (Used when exporting)
  70325. * @returns the serialized object
  70326. */
  70327. serialize(): any;
  70328. /**
  70329. * Parse the serialized pipeline
  70330. * @param source Source pipeline.
  70331. * @param scene The scene to load the pipeline to.
  70332. * @param rootUrl The URL of the serialized pipeline.
  70333. * @returns An instantiated pipeline from the serialized object.
  70334. */
  70335. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70336. /**
  70337. * Luminance steps
  70338. */
  70339. static LuminanceSteps: number;
  70340. }
  70341. }
  70342. declare module BABYLON {
  70343. /** @hidden */
  70344. export var stereoscopicInterlacePixelShader: {
  70345. name: string;
  70346. shader: string;
  70347. };
  70348. }
  70349. declare module BABYLON {
  70350. /**
  70351. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70352. */
  70353. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70354. private _stepSize;
  70355. private _passedProcess;
  70356. /**
  70357. * Initializes a StereoscopicInterlacePostProcessI
  70358. * @param name The name of the effect.
  70359. * @param rigCameras The rig cameras to be appled to the post process
  70360. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70361. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70363. * @param engine The engine which the post process will be applied. (default: current engine)
  70364. * @param reusable If the post process can be reused on the same frame. (default: false)
  70365. */
  70366. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70367. }
  70368. /**
  70369. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70370. */
  70371. export class StereoscopicInterlacePostProcess extends PostProcess {
  70372. private _stepSize;
  70373. private _passedProcess;
  70374. /**
  70375. * Initializes a StereoscopicInterlacePostProcess
  70376. * @param name The name of the effect.
  70377. * @param rigCameras The rig cameras to be appled to the post process
  70378. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70380. * @param engine The engine which the post process will be applied. (default: current engine)
  70381. * @param reusable If the post process can be reused on the same frame. (default: false)
  70382. */
  70383. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70384. }
  70385. }
  70386. declare module BABYLON {
  70387. /** @hidden */
  70388. export var tonemapPixelShader: {
  70389. name: string;
  70390. shader: string;
  70391. };
  70392. }
  70393. declare module BABYLON {
  70394. /** Defines operator used for tonemapping */
  70395. export enum TonemappingOperator {
  70396. /** Hable */
  70397. Hable = 0,
  70398. /** Reinhard */
  70399. Reinhard = 1,
  70400. /** HejiDawson */
  70401. HejiDawson = 2,
  70402. /** Photographic */
  70403. Photographic = 3
  70404. }
  70405. /**
  70406. * Defines a post process to apply tone mapping
  70407. */
  70408. export class TonemapPostProcess extends PostProcess {
  70409. private _operator;
  70410. /** Defines the required exposure adjustement */
  70411. exposureAdjustment: number;
  70412. /**
  70413. * Creates a new TonemapPostProcess
  70414. * @param name defines the name of the postprocess
  70415. * @param _operator defines the operator to use
  70416. * @param exposureAdjustment defines the required exposure adjustement
  70417. * @param camera defines the camera to use (can be null)
  70418. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70419. * @param engine defines the hosting engine (can be ignore if camera is set)
  70420. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70421. */
  70422. constructor(name: string, _operator: TonemappingOperator,
  70423. /** Defines the required exposure adjustement */
  70424. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70425. }
  70426. }
  70427. declare module BABYLON {
  70428. /** @hidden */
  70429. export var volumetricLightScatteringPixelShader: {
  70430. name: string;
  70431. shader: string;
  70432. };
  70433. }
  70434. declare module BABYLON {
  70435. /** @hidden */
  70436. export var volumetricLightScatteringPassVertexShader: {
  70437. name: string;
  70438. shader: string;
  70439. };
  70440. }
  70441. declare module BABYLON {
  70442. /** @hidden */
  70443. export var volumetricLightScatteringPassPixelShader: {
  70444. name: string;
  70445. shader: string;
  70446. };
  70447. }
  70448. declare module BABYLON {
  70449. /**
  70450. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70451. */
  70452. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70453. private _volumetricLightScatteringPass;
  70454. private _volumetricLightScatteringRTT;
  70455. private _viewPort;
  70456. private _screenCoordinates;
  70457. private _cachedDefines;
  70458. /**
  70459. * If not undefined, the mesh position is computed from the attached node position
  70460. */
  70461. attachedNode: {
  70462. position: Vector3;
  70463. };
  70464. /**
  70465. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70466. */
  70467. customMeshPosition: Vector3;
  70468. /**
  70469. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70470. */
  70471. useCustomMeshPosition: boolean;
  70472. /**
  70473. * If the post-process should inverse the light scattering direction
  70474. */
  70475. invert: boolean;
  70476. /**
  70477. * The internal mesh used by the post-process
  70478. */
  70479. mesh: Mesh;
  70480. /**
  70481. * @hidden
  70482. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70483. */
  70484. get useDiffuseColor(): boolean;
  70485. set useDiffuseColor(useDiffuseColor: boolean);
  70486. /**
  70487. * Array containing the excluded meshes not rendered in the internal pass
  70488. */
  70489. excludedMeshes: AbstractMesh[];
  70490. /**
  70491. * Controls the overall intensity of the post-process
  70492. */
  70493. exposure: number;
  70494. /**
  70495. * Dissipates each sample's contribution in range [0, 1]
  70496. */
  70497. decay: number;
  70498. /**
  70499. * Controls the overall intensity of each sample
  70500. */
  70501. weight: number;
  70502. /**
  70503. * Controls the density of each sample
  70504. */
  70505. density: number;
  70506. /**
  70507. * @constructor
  70508. * @param name The post-process name
  70509. * @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)
  70510. * @param camera The camera that the post-process will be attached to
  70511. * @param mesh The mesh used to create the light scattering
  70512. * @param samples The post-process quality, default 100
  70513. * @param samplingModeThe post-process filtering mode
  70514. * @param engine The babylon engine
  70515. * @param reusable If the post-process is reusable
  70516. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70517. */
  70518. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70519. /**
  70520. * Returns the string "VolumetricLightScatteringPostProcess"
  70521. * @returns "VolumetricLightScatteringPostProcess"
  70522. */
  70523. getClassName(): string;
  70524. private _isReady;
  70525. /**
  70526. * Sets the new light position for light scattering effect
  70527. * @param position The new custom light position
  70528. */
  70529. setCustomMeshPosition(position: Vector3): void;
  70530. /**
  70531. * Returns the light position for light scattering effect
  70532. * @return Vector3 The custom light position
  70533. */
  70534. getCustomMeshPosition(): Vector3;
  70535. /**
  70536. * Disposes the internal assets and detaches the post-process from the camera
  70537. */
  70538. dispose(camera: Camera): void;
  70539. /**
  70540. * Returns the render target texture used by the post-process
  70541. * @return the render target texture used by the post-process
  70542. */
  70543. getPass(): RenderTargetTexture;
  70544. private _meshExcluded;
  70545. private _createPass;
  70546. private _updateMeshScreenCoordinates;
  70547. /**
  70548. * Creates a default mesh for the Volumeric Light Scattering post-process
  70549. * @param name The mesh name
  70550. * @param scene The scene where to create the mesh
  70551. * @return the default mesh
  70552. */
  70553. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70554. }
  70555. }
  70556. declare module BABYLON {
  70557. interface Scene {
  70558. /** @hidden (Backing field) */
  70559. _boundingBoxRenderer: BoundingBoxRenderer;
  70560. /** @hidden (Backing field) */
  70561. _forceShowBoundingBoxes: boolean;
  70562. /**
  70563. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70564. */
  70565. forceShowBoundingBoxes: boolean;
  70566. /**
  70567. * Gets the bounding box renderer associated with the scene
  70568. * @returns a BoundingBoxRenderer
  70569. */
  70570. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70571. }
  70572. interface AbstractMesh {
  70573. /** @hidden (Backing field) */
  70574. _showBoundingBox: boolean;
  70575. /**
  70576. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70577. */
  70578. showBoundingBox: boolean;
  70579. }
  70580. /**
  70581. * Component responsible of rendering the bounding box of the meshes in a scene.
  70582. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70583. */
  70584. export class BoundingBoxRenderer implements ISceneComponent {
  70585. /**
  70586. * The component name helpfull to identify the component in the list of scene components.
  70587. */
  70588. readonly name: string;
  70589. /**
  70590. * The scene the component belongs to.
  70591. */
  70592. scene: Scene;
  70593. /**
  70594. * Color of the bounding box lines placed in front of an object
  70595. */
  70596. frontColor: Color3;
  70597. /**
  70598. * Color of the bounding box lines placed behind an object
  70599. */
  70600. backColor: Color3;
  70601. /**
  70602. * Defines if the renderer should show the back lines or not
  70603. */
  70604. showBackLines: boolean;
  70605. /**
  70606. * Observable raised before rendering a bounding box
  70607. */
  70608. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70609. /**
  70610. * Observable raised after rendering a bounding box
  70611. */
  70612. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70613. /**
  70614. * @hidden
  70615. */
  70616. renderList: SmartArray<BoundingBox>;
  70617. private _colorShader;
  70618. private _vertexBuffers;
  70619. private _indexBuffer;
  70620. private _fillIndexBuffer;
  70621. private _fillIndexData;
  70622. /**
  70623. * Instantiates a new bounding box renderer in a scene.
  70624. * @param scene the scene the renderer renders in
  70625. */
  70626. constructor(scene: Scene);
  70627. /**
  70628. * Registers the component in a given scene
  70629. */
  70630. register(): void;
  70631. private _evaluateSubMesh;
  70632. private _activeMesh;
  70633. private _prepareRessources;
  70634. private _createIndexBuffer;
  70635. /**
  70636. * Rebuilds the elements related to this component in case of
  70637. * context lost for instance.
  70638. */
  70639. rebuild(): void;
  70640. /**
  70641. * @hidden
  70642. */
  70643. reset(): void;
  70644. /**
  70645. * Render the bounding boxes of a specific rendering group
  70646. * @param renderingGroupId defines the rendering group to render
  70647. */
  70648. render(renderingGroupId: number): void;
  70649. /**
  70650. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70651. * @param mesh Define the mesh to render the occlusion bounding box for
  70652. */
  70653. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70654. /**
  70655. * Dispose and release the resources attached to this renderer.
  70656. */
  70657. dispose(): void;
  70658. }
  70659. }
  70660. declare module BABYLON {
  70661. interface Scene {
  70662. /** @hidden (Backing field) */
  70663. _depthRenderer: {
  70664. [id: string]: DepthRenderer;
  70665. };
  70666. /**
  70667. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70668. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70669. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70670. * @returns the created depth renderer
  70671. */
  70672. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70673. /**
  70674. * Disables a depth renderer for a given camera
  70675. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70676. */
  70677. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70678. }
  70679. /**
  70680. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70681. * in several rendering techniques.
  70682. */
  70683. export class DepthRendererSceneComponent implements ISceneComponent {
  70684. /**
  70685. * The component name helpfull to identify the component in the list of scene components.
  70686. */
  70687. readonly name: string;
  70688. /**
  70689. * The scene the component belongs to.
  70690. */
  70691. scene: Scene;
  70692. /**
  70693. * Creates a new instance of the component for the given scene
  70694. * @param scene Defines the scene to register the component in
  70695. */
  70696. constructor(scene: Scene);
  70697. /**
  70698. * Registers the component in a given scene
  70699. */
  70700. register(): void;
  70701. /**
  70702. * Rebuilds the elements related to this component in case of
  70703. * context lost for instance.
  70704. */
  70705. rebuild(): void;
  70706. /**
  70707. * Disposes the component and the associated ressources
  70708. */
  70709. dispose(): void;
  70710. private _gatherRenderTargets;
  70711. private _gatherActiveCameraRenderTargets;
  70712. }
  70713. }
  70714. declare module BABYLON {
  70715. /** @hidden */
  70716. export var fibonacci: {
  70717. name: string;
  70718. shader: string;
  70719. };
  70720. }
  70721. declare module BABYLON {
  70722. /** @hidden */
  70723. export var diffusionProfile: {
  70724. name: string;
  70725. shader: string;
  70726. };
  70727. }
  70728. declare module BABYLON {
  70729. /** @hidden */
  70730. export var subSurfaceScatteringPixelShader: {
  70731. name: string;
  70732. shader: string;
  70733. };
  70734. }
  70735. declare module BABYLON {
  70736. /**
  70737. * Sub surface scattering post process
  70738. */
  70739. export class SubSurfaceScatteringPostProcess extends PostProcess {
  70740. /** @hidden */
  70741. texelWidth: number;
  70742. /** @hidden */
  70743. texelHeight: number;
  70744. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70745. }
  70746. }
  70747. declare module BABYLON {
  70748. /**
  70749. * Contains all parameters needed for the prepass to perform
  70750. * screen space subsurface scattering
  70751. */
  70752. export class SubSurfaceConfiguration {
  70753. private _ssDiffusionS;
  70754. private _ssFilterRadii;
  70755. private _ssDiffusionD;
  70756. /**
  70757. * Diffusion profile color for subsurface scattering
  70758. */
  70759. get ssDiffusionS(): number[];
  70760. /**
  70761. * Diffusion profile max color channel value for subsurface scattering
  70762. */
  70763. get ssDiffusionD(): number[];
  70764. /**
  70765. * Diffusion profile filter radius for subsurface scattering
  70766. */
  70767. get ssFilterRadii(): number[];
  70768. /**
  70769. * Diffusion profile colors for subsurface scattering
  70770. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  70771. * See ...
  70772. * Note that you can only store up to 5 of them
  70773. */
  70774. ssDiffusionProfileColors: Color3[];
  70775. /**
  70776. * Defines the ratio real world => scene units.
  70777. * Used for subsurface scattering
  70778. */
  70779. metersPerUnit: number;
  70780. /**
  70781. * Builds a subsurface configuration object
  70782. * @param scene The scene
  70783. */
  70784. constructor();
  70785. /**
  70786. * Adds a new diffusion profile.
  70787. * Useful for more realistic subsurface scattering on diverse materials.
  70788. * @param color The color of the diffusion profile. Should be the average color of the material.
  70789. * @return The index of the diffusion profile for the material subsurface configuration
  70790. */
  70791. addDiffusionProfile(color: Color3): number;
  70792. /**
  70793. * Deletes all diffusion profiles.
  70794. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  70795. */
  70796. clearAllDiffusionProfiles(): void;
  70797. /**
  70798. * Disposes this object
  70799. */
  70800. dispose(): void;
  70801. /**
  70802. * @hidden
  70803. * https://zero-radiance.github.io/post/sampling-diffusion/
  70804. *
  70805. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  70806. * ------------------------------------------------------------------------------------
  70807. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  70808. * PDF[r, phi, s] = r * R[r, phi, s]
  70809. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  70810. * ------------------------------------------------------------------------------------
  70811. * We importance sample the color channel with the widest scattering distance.
  70812. */
  70813. getDiffusionProfileParameters(color: Color3): number;
  70814. /**
  70815. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  70816. * 'u' is the random number (the value of the CDF): [0, 1).
  70817. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  70818. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  70819. */
  70820. private _sampleBurleyDiffusionProfile;
  70821. }
  70822. }
  70823. declare module BABYLON {
  70824. /**
  70825. * Renders a pre pass of the scene
  70826. * This means every mesh in the scene will be rendered to a render target texture
  70827. * And then this texture will be composited to the rendering canvas with post processes
  70828. * It is necessary for effects like subsurface scattering or deferred shading
  70829. */
  70830. export class PrePassRenderer {
  70831. /** @hidden */
  70832. static _SceneComponentInitialization: (scene: Scene) => void;
  70833. private _scene;
  70834. private _engine;
  70835. private _isDirty;
  70836. /**
  70837. * Number of textures in the multi render target texture where the scene is directly rendered
  70838. */
  70839. readonly mrtCount: number;
  70840. /**
  70841. * The render target where the scene is directly rendered
  70842. */
  70843. prePassRT: MultiRenderTarget;
  70844. private _mrtTypes;
  70845. private _multiRenderAttachments;
  70846. private _defaultAttachments;
  70847. private _clearAttachments;
  70848. private readonly _clearColor;
  70849. /**
  70850. * Image processing post process for composition
  70851. */
  70852. imageProcessingPostProcess: ImageProcessingPostProcess;
  70853. /**
  70854. * Post process for subsurface scattering
  70855. */
  70856. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  70857. /**
  70858. * Configuration for sub surface scattering post process
  70859. */
  70860. subSurfaceConfiguration: SubSurfaceConfiguration;
  70861. private _enabled;
  70862. /**
  70863. * Indicates if the prepass is enabled
  70864. */
  70865. get enabled(): boolean;
  70866. /**
  70867. * How many samples are used for MSAA of the scene render target
  70868. */
  70869. get samples(): number;
  70870. set samples(n: number);
  70871. /**
  70872. * Instanciates a prepass renderer
  70873. * @param scene The scene
  70874. */
  70875. constructor(scene: Scene);
  70876. private _initializeAttachments;
  70877. private _createEffects;
  70878. /**
  70879. * Indicates if rendering a prepass is supported
  70880. */
  70881. get isSupported(): boolean;
  70882. /**
  70883. * Sets the proper output textures to draw in the engine.
  70884. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  70885. */
  70886. bindAttachmentsForEffect(effect: Effect): void;
  70887. /**
  70888. * @hidden
  70889. */
  70890. _beforeCameraDraw(): void;
  70891. /**
  70892. * @hidden
  70893. */
  70894. _afterCameraDraw(): void;
  70895. private _checkRTSize;
  70896. private _bindFrameBuffer;
  70897. /**
  70898. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  70899. */
  70900. clear(): void;
  70901. private _setState;
  70902. private _enable;
  70903. private _disable;
  70904. /**
  70905. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  70906. */
  70907. markAsDirty(): void;
  70908. private _update;
  70909. /**
  70910. * Disposes the prepass renderer.
  70911. */
  70912. dispose(): void;
  70913. }
  70914. }
  70915. declare module BABYLON {
  70916. interface AbstractScene {
  70917. /** @hidden (Backing field) */
  70918. _prePassRenderer: Nullable<PrePassRenderer>;
  70919. /**
  70920. * Gets or Sets the current prepass renderer associated to the scene.
  70921. */
  70922. prePassRenderer: Nullable<PrePassRenderer>;
  70923. /**
  70924. * Enables the prepass and associates it with the scene
  70925. * @returns the PrePassRenderer
  70926. */
  70927. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  70928. /**
  70929. * Disables the prepass associated with the scene
  70930. */
  70931. disablePrePassRenderer(): void;
  70932. }
  70933. /**
  70934. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70935. * in several rendering techniques.
  70936. */
  70937. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  70938. /**
  70939. * The component name helpful to identify the component in the list of scene components.
  70940. */
  70941. readonly name: string;
  70942. /**
  70943. * The scene the component belongs to.
  70944. */
  70945. scene: Scene;
  70946. /**
  70947. * Creates a new instance of the component for the given scene
  70948. * @param scene Defines the scene to register the component in
  70949. */
  70950. constructor(scene: Scene);
  70951. /**
  70952. * Registers the component in a given scene
  70953. */
  70954. register(): void;
  70955. private _beforeCameraDraw;
  70956. private _afterCameraDraw;
  70957. private _beforeClearStage;
  70958. /**
  70959. * Serializes the component data to the specified json object
  70960. * @param serializationObject The object to serialize to
  70961. */
  70962. serialize(serializationObject: any): void;
  70963. /**
  70964. * Adds all the elements from the container to the scene
  70965. * @param container the container holding the elements
  70966. */
  70967. addFromContainer(container: AbstractScene): void;
  70968. /**
  70969. * Removes all the elements in the container from the scene
  70970. * @param container contains the elements to remove
  70971. * @param dispose if the removed element should be disposed (default: false)
  70972. */
  70973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70974. /**
  70975. * Rebuilds the elements related to this component in case of
  70976. * context lost for instance.
  70977. */
  70978. rebuild(): void;
  70979. /**
  70980. * Disposes the component and the associated ressources
  70981. */
  70982. dispose(): void;
  70983. }
  70984. }
  70985. declare module BABYLON {
  70986. /** @hidden */
  70987. export var outlinePixelShader: {
  70988. name: string;
  70989. shader: string;
  70990. };
  70991. }
  70992. declare module BABYLON {
  70993. /** @hidden */
  70994. export var outlineVertexShader: {
  70995. name: string;
  70996. shader: string;
  70997. };
  70998. }
  70999. declare module BABYLON {
  71000. interface Scene {
  71001. /** @hidden */
  71002. _outlineRenderer: OutlineRenderer;
  71003. /**
  71004. * Gets the outline renderer associated with the scene
  71005. * @returns a OutlineRenderer
  71006. */
  71007. getOutlineRenderer(): OutlineRenderer;
  71008. }
  71009. interface AbstractMesh {
  71010. /** @hidden (Backing field) */
  71011. _renderOutline: boolean;
  71012. /**
  71013. * Gets or sets a boolean indicating if the outline must be rendered as well
  71014. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71015. */
  71016. renderOutline: boolean;
  71017. /** @hidden (Backing field) */
  71018. _renderOverlay: boolean;
  71019. /**
  71020. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71021. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71022. */
  71023. renderOverlay: boolean;
  71024. }
  71025. /**
  71026. * This class is responsible to draw bothe outline/overlay of meshes.
  71027. * It should not be used directly but through the available method on mesh.
  71028. */
  71029. export class OutlineRenderer implements ISceneComponent {
  71030. /**
  71031. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71032. */
  71033. private static _StencilReference;
  71034. /**
  71035. * The name of the component. Each component must have a unique name.
  71036. */
  71037. name: string;
  71038. /**
  71039. * The scene the component belongs to.
  71040. */
  71041. scene: Scene;
  71042. /**
  71043. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71044. */
  71045. zOffset: number;
  71046. private _engine;
  71047. private _effect;
  71048. private _cachedDefines;
  71049. private _savedDepthWrite;
  71050. /**
  71051. * Instantiates a new outline renderer. (There could be only one per scene).
  71052. * @param scene Defines the scene it belongs to
  71053. */
  71054. constructor(scene: Scene);
  71055. /**
  71056. * Register the component to one instance of a scene.
  71057. */
  71058. register(): void;
  71059. /**
  71060. * Rebuilds the elements related to this component in case of
  71061. * context lost for instance.
  71062. */
  71063. rebuild(): void;
  71064. /**
  71065. * Disposes the component and the associated ressources.
  71066. */
  71067. dispose(): void;
  71068. /**
  71069. * Renders the outline in the canvas.
  71070. * @param subMesh Defines the sumesh to render
  71071. * @param batch Defines the batch of meshes in case of instances
  71072. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71073. */
  71074. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71075. /**
  71076. * Returns whether or not the outline renderer is ready for a given submesh.
  71077. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71078. * @param subMesh Defines the submesh to check readyness for
  71079. * @param useInstances Defines wheter wee are trying to render instances or not
  71080. * @returns true if ready otherwise false
  71081. */
  71082. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71083. private _beforeRenderingMesh;
  71084. private _afterRenderingMesh;
  71085. }
  71086. }
  71087. declare module BABYLON {
  71088. /**
  71089. * Defines the basic options interface of a Sprite Frame Source Size.
  71090. */
  71091. export interface ISpriteJSONSpriteSourceSize {
  71092. /**
  71093. * number of the original width of the Frame
  71094. */
  71095. w: number;
  71096. /**
  71097. * number of the original height of the Frame
  71098. */
  71099. h: number;
  71100. }
  71101. /**
  71102. * Defines the basic options interface of a Sprite Frame Data.
  71103. */
  71104. export interface ISpriteJSONSpriteFrameData {
  71105. /**
  71106. * number of the x offset of the Frame
  71107. */
  71108. x: number;
  71109. /**
  71110. * number of the y offset of the Frame
  71111. */
  71112. y: number;
  71113. /**
  71114. * number of the width of the Frame
  71115. */
  71116. w: number;
  71117. /**
  71118. * number of the height of the Frame
  71119. */
  71120. h: number;
  71121. }
  71122. /**
  71123. * Defines the basic options interface of a JSON Sprite.
  71124. */
  71125. export interface ISpriteJSONSprite {
  71126. /**
  71127. * string name of the Frame
  71128. */
  71129. filename: string;
  71130. /**
  71131. * ISpriteJSONSpriteFrame basic object of the frame data
  71132. */
  71133. frame: ISpriteJSONSpriteFrameData;
  71134. /**
  71135. * boolean to flag is the frame was rotated.
  71136. */
  71137. rotated: boolean;
  71138. /**
  71139. * boolean to flag is the frame was trimmed.
  71140. */
  71141. trimmed: boolean;
  71142. /**
  71143. * ISpriteJSONSpriteFrame basic object of the source data
  71144. */
  71145. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71146. /**
  71147. * ISpriteJSONSpriteFrame basic object of the source data
  71148. */
  71149. sourceSize: ISpriteJSONSpriteSourceSize;
  71150. }
  71151. /**
  71152. * Defines the basic options interface of a JSON atlas.
  71153. */
  71154. export interface ISpriteJSONAtlas {
  71155. /**
  71156. * Array of objects that contain the frame data.
  71157. */
  71158. frames: Array<ISpriteJSONSprite>;
  71159. /**
  71160. * object basic object containing the sprite meta data.
  71161. */
  71162. meta?: object;
  71163. }
  71164. }
  71165. declare module BABYLON {
  71166. /** @hidden */
  71167. export var spriteMapPixelShader: {
  71168. name: string;
  71169. shader: string;
  71170. };
  71171. }
  71172. declare module BABYLON {
  71173. /** @hidden */
  71174. export var spriteMapVertexShader: {
  71175. name: string;
  71176. shader: string;
  71177. };
  71178. }
  71179. declare module BABYLON {
  71180. /**
  71181. * Defines the basic options interface of a SpriteMap
  71182. */
  71183. export interface ISpriteMapOptions {
  71184. /**
  71185. * Vector2 of the number of cells in the grid.
  71186. */
  71187. stageSize?: Vector2;
  71188. /**
  71189. * Vector2 of the size of the output plane in World Units.
  71190. */
  71191. outputSize?: Vector2;
  71192. /**
  71193. * Vector3 of the position of the output plane in World Units.
  71194. */
  71195. outputPosition?: Vector3;
  71196. /**
  71197. * Vector3 of the rotation of the output plane.
  71198. */
  71199. outputRotation?: Vector3;
  71200. /**
  71201. * number of layers that the system will reserve in resources.
  71202. */
  71203. layerCount?: number;
  71204. /**
  71205. * number of max animation frames a single cell will reserve in resources.
  71206. */
  71207. maxAnimationFrames?: number;
  71208. /**
  71209. * number cell index of the base tile when the system compiles.
  71210. */
  71211. baseTile?: number;
  71212. /**
  71213. * boolean flip the sprite after its been repositioned by the framing data.
  71214. */
  71215. flipU?: boolean;
  71216. /**
  71217. * Vector3 scalar of the global RGB values of the SpriteMap.
  71218. */
  71219. colorMultiply?: Vector3;
  71220. }
  71221. /**
  71222. * Defines the IDisposable interface in order to be cleanable from resources.
  71223. */
  71224. export interface ISpriteMap extends IDisposable {
  71225. /**
  71226. * String name of the SpriteMap.
  71227. */
  71228. name: string;
  71229. /**
  71230. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71231. */
  71232. atlasJSON: ISpriteJSONAtlas;
  71233. /**
  71234. * Texture of the SpriteMap.
  71235. */
  71236. spriteSheet: Texture;
  71237. /**
  71238. * The parameters to initialize the SpriteMap with.
  71239. */
  71240. options: ISpriteMapOptions;
  71241. }
  71242. /**
  71243. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71244. */
  71245. export class SpriteMap implements ISpriteMap {
  71246. /** The Name of the spriteMap */
  71247. name: string;
  71248. /** The JSON file with the frame and meta data */
  71249. atlasJSON: ISpriteJSONAtlas;
  71250. /** The systems Sprite Sheet Texture */
  71251. spriteSheet: Texture;
  71252. /** Arguments passed with the Constructor */
  71253. options: ISpriteMapOptions;
  71254. /** Public Sprite Storage array, parsed from atlasJSON */
  71255. sprites: Array<ISpriteJSONSprite>;
  71256. /** Returns the Number of Sprites in the System */
  71257. get spriteCount(): number;
  71258. /** Returns the Position of Output Plane*/
  71259. get position(): Vector3;
  71260. /** Returns the Position of Output Plane*/
  71261. set position(v: Vector3);
  71262. /** Returns the Rotation of Output Plane*/
  71263. get rotation(): Vector3;
  71264. /** Returns the Rotation of Output Plane*/
  71265. set rotation(v: Vector3);
  71266. /** Sets the AnimationMap*/
  71267. get animationMap(): RawTexture;
  71268. /** Sets the AnimationMap*/
  71269. set animationMap(v: RawTexture);
  71270. /** Scene that the SpriteMap was created in */
  71271. private _scene;
  71272. /** Texture Buffer of Float32 that holds tile frame data*/
  71273. private _frameMap;
  71274. /** Texture Buffers of Float32 that holds tileMap data*/
  71275. private _tileMaps;
  71276. /** Texture Buffer of Float32 that holds Animation Data*/
  71277. private _animationMap;
  71278. /** Custom ShaderMaterial Central to the System*/
  71279. private _material;
  71280. /** Custom ShaderMaterial Central to the System*/
  71281. private _output;
  71282. /** Systems Time Ticker*/
  71283. private _time;
  71284. /**
  71285. * Creates a new SpriteMap
  71286. * @param name defines the SpriteMaps Name
  71287. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71288. * @param spriteSheet is the Texture that the Sprites are on.
  71289. * @param options a basic deployment configuration
  71290. * @param scene The Scene that the map is deployed on
  71291. */
  71292. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71293. /**
  71294. * Returns tileID location
  71295. * @returns Vector2 the cell position ID
  71296. */
  71297. getTileID(): Vector2;
  71298. /**
  71299. * Gets the UV location of the mouse over the SpriteMap.
  71300. * @returns Vector2 the UV position of the mouse interaction
  71301. */
  71302. getMousePosition(): Vector2;
  71303. /**
  71304. * Creates the "frame" texture Buffer
  71305. * -------------------------------------
  71306. * Structure of frames
  71307. * "filename": "Falling-Water-2.png",
  71308. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71309. * "rotated": true,
  71310. * "trimmed": true,
  71311. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71312. * "sourceSize": {"w":32,"h":32}
  71313. * @returns RawTexture of the frameMap
  71314. */
  71315. private _createFrameBuffer;
  71316. /**
  71317. * Creates the tileMap texture Buffer
  71318. * @param buffer normally and array of numbers, or a false to generate from scratch
  71319. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71320. * @returns RawTexture of the tileMap
  71321. */
  71322. private _createTileBuffer;
  71323. /**
  71324. * Modifies the data of the tileMaps
  71325. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71326. * @param pos is the iVector2 Coordinates of the Tile
  71327. * @param tile The SpriteIndex of the new Tile
  71328. */
  71329. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71330. /**
  71331. * Creates the animationMap texture Buffer
  71332. * @param buffer normally and array of numbers, or a false to generate from scratch
  71333. * @returns RawTexture of the animationMap
  71334. */
  71335. private _createTileAnimationBuffer;
  71336. /**
  71337. * Modifies the data of the animationMap
  71338. * @param cellID is the Index of the Sprite
  71339. * @param _frame is the target Animation frame
  71340. * @param toCell is the Target Index of the next frame of the animation
  71341. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71342. * @param speed is a global scalar of the time variable on the map.
  71343. */
  71344. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71345. /**
  71346. * Exports the .tilemaps file
  71347. */
  71348. saveTileMaps(): void;
  71349. /**
  71350. * Imports the .tilemaps file
  71351. * @param url of the .tilemaps file
  71352. */
  71353. loadTileMaps(url: string): void;
  71354. /**
  71355. * Release associated resources
  71356. */
  71357. dispose(): void;
  71358. }
  71359. }
  71360. declare module BABYLON {
  71361. /**
  71362. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71363. * @see https://doc.babylonjs.com/babylon101/sprites
  71364. */
  71365. export class SpritePackedManager extends SpriteManager {
  71366. /** defines the packed manager's name */
  71367. name: string;
  71368. /**
  71369. * Creates a new sprite manager from a packed sprite sheet
  71370. * @param name defines the manager's name
  71371. * @param imgUrl defines the sprite sheet url
  71372. * @param capacity defines the maximum allowed number of sprites
  71373. * @param scene defines the hosting scene
  71374. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71375. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71376. * @param samplingMode defines the smapling mode to use with spritesheet
  71377. * @param fromPacked set to true; do not alter
  71378. */
  71379. constructor(
  71380. /** defines the packed manager's name */
  71381. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71382. }
  71383. }
  71384. declare module BABYLON {
  71385. /**
  71386. * Defines the list of states available for a task inside a AssetsManager
  71387. */
  71388. export enum AssetTaskState {
  71389. /**
  71390. * Initialization
  71391. */
  71392. INIT = 0,
  71393. /**
  71394. * Running
  71395. */
  71396. RUNNING = 1,
  71397. /**
  71398. * Done
  71399. */
  71400. DONE = 2,
  71401. /**
  71402. * Error
  71403. */
  71404. ERROR = 3
  71405. }
  71406. /**
  71407. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71408. */
  71409. export abstract class AbstractAssetTask {
  71410. /**
  71411. * Task name
  71412. */ name: string;
  71413. /**
  71414. * Callback called when the task is successful
  71415. */
  71416. onSuccess: (task: any) => void;
  71417. /**
  71418. * Callback called when the task is not successful
  71419. */
  71420. onError: (task: any, message?: string, exception?: any) => void;
  71421. /**
  71422. * Creates a new AssetsManager
  71423. * @param name defines the name of the task
  71424. */
  71425. constructor(
  71426. /**
  71427. * Task name
  71428. */ name: string);
  71429. private _isCompleted;
  71430. private _taskState;
  71431. private _errorObject;
  71432. /**
  71433. * Get if the task is completed
  71434. */
  71435. get isCompleted(): boolean;
  71436. /**
  71437. * Gets the current state of the task
  71438. */
  71439. get taskState(): AssetTaskState;
  71440. /**
  71441. * Gets the current error object (if task is in error)
  71442. */
  71443. get errorObject(): {
  71444. message?: string;
  71445. exception?: any;
  71446. };
  71447. /**
  71448. * Internal only
  71449. * @hidden
  71450. */
  71451. _setErrorObject(message?: string, exception?: any): void;
  71452. /**
  71453. * Execute the current task
  71454. * @param scene defines the scene where you want your assets to be loaded
  71455. * @param onSuccess is a callback called when the task is successfully executed
  71456. * @param onError is a callback called if an error occurs
  71457. */
  71458. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71459. /**
  71460. * Execute the current task
  71461. * @param scene defines the scene where you want your assets to be loaded
  71462. * @param onSuccess is a callback called when the task is successfully executed
  71463. * @param onError is a callback called if an error occurs
  71464. */
  71465. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71466. /**
  71467. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71468. * This can be used with failed tasks that have the reason for failure fixed.
  71469. */
  71470. reset(): void;
  71471. private onErrorCallback;
  71472. private onDoneCallback;
  71473. }
  71474. /**
  71475. * Define the interface used by progress events raised during assets loading
  71476. */
  71477. export interface IAssetsProgressEvent {
  71478. /**
  71479. * Defines the number of remaining tasks to process
  71480. */
  71481. remainingCount: number;
  71482. /**
  71483. * Defines the total number of tasks
  71484. */
  71485. totalCount: number;
  71486. /**
  71487. * Defines the task that was just processed
  71488. */
  71489. task: AbstractAssetTask;
  71490. }
  71491. /**
  71492. * Class used to share progress information about assets loading
  71493. */
  71494. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71495. /**
  71496. * Defines the number of remaining tasks to process
  71497. */
  71498. remainingCount: number;
  71499. /**
  71500. * Defines the total number of tasks
  71501. */
  71502. totalCount: number;
  71503. /**
  71504. * Defines the task that was just processed
  71505. */
  71506. task: AbstractAssetTask;
  71507. /**
  71508. * Creates a AssetsProgressEvent
  71509. * @param remainingCount defines the number of remaining tasks to process
  71510. * @param totalCount defines the total number of tasks
  71511. * @param task defines the task that was just processed
  71512. */
  71513. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71514. }
  71515. /**
  71516. * Define a task used by AssetsManager to load meshes
  71517. */
  71518. export class MeshAssetTask extends AbstractAssetTask {
  71519. /**
  71520. * Defines the name of the task
  71521. */
  71522. name: string;
  71523. /**
  71524. * Defines the list of mesh's names you want to load
  71525. */
  71526. meshesNames: any;
  71527. /**
  71528. * Defines the root url to use as a base to load your meshes and associated resources
  71529. */
  71530. rootUrl: string;
  71531. /**
  71532. * Defines the filename or File of the scene to load from
  71533. */
  71534. sceneFilename: string | File;
  71535. /**
  71536. * Gets the list of loaded meshes
  71537. */
  71538. loadedMeshes: Array<AbstractMesh>;
  71539. /**
  71540. * Gets the list of loaded particle systems
  71541. */
  71542. loadedParticleSystems: Array<IParticleSystem>;
  71543. /**
  71544. * Gets the list of loaded skeletons
  71545. */
  71546. loadedSkeletons: Array<Skeleton>;
  71547. /**
  71548. * Gets the list of loaded animation groups
  71549. */
  71550. loadedAnimationGroups: Array<AnimationGroup>;
  71551. /**
  71552. * Callback called when the task is successful
  71553. */
  71554. onSuccess: (task: MeshAssetTask) => void;
  71555. /**
  71556. * Callback called when the task is successful
  71557. */
  71558. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71559. /**
  71560. * Creates a new MeshAssetTask
  71561. * @param name defines the name of the task
  71562. * @param meshesNames defines the list of mesh's names you want to load
  71563. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71564. * @param sceneFilename defines the filename or File of the scene to load from
  71565. */
  71566. constructor(
  71567. /**
  71568. * Defines the name of the task
  71569. */
  71570. name: string,
  71571. /**
  71572. * Defines the list of mesh's names you want to load
  71573. */
  71574. meshesNames: any,
  71575. /**
  71576. * Defines the root url to use as a base to load your meshes and associated resources
  71577. */
  71578. rootUrl: string,
  71579. /**
  71580. * Defines the filename or File of the scene to load from
  71581. */
  71582. sceneFilename: string | File);
  71583. /**
  71584. * Execute the current task
  71585. * @param scene defines the scene where you want your assets to be loaded
  71586. * @param onSuccess is a callback called when the task is successfully executed
  71587. * @param onError is a callback called if an error occurs
  71588. */
  71589. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71590. }
  71591. /**
  71592. * Define a task used by AssetsManager to load text content
  71593. */
  71594. export class TextFileAssetTask extends AbstractAssetTask {
  71595. /**
  71596. * Defines the name of the task
  71597. */
  71598. name: string;
  71599. /**
  71600. * Defines the location of the file to load
  71601. */
  71602. url: string;
  71603. /**
  71604. * Gets the loaded text string
  71605. */
  71606. text: string;
  71607. /**
  71608. * Callback called when the task is successful
  71609. */
  71610. onSuccess: (task: TextFileAssetTask) => void;
  71611. /**
  71612. * Callback called when the task is successful
  71613. */
  71614. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71615. /**
  71616. * Creates a new TextFileAssetTask object
  71617. * @param name defines the name of the task
  71618. * @param url defines the location of the file to load
  71619. */
  71620. constructor(
  71621. /**
  71622. * Defines the name of the task
  71623. */
  71624. name: string,
  71625. /**
  71626. * Defines the location of the file to load
  71627. */
  71628. url: string);
  71629. /**
  71630. * Execute the current task
  71631. * @param scene defines the scene where you want your assets to be loaded
  71632. * @param onSuccess is a callback called when the task is successfully executed
  71633. * @param onError is a callback called if an error occurs
  71634. */
  71635. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71636. }
  71637. /**
  71638. * Define a task used by AssetsManager to load binary data
  71639. */
  71640. export class BinaryFileAssetTask extends AbstractAssetTask {
  71641. /**
  71642. * Defines the name of the task
  71643. */
  71644. name: string;
  71645. /**
  71646. * Defines the location of the file to load
  71647. */
  71648. url: string;
  71649. /**
  71650. * Gets the lodaded data (as an array buffer)
  71651. */
  71652. data: ArrayBuffer;
  71653. /**
  71654. * Callback called when the task is successful
  71655. */
  71656. onSuccess: (task: BinaryFileAssetTask) => void;
  71657. /**
  71658. * Callback called when the task is successful
  71659. */
  71660. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71661. /**
  71662. * Creates a new BinaryFileAssetTask object
  71663. * @param name defines the name of the new task
  71664. * @param url defines the location of the file to load
  71665. */
  71666. constructor(
  71667. /**
  71668. * Defines the name of the task
  71669. */
  71670. name: string,
  71671. /**
  71672. * Defines the location of the file to load
  71673. */
  71674. url: string);
  71675. /**
  71676. * Execute the current task
  71677. * @param scene defines the scene where you want your assets to be loaded
  71678. * @param onSuccess is a callback called when the task is successfully executed
  71679. * @param onError is a callback called if an error occurs
  71680. */
  71681. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71682. }
  71683. /**
  71684. * Define a task used by AssetsManager to load images
  71685. */
  71686. export class ImageAssetTask extends AbstractAssetTask {
  71687. /**
  71688. * Defines the name of the task
  71689. */
  71690. name: string;
  71691. /**
  71692. * Defines the location of the image to load
  71693. */
  71694. url: string;
  71695. /**
  71696. * Gets the loaded images
  71697. */
  71698. image: HTMLImageElement;
  71699. /**
  71700. * Callback called when the task is successful
  71701. */
  71702. onSuccess: (task: ImageAssetTask) => void;
  71703. /**
  71704. * Callback called when the task is successful
  71705. */
  71706. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71707. /**
  71708. * Creates a new ImageAssetTask
  71709. * @param name defines the name of the task
  71710. * @param url defines the location of the image to load
  71711. */
  71712. constructor(
  71713. /**
  71714. * Defines the name of the task
  71715. */
  71716. name: string,
  71717. /**
  71718. * Defines the location of the image to load
  71719. */
  71720. url: string);
  71721. /**
  71722. * Execute the current task
  71723. * @param scene defines the scene where you want your assets to be loaded
  71724. * @param onSuccess is a callback called when the task is successfully executed
  71725. * @param onError is a callback called if an error occurs
  71726. */
  71727. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71728. }
  71729. /**
  71730. * Defines the interface used by texture loading tasks
  71731. */
  71732. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71733. /**
  71734. * Gets the loaded texture
  71735. */
  71736. texture: TEX;
  71737. }
  71738. /**
  71739. * Define a task used by AssetsManager to load 2D textures
  71740. */
  71741. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71742. /**
  71743. * Defines the name of the task
  71744. */
  71745. name: string;
  71746. /**
  71747. * Defines the location of the file to load
  71748. */
  71749. url: string;
  71750. /**
  71751. * Defines if mipmap should not be generated (default is false)
  71752. */
  71753. noMipmap?: boolean | undefined;
  71754. /**
  71755. * Defines if texture must be inverted on Y axis (default is true)
  71756. */
  71757. invertY: boolean;
  71758. /**
  71759. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71760. */
  71761. samplingMode: number;
  71762. /**
  71763. * Gets the loaded texture
  71764. */
  71765. texture: Texture;
  71766. /**
  71767. * Callback called when the task is successful
  71768. */
  71769. onSuccess: (task: TextureAssetTask) => void;
  71770. /**
  71771. * Callback called when the task is successful
  71772. */
  71773. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71774. /**
  71775. * Creates a new TextureAssetTask object
  71776. * @param name defines the name of the task
  71777. * @param url defines the location of the file to load
  71778. * @param noMipmap defines if mipmap should not be generated (default is false)
  71779. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71780. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71781. */
  71782. constructor(
  71783. /**
  71784. * Defines the name of the task
  71785. */
  71786. name: string,
  71787. /**
  71788. * Defines the location of the file to load
  71789. */
  71790. url: string,
  71791. /**
  71792. * Defines if mipmap should not be generated (default is false)
  71793. */
  71794. noMipmap?: boolean | undefined,
  71795. /**
  71796. * Defines if texture must be inverted on Y axis (default is true)
  71797. */
  71798. invertY?: boolean,
  71799. /**
  71800. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71801. */
  71802. samplingMode?: number);
  71803. /**
  71804. * Execute the current task
  71805. * @param scene defines the scene where you want your assets to be loaded
  71806. * @param onSuccess is a callback called when the task is successfully executed
  71807. * @param onError is a callback called if an error occurs
  71808. */
  71809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71810. }
  71811. /**
  71812. * Define a task used by AssetsManager to load cube textures
  71813. */
  71814. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71815. /**
  71816. * Defines the name of the task
  71817. */
  71818. name: string;
  71819. /**
  71820. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71821. */
  71822. url: string;
  71823. /**
  71824. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71825. */
  71826. extensions?: string[] | undefined;
  71827. /**
  71828. * Defines if mipmaps should not be generated (default is false)
  71829. */
  71830. noMipmap?: boolean | undefined;
  71831. /**
  71832. * Defines the explicit list of files (undefined by default)
  71833. */
  71834. files?: string[] | undefined;
  71835. /**
  71836. * Gets the loaded texture
  71837. */
  71838. texture: CubeTexture;
  71839. /**
  71840. * Callback called when the task is successful
  71841. */
  71842. onSuccess: (task: CubeTextureAssetTask) => void;
  71843. /**
  71844. * Callback called when the task is successful
  71845. */
  71846. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71847. /**
  71848. * Creates a new CubeTextureAssetTask
  71849. * @param name defines the name of the task
  71850. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71851. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71852. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71853. * @param files defines the explicit list of files (undefined by default)
  71854. */
  71855. constructor(
  71856. /**
  71857. * Defines the name of the task
  71858. */
  71859. name: string,
  71860. /**
  71861. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71862. */
  71863. url: string,
  71864. /**
  71865. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71866. */
  71867. extensions?: string[] | undefined,
  71868. /**
  71869. * Defines if mipmaps should not be generated (default is false)
  71870. */
  71871. noMipmap?: boolean | undefined,
  71872. /**
  71873. * Defines the explicit list of files (undefined by default)
  71874. */
  71875. files?: string[] | undefined);
  71876. /**
  71877. * Execute the current task
  71878. * @param scene defines the scene where you want your assets to be loaded
  71879. * @param onSuccess is a callback called when the task is successfully executed
  71880. * @param onError is a callback called if an error occurs
  71881. */
  71882. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71883. }
  71884. /**
  71885. * Define a task used by AssetsManager to load HDR cube textures
  71886. */
  71887. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71888. /**
  71889. * Defines the name of the task
  71890. */
  71891. name: string;
  71892. /**
  71893. * Defines the location of the file to load
  71894. */
  71895. url: string;
  71896. /**
  71897. * Defines the desired size (the more it increases the longer the generation will be)
  71898. */
  71899. size: number;
  71900. /**
  71901. * Defines if mipmaps should not be generated (default is false)
  71902. */
  71903. noMipmap: boolean;
  71904. /**
  71905. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71906. */
  71907. generateHarmonics: boolean;
  71908. /**
  71909. * 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)
  71910. */
  71911. gammaSpace: boolean;
  71912. /**
  71913. * Internal Use Only
  71914. */
  71915. reserved: boolean;
  71916. /**
  71917. * Gets the loaded texture
  71918. */
  71919. texture: HDRCubeTexture;
  71920. /**
  71921. * Callback called when the task is successful
  71922. */
  71923. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71924. /**
  71925. * Callback called when the task is successful
  71926. */
  71927. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71928. /**
  71929. * Creates a new HDRCubeTextureAssetTask object
  71930. * @param name defines the name of the task
  71931. * @param url defines the location of the file to load
  71932. * @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.
  71933. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71934. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71935. * @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)
  71936. * @param reserved Internal use only
  71937. */
  71938. constructor(
  71939. /**
  71940. * Defines the name of the task
  71941. */
  71942. name: string,
  71943. /**
  71944. * Defines the location of the file to load
  71945. */
  71946. url: string,
  71947. /**
  71948. * Defines the desired size (the more it increases the longer the generation will be)
  71949. */
  71950. size: number,
  71951. /**
  71952. * Defines if mipmaps should not be generated (default is false)
  71953. */
  71954. noMipmap?: boolean,
  71955. /**
  71956. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71957. */
  71958. generateHarmonics?: boolean,
  71959. /**
  71960. * 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)
  71961. */
  71962. gammaSpace?: boolean,
  71963. /**
  71964. * Internal Use Only
  71965. */
  71966. reserved?: boolean);
  71967. /**
  71968. * Execute the current task
  71969. * @param scene defines the scene where you want your assets to be loaded
  71970. * @param onSuccess is a callback called when the task is successfully executed
  71971. * @param onError is a callback called if an error occurs
  71972. */
  71973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71974. }
  71975. /**
  71976. * Define a task used by AssetsManager to load Equirectangular cube textures
  71977. */
  71978. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71979. /**
  71980. * Defines the name of the task
  71981. */
  71982. name: string;
  71983. /**
  71984. * Defines the location of the file to load
  71985. */
  71986. url: string;
  71987. /**
  71988. * Defines the desired size (the more it increases the longer the generation will be)
  71989. */
  71990. size: number;
  71991. /**
  71992. * Defines if mipmaps should not be generated (default is false)
  71993. */
  71994. noMipmap: boolean;
  71995. /**
  71996. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71997. * but the standard material would require them in Gamma space) (default is true)
  71998. */
  71999. gammaSpace: boolean;
  72000. /**
  72001. * Gets the loaded texture
  72002. */
  72003. texture: EquiRectangularCubeTexture;
  72004. /**
  72005. * Callback called when the task is successful
  72006. */
  72007. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72008. /**
  72009. * Callback called when the task is successful
  72010. */
  72011. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72012. /**
  72013. * Creates a new EquiRectangularCubeTextureAssetTask object
  72014. * @param name defines the name of the task
  72015. * @param url defines the location of the file to load
  72016. * @param size defines the desired size (the more it increases the longer the generation will be)
  72017. * If the size is omitted this implies you are using a preprocessed cubemap.
  72018. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72019. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72020. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72021. * (default is true)
  72022. */
  72023. constructor(
  72024. /**
  72025. * Defines the name of the task
  72026. */
  72027. name: string,
  72028. /**
  72029. * Defines the location of the file to load
  72030. */
  72031. url: string,
  72032. /**
  72033. * Defines the desired size (the more it increases the longer the generation will be)
  72034. */
  72035. size: number,
  72036. /**
  72037. * Defines if mipmaps should not be generated (default is false)
  72038. */
  72039. noMipmap?: boolean,
  72040. /**
  72041. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72042. * but the standard material would require them in Gamma space) (default is true)
  72043. */
  72044. gammaSpace?: boolean);
  72045. /**
  72046. * Execute the current task
  72047. * @param scene defines the scene where you want your assets to be loaded
  72048. * @param onSuccess is a callback called when the task is successfully executed
  72049. * @param onError is a callback called if an error occurs
  72050. */
  72051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72052. }
  72053. /**
  72054. * This class can be used to easily import assets into a scene
  72055. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72056. */
  72057. export class AssetsManager {
  72058. private _scene;
  72059. private _isLoading;
  72060. protected _tasks: AbstractAssetTask[];
  72061. protected _waitingTasksCount: number;
  72062. protected _totalTasksCount: number;
  72063. /**
  72064. * Callback called when all tasks are processed
  72065. */
  72066. onFinish: (tasks: AbstractAssetTask[]) => void;
  72067. /**
  72068. * Callback called when a task is successful
  72069. */
  72070. onTaskSuccess: (task: AbstractAssetTask) => void;
  72071. /**
  72072. * Callback called when a task had an error
  72073. */
  72074. onTaskError: (task: AbstractAssetTask) => void;
  72075. /**
  72076. * Callback called when a task is done (whatever the result is)
  72077. */
  72078. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72079. /**
  72080. * Observable called when all tasks are processed
  72081. */
  72082. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72083. /**
  72084. * Observable called when a task had an error
  72085. */
  72086. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72087. /**
  72088. * Observable called when all tasks were executed
  72089. */
  72090. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72091. /**
  72092. * Observable called when a task is done (whatever the result is)
  72093. */
  72094. onProgressObservable: Observable<IAssetsProgressEvent>;
  72095. /**
  72096. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72097. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72098. */
  72099. useDefaultLoadingScreen: boolean;
  72100. /**
  72101. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72102. * when all assets have been downloaded.
  72103. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72104. */
  72105. autoHideLoadingUI: boolean;
  72106. /**
  72107. * Creates a new AssetsManager
  72108. * @param scene defines the scene to work on
  72109. */
  72110. constructor(scene: Scene);
  72111. /**
  72112. * Add a MeshAssetTask to the list of active tasks
  72113. * @param taskName defines the name of the new task
  72114. * @param meshesNames defines the name of meshes to load
  72115. * @param rootUrl defines the root url to use to locate files
  72116. * @param sceneFilename defines the filename of the scene file
  72117. * @returns a new MeshAssetTask object
  72118. */
  72119. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72120. /**
  72121. * Add a TextFileAssetTask to the list of active tasks
  72122. * @param taskName defines the name of the new task
  72123. * @param url defines the url of the file to load
  72124. * @returns a new TextFileAssetTask object
  72125. */
  72126. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72127. /**
  72128. * Add a BinaryFileAssetTask to the list of active tasks
  72129. * @param taskName defines the name of the new task
  72130. * @param url defines the url of the file to load
  72131. * @returns a new BinaryFileAssetTask object
  72132. */
  72133. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72134. /**
  72135. * Add a ImageAssetTask to the list of active tasks
  72136. * @param taskName defines the name of the new task
  72137. * @param url defines the url of the file to load
  72138. * @returns a new ImageAssetTask object
  72139. */
  72140. addImageTask(taskName: string, url: string): ImageAssetTask;
  72141. /**
  72142. * Add a TextureAssetTask to the list of active tasks
  72143. * @param taskName defines the name of the new task
  72144. * @param url defines the url of the file to load
  72145. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72146. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72147. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72148. * @returns a new TextureAssetTask object
  72149. */
  72150. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72151. /**
  72152. * Add a CubeTextureAssetTask to the list of active tasks
  72153. * @param taskName defines the name of the new task
  72154. * @param url defines the url of the file to load
  72155. * @param extensions defines the extension to use to load the cube map (can be null)
  72156. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72157. * @param files defines the list of files to load (can be null)
  72158. * @returns a new CubeTextureAssetTask object
  72159. */
  72160. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72161. /**
  72162. *
  72163. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72164. * @param taskName defines the name of the new task
  72165. * @param url defines the url of the file to load
  72166. * @param size defines the size you want for the cubemap (can be null)
  72167. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72168. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72169. * @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)
  72170. * @param reserved Internal use only
  72171. * @returns a new HDRCubeTextureAssetTask object
  72172. */
  72173. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72174. /**
  72175. *
  72176. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72177. * @param taskName defines the name of the new task
  72178. * @param url defines the url of the file to load
  72179. * @param size defines the size you want for the cubemap (can be null)
  72180. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72181. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72182. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72183. * @returns a new EquiRectangularCubeTextureAssetTask object
  72184. */
  72185. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72186. /**
  72187. * Remove a task from the assets manager.
  72188. * @param task the task to remove
  72189. */
  72190. removeTask(task: AbstractAssetTask): void;
  72191. private _decreaseWaitingTasksCount;
  72192. private _runTask;
  72193. /**
  72194. * Reset the AssetsManager and remove all tasks
  72195. * @return the current instance of the AssetsManager
  72196. */
  72197. reset(): AssetsManager;
  72198. /**
  72199. * Start the loading process
  72200. * @return the current instance of the AssetsManager
  72201. */
  72202. load(): AssetsManager;
  72203. /**
  72204. * Start the loading process as an async operation
  72205. * @return a promise returning the list of failed tasks
  72206. */
  72207. loadAsync(): Promise<void>;
  72208. }
  72209. }
  72210. declare module BABYLON {
  72211. /**
  72212. * Wrapper class for promise with external resolve and reject.
  72213. */
  72214. export class Deferred<T> {
  72215. /**
  72216. * The promise associated with this deferred object.
  72217. */
  72218. readonly promise: Promise<T>;
  72219. private _resolve;
  72220. private _reject;
  72221. /**
  72222. * The resolve method of the promise associated with this deferred object.
  72223. */
  72224. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72225. /**
  72226. * The reject method of the promise associated with this deferred object.
  72227. */
  72228. get reject(): (reason?: any) => void;
  72229. /**
  72230. * Constructor for this deferred object.
  72231. */
  72232. constructor();
  72233. }
  72234. }
  72235. declare module BABYLON {
  72236. /**
  72237. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72238. */
  72239. export class MeshExploder {
  72240. private _centerMesh;
  72241. private _meshes;
  72242. private _meshesOrigins;
  72243. private _toCenterVectors;
  72244. private _scaledDirection;
  72245. private _newPosition;
  72246. private _centerPosition;
  72247. /**
  72248. * Explodes meshes from a center mesh.
  72249. * @param meshes The meshes to explode.
  72250. * @param centerMesh The mesh to be center of explosion.
  72251. */
  72252. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72253. private _setCenterMesh;
  72254. /**
  72255. * Get class name
  72256. * @returns "MeshExploder"
  72257. */
  72258. getClassName(): string;
  72259. /**
  72260. * "Exploded meshes"
  72261. * @returns Array of meshes with the centerMesh at index 0.
  72262. */
  72263. getMeshes(): Array<Mesh>;
  72264. /**
  72265. * Explodes meshes giving a specific direction
  72266. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72267. */
  72268. explode(direction?: number): void;
  72269. }
  72270. }
  72271. declare module BABYLON {
  72272. /**
  72273. * Class used to help managing file picking and drag'n'drop
  72274. */
  72275. export class FilesInput {
  72276. /**
  72277. * List of files ready to be loaded
  72278. */
  72279. static get FilesToLoad(): {
  72280. [key: string]: File;
  72281. };
  72282. /**
  72283. * Callback called when a file is processed
  72284. */
  72285. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72286. private _engine;
  72287. private _currentScene;
  72288. private _sceneLoadedCallback;
  72289. private _progressCallback;
  72290. private _additionalRenderLoopLogicCallback;
  72291. private _textureLoadingCallback;
  72292. private _startingProcessingFilesCallback;
  72293. private _onReloadCallback;
  72294. private _errorCallback;
  72295. private _elementToMonitor;
  72296. private _sceneFileToLoad;
  72297. private _filesToLoad;
  72298. /**
  72299. * Creates a new FilesInput
  72300. * @param engine defines the rendering engine
  72301. * @param scene defines the hosting scene
  72302. * @param sceneLoadedCallback callback called when scene is loaded
  72303. * @param progressCallback callback called to track progress
  72304. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72305. * @param textureLoadingCallback callback called when a texture is loading
  72306. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72307. * @param onReloadCallback callback called when a reload is requested
  72308. * @param errorCallback callback call if an error occurs
  72309. */
  72310. 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>);
  72311. private _dragEnterHandler;
  72312. private _dragOverHandler;
  72313. private _dropHandler;
  72314. /**
  72315. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72316. * @param elementToMonitor defines the DOM element to track
  72317. */
  72318. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72319. /** Gets the current list of files to load */
  72320. get filesToLoad(): File[];
  72321. /**
  72322. * Release all associated resources
  72323. */
  72324. dispose(): void;
  72325. private renderFunction;
  72326. private drag;
  72327. private drop;
  72328. private _traverseFolder;
  72329. private _processFiles;
  72330. /**
  72331. * Load files from a drop event
  72332. * @param event defines the drop event to use as source
  72333. */
  72334. loadFiles(event: any): void;
  72335. private _processReload;
  72336. /**
  72337. * Reload the current scene from the loaded files
  72338. */
  72339. reload(): void;
  72340. }
  72341. }
  72342. declare module BABYLON {
  72343. /**
  72344. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72345. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72346. */
  72347. export class SceneOptimization {
  72348. /**
  72349. * Defines the priority of this optimization (0 by default which means first in the list)
  72350. */
  72351. priority: number;
  72352. /**
  72353. * Gets a string describing the action executed by the current optimization
  72354. * @returns description string
  72355. */
  72356. getDescription(): string;
  72357. /**
  72358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72359. * @param scene defines the current scene where to apply this optimization
  72360. * @param optimizer defines the current optimizer
  72361. * @returns true if everything that can be done was applied
  72362. */
  72363. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72364. /**
  72365. * Creates the SceneOptimization object
  72366. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72367. * @param desc defines the description associated with the optimization
  72368. */
  72369. constructor(
  72370. /**
  72371. * Defines the priority of this optimization (0 by default which means first in the list)
  72372. */
  72373. priority?: number);
  72374. }
  72375. /**
  72376. * Defines an optimization used to reduce the size of render target textures
  72377. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72378. */
  72379. export class TextureOptimization extends SceneOptimization {
  72380. /**
  72381. * Defines the priority of this optimization (0 by default which means first in the list)
  72382. */
  72383. priority: number;
  72384. /**
  72385. * 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
  72386. */
  72387. maximumSize: number;
  72388. /**
  72389. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72390. */
  72391. step: number;
  72392. /**
  72393. * Gets a string describing the action executed by the current optimization
  72394. * @returns description string
  72395. */
  72396. getDescription(): string;
  72397. /**
  72398. * Creates the TextureOptimization object
  72399. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72400. * @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
  72401. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72402. */
  72403. constructor(
  72404. /**
  72405. * Defines the priority of this optimization (0 by default which means first in the list)
  72406. */
  72407. priority?: number,
  72408. /**
  72409. * 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
  72410. */
  72411. maximumSize?: number,
  72412. /**
  72413. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72414. */
  72415. step?: number);
  72416. /**
  72417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72418. * @param scene defines the current scene where to apply this optimization
  72419. * @param optimizer defines the current optimizer
  72420. * @returns true if everything that can be done was applied
  72421. */
  72422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72423. }
  72424. /**
  72425. * Defines an optimization used to increase or decrease the rendering resolution
  72426. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72427. */
  72428. export class HardwareScalingOptimization extends SceneOptimization {
  72429. /**
  72430. * Defines the priority of this optimization (0 by default which means first in the list)
  72431. */
  72432. priority: number;
  72433. /**
  72434. * Defines the maximum scale to use (2 by default)
  72435. */
  72436. maximumScale: number;
  72437. /**
  72438. * Defines the step to use between two passes (0.5 by default)
  72439. */
  72440. step: number;
  72441. private _currentScale;
  72442. private _directionOffset;
  72443. /**
  72444. * Gets a string describing the action executed by the current optimization
  72445. * @return description string
  72446. */
  72447. getDescription(): string;
  72448. /**
  72449. * Creates the HardwareScalingOptimization object
  72450. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72451. * @param maximumScale defines the maximum scale to use (2 by default)
  72452. * @param step defines the step to use between two passes (0.5 by default)
  72453. */
  72454. constructor(
  72455. /**
  72456. * Defines the priority of this optimization (0 by default which means first in the list)
  72457. */
  72458. priority?: number,
  72459. /**
  72460. * Defines the maximum scale to use (2 by default)
  72461. */
  72462. maximumScale?: number,
  72463. /**
  72464. * Defines the step to use between two passes (0.5 by default)
  72465. */
  72466. step?: number);
  72467. /**
  72468. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72469. * @param scene defines the current scene where to apply this optimization
  72470. * @param optimizer defines the current optimizer
  72471. * @returns true if everything that can be done was applied
  72472. */
  72473. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72474. }
  72475. /**
  72476. * Defines an optimization used to remove shadows
  72477. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72478. */
  72479. export class ShadowsOptimization extends SceneOptimization {
  72480. /**
  72481. * Gets a string describing the action executed by the current optimization
  72482. * @return description string
  72483. */
  72484. getDescription(): string;
  72485. /**
  72486. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72487. * @param scene defines the current scene where to apply this optimization
  72488. * @param optimizer defines the current optimizer
  72489. * @returns true if everything that can be done was applied
  72490. */
  72491. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72492. }
  72493. /**
  72494. * Defines an optimization used to turn post-processes off
  72495. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72496. */
  72497. export class PostProcessesOptimization extends SceneOptimization {
  72498. /**
  72499. * Gets a string describing the action executed by the current optimization
  72500. * @return description string
  72501. */
  72502. getDescription(): string;
  72503. /**
  72504. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72505. * @param scene defines the current scene where to apply this optimization
  72506. * @param optimizer defines the current optimizer
  72507. * @returns true if everything that can be done was applied
  72508. */
  72509. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72510. }
  72511. /**
  72512. * Defines an optimization used to turn lens flares off
  72513. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72514. */
  72515. export class LensFlaresOptimization extends SceneOptimization {
  72516. /**
  72517. * Gets a string describing the action executed by the current optimization
  72518. * @return description string
  72519. */
  72520. getDescription(): string;
  72521. /**
  72522. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72523. * @param scene defines the current scene where to apply this optimization
  72524. * @param optimizer defines the current optimizer
  72525. * @returns true if everything that can be done was applied
  72526. */
  72527. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72528. }
  72529. /**
  72530. * Defines an optimization based on user defined callback.
  72531. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72532. */
  72533. export class CustomOptimization extends SceneOptimization {
  72534. /**
  72535. * Callback called to apply the custom optimization.
  72536. */
  72537. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72538. /**
  72539. * Callback called to get custom description
  72540. */
  72541. onGetDescription: () => string;
  72542. /**
  72543. * Gets a string describing the action executed by the current optimization
  72544. * @returns description string
  72545. */
  72546. getDescription(): string;
  72547. /**
  72548. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72549. * @param scene defines the current scene where to apply this optimization
  72550. * @param optimizer defines the current optimizer
  72551. * @returns true if everything that can be done was applied
  72552. */
  72553. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72554. }
  72555. /**
  72556. * Defines an optimization used to turn particles off
  72557. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72558. */
  72559. export class ParticlesOptimization extends SceneOptimization {
  72560. /**
  72561. * Gets a string describing the action executed by the current optimization
  72562. * @return description string
  72563. */
  72564. getDescription(): string;
  72565. /**
  72566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72567. * @param scene defines the current scene where to apply this optimization
  72568. * @param optimizer defines the current optimizer
  72569. * @returns true if everything that can be done was applied
  72570. */
  72571. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72572. }
  72573. /**
  72574. * Defines an optimization used to turn render targets off
  72575. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72576. */
  72577. export class RenderTargetsOptimization extends SceneOptimization {
  72578. /**
  72579. * Gets a string describing the action executed by the current optimization
  72580. * @return description string
  72581. */
  72582. getDescription(): string;
  72583. /**
  72584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72585. * @param scene defines the current scene where to apply this optimization
  72586. * @param optimizer defines the current optimizer
  72587. * @returns true if everything that can be done was applied
  72588. */
  72589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72590. }
  72591. /**
  72592. * Defines an optimization used to merge meshes with compatible materials
  72593. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72594. */
  72595. export class MergeMeshesOptimization extends SceneOptimization {
  72596. private static _UpdateSelectionTree;
  72597. /**
  72598. * Gets or sets a boolean which defines if optimization octree has to be updated
  72599. */
  72600. static get UpdateSelectionTree(): boolean;
  72601. /**
  72602. * Gets or sets a boolean which defines if optimization octree has to be updated
  72603. */
  72604. static set UpdateSelectionTree(value: boolean);
  72605. /**
  72606. * Gets a string describing the action executed by the current optimization
  72607. * @return description string
  72608. */
  72609. getDescription(): string;
  72610. private _canBeMerged;
  72611. /**
  72612. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72613. * @param scene defines the current scene where to apply this optimization
  72614. * @param optimizer defines the current optimizer
  72615. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72616. * @returns true if everything that can be done was applied
  72617. */
  72618. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72619. }
  72620. /**
  72621. * Defines a list of options used by SceneOptimizer
  72622. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72623. */
  72624. export class SceneOptimizerOptions {
  72625. /**
  72626. * Defines the target frame rate to reach (60 by default)
  72627. */
  72628. targetFrameRate: number;
  72629. /**
  72630. * Defines the interval between two checkes (2000ms by default)
  72631. */
  72632. trackerDuration: number;
  72633. /**
  72634. * Gets the list of optimizations to apply
  72635. */
  72636. optimizations: SceneOptimization[];
  72637. /**
  72638. * Creates a new list of options used by SceneOptimizer
  72639. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72640. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72641. */
  72642. constructor(
  72643. /**
  72644. * Defines the target frame rate to reach (60 by default)
  72645. */
  72646. targetFrameRate?: number,
  72647. /**
  72648. * Defines the interval between two checkes (2000ms by default)
  72649. */
  72650. trackerDuration?: number);
  72651. /**
  72652. * Add a new optimization
  72653. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72654. * @returns the current SceneOptimizerOptions
  72655. */
  72656. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72657. /**
  72658. * Add a new custom optimization
  72659. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72660. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72661. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72662. * @returns the current SceneOptimizerOptions
  72663. */
  72664. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72665. /**
  72666. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72667. * @param targetFrameRate defines the target frame rate (60 by default)
  72668. * @returns a SceneOptimizerOptions object
  72669. */
  72670. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72671. /**
  72672. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72673. * @param targetFrameRate defines the target frame rate (60 by default)
  72674. * @returns a SceneOptimizerOptions object
  72675. */
  72676. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72677. /**
  72678. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72679. * @param targetFrameRate defines the target frame rate (60 by default)
  72680. * @returns a SceneOptimizerOptions object
  72681. */
  72682. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72683. }
  72684. /**
  72685. * Class used to run optimizations in order to reach a target frame rate
  72686. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72687. */
  72688. export class SceneOptimizer implements IDisposable {
  72689. private _isRunning;
  72690. private _options;
  72691. private _scene;
  72692. private _currentPriorityLevel;
  72693. private _targetFrameRate;
  72694. private _trackerDuration;
  72695. private _currentFrameRate;
  72696. private _sceneDisposeObserver;
  72697. private _improvementMode;
  72698. /**
  72699. * Defines an observable called when the optimizer reaches the target frame rate
  72700. */
  72701. onSuccessObservable: Observable<SceneOptimizer>;
  72702. /**
  72703. * Defines an observable called when the optimizer enables an optimization
  72704. */
  72705. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72706. /**
  72707. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72708. */
  72709. onFailureObservable: Observable<SceneOptimizer>;
  72710. /**
  72711. * Gets a boolean indicating if the optimizer is in improvement mode
  72712. */
  72713. get isInImprovementMode(): boolean;
  72714. /**
  72715. * Gets the current priority level (0 at start)
  72716. */
  72717. get currentPriorityLevel(): number;
  72718. /**
  72719. * Gets the current frame rate checked by the SceneOptimizer
  72720. */
  72721. get currentFrameRate(): number;
  72722. /**
  72723. * Gets or sets the current target frame rate (60 by default)
  72724. */
  72725. get targetFrameRate(): number;
  72726. /**
  72727. * Gets or sets the current target frame rate (60 by default)
  72728. */
  72729. set targetFrameRate(value: number);
  72730. /**
  72731. * Gets or sets the current interval between two checks (every 2000ms by default)
  72732. */
  72733. get trackerDuration(): number;
  72734. /**
  72735. * Gets or sets the current interval between two checks (every 2000ms by default)
  72736. */
  72737. set trackerDuration(value: number);
  72738. /**
  72739. * Gets the list of active optimizations
  72740. */
  72741. get optimizations(): SceneOptimization[];
  72742. /**
  72743. * Creates a new SceneOptimizer
  72744. * @param scene defines the scene to work on
  72745. * @param options defines the options to use with the SceneOptimizer
  72746. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72747. * @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)
  72748. */
  72749. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72750. /**
  72751. * Stops the current optimizer
  72752. */
  72753. stop(): void;
  72754. /**
  72755. * Reset the optimizer to initial step (current priority level = 0)
  72756. */
  72757. reset(): void;
  72758. /**
  72759. * Start the optimizer. By default it will try to reach a specific framerate
  72760. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72761. */
  72762. start(): void;
  72763. private _checkCurrentState;
  72764. /**
  72765. * Release all resources
  72766. */
  72767. dispose(): void;
  72768. /**
  72769. * Helper function to create a SceneOptimizer with one single line of code
  72770. * @param scene defines the scene to work on
  72771. * @param options defines the options to use with the SceneOptimizer
  72772. * @param onSuccess defines a callback to call on success
  72773. * @param onFailure defines a callback to call on failure
  72774. * @returns the new SceneOptimizer object
  72775. */
  72776. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72777. }
  72778. }
  72779. declare module BABYLON {
  72780. /**
  72781. * Class used to serialize a scene into a string
  72782. */
  72783. export class SceneSerializer {
  72784. /**
  72785. * Clear cache used by a previous serialization
  72786. */
  72787. static ClearCache(): void;
  72788. /**
  72789. * Serialize a scene into a JSON compatible object
  72790. * @param scene defines the scene to serialize
  72791. * @returns a JSON compatible object
  72792. */
  72793. static Serialize(scene: Scene): any;
  72794. /**
  72795. * Serialize a mesh into a JSON compatible object
  72796. * @param toSerialize defines the mesh to serialize
  72797. * @param withParents defines if parents must be serialized as well
  72798. * @param withChildren defines if children must be serialized as well
  72799. * @returns a JSON compatible object
  72800. */
  72801. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72802. }
  72803. }
  72804. declare module BABYLON {
  72805. /**
  72806. * Class used to host texture specific utilities
  72807. */
  72808. export class TextureTools {
  72809. /**
  72810. * Uses the GPU to create a copy texture rescaled at a given size
  72811. * @param texture Texture to copy from
  72812. * @param width defines the desired width
  72813. * @param height defines the desired height
  72814. * @param useBilinearMode defines if bilinear mode has to be used
  72815. * @return the generated texture
  72816. */
  72817. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72818. }
  72819. }
  72820. declare module BABYLON {
  72821. /**
  72822. * This represents the different options available for the video capture.
  72823. */
  72824. export interface VideoRecorderOptions {
  72825. /** Defines the mime type of the video. */
  72826. mimeType: string;
  72827. /** Defines the FPS the video should be recorded at. */
  72828. fps: number;
  72829. /** Defines the chunk size for the recording data. */
  72830. recordChunckSize: number;
  72831. /** The audio tracks to attach to the recording. */
  72832. audioTracks?: MediaStreamTrack[];
  72833. }
  72834. /**
  72835. * This can help with recording videos from BabylonJS.
  72836. * This is based on the available WebRTC functionalities of the browser.
  72837. *
  72838. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  72839. */
  72840. export class VideoRecorder {
  72841. private static readonly _defaultOptions;
  72842. /**
  72843. * Returns whether or not the VideoRecorder is available in your browser.
  72844. * @param engine Defines the Babylon Engine.
  72845. * @returns true if supported otherwise false.
  72846. */
  72847. static IsSupported(engine: Engine): boolean;
  72848. private readonly _options;
  72849. private _canvas;
  72850. private _mediaRecorder;
  72851. private _recordedChunks;
  72852. private _fileName;
  72853. private _resolve;
  72854. private _reject;
  72855. /**
  72856. * True when a recording is already in progress.
  72857. */
  72858. get isRecording(): boolean;
  72859. /**
  72860. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72861. * @param engine Defines the BabylonJS Engine you wish to record.
  72862. * @param options Defines options that can be used to customize the capture.
  72863. */
  72864. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72865. /**
  72866. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72867. */
  72868. stopRecording(): void;
  72869. /**
  72870. * Starts recording the canvas for a max duration specified in parameters.
  72871. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72872. * If null no automatic download will start and you can rely on the promise to get the data back.
  72873. * @param maxDuration Defines the maximum recording time in seconds.
  72874. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72875. * @return A promise callback at the end of the recording with the video data in Blob.
  72876. */
  72877. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72878. /**
  72879. * Releases internal resources used during the recording.
  72880. */
  72881. dispose(): void;
  72882. private _handleDataAvailable;
  72883. private _handleError;
  72884. private _handleStop;
  72885. }
  72886. }
  72887. declare module BABYLON {
  72888. /**
  72889. * Class containing a set of static utilities functions for screenshots
  72890. */
  72891. export class ScreenshotTools {
  72892. /**
  72893. * Captures a screenshot of the current rendering
  72894. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72895. * @param engine defines the rendering engine
  72896. * @param camera defines the source camera
  72897. * @param size This parameter can be set to a single number or to an object with the
  72898. * following (optional) properties: precision, width, height. If a single number is passed,
  72899. * it will be used for both width and height. If an object is passed, the screenshot size
  72900. * will be derived from the parameters. The precision property is a multiplier allowing
  72901. * rendering at a higher or lower resolution
  72902. * @param successCallback defines the callback receives a single parameter which contains the
  72903. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72904. * src parameter of an <img> to display it
  72905. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72906. * Check your browser for supported MIME types
  72907. */
  72908. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72909. /**
  72910. * Captures a screenshot of the current rendering
  72911. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72912. * @param engine defines the rendering engine
  72913. * @param camera defines the source camera
  72914. * @param size This parameter can be set to a single number or to an object with the
  72915. * following (optional) properties: precision, width, height. If a single number is passed,
  72916. * it will be used for both width and height. If an object is passed, the screenshot size
  72917. * will be derived from the parameters. The precision property is a multiplier allowing
  72918. * rendering at a higher or lower resolution
  72919. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72920. * Check your browser for supported MIME types
  72921. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72922. * to the src parameter of an <img> to display it
  72923. */
  72924. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72925. /**
  72926. * Generates an image screenshot from the specified camera.
  72927. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72928. * @param engine The engine to use for rendering
  72929. * @param camera The camera to use for rendering
  72930. * @param size This parameter can be set to a single number or to an object with the
  72931. * following (optional) properties: precision, width, height. If a single number is passed,
  72932. * it will be used for both width and height. If an object is passed, the screenshot size
  72933. * will be derived from the parameters. The precision property is a multiplier allowing
  72934. * rendering at a higher or lower resolution
  72935. * @param successCallback The callback receives a single parameter which contains the
  72936. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72937. * src parameter of an <img> to display it
  72938. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72939. * Check your browser for supported MIME types
  72940. * @param samples Texture samples (default: 1)
  72941. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72942. * @param fileName A name for for the downloaded file.
  72943. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72944. */
  72945. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72946. /**
  72947. * Generates an image screenshot from the specified camera.
  72948. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72949. * @param engine The engine to use for rendering
  72950. * @param camera The camera to use for rendering
  72951. * @param size This parameter can be set to a single number or to an object with the
  72952. * following (optional) properties: precision, width, height. If a single number is passed,
  72953. * it will be used for both width and height. If an object is passed, the screenshot size
  72954. * will be derived from the parameters. The precision property is a multiplier allowing
  72955. * rendering at a higher or lower resolution
  72956. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72957. * Check your browser for supported MIME types
  72958. * @param samples Texture samples (default: 1)
  72959. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72960. * @param fileName A name for for the downloaded file.
  72961. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72962. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72963. * to the src parameter of an <img> to display it
  72964. */
  72965. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72966. /**
  72967. * Gets height and width for screenshot size
  72968. * @private
  72969. */
  72970. private static _getScreenshotSize;
  72971. }
  72972. }
  72973. declare module BABYLON {
  72974. /**
  72975. * Interface for a data buffer
  72976. */
  72977. export interface IDataBuffer {
  72978. /**
  72979. * Reads bytes from the data buffer.
  72980. * @param byteOffset The byte offset to read
  72981. * @param byteLength The byte length to read
  72982. * @returns A promise that resolves when the bytes are read
  72983. */
  72984. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72985. /**
  72986. * The byte length of the buffer.
  72987. */
  72988. readonly byteLength: number;
  72989. }
  72990. /**
  72991. * Utility class for reading from a data buffer
  72992. */
  72993. export class DataReader {
  72994. /**
  72995. * The data buffer associated with this data reader.
  72996. */
  72997. readonly buffer: IDataBuffer;
  72998. /**
  72999. * The current byte offset from the beginning of the data buffer.
  73000. */
  73001. byteOffset: number;
  73002. private _dataView;
  73003. private _dataByteOffset;
  73004. /**
  73005. * Constructor
  73006. * @param buffer The buffer to read
  73007. */
  73008. constructor(buffer: IDataBuffer);
  73009. /**
  73010. * Loads the given byte length.
  73011. * @param byteLength The byte length to load
  73012. * @returns A promise that resolves when the load is complete
  73013. */
  73014. loadAsync(byteLength: number): Promise<void>;
  73015. /**
  73016. * Read a unsigned 32-bit integer from the currently loaded data range.
  73017. * @returns The 32-bit integer read
  73018. */
  73019. readUint32(): number;
  73020. /**
  73021. * Read a byte array from the currently loaded data range.
  73022. * @param byteLength The byte length to read
  73023. * @returns The byte array read
  73024. */
  73025. readUint8Array(byteLength: number): Uint8Array;
  73026. /**
  73027. * Read a string from the currently loaded data range.
  73028. * @param byteLength The byte length to read
  73029. * @returns The string read
  73030. */
  73031. readString(byteLength: number): string;
  73032. /**
  73033. * Skips the given byte length the currently loaded data range.
  73034. * @param byteLength The byte length to skip
  73035. */
  73036. skipBytes(byteLength: number): void;
  73037. }
  73038. }
  73039. declare module BABYLON {
  73040. /**
  73041. * Class for storing data to local storage if available or in-memory storage otherwise
  73042. */
  73043. export class DataStorage {
  73044. private static _Storage;
  73045. private static _GetStorage;
  73046. /**
  73047. * Reads a string from the data storage
  73048. * @param key The key to read
  73049. * @param defaultValue The value if the key doesn't exist
  73050. * @returns The string value
  73051. */
  73052. static ReadString(key: string, defaultValue: string): string;
  73053. /**
  73054. * Writes a string to the data storage
  73055. * @param key The key to write
  73056. * @param value The value to write
  73057. */
  73058. static WriteString(key: string, value: string): void;
  73059. /**
  73060. * Reads a boolean from the data storage
  73061. * @param key The key to read
  73062. * @param defaultValue The value if the key doesn't exist
  73063. * @returns The boolean value
  73064. */
  73065. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73066. /**
  73067. * Writes a boolean to the data storage
  73068. * @param key The key to write
  73069. * @param value The value to write
  73070. */
  73071. static WriteBoolean(key: string, value: boolean): void;
  73072. /**
  73073. * Reads a number from the data storage
  73074. * @param key The key to read
  73075. * @param defaultValue The value if the key doesn't exist
  73076. * @returns The number value
  73077. */
  73078. static ReadNumber(key: string, defaultValue: number): number;
  73079. /**
  73080. * Writes a number to the data storage
  73081. * @param key The key to write
  73082. * @param value The value to write
  73083. */
  73084. static WriteNumber(key: string, value: number): void;
  73085. }
  73086. }
  73087. declare module BABYLON {
  73088. /**
  73089. * An interface for all Hit test features
  73090. */
  73091. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73092. /**
  73093. * Triggered when new babylon (transformed) hit test results are available
  73094. */
  73095. onHitTestResultObservable: Observable<T[]>;
  73096. }
  73097. /**
  73098. * Options used for hit testing
  73099. */
  73100. export interface IWebXRLegacyHitTestOptions {
  73101. /**
  73102. * Only test when user interacted with the scene. Default - hit test every frame
  73103. */
  73104. testOnPointerDownOnly?: boolean;
  73105. /**
  73106. * The node to use to transform the local results to world coordinates
  73107. */
  73108. worldParentNode?: TransformNode;
  73109. }
  73110. /**
  73111. * Interface defining the babylon result of raycasting/hit-test
  73112. */
  73113. export interface IWebXRLegacyHitResult {
  73114. /**
  73115. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73116. */
  73117. transformationMatrix: Matrix;
  73118. /**
  73119. * The native hit test result
  73120. */
  73121. xrHitResult: XRHitResult | XRHitTestResult;
  73122. }
  73123. /**
  73124. * The currently-working hit-test module.
  73125. * Hit test (or Ray-casting) is used to interact with the real world.
  73126. * For further information read here - https://github.com/immersive-web/hit-test
  73127. */
  73128. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73129. /**
  73130. * options to use when constructing this feature
  73131. */
  73132. readonly options: IWebXRLegacyHitTestOptions;
  73133. private _direction;
  73134. private _mat;
  73135. private _onSelectEnabled;
  73136. private _origin;
  73137. /**
  73138. * The module's name
  73139. */
  73140. static readonly Name: string;
  73141. /**
  73142. * The (Babylon) version of this module.
  73143. * This is an integer representing the implementation version.
  73144. * This number does not correspond to the WebXR specs version
  73145. */
  73146. static readonly Version: number;
  73147. /**
  73148. * Populated with the last native XR Hit Results
  73149. */
  73150. lastNativeXRHitResults: XRHitResult[];
  73151. /**
  73152. * Triggered when new babylon (transformed) hit test results are available
  73153. */
  73154. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73155. /**
  73156. * Creates a new instance of the (legacy version) hit test feature
  73157. * @param _xrSessionManager an instance of WebXRSessionManager
  73158. * @param options options to use when constructing this feature
  73159. */
  73160. constructor(_xrSessionManager: WebXRSessionManager,
  73161. /**
  73162. * options to use when constructing this feature
  73163. */
  73164. options?: IWebXRLegacyHitTestOptions);
  73165. /**
  73166. * execute a hit test with an XR Ray
  73167. *
  73168. * @param xrSession a native xrSession that will execute this hit test
  73169. * @param xrRay the ray (position and direction) to use for ray-casting
  73170. * @param referenceSpace native XR reference space to use for the hit-test
  73171. * @param filter filter function that will filter the results
  73172. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73173. */
  73174. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73175. /**
  73176. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73177. * @param event the (select) event to use to select with
  73178. * @param referenceSpace the reference space to use for this hit test
  73179. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73180. */
  73181. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73182. /**
  73183. * attach this feature
  73184. * Will usually be called by the features manager
  73185. *
  73186. * @returns true if successful.
  73187. */
  73188. attach(): boolean;
  73189. /**
  73190. * detach this feature.
  73191. * Will usually be called by the features manager
  73192. *
  73193. * @returns true if successful.
  73194. */
  73195. detach(): boolean;
  73196. /**
  73197. * Dispose this feature and all of the resources attached
  73198. */
  73199. dispose(): void;
  73200. protected _onXRFrame(frame: XRFrame): void;
  73201. private _onHitTestResults;
  73202. private _onSelect;
  73203. }
  73204. }
  73205. declare module BABYLON {
  73206. /**
  73207. * Options used for hit testing (version 2)
  73208. */
  73209. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73210. /**
  73211. * Do not create a permanent hit test. Will usually be used when only
  73212. * transient inputs are needed.
  73213. */
  73214. disablePermanentHitTest?: boolean;
  73215. /**
  73216. * Enable transient (for example touch-based) hit test inspections
  73217. */
  73218. enableTransientHitTest?: boolean;
  73219. /**
  73220. * Offset ray for the permanent hit test
  73221. */
  73222. offsetRay?: Vector3;
  73223. /**
  73224. * Offset ray for the transient hit test
  73225. */
  73226. transientOffsetRay?: Vector3;
  73227. /**
  73228. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73229. */
  73230. useReferenceSpace?: boolean;
  73231. }
  73232. /**
  73233. * Interface defining the babylon result of hit-test
  73234. */
  73235. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73236. /**
  73237. * The input source that generated this hit test (if transient)
  73238. */
  73239. inputSource?: XRInputSource;
  73240. /**
  73241. * Is this a transient hit test
  73242. */
  73243. isTransient?: boolean;
  73244. /**
  73245. * Position of the hit test result
  73246. */
  73247. position: Vector3;
  73248. /**
  73249. * Rotation of the hit test result
  73250. */
  73251. rotationQuaternion: Quaternion;
  73252. /**
  73253. * The native hit test result
  73254. */
  73255. xrHitResult: XRHitTestResult;
  73256. }
  73257. /**
  73258. * The currently-working hit-test module.
  73259. * Hit test (or Ray-casting) is used to interact with the real world.
  73260. * For further information read here - https://github.com/immersive-web/hit-test
  73261. *
  73262. * Tested on chrome (mobile) 80.
  73263. */
  73264. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73265. /**
  73266. * options to use when constructing this feature
  73267. */
  73268. readonly options: IWebXRHitTestOptions;
  73269. private _tmpMat;
  73270. private _tmpPos;
  73271. private _tmpQuat;
  73272. private _transientXrHitTestSource;
  73273. private _xrHitTestSource;
  73274. private initHitTestSource;
  73275. /**
  73276. * The module's name
  73277. */
  73278. static readonly Name: string;
  73279. /**
  73280. * The (Babylon) version of this module.
  73281. * This is an integer representing the implementation version.
  73282. * This number does not correspond to the WebXR specs version
  73283. */
  73284. static readonly Version: number;
  73285. /**
  73286. * When set to true, each hit test will have its own position/rotation objects
  73287. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73288. * the developers will clone them or copy them as they see fit.
  73289. */
  73290. autoCloneTransformation: boolean;
  73291. /**
  73292. * Triggered when new babylon (transformed) hit test results are available
  73293. */
  73294. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73295. /**
  73296. * Use this to temporarily pause hit test checks.
  73297. */
  73298. paused: boolean;
  73299. /**
  73300. * Creates a new instance of the hit test feature
  73301. * @param _xrSessionManager an instance of WebXRSessionManager
  73302. * @param options options to use when constructing this feature
  73303. */
  73304. constructor(_xrSessionManager: WebXRSessionManager,
  73305. /**
  73306. * options to use when constructing this feature
  73307. */
  73308. options?: IWebXRHitTestOptions);
  73309. /**
  73310. * attach this feature
  73311. * Will usually be called by the features manager
  73312. *
  73313. * @returns true if successful.
  73314. */
  73315. attach(): boolean;
  73316. /**
  73317. * detach this feature.
  73318. * Will usually be called by the features manager
  73319. *
  73320. * @returns true if successful.
  73321. */
  73322. detach(): boolean;
  73323. /**
  73324. * Dispose this feature and all of the resources attached
  73325. */
  73326. dispose(): void;
  73327. protected _onXRFrame(frame: XRFrame): void;
  73328. private _processWebXRHitTestResult;
  73329. }
  73330. }
  73331. declare module BABYLON {
  73332. /**
  73333. * Configuration options of the anchor system
  73334. */
  73335. export interface IWebXRAnchorSystemOptions {
  73336. /**
  73337. * a node that will be used to convert local to world coordinates
  73338. */
  73339. worldParentNode?: TransformNode;
  73340. /**
  73341. * If set to true a reference of the created anchors will be kept until the next session starts
  73342. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73343. */
  73344. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73345. }
  73346. /**
  73347. * A babylon container for an XR Anchor
  73348. */
  73349. export interface IWebXRAnchor {
  73350. /**
  73351. * A babylon-assigned ID for this anchor
  73352. */
  73353. id: number;
  73354. /**
  73355. * Transformation matrix to apply to an object attached to this anchor
  73356. */
  73357. transformationMatrix: Matrix;
  73358. /**
  73359. * The native anchor object
  73360. */
  73361. xrAnchor: XRAnchor;
  73362. /**
  73363. * if defined, this object will be constantly updated by the anchor's position and rotation
  73364. */
  73365. attachedNode?: TransformNode;
  73366. }
  73367. /**
  73368. * An implementation of the anchor system for WebXR.
  73369. * For further information see https://github.com/immersive-web/anchors/
  73370. */
  73371. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73372. private _options;
  73373. private _lastFrameDetected;
  73374. private _trackedAnchors;
  73375. private _referenceSpaceForFrameAnchors;
  73376. private _futureAnchors;
  73377. /**
  73378. * The module's name
  73379. */
  73380. static readonly Name: string;
  73381. /**
  73382. * The (Babylon) version of this module.
  73383. * This is an integer representing the implementation version.
  73384. * This number does not correspond to the WebXR specs version
  73385. */
  73386. static readonly Version: number;
  73387. /**
  73388. * Observers registered here will be executed when a new anchor was added to the session
  73389. */
  73390. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73391. /**
  73392. * Observers registered here will be executed when an anchor was removed from the session
  73393. */
  73394. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73395. /**
  73396. * Observers registered here will be executed when an existing anchor updates
  73397. * This can execute N times every frame
  73398. */
  73399. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73400. /**
  73401. * Set the reference space to use for anchor creation, when not using a hit test.
  73402. * Will default to the session's reference space if not defined
  73403. */
  73404. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73405. /**
  73406. * constructs a new anchor system
  73407. * @param _xrSessionManager an instance of WebXRSessionManager
  73408. * @param _options configuration object for this feature
  73409. */
  73410. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73411. private _tmpVector;
  73412. private _tmpQuaternion;
  73413. private _populateTmpTransformation;
  73414. /**
  73415. * Create a new anchor point using a hit test result at a specific point in the scene
  73416. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73417. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73418. *
  73419. * @param hitTestResult The hit test result to use for this anchor creation
  73420. * @param position an optional position offset for this anchor
  73421. * @param rotationQuaternion an optional rotation offset for this anchor
  73422. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73423. */
  73424. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73425. /**
  73426. * Add a new anchor at a specific position and rotation
  73427. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73428. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73429. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73430. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73431. *
  73432. * @param position the position in which to add an anchor
  73433. * @param rotationQuaternion an optional rotation for the anchor transformation
  73434. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73435. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73436. */
  73437. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73438. /**
  73439. * detach this feature.
  73440. * Will usually be called by the features manager
  73441. *
  73442. * @returns true if successful.
  73443. */
  73444. detach(): boolean;
  73445. /**
  73446. * Dispose this feature and all of the resources attached
  73447. */
  73448. dispose(): void;
  73449. protected _onXRFrame(frame: XRFrame): void;
  73450. /**
  73451. * avoiding using Array.find for global support.
  73452. * @param xrAnchor the plane to find in the array
  73453. */
  73454. private _findIndexInAnchorArray;
  73455. private _updateAnchorWithXRFrame;
  73456. private _createAnchorAtTransformation;
  73457. }
  73458. }
  73459. declare module BABYLON {
  73460. /**
  73461. * Options used in the plane detector module
  73462. */
  73463. export interface IWebXRPlaneDetectorOptions {
  73464. /**
  73465. * The node to use to transform the local results to world coordinates
  73466. */
  73467. worldParentNode?: TransformNode;
  73468. /**
  73469. * If set to true a reference of the created planes will be kept until the next session starts
  73470. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73471. */
  73472. doNotRemovePlanesOnSessionEnded?: boolean;
  73473. }
  73474. /**
  73475. * A babylon interface for a WebXR plane.
  73476. * A Plane is actually a polygon, built from N points in space
  73477. *
  73478. * Supported in chrome 79, not supported in canary 81 ATM
  73479. */
  73480. export interface IWebXRPlane {
  73481. /**
  73482. * a babylon-assigned ID for this polygon
  73483. */
  73484. id: number;
  73485. /**
  73486. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73487. */
  73488. polygonDefinition: Array<Vector3>;
  73489. /**
  73490. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73491. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73492. */
  73493. transformationMatrix: Matrix;
  73494. /**
  73495. * the native xr-plane object
  73496. */
  73497. xrPlane: XRPlane;
  73498. }
  73499. /**
  73500. * The plane detector is used to detect planes in the real world when in AR
  73501. * For more information see https://github.com/immersive-web/real-world-geometry/
  73502. */
  73503. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73504. private _options;
  73505. private _detectedPlanes;
  73506. private _enabled;
  73507. private _lastFrameDetected;
  73508. /**
  73509. * The module's name
  73510. */
  73511. static readonly Name: string;
  73512. /**
  73513. * The (Babylon) version of this module.
  73514. * This is an integer representing the implementation version.
  73515. * This number does not correspond to the WebXR specs version
  73516. */
  73517. static readonly Version: number;
  73518. /**
  73519. * Observers registered here will be executed when a new plane was added to the session
  73520. */
  73521. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73522. /**
  73523. * Observers registered here will be executed when a plane is no longer detected in the session
  73524. */
  73525. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73526. /**
  73527. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73528. * This can execute N times every frame
  73529. */
  73530. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73531. /**
  73532. * construct a new Plane Detector
  73533. * @param _xrSessionManager an instance of xr Session manager
  73534. * @param _options configuration to use when constructing this feature
  73535. */
  73536. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73537. /**
  73538. * detach this feature.
  73539. * Will usually be called by the features manager
  73540. *
  73541. * @returns true if successful.
  73542. */
  73543. detach(): boolean;
  73544. /**
  73545. * Dispose this feature and all of the resources attached
  73546. */
  73547. dispose(): void;
  73548. protected _onXRFrame(frame: XRFrame): void;
  73549. private _init;
  73550. private _updatePlaneWithXRPlane;
  73551. /**
  73552. * avoiding using Array.find for global support.
  73553. * @param xrPlane the plane to find in the array
  73554. */
  73555. private findIndexInPlaneArray;
  73556. }
  73557. }
  73558. declare module BABYLON {
  73559. /**
  73560. * Options interface for the background remover plugin
  73561. */
  73562. export interface IWebXRBackgroundRemoverOptions {
  73563. /**
  73564. * Further background meshes to disable when entering AR
  73565. */
  73566. backgroundMeshes?: AbstractMesh[];
  73567. /**
  73568. * flags to configure the removal of the environment helper.
  73569. * If not set, the entire background will be removed. If set, flags should be set as well.
  73570. */
  73571. environmentHelperRemovalFlags?: {
  73572. /**
  73573. * Should the skybox be removed (default false)
  73574. */
  73575. skyBox?: boolean;
  73576. /**
  73577. * Should the ground be removed (default false)
  73578. */
  73579. ground?: boolean;
  73580. };
  73581. /**
  73582. * don't disable the environment helper
  73583. */
  73584. ignoreEnvironmentHelper?: boolean;
  73585. }
  73586. /**
  73587. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73588. */
  73589. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73590. /**
  73591. * read-only options to be used in this module
  73592. */
  73593. readonly options: IWebXRBackgroundRemoverOptions;
  73594. /**
  73595. * The module's name
  73596. */
  73597. static readonly Name: string;
  73598. /**
  73599. * The (Babylon) version of this module.
  73600. * This is an integer representing the implementation version.
  73601. * This number does not correspond to the WebXR specs version
  73602. */
  73603. static readonly Version: number;
  73604. /**
  73605. * registered observers will be triggered when the background state changes
  73606. */
  73607. onBackgroundStateChangedObservable: Observable<boolean>;
  73608. /**
  73609. * constructs a new background remover module
  73610. * @param _xrSessionManager the session manager for this module
  73611. * @param options read-only options to be used in this module
  73612. */
  73613. constructor(_xrSessionManager: WebXRSessionManager,
  73614. /**
  73615. * read-only options to be used in this module
  73616. */
  73617. options?: IWebXRBackgroundRemoverOptions);
  73618. /**
  73619. * attach this feature
  73620. * Will usually be called by the features manager
  73621. *
  73622. * @returns true if successful.
  73623. */
  73624. attach(): boolean;
  73625. /**
  73626. * detach this feature.
  73627. * Will usually be called by the features manager
  73628. *
  73629. * @returns true if successful.
  73630. */
  73631. detach(): boolean;
  73632. /**
  73633. * Dispose this feature and all of the resources attached
  73634. */
  73635. dispose(): void;
  73636. protected _onXRFrame(_xrFrame: XRFrame): void;
  73637. private _setBackgroundState;
  73638. }
  73639. }
  73640. declare module BABYLON {
  73641. /**
  73642. * Options for the controller physics feature
  73643. */
  73644. export class IWebXRControllerPhysicsOptions {
  73645. /**
  73646. * Should the headset get its own impostor
  73647. */
  73648. enableHeadsetImpostor?: boolean;
  73649. /**
  73650. * Optional parameters for the headset impostor
  73651. */
  73652. headsetImpostorParams?: {
  73653. /**
  73654. * The type of impostor to create. Default is sphere
  73655. */
  73656. impostorType: number;
  73657. /**
  73658. * the size of the impostor. Defaults to 10cm
  73659. */
  73660. impostorSize?: number | {
  73661. width: number;
  73662. height: number;
  73663. depth: number;
  73664. };
  73665. /**
  73666. * Friction definitions
  73667. */
  73668. friction?: number;
  73669. /**
  73670. * Restitution
  73671. */
  73672. restitution?: number;
  73673. };
  73674. /**
  73675. * The physics properties of the future impostors
  73676. */
  73677. physicsProperties?: {
  73678. /**
  73679. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73680. * Note that this requires a physics engine that supports mesh impostors!
  73681. */
  73682. useControllerMesh?: boolean;
  73683. /**
  73684. * The type of impostor to create. Default is sphere
  73685. */
  73686. impostorType?: number;
  73687. /**
  73688. * the size of the impostor. Defaults to 10cm
  73689. */
  73690. impostorSize?: number | {
  73691. width: number;
  73692. height: number;
  73693. depth: number;
  73694. };
  73695. /**
  73696. * Friction definitions
  73697. */
  73698. friction?: number;
  73699. /**
  73700. * Restitution
  73701. */
  73702. restitution?: number;
  73703. };
  73704. /**
  73705. * the xr input to use with this pointer selection
  73706. */
  73707. xrInput: WebXRInput;
  73708. }
  73709. /**
  73710. * Add physics impostor to your webxr controllers,
  73711. * including naive calculation of their linear and angular velocity
  73712. */
  73713. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73714. private readonly _options;
  73715. private _attachController;
  73716. private _controllers;
  73717. private _debugMode;
  73718. private _delta;
  73719. private _headsetImpostor?;
  73720. private _headsetMesh?;
  73721. private _lastTimestamp;
  73722. private _tmpQuaternion;
  73723. private _tmpVector;
  73724. /**
  73725. * The module's name
  73726. */
  73727. static readonly Name: string;
  73728. /**
  73729. * The (Babylon) version of this module.
  73730. * This is an integer representing the implementation version.
  73731. * This number does not correspond to the webxr specs version
  73732. */
  73733. static readonly Version: number;
  73734. /**
  73735. * Construct a new Controller Physics Feature
  73736. * @param _xrSessionManager the corresponding xr session manager
  73737. * @param _options options to create this feature with
  73738. */
  73739. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73740. /**
  73741. * @hidden
  73742. * enable debugging - will show console outputs and the impostor mesh
  73743. */
  73744. _enablePhysicsDebug(): void;
  73745. /**
  73746. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73747. * @param xrController the controller to add
  73748. */
  73749. addController(xrController: WebXRInputSource): void;
  73750. /**
  73751. * attach this feature
  73752. * Will usually be called by the features manager
  73753. *
  73754. * @returns true if successful.
  73755. */
  73756. attach(): boolean;
  73757. /**
  73758. * detach this feature.
  73759. * Will usually be called by the features manager
  73760. *
  73761. * @returns true if successful.
  73762. */
  73763. detach(): boolean;
  73764. /**
  73765. * Get the headset impostor, if enabled
  73766. * @returns the impostor
  73767. */
  73768. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73769. /**
  73770. * Get the physics impostor of a specific controller.
  73771. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73772. * @param controller the controller or the controller id of which to get the impostor
  73773. * @returns the impostor or null
  73774. */
  73775. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73776. /**
  73777. * Update the physics properties provided in the constructor
  73778. * @param newProperties the new properties object
  73779. */
  73780. setPhysicsProperties(newProperties: {
  73781. impostorType?: number;
  73782. impostorSize?: number | {
  73783. width: number;
  73784. height: number;
  73785. depth: number;
  73786. };
  73787. friction?: number;
  73788. restitution?: number;
  73789. }): void;
  73790. protected _onXRFrame(_xrFrame: any): void;
  73791. private _detachController;
  73792. }
  73793. }
  73794. declare module BABYLON {
  73795. /**
  73796. * The motion controller class for all microsoft mixed reality controllers
  73797. */
  73798. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73799. protected readonly _mapping: {
  73800. defaultButton: {
  73801. valueNodeName: string;
  73802. unpressedNodeName: string;
  73803. pressedNodeName: string;
  73804. };
  73805. defaultAxis: {
  73806. valueNodeName: string;
  73807. minNodeName: string;
  73808. maxNodeName: string;
  73809. };
  73810. buttons: {
  73811. "xr-standard-trigger": {
  73812. rootNodeName: string;
  73813. componentProperty: string;
  73814. states: string[];
  73815. };
  73816. "xr-standard-squeeze": {
  73817. rootNodeName: string;
  73818. componentProperty: string;
  73819. states: string[];
  73820. };
  73821. "xr-standard-touchpad": {
  73822. rootNodeName: string;
  73823. labelAnchorNodeName: string;
  73824. touchPointNodeName: string;
  73825. };
  73826. "xr-standard-thumbstick": {
  73827. rootNodeName: string;
  73828. componentProperty: string;
  73829. states: string[];
  73830. };
  73831. };
  73832. axes: {
  73833. "xr-standard-touchpad": {
  73834. "x-axis": {
  73835. rootNodeName: string;
  73836. };
  73837. "y-axis": {
  73838. rootNodeName: string;
  73839. };
  73840. };
  73841. "xr-standard-thumbstick": {
  73842. "x-axis": {
  73843. rootNodeName: string;
  73844. };
  73845. "y-axis": {
  73846. rootNodeName: string;
  73847. };
  73848. };
  73849. };
  73850. };
  73851. /**
  73852. * The base url used to load the left and right controller models
  73853. */
  73854. static MODEL_BASE_URL: string;
  73855. /**
  73856. * The name of the left controller model file
  73857. */
  73858. static MODEL_LEFT_FILENAME: string;
  73859. /**
  73860. * The name of the right controller model file
  73861. */
  73862. static MODEL_RIGHT_FILENAME: string;
  73863. profileId: string;
  73864. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73865. protected _getFilenameAndPath(): {
  73866. filename: string;
  73867. path: string;
  73868. };
  73869. protected _getModelLoadingConstraints(): boolean;
  73870. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73871. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73872. protected _updateModel(): void;
  73873. }
  73874. }
  73875. declare module BABYLON {
  73876. /**
  73877. * The motion controller class for oculus touch (quest, rift).
  73878. * This class supports legacy mapping as well the standard xr mapping
  73879. */
  73880. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73881. private _forceLegacyControllers;
  73882. private _modelRootNode;
  73883. /**
  73884. * The base url used to load the left and right controller models
  73885. */
  73886. static MODEL_BASE_URL: string;
  73887. /**
  73888. * The name of the left controller model file
  73889. */
  73890. static MODEL_LEFT_FILENAME: string;
  73891. /**
  73892. * The name of the right controller model file
  73893. */
  73894. static MODEL_RIGHT_FILENAME: string;
  73895. /**
  73896. * Base Url for the Quest controller model.
  73897. */
  73898. static QUEST_MODEL_BASE_URL: string;
  73899. profileId: string;
  73900. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73901. protected _getFilenameAndPath(): {
  73902. filename: string;
  73903. path: string;
  73904. };
  73905. protected _getModelLoadingConstraints(): boolean;
  73906. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73907. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73908. protected _updateModel(): void;
  73909. /**
  73910. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73911. * between the touch and touch 2.
  73912. */
  73913. private _isQuest;
  73914. }
  73915. }
  73916. declare module BABYLON {
  73917. /**
  73918. * The motion controller class for the standard HTC-Vive controllers
  73919. */
  73920. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73921. private _modelRootNode;
  73922. /**
  73923. * The base url used to load the left and right controller models
  73924. */
  73925. static MODEL_BASE_URL: string;
  73926. /**
  73927. * File name for the controller model.
  73928. */
  73929. static MODEL_FILENAME: string;
  73930. profileId: string;
  73931. /**
  73932. * Create a new Vive motion controller object
  73933. * @param scene the scene to use to create this controller
  73934. * @param gamepadObject the corresponding gamepad object
  73935. * @param handedness the handedness of the controller
  73936. */
  73937. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73938. protected _getFilenameAndPath(): {
  73939. filename: string;
  73940. path: string;
  73941. };
  73942. protected _getModelLoadingConstraints(): boolean;
  73943. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73944. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73945. protected _updateModel(): void;
  73946. }
  73947. }
  73948. declare module BABYLON {
  73949. /**
  73950. * A cursor which tracks a point on a path
  73951. */
  73952. export class PathCursor {
  73953. private path;
  73954. /**
  73955. * Stores path cursor callbacks for when an onchange event is triggered
  73956. */
  73957. private _onchange;
  73958. /**
  73959. * The value of the path cursor
  73960. */
  73961. value: number;
  73962. /**
  73963. * The animation array of the path cursor
  73964. */
  73965. animations: Animation[];
  73966. /**
  73967. * Initializes the path cursor
  73968. * @param path The path to track
  73969. */
  73970. constructor(path: Path2);
  73971. /**
  73972. * Gets the cursor point on the path
  73973. * @returns A point on the path cursor at the cursor location
  73974. */
  73975. getPoint(): Vector3;
  73976. /**
  73977. * Moves the cursor ahead by the step amount
  73978. * @param step The amount to move the cursor forward
  73979. * @returns This path cursor
  73980. */
  73981. moveAhead(step?: number): PathCursor;
  73982. /**
  73983. * Moves the cursor behind by the step amount
  73984. * @param step The amount to move the cursor back
  73985. * @returns This path cursor
  73986. */
  73987. moveBack(step?: number): PathCursor;
  73988. /**
  73989. * Moves the cursor by the step amount
  73990. * If the step amount is greater than one, an exception is thrown
  73991. * @param step The amount to move the cursor
  73992. * @returns This path cursor
  73993. */
  73994. move(step: number): PathCursor;
  73995. /**
  73996. * Ensures that the value is limited between zero and one
  73997. * @returns This path cursor
  73998. */
  73999. private ensureLimits;
  74000. /**
  74001. * Runs onchange callbacks on change (used by the animation engine)
  74002. * @returns This path cursor
  74003. */
  74004. private raiseOnChange;
  74005. /**
  74006. * Executes a function on change
  74007. * @param f A path cursor onchange callback
  74008. * @returns This path cursor
  74009. */
  74010. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74011. }
  74012. }
  74013. declare module BABYLON {
  74014. /** @hidden */
  74015. export var blurPixelShader: {
  74016. name: string;
  74017. shader: string;
  74018. };
  74019. }
  74020. declare module BABYLON {
  74021. /** @hidden */
  74022. export var pointCloudVertexDeclaration: {
  74023. name: string;
  74024. shader: string;
  74025. };
  74026. }
  74027. // Mixins
  74028. interface Window {
  74029. mozIndexedDB: IDBFactory;
  74030. webkitIndexedDB: IDBFactory;
  74031. msIndexedDB: IDBFactory;
  74032. webkitURL: typeof URL;
  74033. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74034. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74035. WebGLRenderingContext: WebGLRenderingContext;
  74036. MSGesture: MSGesture;
  74037. CANNON: any;
  74038. AudioContext: AudioContext;
  74039. webkitAudioContext: AudioContext;
  74040. PointerEvent: any;
  74041. Math: Math;
  74042. Uint8Array: Uint8ArrayConstructor;
  74043. Float32Array: Float32ArrayConstructor;
  74044. mozURL: typeof URL;
  74045. msURL: typeof URL;
  74046. VRFrameData: any; // WebVR, from specs 1.1
  74047. DracoDecoderModule: any;
  74048. setImmediate(handler: (...args: any[]) => void): number;
  74049. }
  74050. interface HTMLCanvasElement {
  74051. requestPointerLock(): void;
  74052. msRequestPointerLock?(): void;
  74053. mozRequestPointerLock?(): void;
  74054. webkitRequestPointerLock?(): void;
  74055. /** Track wether a record is in progress */
  74056. isRecording: boolean;
  74057. /** Capture Stream method defined by some browsers */
  74058. captureStream(fps?: number): MediaStream;
  74059. }
  74060. interface CanvasRenderingContext2D {
  74061. msImageSmoothingEnabled: boolean;
  74062. }
  74063. interface MouseEvent {
  74064. mozMovementX: number;
  74065. mozMovementY: number;
  74066. webkitMovementX: number;
  74067. webkitMovementY: number;
  74068. msMovementX: number;
  74069. msMovementY: number;
  74070. }
  74071. interface Navigator {
  74072. mozGetVRDevices: (any: any) => any;
  74073. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74074. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74075. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74076. webkitGetGamepads(): Gamepad[];
  74077. msGetGamepads(): Gamepad[];
  74078. webkitGamepads(): Gamepad[];
  74079. }
  74080. interface HTMLVideoElement {
  74081. mozSrcObject: any;
  74082. }
  74083. interface Math {
  74084. fround(x: number): number;
  74085. imul(a: number, b: number): number;
  74086. }
  74087. interface WebGLRenderingContext {
  74088. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74089. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74090. vertexAttribDivisor(index: number, divisor: number): void;
  74091. createVertexArray(): any;
  74092. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74093. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74094. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74095. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74096. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74097. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74098. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74099. // Queries
  74100. createQuery(): WebGLQuery;
  74101. deleteQuery(query: WebGLQuery): void;
  74102. beginQuery(target: number, query: WebGLQuery): void;
  74103. endQuery(target: number): void;
  74104. getQueryParameter(query: WebGLQuery, pname: number): any;
  74105. getQuery(target: number, pname: number): any;
  74106. MAX_SAMPLES: number;
  74107. RGBA8: number;
  74108. READ_FRAMEBUFFER: number;
  74109. DRAW_FRAMEBUFFER: number;
  74110. UNIFORM_BUFFER: number;
  74111. HALF_FLOAT_OES: number;
  74112. RGBA16F: number;
  74113. RGBA32F: number;
  74114. R32F: number;
  74115. RG32F: number;
  74116. RGB32F: number;
  74117. R16F: number;
  74118. RG16F: number;
  74119. RGB16F: number;
  74120. RED: number;
  74121. RG: number;
  74122. R8: number;
  74123. RG8: number;
  74124. UNSIGNED_INT_24_8: number;
  74125. DEPTH24_STENCIL8: number;
  74126. MIN: number;
  74127. MAX: number;
  74128. /* Multiple Render Targets */
  74129. drawBuffers(buffers: number[]): void;
  74130. readBuffer(src: number): void;
  74131. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74132. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74133. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74134. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74135. // Occlusion Query
  74136. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74137. ANY_SAMPLES_PASSED: number;
  74138. QUERY_RESULT_AVAILABLE: number;
  74139. QUERY_RESULT: number;
  74140. }
  74141. interface WebGLProgram {
  74142. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74143. }
  74144. interface EXT_disjoint_timer_query {
  74145. QUERY_COUNTER_BITS_EXT: number;
  74146. TIME_ELAPSED_EXT: number;
  74147. TIMESTAMP_EXT: number;
  74148. GPU_DISJOINT_EXT: number;
  74149. QUERY_RESULT_EXT: number;
  74150. QUERY_RESULT_AVAILABLE_EXT: number;
  74151. queryCounterEXT(query: WebGLQuery, target: number): void;
  74152. createQueryEXT(): WebGLQuery;
  74153. beginQueryEXT(target: number, query: WebGLQuery): void;
  74154. endQueryEXT(target: number): void;
  74155. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74156. deleteQueryEXT(query: WebGLQuery): void;
  74157. }
  74158. interface WebGLUniformLocation {
  74159. _currentState: any;
  74160. }
  74161. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74162. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74163. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74164. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74165. interface WebGLRenderingContext {
  74166. readonly RASTERIZER_DISCARD: number;
  74167. readonly DEPTH_COMPONENT24: number;
  74168. readonly TEXTURE_3D: number;
  74169. readonly TEXTURE_2D_ARRAY: number;
  74170. readonly TEXTURE_COMPARE_FUNC: number;
  74171. readonly TEXTURE_COMPARE_MODE: number;
  74172. readonly COMPARE_REF_TO_TEXTURE: number;
  74173. readonly TEXTURE_WRAP_R: number;
  74174. readonly HALF_FLOAT: number;
  74175. readonly RGB8: number;
  74176. readonly RED_INTEGER: number;
  74177. readonly RG_INTEGER: number;
  74178. readonly RGB_INTEGER: number;
  74179. readonly RGBA_INTEGER: number;
  74180. readonly R8_SNORM: number;
  74181. readonly RG8_SNORM: number;
  74182. readonly RGB8_SNORM: number;
  74183. readonly RGBA8_SNORM: number;
  74184. readonly R8I: number;
  74185. readonly RG8I: number;
  74186. readonly RGB8I: number;
  74187. readonly RGBA8I: number;
  74188. readonly R8UI: number;
  74189. readonly RG8UI: number;
  74190. readonly RGB8UI: number;
  74191. readonly RGBA8UI: number;
  74192. readonly R16I: number;
  74193. readonly RG16I: number;
  74194. readonly RGB16I: number;
  74195. readonly RGBA16I: number;
  74196. readonly R16UI: number;
  74197. readonly RG16UI: number;
  74198. readonly RGB16UI: number;
  74199. readonly RGBA16UI: number;
  74200. readonly R32I: number;
  74201. readonly RG32I: number;
  74202. readonly RGB32I: number;
  74203. readonly RGBA32I: number;
  74204. readonly R32UI: number;
  74205. readonly RG32UI: number;
  74206. readonly RGB32UI: number;
  74207. readonly RGBA32UI: number;
  74208. readonly RGB10_A2UI: number;
  74209. readonly R11F_G11F_B10F: number;
  74210. readonly RGB9_E5: number;
  74211. readonly RGB10_A2: number;
  74212. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74213. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74214. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74215. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74216. readonly DEPTH_COMPONENT32F: number;
  74217. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74218. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74219. 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;
  74220. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74221. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74222. readonly TRANSFORM_FEEDBACK: number;
  74223. readonly INTERLEAVED_ATTRIBS: number;
  74224. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74225. createTransformFeedback(): WebGLTransformFeedback;
  74226. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74227. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74228. beginTransformFeedback(primitiveMode: number): void;
  74229. endTransformFeedback(): void;
  74230. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74231. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74232. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74233. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74234. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74235. }
  74236. interface ImageBitmap {
  74237. readonly width: number;
  74238. readonly height: number;
  74239. close(): void;
  74240. }
  74241. interface WebGLQuery extends WebGLObject {
  74242. }
  74243. declare var WebGLQuery: {
  74244. prototype: WebGLQuery;
  74245. new(): WebGLQuery;
  74246. };
  74247. interface WebGLSampler extends WebGLObject {
  74248. }
  74249. declare var WebGLSampler: {
  74250. prototype: WebGLSampler;
  74251. new(): WebGLSampler;
  74252. };
  74253. interface WebGLSync extends WebGLObject {
  74254. }
  74255. declare var WebGLSync: {
  74256. prototype: WebGLSync;
  74257. new(): WebGLSync;
  74258. };
  74259. interface WebGLTransformFeedback extends WebGLObject {
  74260. }
  74261. declare var WebGLTransformFeedback: {
  74262. prototype: WebGLTransformFeedback;
  74263. new(): WebGLTransformFeedback;
  74264. };
  74265. interface WebGLVertexArrayObject extends WebGLObject {
  74266. }
  74267. declare var WebGLVertexArrayObject: {
  74268. prototype: WebGLVertexArrayObject;
  74269. new(): WebGLVertexArrayObject;
  74270. };
  74271. // Type definitions for WebVR API
  74272. // Project: https://w3c.github.io/webvr/
  74273. // Definitions by: six a <https://github.com/lostfictions>
  74274. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74275. interface VRDisplay extends EventTarget {
  74276. /**
  74277. * Dictionary of capabilities describing the VRDisplay.
  74278. */
  74279. readonly capabilities: VRDisplayCapabilities;
  74280. /**
  74281. * z-depth defining the far plane of the eye view frustum
  74282. * enables mapping of values in the render target depth
  74283. * attachment to scene coordinates. Initially set to 10000.0.
  74284. */
  74285. depthFar: number;
  74286. /**
  74287. * z-depth defining the near plane of the eye view frustum
  74288. * enables mapping of values in the render target depth
  74289. * attachment to scene coordinates. Initially set to 0.01.
  74290. */
  74291. depthNear: number;
  74292. /**
  74293. * An identifier for this distinct VRDisplay. Used as an
  74294. * association point in the Gamepad API.
  74295. */
  74296. readonly displayId: number;
  74297. /**
  74298. * A display name, a user-readable name identifying it.
  74299. */
  74300. readonly displayName: string;
  74301. readonly isConnected: boolean;
  74302. readonly isPresenting: boolean;
  74303. /**
  74304. * If this VRDisplay supports room-scale experiences, the optional
  74305. * stage attribute contains details on the room-scale parameters.
  74306. */
  74307. readonly stageParameters: VRStageParameters | null;
  74308. /**
  74309. * Passing the value returned by `requestAnimationFrame` to
  74310. * `cancelAnimationFrame` will unregister the callback.
  74311. * @param handle Define the hanle of the request to cancel
  74312. */
  74313. cancelAnimationFrame(handle: number): void;
  74314. /**
  74315. * Stops presenting to the VRDisplay.
  74316. * @returns a promise to know when it stopped
  74317. */
  74318. exitPresent(): Promise<void>;
  74319. /**
  74320. * Return the current VREyeParameters for the given eye.
  74321. * @param whichEye Define the eye we want the parameter for
  74322. * @returns the eye parameters
  74323. */
  74324. getEyeParameters(whichEye: string): VREyeParameters;
  74325. /**
  74326. * Populates the passed VRFrameData with the information required to render
  74327. * the current frame.
  74328. * @param frameData Define the data structure to populate
  74329. * @returns true if ok otherwise false
  74330. */
  74331. getFrameData(frameData: VRFrameData): boolean;
  74332. /**
  74333. * Get the layers currently being presented.
  74334. * @returns the list of VR layers
  74335. */
  74336. getLayers(): VRLayer[];
  74337. /**
  74338. * Return a VRPose containing the future predicted pose of the VRDisplay
  74339. * when the current frame will be presented. The value returned will not
  74340. * change until JavaScript has returned control to the browser.
  74341. *
  74342. * The VRPose will contain the position, orientation, velocity,
  74343. * and acceleration of each of these properties.
  74344. * @returns the pose object
  74345. */
  74346. getPose(): VRPose;
  74347. /**
  74348. * Return the current instantaneous pose of the VRDisplay, with no
  74349. * prediction applied.
  74350. * @returns the current instantaneous pose
  74351. */
  74352. getImmediatePose(): VRPose;
  74353. /**
  74354. * The callback passed to `requestAnimationFrame` will be called
  74355. * any time a new frame should be rendered. When the VRDisplay is
  74356. * presenting the callback will be called at the native refresh
  74357. * rate of the HMD. When not presenting this function acts
  74358. * identically to how window.requestAnimationFrame acts. Content should
  74359. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74360. * asynchronously from other displays and at differing refresh rates.
  74361. * @param callback Define the eaction to run next frame
  74362. * @returns the request handle it
  74363. */
  74364. requestAnimationFrame(callback: FrameRequestCallback): number;
  74365. /**
  74366. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74367. * Repeat calls while already presenting will update the VRLayers being displayed.
  74368. * @param layers Define the list of layer to present
  74369. * @returns a promise to know when the request has been fulfilled
  74370. */
  74371. requestPresent(layers: VRLayer[]): Promise<void>;
  74372. /**
  74373. * Reset the pose for this display, treating its current position and
  74374. * orientation as the "origin/zero" values. VRPose.position,
  74375. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74376. * updated when calling resetPose(). This should be called in only
  74377. * sitting-space experiences.
  74378. */
  74379. resetPose(): void;
  74380. /**
  74381. * The VRLayer provided to the VRDisplay will be captured and presented
  74382. * in the HMD. Calling this function has the same effect on the source
  74383. * canvas as any other operation that uses its source image, and canvases
  74384. * created without preserveDrawingBuffer set to true will be cleared.
  74385. * @param pose Define the pose to submit
  74386. */
  74387. submitFrame(pose?: VRPose): void;
  74388. }
  74389. declare var VRDisplay: {
  74390. prototype: VRDisplay;
  74391. new(): VRDisplay;
  74392. };
  74393. interface VRLayer {
  74394. leftBounds?: number[] | Float32Array | null;
  74395. rightBounds?: number[] | Float32Array | null;
  74396. source?: HTMLCanvasElement | null;
  74397. }
  74398. interface VRDisplayCapabilities {
  74399. readonly canPresent: boolean;
  74400. readonly hasExternalDisplay: boolean;
  74401. readonly hasOrientation: boolean;
  74402. readonly hasPosition: boolean;
  74403. readonly maxLayers: number;
  74404. }
  74405. interface VREyeParameters {
  74406. /** @deprecated */
  74407. readonly fieldOfView: VRFieldOfView;
  74408. readonly offset: Float32Array;
  74409. readonly renderHeight: number;
  74410. readonly renderWidth: number;
  74411. }
  74412. interface VRFieldOfView {
  74413. readonly downDegrees: number;
  74414. readonly leftDegrees: number;
  74415. readonly rightDegrees: number;
  74416. readonly upDegrees: number;
  74417. }
  74418. interface VRFrameData {
  74419. readonly leftProjectionMatrix: Float32Array;
  74420. readonly leftViewMatrix: Float32Array;
  74421. readonly pose: VRPose;
  74422. readonly rightProjectionMatrix: Float32Array;
  74423. readonly rightViewMatrix: Float32Array;
  74424. readonly timestamp: number;
  74425. }
  74426. interface VRPose {
  74427. readonly angularAcceleration: Float32Array | null;
  74428. readonly angularVelocity: Float32Array | null;
  74429. readonly linearAcceleration: Float32Array | null;
  74430. readonly linearVelocity: Float32Array | null;
  74431. readonly orientation: Float32Array | null;
  74432. readonly position: Float32Array | null;
  74433. readonly timestamp: number;
  74434. }
  74435. interface VRStageParameters {
  74436. sittingToStandingTransform?: Float32Array;
  74437. sizeX?: number;
  74438. sizeY?: number;
  74439. }
  74440. interface Navigator {
  74441. getVRDisplays(): Promise<VRDisplay[]>;
  74442. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74443. }
  74444. interface Window {
  74445. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74446. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74447. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74448. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74449. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74450. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74451. }
  74452. interface Gamepad {
  74453. readonly displayId: number;
  74454. }
  74455. type XRSessionMode =
  74456. | "inline"
  74457. | "immersive-vr"
  74458. | "immersive-ar";
  74459. type XRReferenceSpaceType =
  74460. | "viewer"
  74461. | "local"
  74462. | "local-floor"
  74463. | "bounded-floor"
  74464. | "unbounded";
  74465. type XREnvironmentBlendMode =
  74466. | "opaque"
  74467. | "additive"
  74468. | "alpha-blend";
  74469. type XRVisibilityState =
  74470. | "visible"
  74471. | "visible-blurred"
  74472. | "hidden";
  74473. type XRHandedness =
  74474. | "none"
  74475. | "left"
  74476. | "right";
  74477. type XRTargetRayMode =
  74478. | "gaze"
  74479. | "tracked-pointer"
  74480. | "screen";
  74481. type XREye =
  74482. | "none"
  74483. | "left"
  74484. | "right";
  74485. type XREventType =
  74486. | "devicechange"
  74487. | "visibilitychange"
  74488. | "end"
  74489. | "inputsourceschange"
  74490. | "select"
  74491. | "selectstart"
  74492. | "selectend"
  74493. | "squeeze"
  74494. | "squeezestart"
  74495. | "squeezeend"
  74496. | "reset";
  74497. interface XRSpace extends EventTarget {
  74498. }
  74499. interface XRRenderState {
  74500. depthNear?: number;
  74501. depthFar?: number;
  74502. inlineVerticalFieldOfView?: number;
  74503. baseLayer?: XRWebGLLayer;
  74504. }
  74505. interface XRInputSource {
  74506. handedness: XRHandedness;
  74507. targetRayMode: XRTargetRayMode;
  74508. targetRaySpace: XRSpace;
  74509. gripSpace: XRSpace | undefined;
  74510. gamepad: Gamepad | undefined;
  74511. profiles: Array<string>;
  74512. }
  74513. interface XRSessionInit {
  74514. optionalFeatures?: string[];
  74515. requiredFeatures?: string[];
  74516. }
  74517. interface XRSession {
  74518. addEventListener: Function;
  74519. removeEventListener: Function;
  74520. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74521. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74522. requestAnimationFrame: Function;
  74523. end(): Promise<void>;
  74524. renderState: XRRenderState;
  74525. inputSources: Array<XRInputSource>;
  74526. // hit test
  74527. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74528. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74529. // legacy AR hit test
  74530. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74531. // legacy plane detection
  74532. updateWorldTrackingState(options: {
  74533. planeDetectionState?: { enabled: boolean; }
  74534. }): void;
  74535. }
  74536. interface XRReferenceSpace extends XRSpace {
  74537. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74538. onreset: any;
  74539. }
  74540. type XRPlaneSet = Set<XRPlane>;
  74541. type XRAnchorSet = Set<XRAnchor>;
  74542. interface XRFrame {
  74543. session: XRSession;
  74544. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74545. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74546. // AR
  74547. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74548. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74549. // Anchors
  74550. trackedAnchors?: XRAnchorSet;
  74551. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74552. // Planes
  74553. worldInformation: {
  74554. detectedPlanes?: XRPlaneSet;
  74555. };
  74556. }
  74557. interface XRViewerPose extends XRPose {
  74558. views: Array<XRView>;
  74559. }
  74560. interface XRPose {
  74561. transform: XRRigidTransform;
  74562. emulatedPosition: boolean;
  74563. }
  74564. interface XRWebGLLayerOptions {
  74565. antialias?: boolean;
  74566. depth?: boolean;
  74567. stencil?: boolean;
  74568. alpha?: boolean;
  74569. multiview?: boolean;
  74570. framebufferScaleFactor?: number;
  74571. }
  74572. declare var XRWebGLLayer: {
  74573. prototype: XRWebGLLayer;
  74574. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74575. };
  74576. interface XRWebGLLayer {
  74577. framebuffer: WebGLFramebuffer;
  74578. framebufferWidth: number;
  74579. framebufferHeight: number;
  74580. getViewport: Function;
  74581. }
  74582. declare class XRRigidTransform {
  74583. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74584. position: DOMPointReadOnly;
  74585. orientation: DOMPointReadOnly;
  74586. matrix: Float32Array;
  74587. inverse: XRRigidTransform;
  74588. }
  74589. interface XRView {
  74590. eye: XREye;
  74591. projectionMatrix: Float32Array;
  74592. transform: XRRigidTransform;
  74593. }
  74594. interface XRInputSourceChangeEvent {
  74595. session: XRSession;
  74596. removed: Array<XRInputSource>;
  74597. added: Array<XRInputSource>;
  74598. }
  74599. interface XRInputSourceEvent extends Event {
  74600. readonly frame: XRFrame;
  74601. readonly inputSource: XRInputSource;
  74602. }
  74603. // Experimental(er) features
  74604. declare class XRRay {
  74605. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74606. origin: DOMPointReadOnly;
  74607. direction: DOMPointReadOnly;
  74608. matrix: Float32Array;
  74609. }
  74610. declare enum XRHitTestTrackableType {
  74611. "point",
  74612. "plane"
  74613. }
  74614. interface XRHitResult {
  74615. hitMatrix: Float32Array;
  74616. }
  74617. interface XRTransientInputHitTestResult {
  74618. readonly inputSource: XRInputSource;
  74619. readonly results: Array<XRHitTestResult>;
  74620. }
  74621. interface XRHitTestResult {
  74622. getPose(baseSpace: XRSpace): XRPose | undefined;
  74623. // When anchor system is enabled
  74624. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74625. }
  74626. interface XRHitTestSource {
  74627. cancel(): void;
  74628. }
  74629. interface XRTransientInputHitTestSource {
  74630. cancel(): void;
  74631. }
  74632. interface XRHitTestOptionsInit {
  74633. space: XRSpace;
  74634. entityTypes?: Array<XRHitTestTrackableType>;
  74635. offsetRay?: XRRay;
  74636. }
  74637. interface XRTransientInputHitTestOptionsInit {
  74638. profile: string;
  74639. entityTypes?: Array<XRHitTestTrackableType>;
  74640. offsetRay?: XRRay;
  74641. }
  74642. interface XRAnchor {
  74643. anchorSpace: XRSpace;
  74644. delete(): void;
  74645. }
  74646. interface XRPlane {
  74647. orientation: "Horizontal" | "Vertical";
  74648. planeSpace: XRSpace;
  74649. polygon: Array<DOMPointReadOnly>;
  74650. lastChangedTime: number;
  74651. }
  74652. /**
  74653. * @ignore
  74654. */
  74655. declare module BABYLON.GLTF2.Exporter {
  74656. }
  74657. /**
  74658. * @ignore
  74659. */
  74660. declare module BABYLON.GLTF1 {
  74661. }
  74662. declare module BABYLON.GUI {
  74663. /**
  74664. * Class used to specific a value and its associated unit
  74665. */
  74666. export class ValueAndUnit {
  74667. /** defines the unit to store */
  74668. unit: number;
  74669. /** defines a boolean indicating if the value can be negative */
  74670. negativeValueAllowed: boolean;
  74671. private _value;
  74672. private _originalUnit;
  74673. /**
  74674. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74675. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74676. */
  74677. ignoreAdaptiveScaling: boolean;
  74678. /**
  74679. * Creates a new ValueAndUnit
  74680. * @param value defines the value to store
  74681. * @param unit defines the unit to store
  74682. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74683. */
  74684. constructor(value: number,
  74685. /** defines the unit to store */
  74686. unit?: number,
  74687. /** defines a boolean indicating if the value can be negative */
  74688. negativeValueAllowed?: boolean);
  74689. /** Gets a boolean indicating if the value is a percentage */
  74690. get isPercentage(): boolean;
  74691. /** Gets a boolean indicating if the value is store as pixel */
  74692. get isPixel(): boolean;
  74693. /** Gets direct internal value */
  74694. get internalValue(): number;
  74695. /**
  74696. * Gets value as pixel
  74697. * @param host defines the root host
  74698. * @param refValue defines the reference value for percentages
  74699. * @returns the value as pixel
  74700. */
  74701. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74702. /**
  74703. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74704. * @param value defines the value to store
  74705. * @param unit defines the unit to store
  74706. * @returns the current ValueAndUnit
  74707. */
  74708. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74709. /**
  74710. * Gets the value accordingly to its unit
  74711. * @param host defines the root host
  74712. * @returns the value
  74713. */
  74714. getValue(host: AdvancedDynamicTexture): number;
  74715. /**
  74716. * Gets a string representation of the value
  74717. * @param host defines the root host
  74718. * @param decimals defines an optional number of decimals to display
  74719. * @returns a string
  74720. */
  74721. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74722. /**
  74723. * Store a value parsed from a string
  74724. * @param source defines the source string
  74725. * @returns true if the value was successfully parsed
  74726. */
  74727. fromString(source: string | number): boolean;
  74728. private static _Regex;
  74729. private static _UNITMODE_PERCENTAGE;
  74730. private static _UNITMODE_PIXEL;
  74731. /** UNITMODE_PERCENTAGE */
  74732. static get UNITMODE_PERCENTAGE(): number;
  74733. /** UNITMODE_PIXEL */
  74734. static get UNITMODE_PIXEL(): number;
  74735. }
  74736. }
  74737. declare module BABYLON.GUI {
  74738. /**
  74739. * Define a style used by control to automatically setup properties based on a template.
  74740. * Only support font related properties so far
  74741. */
  74742. export class Style implements BABYLON.IDisposable {
  74743. private _fontFamily;
  74744. private _fontStyle;
  74745. private _fontWeight;
  74746. /** @hidden */
  74747. _host: AdvancedDynamicTexture;
  74748. /** @hidden */
  74749. _fontSize: ValueAndUnit;
  74750. /**
  74751. * BABYLON.Observable raised when the style values are changed
  74752. */
  74753. onChangedObservable: BABYLON.Observable<Style>;
  74754. /**
  74755. * Creates a new style object
  74756. * @param host defines the AdvancedDynamicTexture which hosts this style
  74757. */
  74758. constructor(host: AdvancedDynamicTexture);
  74759. /**
  74760. * Gets or sets the font size
  74761. */
  74762. get fontSize(): string | number;
  74763. set fontSize(value: string | number);
  74764. /**
  74765. * Gets or sets the font family
  74766. */
  74767. get fontFamily(): string;
  74768. set fontFamily(value: string);
  74769. /**
  74770. * Gets or sets the font style
  74771. */
  74772. get fontStyle(): string;
  74773. set fontStyle(value: string);
  74774. /** Gets or sets font weight */
  74775. get fontWeight(): string;
  74776. set fontWeight(value: string);
  74777. /** Dispose all associated resources */
  74778. dispose(): void;
  74779. }
  74780. }
  74781. declare module BABYLON.GUI {
  74782. /**
  74783. * Class used to transport BABYLON.Vector2 information for pointer events
  74784. */
  74785. export class Vector2WithInfo extends BABYLON.Vector2 {
  74786. /** defines the current mouse button index */
  74787. buttonIndex: number;
  74788. /**
  74789. * Creates a new Vector2WithInfo
  74790. * @param source defines the vector2 data to transport
  74791. * @param buttonIndex defines the current mouse button index
  74792. */
  74793. constructor(source: BABYLON.Vector2,
  74794. /** defines the current mouse button index */
  74795. buttonIndex?: number);
  74796. }
  74797. /** Class used to provide 2D matrix features */
  74798. export class Matrix2D {
  74799. /** Gets the internal array of 6 floats used to store matrix data */
  74800. m: Float32Array;
  74801. /**
  74802. * Creates a new matrix
  74803. * @param m00 defines value for (0, 0)
  74804. * @param m01 defines value for (0, 1)
  74805. * @param m10 defines value for (1, 0)
  74806. * @param m11 defines value for (1, 1)
  74807. * @param m20 defines value for (2, 0)
  74808. * @param m21 defines value for (2, 1)
  74809. */
  74810. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74811. /**
  74812. * Fills the matrix from direct values
  74813. * @param m00 defines value for (0, 0)
  74814. * @param m01 defines value for (0, 1)
  74815. * @param m10 defines value for (1, 0)
  74816. * @param m11 defines value for (1, 1)
  74817. * @param m20 defines value for (2, 0)
  74818. * @param m21 defines value for (2, 1)
  74819. * @returns the current modified matrix
  74820. */
  74821. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74822. /**
  74823. * Gets matrix determinant
  74824. * @returns the determinant
  74825. */
  74826. determinant(): number;
  74827. /**
  74828. * Inverses the matrix and stores it in a target matrix
  74829. * @param result defines the target matrix
  74830. * @returns the current matrix
  74831. */
  74832. invertToRef(result: Matrix2D): Matrix2D;
  74833. /**
  74834. * Multiplies the current matrix with another one
  74835. * @param other defines the second operand
  74836. * @param result defines the target matrix
  74837. * @returns the current matrix
  74838. */
  74839. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74840. /**
  74841. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74842. * @param x defines the x coordinate to transform
  74843. * @param y defines the x coordinate to transform
  74844. * @param result defines the target vector2
  74845. * @returns the current matrix
  74846. */
  74847. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74848. /**
  74849. * Creates an identity matrix
  74850. * @returns a new matrix
  74851. */
  74852. static Identity(): Matrix2D;
  74853. /**
  74854. * Creates a translation matrix and stores it in a target matrix
  74855. * @param x defines the x coordinate of the translation
  74856. * @param y defines the y coordinate of the translation
  74857. * @param result defines the target matrix
  74858. */
  74859. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74860. /**
  74861. * Creates a scaling matrix and stores it in a target matrix
  74862. * @param x defines the x coordinate of the scaling
  74863. * @param y defines the y coordinate of the scaling
  74864. * @param result defines the target matrix
  74865. */
  74866. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74867. /**
  74868. * Creates a rotation matrix and stores it in a target matrix
  74869. * @param angle defines the rotation angle
  74870. * @param result defines the target matrix
  74871. */
  74872. static RotationToRef(angle: number, result: Matrix2D): void;
  74873. private static _TempPreTranslationMatrix;
  74874. private static _TempPostTranslationMatrix;
  74875. private static _TempRotationMatrix;
  74876. private static _TempScalingMatrix;
  74877. private static _TempCompose0;
  74878. private static _TempCompose1;
  74879. private static _TempCompose2;
  74880. /**
  74881. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74882. * @param tx defines the x coordinate of the translation
  74883. * @param ty defines the y coordinate of the translation
  74884. * @param angle defines the rotation angle
  74885. * @param scaleX defines the x coordinate of the scaling
  74886. * @param scaleY defines the y coordinate of the scaling
  74887. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74888. * @param result defines the target matrix
  74889. */
  74890. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74891. }
  74892. }
  74893. declare module BABYLON.GUI {
  74894. /**
  74895. * Class used to store 2D control sizes
  74896. */
  74897. export class Measure {
  74898. /** defines left coordinate */
  74899. left: number;
  74900. /** defines top coordinate */
  74901. top: number;
  74902. /** defines width dimension */
  74903. width: number;
  74904. /** defines height dimension */
  74905. height: number;
  74906. /**
  74907. * Creates a new measure
  74908. * @param left defines left coordinate
  74909. * @param top defines top coordinate
  74910. * @param width defines width dimension
  74911. * @param height defines height dimension
  74912. */
  74913. constructor(
  74914. /** defines left coordinate */
  74915. left: number,
  74916. /** defines top coordinate */
  74917. top: number,
  74918. /** defines width dimension */
  74919. width: number,
  74920. /** defines height dimension */
  74921. height: number);
  74922. /**
  74923. * Copy from another measure
  74924. * @param other defines the other measure to copy from
  74925. */
  74926. copyFrom(other: Measure): void;
  74927. /**
  74928. * Copy from a group of 4 floats
  74929. * @param left defines left coordinate
  74930. * @param top defines top coordinate
  74931. * @param width defines width dimension
  74932. * @param height defines height dimension
  74933. */
  74934. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74935. /**
  74936. * Computes the axis aligned bounding box measure for two given measures
  74937. * @param a Input measure
  74938. * @param b Input measure
  74939. * @param result the resulting bounding measure
  74940. */
  74941. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74942. /**
  74943. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74944. * @param transform the matrix to transform the measure before computing the AABB
  74945. * @param result the resulting AABB
  74946. */
  74947. transformToRef(transform: Matrix2D, result: Measure): void;
  74948. /**
  74949. * Check equality between this measure and another one
  74950. * @param other defines the other measures
  74951. * @returns true if both measures are equals
  74952. */
  74953. isEqualsTo(other: Measure): boolean;
  74954. /**
  74955. * Creates an empty measure
  74956. * @returns a new measure
  74957. */
  74958. static Empty(): Measure;
  74959. }
  74960. }
  74961. declare module BABYLON.GUI {
  74962. /**
  74963. * Interface used to define a control that can receive focus
  74964. */
  74965. export interface IFocusableControl {
  74966. /**
  74967. * Function called when the control receives the focus
  74968. */
  74969. onFocus(): void;
  74970. /**
  74971. * Function called when the control loses the focus
  74972. */
  74973. onBlur(): void;
  74974. /**
  74975. * Function called to let the control handle keyboard events
  74976. * @param evt defines the current keyboard event
  74977. */
  74978. processKeyboard(evt: KeyboardEvent): void;
  74979. /**
  74980. * Function called to get the list of controls that should not steal the focus from this control
  74981. * @returns an array of controls
  74982. */
  74983. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74984. }
  74985. /**
  74986. * Class used to create texture to support 2D GUI elements
  74987. * @see https://doc.babylonjs.com/how_to/gui
  74988. */
  74989. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74990. private _isDirty;
  74991. private _renderObserver;
  74992. private _resizeObserver;
  74993. private _preKeyboardObserver;
  74994. private _pointerMoveObserver;
  74995. private _pointerObserver;
  74996. private _canvasPointerOutObserver;
  74997. private _background;
  74998. /** @hidden */
  74999. _rootContainer: Container;
  75000. /** @hidden */
  75001. _lastPickedControl: Control;
  75002. /** @hidden */
  75003. _lastControlOver: {
  75004. [pointerId: number]: Control;
  75005. };
  75006. /** @hidden */
  75007. _lastControlDown: {
  75008. [pointerId: number]: Control;
  75009. };
  75010. /** @hidden */
  75011. _capturingControl: {
  75012. [pointerId: number]: Control;
  75013. };
  75014. /** @hidden */
  75015. _shouldBlockPointer: boolean;
  75016. /** @hidden */
  75017. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75018. /** @hidden */
  75019. _linkedControls: Control[];
  75020. private _isFullscreen;
  75021. private _fullscreenViewport;
  75022. private _idealWidth;
  75023. private _idealHeight;
  75024. private _useSmallestIdeal;
  75025. private _renderAtIdealSize;
  75026. private _focusedControl;
  75027. private _blockNextFocusCheck;
  75028. private _renderScale;
  75029. private _rootElement;
  75030. private _cursorChanged;
  75031. private _defaultMousePointerId;
  75032. /** @hidden */
  75033. _numLayoutCalls: number;
  75034. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75035. get numLayoutCalls(): number;
  75036. /** @hidden */
  75037. _numRenderCalls: number;
  75038. /** Gets the number of render calls made the last time the ADT has been rendered */
  75039. get numRenderCalls(): number;
  75040. /**
  75041. * Define type to string to ensure compatibility across browsers
  75042. * Safari doesn't support DataTransfer constructor
  75043. */
  75044. private _clipboardData;
  75045. /**
  75046. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75047. */
  75048. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75049. /**
  75050. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75051. */
  75052. onControlPickedObservable: BABYLON.Observable<Control>;
  75053. /**
  75054. * BABYLON.Observable event triggered before layout is evaluated
  75055. */
  75056. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75057. /**
  75058. * BABYLON.Observable event triggered after the layout was evaluated
  75059. */
  75060. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75061. /**
  75062. * BABYLON.Observable event triggered before the texture is rendered
  75063. */
  75064. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75065. /**
  75066. * BABYLON.Observable event triggered after the texture was rendered
  75067. */
  75068. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75069. /**
  75070. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75071. */
  75072. premulAlpha: boolean;
  75073. /**
  75074. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75075. * Useful when you want more antialiasing
  75076. */
  75077. get renderScale(): number;
  75078. set renderScale(value: number);
  75079. /** Gets or sets the background color */
  75080. get background(): string;
  75081. set background(value: string);
  75082. /**
  75083. * Gets or sets the ideal width used to design controls.
  75084. * The GUI will then rescale everything accordingly
  75085. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75086. */
  75087. get idealWidth(): number;
  75088. set idealWidth(value: number);
  75089. /**
  75090. * Gets or sets the ideal height used to design controls.
  75091. * The GUI will then rescale everything accordingly
  75092. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75093. */
  75094. get idealHeight(): number;
  75095. set idealHeight(value: number);
  75096. /**
  75097. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75098. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75099. */
  75100. get useSmallestIdeal(): boolean;
  75101. set useSmallestIdeal(value: boolean);
  75102. /**
  75103. * Gets or sets a boolean indicating if adaptive scaling must be used
  75104. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75105. */
  75106. get renderAtIdealSize(): boolean;
  75107. set renderAtIdealSize(value: boolean);
  75108. /**
  75109. * Gets the ratio used when in "ideal mode"
  75110. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75111. * */
  75112. get idealRatio(): number;
  75113. /**
  75114. * Gets the underlying layer used to render the texture when in fullscreen mode
  75115. */
  75116. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75117. /**
  75118. * Gets the root container control
  75119. */
  75120. get rootContainer(): Container;
  75121. /**
  75122. * Returns an array containing the root container.
  75123. * This is mostly used to let the Inspector introspects the ADT
  75124. * @returns an array containing the rootContainer
  75125. */
  75126. getChildren(): Array<Container>;
  75127. /**
  75128. * Will return all controls that are inside this texture
  75129. * @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
  75130. * @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
  75131. * @return all child controls
  75132. */
  75133. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75134. /**
  75135. * Gets or sets the current focused control
  75136. */
  75137. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75138. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75139. /**
  75140. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75141. */
  75142. get isForeground(): boolean;
  75143. set isForeground(value: boolean);
  75144. /**
  75145. * Gets or set information about clipboardData
  75146. */
  75147. get clipboardData(): string;
  75148. set clipboardData(value: string);
  75149. /**
  75150. * Creates a new AdvancedDynamicTexture
  75151. * @param name defines the name of the texture
  75152. * @param width defines the width of the texture
  75153. * @param height defines the height of the texture
  75154. * @param scene defines the hosting scene
  75155. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75156. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75157. */
  75158. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75159. /**
  75160. * Get the current class name of the texture useful for serialization or dynamic coding.
  75161. * @returns "AdvancedDynamicTexture"
  75162. */
  75163. getClassName(): string;
  75164. /**
  75165. * Function used to execute a function on all controls
  75166. * @param func defines the function to execute
  75167. * @param container defines the container where controls belong. If null the root container will be used
  75168. */
  75169. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75170. private _useInvalidateRectOptimization;
  75171. /**
  75172. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75173. */
  75174. get useInvalidateRectOptimization(): boolean;
  75175. set useInvalidateRectOptimization(value: boolean);
  75176. private _invalidatedRectangle;
  75177. /**
  75178. * Invalidates a rectangle area on the gui texture
  75179. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75180. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75181. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75182. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75183. */
  75184. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75185. /**
  75186. * Marks the texture as dirty forcing a complete update
  75187. */
  75188. markAsDirty(): void;
  75189. /**
  75190. * Helper function used to create a new style
  75191. * @returns a new style
  75192. * @see https://doc.babylonjs.com/how_to/gui#styles
  75193. */
  75194. createStyle(): Style;
  75195. /**
  75196. * Adds a new control to the root container
  75197. * @param control defines the control to add
  75198. * @returns the current texture
  75199. */
  75200. addControl(control: Control): AdvancedDynamicTexture;
  75201. /**
  75202. * Removes a control from the root container
  75203. * @param control defines the control to remove
  75204. * @returns the current texture
  75205. */
  75206. removeControl(control: Control): AdvancedDynamicTexture;
  75207. /**
  75208. * Release all resources
  75209. */
  75210. dispose(): void;
  75211. private _onResize;
  75212. /** @hidden */
  75213. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75214. /**
  75215. * Get screen coordinates for a vector3
  75216. * @param position defines the position to project
  75217. * @param worldMatrix defines the world matrix to use
  75218. * @returns the projected position
  75219. */
  75220. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75221. private _checkUpdate;
  75222. private _clearMeasure;
  75223. private _render;
  75224. /** @hidden */
  75225. _changeCursor(cursor: string): void;
  75226. /** @hidden */
  75227. _registerLastControlDown(control: Control, pointerId: number): void;
  75228. private _doPicking;
  75229. /** @hidden */
  75230. _cleanControlAfterRemovalFromList(list: {
  75231. [pointerId: number]: Control;
  75232. }, control: Control): void;
  75233. /** @hidden */
  75234. _cleanControlAfterRemoval(control: Control): void;
  75235. /** Attach to all scene events required to support pointer events */
  75236. attach(): void;
  75237. /** @hidden */
  75238. private onClipboardCopy;
  75239. /** @hidden */
  75240. private onClipboardCut;
  75241. /** @hidden */
  75242. private onClipboardPaste;
  75243. /**
  75244. * Register the clipboard Events onto the canvas
  75245. */
  75246. registerClipboardEvents(): void;
  75247. /**
  75248. * Unregister the clipboard Events from the canvas
  75249. */
  75250. unRegisterClipboardEvents(): void;
  75251. /**
  75252. * Connect the texture to a hosting mesh to enable interactions
  75253. * @param mesh defines the mesh to attach to
  75254. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75255. */
  75256. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75257. /**
  75258. * Move the focus to a specific control
  75259. * @param control defines the control which will receive the focus
  75260. */
  75261. moveFocusToControl(control: IFocusableControl): void;
  75262. private _manageFocus;
  75263. private _attachToOnPointerOut;
  75264. /**
  75265. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75266. * @param mesh defines the mesh which will receive the texture
  75267. * @param width defines the texture width (1024 by default)
  75268. * @param height defines the texture height (1024 by default)
  75269. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75270. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75271. * @returns a new AdvancedDynamicTexture
  75272. */
  75273. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75274. /**
  75275. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75276. * In this mode the texture will rely on a layer for its rendering.
  75277. * This allows it to be treated like any other layer.
  75278. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75279. * LayerMask is set through advancedTexture.layer.layerMask
  75280. * @param name defines name for the texture
  75281. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75282. * @param scene defines the hsoting scene
  75283. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75284. * @returns a new AdvancedDynamicTexture
  75285. */
  75286. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75287. }
  75288. }
  75289. declare module BABYLON.GUI {
  75290. /**
  75291. * Root class used for all 2D controls
  75292. * @see https://doc.babylonjs.com/how_to/gui#controls
  75293. */
  75294. export class Control {
  75295. /** defines the name of the control */
  75296. name?: string | undefined;
  75297. /**
  75298. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75299. */
  75300. static AllowAlphaInheritance: boolean;
  75301. private _alpha;
  75302. private _alphaSet;
  75303. private _zIndex;
  75304. /** @hidden */
  75305. _host: AdvancedDynamicTexture;
  75306. /** Gets or sets the control parent */
  75307. parent: BABYLON.Nullable<Container>;
  75308. /** @hidden */
  75309. _currentMeasure: Measure;
  75310. private _fontFamily;
  75311. private _fontStyle;
  75312. private _fontWeight;
  75313. private _fontSize;
  75314. private _font;
  75315. /** @hidden */
  75316. _width: ValueAndUnit;
  75317. /** @hidden */
  75318. _height: ValueAndUnit;
  75319. /** @hidden */
  75320. protected _fontOffset: {
  75321. ascent: number;
  75322. height: number;
  75323. descent: number;
  75324. };
  75325. private _color;
  75326. private _style;
  75327. private _styleObserver;
  75328. /** @hidden */
  75329. protected _horizontalAlignment: number;
  75330. /** @hidden */
  75331. protected _verticalAlignment: number;
  75332. /** @hidden */
  75333. protected _isDirty: boolean;
  75334. /** @hidden */
  75335. protected _wasDirty: boolean;
  75336. /** @hidden */
  75337. _tempParentMeasure: Measure;
  75338. /** @hidden */
  75339. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75340. /** @hidden */
  75341. protected _cachedParentMeasure: Measure;
  75342. private _paddingLeft;
  75343. private _paddingRight;
  75344. private _paddingTop;
  75345. private _paddingBottom;
  75346. /** @hidden */
  75347. _left: ValueAndUnit;
  75348. /** @hidden */
  75349. _top: ValueAndUnit;
  75350. private _scaleX;
  75351. private _scaleY;
  75352. private _rotation;
  75353. private _transformCenterX;
  75354. private _transformCenterY;
  75355. /** @hidden */
  75356. _transformMatrix: Matrix2D;
  75357. /** @hidden */
  75358. protected _invertTransformMatrix: Matrix2D;
  75359. /** @hidden */
  75360. protected _transformedPosition: BABYLON.Vector2;
  75361. private _isMatrixDirty;
  75362. private _cachedOffsetX;
  75363. private _cachedOffsetY;
  75364. private _isVisible;
  75365. private _isHighlighted;
  75366. /** @hidden */
  75367. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75368. private _fontSet;
  75369. private _dummyVector2;
  75370. private _downCount;
  75371. private _enterCount;
  75372. private _doNotRender;
  75373. private _downPointerIds;
  75374. protected _isEnabled: boolean;
  75375. protected _disabledColor: string;
  75376. protected _disabledColorItem: string;
  75377. /** @hidden */
  75378. protected _rebuildLayout: boolean;
  75379. /** @hidden */
  75380. _customData: any;
  75381. /** @hidden */
  75382. _isClipped: boolean;
  75383. /** @hidden */
  75384. _automaticSize: boolean;
  75385. /** @hidden */
  75386. _tag: any;
  75387. /**
  75388. * 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
  75389. */
  75390. uniqueId: number;
  75391. /**
  75392. * Gets or sets an object used to store user defined information for the node
  75393. */
  75394. metadata: any;
  75395. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75396. isHitTestVisible: boolean;
  75397. /** Gets or sets a boolean indicating if the control can block pointer events */
  75398. isPointerBlocker: boolean;
  75399. /** Gets or sets a boolean indicating if the control can be focusable */
  75400. isFocusInvisible: boolean;
  75401. /**
  75402. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75403. * 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
  75404. */
  75405. clipChildren: boolean;
  75406. /**
  75407. * Gets or sets a boolean indicating that control content must be clipped
  75408. * 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
  75409. */
  75410. clipContent: boolean;
  75411. /**
  75412. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75413. */
  75414. useBitmapCache: boolean;
  75415. private _cacheData;
  75416. private _shadowOffsetX;
  75417. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75418. get shadowOffsetX(): number;
  75419. set shadowOffsetX(value: number);
  75420. private _shadowOffsetY;
  75421. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75422. get shadowOffsetY(): number;
  75423. set shadowOffsetY(value: number);
  75424. private _shadowBlur;
  75425. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75426. get shadowBlur(): number;
  75427. set shadowBlur(value: number);
  75428. private _shadowColor;
  75429. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75430. get shadowColor(): string;
  75431. set shadowColor(value: string);
  75432. /** Gets or sets the cursor to use when the control is hovered */
  75433. hoverCursor: string;
  75434. /** @hidden */
  75435. protected _linkOffsetX: ValueAndUnit;
  75436. /** @hidden */
  75437. protected _linkOffsetY: ValueAndUnit;
  75438. /** Gets the control type name */
  75439. get typeName(): string;
  75440. /**
  75441. * Get the current class name of the control.
  75442. * @returns current class name
  75443. */
  75444. getClassName(): string;
  75445. /**
  75446. * An event triggered when pointer wheel is scrolled
  75447. */
  75448. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75449. /**
  75450. * An event triggered when the pointer move over the control.
  75451. */
  75452. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75453. /**
  75454. * An event triggered when the pointer move out of the control.
  75455. */
  75456. onPointerOutObservable: BABYLON.Observable<Control>;
  75457. /**
  75458. * An event triggered when the pointer taps the control
  75459. */
  75460. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75461. /**
  75462. * An event triggered when pointer up
  75463. */
  75464. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75465. /**
  75466. * An event triggered when a control is clicked on
  75467. */
  75468. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75469. /**
  75470. * An event triggered when pointer enters the control
  75471. */
  75472. onPointerEnterObservable: BABYLON.Observable<Control>;
  75473. /**
  75474. * An event triggered when the control is marked as dirty
  75475. */
  75476. onDirtyObservable: BABYLON.Observable<Control>;
  75477. /**
  75478. * An event triggered before drawing the control
  75479. */
  75480. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75481. /**
  75482. * An event triggered after the control was drawn
  75483. */
  75484. onAfterDrawObservable: BABYLON.Observable<Control>;
  75485. /**
  75486. * An event triggered when the control has been disposed
  75487. */
  75488. onDisposeObservable: BABYLON.Observable<Control>;
  75489. /**
  75490. * Get the hosting AdvancedDynamicTexture
  75491. */
  75492. get host(): AdvancedDynamicTexture;
  75493. /** Gets or set information about font offsets (used to render and align text) */
  75494. get fontOffset(): {
  75495. ascent: number;
  75496. height: number;
  75497. descent: number;
  75498. };
  75499. set fontOffset(offset: {
  75500. ascent: number;
  75501. height: number;
  75502. descent: number;
  75503. });
  75504. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75505. get alpha(): number;
  75506. set alpha(value: number);
  75507. /**
  75508. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75509. */
  75510. get isHighlighted(): boolean;
  75511. set isHighlighted(value: boolean);
  75512. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75513. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75514. */
  75515. get scaleX(): number;
  75516. set scaleX(value: number);
  75517. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75518. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75519. */
  75520. get scaleY(): number;
  75521. set scaleY(value: number);
  75522. /** Gets or sets the rotation angle (0 by default)
  75523. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75524. */
  75525. get rotation(): number;
  75526. set rotation(value: number);
  75527. /** Gets or sets the transformation center on Y axis (0 by default)
  75528. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75529. */
  75530. get transformCenterY(): number;
  75531. set transformCenterY(value: number);
  75532. /** Gets or sets the transformation center on X axis (0 by default)
  75533. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75534. */
  75535. get transformCenterX(): number;
  75536. set transformCenterX(value: number);
  75537. /**
  75538. * Gets or sets the horizontal alignment
  75539. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75540. */
  75541. get horizontalAlignment(): number;
  75542. set horizontalAlignment(value: number);
  75543. /**
  75544. * Gets or sets the vertical alignment
  75545. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75546. */
  75547. get verticalAlignment(): number;
  75548. set verticalAlignment(value: number);
  75549. /**
  75550. * Gets or sets control width
  75551. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75552. */
  75553. get width(): string | number;
  75554. set width(value: string | number);
  75555. /**
  75556. * Gets or sets the control width in pixel
  75557. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75558. */
  75559. get widthInPixels(): number;
  75560. set widthInPixels(value: number);
  75561. /**
  75562. * Gets or sets control height
  75563. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75564. */
  75565. get height(): string | number;
  75566. set height(value: string | number);
  75567. /**
  75568. * Gets or sets control height in pixel
  75569. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75570. */
  75571. get heightInPixels(): number;
  75572. set heightInPixels(value: number);
  75573. /** Gets or set font family */
  75574. get fontFamily(): string;
  75575. set fontFamily(value: string);
  75576. /** Gets or sets font style */
  75577. get fontStyle(): string;
  75578. set fontStyle(value: string);
  75579. /** Gets or sets font weight */
  75580. get fontWeight(): string;
  75581. set fontWeight(value: string);
  75582. /**
  75583. * Gets or sets style
  75584. * @see https://doc.babylonjs.com/how_to/gui#styles
  75585. */
  75586. get style(): BABYLON.Nullable<Style>;
  75587. set style(value: BABYLON.Nullable<Style>);
  75588. /** @hidden */
  75589. get _isFontSizeInPercentage(): boolean;
  75590. /** Gets or sets font size in pixels */
  75591. get fontSizeInPixels(): number;
  75592. set fontSizeInPixels(value: number);
  75593. /** Gets or sets font size */
  75594. get fontSize(): string | number;
  75595. set fontSize(value: string | number);
  75596. /** Gets or sets foreground color */
  75597. get color(): string;
  75598. set color(value: string);
  75599. /** Gets or sets z index which is used to reorder controls on the z axis */
  75600. get zIndex(): number;
  75601. set zIndex(value: number);
  75602. /** Gets or sets a boolean indicating if the control can be rendered */
  75603. get notRenderable(): boolean;
  75604. set notRenderable(value: boolean);
  75605. /** Gets or sets a boolean indicating if the control is visible */
  75606. get isVisible(): boolean;
  75607. set isVisible(value: boolean);
  75608. /** Gets a boolean indicating that the control needs to update its rendering */
  75609. get isDirty(): boolean;
  75610. /**
  75611. * Gets the current linked mesh (or null if none)
  75612. */
  75613. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75614. /**
  75615. * Gets or sets a value indicating the padding to use on the left of the control
  75616. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75617. */
  75618. get paddingLeft(): string | number;
  75619. set paddingLeft(value: string | number);
  75620. /**
  75621. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75622. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75623. */
  75624. get paddingLeftInPixels(): number;
  75625. set paddingLeftInPixels(value: number);
  75626. /**
  75627. * Gets or sets a value indicating the padding to use on the right of the control
  75628. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75629. */
  75630. get paddingRight(): string | number;
  75631. set paddingRight(value: string | number);
  75632. /**
  75633. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75634. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75635. */
  75636. get paddingRightInPixels(): number;
  75637. set paddingRightInPixels(value: number);
  75638. /**
  75639. * Gets or sets a value indicating the padding to use on the top of the control
  75640. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75641. */
  75642. get paddingTop(): string | number;
  75643. set paddingTop(value: string | number);
  75644. /**
  75645. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75646. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75647. */
  75648. get paddingTopInPixels(): number;
  75649. set paddingTopInPixels(value: number);
  75650. /**
  75651. * Gets or sets a value indicating the padding to use on the bottom of the control
  75652. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75653. */
  75654. get paddingBottom(): string | number;
  75655. set paddingBottom(value: string | number);
  75656. /**
  75657. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75658. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75659. */
  75660. get paddingBottomInPixels(): number;
  75661. set paddingBottomInPixels(value: number);
  75662. /**
  75663. * Gets or sets a value indicating the left coordinate of the control
  75664. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75665. */
  75666. get left(): string | number;
  75667. set left(value: string | number);
  75668. /**
  75669. * Gets or sets a value indicating the left coordinate in pixels of the control
  75670. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75671. */
  75672. get leftInPixels(): number;
  75673. set leftInPixels(value: number);
  75674. /**
  75675. * Gets or sets a value indicating the top coordinate of the control
  75676. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75677. */
  75678. get top(): string | number;
  75679. set top(value: string | number);
  75680. /**
  75681. * Gets or sets a value indicating the top coordinate in pixels of the control
  75682. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75683. */
  75684. get topInPixels(): number;
  75685. set topInPixels(value: number);
  75686. /**
  75687. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75688. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75689. */
  75690. get linkOffsetX(): string | number;
  75691. set linkOffsetX(value: string | number);
  75692. /**
  75693. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75694. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75695. */
  75696. get linkOffsetXInPixels(): number;
  75697. set linkOffsetXInPixels(value: number);
  75698. /**
  75699. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75700. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75701. */
  75702. get linkOffsetY(): string | number;
  75703. set linkOffsetY(value: string | number);
  75704. /**
  75705. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75706. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75707. */
  75708. get linkOffsetYInPixels(): number;
  75709. set linkOffsetYInPixels(value: number);
  75710. /** Gets the center coordinate on X axis */
  75711. get centerX(): number;
  75712. /** Gets the center coordinate on Y axis */
  75713. get centerY(): number;
  75714. /** Gets or sets if control is Enabled*/
  75715. get isEnabled(): boolean;
  75716. set isEnabled(value: boolean);
  75717. /** Gets or sets background color of control if it's disabled*/
  75718. get disabledColor(): string;
  75719. set disabledColor(value: string);
  75720. /** Gets or sets front color of control if it's disabled*/
  75721. get disabledColorItem(): string;
  75722. set disabledColorItem(value: string);
  75723. /**
  75724. * Creates a new control
  75725. * @param name defines the name of the control
  75726. */
  75727. constructor(
  75728. /** defines the name of the control */
  75729. name?: string | undefined);
  75730. /** @hidden */
  75731. protected _getTypeName(): string;
  75732. /**
  75733. * Gets the first ascendant in the hierarchy of the given type
  75734. * @param className defines the required type
  75735. * @returns the ascendant or null if not found
  75736. */
  75737. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75738. /** @hidden */
  75739. _resetFontCache(): void;
  75740. /**
  75741. * Determines if a container is an ascendant of the current control
  75742. * @param container defines the container to look for
  75743. * @returns true if the container is one of the ascendant of the control
  75744. */
  75745. isAscendant(container: Control): boolean;
  75746. /**
  75747. * Gets coordinates in local control space
  75748. * @param globalCoordinates defines the coordinates to transform
  75749. * @returns the new coordinates in local space
  75750. */
  75751. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75752. /**
  75753. * Gets coordinates in local control space
  75754. * @param globalCoordinates defines the coordinates to transform
  75755. * @param result defines the target vector2 where to store the result
  75756. * @returns the current control
  75757. */
  75758. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75759. /**
  75760. * Gets coordinates in parent local control space
  75761. * @param globalCoordinates defines the coordinates to transform
  75762. * @returns the new coordinates in parent local space
  75763. */
  75764. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75765. /**
  75766. * Move the current control to a vector3 position projected onto the screen.
  75767. * @param position defines the target position
  75768. * @param scene defines the hosting scene
  75769. */
  75770. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75771. /**
  75772. * Will store all controls that have this control as ascendant in a given array
  75773. * @param results defines the array where to store the descendants
  75774. * @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
  75775. * @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
  75776. */
  75777. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75778. /**
  75779. * Will return all controls that have this control as ascendant
  75780. * @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
  75781. * @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
  75782. * @return all child controls
  75783. */
  75784. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75785. /**
  75786. * Link current control with a target mesh
  75787. * @param mesh defines the mesh to link with
  75788. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75789. */
  75790. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75791. /** @hidden */
  75792. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75793. /** @hidden */
  75794. _offsetLeft(offset: number): void;
  75795. /** @hidden */
  75796. _offsetTop(offset: number): void;
  75797. /** @hidden */
  75798. _markMatrixAsDirty(): void;
  75799. /** @hidden */
  75800. _flagDescendantsAsMatrixDirty(): void;
  75801. /** @hidden */
  75802. _intersectsRect(rect: Measure): boolean;
  75803. /** @hidden */
  75804. protected invalidateRect(): void;
  75805. /** @hidden */
  75806. _markAsDirty(force?: boolean): void;
  75807. /** @hidden */
  75808. _markAllAsDirty(): void;
  75809. /** @hidden */
  75810. _link(host: AdvancedDynamicTexture): void;
  75811. /** @hidden */
  75812. protected _transform(context?: CanvasRenderingContext2D): void;
  75813. /** @hidden */
  75814. _renderHighlight(context: CanvasRenderingContext2D): void;
  75815. /** @hidden */
  75816. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75817. /** @hidden */
  75818. protected _applyStates(context: CanvasRenderingContext2D): void;
  75819. /** @hidden */
  75820. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75821. /** @hidden */
  75822. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75823. protected _evaluateClippingState(parentMeasure: Measure): void;
  75824. /** @hidden */
  75825. _measure(): void;
  75826. /** @hidden */
  75827. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75828. /** @hidden */
  75829. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75830. /** @hidden */
  75831. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75832. /** @hidden */
  75833. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75834. private static _ClipMeasure;
  75835. private _tmpMeasureA;
  75836. private _clip;
  75837. /** @hidden */
  75838. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75839. /** @hidden */
  75840. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75841. /**
  75842. * Tests if a given coordinates belong to the current control
  75843. * @param x defines x coordinate to test
  75844. * @param y defines y coordinate to test
  75845. * @returns true if the coordinates are inside the control
  75846. */
  75847. contains(x: number, y: number): boolean;
  75848. /** @hidden */
  75849. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75850. /** @hidden */
  75851. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75852. /** @hidden */
  75853. _onPointerEnter(target: Control): boolean;
  75854. /** @hidden */
  75855. _onPointerOut(target: Control, force?: boolean): void;
  75856. /** @hidden */
  75857. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75858. /** @hidden */
  75859. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75860. /** @hidden */
  75861. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75862. /** @hidden */
  75863. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75864. /** @hidden */
  75865. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75866. private _prepareFont;
  75867. /** Releases associated resources */
  75868. dispose(): void;
  75869. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75870. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75871. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75872. private static _VERTICAL_ALIGNMENT_TOP;
  75873. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75874. private static _VERTICAL_ALIGNMENT_CENTER;
  75875. /** HORIZONTAL_ALIGNMENT_LEFT */
  75876. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75877. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75878. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75879. /** HORIZONTAL_ALIGNMENT_CENTER */
  75880. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75881. /** VERTICAL_ALIGNMENT_TOP */
  75882. static get VERTICAL_ALIGNMENT_TOP(): number;
  75883. /** VERTICAL_ALIGNMENT_BOTTOM */
  75884. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75885. /** VERTICAL_ALIGNMENT_CENTER */
  75886. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75887. private static _FontHeightSizes;
  75888. /** @hidden */
  75889. static _GetFontOffset(font: string): {
  75890. ascent: number;
  75891. height: number;
  75892. descent: number;
  75893. };
  75894. /**
  75895. * Creates a stack panel that can be used to render headers
  75896. * @param control defines the control to associate with the header
  75897. * @param text defines the text of the header
  75898. * @param size defines the size of the header
  75899. * @param options defines options used to configure the header
  75900. * @returns a new StackPanel
  75901. * @ignore
  75902. * @hidden
  75903. */
  75904. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75905. isHorizontal: boolean;
  75906. controlFirst: boolean;
  75907. }) => any;
  75908. /** @hidden */
  75909. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75910. }
  75911. }
  75912. declare module BABYLON.GUI {
  75913. /**
  75914. * Root class for 2D containers
  75915. * @see https://doc.babylonjs.com/how_to/gui#containers
  75916. */
  75917. export class Container extends Control {
  75918. name?: string | undefined;
  75919. /** @hidden */
  75920. _children: Control[];
  75921. /** @hidden */
  75922. protected _measureForChildren: Measure;
  75923. /** @hidden */
  75924. protected _background: string;
  75925. /** @hidden */
  75926. protected _adaptWidthToChildren: boolean;
  75927. /** @hidden */
  75928. protected _adaptHeightToChildren: boolean;
  75929. /**
  75930. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75931. */
  75932. logLayoutCycleErrors: boolean;
  75933. /**
  75934. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75935. */
  75936. maxLayoutCycle: number;
  75937. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75938. get adaptHeightToChildren(): boolean;
  75939. set adaptHeightToChildren(value: boolean);
  75940. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75941. get adaptWidthToChildren(): boolean;
  75942. set adaptWidthToChildren(value: boolean);
  75943. /** Gets or sets background color */
  75944. get background(): string;
  75945. set background(value: string);
  75946. /** Gets the list of children */
  75947. get children(): Control[];
  75948. /**
  75949. * Creates a new Container
  75950. * @param name defines the name of the container
  75951. */
  75952. constructor(name?: string | undefined);
  75953. protected _getTypeName(): string;
  75954. _flagDescendantsAsMatrixDirty(): void;
  75955. /**
  75956. * Gets a child using its name
  75957. * @param name defines the child name to look for
  75958. * @returns the child control if found
  75959. */
  75960. getChildByName(name: string): BABYLON.Nullable<Control>;
  75961. /**
  75962. * Gets a child using its type and its name
  75963. * @param name defines the child name to look for
  75964. * @param type defines the child type to look for
  75965. * @returns the child control if found
  75966. */
  75967. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75968. /**
  75969. * Search for a specific control in children
  75970. * @param control defines the control to look for
  75971. * @returns true if the control is in child list
  75972. */
  75973. containsControl(control: Control): boolean;
  75974. /**
  75975. * Adds a new control to the current container
  75976. * @param control defines the control to add
  75977. * @returns the current container
  75978. */
  75979. addControl(control: BABYLON.Nullable<Control>): Container;
  75980. /**
  75981. * Removes all controls from the current container
  75982. * @returns the current container
  75983. */
  75984. clearControls(): Container;
  75985. /**
  75986. * Removes a control from the current container
  75987. * @param control defines the control to remove
  75988. * @returns the current container
  75989. */
  75990. removeControl(control: Control): Container;
  75991. /** @hidden */
  75992. _reOrderControl(control: Control): void;
  75993. /** @hidden */
  75994. _offsetLeft(offset: number): void;
  75995. /** @hidden */
  75996. _offsetTop(offset: number): void;
  75997. /** @hidden */
  75998. _markAllAsDirty(): void;
  75999. /** @hidden */
  76000. protected _localDraw(context: CanvasRenderingContext2D): void;
  76001. /** @hidden */
  76002. _link(host: AdvancedDynamicTexture): void;
  76003. /** @hidden */
  76004. protected _beforeLayout(): void;
  76005. /** @hidden */
  76006. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76007. /** @hidden */
  76008. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76009. protected _postMeasure(): void;
  76010. /** @hidden */
  76011. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76012. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76013. /** @hidden */
  76014. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76015. /** @hidden */
  76016. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76017. /** Releases associated resources */
  76018. dispose(): void;
  76019. }
  76020. }
  76021. declare module BABYLON.GUI {
  76022. /** Class used to create rectangle container */
  76023. export class Rectangle extends Container {
  76024. name?: string | undefined;
  76025. private _thickness;
  76026. private _cornerRadius;
  76027. /** Gets or sets border thickness */
  76028. get thickness(): number;
  76029. set thickness(value: number);
  76030. /** Gets or sets the corner radius angle */
  76031. get cornerRadius(): number;
  76032. set cornerRadius(value: number);
  76033. /**
  76034. * Creates a new Rectangle
  76035. * @param name defines the control name
  76036. */
  76037. constructor(name?: string | undefined);
  76038. protected _getTypeName(): string;
  76039. protected _localDraw(context: CanvasRenderingContext2D): void;
  76040. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76041. private _drawRoundedRect;
  76042. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76043. }
  76044. }
  76045. declare module BABYLON.GUI {
  76046. /**
  76047. * Enum that determines the text-wrapping mode to use.
  76048. */
  76049. export enum TextWrapping {
  76050. /**
  76051. * Clip the text when it's larger than Control.width; this is the default mode.
  76052. */
  76053. Clip = 0,
  76054. /**
  76055. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76056. */
  76057. WordWrap = 1,
  76058. /**
  76059. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76060. */
  76061. Ellipsis = 2
  76062. }
  76063. /**
  76064. * Class used to create text block control
  76065. */
  76066. export class TextBlock extends Control {
  76067. /**
  76068. * Defines the name of the control
  76069. */
  76070. name?: string | undefined;
  76071. private _text;
  76072. private _textWrapping;
  76073. private _textHorizontalAlignment;
  76074. private _textVerticalAlignment;
  76075. private _lines;
  76076. private _resizeToFit;
  76077. private _lineSpacing;
  76078. private _outlineWidth;
  76079. private _outlineColor;
  76080. /**
  76081. * An event triggered after the text is changed
  76082. */
  76083. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76084. /**
  76085. * An event triggered after the text was broken up into lines
  76086. */
  76087. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76088. /**
  76089. * Function used to split a string into words. By default, a string is split at each space character found
  76090. */
  76091. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76092. /**
  76093. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76094. */
  76095. get lines(): any[];
  76096. /**
  76097. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76098. */
  76099. get resizeToFit(): boolean;
  76100. /**
  76101. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76102. */
  76103. set resizeToFit(value: boolean);
  76104. /**
  76105. * Gets or sets a boolean indicating if text must be wrapped
  76106. */
  76107. get textWrapping(): TextWrapping | boolean;
  76108. /**
  76109. * Gets or sets a boolean indicating if text must be wrapped
  76110. */
  76111. set textWrapping(value: TextWrapping | boolean);
  76112. /**
  76113. * Gets or sets text to display
  76114. */
  76115. get text(): string;
  76116. /**
  76117. * Gets or sets text to display
  76118. */
  76119. set text(value: string);
  76120. /**
  76121. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76122. */
  76123. get textHorizontalAlignment(): number;
  76124. /**
  76125. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76126. */
  76127. set textHorizontalAlignment(value: number);
  76128. /**
  76129. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76130. */
  76131. get textVerticalAlignment(): number;
  76132. /**
  76133. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76134. */
  76135. set textVerticalAlignment(value: number);
  76136. /**
  76137. * Gets or sets line spacing value
  76138. */
  76139. set lineSpacing(value: string | number);
  76140. /**
  76141. * Gets or sets line spacing value
  76142. */
  76143. get lineSpacing(): string | number;
  76144. /**
  76145. * Gets or sets outlineWidth of the text to display
  76146. */
  76147. get outlineWidth(): number;
  76148. /**
  76149. * Gets or sets outlineWidth of the text to display
  76150. */
  76151. set outlineWidth(value: number);
  76152. /**
  76153. * Gets or sets outlineColor of the text to display
  76154. */
  76155. get outlineColor(): string;
  76156. /**
  76157. * Gets or sets outlineColor of the text to display
  76158. */
  76159. set outlineColor(value: string);
  76160. /**
  76161. * Creates a new TextBlock object
  76162. * @param name defines the name of the control
  76163. * @param text defines the text to display (emptry string by default)
  76164. */
  76165. constructor(
  76166. /**
  76167. * Defines the name of the control
  76168. */
  76169. name?: string | undefined, text?: string);
  76170. protected _getTypeName(): string;
  76171. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76172. private _drawText;
  76173. /** @hidden */
  76174. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76175. protected _applyStates(context: CanvasRenderingContext2D): void;
  76176. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76177. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76178. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76179. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76180. protected _renderLines(context: CanvasRenderingContext2D): void;
  76181. /**
  76182. * Given a width constraint applied on the text block, find the expected height
  76183. * @returns expected height
  76184. */
  76185. computeExpectedHeight(): number;
  76186. dispose(): void;
  76187. }
  76188. }
  76189. declare module BABYLON.GUI {
  76190. /**
  76191. * Class used to create 2D images
  76192. */
  76193. export class Image extends Control {
  76194. name?: string | undefined;
  76195. private _workingCanvas;
  76196. private _domImage;
  76197. private _imageWidth;
  76198. private _imageHeight;
  76199. private _loaded;
  76200. private _stretch;
  76201. private _source;
  76202. private _autoScale;
  76203. private _sourceLeft;
  76204. private _sourceTop;
  76205. private _sourceWidth;
  76206. private _sourceHeight;
  76207. private _svgAttributesComputationCompleted;
  76208. private _isSVG;
  76209. private _cellWidth;
  76210. private _cellHeight;
  76211. private _cellId;
  76212. private _populateNinePatchSlicesFromImage;
  76213. private _sliceLeft;
  76214. private _sliceRight;
  76215. private _sliceTop;
  76216. private _sliceBottom;
  76217. private _detectPointerOnOpaqueOnly;
  76218. /**
  76219. * BABYLON.Observable notified when the content is loaded
  76220. */
  76221. onImageLoadedObservable: BABYLON.Observable<Image>;
  76222. /**
  76223. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76224. */
  76225. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76226. /**
  76227. * Gets a boolean indicating that the content is loaded
  76228. */
  76229. get isLoaded(): boolean;
  76230. /**
  76231. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76232. */
  76233. get populateNinePatchSlicesFromImage(): boolean;
  76234. set populateNinePatchSlicesFromImage(value: boolean);
  76235. /**
  76236. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76237. * Beware using this as this will comsume more memory as the image has to be stored twice
  76238. */
  76239. get detectPointerOnOpaqueOnly(): boolean;
  76240. set detectPointerOnOpaqueOnly(value: boolean);
  76241. /**
  76242. * Gets or sets the left value for slicing (9-patch)
  76243. */
  76244. get sliceLeft(): number;
  76245. set sliceLeft(value: number);
  76246. /**
  76247. * Gets or sets the right value for slicing (9-patch)
  76248. */
  76249. get sliceRight(): number;
  76250. set sliceRight(value: number);
  76251. /**
  76252. * Gets or sets the top value for slicing (9-patch)
  76253. */
  76254. get sliceTop(): number;
  76255. set sliceTop(value: number);
  76256. /**
  76257. * Gets or sets the bottom value for slicing (9-patch)
  76258. */
  76259. get sliceBottom(): number;
  76260. set sliceBottom(value: number);
  76261. /**
  76262. * Gets or sets the left coordinate in the source image
  76263. */
  76264. get sourceLeft(): number;
  76265. set sourceLeft(value: number);
  76266. /**
  76267. * Gets or sets the top coordinate in the source image
  76268. */
  76269. get sourceTop(): number;
  76270. set sourceTop(value: number);
  76271. /**
  76272. * Gets or sets the width to capture in the source image
  76273. */
  76274. get sourceWidth(): number;
  76275. set sourceWidth(value: number);
  76276. /**
  76277. * Gets or sets the height to capture in the source image
  76278. */
  76279. get sourceHeight(): number;
  76280. set sourceHeight(value: number);
  76281. /** Indicates if the format of the image is SVG */
  76282. get isSVG(): boolean;
  76283. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76284. get svgAttributesComputationCompleted(): boolean;
  76285. /**
  76286. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76287. * @see https://doc.babylonjs.com/how_to/gui#image
  76288. */
  76289. get autoScale(): boolean;
  76290. set autoScale(value: boolean);
  76291. /** Gets or sets the streching mode used by the image */
  76292. get stretch(): number;
  76293. set stretch(value: number);
  76294. /** @hidden */
  76295. _rotate90(n: number, preserveProperties?: boolean): Image;
  76296. private _handleRotationForSVGImage;
  76297. private _rotate90SourceProperties;
  76298. /**
  76299. * Gets or sets the internal DOM image used to render the control
  76300. */
  76301. set domImage(value: HTMLImageElement);
  76302. get domImage(): HTMLImageElement;
  76303. private _onImageLoaded;
  76304. private _extractNinePatchSliceDataFromImage;
  76305. /**
  76306. * Gets or sets image source url
  76307. */
  76308. set source(value: BABYLON.Nullable<string>);
  76309. /**
  76310. * Checks for svg document with icon id present
  76311. */
  76312. private _svgCheck;
  76313. /**
  76314. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76315. * given external svg file and icon id
  76316. */
  76317. private _getSVGAttribs;
  76318. /**
  76319. * Gets or sets the cell width to use when animation sheet is enabled
  76320. * @see https://doc.babylonjs.com/how_to/gui#image
  76321. */
  76322. get cellWidth(): number;
  76323. set cellWidth(value: number);
  76324. /**
  76325. * Gets or sets the cell height to use when animation sheet is enabled
  76326. * @see https://doc.babylonjs.com/how_to/gui#image
  76327. */
  76328. get cellHeight(): number;
  76329. set cellHeight(value: number);
  76330. /**
  76331. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76332. * @see https://doc.babylonjs.com/how_to/gui#image
  76333. */
  76334. get cellId(): number;
  76335. set cellId(value: number);
  76336. /**
  76337. * Creates a new Image
  76338. * @param name defines the control name
  76339. * @param url defines the image url
  76340. */
  76341. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76342. /**
  76343. * Tests if a given coordinates belong to the current control
  76344. * @param x defines x coordinate to test
  76345. * @param y defines y coordinate to test
  76346. * @returns true if the coordinates are inside the control
  76347. */
  76348. contains(x: number, y: number): boolean;
  76349. protected _getTypeName(): string;
  76350. /** Force the control to synchronize with its content */
  76351. synchronizeSizeWithContent(): void;
  76352. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76353. private _prepareWorkingCanvasForOpaqueDetection;
  76354. private _drawImage;
  76355. _draw(context: CanvasRenderingContext2D): void;
  76356. private _renderCornerPatch;
  76357. private _renderNinePatch;
  76358. dispose(): void;
  76359. /** STRETCH_NONE */
  76360. static readonly STRETCH_NONE: number;
  76361. /** STRETCH_FILL */
  76362. static readonly STRETCH_FILL: number;
  76363. /** STRETCH_UNIFORM */
  76364. static readonly STRETCH_UNIFORM: number;
  76365. /** STRETCH_EXTEND */
  76366. static readonly STRETCH_EXTEND: number;
  76367. /** NINE_PATCH */
  76368. static readonly STRETCH_NINE_PATCH: number;
  76369. }
  76370. }
  76371. declare module BABYLON.GUI {
  76372. /**
  76373. * Class used to create 2D buttons
  76374. */
  76375. export class Button extends Rectangle {
  76376. name?: string | undefined;
  76377. /**
  76378. * Function called to generate a pointer enter animation
  76379. */
  76380. pointerEnterAnimation: () => void;
  76381. /**
  76382. * Function called to generate a pointer out animation
  76383. */
  76384. pointerOutAnimation: () => void;
  76385. /**
  76386. * Function called to generate a pointer down animation
  76387. */
  76388. pointerDownAnimation: () => void;
  76389. /**
  76390. * Function called to generate a pointer up animation
  76391. */
  76392. pointerUpAnimation: () => void;
  76393. /**
  76394. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76395. */
  76396. delegatePickingToChildren: boolean;
  76397. private _image;
  76398. /**
  76399. * Returns the image part of the button (if any)
  76400. */
  76401. get image(): BABYLON.Nullable<Image>;
  76402. private _textBlock;
  76403. /**
  76404. * Returns the image part of the button (if any)
  76405. */
  76406. get textBlock(): BABYLON.Nullable<TextBlock>;
  76407. /**
  76408. * Creates a new Button
  76409. * @param name defines the name of the button
  76410. */
  76411. constructor(name?: string | undefined);
  76412. protected _getTypeName(): string;
  76413. /** @hidden */
  76414. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76415. /** @hidden */
  76416. _onPointerEnter(target: Control): boolean;
  76417. /** @hidden */
  76418. _onPointerOut(target: Control, force?: boolean): void;
  76419. /** @hidden */
  76420. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76421. /** @hidden */
  76422. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76423. /**
  76424. * Creates a new button made with an image and a text
  76425. * @param name defines the name of the button
  76426. * @param text defines the text of the button
  76427. * @param imageUrl defines the url of the image
  76428. * @returns a new Button
  76429. */
  76430. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76431. /**
  76432. * Creates a new button made with an image
  76433. * @param name defines the name of the button
  76434. * @param imageUrl defines the url of the image
  76435. * @returns a new Button
  76436. */
  76437. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76438. /**
  76439. * Creates a new button made with a text
  76440. * @param name defines the name of the button
  76441. * @param text defines the text of the button
  76442. * @returns a new Button
  76443. */
  76444. static CreateSimpleButton(name: string, text: string): Button;
  76445. /**
  76446. * Creates a new button made with an image and a centered text
  76447. * @param name defines the name of the button
  76448. * @param text defines the text of the button
  76449. * @param imageUrl defines the url of the image
  76450. * @returns a new Button
  76451. */
  76452. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76453. }
  76454. }
  76455. declare module BABYLON.GUI {
  76456. /**
  76457. * Class used to create a 2D stack panel container
  76458. */
  76459. export class StackPanel extends Container {
  76460. name?: string | undefined;
  76461. private _isVertical;
  76462. private _manualWidth;
  76463. private _manualHeight;
  76464. private _doNotTrackManualChanges;
  76465. /**
  76466. * Gets or sets a boolean indicating that layou warnings should be ignored
  76467. */
  76468. ignoreLayoutWarnings: boolean;
  76469. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76470. get isVertical(): boolean;
  76471. set isVertical(value: boolean);
  76472. /**
  76473. * Gets or sets panel width.
  76474. * This value should not be set when in horizontal mode as it will be computed automatically
  76475. */
  76476. set width(value: string | number);
  76477. get width(): string | number;
  76478. /**
  76479. * Gets or sets panel height.
  76480. * This value should not be set when in vertical mode as it will be computed automatically
  76481. */
  76482. set height(value: string | number);
  76483. get height(): string | number;
  76484. /**
  76485. * Creates a new StackPanel
  76486. * @param name defines control name
  76487. */
  76488. constructor(name?: string | undefined);
  76489. protected _getTypeName(): string;
  76490. /** @hidden */
  76491. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76492. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76493. protected _postMeasure(): void;
  76494. }
  76495. }
  76496. declare module BABYLON.GUI {
  76497. /**
  76498. * Class used to represent a 2D checkbox
  76499. */
  76500. export class Checkbox extends Control {
  76501. name?: string | undefined;
  76502. private _isChecked;
  76503. private _background;
  76504. private _checkSizeRatio;
  76505. private _thickness;
  76506. /** Gets or sets border thickness */
  76507. get thickness(): number;
  76508. set thickness(value: number);
  76509. /**
  76510. * BABYLON.Observable raised when isChecked property changes
  76511. */
  76512. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76513. /** Gets or sets a value indicating the ratio between overall size and check size */
  76514. get checkSizeRatio(): number;
  76515. set checkSizeRatio(value: number);
  76516. /** Gets or sets background color */
  76517. get background(): string;
  76518. set background(value: string);
  76519. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76520. get isChecked(): boolean;
  76521. set isChecked(value: boolean);
  76522. /**
  76523. * Creates a new CheckBox
  76524. * @param name defines the control name
  76525. */
  76526. constructor(name?: string | undefined);
  76527. protected _getTypeName(): string;
  76528. /** @hidden */
  76529. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76530. /** @hidden */
  76531. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76532. /**
  76533. * Utility function to easily create a checkbox with a header
  76534. * @param title defines the label to use for the header
  76535. * @param onValueChanged defines the callback to call when value changes
  76536. * @returns a StackPanel containing the checkbox and a textBlock
  76537. */
  76538. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76539. }
  76540. }
  76541. declare module BABYLON.GUI {
  76542. /**
  76543. * Class used to store key control properties
  76544. */
  76545. export class KeyPropertySet {
  76546. /** Width */
  76547. width?: string;
  76548. /** Height */
  76549. height?: string;
  76550. /** Left padding */
  76551. paddingLeft?: string;
  76552. /** Right padding */
  76553. paddingRight?: string;
  76554. /** Top padding */
  76555. paddingTop?: string;
  76556. /** Bottom padding */
  76557. paddingBottom?: string;
  76558. /** Foreground color */
  76559. color?: string;
  76560. /** Background color */
  76561. background?: string;
  76562. }
  76563. /**
  76564. * Class used to create virtual keyboard
  76565. */
  76566. export class VirtualKeyboard extends StackPanel {
  76567. /** BABYLON.Observable raised when a key is pressed */
  76568. onKeyPressObservable: BABYLON.Observable<string>;
  76569. /** Gets or sets default key button width */
  76570. defaultButtonWidth: string;
  76571. /** Gets or sets default key button height */
  76572. defaultButtonHeight: string;
  76573. /** Gets or sets default key button left padding */
  76574. defaultButtonPaddingLeft: string;
  76575. /** Gets or sets default key button right padding */
  76576. defaultButtonPaddingRight: string;
  76577. /** Gets or sets default key button top padding */
  76578. defaultButtonPaddingTop: string;
  76579. /** Gets or sets default key button bottom padding */
  76580. defaultButtonPaddingBottom: string;
  76581. /** Gets or sets default key button foreground color */
  76582. defaultButtonColor: string;
  76583. /** Gets or sets default key button background color */
  76584. defaultButtonBackground: string;
  76585. /** Gets or sets shift button foreground color */
  76586. shiftButtonColor: string;
  76587. /** Gets or sets shift button thickness*/
  76588. selectedShiftThickness: number;
  76589. /** Gets shift key state */
  76590. shiftState: number;
  76591. protected _getTypeName(): string;
  76592. private _createKey;
  76593. /**
  76594. * Adds a new row of keys
  76595. * @param keys defines the list of keys to add
  76596. * @param propertySets defines the associated property sets
  76597. */
  76598. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76599. /**
  76600. * Set the shift key to a specific state
  76601. * @param shiftState defines the new shift state
  76602. */
  76603. applyShiftState(shiftState: number): void;
  76604. private _currentlyConnectedInputText;
  76605. private _connectedInputTexts;
  76606. private _onKeyPressObserver;
  76607. /** Gets the input text control currently attached to the keyboard */
  76608. get connectedInputText(): BABYLON.Nullable<InputText>;
  76609. /**
  76610. * Connects the keyboard with an input text control
  76611. *
  76612. * @param input defines the target control
  76613. */
  76614. connect(input: InputText): void;
  76615. /**
  76616. * Disconnects the keyboard from connected InputText controls
  76617. *
  76618. * @param input optionally defines a target control, otherwise all are disconnected
  76619. */
  76620. disconnect(input?: InputText): void;
  76621. private _removeConnectedInputObservables;
  76622. /**
  76623. * Release all resources
  76624. */
  76625. dispose(): void;
  76626. /**
  76627. * Creates a new keyboard using a default layout
  76628. *
  76629. * @param name defines control name
  76630. * @returns a new VirtualKeyboard
  76631. */
  76632. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76633. }
  76634. }
  76635. declare module BABYLON.GUI {
  76636. /**
  76637. * Class used to create input text control
  76638. */
  76639. export class InputText extends Control implements IFocusableControl {
  76640. name?: string | undefined;
  76641. private _text;
  76642. private _placeholderText;
  76643. private _background;
  76644. private _focusedBackground;
  76645. private _focusedColor;
  76646. private _placeholderColor;
  76647. private _thickness;
  76648. private _margin;
  76649. private _autoStretchWidth;
  76650. private _maxWidth;
  76651. private _isFocused;
  76652. private _blinkTimeout;
  76653. private _blinkIsEven;
  76654. private _cursorOffset;
  76655. private _scrollLeft;
  76656. private _textWidth;
  76657. private _clickedCoordinate;
  76658. private _deadKey;
  76659. private _addKey;
  76660. private _currentKey;
  76661. private _isTextHighlightOn;
  76662. private _textHighlightColor;
  76663. private _highligherOpacity;
  76664. private _highlightedText;
  76665. private _startHighlightIndex;
  76666. private _endHighlightIndex;
  76667. private _cursorIndex;
  76668. private _onFocusSelectAll;
  76669. private _isPointerDown;
  76670. private _onClipboardObserver;
  76671. private _onPointerDblTapObserver;
  76672. /** @hidden */
  76673. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76674. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76675. promptMessage: string;
  76676. /** Force disable prompt on mobile device */
  76677. disableMobilePrompt: boolean;
  76678. /** BABYLON.Observable raised when the text changes */
  76679. onTextChangedObservable: BABYLON.Observable<InputText>;
  76680. /** BABYLON.Observable raised just before an entered character is to be added */
  76681. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76682. /** BABYLON.Observable raised when the control gets the focus */
  76683. onFocusObservable: BABYLON.Observable<InputText>;
  76684. /** BABYLON.Observable raised when the control loses the focus */
  76685. onBlurObservable: BABYLON.Observable<InputText>;
  76686. /**Observable raised when the text is highlighted */
  76687. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76688. /**Observable raised when copy event is triggered */
  76689. onTextCopyObservable: BABYLON.Observable<InputText>;
  76690. /** BABYLON.Observable raised when cut event is triggered */
  76691. onTextCutObservable: BABYLON.Observable<InputText>;
  76692. /** BABYLON.Observable raised when paste event is triggered */
  76693. onTextPasteObservable: BABYLON.Observable<InputText>;
  76694. /** BABYLON.Observable raised when a key event was processed */
  76695. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76696. /** Gets or sets the maximum width allowed by the control */
  76697. get maxWidth(): string | number;
  76698. /** Gets the maximum width allowed by the control in pixels */
  76699. get maxWidthInPixels(): number;
  76700. set maxWidth(value: string | number);
  76701. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76702. get highligherOpacity(): number;
  76703. set highligherOpacity(value: number);
  76704. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76705. get onFocusSelectAll(): boolean;
  76706. set onFocusSelectAll(value: boolean);
  76707. /** Gets or sets the text hightlight color */
  76708. get textHighlightColor(): string;
  76709. set textHighlightColor(value: string);
  76710. /** Gets or sets control margin */
  76711. get margin(): string;
  76712. /** Gets control margin in pixels */
  76713. get marginInPixels(): number;
  76714. set margin(value: string);
  76715. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76716. get autoStretchWidth(): boolean;
  76717. set autoStretchWidth(value: boolean);
  76718. /** Gets or sets border thickness */
  76719. get thickness(): number;
  76720. set thickness(value: number);
  76721. /** Gets or sets the background color when focused */
  76722. get focusedBackground(): string;
  76723. set focusedBackground(value: string);
  76724. /** Gets or sets the background color when focused */
  76725. get focusedColor(): string;
  76726. set focusedColor(value: string);
  76727. /** Gets or sets the background color */
  76728. get background(): string;
  76729. set background(value: string);
  76730. /** Gets or sets the placeholder color */
  76731. get placeholderColor(): string;
  76732. set placeholderColor(value: string);
  76733. /** Gets or sets the text displayed when the control is empty */
  76734. get placeholderText(): string;
  76735. set placeholderText(value: string);
  76736. /** Gets or sets the dead key flag */
  76737. get deadKey(): boolean;
  76738. set deadKey(flag: boolean);
  76739. /** Gets or sets the highlight text */
  76740. get highlightedText(): string;
  76741. set highlightedText(text: string);
  76742. /** Gets or sets if the current key should be added */
  76743. get addKey(): boolean;
  76744. set addKey(flag: boolean);
  76745. /** Gets or sets the value of the current key being entered */
  76746. get currentKey(): string;
  76747. set currentKey(key: string);
  76748. /** Gets or sets the text displayed in the control */
  76749. get text(): string;
  76750. set text(value: string);
  76751. /** Gets or sets control width */
  76752. get width(): string | number;
  76753. set width(value: string | number);
  76754. /**
  76755. * Creates a new InputText
  76756. * @param name defines the control name
  76757. * @param text defines the text of the control
  76758. */
  76759. constructor(name?: string | undefined, text?: string);
  76760. /** @hidden */
  76761. onBlur(): void;
  76762. /** @hidden */
  76763. onFocus(): void;
  76764. protected _getTypeName(): string;
  76765. /**
  76766. * Function called to get the list of controls that should not steal the focus from this control
  76767. * @returns an array of controls
  76768. */
  76769. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76770. /** @hidden */
  76771. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76772. /** @hidden */
  76773. private _updateValueFromCursorIndex;
  76774. /** @hidden */
  76775. private _processDblClick;
  76776. /** @hidden */
  76777. private _selectAllText;
  76778. /**
  76779. * Handles the keyboard event
  76780. * @param evt Defines the KeyboardEvent
  76781. */
  76782. processKeyboard(evt: KeyboardEvent): void;
  76783. /** @hidden */
  76784. private _onCopyText;
  76785. /** @hidden */
  76786. private _onCutText;
  76787. /** @hidden */
  76788. private _onPasteText;
  76789. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76790. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76791. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76792. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76793. protected _beforeRenderText(text: string): string;
  76794. dispose(): void;
  76795. }
  76796. }
  76797. declare module BABYLON.GUI {
  76798. /**
  76799. * Class used to create a 2D grid container
  76800. */
  76801. export class Grid extends Container {
  76802. name?: string | undefined;
  76803. private _rowDefinitions;
  76804. private _columnDefinitions;
  76805. private _cells;
  76806. private _childControls;
  76807. /**
  76808. * Gets the number of columns
  76809. */
  76810. get columnCount(): number;
  76811. /**
  76812. * Gets the number of rows
  76813. */
  76814. get rowCount(): number;
  76815. /** Gets the list of children */
  76816. get children(): Control[];
  76817. /** Gets the list of cells (e.g. the containers) */
  76818. get cells(): {
  76819. [key: string]: Container;
  76820. };
  76821. /**
  76822. * Gets the definition of a specific row
  76823. * @param index defines the index of the row
  76824. * @returns the row definition
  76825. */
  76826. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76827. /**
  76828. * Gets the definition of a specific column
  76829. * @param index defines the index of the column
  76830. * @returns the column definition
  76831. */
  76832. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76833. /**
  76834. * Adds a new row to the grid
  76835. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76836. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76837. * @returns the current grid
  76838. */
  76839. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76840. /**
  76841. * Adds a new column to the grid
  76842. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76843. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76844. * @returns the current grid
  76845. */
  76846. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76847. /**
  76848. * Update a row definition
  76849. * @param index defines the index of the row to update
  76850. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76851. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76852. * @returns the current grid
  76853. */
  76854. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76855. /**
  76856. * Update a column definition
  76857. * @param index defines the index of the column to update
  76858. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76859. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76860. * @returns the current grid
  76861. */
  76862. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76863. /**
  76864. * Gets the list of children stored in a specific cell
  76865. * @param row defines the row to check
  76866. * @param column defines the column to check
  76867. * @returns the list of controls
  76868. */
  76869. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76870. /**
  76871. * Gets a string representing the child cell info (row x column)
  76872. * @param child defines the control to get info from
  76873. * @returns a string containing the child cell info (row x column)
  76874. */
  76875. getChildCellInfo(child: Control): string;
  76876. private _removeCell;
  76877. private _offsetCell;
  76878. /**
  76879. * Remove a column definition at specified index
  76880. * @param index defines the index of the column to remove
  76881. * @returns the current grid
  76882. */
  76883. removeColumnDefinition(index: number): Grid;
  76884. /**
  76885. * Remove a row definition at specified index
  76886. * @param index defines the index of the row to remove
  76887. * @returns the current grid
  76888. */
  76889. removeRowDefinition(index: number): Grid;
  76890. /**
  76891. * Adds a new control to the current grid
  76892. * @param control defines the control to add
  76893. * @param row defines the row where to add the control (0 by default)
  76894. * @param column defines the column where to add the control (0 by default)
  76895. * @returns the current grid
  76896. */
  76897. addControl(control: Control, row?: number, column?: number): Grid;
  76898. /**
  76899. * Removes a control from the current container
  76900. * @param control defines the control to remove
  76901. * @returns the current container
  76902. */
  76903. removeControl(control: Control): Container;
  76904. /**
  76905. * Creates a new Grid
  76906. * @param name defines control name
  76907. */
  76908. constructor(name?: string | undefined);
  76909. protected _getTypeName(): string;
  76910. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76911. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76912. _flagDescendantsAsMatrixDirty(): void;
  76913. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76914. /** Releases associated resources */
  76915. dispose(): void;
  76916. }
  76917. }
  76918. declare module BABYLON.GUI {
  76919. /** Class used to create color pickers */
  76920. export class ColorPicker extends Control {
  76921. name?: string | undefined;
  76922. private static _Epsilon;
  76923. private _colorWheelCanvas;
  76924. private _value;
  76925. private _tmpColor;
  76926. private _pointerStartedOnSquare;
  76927. private _pointerStartedOnWheel;
  76928. private _squareLeft;
  76929. private _squareTop;
  76930. private _squareSize;
  76931. private _h;
  76932. private _s;
  76933. private _v;
  76934. private _lastPointerDownID;
  76935. /**
  76936. * BABYLON.Observable raised when the value changes
  76937. */
  76938. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76939. /** Gets or sets the color of the color picker */
  76940. get value(): BABYLON.Color3;
  76941. set value(value: BABYLON.Color3);
  76942. /**
  76943. * Gets or sets control width
  76944. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76945. */
  76946. get width(): string | number;
  76947. set width(value: string | number);
  76948. /**
  76949. * Gets or sets control height
  76950. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76951. */
  76952. get height(): string | number;
  76953. /** Gets or sets control height */
  76954. set height(value: string | number);
  76955. /** Gets or sets control size */
  76956. get size(): string | number;
  76957. set size(value: string | number);
  76958. /**
  76959. * Creates a new ColorPicker
  76960. * @param name defines the control name
  76961. */
  76962. constructor(name?: string | undefined);
  76963. protected _getTypeName(): string;
  76964. /** @hidden */
  76965. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76966. private _updateSquareProps;
  76967. private _drawGradientSquare;
  76968. private _drawCircle;
  76969. private _createColorWheelCanvas;
  76970. /** @hidden */
  76971. _draw(context: CanvasRenderingContext2D): void;
  76972. private _pointerIsDown;
  76973. private _updateValueFromPointer;
  76974. private _isPointOnSquare;
  76975. private _isPointOnWheel;
  76976. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76977. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76978. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76979. /**
  76980. * This function expands the color picker by creating a color picker dialog with manual
  76981. * color value input and the ability to save colors into an array to be used later in
  76982. * subsequent launches of the dialogue.
  76983. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76984. * @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.
  76985. * @returns picked color as a hex string and the saved colors array as hex strings.
  76986. */
  76987. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76988. pickerWidth?: string;
  76989. pickerHeight?: string;
  76990. headerHeight?: string;
  76991. lastColor?: string;
  76992. swatchLimit?: number;
  76993. numSwatchesPerLine?: number;
  76994. savedColors?: Array<string>;
  76995. }): Promise<{
  76996. savedColors?: string[];
  76997. pickedColor: string;
  76998. }>;
  76999. }
  77000. }
  77001. declare module BABYLON.GUI {
  77002. /** Class used to create 2D ellipse containers */
  77003. export class Ellipse extends Container {
  77004. name?: string | undefined;
  77005. private _thickness;
  77006. /** Gets or sets border thickness */
  77007. get thickness(): number;
  77008. set thickness(value: number);
  77009. /**
  77010. * Creates a new Ellipse
  77011. * @param name defines the control name
  77012. */
  77013. constructor(name?: string | undefined);
  77014. protected _getTypeName(): string;
  77015. protected _localDraw(context: CanvasRenderingContext2D): void;
  77016. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77017. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77018. }
  77019. }
  77020. declare module BABYLON.GUI {
  77021. /**
  77022. * Class used to create a password control
  77023. */
  77024. export class InputPassword extends InputText {
  77025. protected _beforeRenderText(text: string): string;
  77026. }
  77027. }
  77028. declare module BABYLON.GUI {
  77029. /** Class used to render 2D lines */
  77030. export class Line extends Control {
  77031. name?: string | undefined;
  77032. private _lineWidth;
  77033. private _x1;
  77034. private _y1;
  77035. private _x2;
  77036. private _y2;
  77037. private _dash;
  77038. private _connectedControl;
  77039. private _connectedControlDirtyObserver;
  77040. /** Gets or sets the dash pattern */
  77041. get dash(): Array<number>;
  77042. set dash(value: Array<number>);
  77043. /** Gets or sets the control connected with the line end */
  77044. get connectedControl(): Control;
  77045. set connectedControl(value: Control);
  77046. /** Gets or sets start coordinates on X axis */
  77047. get x1(): string | number;
  77048. set x1(value: string | number);
  77049. /** Gets or sets start coordinates on Y axis */
  77050. get y1(): string | number;
  77051. set y1(value: string | number);
  77052. /** Gets or sets end coordinates on X axis */
  77053. get x2(): string | number;
  77054. set x2(value: string | number);
  77055. /** Gets or sets end coordinates on Y axis */
  77056. get y2(): string | number;
  77057. set y2(value: string | number);
  77058. /** Gets or sets line width */
  77059. get lineWidth(): number;
  77060. set lineWidth(value: number);
  77061. /** Gets or sets horizontal alignment */
  77062. set horizontalAlignment(value: number);
  77063. /** Gets or sets vertical alignment */
  77064. set verticalAlignment(value: number);
  77065. private get _effectiveX2();
  77066. private get _effectiveY2();
  77067. /**
  77068. * Creates a new Line
  77069. * @param name defines the control name
  77070. */
  77071. constructor(name?: string | undefined);
  77072. protected _getTypeName(): string;
  77073. _draw(context: CanvasRenderingContext2D): void;
  77074. _measure(): void;
  77075. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77076. /**
  77077. * Move one end of the line given 3D cartesian coordinates.
  77078. * @param position Targeted world position
  77079. * @param scene BABYLON.Scene
  77080. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77081. */
  77082. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77083. /**
  77084. * Move one end of the line to a position in screen absolute space.
  77085. * @param projectedPosition Position in screen absolute space (X, Y)
  77086. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77087. */
  77088. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77089. }
  77090. }
  77091. declare module BABYLON.GUI {
  77092. /**
  77093. * Class used to store a point for a MultiLine object.
  77094. * The point can be pure 2D coordinates, a mesh or a control
  77095. */
  77096. export class MultiLinePoint {
  77097. private _multiLine;
  77098. private _x;
  77099. private _y;
  77100. private _control;
  77101. private _mesh;
  77102. private _controlObserver;
  77103. private _meshObserver;
  77104. /** @hidden */
  77105. _point: BABYLON.Vector2;
  77106. /**
  77107. * Creates a new MultiLinePoint
  77108. * @param multiLine defines the source MultiLine object
  77109. */
  77110. constructor(multiLine: MultiLine);
  77111. /** Gets or sets x coordinate */
  77112. get x(): string | number;
  77113. set x(value: string | number);
  77114. /** Gets or sets y coordinate */
  77115. get y(): string | number;
  77116. set y(value: string | number);
  77117. /** Gets or sets the control associated with this point */
  77118. get control(): BABYLON.Nullable<Control>;
  77119. set control(value: BABYLON.Nullable<Control>);
  77120. /** Gets or sets the mesh associated with this point */
  77121. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77122. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77123. /** Resets links */
  77124. resetLinks(): void;
  77125. /**
  77126. * Gets a translation vector
  77127. * @returns the translation vector
  77128. */
  77129. translate(): BABYLON.Vector2;
  77130. private _translatePoint;
  77131. /** Release associated resources */
  77132. dispose(): void;
  77133. }
  77134. }
  77135. declare module BABYLON.GUI {
  77136. /**
  77137. * Class used to create multi line control
  77138. */
  77139. export class MultiLine extends Control {
  77140. name?: string | undefined;
  77141. private _lineWidth;
  77142. private _dash;
  77143. private _points;
  77144. private _minX;
  77145. private _minY;
  77146. private _maxX;
  77147. private _maxY;
  77148. /**
  77149. * Creates a new MultiLine
  77150. * @param name defines the control name
  77151. */
  77152. constructor(name?: string | undefined);
  77153. /** Gets or sets dash pattern */
  77154. get dash(): Array<number>;
  77155. set dash(value: Array<number>);
  77156. /**
  77157. * Gets point stored at specified index
  77158. * @param index defines the index to look for
  77159. * @returns the requested point if found
  77160. */
  77161. getAt(index: number): MultiLinePoint;
  77162. /** Function called when a point is updated */
  77163. onPointUpdate: () => void;
  77164. /**
  77165. * Adds new points to the point collection
  77166. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77167. * @returns the list of created MultiLinePoint
  77168. */
  77169. add(...items: (AbstractMesh | Control | {
  77170. x: string | number;
  77171. y: string | number;
  77172. })[]): MultiLinePoint[];
  77173. /**
  77174. * Adds a new point to the point collection
  77175. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77176. * @returns the created MultiLinePoint
  77177. */
  77178. push(item?: (AbstractMesh | Control | {
  77179. x: string | number;
  77180. y: string | number;
  77181. })): MultiLinePoint;
  77182. /**
  77183. * Remove a specific value or point from the active point collection
  77184. * @param value defines the value or point to remove
  77185. */
  77186. remove(value: number | MultiLinePoint): void;
  77187. /**
  77188. * Resets this object to initial state (no point)
  77189. */
  77190. reset(): void;
  77191. /**
  77192. * Resets all links
  77193. */
  77194. resetLinks(): void;
  77195. /** Gets or sets line width */
  77196. get lineWidth(): number;
  77197. set lineWidth(value: number);
  77198. set horizontalAlignment(value: number);
  77199. set verticalAlignment(value: number);
  77200. protected _getTypeName(): string;
  77201. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77202. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77203. _measure(): void;
  77204. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77205. dispose(): void;
  77206. }
  77207. }
  77208. declare module BABYLON.GUI {
  77209. /**
  77210. * Class used to create radio button controls
  77211. */
  77212. export class RadioButton extends Control {
  77213. name?: string | undefined;
  77214. private _isChecked;
  77215. private _background;
  77216. private _checkSizeRatio;
  77217. private _thickness;
  77218. /** Gets or sets border thickness */
  77219. get thickness(): number;
  77220. set thickness(value: number);
  77221. /** Gets or sets group name */
  77222. group: string;
  77223. /** BABYLON.Observable raised when isChecked is changed */
  77224. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77225. /** Gets or sets a value indicating the ratio between overall size and check size */
  77226. get checkSizeRatio(): number;
  77227. set checkSizeRatio(value: number);
  77228. /** Gets or sets background color */
  77229. get background(): string;
  77230. set background(value: string);
  77231. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77232. get isChecked(): boolean;
  77233. set isChecked(value: boolean);
  77234. /**
  77235. * Creates a new RadioButton
  77236. * @param name defines the control name
  77237. */
  77238. constructor(name?: string | undefined);
  77239. protected _getTypeName(): string;
  77240. _draw(context: CanvasRenderingContext2D): void;
  77241. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77242. /**
  77243. * Utility function to easily create a radio button with a header
  77244. * @param title defines the label to use for the header
  77245. * @param group defines the group to use for the radio button
  77246. * @param isChecked defines the initial state of the radio button
  77247. * @param onValueChanged defines the callback to call when value changes
  77248. * @returns a StackPanel containing the radio button and a textBlock
  77249. */
  77250. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77251. }
  77252. }
  77253. declare module BABYLON.GUI {
  77254. /**
  77255. * Class used to create slider controls
  77256. */
  77257. export class BaseSlider extends Control {
  77258. name?: string | undefined;
  77259. protected _thumbWidth: ValueAndUnit;
  77260. private _minimum;
  77261. private _maximum;
  77262. private _value;
  77263. private _isVertical;
  77264. protected _barOffset: ValueAndUnit;
  77265. private _isThumbClamped;
  77266. protected _displayThumb: boolean;
  77267. private _step;
  77268. private _lastPointerDownID;
  77269. protected _effectiveBarOffset: number;
  77270. protected _renderLeft: number;
  77271. protected _renderTop: number;
  77272. protected _renderWidth: number;
  77273. protected _renderHeight: number;
  77274. protected _backgroundBoxLength: number;
  77275. protected _backgroundBoxThickness: number;
  77276. protected _effectiveThumbThickness: number;
  77277. /** BABYLON.Observable raised when the sldier value changes */
  77278. onValueChangedObservable: BABYLON.Observable<number>;
  77279. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77280. get displayThumb(): boolean;
  77281. set displayThumb(value: boolean);
  77282. /** Gets or sets a step to apply to values (0 by default) */
  77283. get step(): number;
  77284. set step(value: number);
  77285. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77286. get barOffset(): string | number;
  77287. /** Gets main bar offset in pixels*/
  77288. get barOffsetInPixels(): number;
  77289. set barOffset(value: string | number);
  77290. /** Gets or sets thumb width */
  77291. get thumbWidth(): string | number;
  77292. /** Gets thumb width in pixels */
  77293. get thumbWidthInPixels(): number;
  77294. set thumbWidth(value: string | number);
  77295. /** Gets or sets minimum value */
  77296. get minimum(): number;
  77297. set minimum(value: number);
  77298. /** Gets or sets maximum value */
  77299. get maximum(): number;
  77300. set maximum(value: number);
  77301. /** Gets or sets current value */
  77302. get value(): number;
  77303. set value(value: number);
  77304. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77305. get isVertical(): boolean;
  77306. set isVertical(value: boolean);
  77307. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77308. get isThumbClamped(): boolean;
  77309. set isThumbClamped(value: boolean);
  77310. /**
  77311. * Creates a new BaseSlider
  77312. * @param name defines the control name
  77313. */
  77314. constructor(name?: string | undefined);
  77315. protected _getTypeName(): string;
  77316. protected _getThumbPosition(): number;
  77317. protected _getThumbThickness(type: string): number;
  77318. protected _prepareRenderingData(type: string): void;
  77319. private _pointerIsDown;
  77320. /** @hidden */
  77321. protected _updateValueFromPointer(x: number, y: number): void;
  77322. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77323. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77324. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77325. }
  77326. }
  77327. declare module BABYLON.GUI {
  77328. /**
  77329. * Class used to create slider controls
  77330. */
  77331. export class Slider extends BaseSlider {
  77332. name?: string | undefined;
  77333. private _background;
  77334. private _borderColor;
  77335. private _isThumbCircle;
  77336. protected _displayValueBar: boolean;
  77337. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77338. get displayValueBar(): boolean;
  77339. set displayValueBar(value: boolean);
  77340. /** Gets or sets border color */
  77341. get borderColor(): string;
  77342. set borderColor(value: string);
  77343. /** Gets or sets background color */
  77344. get background(): string;
  77345. set background(value: string);
  77346. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77347. get isThumbCircle(): boolean;
  77348. set isThumbCircle(value: boolean);
  77349. /**
  77350. * Creates a new Slider
  77351. * @param name defines the control name
  77352. */
  77353. constructor(name?: string | undefined);
  77354. protected _getTypeName(): string;
  77355. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77356. }
  77357. }
  77358. declare module BABYLON.GUI {
  77359. /** Class used to create a RadioGroup
  77360. * which contains groups of radio buttons
  77361. */
  77362. export class SelectorGroup {
  77363. /** name of SelectorGroup */
  77364. name: string;
  77365. private _groupPanel;
  77366. private _selectors;
  77367. private _groupHeader;
  77368. /**
  77369. * Creates a new SelectorGroup
  77370. * @param name of group, used as a group heading
  77371. */
  77372. constructor(
  77373. /** name of SelectorGroup */
  77374. name: string);
  77375. /** Gets the groupPanel of the SelectorGroup */
  77376. get groupPanel(): StackPanel;
  77377. /** Gets the selectors array */
  77378. get selectors(): StackPanel[];
  77379. /** Gets and sets the group header */
  77380. get header(): string;
  77381. set header(label: string);
  77382. /** @hidden */
  77383. private _addGroupHeader;
  77384. /** @hidden*/
  77385. _getSelector(selectorNb: number): StackPanel | undefined;
  77386. /** Removes the selector at the given position
  77387. * @param selectorNb the position of the selector within the group
  77388. */
  77389. removeSelector(selectorNb: number): void;
  77390. }
  77391. /** Class used to create a CheckboxGroup
  77392. * which contains groups of checkbox buttons
  77393. */
  77394. export class CheckboxGroup extends SelectorGroup {
  77395. /** Adds a checkbox as a control
  77396. * @param text is the label for the selector
  77397. * @param func is the function called when the Selector is checked
  77398. * @param checked is true when Selector is checked
  77399. */
  77400. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77401. /** @hidden */
  77402. _setSelectorLabel(selectorNb: number, label: string): void;
  77403. /** @hidden */
  77404. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77405. /** @hidden */
  77406. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77407. /** @hidden */
  77408. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77409. }
  77410. /** Class used to create a RadioGroup
  77411. * which contains groups of radio buttons
  77412. */
  77413. export class RadioGroup extends SelectorGroup {
  77414. private _selectNb;
  77415. /** Adds a radio button as a control
  77416. * @param label is the label for the selector
  77417. * @param func is the function called when the Selector is checked
  77418. * @param checked is true when Selector is checked
  77419. */
  77420. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77421. /** @hidden */
  77422. _setSelectorLabel(selectorNb: number, label: string): void;
  77423. /** @hidden */
  77424. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77425. /** @hidden */
  77426. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77427. /** @hidden */
  77428. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77429. }
  77430. /** Class used to create a SliderGroup
  77431. * which contains groups of slider buttons
  77432. */
  77433. export class SliderGroup extends SelectorGroup {
  77434. /**
  77435. * Adds a slider to the SelectorGroup
  77436. * @param label is the label for the SliderBar
  77437. * @param func is the function called when the Slider moves
  77438. * @param unit is a string describing the units used, eg degrees or metres
  77439. * @param min is the minimum value for the Slider
  77440. * @param max is the maximum value for the Slider
  77441. * @param value is the start value for the Slider between min and max
  77442. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77443. */
  77444. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77445. /** @hidden */
  77446. _setSelectorLabel(selectorNb: number, label: string): void;
  77447. /** @hidden */
  77448. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77449. /** @hidden */
  77450. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77451. /** @hidden */
  77452. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77453. }
  77454. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77455. * @see https://doc.babylonjs.com/how_to/selector
  77456. */
  77457. export class SelectionPanel extends Rectangle {
  77458. /** name of SelectionPanel */
  77459. name: string;
  77460. /** an array of SelectionGroups */
  77461. groups: SelectorGroup[];
  77462. private _panel;
  77463. private _buttonColor;
  77464. private _buttonBackground;
  77465. private _headerColor;
  77466. private _barColor;
  77467. private _barHeight;
  77468. private _spacerHeight;
  77469. private _labelColor;
  77470. private _groups;
  77471. private _bars;
  77472. /**
  77473. * Creates a new SelectionPanel
  77474. * @param name of SelectionPanel
  77475. * @param groups is an array of SelectionGroups
  77476. */
  77477. constructor(
  77478. /** name of SelectionPanel */
  77479. name: string,
  77480. /** an array of SelectionGroups */
  77481. groups?: SelectorGroup[]);
  77482. protected _getTypeName(): string;
  77483. /** Gets or sets the headerColor */
  77484. get headerColor(): string;
  77485. set headerColor(color: string);
  77486. private _setHeaderColor;
  77487. /** Gets or sets the button color */
  77488. get buttonColor(): string;
  77489. set buttonColor(color: string);
  77490. private _setbuttonColor;
  77491. /** Gets or sets the label color */
  77492. get labelColor(): string;
  77493. set labelColor(color: string);
  77494. private _setLabelColor;
  77495. /** Gets or sets the button background */
  77496. get buttonBackground(): string;
  77497. set buttonBackground(color: string);
  77498. private _setButtonBackground;
  77499. /** Gets or sets the color of separator bar */
  77500. get barColor(): string;
  77501. set barColor(color: string);
  77502. private _setBarColor;
  77503. /** Gets or sets the height of separator bar */
  77504. get barHeight(): string;
  77505. set barHeight(value: string);
  77506. private _setBarHeight;
  77507. /** Gets or sets the height of spacers*/
  77508. get spacerHeight(): string;
  77509. set spacerHeight(value: string);
  77510. private _setSpacerHeight;
  77511. /** Adds a bar between groups */
  77512. private _addSpacer;
  77513. /** Add a group to the selection panel
  77514. * @param group is the selector group to add
  77515. */
  77516. addGroup(group: SelectorGroup): void;
  77517. /** Remove the group from the given position
  77518. * @param groupNb is the position of the group in the list
  77519. */
  77520. removeGroup(groupNb: number): void;
  77521. /** Change a group header label
  77522. * @param label is the new group header label
  77523. * @param groupNb is the number of the group to relabel
  77524. * */
  77525. setHeaderName(label: string, groupNb: number): void;
  77526. /** Change selector label to the one given
  77527. * @param label is the new selector label
  77528. * @param groupNb is the number of the groupcontaining the selector
  77529. * @param selectorNb is the number of the selector within a group to relabel
  77530. * */
  77531. relabel(label: string, groupNb: number, selectorNb: number): void;
  77532. /** For a given group position remove the selector at the given position
  77533. * @param groupNb is the number of the group to remove the selector from
  77534. * @param selectorNb is the number of the selector within the group
  77535. */
  77536. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77537. /** For a given group position of correct type add a checkbox button
  77538. * @param groupNb is the number of the group to remove the selector from
  77539. * @param label is the label for the selector
  77540. * @param func is the function called when the Selector is checked
  77541. * @param checked is true when Selector is checked
  77542. */
  77543. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77544. /** For a given group position of correct type add a radio button
  77545. * @param groupNb is the number of the group to remove the selector from
  77546. * @param label is the label for the selector
  77547. * @param func is the function called when the Selector is checked
  77548. * @param checked is true when Selector is checked
  77549. */
  77550. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77551. /**
  77552. * For a given slider group add a slider
  77553. * @param groupNb is the number of the group to add the slider to
  77554. * @param label is the label for the Slider
  77555. * @param func is the function called when the Slider moves
  77556. * @param unit is a string describing the units used, eg degrees or metres
  77557. * @param min is the minimum value for the Slider
  77558. * @param max is the maximum value for the Slider
  77559. * @param value is the start value for the Slider between min and max
  77560. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77561. */
  77562. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77563. }
  77564. }
  77565. declare module BABYLON.GUI {
  77566. /**
  77567. * Class used to hold a the container for ScrollViewer
  77568. * @hidden
  77569. */
  77570. export class _ScrollViewerWindow extends Container {
  77571. parentClientWidth: number;
  77572. parentClientHeight: number;
  77573. private _freezeControls;
  77574. private _parentMeasure;
  77575. private _oldLeft;
  77576. private _oldTop;
  77577. get freezeControls(): boolean;
  77578. set freezeControls(value: boolean);
  77579. private _bucketWidth;
  77580. private _bucketHeight;
  77581. private _buckets;
  77582. private _bucketLen;
  77583. get bucketWidth(): number;
  77584. get bucketHeight(): number;
  77585. setBucketSizes(width: number, height: number): void;
  77586. private _useBuckets;
  77587. private _makeBuckets;
  77588. private _dispatchInBuckets;
  77589. private _updateMeasures;
  77590. private _updateChildrenMeasures;
  77591. private _restoreMeasures;
  77592. /**
  77593. * Creates a new ScrollViewerWindow
  77594. * @param name of ScrollViewerWindow
  77595. */
  77596. constructor(name?: string);
  77597. protected _getTypeName(): string;
  77598. /** @hidden */
  77599. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77600. /** @hidden */
  77601. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77602. private _scrollChildren;
  77603. private _scrollChildrenWithBuckets;
  77604. /** @hidden */
  77605. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77606. protected _postMeasure(): void;
  77607. }
  77608. }
  77609. declare module BABYLON.GUI {
  77610. /**
  77611. * Class used to create slider controls
  77612. */
  77613. export class ScrollBar extends BaseSlider {
  77614. name?: string | undefined;
  77615. private _background;
  77616. private _borderColor;
  77617. private _tempMeasure;
  77618. /** Gets or sets border color */
  77619. get borderColor(): string;
  77620. set borderColor(value: string);
  77621. /** Gets or sets background color */
  77622. get background(): string;
  77623. set background(value: string);
  77624. /**
  77625. * Creates a new Slider
  77626. * @param name defines the control name
  77627. */
  77628. constructor(name?: string | undefined);
  77629. protected _getTypeName(): string;
  77630. protected _getThumbThickness(): number;
  77631. _draw(context: CanvasRenderingContext2D): void;
  77632. private _first;
  77633. private _originX;
  77634. private _originY;
  77635. /** @hidden */
  77636. protected _updateValueFromPointer(x: number, y: number): void;
  77637. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77638. }
  77639. }
  77640. declare module BABYLON.GUI {
  77641. /**
  77642. * Class used to create slider controls
  77643. */
  77644. export class ImageScrollBar extends BaseSlider {
  77645. name?: string | undefined;
  77646. private _backgroundBaseImage;
  77647. private _backgroundImage;
  77648. private _thumbImage;
  77649. private _thumbBaseImage;
  77650. private _thumbLength;
  77651. private _thumbHeight;
  77652. private _barImageHeight;
  77653. private _tempMeasure;
  77654. /** Number of 90° rotation to apply on the images when in vertical mode */
  77655. num90RotationInVerticalMode: number;
  77656. /**
  77657. * Gets or sets the image used to render the background for horizontal bar
  77658. */
  77659. get backgroundImage(): Image;
  77660. set backgroundImage(value: Image);
  77661. /**
  77662. * Gets or sets the image used to render the thumb
  77663. */
  77664. get thumbImage(): Image;
  77665. set thumbImage(value: Image);
  77666. /**
  77667. * Gets or sets the length of the thumb
  77668. */
  77669. get thumbLength(): number;
  77670. set thumbLength(value: number);
  77671. /**
  77672. * Gets or sets the height of the thumb
  77673. */
  77674. get thumbHeight(): number;
  77675. set thumbHeight(value: number);
  77676. /**
  77677. * Gets or sets the height of the bar image
  77678. */
  77679. get barImageHeight(): number;
  77680. set barImageHeight(value: number);
  77681. /**
  77682. * Creates a new ImageScrollBar
  77683. * @param name defines the control name
  77684. */
  77685. constructor(name?: string | undefined);
  77686. protected _getTypeName(): string;
  77687. protected _getThumbThickness(): number;
  77688. _draw(context: CanvasRenderingContext2D): void;
  77689. private _first;
  77690. private _originX;
  77691. private _originY;
  77692. /** @hidden */
  77693. protected _updateValueFromPointer(x: number, y: number): void;
  77694. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77695. }
  77696. }
  77697. declare module BABYLON.GUI {
  77698. /**
  77699. * Class used to hold a viewer window and sliders in a grid
  77700. */
  77701. export class ScrollViewer extends Rectangle {
  77702. private _grid;
  77703. private _horizontalBarSpace;
  77704. private _verticalBarSpace;
  77705. private _dragSpace;
  77706. private _horizontalBar;
  77707. private _verticalBar;
  77708. private _barColor;
  77709. private _barBackground;
  77710. private _barImage;
  77711. private _horizontalBarImage;
  77712. private _verticalBarImage;
  77713. private _barBackgroundImage;
  77714. private _horizontalBarBackgroundImage;
  77715. private _verticalBarBackgroundImage;
  77716. private _barSize;
  77717. private _window;
  77718. private _pointerIsOver;
  77719. private _wheelPrecision;
  77720. private _onWheelObserver;
  77721. private _clientWidth;
  77722. private _clientHeight;
  77723. private _useImageBar;
  77724. private _thumbLength;
  77725. private _thumbHeight;
  77726. private _barImageHeight;
  77727. private _horizontalBarImageHeight;
  77728. private _verticalBarImageHeight;
  77729. private _oldWindowContentsWidth;
  77730. private _oldWindowContentsHeight;
  77731. /**
  77732. * Gets the horizontal scrollbar
  77733. */
  77734. get horizontalBar(): ScrollBar | ImageScrollBar;
  77735. /**
  77736. * Gets the vertical scrollbar
  77737. */
  77738. get verticalBar(): ScrollBar | ImageScrollBar;
  77739. /**
  77740. * Adds a new control to the current container
  77741. * @param control defines the control to add
  77742. * @returns the current container
  77743. */
  77744. addControl(control: BABYLON.Nullable<Control>): Container;
  77745. /**
  77746. * Removes a control from the current container
  77747. * @param control defines the control to remove
  77748. * @returns the current container
  77749. */
  77750. removeControl(control: Control): Container;
  77751. /** Gets the list of children */
  77752. get children(): Control[];
  77753. _flagDescendantsAsMatrixDirty(): void;
  77754. /**
  77755. * Freezes or unfreezes the controls in the window.
  77756. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77757. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77758. */
  77759. get freezeControls(): boolean;
  77760. set freezeControls(value: boolean);
  77761. /** Gets the bucket width */
  77762. get bucketWidth(): number;
  77763. /** Gets the bucket height */
  77764. get bucketHeight(): number;
  77765. /**
  77766. * Sets the bucket sizes.
  77767. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77768. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77769. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77770. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77771. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77772. * used), that's why it is not enabled by default.
  77773. * @param width width of the bucket
  77774. * @param height height of the bucket
  77775. */
  77776. setBucketSizes(width: number, height: number): void;
  77777. private _forceHorizontalBar;
  77778. private _forceVerticalBar;
  77779. /**
  77780. * Forces the horizontal scroll bar to be displayed
  77781. */
  77782. get forceHorizontalBar(): boolean;
  77783. set forceHorizontalBar(value: boolean);
  77784. /**
  77785. * Forces the vertical scroll bar to be displayed
  77786. */
  77787. get forceVerticalBar(): boolean;
  77788. set forceVerticalBar(value: boolean);
  77789. /**
  77790. * Creates a new ScrollViewer
  77791. * @param name of ScrollViewer
  77792. */
  77793. constructor(name?: string, isImageBased?: boolean);
  77794. /** Reset the scroll viewer window to initial size */
  77795. resetWindow(): void;
  77796. protected _getTypeName(): string;
  77797. private _buildClientSizes;
  77798. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77799. protected _postMeasure(): void;
  77800. /**
  77801. * Gets or sets the mouse wheel precision
  77802. * from 0 to 1 with a default value of 0.05
  77803. * */
  77804. get wheelPrecision(): number;
  77805. set wheelPrecision(value: number);
  77806. /** Gets or sets the scroll bar container background color */
  77807. get scrollBackground(): string;
  77808. set scrollBackground(color: string);
  77809. /** Gets or sets the bar color */
  77810. get barColor(): string;
  77811. set barColor(color: string);
  77812. /** Gets or sets the bar image */
  77813. get thumbImage(): Image;
  77814. set thumbImage(value: Image);
  77815. /** Gets or sets the horizontal bar image */
  77816. get horizontalThumbImage(): Image;
  77817. set horizontalThumbImage(value: Image);
  77818. /** Gets or sets the vertical bar image */
  77819. get verticalThumbImage(): Image;
  77820. set verticalThumbImage(value: Image);
  77821. /** Gets or sets the size of the bar */
  77822. get barSize(): number;
  77823. set barSize(value: number);
  77824. /** Gets or sets the length of the thumb */
  77825. get thumbLength(): number;
  77826. set thumbLength(value: number);
  77827. /** Gets or sets the height of the thumb */
  77828. get thumbHeight(): number;
  77829. set thumbHeight(value: number);
  77830. /** Gets or sets the height of the bar image */
  77831. get barImageHeight(): number;
  77832. set barImageHeight(value: number);
  77833. /** Gets or sets the height of the horizontal bar image */
  77834. get horizontalBarImageHeight(): number;
  77835. set horizontalBarImageHeight(value: number);
  77836. /** Gets or sets the height of the vertical bar image */
  77837. get verticalBarImageHeight(): number;
  77838. set verticalBarImageHeight(value: number);
  77839. /** Gets or sets the bar background */
  77840. get barBackground(): string;
  77841. set barBackground(color: string);
  77842. /** Gets or sets the bar background image */
  77843. get barImage(): Image;
  77844. set barImage(value: Image);
  77845. /** Gets or sets the horizontal bar background image */
  77846. get horizontalBarImage(): Image;
  77847. set horizontalBarImage(value: Image);
  77848. /** Gets or sets the vertical bar background image */
  77849. get verticalBarImage(): Image;
  77850. set verticalBarImage(value: Image);
  77851. private _setWindowPosition;
  77852. /** @hidden */
  77853. private _updateScroller;
  77854. _link(host: AdvancedDynamicTexture): void;
  77855. /** @hidden */
  77856. private _addBar;
  77857. /** @hidden */
  77858. private _attachWheel;
  77859. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77860. /** Releases associated resources */
  77861. dispose(): void;
  77862. }
  77863. }
  77864. declare module BABYLON.GUI {
  77865. /** Class used to render a grid */
  77866. export class DisplayGrid extends Control {
  77867. name?: string | undefined;
  77868. private _cellWidth;
  77869. private _cellHeight;
  77870. private _minorLineTickness;
  77871. private _minorLineColor;
  77872. private _majorLineTickness;
  77873. private _majorLineColor;
  77874. private _majorLineFrequency;
  77875. private _background;
  77876. private _displayMajorLines;
  77877. private _displayMinorLines;
  77878. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77879. get displayMinorLines(): boolean;
  77880. set displayMinorLines(value: boolean);
  77881. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77882. get displayMajorLines(): boolean;
  77883. set displayMajorLines(value: boolean);
  77884. /** Gets or sets background color (Black by default) */
  77885. get background(): string;
  77886. set background(value: string);
  77887. /** Gets or sets the width of each cell (20 by default) */
  77888. get cellWidth(): number;
  77889. set cellWidth(value: number);
  77890. /** Gets or sets the height of each cell (20 by default) */
  77891. get cellHeight(): number;
  77892. set cellHeight(value: number);
  77893. /** Gets or sets the tickness of minor lines (1 by default) */
  77894. get minorLineTickness(): number;
  77895. set minorLineTickness(value: number);
  77896. /** Gets or sets the color of minor lines (DarkGray by default) */
  77897. get minorLineColor(): string;
  77898. set minorLineColor(value: string);
  77899. /** Gets or sets the tickness of major lines (2 by default) */
  77900. get majorLineTickness(): number;
  77901. set majorLineTickness(value: number);
  77902. /** Gets or sets the color of major lines (White by default) */
  77903. get majorLineColor(): string;
  77904. set majorLineColor(value: string);
  77905. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77906. get majorLineFrequency(): number;
  77907. set majorLineFrequency(value: number);
  77908. /**
  77909. * Creates a new GridDisplayRectangle
  77910. * @param name defines the control name
  77911. */
  77912. constructor(name?: string | undefined);
  77913. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77914. protected _getTypeName(): string;
  77915. }
  77916. }
  77917. declare module BABYLON.GUI {
  77918. /**
  77919. * Class used to create slider controls based on images
  77920. */
  77921. export class ImageBasedSlider extends BaseSlider {
  77922. name?: string | undefined;
  77923. private _backgroundImage;
  77924. private _thumbImage;
  77925. private _valueBarImage;
  77926. private _tempMeasure;
  77927. get displayThumb(): boolean;
  77928. set displayThumb(value: boolean);
  77929. /**
  77930. * Gets or sets the image used to render the background
  77931. */
  77932. get backgroundImage(): Image;
  77933. set backgroundImage(value: Image);
  77934. /**
  77935. * Gets or sets the image used to render the value bar
  77936. */
  77937. get valueBarImage(): Image;
  77938. set valueBarImage(value: Image);
  77939. /**
  77940. * Gets or sets the image used to render the thumb
  77941. */
  77942. get thumbImage(): Image;
  77943. set thumbImage(value: Image);
  77944. /**
  77945. * Creates a new ImageBasedSlider
  77946. * @param name defines the control name
  77947. */
  77948. constructor(name?: string | undefined);
  77949. protected _getTypeName(): string;
  77950. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77951. }
  77952. }
  77953. declare module BABYLON.GUI {
  77954. /**
  77955. * Forcing an export so that this code will execute
  77956. * @hidden
  77957. */
  77958. const name = "Statics";
  77959. }
  77960. declare module BABYLON.GUI {
  77961. /**
  77962. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77963. */
  77964. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77965. /**
  77966. * Define the instrumented AdvancedDynamicTexture.
  77967. */
  77968. texture: AdvancedDynamicTexture;
  77969. private _captureRenderTime;
  77970. private _renderTime;
  77971. private _captureLayoutTime;
  77972. private _layoutTime;
  77973. private _onBeginRenderObserver;
  77974. private _onEndRenderObserver;
  77975. private _onBeginLayoutObserver;
  77976. private _onEndLayoutObserver;
  77977. /**
  77978. * Gets the perf counter used to capture render time
  77979. */
  77980. get renderTimeCounter(): BABYLON.PerfCounter;
  77981. /**
  77982. * Gets the perf counter used to capture layout time
  77983. */
  77984. get layoutTimeCounter(): BABYLON.PerfCounter;
  77985. /**
  77986. * Enable or disable the render time capture
  77987. */
  77988. get captureRenderTime(): boolean;
  77989. set captureRenderTime(value: boolean);
  77990. /**
  77991. * Enable or disable the layout time capture
  77992. */
  77993. get captureLayoutTime(): boolean;
  77994. set captureLayoutTime(value: boolean);
  77995. /**
  77996. * Instantiates a new advanced dynamic texture instrumentation.
  77997. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77998. * @param texture Defines the AdvancedDynamicTexture to instrument
  77999. */
  78000. constructor(
  78001. /**
  78002. * Define the instrumented AdvancedDynamicTexture.
  78003. */
  78004. texture: AdvancedDynamicTexture);
  78005. /**
  78006. * Dispose and release associated resources.
  78007. */
  78008. dispose(): void;
  78009. }
  78010. }
  78011. declare module BABYLON.GUI {
  78012. /**
  78013. * Class used to load GUI via XML.
  78014. */
  78015. export class XmlLoader {
  78016. private _nodes;
  78017. private _nodeTypes;
  78018. private _isLoaded;
  78019. private _objectAttributes;
  78020. private _parentClass;
  78021. /**
  78022. * Create a new xml loader
  78023. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78024. */
  78025. constructor(parentClass?: null);
  78026. private _getChainElement;
  78027. private _getClassAttribute;
  78028. private _createGuiElement;
  78029. private _parseGrid;
  78030. private _parseElement;
  78031. private _prepareSourceElement;
  78032. private _parseElementsFromSource;
  78033. private _parseXml;
  78034. /**
  78035. * Gets if the loading has finished.
  78036. * @returns whether the loading has finished or not
  78037. */
  78038. isLoaded(): boolean;
  78039. /**
  78040. * Gets a loaded node / control by id.
  78041. * @param id the Controls id set in the xml
  78042. * @returns element of type Control
  78043. */
  78044. getNodeById(id: string): any;
  78045. /**
  78046. * Gets all loaded nodes / controls
  78047. * @returns Array of controls
  78048. */
  78049. getNodes(): any;
  78050. /**
  78051. * Initiates the xml layout loading
  78052. * @param xmlFile defines the xml layout to load
  78053. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78054. * @param callback defines the callback called on layout load.
  78055. */
  78056. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78057. }
  78058. }
  78059. declare module BABYLON.GUI {
  78060. /**
  78061. * Class used to create containers for controls
  78062. */
  78063. export class Container3D extends Control3D {
  78064. private _blockLayout;
  78065. /**
  78066. * Gets the list of child controls
  78067. */
  78068. protected _children: Control3D[];
  78069. /**
  78070. * Gets the list of child controls
  78071. */
  78072. get children(): Array<Control3D>;
  78073. /**
  78074. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78075. * This is helpful to optimize layout operation when adding multiple children in a row
  78076. */
  78077. get blockLayout(): boolean;
  78078. set blockLayout(value: boolean);
  78079. /**
  78080. * Creates a new container
  78081. * @param name defines the container name
  78082. */
  78083. constructor(name?: string);
  78084. /**
  78085. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78086. * @returns the current container
  78087. */
  78088. updateLayout(): Container3D;
  78089. /**
  78090. * Gets a boolean indicating if the given control is in the children of this control
  78091. * @param control defines the control to check
  78092. * @returns true if the control is in the child list
  78093. */
  78094. containsControl(control: Control3D): boolean;
  78095. /**
  78096. * Adds a control to the children of this control
  78097. * @param control defines the control to add
  78098. * @returns the current container
  78099. */
  78100. addControl(control: Control3D): Container3D;
  78101. /**
  78102. * This function will be called everytime a new control is added
  78103. */
  78104. protected _arrangeChildren(): void;
  78105. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78106. /**
  78107. * Removes a control from the children of this control
  78108. * @param control defines the control to remove
  78109. * @returns the current container
  78110. */
  78111. removeControl(control: Control3D): Container3D;
  78112. protected _getTypeName(): string;
  78113. /**
  78114. * Releases all associated resources
  78115. */
  78116. dispose(): void;
  78117. /** Control rotation will remain unchanged */
  78118. static readonly UNSET_ORIENTATION: number;
  78119. /** Control will rotate to make it look at sphere central axis */
  78120. static readonly FACEORIGIN_ORIENTATION: number;
  78121. /** Control will rotate to make it look back at sphere central axis */
  78122. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78123. /** Control will rotate to look at z axis (0, 0, 1) */
  78124. static readonly FACEFORWARD_ORIENTATION: number;
  78125. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78126. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78127. }
  78128. }
  78129. declare module BABYLON.GUI {
  78130. /**
  78131. * Class used to manage 3D user interface
  78132. * @see https://doc.babylonjs.com/how_to/gui3d
  78133. */
  78134. export class GUI3DManager implements BABYLON.IDisposable {
  78135. private _scene;
  78136. private _sceneDisposeObserver;
  78137. private _utilityLayer;
  78138. private _rootContainer;
  78139. private _pointerObserver;
  78140. private _pointerOutObserver;
  78141. /** @hidden */
  78142. _lastPickedControl: Control3D;
  78143. /** @hidden */
  78144. _lastControlOver: {
  78145. [pointerId: number]: Control3D;
  78146. };
  78147. /** @hidden */
  78148. _lastControlDown: {
  78149. [pointerId: number]: Control3D;
  78150. };
  78151. /**
  78152. * BABYLON.Observable raised when the point picked by the pointer events changed
  78153. */
  78154. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78155. /** @hidden */
  78156. _sharedMaterials: {
  78157. [key: string]: BABYLON.Material;
  78158. };
  78159. /** Gets the hosting scene */
  78160. get scene(): BABYLON.Scene;
  78161. /** Gets associated utility layer */
  78162. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78163. /**
  78164. * Creates a new GUI3DManager
  78165. * @param scene
  78166. */
  78167. constructor(scene?: BABYLON.Scene);
  78168. private _handlePointerOut;
  78169. private _doPicking;
  78170. /**
  78171. * Gets the root container
  78172. */
  78173. get rootContainer(): Container3D;
  78174. /**
  78175. * Gets a boolean indicating if the given control is in the root child list
  78176. * @param control defines the control to check
  78177. * @returns true if the control is in the root child list
  78178. */
  78179. containsControl(control: Control3D): boolean;
  78180. /**
  78181. * Adds a control to the root child list
  78182. * @param control defines the control to add
  78183. * @returns the current manager
  78184. */
  78185. addControl(control: Control3D): GUI3DManager;
  78186. /**
  78187. * Removes a control from the root child list
  78188. * @param control defines the control to remove
  78189. * @returns the current container
  78190. */
  78191. removeControl(control: Control3D): GUI3DManager;
  78192. /**
  78193. * Releases all associated resources
  78194. */
  78195. dispose(): void;
  78196. }
  78197. }
  78198. declare module BABYLON.GUI {
  78199. /**
  78200. * Class used to transport BABYLON.Vector3 information for pointer events
  78201. */
  78202. export class Vector3WithInfo extends BABYLON.Vector3 {
  78203. /** defines the current mouse button index */
  78204. buttonIndex: number;
  78205. /**
  78206. * Creates a new Vector3WithInfo
  78207. * @param source defines the vector3 data to transport
  78208. * @param buttonIndex defines the current mouse button index
  78209. */
  78210. constructor(source: BABYLON.Vector3,
  78211. /** defines the current mouse button index */
  78212. buttonIndex?: number);
  78213. }
  78214. }
  78215. declare module BABYLON.GUI {
  78216. /**
  78217. * Class used as base class for controls
  78218. */
  78219. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78220. /** Defines the control name */
  78221. name?: string | undefined;
  78222. /** @hidden */
  78223. _host: GUI3DManager;
  78224. private _node;
  78225. private _downCount;
  78226. private _enterCount;
  78227. private _downPointerIds;
  78228. private _isVisible;
  78229. /** Gets or sets the control position in world space */
  78230. get position(): BABYLON.Vector3;
  78231. set position(value: BABYLON.Vector3);
  78232. /** Gets or sets the control scaling in world space */
  78233. get scaling(): BABYLON.Vector3;
  78234. set scaling(value: BABYLON.Vector3);
  78235. /** Callback used to start pointer enter animation */
  78236. pointerEnterAnimation: () => void;
  78237. /** Callback used to start pointer out animation */
  78238. pointerOutAnimation: () => void;
  78239. /** Callback used to start pointer down animation */
  78240. pointerDownAnimation: () => void;
  78241. /** Callback used to start pointer up animation */
  78242. pointerUpAnimation: () => void;
  78243. /**
  78244. * An event triggered when the pointer move over the control
  78245. */
  78246. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78247. /**
  78248. * An event triggered when the pointer move out of the control
  78249. */
  78250. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78251. /**
  78252. * An event triggered when the pointer taps the control
  78253. */
  78254. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78255. /**
  78256. * An event triggered when pointer is up
  78257. */
  78258. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78259. /**
  78260. * An event triggered when a control is clicked on (with a mouse)
  78261. */
  78262. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78263. /**
  78264. * An event triggered when pointer enters the control
  78265. */
  78266. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78267. /**
  78268. * Gets or sets the parent container
  78269. */
  78270. parent: BABYLON.Nullable<Container3D>;
  78271. private _behaviors;
  78272. /**
  78273. * Gets the list of attached behaviors
  78274. * @see https://doc.babylonjs.com/features/behaviour
  78275. */
  78276. get behaviors(): BABYLON.Behavior<Control3D>[];
  78277. /**
  78278. * Attach a behavior to the control
  78279. * @see https://doc.babylonjs.com/features/behaviour
  78280. * @param behavior defines the behavior to attach
  78281. * @returns the current control
  78282. */
  78283. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78284. /**
  78285. * Remove an attached behavior
  78286. * @see https://doc.babylonjs.com/features/behaviour
  78287. * @param behavior defines the behavior to attach
  78288. * @returns the current control
  78289. */
  78290. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78291. /**
  78292. * Gets an attached behavior by name
  78293. * @param name defines the name of the behavior to look for
  78294. * @see https://doc.babylonjs.com/features/behaviour
  78295. * @returns null if behavior was not found else the requested behavior
  78296. */
  78297. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78298. /** Gets or sets a boolean indicating if the control is visible */
  78299. get isVisible(): boolean;
  78300. set isVisible(value: boolean);
  78301. /**
  78302. * Creates a new control
  78303. * @param name defines the control name
  78304. */
  78305. constructor(
  78306. /** Defines the control name */
  78307. name?: string | undefined);
  78308. /**
  78309. * Gets a string representing the class name
  78310. */
  78311. get typeName(): string;
  78312. /**
  78313. * Get the current class name of the control.
  78314. * @returns current class name
  78315. */
  78316. getClassName(): string;
  78317. protected _getTypeName(): string;
  78318. /**
  78319. * Gets the transform node used by this control
  78320. */
  78321. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78322. /**
  78323. * Gets the mesh used to render this control
  78324. */
  78325. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78326. /**
  78327. * Link the control as child of the given node
  78328. * @param node defines the node to link to. Use null to unlink the control
  78329. * @returns the current control
  78330. */
  78331. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78332. /** @hidden **/
  78333. _prepareNode(scene: BABYLON.Scene): void;
  78334. /**
  78335. * Node creation.
  78336. * Can be overriden by children
  78337. * @param scene defines the scene where the node must be attached
  78338. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78339. */
  78340. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78341. /**
  78342. * Affect a material to the given mesh
  78343. * @param mesh defines the mesh which will represent the control
  78344. */
  78345. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78346. /** @hidden */
  78347. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78348. /** @hidden */
  78349. _onPointerEnter(target: Control3D): boolean;
  78350. /** @hidden */
  78351. _onPointerOut(target: Control3D): void;
  78352. /** @hidden */
  78353. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78354. /** @hidden */
  78355. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78356. /** @hidden */
  78357. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78358. /** @hidden */
  78359. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78360. /** @hidden */
  78361. _disposeNode(): void;
  78362. /**
  78363. * Releases all associated resources
  78364. */
  78365. dispose(): void;
  78366. }
  78367. }
  78368. declare module BABYLON.GUI {
  78369. /**
  78370. * Class used as a root to all buttons
  78371. */
  78372. export class AbstractButton3D extends Control3D {
  78373. /**
  78374. * Creates a new button
  78375. * @param name defines the control name
  78376. */
  78377. constructor(name?: string);
  78378. protected _getTypeName(): string;
  78379. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78380. }
  78381. }
  78382. declare module BABYLON.GUI {
  78383. /**
  78384. * Class used to create a button in 3D
  78385. */
  78386. export class Button3D extends AbstractButton3D {
  78387. /** @hidden */
  78388. protected _currentMaterial: BABYLON.Material;
  78389. private _facadeTexture;
  78390. private _content;
  78391. private _contentResolution;
  78392. private _contentScaleRatio;
  78393. /**
  78394. * Gets or sets the texture resolution used to render content (512 by default)
  78395. */
  78396. get contentResolution(): BABYLON.int;
  78397. set contentResolution(value: BABYLON.int);
  78398. /**
  78399. * Gets or sets the texture scale ratio used to render content (2 by default)
  78400. */
  78401. get contentScaleRatio(): number;
  78402. set contentScaleRatio(value: number);
  78403. protected _disposeFacadeTexture(): void;
  78404. protected _resetContent(): void;
  78405. /**
  78406. * Creates a new button
  78407. * @param name defines the control name
  78408. */
  78409. constructor(name?: string);
  78410. /**
  78411. * Gets or sets the GUI 2D content used to display the button's facade
  78412. */
  78413. get content(): Control;
  78414. set content(value: Control);
  78415. /**
  78416. * Apply the facade texture (created from the content property).
  78417. * This function can be overloaded by child classes
  78418. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78419. */
  78420. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78421. protected _getTypeName(): string;
  78422. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78423. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78424. /**
  78425. * Releases all associated resources
  78426. */
  78427. dispose(): void;
  78428. }
  78429. }
  78430. declare module BABYLON.GUI {
  78431. /**
  78432. * Abstract class used to create a container panel deployed on the surface of a volume
  78433. */
  78434. export abstract class VolumeBasedPanel extends Container3D {
  78435. private _columns;
  78436. private _rows;
  78437. private _rowThenColum;
  78438. private _orientation;
  78439. protected _cellWidth: number;
  78440. protected _cellHeight: number;
  78441. /**
  78442. * Gets or sets the distance between elements
  78443. */
  78444. margin: number;
  78445. /**
  78446. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78447. * | Value | Type | Description |
  78448. * | ----- | ----------------------------------- | ----------- |
  78449. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78450. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78451. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78452. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78453. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78454. */
  78455. get orientation(): number;
  78456. set orientation(value: number);
  78457. /**
  78458. * Gets or sets the number of columns requested (10 by default).
  78459. * The panel will automatically compute the number of rows based on number of child controls.
  78460. */
  78461. get columns(): BABYLON.int;
  78462. set columns(value: BABYLON.int);
  78463. /**
  78464. * Gets or sets a the number of rows requested.
  78465. * The panel will automatically compute the number of columns based on number of child controls.
  78466. */
  78467. get rows(): BABYLON.int;
  78468. set rows(value: BABYLON.int);
  78469. /**
  78470. * Creates new VolumeBasedPanel
  78471. */
  78472. constructor();
  78473. protected _arrangeChildren(): void;
  78474. /** Child classes must implement this function to provide correct control positioning */
  78475. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78476. /** Child classes can implement this function to provide additional processing */
  78477. protected _finalProcessing(): void;
  78478. }
  78479. }
  78480. declare module BABYLON.GUI {
  78481. /**
  78482. * Class used to create a container panel deployed on the surface of a cylinder
  78483. */
  78484. export class CylinderPanel extends VolumeBasedPanel {
  78485. private _radius;
  78486. /**
  78487. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78488. */
  78489. get radius(): BABYLON.float;
  78490. set radius(value: BABYLON.float);
  78491. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78492. private _cylindricalMapping;
  78493. }
  78494. }
  78495. declare module BABYLON.GUI {
  78496. /** @hidden */
  78497. export var fluentVertexShader: {
  78498. name: string;
  78499. shader: string;
  78500. };
  78501. }
  78502. declare module BABYLON.GUI {
  78503. /** @hidden */
  78504. export var fluentPixelShader: {
  78505. name: string;
  78506. shader: string;
  78507. };
  78508. }
  78509. declare module BABYLON.GUI {
  78510. /** @hidden */
  78511. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78512. INNERGLOW: boolean;
  78513. BORDER: boolean;
  78514. HOVERLIGHT: boolean;
  78515. TEXTURE: boolean;
  78516. constructor();
  78517. }
  78518. /**
  78519. * Class used to render controls with fluent desgin
  78520. */
  78521. export class FluentMaterial extends BABYLON.PushMaterial {
  78522. /**
  78523. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78524. */
  78525. innerGlowColorIntensity: number;
  78526. /**
  78527. * Gets or sets the inner glow color (white by default)
  78528. */
  78529. innerGlowColor: BABYLON.Color3;
  78530. /**
  78531. * Gets or sets alpha value (default is 1.0)
  78532. */
  78533. alpha: number;
  78534. /**
  78535. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78536. */
  78537. albedoColor: BABYLON.Color3;
  78538. /**
  78539. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78540. */
  78541. renderBorders: boolean;
  78542. /**
  78543. * Gets or sets border width (default is 0.5)
  78544. */
  78545. borderWidth: number;
  78546. /**
  78547. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78548. */
  78549. edgeSmoothingValue: number;
  78550. /**
  78551. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78552. */
  78553. borderMinValue: number;
  78554. /**
  78555. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78556. */
  78557. renderHoverLight: boolean;
  78558. /**
  78559. * Gets or sets the radius used to render the hover light (default is 1.0)
  78560. */
  78561. hoverRadius: number;
  78562. /**
  78563. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78564. */
  78565. hoverColor: BABYLON.Color4;
  78566. /**
  78567. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78568. */
  78569. hoverPosition: BABYLON.Vector3;
  78570. private _albedoTexture;
  78571. /** Gets or sets the texture to use for albedo color */
  78572. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78573. /**
  78574. * Creates a new Fluent material
  78575. * @param name defines the name of the material
  78576. * @param scene defines the hosting scene
  78577. */
  78578. constructor(name: string, scene: BABYLON.Scene);
  78579. needAlphaBlending(): boolean;
  78580. needAlphaTesting(): boolean;
  78581. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78582. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78583. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78584. getActiveTextures(): BABYLON.BaseTexture[];
  78585. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78586. dispose(forceDisposeEffect?: boolean): void;
  78587. clone(name: string): FluentMaterial;
  78588. serialize(): any;
  78589. getClassName(): string;
  78590. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78591. }
  78592. }
  78593. declare module BABYLON.GUI {
  78594. /**
  78595. * Class used to create a holographic button in 3D
  78596. */
  78597. export class HolographicButton extends Button3D {
  78598. private _backPlate;
  78599. private _textPlate;
  78600. private _frontPlate;
  78601. private _text;
  78602. private _imageUrl;
  78603. private _shareMaterials;
  78604. private _frontMaterial;
  78605. private _backMaterial;
  78606. private _plateMaterial;
  78607. private _pickedPointObserver;
  78608. private _tooltipFade;
  78609. private _tooltipTextBlock;
  78610. private _tooltipTexture;
  78611. private _tooltipMesh;
  78612. private _tooltipHoverObserver;
  78613. private _tooltipOutObserver;
  78614. private _disposeTooltip;
  78615. /**
  78616. * Rendering ground id of all the mesh in the button
  78617. */
  78618. set renderingGroupId(id: number);
  78619. get renderingGroupId(): number;
  78620. /**
  78621. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78622. */
  78623. set tooltipText(text: BABYLON.Nullable<string>);
  78624. get tooltipText(): BABYLON.Nullable<string>;
  78625. /**
  78626. * Gets or sets text for the button
  78627. */
  78628. get text(): string;
  78629. set text(value: string);
  78630. /**
  78631. * Gets or sets the image url for the button
  78632. */
  78633. get imageUrl(): string;
  78634. set imageUrl(value: string);
  78635. /**
  78636. * Gets the back material used by this button
  78637. */
  78638. get backMaterial(): FluentMaterial;
  78639. /**
  78640. * Gets the front material used by this button
  78641. */
  78642. get frontMaterial(): FluentMaterial;
  78643. /**
  78644. * Gets the plate material used by this button
  78645. */
  78646. get plateMaterial(): BABYLON.StandardMaterial;
  78647. /**
  78648. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78649. */
  78650. get shareMaterials(): boolean;
  78651. /**
  78652. * Creates a new button
  78653. * @param name defines the control name
  78654. */
  78655. constructor(name?: string, shareMaterials?: boolean);
  78656. protected _getTypeName(): string;
  78657. private _rebuildContent;
  78658. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78659. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78660. private _createBackMaterial;
  78661. private _createFrontMaterial;
  78662. private _createPlateMaterial;
  78663. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78664. /**
  78665. * Releases all associated resources
  78666. */
  78667. dispose(): void;
  78668. }
  78669. }
  78670. declare module BABYLON.GUI {
  78671. /**
  78672. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78673. */
  78674. export class MeshButton3D extends Button3D {
  78675. /** @hidden */
  78676. protected _currentMesh: BABYLON.Mesh;
  78677. /**
  78678. * Creates a new 3D button based on a mesh
  78679. * @param mesh mesh to become a 3D button
  78680. * @param name defines the control name
  78681. */
  78682. constructor(mesh: BABYLON.Mesh, name?: string);
  78683. protected _getTypeName(): string;
  78684. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78685. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78686. }
  78687. }
  78688. declare module BABYLON.GUI {
  78689. /**
  78690. * Class used to create a container panel deployed on the surface of a plane
  78691. */
  78692. export class PlanePanel extends VolumeBasedPanel {
  78693. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78694. }
  78695. }
  78696. declare module BABYLON.GUI {
  78697. /**
  78698. * Class used to create a container panel where items get randomized planar mapping
  78699. */
  78700. export class ScatterPanel extends VolumeBasedPanel {
  78701. private _iteration;
  78702. /**
  78703. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78704. */
  78705. get iteration(): BABYLON.float;
  78706. set iteration(value: BABYLON.float);
  78707. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78708. private _scatterMapping;
  78709. protected _finalProcessing(): void;
  78710. }
  78711. }
  78712. declare module BABYLON.GUI {
  78713. /**
  78714. * Class used to create a container panel deployed on the surface of a sphere
  78715. */
  78716. export class SpherePanel extends VolumeBasedPanel {
  78717. private _radius;
  78718. /**
  78719. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78720. */
  78721. get radius(): BABYLON.float;
  78722. set radius(value: BABYLON.float);
  78723. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78724. private _sphericalMapping;
  78725. }
  78726. }
  78727. declare module BABYLON.GUI {
  78728. /**
  78729. * Class used to create a stack panel in 3D on XY plane
  78730. */
  78731. export class StackPanel3D extends Container3D {
  78732. private _isVertical;
  78733. /**
  78734. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78735. */
  78736. get isVertical(): boolean;
  78737. set isVertical(value: boolean);
  78738. /**
  78739. * Gets or sets the distance between elements
  78740. */
  78741. margin: number;
  78742. /**
  78743. * Creates new StackPanel
  78744. * @param isVertical
  78745. */
  78746. constructor(isVertical?: boolean);
  78747. protected _arrangeChildren(): void;
  78748. }
  78749. }
  78750. declare module BABYLON {
  78751. /**
  78752. * Configuration for glTF validation
  78753. */
  78754. export interface IGLTFValidationConfiguration {
  78755. /**
  78756. * The url of the glTF validator.
  78757. */
  78758. url: string;
  78759. }
  78760. /**
  78761. * glTF validation
  78762. */
  78763. export class GLTFValidation {
  78764. /**
  78765. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78766. */
  78767. static Configuration: IGLTFValidationConfiguration;
  78768. private static _LoadScriptPromise;
  78769. /**
  78770. * Validate a glTF asset using the glTF-Validator.
  78771. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78772. * @param rootUrl The root url for the glTF
  78773. * @param fileName The file name for the glTF
  78774. * @param getExternalResource The callback to get external resources for the glTF validator
  78775. * @returns A promise that resolves with the glTF validation results once complete
  78776. */
  78777. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78778. }
  78779. }
  78780. declare module BABYLON {
  78781. /**
  78782. * Mode that determines the coordinate system to use.
  78783. */
  78784. export enum GLTFLoaderCoordinateSystemMode {
  78785. /**
  78786. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78787. */
  78788. AUTO = 0,
  78789. /**
  78790. * Sets the useRightHandedSystem flag on the scene.
  78791. */
  78792. FORCE_RIGHT_HANDED = 1
  78793. }
  78794. /**
  78795. * Mode that determines what animations will start.
  78796. */
  78797. export enum GLTFLoaderAnimationStartMode {
  78798. /**
  78799. * No animation will start.
  78800. */
  78801. NONE = 0,
  78802. /**
  78803. * The first animation will start.
  78804. */
  78805. FIRST = 1,
  78806. /**
  78807. * All animations will start.
  78808. */
  78809. ALL = 2
  78810. }
  78811. /**
  78812. * Interface that contains the data for the glTF asset.
  78813. */
  78814. export interface IGLTFLoaderData {
  78815. /**
  78816. * The object that represents the glTF JSON.
  78817. */
  78818. json: Object;
  78819. /**
  78820. * The BIN chunk of a binary glTF.
  78821. */
  78822. bin: Nullable<IDataBuffer>;
  78823. }
  78824. /**
  78825. * Interface for extending the loader.
  78826. */
  78827. export interface IGLTFLoaderExtension {
  78828. /**
  78829. * The name of this extension.
  78830. */
  78831. readonly name: string;
  78832. /**
  78833. * Defines whether this extension is enabled.
  78834. */
  78835. enabled: boolean;
  78836. /**
  78837. * Defines the order of this extension.
  78838. * The loader sorts the extensions using these values when loading.
  78839. */
  78840. order?: number;
  78841. }
  78842. /**
  78843. * Loader state.
  78844. */
  78845. export enum GLTFLoaderState {
  78846. /**
  78847. * The asset is loading.
  78848. */
  78849. LOADING = 0,
  78850. /**
  78851. * The asset is ready for rendering.
  78852. */
  78853. READY = 1,
  78854. /**
  78855. * The asset is completely loaded.
  78856. */
  78857. COMPLETE = 2
  78858. }
  78859. /** @hidden */
  78860. export interface IImportMeshAsyncOutput {
  78861. meshes: AbstractMesh[];
  78862. particleSystems: IParticleSystem[];
  78863. skeletons: Skeleton[];
  78864. animationGroups: AnimationGroup[];
  78865. lights: Light[];
  78866. transformNodes: TransformNode[];
  78867. }
  78868. /** @hidden */
  78869. export interface IGLTFLoader extends IDisposable {
  78870. readonly state: Nullable<GLTFLoaderState>;
  78871. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78872. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78873. }
  78874. /**
  78875. * File loader for loading glTF files into a scene.
  78876. */
  78877. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78878. /** @hidden */
  78879. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78880. /** @hidden */
  78881. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78882. /**
  78883. * Raised when the asset has been parsed
  78884. */
  78885. onParsedObservable: Observable<IGLTFLoaderData>;
  78886. private _onParsedObserver;
  78887. /**
  78888. * Raised when the asset has been parsed
  78889. */
  78890. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78891. /**
  78892. * 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.
  78893. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78894. * Defaults to true.
  78895. * @hidden
  78896. */
  78897. static IncrementalLoading: boolean;
  78898. /**
  78899. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78900. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78901. * @hidden
  78902. */
  78903. static HomogeneousCoordinates: boolean;
  78904. /**
  78905. * The coordinate system mode. Defaults to AUTO.
  78906. */
  78907. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78908. /**
  78909. * The animation start mode. Defaults to FIRST.
  78910. */
  78911. animationStartMode: GLTFLoaderAnimationStartMode;
  78912. /**
  78913. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78914. */
  78915. compileMaterials: boolean;
  78916. /**
  78917. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78918. */
  78919. useClipPlane: boolean;
  78920. /**
  78921. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78922. */
  78923. compileShadowGenerators: boolean;
  78924. /**
  78925. * Defines if the Alpha blended materials are only applied as coverage.
  78926. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78927. * If true, no extra effects are applied to transparent pixels.
  78928. */
  78929. transparencyAsCoverage: boolean;
  78930. /**
  78931. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78932. * Enabling will disable offline support and glTF validator.
  78933. * Defaults to false.
  78934. */
  78935. useRangeRequests: boolean;
  78936. /**
  78937. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78938. */
  78939. createInstances: boolean;
  78940. /**
  78941. * 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.
  78942. */
  78943. alwaysComputeBoundingBox: boolean;
  78944. /**
  78945. * Function called before loading a url referenced by the asset.
  78946. */
  78947. preprocessUrlAsync: (url: string) => Promise<string>;
  78948. /**
  78949. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78950. */
  78951. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78952. private _onMeshLoadedObserver;
  78953. /**
  78954. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78955. */
  78956. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78957. /**
  78958. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78959. */
  78960. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78961. private _onTextureLoadedObserver;
  78962. /**
  78963. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78964. */
  78965. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78966. /**
  78967. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78968. */
  78969. readonly onMaterialLoadedObservable: Observable<Material>;
  78970. private _onMaterialLoadedObserver;
  78971. /**
  78972. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78973. */
  78974. set onMaterialLoaded(callback: (material: Material) => void);
  78975. /**
  78976. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78977. */
  78978. readonly onCameraLoadedObservable: Observable<Camera>;
  78979. private _onCameraLoadedObserver;
  78980. /**
  78981. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78982. */
  78983. set onCameraLoaded(callback: (camera: Camera) => void);
  78984. /**
  78985. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78986. * For assets with LODs, raised when all of the LODs are complete.
  78987. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78988. */
  78989. readonly onCompleteObservable: Observable<void>;
  78990. private _onCompleteObserver;
  78991. /**
  78992. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78993. * For assets with LODs, raised when all of the LODs are complete.
  78994. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78995. */
  78996. set onComplete(callback: () => void);
  78997. /**
  78998. * Observable raised when an error occurs.
  78999. */
  79000. readonly onErrorObservable: Observable<any>;
  79001. private _onErrorObserver;
  79002. /**
  79003. * Callback raised when an error occurs.
  79004. */
  79005. set onError(callback: (reason: any) => void);
  79006. /**
  79007. * Observable raised after the loader is disposed.
  79008. */
  79009. readonly onDisposeObservable: Observable<void>;
  79010. private _onDisposeObserver;
  79011. /**
  79012. * Callback raised after the loader is disposed.
  79013. */
  79014. set onDispose(callback: () => void);
  79015. /**
  79016. * Observable raised after a loader extension is created.
  79017. * Set additional options for a loader extension in this event.
  79018. */
  79019. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79020. private _onExtensionLoadedObserver;
  79021. /**
  79022. * Callback raised after a loader extension is created.
  79023. */
  79024. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79025. /**
  79026. * Defines if the loader logging is enabled.
  79027. */
  79028. get loggingEnabled(): boolean;
  79029. set loggingEnabled(value: boolean);
  79030. /**
  79031. * Defines if the loader should capture performance counters.
  79032. */
  79033. get capturePerformanceCounters(): boolean;
  79034. set capturePerformanceCounters(value: boolean);
  79035. /**
  79036. * Defines if the loader should validate the asset.
  79037. */
  79038. validate: boolean;
  79039. /**
  79040. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79041. */
  79042. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79043. private _onValidatedObserver;
  79044. /**
  79045. * Callback raised after a loader extension is created.
  79046. */
  79047. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79048. private _loader;
  79049. private _progressCallback?;
  79050. private _requests;
  79051. private static magicBase64Encoded;
  79052. /**
  79053. * Name of the loader ("gltf")
  79054. */
  79055. name: string;
  79056. /** @hidden */
  79057. extensions: ISceneLoaderPluginExtensions;
  79058. /**
  79059. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79060. */
  79061. dispose(): void;
  79062. /** @hidden */
  79063. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79064. /** @hidden */
  79065. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79066. /** @hidden */
  79067. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79068. meshes: AbstractMesh[];
  79069. particleSystems: IParticleSystem[];
  79070. skeletons: Skeleton[];
  79071. animationGroups: AnimationGroup[];
  79072. }>;
  79073. /** @hidden */
  79074. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79075. /** @hidden */
  79076. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79077. /** @hidden */
  79078. canDirectLoad(data: string): boolean;
  79079. /** @hidden */
  79080. directLoad(scene: Scene, data: string): Promise<any>;
  79081. /**
  79082. * The callback that allows custom handling of the root url based on the response url.
  79083. * @param rootUrl the original root url
  79084. * @param responseURL the response url if available
  79085. * @returns the new root url
  79086. */
  79087. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79088. /** @hidden */
  79089. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79090. /**
  79091. * The loader state or null if the loader is not active.
  79092. */
  79093. get loaderState(): Nullable<GLTFLoaderState>;
  79094. /**
  79095. * Returns a promise that resolves when the asset is completely loaded.
  79096. * @returns a promise that resolves when the asset is completely loaded.
  79097. */
  79098. whenCompleteAsync(): Promise<void>;
  79099. /** @hidden */
  79100. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79101. /** @hidden */
  79102. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79103. private _onProgress;
  79104. private _validate;
  79105. private _getLoader;
  79106. private _parseJson;
  79107. private _unpackBinaryAsync;
  79108. private _unpackBinaryV1Async;
  79109. private _unpackBinaryV2Async;
  79110. private static _parseVersion;
  79111. private static _compareVersion;
  79112. private static readonly _logSpaces;
  79113. private _logIndentLevel;
  79114. private _loggingEnabled;
  79115. /** @hidden */
  79116. _log: (message: string) => void;
  79117. /** @hidden */
  79118. _logOpen(message: string): void;
  79119. /** @hidden */
  79120. _logClose(): void;
  79121. private _logEnabled;
  79122. private _logDisabled;
  79123. private _capturePerformanceCounters;
  79124. /** @hidden */
  79125. _startPerformanceCounter: (counterName: string) => void;
  79126. /** @hidden */
  79127. _endPerformanceCounter: (counterName: string) => void;
  79128. private _startPerformanceCounterEnabled;
  79129. private _startPerformanceCounterDisabled;
  79130. private _endPerformanceCounterEnabled;
  79131. private _endPerformanceCounterDisabled;
  79132. }
  79133. }
  79134. declare module BABYLON.GLTF1 {
  79135. /**
  79136. * Enums
  79137. * @hidden
  79138. */
  79139. export enum EComponentType {
  79140. BYTE = 5120,
  79141. UNSIGNED_BYTE = 5121,
  79142. SHORT = 5122,
  79143. UNSIGNED_SHORT = 5123,
  79144. FLOAT = 5126
  79145. }
  79146. /** @hidden */
  79147. export enum EShaderType {
  79148. FRAGMENT = 35632,
  79149. VERTEX = 35633
  79150. }
  79151. /** @hidden */
  79152. export enum EParameterType {
  79153. BYTE = 5120,
  79154. UNSIGNED_BYTE = 5121,
  79155. SHORT = 5122,
  79156. UNSIGNED_SHORT = 5123,
  79157. INT = 5124,
  79158. UNSIGNED_INT = 5125,
  79159. FLOAT = 5126,
  79160. FLOAT_VEC2 = 35664,
  79161. FLOAT_VEC3 = 35665,
  79162. FLOAT_VEC4 = 35666,
  79163. INT_VEC2 = 35667,
  79164. INT_VEC3 = 35668,
  79165. INT_VEC4 = 35669,
  79166. BOOL = 35670,
  79167. BOOL_VEC2 = 35671,
  79168. BOOL_VEC3 = 35672,
  79169. BOOL_VEC4 = 35673,
  79170. FLOAT_MAT2 = 35674,
  79171. FLOAT_MAT3 = 35675,
  79172. FLOAT_MAT4 = 35676,
  79173. SAMPLER_2D = 35678
  79174. }
  79175. /** @hidden */
  79176. export enum ETextureWrapMode {
  79177. CLAMP_TO_EDGE = 33071,
  79178. MIRRORED_REPEAT = 33648,
  79179. REPEAT = 10497
  79180. }
  79181. /** @hidden */
  79182. export enum ETextureFilterType {
  79183. NEAREST = 9728,
  79184. LINEAR = 9728,
  79185. NEAREST_MIPMAP_NEAREST = 9984,
  79186. LINEAR_MIPMAP_NEAREST = 9985,
  79187. NEAREST_MIPMAP_LINEAR = 9986,
  79188. LINEAR_MIPMAP_LINEAR = 9987
  79189. }
  79190. /** @hidden */
  79191. export enum ETextureFormat {
  79192. ALPHA = 6406,
  79193. RGB = 6407,
  79194. RGBA = 6408,
  79195. LUMINANCE = 6409,
  79196. LUMINANCE_ALPHA = 6410
  79197. }
  79198. /** @hidden */
  79199. export enum ECullingType {
  79200. FRONT = 1028,
  79201. BACK = 1029,
  79202. FRONT_AND_BACK = 1032
  79203. }
  79204. /** @hidden */
  79205. export enum EBlendingFunction {
  79206. ZERO = 0,
  79207. ONE = 1,
  79208. SRC_COLOR = 768,
  79209. ONE_MINUS_SRC_COLOR = 769,
  79210. DST_COLOR = 774,
  79211. ONE_MINUS_DST_COLOR = 775,
  79212. SRC_ALPHA = 770,
  79213. ONE_MINUS_SRC_ALPHA = 771,
  79214. DST_ALPHA = 772,
  79215. ONE_MINUS_DST_ALPHA = 773,
  79216. CONSTANT_COLOR = 32769,
  79217. ONE_MINUS_CONSTANT_COLOR = 32770,
  79218. CONSTANT_ALPHA = 32771,
  79219. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79220. SRC_ALPHA_SATURATE = 776
  79221. }
  79222. /** @hidden */
  79223. export interface IGLTFProperty {
  79224. extensions?: {
  79225. [key: string]: any;
  79226. };
  79227. extras?: Object;
  79228. }
  79229. /** @hidden */
  79230. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79231. name?: string;
  79232. }
  79233. /** @hidden */
  79234. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79235. bufferView: string;
  79236. byteOffset: number;
  79237. byteStride: number;
  79238. count: number;
  79239. type: string;
  79240. componentType: EComponentType;
  79241. max?: number[];
  79242. min?: number[];
  79243. name?: string;
  79244. }
  79245. /** @hidden */
  79246. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79247. buffer: string;
  79248. byteOffset: number;
  79249. byteLength: number;
  79250. byteStride: number;
  79251. target?: number;
  79252. }
  79253. /** @hidden */
  79254. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79255. uri: string;
  79256. byteLength?: number;
  79257. type?: string;
  79258. }
  79259. /** @hidden */
  79260. export interface IGLTFShader extends IGLTFChildRootProperty {
  79261. uri: string;
  79262. type: EShaderType;
  79263. }
  79264. /** @hidden */
  79265. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79266. attributes: string[];
  79267. fragmentShader: string;
  79268. vertexShader: string;
  79269. }
  79270. /** @hidden */
  79271. export interface IGLTFTechniqueParameter {
  79272. type: number;
  79273. count?: number;
  79274. semantic?: string;
  79275. node?: string;
  79276. value?: number | boolean | string | Array<any>;
  79277. source?: string;
  79278. babylonValue?: any;
  79279. }
  79280. /** @hidden */
  79281. export interface IGLTFTechniqueCommonProfile {
  79282. lightingModel: string;
  79283. texcoordBindings: Object;
  79284. parameters?: Array<any>;
  79285. }
  79286. /** @hidden */
  79287. export interface IGLTFTechniqueStatesFunctions {
  79288. blendColor?: number[];
  79289. blendEquationSeparate?: number[];
  79290. blendFuncSeparate?: number[];
  79291. colorMask: boolean[];
  79292. cullFace: number[];
  79293. }
  79294. /** @hidden */
  79295. export interface IGLTFTechniqueStates {
  79296. enable: number[];
  79297. functions: IGLTFTechniqueStatesFunctions;
  79298. }
  79299. /** @hidden */
  79300. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79301. parameters: {
  79302. [key: string]: IGLTFTechniqueParameter;
  79303. };
  79304. program: string;
  79305. attributes: {
  79306. [key: string]: string;
  79307. };
  79308. uniforms: {
  79309. [key: string]: string;
  79310. };
  79311. states: IGLTFTechniqueStates;
  79312. }
  79313. /** @hidden */
  79314. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79315. technique?: string;
  79316. values: string[];
  79317. }
  79318. /** @hidden */
  79319. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79320. attributes: {
  79321. [key: string]: string;
  79322. };
  79323. indices: string;
  79324. material: string;
  79325. mode?: number;
  79326. }
  79327. /** @hidden */
  79328. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79329. primitives: IGLTFMeshPrimitive[];
  79330. }
  79331. /** @hidden */
  79332. export interface IGLTFImage extends IGLTFChildRootProperty {
  79333. uri: string;
  79334. }
  79335. /** @hidden */
  79336. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79337. magFilter?: number;
  79338. minFilter?: number;
  79339. wrapS?: number;
  79340. wrapT?: number;
  79341. }
  79342. /** @hidden */
  79343. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79344. sampler: string;
  79345. source: string;
  79346. format?: ETextureFormat;
  79347. internalFormat?: ETextureFormat;
  79348. target?: number;
  79349. type?: number;
  79350. babylonTexture?: Texture;
  79351. }
  79352. /** @hidden */
  79353. export interface IGLTFAmbienLight {
  79354. color?: number[];
  79355. }
  79356. /** @hidden */
  79357. export interface IGLTFDirectionalLight {
  79358. color?: number[];
  79359. }
  79360. /** @hidden */
  79361. export interface IGLTFPointLight {
  79362. color?: number[];
  79363. constantAttenuation?: number;
  79364. linearAttenuation?: number;
  79365. quadraticAttenuation?: number;
  79366. }
  79367. /** @hidden */
  79368. export interface IGLTFSpotLight {
  79369. color?: number[];
  79370. constantAttenuation?: number;
  79371. fallOfAngle?: number;
  79372. fallOffExponent?: number;
  79373. linearAttenuation?: number;
  79374. quadraticAttenuation?: number;
  79375. }
  79376. /** @hidden */
  79377. export interface IGLTFLight extends IGLTFChildRootProperty {
  79378. type: string;
  79379. }
  79380. /** @hidden */
  79381. export interface IGLTFCameraOrthographic {
  79382. xmag: number;
  79383. ymag: number;
  79384. zfar: number;
  79385. znear: number;
  79386. }
  79387. /** @hidden */
  79388. export interface IGLTFCameraPerspective {
  79389. aspectRatio: number;
  79390. yfov: number;
  79391. zfar: number;
  79392. znear: number;
  79393. }
  79394. /** @hidden */
  79395. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79396. type: string;
  79397. }
  79398. /** @hidden */
  79399. export interface IGLTFAnimationChannelTarget {
  79400. id: string;
  79401. path: string;
  79402. }
  79403. /** @hidden */
  79404. export interface IGLTFAnimationChannel {
  79405. sampler: string;
  79406. target: IGLTFAnimationChannelTarget;
  79407. }
  79408. /** @hidden */
  79409. export interface IGLTFAnimationSampler {
  79410. input: string;
  79411. output: string;
  79412. interpolation?: string;
  79413. }
  79414. /** @hidden */
  79415. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79416. channels?: IGLTFAnimationChannel[];
  79417. parameters?: {
  79418. [key: string]: string;
  79419. };
  79420. samplers?: {
  79421. [key: string]: IGLTFAnimationSampler;
  79422. };
  79423. }
  79424. /** @hidden */
  79425. export interface IGLTFNodeInstanceSkin {
  79426. skeletons: string[];
  79427. skin: string;
  79428. meshes: string[];
  79429. }
  79430. /** @hidden */
  79431. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79432. bindShapeMatrix: number[];
  79433. inverseBindMatrices: string;
  79434. jointNames: string[];
  79435. babylonSkeleton?: Skeleton;
  79436. }
  79437. /** @hidden */
  79438. export interface IGLTFNode extends IGLTFChildRootProperty {
  79439. camera?: string;
  79440. children: string[];
  79441. skin?: string;
  79442. jointName?: string;
  79443. light?: string;
  79444. matrix: number[];
  79445. mesh?: string;
  79446. meshes?: string[];
  79447. rotation?: number[];
  79448. scale?: number[];
  79449. translation?: number[];
  79450. babylonNode?: Node;
  79451. }
  79452. /** @hidden */
  79453. export interface IGLTFScene extends IGLTFChildRootProperty {
  79454. nodes: string[];
  79455. }
  79456. /** @hidden */
  79457. export interface IGLTFRuntime {
  79458. extensions: {
  79459. [key: string]: any;
  79460. };
  79461. accessors: {
  79462. [key: string]: IGLTFAccessor;
  79463. };
  79464. buffers: {
  79465. [key: string]: IGLTFBuffer;
  79466. };
  79467. bufferViews: {
  79468. [key: string]: IGLTFBufferView;
  79469. };
  79470. meshes: {
  79471. [key: string]: IGLTFMesh;
  79472. };
  79473. lights: {
  79474. [key: string]: IGLTFLight;
  79475. };
  79476. cameras: {
  79477. [key: string]: IGLTFCamera;
  79478. };
  79479. nodes: {
  79480. [key: string]: IGLTFNode;
  79481. };
  79482. images: {
  79483. [key: string]: IGLTFImage;
  79484. };
  79485. textures: {
  79486. [key: string]: IGLTFTexture;
  79487. };
  79488. shaders: {
  79489. [key: string]: IGLTFShader;
  79490. };
  79491. programs: {
  79492. [key: string]: IGLTFProgram;
  79493. };
  79494. samplers: {
  79495. [key: string]: IGLTFSampler;
  79496. };
  79497. techniques: {
  79498. [key: string]: IGLTFTechnique;
  79499. };
  79500. materials: {
  79501. [key: string]: IGLTFMaterial;
  79502. };
  79503. animations: {
  79504. [key: string]: IGLTFAnimation;
  79505. };
  79506. skins: {
  79507. [key: string]: IGLTFSkins;
  79508. };
  79509. currentScene?: Object;
  79510. scenes: {
  79511. [key: string]: IGLTFScene;
  79512. };
  79513. extensionsUsed: string[];
  79514. extensionsRequired?: string[];
  79515. buffersCount: number;
  79516. shaderscount: number;
  79517. scene: Scene;
  79518. rootUrl: string;
  79519. loadedBufferCount: number;
  79520. loadedBufferViews: {
  79521. [name: string]: ArrayBufferView;
  79522. };
  79523. loadedShaderCount: number;
  79524. importOnlyMeshes: boolean;
  79525. importMeshesNames?: string[];
  79526. dummyNodes: Node[];
  79527. forAssetContainer: boolean;
  79528. }
  79529. /** @hidden */
  79530. export interface INodeToRoot {
  79531. bone: Bone;
  79532. node: IGLTFNode;
  79533. id: string;
  79534. }
  79535. /** @hidden */
  79536. export interface IJointNode {
  79537. node: IGLTFNode;
  79538. id: string;
  79539. }
  79540. }
  79541. declare module BABYLON.GLTF1 {
  79542. /**
  79543. * Utils functions for GLTF
  79544. * @hidden
  79545. */
  79546. export class GLTFUtils {
  79547. /**
  79548. * Sets the given "parameter" matrix
  79549. * @param scene: the Scene object
  79550. * @param source: the source node where to pick the matrix
  79551. * @param parameter: the GLTF technique parameter
  79552. * @param uniformName: the name of the shader's uniform
  79553. * @param shaderMaterial: the shader material
  79554. */
  79555. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79556. /**
  79557. * Sets the given "parameter" matrix
  79558. * @param shaderMaterial: the shader material
  79559. * @param uniform: the name of the shader's uniform
  79560. * @param value: the value of the uniform
  79561. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79562. */
  79563. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79564. /**
  79565. * Returns the wrap mode of the texture
  79566. * @param mode: the mode value
  79567. */
  79568. static GetWrapMode(mode: number): number;
  79569. /**
  79570. * Returns the byte stride giving an accessor
  79571. * @param accessor: the GLTF accessor objet
  79572. */
  79573. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79574. /**
  79575. * Returns the texture filter mode giving a mode value
  79576. * @param mode: the filter mode value
  79577. */
  79578. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79579. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79580. /**
  79581. * Returns a buffer from its accessor
  79582. * @param gltfRuntime: the GLTF runtime
  79583. * @param accessor: the GLTF accessor
  79584. */
  79585. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79586. /**
  79587. * Decodes a buffer view into a string
  79588. * @param view: the buffer view
  79589. */
  79590. static DecodeBufferToText(view: ArrayBufferView): string;
  79591. /**
  79592. * Returns the default material of gltf. Related to
  79593. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79594. * @param scene: the Babylon.js scene
  79595. */
  79596. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79597. private static _DefaultMaterial;
  79598. }
  79599. }
  79600. declare module BABYLON.GLTF1 {
  79601. /**
  79602. * Implementation of the base glTF spec
  79603. * @hidden
  79604. */
  79605. export class GLTFLoaderBase {
  79606. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79607. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79608. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79609. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79610. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79611. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79612. }
  79613. /**
  79614. * glTF V1 Loader
  79615. * @hidden
  79616. */
  79617. export class GLTFLoader implements IGLTFLoader {
  79618. static Extensions: {
  79619. [name: string]: GLTFLoaderExtension;
  79620. };
  79621. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79622. state: Nullable<GLTFLoaderState>;
  79623. dispose(): void;
  79624. private _importMeshAsync;
  79625. /**
  79626. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79627. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79628. * @param scene the scene the meshes should be added to
  79629. * @param forAssetContainer defines if the entities must be stored in the scene
  79630. * @param data gltf data containing information of the meshes in a loaded file
  79631. * @param rootUrl root url to load from
  79632. * @param onProgress event that fires when loading progress has occured
  79633. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79634. */
  79635. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79636. private _loadAsync;
  79637. /**
  79638. * Imports all objects from a loaded gltf file and adds them to the scene
  79639. * @param scene the scene the objects should be added to
  79640. * @param data gltf data containing information of the meshes in a loaded file
  79641. * @param rootUrl root url to load from
  79642. * @param onProgress event that fires when loading progress has occured
  79643. * @returns a promise which completes when objects have been loaded to the scene
  79644. */
  79645. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79646. private _loadShadersAsync;
  79647. private _loadBuffersAsync;
  79648. private _createNodes;
  79649. }
  79650. /** @hidden */
  79651. export abstract class GLTFLoaderExtension {
  79652. private _name;
  79653. constructor(name: string);
  79654. get name(): string;
  79655. /**
  79656. * Defines an override for loading the runtime
  79657. * Return true to stop further extensions from loading the runtime
  79658. */
  79659. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79660. /**
  79661. * Defines an onverride for creating gltf runtime
  79662. * Return true to stop further extensions from creating the runtime
  79663. */
  79664. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79665. /**
  79666. * Defines an override for loading buffers
  79667. * Return true to stop further extensions from loading this buffer
  79668. */
  79669. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79670. /**
  79671. * Defines an override for loading texture buffers
  79672. * Return true to stop further extensions from loading this texture data
  79673. */
  79674. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79675. /**
  79676. * Defines an override for creating textures
  79677. * Return true to stop further extensions from loading this texture
  79678. */
  79679. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79680. /**
  79681. * Defines an override for loading shader strings
  79682. * Return true to stop further extensions from loading this shader data
  79683. */
  79684. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79685. /**
  79686. * Defines an override for loading materials
  79687. * Return true to stop further extensions from loading this material
  79688. */
  79689. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79690. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79691. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79692. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79693. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79694. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79695. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79696. private static LoadTextureBufferAsync;
  79697. private static CreateTextureAsync;
  79698. private static ApplyExtensions;
  79699. }
  79700. }
  79701. declare module BABYLON.GLTF1 {
  79702. /** @hidden */
  79703. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79704. private _bin;
  79705. constructor();
  79706. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79707. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79708. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79709. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79710. }
  79711. }
  79712. declare module BABYLON.GLTF1 {
  79713. /** @hidden */
  79714. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79715. constructor();
  79716. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79717. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79718. private _loadTexture;
  79719. }
  79720. }
  79721. declare module BABYLON.GLTF2.Loader {
  79722. /**
  79723. * Loader interface with an index field.
  79724. */
  79725. export interface IArrayItem {
  79726. /**
  79727. * The index of this item in the array.
  79728. */
  79729. index: number;
  79730. }
  79731. /**
  79732. * Loader interface with additional members.
  79733. */
  79734. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79735. /** @hidden */
  79736. _data?: Promise<ArrayBufferView>;
  79737. /** @hidden */
  79738. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79739. }
  79740. /**
  79741. * Loader interface with additional members.
  79742. */
  79743. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79744. }
  79745. /** @hidden */
  79746. export interface _IAnimationSamplerData {
  79747. input: Float32Array;
  79748. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79749. output: Float32Array;
  79750. }
  79751. /**
  79752. * Loader interface with additional members.
  79753. */
  79754. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79755. /** @hidden */
  79756. _data?: Promise<_IAnimationSamplerData>;
  79757. }
  79758. /**
  79759. * Loader interface with additional members.
  79760. */
  79761. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79762. channels: IAnimationChannel[];
  79763. samplers: IAnimationSampler[];
  79764. /** @hidden */
  79765. _babylonAnimationGroup?: AnimationGroup;
  79766. }
  79767. /**
  79768. * Loader interface with additional members.
  79769. */
  79770. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79771. /** @hidden */
  79772. _data?: Promise<ArrayBufferView>;
  79773. }
  79774. /**
  79775. * Loader interface with additional members.
  79776. */
  79777. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79778. /** @hidden */
  79779. _data?: Promise<ArrayBufferView>;
  79780. /** @hidden */
  79781. _babylonBuffer?: Promise<Buffer>;
  79782. }
  79783. /**
  79784. * Loader interface with additional members.
  79785. */
  79786. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79787. }
  79788. /**
  79789. * Loader interface with additional members.
  79790. */
  79791. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79792. /** @hidden */
  79793. _data?: Promise<ArrayBufferView>;
  79794. }
  79795. /**
  79796. * Loader interface with additional members.
  79797. */
  79798. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79799. }
  79800. /**
  79801. * Loader interface with additional members.
  79802. */
  79803. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79804. }
  79805. /**
  79806. * Loader interface with additional members.
  79807. */
  79808. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79809. baseColorTexture?: ITextureInfo;
  79810. metallicRoughnessTexture?: ITextureInfo;
  79811. }
  79812. /**
  79813. * Loader interface with additional members.
  79814. */
  79815. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79816. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79817. normalTexture?: IMaterialNormalTextureInfo;
  79818. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79819. emissiveTexture?: ITextureInfo;
  79820. /** @hidden */
  79821. _data?: {
  79822. [babylonDrawMode: number]: {
  79823. babylonMaterial: Material;
  79824. babylonMeshes: AbstractMesh[];
  79825. promise: Promise<void>;
  79826. };
  79827. };
  79828. }
  79829. /**
  79830. * Loader interface with additional members.
  79831. */
  79832. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79833. primitives: IMeshPrimitive[];
  79834. }
  79835. /**
  79836. * Loader interface with additional members.
  79837. */
  79838. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79839. /** @hidden */
  79840. _instanceData?: {
  79841. babylonSourceMesh: Mesh;
  79842. promise: Promise<any>;
  79843. };
  79844. }
  79845. /**
  79846. * Loader interface with additional members.
  79847. */
  79848. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79849. /**
  79850. * The parent glTF node.
  79851. */
  79852. parent?: INode;
  79853. /** @hidden */
  79854. _babylonTransformNode?: TransformNode;
  79855. /** @hidden */
  79856. _primitiveBabylonMeshes?: AbstractMesh[];
  79857. /** @hidden */
  79858. _babylonBones?: Bone[];
  79859. /** @hidden */
  79860. _numMorphTargets?: number;
  79861. }
  79862. /** @hidden */
  79863. export interface _ISamplerData {
  79864. noMipMaps: boolean;
  79865. samplingMode: number;
  79866. wrapU: number;
  79867. wrapV: number;
  79868. }
  79869. /**
  79870. * Loader interface with additional members.
  79871. */
  79872. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79873. /** @hidden */
  79874. _data?: _ISamplerData;
  79875. }
  79876. /**
  79877. * Loader interface with additional members.
  79878. */
  79879. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79880. }
  79881. /**
  79882. * Loader interface with additional members.
  79883. */
  79884. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79885. /** @hidden */
  79886. _data?: {
  79887. babylonSkeleton: Skeleton;
  79888. promise: Promise<void>;
  79889. };
  79890. }
  79891. /**
  79892. * Loader interface with additional members.
  79893. */
  79894. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79895. }
  79896. /**
  79897. * Loader interface with additional members.
  79898. */
  79899. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79900. }
  79901. /**
  79902. * Loader interface with additional members.
  79903. */
  79904. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79905. accessors?: IAccessor[];
  79906. animations?: IAnimation[];
  79907. buffers?: IBuffer[];
  79908. bufferViews?: IBufferView[];
  79909. cameras?: ICamera[];
  79910. images?: IImage[];
  79911. materials?: IMaterial[];
  79912. meshes?: IMesh[];
  79913. nodes?: INode[];
  79914. samplers?: ISampler[];
  79915. scenes?: IScene[];
  79916. skins?: ISkin[];
  79917. textures?: ITexture[];
  79918. }
  79919. }
  79920. declare module BABYLON.GLTF2 {
  79921. /**
  79922. * Interface for a glTF loader extension.
  79923. */
  79924. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79925. /**
  79926. * Called after the loader state changes to LOADING.
  79927. */
  79928. onLoading?(): void;
  79929. /**
  79930. * Called after the loader state changes to READY.
  79931. */
  79932. onReady?(): void;
  79933. /**
  79934. * Define this method to modify the default behavior when loading scenes.
  79935. * @param context The context when loading the asset
  79936. * @param scene The glTF scene property
  79937. * @returns A promise that resolves when the load is complete or null if not handled
  79938. */
  79939. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79940. /**
  79941. * Define this method to modify the default behavior when loading nodes.
  79942. * @param context The context when loading the asset
  79943. * @param node The glTF node property
  79944. * @param assign A function called synchronously after parsing the glTF properties
  79945. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79946. */
  79947. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79948. /**
  79949. * Define this method to modify the default behavior when loading cameras.
  79950. * @param context The context when loading the asset
  79951. * @param camera The glTF camera property
  79952. * @param assign A function called synchronously after parsing the glTF properties
  79953. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79954. */
  79955. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79956. /**
  79957. * @hidden
  79958. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79959. * @param context The context when loading the asset
  79960. * @param primitive The glTF mesh primitive property
  79961. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79962. */
  79963. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79964. /**
  79965. * @hidden
  79966. * Define this method to modify the default behavior when loading data for mesh primitives.
  79967. * @param context The context when loading the asset
  79968. * @param name The mesh name when loading the asset
  79969. * @param node The glTF node when loading the asset
  79970. * @param mesh The glTF mesh when loading the asset
  79971. * @param primitive The glTF mesh primitive property
  79972. * @param assign A function called synchronously after parsing the glTF properties
  79973. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79974. */
  79975. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79976. /**
  79977. * @hidden
  79978. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79979. * @param context The context when loading the asset
  79980. * @param material The glTF material property
  79981. * @param assign A function called synchronously after parsing the glTF properties
  79982. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79983. */
  79984. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79985. /**
  79986. * Define this method to modify the default behavior when creating materials.
  79987. * @param context The context when loading the asset
  79988. * @param material The glTF material property
  79989. * @param babylonDrawMode The draw mode for the Babylon material
  79990. * @returns The Babylon material or null if not handled
  79991. */
  79992. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79993. /**
  79994. * Define this method to modify the default behavior when loading material properties.
  79995. * @param context The context when loading the asset
  79996. * @param material The glTF material property
  79997. * @param babylonMaterial The Babylon material
  79998. * @returns A promise that resolves when the load is complete or null if not handled
  79999. */
  80000. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80001. /**
  80002. * Define this method to modify the default behavior when loading texture infos.
  80003. * @param context The context when loading the asset
  80004. * @param textureInfo The glTF texture info property
  80005. * @param assign A function called synchronously after parsing the glTF properties
  80006. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80007. */
  80008. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80009. /**
  80010. * @hidden
  80011. * Define this method to modify the default behavior when loading textures.
  80012. * @param context The context when loading the asset
  80013. * @param texture The glTF texture property
  80014. * @param assign A function called synchronously after parsing the glTF properties
  80015. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80016. */
  80017. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80018. /**
  80019. * Define this method to modify the default behavior when loading animations.
  80020. * @param context The context when loading the asset
  80021. * @param animation The glTF animation property
  80022. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80023. */
  80024. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80025. /**
  80026. * @hidden
  80027. * Define this method to modify the default behavior when loading skins.
  80028. * @param context The context when loading the asset
  80029. * @param node The glTF node property
  80030. * @param skin The glTF skin property
  80031. * @returns A promise that resolves when the load is complete or null if not handled
  80032. */
  80033. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80034. /**
  80035. * @hidden
  80036. * Define this method to modify the default behavior when loading uris.
  80037. * @param context The context when loading the asset
  80038. * @param property The glTF property associated with the uri
  80039. * @param uri The uri to load
  80040. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80041. */
  80042. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80043. /**
  80044. * Define this method to modify the default behavior when loading buffer views.
  80045. * @param context The context when loading the asset
  80046. * @param bufferView The glTF buffer view property
  80047. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80048. */
  80049. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80050. /**
  80051. * Define this method to modify the default behavior when loading buffers.
  80052. * @param context The context when loading the asset
  80053. * @param buffer The glTF buffer property
  80054. * @param byteOffset The byte offset to load
  80055. * @param byteLength The byte length to load
  80056. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80057. */
  80058. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80059. }
  80060. }
  80061. declare module BABYLON.GLTF2 {
  80062. /**
  80063. * Helper class for working with arrays when loading the glTF asset
  80064. */
  80065. export class ArrayItem {
  80066. /**
  80067. * Gets an item from the given array.
  80068. * @param context The context when loading the asset
  80069. * @param array The array to get the item from
  80070. * @param index The index to the array
  80071. * @returns The array item
  80072. */
  80073. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80074. /**
  80075. * Assign an `index` field to each item of the given array.
  80076. * @param array The array of items
  80077. */
  80078. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80079. }
  80080. /**
  80081. * The glTF 2.0 loader
  80082. */
  80083. export class GLTFLoader implements IGLTFLoader {
  80084. /** @hidden */
  80085. _completePromises: Promise<any>[];
  80086. /** @hidden */
  80087. _forAssetContainer: boolean;
  80088. /** Storage */
  80089. _babylonLights: Light[];
  80090. /** @hidden */
  80091. _disableInstancedMesh: number;
  80092. private _disposed;
  80093. private _parent;
  80094. private _state;
  80095. private _extensions;
  80096. private _rootUrl;
  80097. private _fileName;
  80098. private _uniqueRootUrl;
  80099. private _gltf;
  80100. private _bin;
  80101. private _babylonScene;
  80102. private _rootBabylonMesh;
  80103. private _defaultBabylonMaterialData;
  80104. private static _RegisteredExtensions;
  80105. /**
  80106. * The default glTF sampler.
  80107. */
  80108. static readonly DefaultSampler: ISampler;
  80109. /**
  80110. * Registers a loader extension.
  80111. * @param name The name of the loader extension.
  80112. * @param factory The factory function that creates the loader extension.
  80113. */
  80114. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80115. /**
  80116. * Unregisters a loader extension.
  80117. * @param name The name of the loader extension.
  80118. * @returns A boolean indicating whether the extension has been unregistered
  80119. */
  80120. static UnregisterExtension(name: string): boolean;
  80121. /**
  80122. * The loader state.
  80123. */
  80124. get state(): Nullable<GLTFLoaderState>;
  80125. /**
  80126. * The object that represents the glTF JSON.
  80127. */
  80128. get gltf(): IGLTF;
  80129. /**
  80130. * The BIN chunk of a binary glTF.
  80131. */
  80132. get bin(): Nullable<IDataBuffer>;
  80133. /**
  80134. * The parent file loader.
  80135. */
  80136. get parent(): GLTFFileLoader;
  80137. /**
  80138. * The Babylon scene when loading the asset.
  80139. */
  80140. get babylonScene(): Scene;
  80141. /**
  80142. * The root Babylon mesh when loading the asset.
  80143. */
  80144. get rootBabylonMesh(): Mesh;
  80145. /** @hidden */
  80146. constructor(parent: GLTFFileLoader);
  80147. /** @hidden */
  80148. dispose(): void;
  80149. /** @hidden */
  80150. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80151. /** @hidden */
  80152. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80153. private _loadAsync;
  80154. private _loadData;
  80155. private _setupData;
  80156. private _loadExtensions;
  80157. private _checkExtensions;
  80158. private _setState;
  80159. private _createRootNode;
  80160. /**
  80161. * Loads a glTF scene.
  80162. * @param context The context when loading the asset
  80163. * @param scene The glTF scene property
  80164. * @returns A promise that resolves when the load is complete
  80165. */
  80166. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80167. private _forEachPrimitive;
  80168. private _getMeshes;
  80169. private _getTransformNodes;
  80170. private _getSkeletons;
  80171. private _getAnimationGroups;
  80172. private _startAnimations;
  80173. /**
  80174. * Loads a glTF node.
  80175. * @param context The context when loading the asset
  80176. * @param node The glTF node property
  80177. * @param assign A function called synchronously after parsing the glTF properties
  80178. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80179. */
  80180. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80181. private _loadMeshAsync;
  80182. /**
  80183. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80184. * @param context The context when loading the asset
  80185. * @param name The mesh name when loading the asset
  80186. * @param node The glTF node when loading the asset
  80187. * @param mesh The glTF mesh when loading the asset
  80188. * @param primitive The glTF mesh primitive property
  80189. * @param assign A function called synchronously after parsing the glTF properties
  80190. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80191. */
  80192. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80193. private _loadVertexDataAsync;
  80194. private _createMorphTargets;
  80195. private _loadMorphTargetsAsync;
  80196. private _loadMorphTargetVertexDataAsync;
  80197. private static _LoadTransform;
  80198. private _loadSkinAsync;
  80199. private _loadBones;
  80200. private _loadBone;
  80201. private _loadSkinInverseBindMatricesDataAsync;
  80202. private _updateBoneMatrices;
  80203. private _getNodeMatrix;
  80204. /**
  80205. * Loads a glTF camera.
  80206. * @param context The context when loading the asset
  80207. * @param camera The glTF camera property
  80208. * @param assign A function called synchronously after parsing the glTF properties
  80209. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80210. */
  80211. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80212. private _loadAnimationsAsync;
  80213. /**
  80214. * Loads a glTF animation.
  80215. * @param context The context when loading the asset
  80216. * @param animation The glTF animation property
  80217. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80218. */
  80219. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80220. /**
  80221. * @hidden Loads a glTF animation channel.
  80222. * @param context The context when loading the asset
  80223. * @param animationContext The context of the animation when loading the asset
  80224. * @param animation The glTF animation property
  80225. * @param channel The glTF animation channel property
  80226. * @param babylonAnimationGroup The babylon animation group property
  80227. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80228. * @returns A void promise when the channel load is complete
  80229. */
  80230. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80231. private _loadAnimationSamplerAsync;
  80232. private _loadBufferAsync;
  80233. /**
  80234. * Loads a glTF buffer view.
  80235. * @param context The context when loading the asset
  80236. * @param bufferView The glTF buffer view property
  80237. * @returns A promise that resolves with the loaded data when the load is complete
  80238. */
  80239. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80240. private _loadAccessorAsync;
  80241. /** @hidden */
  80242. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80243. private _loadIndicesAccessorAsync;
  80244. private _loadVertexBufferViewAsync;
  80245. private _loadVertexAccessorAsync;
  80246. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80247. /** @hidden */
  80248. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80249. private _createDefaultMaterial;
  80250. /**
  80251. * Creates a Babylon material from a glTF material.
  80252. * @param context The context when loading the asset
  80253. * @param material The glTF material property
  80254. * @param babylonDrawMode The draw mode for the Babylon material
  80255. * @returns The Babylon material
  80256. */
  80257. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80258. /**
  80259. * Loads properties from a glTF material into a Babylon material.
  80260. * @param context The context when loading the asset
  80261. * @param material The glTF material property
  80262. * @param babylonMaterial The Babylon material
  80263. * @returns A promise that resolves when the load is complete
  80264. */
  80265. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80266. /**
  80267. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80268. * @param context The context when loading the asset
  80269. * @param material The glTF material property
  80270. * @param babylonMaterial The Babylon material
  80271. * @returns A promise that resolves when the load is complete
  80272. */
  80273. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80274. /**
  80275. * Loads the alpha properties from a glTF material into a Babylon material.
  80276. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80277. * @param context The context when loading the asset
  80278. * @param material The glTF material property
  80279. * @param babylonMaterial The Babylon material
  80280. */
  80281. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80282. /**
  80283. * Loads a glTF texture info.
  80284. * @param context The context when loading the asset
  80285. * @param textureInfo The glTF texture info property
  80286. * @param assign A function called synchronously after parsing the glTF properties
  80287. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80288. */
  80289. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80290. /** @hidden */
  80291. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80292. /** @hidden */
  80293. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80294. private _loadSampler;
  80295. /**
  80296. * Loads a glTF image.
  80297. * @param context The context when loading the asset
  80298. * @param image The glTF image property
  80299. * @returns A promise that resolves with the loaded data when the load is complete
  80300. */
  80301. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80302. /**
  80303. * Loads a glTF uri.
  80304. * @param context The context when loading the asset
  80305. * @param property The glTF property associated with the uri
  80306. * @param uri The base64 or relative uri
  80307. * @returns A promise that resolves with the loaded data when the load is complete
  80308. */
  80309. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80310. /**
  80311. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80312. * @param babylonObject the Babylon object with metadata
  80313. * @param pointer the JSON pointer
  80314. */
  80315. static AddPointerMetadata(babylonObject: {
  80316. metadata: any;
  80317. }, pointer: string): void;
  80318. private static _GetTextureWrapMode;
  80319. private static _GetTextureSamplingMode;
  80320. private static _GetTypedArrayConstructor;
  80321. private static _GetTypedArray;
  80322. private static _GetNumComponents;
  80323. private static _ValidateUri;
  80324. /** @hidden */
  80325. static _GetDrawMode(context: string, mode: number | undefined): number;
  80326. private _compileMaterialsAsync;
  80327. private _compileShadowGeneratorsAsync;
  80328. private _forEachExtensions;
  80329. private _applyExtensions;
  80330. private _extensionsOnLoading;
  80331. private _extensionsOnReady;
  80332. private _extensionsLoadSceneAsync;
  80333. private _extensionsLoadNodeAsync;
  80334. private _extensionsLoadCameraAsync;
  80335. private _extensionsLoadVertexDataAsync;
  80336. private _extensionsLoadMeshPrimitiveAsync;
  80337. private _extensionsLoadMaterialAsync;
  80338. private _extensionsCreateMaterial;
  80339. private _extensionsLoadMaterialPropertiesAsync;
  80340. private _extensionsLoadTextureInfoAsync;
  80341. private _extensionsLoadTextureAsync;
  80342. private _extensionsLoadAnimationAsync;
  80343. private _extensionsLoadSkinAsync;
  80344. private _extensionsLoadUriAsync;
  80345. private _extensionsLoadBufferViewAsync;
  80346. private _extensionsLoadBufferAsync;
  80347. /**
  80348. * Helper method called by a loader extension to load an glTF extension.
  80349. * @param context The context when loading the asset
  80350. * @param property The glTF property to load the extension from
  80351. * @param extensionName The name of the extension to load
  80352. * @param actionAsync The action to run
  80353. * @returns The promise returned by actionAsync or null if the extension does not exist
  80354. */
  80355. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80356. /**
  80357. * Helper method called by a loader extension to load a glTF extra.
  80358. * @param context The context when loading the asset
  80359. * @param property The glTF property to load the extra from
  80360. * @param extensionName The name of the extension to load
  80361. * @param actionAsync The action to run
  80362. * @returns The promise returned by actionAsync or null if the extra does not exist
  80363. */
  80364. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80365. /**
  80366. * Checks for presence of an extension.
  80367. * @param name The name of the extension to check
  80368. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80369. */
  80370. isExtensionUsed(name: string): boolean;
  80371. /**
  80372. * Increments the indentation level and logs a message.
  80373. * @param message The message to log
  80374. */
  80375. logOpen(message: string): void;
  80376. /**
  80377. * Decrements the indentation level.
  80378. */
  80379. logClose(): void;
  80380. /**
  80381. * Logs a message
  80382. * @param message The message to log
  80383. */
  80384. log(message: string): void;
  80385. /**
  80386. * Starts a performance counter.
  80387. * @param counterName The name of the performance counter
  80388. */
  80389. startPerformanceCounter(counterName: string): void;
  80390. /**
  80391. * Ends a performance counter.
  80392. * @param counterName The name of the performance counter
  80393. */
  80394. endPerformanceCounter(counterName: string): void;
  80395. }
  80396. }
  80397. declare module BABYLON.GLTF2.Loader.Extensions {
  80398. /** @hidden */
  80399. interface IEXTLightsImageBased_LightImageBased {
  80400. _babylonTexture?: BaseTexture;
  80401. _loaded?: Promise<void>;
  80402. }
  80403. /**
  80404. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80405. */
  80406. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80407. /**
  80408. * The name of this extension.
  80409. */
  80410. readonly name: string;
  80411. /**
  80412. * Defines whether this extension is enabled.
  80413. */
  80414. enabled: boolean;
  80415. private _loader;
  80416. private _lights?;
  80417. /** @hidden */
  80418. constructor(loader: GLTFLoader);
  80419. /** @hidden */
  80420. dispose(): void;
  80421. /** @hidden */
  80422. onLoading(): void;
  80423. /** @hidden */
  80424. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80425. private _loadLightAsync;
  80426. }
  80427. }
  80428. declare module BABYLON.GLTF2.Loader.Extensions {
  80429. /**
  80430. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80431. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80432. * !!! Experimental Extension Subject to Changes !!!
  80433. */
  80434. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80435. /**
  80436. * The name of this extension.
  80437. */
  80438. readonly name: string;
  80439. /**
  80440. * Defines whether this extension is enabled.
  80441. */
  80442. enabled: boolean;
  80443. private _loader;
  80444. /** @hidden */
  80445. constructor(loader: GLTFLoader);
  80446. /** @hidden */
  80447. dispose(): void;
  80448. /** @hidden */
  80449. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80450. }
  80451. }
  80452. declare module BABYLON.GLTF2.Loader.Extensions {
  80453. /**
  80454. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80455. */
  80456. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80457. /**
  80458. * The name of this extension.
  80459. */
  80460. readonly name: string;
  80461. /**
  80462. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80463. */
  80464. dracoCompression?: DracoCompression;
  80465. /**
  80466. * Defines whether this extension is enabled.
  80467. */
  80468. enabled: boolean;
  80469. private _loader;
  80470. /** @hidden */
  80471. constructor(loader: GLTFLoader);
  80472. /** @hidden */
  80473. dispose(): void;
  80474. /** @hidden */
  80475. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80476. }
  80477. }
  80478. declare module BABYLON.GLTF2.Loader.Extensions {
  80479. /**
  80480. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80481. */
  80482. export class KHR_lights implements IGLTFLoaderExtension {
  80483. /**
  80484. * The name of this extension.
  80485. */
  80486. readonly name: string;
  80487. /**
  80488. * Defines whether this extension is enabled.
  80489. */
  80490. enabled: boolean;
  80491. private _loader;
  80492. private _lights?;
  80493. /** @hidden */
  80494. constructor(loader: GLTFLoader);
  80495. /** @hidden */
  80496. dispose(): void;
  80497. /** @hidden */
  80498. onLoading(): void;
  80499. /** @hidden */
  80500. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80501. }
  80502. }
  80503. declare module BABYLON.GLTF2.Loader.Extensions {
  80504. /**
  80505. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80506. */
  80507. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80508. /**
  80509. * The name of this extension.
  80510. */
  80511. readonly name: string;
  80512. /**
  80513. * Defines whether this extension is enabled.
  80514. */
  80515. enabled: boolean;
  80516. /**
  80517. * Defines a number that determines the order the extensions are applied.
  80518. */
  80519. order: number;
  80520. private _loader;
  80521. /** @hidden */
  80522. constructor(loader: GLTFLoader);
  80523. /** @hidden */
  80524. dispose(): void;
  80525. /** @hidden */
  80526. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80527. private _loadSpecularGlossinessPropertiesAsync;
  80528. }
  80529. }
  80530. declare module BABYLON.GLTF2.Loader.Extensions {
  80531. /**
  80532. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80533. */
  80534. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80535. /**
  80536. * The name of this extension.
  80537. */
  80538. readonly name: string;
  80539. /**
  80540. * Defines whether this extension is enabled.
  80541. */
  80542. enabled: boolean;
  80543. /**
  80544. * Defines a number that determines the order the extensions are applied.
  80545. */
  80546. order: number;
  80547. private _loader;
  80548. /** @hidden */
  80549. constructor(loader: GLTFLoader);
  80550. /** @hidden */
  80551. dispose(): void;
  80552. /** @hidden */
  80553. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80554. private _loadUnlitPropertiesAsync;
  80555. }
  80556. }
  80557. declare module BABYLON.GLTF2.Loader.Extensions {
  80558. /**
  80559. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80560. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80561. * !!! Experimental Extension Subject to Changes !!!
  80562. */
  80563. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80564. /**
  80565. * The name of this extension.
  80566. */
  80567. readonly name: string;
  80568. /**
  80569. * Defines whether this extension is enabled.
  80570. */
  80571. enabled: boolean;
  80572. /**
  80573. * Defines a number that determines the order the extensions are applied.
  80574. */
  80575. order: number;
  80576. private _loader;
  80577. /** @hidden */
  80578. constructor(loader: GLTFLoader);
  80579. /** @hidden */
  80580. dispose(): void;
  80581. /** @hidden */
  80582. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80583. private _loadClearCoatPropertiesAsync;
  80584. }
  80585. }
  80586. declare module BABYLON.GLTF2.Loader.Extensions {
  80587. /**
  80588. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80589. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80590. * !!! Experimental Extension Subject to Changes !!!
  80591. */
  80592. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80593. /**
  80594. * The name of this extension.
  80595. */
  80596. readonly name: string;
  80597. /**
  80598. * Defines whether this extension is enabled.
  80599. */
  80600. enabled: boolean;
  80601. /**
  80602. * Defines a number that determines the order the extensions are applied.
  80603. */
  80604. order: number;
  80605. private _loader;
  80606. /** @hidden */
  80607. constructor(loader: GLTFLoader);
  80608. /** @hidden */
  80609. dispose(): void;
  80610. /** @hidden */
  80611. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80612. private _loadSheenPropertiesAsync;
  80613. }
  80614. }
  80615. declare module BABYLON.GLTF2.Loader.Extensions {
  80616. /**
  80617. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80618. * !!! Experimental Extension Subject to Changes !!!
  80619. */
  80620. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80621. /**
  80622. * The name of this extension.
  80623. */
  80624. readonly name: string;
  80625. /**
  80626. * Defines whether this extension is enabled.
  80627. */
  80628. enabled: boolean;
  80629. /**
  80630. * Defines a number that determines the order the extensions are applied.
  80631. */
  80632. order: number;
  80633. private _loader;
  80634. /** @hidden */
  80635. constructor(loader: GLTFLoader);
  80636. /** @hidden */
  80637. dispose(): void;
  80638. /** @hidden */
  80639. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80640. private _loadSpecularPropertiesAsync;
  80641. }
  80642. }
  80643. declare module BABYLON.GLTF2.Loader.Extensions {
  80644. /**
  80645. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80646. * !!! Experimental Extension Subject to Changes !!!
  80647. */
  80648. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80649. /**
  80650. * Default ior Value from the spec.
  80651. */
  80652. private static readonly _DEFAULT_IOR;
  80653. /**
  80654. * The name of this extension.
  80655. */
  80656. readonly name: string;
  80657. /**
  80658. * Defines whether this extension is enabled.
  80659. */
  80660. enabled: boolean;
  80661. /**
  80662. * Defines a number that determines the order the extensions are applied.
  80663. */
  80664. order: number;
  80665. private _loader;
  80666. /** @hidden */
  80667. constructor(loader: GLTFLoader);
  80668. /** @hidden */
  80669. dispose(): void;
  80670. /** @hidden */
  80671. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80672. private _loadIorPropertiesAsync;
  80673. }
  80674. }
  80675. declare module BABYLON.GLTF2.Loader.Extensions {
  80676. /**
  80677. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80678. * !!! Experimental Extension Subject to Changes !!!
  80679. */
  80680. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80681. /**
  80682. * The name of this extension.
  80683. */
  80684. readonly name: string;
  80685. /**
  80686. * Defines whether this extension is enabled.
  80687. */
  80688. enabled: boolean;
  80689. private _loader;
  80690. /** @hidden */
  80691. constructor(loader: GLTFLoader);
  80692. /** @hidden */
  80693. dispose(): void;
  80694. /**
  80695. * Gets the list of available variant tag names for this asset.
  80696. * @param rootMesh The glTF root mesh
  80697. * @returns the list of all the variant names for this model
  80698. */
  80699. static GetAvailableVariants(rootMesh: Mesh): string[];
  80700. /**
  80701. * Select a variant given a variant tag name or a list of variant tag names.
  80702. * @param rootMesh The glTF root mesh
  80703. * @param variantName The variant name(s) to select.
  80704. */
  80705. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80706. /**
  80707. * Reset back to the original before selecting a variant.
  80708. * @param rootMesh The glTF root mesh
  80709. */
  80710. static Reset(rootMesh: Mesh): void;
  80711. /**
  80712. * Gets the last selected variant tag name(s) or null if original.
  80713. * @param rootMesh The glTF root mesh
  80714. * @returns The selected variant tag name(s).
  80715. */
  80716. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80717. private static _GetExtensionMetadata;
  80718. /** @hidden */
  80719. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80720. }
  80721. }
  80722. declare module BABYLON.GLTF2.Loader.Extensions {
  80723. /**
  80724. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80725. * !!! Experimental Extension Subject to Changes !!!
  80726. */
  80727. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80728. /**
  80729. * The name of this extension.
  80730. */
  80731. readonly name: string;
  80732. /**
  80733. * Defines whether this extension is enabled.
  80734. */
  80735. enabled: boolean;
  80736. /**
  80737. * Defines a number that determines the order the extensions are applied.
  80738. */
  80739. order: number;
  80740. private _loader;
  80741. /** @hidden */
  80742. constructor(loader: GLTFLoader);
  80743. /** @hidden */
  80744. dispose(): void;
  80745. /** @hidden */
  80746. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80747. private _loadTransparentPropertiesAsync;
  80748. }
  80749. }
  80750. declare module BABYLON.GLTF2.Loader.Extensions {
  80751. /**
  80752. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80753. */
  80754. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80755. /**
  80756. * The name of this extension.
  80757. */
  80758. readonly name: string;
  80759. /**
  80760. * Defines whether this extension is enabled.
  80761. */
  80762. enabled: boolean;
  80763. /** @hidden */
  80764. constructor(loader: GLTFLoader);
  80765. /** @hidden */
  80766. dispose(): void;
  80767. }
  80768. }
  80769. declare module BABYLON.GLTF2.Loader.Extensions {
  80770. /**
  80771. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80772. * !!! Experimental Extension Subject to Changes !!!
  80773. */
  80774. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80775. /** The name of this extension. */
  80776. readonly name: string;
  80777. /** Defines whether this extension is enabled. */
  80778. enabled: boolean;
  80779. private _loader;
  80780. /** @hidden */
  80781. constructor(loader: GLTFLoader);
  80782. /** @hidden */
  80783. dispose(): void;
  80784. /** @hidden */
  80785. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80786. }
  80787. }
  80788. declare module BABYLON.GLTF2.Loader.Extensions {
  80789. /**
  80790. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80791. */
  80792. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80793. /**
  80794. * The name of this extension.
  80795. */
  80796. readonly name: string;
  80797. /**
  80798. * Defines whether this extension is enabled.
  80799. */
  80800. enabled: boolean;
  80801. private _loader;
  80802. /** @hidden */
  80803. constructor(loader: GLTFLoader);
  80804. /** @hidden */
  80805. dispose(): void;
  80806. /** @hidden */
  80807. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80808. }
  80809. }
  80810. declare module BABYLON.GLTF2.Loader.Extensions {
  80811. /**
  80812. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80813. * !!! Experimental Extension Subject to Changes !!!
  80814. */
  80815. export class KHR_xmp implements IGLTFLoaderExtension {
  80816. /**
  80817. * The name of this extension.
  80818. */
  80819. readonly name: string;
  80820. /**
  80821. * Defines whether this extension is enabled.
  80822. */
  80823. enabled: boolean;
  80824. /**
  80825. * Defines a number that determines the order the extensions are applied.
  80826. */
  80827. order: number;
  80828. private _loader;
  80829. /** @hidden */
  80830. constructor(loader: GLTFLoader);
  80831. /** @hidden */
  80832. dispose(): void;
  80833. /**
  80834. * Called after the loader state changes to LOADING.
  80835. */
  80836. onLoading(): void;
  80837. }
  80838. }
  80839. declare module BABYLON.GLTF2.Loader.Extensions {
  80840. /**
  80841. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80842. */
  80843. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80844. /**
  80845. * The name of this extension.
  80846. */
  80847. readonly name: string;
  80848. /**
  80849. * Defines whether this extension is enabled.
  80850. */
  80851. enabled: boolean;
  80852. private _loader;
  80853. private _clips;
  80854. private _emitters;
  80855. /** @hidden */
  80856. constructor(loader: GLTFLoader);
  80857. /** @hidden */
  80858. dispose(): void;
  80859. /** @hidden */
  80860. onLoading(): void;
  80861. /** @hidden */
  80862. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80863. /** @hidden */
  80864. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80865. /** @hidden */
  80866. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80867. private _loadClipAsync;
  80868. private _loadEmitterAsync;
  80869. private _getEventAction;
  80870. private _loadAnimationEventAsync;
  80871. }
  80872. }
  80873. declare module BABYLON.GLTF2.Loader.Extensions {
  80874. /**
  80875. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80876. */
  80877. export class MSFT_lod implements IGLTFLoaderExtension {
  80878. /**
  80879. * The name of this extension.
  80880. */
  80881. readonly name: string;
  80882. /**
  80883. * Defines whether this extension is enabled.
  80884. */
  80885. enabled: boolean;
  80886. /**
  80887. * Defines a number that determines the order the extensions are applied.
  80888. */
  80889. order: number;
  80890. /**
  80891. * Maximum number of LODs to load, starting from the lowest LOD.
  80892. */
  80893. maxLODsToLoad: number;
  80894. /**
  80895. * Observable raised when all node LODs of one level are loaded.
  80896. * The event data is the index of the loaded LOD starting from zero.
  80897. * Dispose the loader to cancel the loading of the next level of LODs.
  80898. */
  80899. onNodeLODsLoadedObservable: Observable<number>;
  80900. /**
  80901. * Observable raised when all material LODs of one level are loaded.
  80902. * The event data is the index of the loaded LOD starting from zero.
  80903. * Dispose the loader to cancel the loading of the next level of LODs.
  80904. */
  80905. onMaterialLODsLoadedObservable: Observable<number>;
  80906. private _loader;
  80907. private _bufferLODs;
  80908. private _nodeIndexLOD;
  80909. private _nodeSignalLODs;
  80910. private _nodePromiseLODs;
  80911. private _nodeBufferLODs;
  80912. private _materialIndexLOD;
  80913. private _materialSignalLODs;
  80914. private _materialPromiseLODs;
  80915. private _materialBufferLODs;
  80916. /** @hidden */
  80917. constructor(loader: GLTFLoader);
  80918. /** @hidden */
  80919. dispose(): void;
  80920. /** @hidden */
  80921. onReady(): void;
  80922. /** @hidden */
  80923. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80924. /** @hidden */
  80925. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80926. /** @hidden */
  80927. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80928. /** @hidden */
  80929. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80930. /** @hidden */
  80931. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80932. private _loadBufferLOD;
  80933. /**
  80934. * Gets an array of LOD properties from lowest to highest.
  80935. */
  80936. private _getLODs;
  80937. private _disposeTransformNode;
  80938. private _disposeMaterials;
  80939. }
  80940. }
  80941. declare module BABYLON.GLTF2.Loader.Extensions {
  80942. /** @hidden */
  80943. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80944. readonly name: string;
  80945. enabled: boolean;
  80946. private _loader;
  80947. constructor(loader: GLTFLoader);
  80948. dispose(): void;
  80949. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80950. }
  80951. }
  80952. declare module BABYLON.GLTF2.Loader.Extensions {
  80953. /** @hidden */
  80954. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80955. readonly name: string;
  80956. enabled: boolean;
  80957. private _loader;
  80958. constructor(loader: GLTFLoader);
  80959. dispose(): void;
  80960. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80961. }
  80962. }
  80963. declare module BABYLON.GLTF2.Loader.Extensions {
  80964. /**
  80965. * Store glTF extras (if present) in BJS objects' metadata
  80966. */
  80967. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80968. /**
  80969. * The name of this extension.
  80970. */
  80971. readonly name: string;
  80972. /**
  80973. * Defines whether this extension is enabled.
  80974. */
  80975. enabled: boolean;
  80976. private _loader;
  80977. private _assignExtras;
  80978. /** @hidden */
  80979. constructor(loader: GLTFLoader);
  80980. /** @hidden */
  80981. dispose(): void;
  80982. /** @hidden */
  80983. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80984. /** @hidden */
  80985. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80986. /** @hidden */
  80987. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80988. }
  80989. }
  80990. declare module BABYLON {
  80991. /**
  80992. * Class reading and parsing the MTL file bundled with the obj file.
  80993. */
  80994. export class MTLFileLoader {
  80995. /**
  80996. * Invert Y-Axis of referenced textures on load
  80997. */
  80998. static INVERT_TEXTURE_Y: boolean;
  80999. /**
  81000. * All material loaded from the mtl will be set here
  81001. */
  81002. materials: StandardMaterial[];
  81003. /**
  81004. * This function will read the mtl file and create each material described inside
  81005. * This function could be improve by adding :
  81006. * -some component missing (Ni, Tf...)
  81007. * -including the specific options available
  81008. *
  81009. * @param scene defines the scene the material will be created in
  81010. * @param data defines the mtl data to parse
  81011. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81012. * @param forAssetContainer defines if the material should be registered in the scene
  81013. */
  81014. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81015. /**
  81016. * Gets the texture for the material.
  81017. *
  81018. * If the material is imported from input file,
  81019. * We sanitize the url to ensure it takes the textre from aside the material.
  81020. *
  81021. * @param rootUrl The root url to load from
  81022. * @param value The value stored in the mtl
  81023. * @return The Texture
  81024. */
  81025. private static _getTexture;
  81026. }
  81027. }
  81028. declare module BABYLON {
  81029. /**
  81030. * Options for loading OBJ/MTL files
  81031. */
  81032. type MeshLoadOptions = {
  81033. /**
  81034. * Defines if UVs are optimized by default during load.
  81035. */
  81036. OptimizeWithUV: boolean;
  81037. /**
  81038. * Defines custom scaling of UV coordinates of loaded meshes.
  81039. */
  81040. UVScaling: Vector2;
  81041. /**
  81042. * Invert model on y-axis (does a model scaling inversion)
  81043. */
  81044. InvertY: boolean;
  81045. /**
  81046. * Invert Y-Axis of referenced textures on load
  81047. */
  81048. InvertTextureY: boolean;
  81049. /**
  81050. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81051. */
  81052. ImportVertexColors: boolean;
  81053. /**
  81054. * Compute the normals for the model, even if normals are present in the file.
  81055. */
  81056. ComputeNormals: boolean;
  81057. /**
  81058. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81059. */
  81060. SkipMaterials: boolean;
  81061. /**
  81062. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81063. */
  81064. MaterialLoadingFailsSilently: boolean;
  81065. };
  81066. /**
  81067. * OBJ file type loader.
  81068. * This is a babylon scene loader plugin.
  81069. */
  81070. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81071. /**
  81072. * Defines if UVs are optimized by default during load.
  81073. */
  81074. static OPTIMIZE_WITH_UV: boolean;
  81075. /**
  81076. * Invert model on y-axis (does a model scaling inversion)
  81077. */
  81078. static INVERT_Y: boolean;
  81079. /**
  81080. * Invert Y-Axis of referenced textures on load
  81081. */
  81082. static get INVERT_TEXTURE_Y(): boolean;
  81083. static set INVERT_TEXTURE_Y(value: boolean);
  81084. /**
  81085. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81086. */
  81087. static IMPORT_VERTEX_COLORS: boolean;
  81088. /**
  81089. * Compute the normals for the model, even if normals are present in the file.
  81090. */
  81091. static COMPUTE_NORMALS: boolean;
  81092. /**
  81093. * Defines custom scaling of UV coordinates of loaded meshes.
  81094. */
  81095. static UV_SCALING: Vector2;
  81096. /**
  81097. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81098. */
  81099. static SKIP_MATERIALS: boolean;
  81100. /**
  81101. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81102. *
  81103. * Defaults to true for backwards compatibility.
  81104. */
  81105. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81106. /**
  81107. * Defines the name of the plugin.
  81108. */
  81109. name: string;
  81110. /**
  81111. * Defines the extension the plugin is able to load.
  81112. */
  81113. extensions: string;
  81114. /** @hidden */
  81115. obj: RegExp;
  81116. /** @hidden */
  81117. group: RegExp;
  81118. /** @hidden */
  81119. mtllib: RegExp;
  81120. /** @hidden */
  81121. usemtl: RegExp;
  81122. /** @hidden */
  81123. smooth: RegExp;
  81124. /** @hidden */
  81125. vertexPattern: RegExp;
  81126. /** @hidden */
  81127. normalPattern: RegExp;
  81128. /** @hidden */
  81129. uvPattern: RegExp;
  81130. /** @hidden */
  81131. facePattern1: RegExp;
  81132. /** @hidden */
  81133. facePattern2: RegExp;
  81134. /** @hidden */
  81135. facePattern3: RegExp;
  81136. /** @hidden */
  81137. facePattern4: RegExp;
  81138. /** @hidden */
  81139. facePattern5: RegExp;
  81140. private _forAssetContainer;
  81141. private _meshLoadOptions;
  81142. /**
  81143. * Creates loader for .OBJ files
  81144. *
  81145. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81146. */
  81147. constructor(meshLoadOptions?: MeshLoadOptions);
  81148. private static get currentMeshLoadOptions();
  81149. /**
  81150. * Calls synchronously the MTL file attached to this obj.
  81151. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81152. * Without this function materials are not displayed in the first frame (but displayed after).
  81153. * In consequence it is impossible to get material information in your HTML file
  81154. *
  81155. * @param url The URL of the MTL file
  81156. * @param rootUrl
  81157. * @param onSuccess Callback function to be called when the MTL file is loaded
  81158. * @private
  81159. */
  81160. private _loadMTL;
  81161. /**
  81162. * Instantiates a OBJ file loader plugin.
  81163. * @returns the created plugin
  81164. */
  81165. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81166. /**
  81167. * If the data string can be loaded directly.
  81168. *
  81169. * @param data string containing the file data
  81170. * @returns if the data can be loaded directly
  81171. */
  81172. canDirectLoad(data: string): boolean;
  81173. /**
  81174. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81175. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81176. * @param scene the scene the meshes should be added to
  81177. * @param data the OBJ data to load
  81178. * @param rootUrl root url to load from
  81179. * @param onProgress event that fires when loading progress has occured
  81180. * @param fileName Defines the name of the file to load
  81181. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81182. */
  81183. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81184. meshes: AbstractMesh[];
  81185. particleSystems: IParticleSystem[];
  81186. skeletons: Skeleton[];
  81187. animationGroups: AnimationGroup[];
  81188. }>;
  81189. /**
  81190. * Imports all objects from the loaded OBJ data and adds them to the scene
  81191. * @param scene the scene the objects should be added to
  81192. * @param data the OBJ data to load
  81193. * @param rootUrl root url to load from
  81194. * @param onProgress event that fires when loading progress has occured
  81195. * @param fileName Defines the name of the file to load
  81196. * @returns a promise which completes when objects have been loaded to the scene
  81197. */
  81198. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81199. /**
  81200. * Load into an asset container.
  81201. * @param scene The scene to load into
  81202. * @param data The data to import
  81203. * @param rootUrl The root url for scene and resources
  81204. * @param onProgress The callback when the load progresses
  81205. * @param fileName Defines the name of the file to load
  81206. * @returns The loaded asset container
  81207. */
  81208. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81209. /**
  81210. * Read the OBJ file and create an Array of meshes.
  81211. * Each mesh contains all information given by the OBJ and the MTL file.
  81212. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81213. *
  81214. * @param meshesNames
  81215. * @param scene Scene The scene where are displayed the data
  81216. * @param data String The content of the obj file
  81217. * @param rootUrl String The path to the folder
  81218. * @returns Array<AbstractMesh>
  81219. * @private
  81220. */
  81221. private _parseSolid;
  81222. }
  81223. }
  81224. declare module BABYLON {
  81225. /**
  81226. * STL file type loader.
  81227. * This is a babylon scene loader plugin.
  81228. */
  81229. export class STLFileLoader implements ISceneLoaderPlugin {
  81230. /** @hidden */
  81231. solidPattern: RegExp;
  81232. /** @hidden */
  81233. facetsPattern: RegExp;
  81234. /** @hidden */
  81235. normalPattern: RegExp;
  81236. /** @hidden */
  81237. vertexPattern: RegExp;
  81238. /**
  81239. * Defines the name of the plugin.
  81240. */
  81241. name: string;
  81242. /**
  81243. * Defines the extensions the stl loader is able to load.
  81244. * force data to come in as an ArrayBuffer
  81245. * we'll convert to string if it looks like it's an ASCII .stl
  81246. */
  81247. extensions: ISceneLoaderPluginExtensions;
  81248. /**
  81249. * Import meshes into a scene.
  81250. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81251. * @param scene The scene to import into
  81252. * @param data The data to import
  81253. * @param rootUrl The root url for scene and resources
  81254. * @param meshes The meshes array to import into
  81255. * @param particleSystems The particle systems array to import into
  81256. * @param skeletons The skeletons array to import into
  81257. * @param onError The callback when import fails
  81258. * @returns True if successful or false otherwise
  81259. */
  81260. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81261. /**
  81262. * Load into a scene.
  81263. * @param scene The scene to load into
  81264. * @param data The data to import
  81265. * @param rootUrl The root url for scene and resources
  81266. * @param onError The callback when import fails
  81267. * @returns true if successful or false otherwise
  81268. */
  81269. load(scene: Scene, data: any, rootUrl: string): boolean;
  81270. /**
  81271. * Load into an asset container.
  81272. * @param scene The scene to load into
  81273. * @param data The data to import
  81274. * @param rootUrl The root url for scene and resources
  81275. * @param onError The callback when import fails
  81276. * @returns The loaded asset container
  81277. */
  81278. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81279. private _isBinary;
  81280. private _parseBinary;
  81281. private _parseASCII;
  81282. }
  81283. }
  81284. declare module BABYLON {
  81285. /**
  81286. * Class for generating OBJ data from a Babylon scene.
  81287. */
  81288. export class OBJExport {
  81289. /**
  81290. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81291. * @param mesh defines the list of meshes to serialize
  81292. * @param materials defines if materials should be exported
  81293. * @param matlibname defines the name of the associated mtl file
  81294. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81295. * @returns the OBJ content
  81296. */
  81297. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81298. /**
  81299. * Exports the material(s) of a mesh in .MTL file format (text)
  81300. * @param mesh defines the mesh to extract the material from
  81301. * @returns the mtl content
  81302. */
  81303. static MTL(mesh: Mesh): string;
  81304. }
  81305. }
  81306. declare module BABYLON {
  81307. /** @hidden */
  81308. export var __IGLTFExporterExtension: number;
  81309. /**
  81310. * Interface for extending the exporter
  81311. * @hidden
  81312. */
  81313. export interface IGLTFExporterExtension {
  81314. /**
  81315. * The name of this extension
  81316. */
  81317. readonly name: string;
  81318. /**
  81319. * Defines whether this extension is enabled
  81320. */
  81321. enabled: boolean;
  81322. /**
  81323. * Defines whether this extension is required
  81324. */
  81325. required: boolean;
  81326. }
  81327. }
  81328. declare module BABYLON.GLTF2.Exporter {
  81329. /** @hidden */
  81330. export var __IGLTFExporterExtensionV2: number;
  81331. /**
  81332. * Interface for a glTF exporter extension
  81333. * @hidden
  81334. */
  81335. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81336. /**
  81337. * Define this method to modify the default behavior before exporting a texture
  81338. * @param context The context when loading the asset
  81339. * @param babylonTexture The Babylon.js texture
  81340. * @param mimeType The mime-type of the generated image
  81341. * @returns A promise that resolves with the exported texture
  81342. */
  81343. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81344. /**
  81345. * Define this method to get notified when a texture info is created
  81346. * @param context The context when loading the asset
  81347. * @param textureInfo The glTF texture info
  81348. * @param babylonTexture The Babylon.js texture
  81349. */
  81350. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81351. /**
  81352. * Define this method to modify the default behavior when exporting texture info
  81353. * @param context The context when loading the asset
  81354. * @param meshPrimitive glTF mesh primitive
  81355. * @param babylonSubMesh Babylon submesh
  81356. * @param binaryWriter glTF serializer binary writer instance
  81357. * @returns nullable IMeshPrimitive promise
  81358. */
  81359. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81360. /**
  81361. * Define this method to modify the default behavior when exporting a node
  81362. * @param context The context when exporting the node
  81363. * @param node glTF node
  81364. * @param babylonNode BabylonJS node
  81365. * @returns nullable INode promise
  81366. */
  81367. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81368. [key: number]: number;
  81369. }): Promise<Nullable<INode>>;
  81370. /**
  81371. * Define this method to modify the default behavior when exporting a material
  81372. * @param material glTF material
  81373. * @param babylonMaterial BabylonJS material
  81374. * @returns nullable IMaterial promise
  81375. */
  81376. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81377. /**
  81378. * Define this method to return additional textures to export from a material
  81379. * @param material glTF material
  81380. * @param babylonMaterial BabylonJS material
  81381. * @returns List of textures
  81382. */
  81383. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81384. /** Gets a boolean indicating that this extension was used */
  81385. wasUsed: boolean;
  81386. /** Gets a boolean indicating that this extension is required for the file to work */
  81387. required: boolean;
  81388. /**
  81389. * Called after the exporter state changes to EXPORTING
  81390. */
  81391. onExporting?(): void;
  81392. }
  81393. }
  81394. declare module BABYLON.GLTF2.Exporter {
  81395. /**
  81396. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81397. * @hidden
  81398. */
  81399. export class _GLTFMaterialExporter {
  81400. /**
  81401. * Represents the dielectric specular values for R, G and B
  81402. */
  81403. private static readonly _DielectricSpecular;
  81404. /**
  81405. * Allows the maximum specular power to be defined for material calculations
  81406. */
  81407. private static readonly _MaxSpecularPower;
  81408. /**
  81409. * Mapping to store textures
  81410. */
  81411. private _textureMap;
  81412. /**
  81413. * Numeric tolerance value
  81414. */
  81415. private static readonly _Epsilon;
  81416. /**
  81417. * Reference to the glTF Exporter
  81418. */
  81419. private _exporter;
  81420. constructor(exporter: _Exporter);
  81421. /**
  81422. * Specifies if two colors are approximately equal in value
  81423. * @param color1 first color to compare to
  81424. * @param color2 second color to compare to
  81425. * @param epsilon threshold value
  81426. */
  81427. private static FuzzyEquals;
  81428. /**
  81429. * Gets the materials from a Babylon scene and converts them to glTF materials
  81430. * @param scene babylonjs scene
  81431. * @param mimeType texture mime type
  81432. * @param images array of images
  81433. * @param textures array of textures
  81434. * @param materials array of materials
  81435. * @param imageData mapping of texture names to base64 textures
  81436. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81437. */
  81438. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81439. /**
  81440. * Makes a copy of the glTF material without the texture parameters
  81441. * @param originalMaterial original glTF material
  81442. * @returns glTF material without texture parameters
  81443. */
  81444. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81445. /**
  81446. * Specifies if the material has any texture parameters present
  81447. * @param material glTF Material
  81448. * @returns boolean specifying if texture parameters are present
  81449. */
  81450. _hasTexturesPresent(material: IMaterial): boolean;
  81451. /**
  81452. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81453. * @param babylonStandardMaterial
  81454. * @returns glTF Metallic Roughness Material representation
  81455. */
  81456. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81457. /**
  81458. * Computes the metallic factor
  81459. * @param diffuse diffused value
  81460. * @param specular specular value
  81461. * @param oneMinusSpecularStrength one minus the specular strength
  81462. * @returns metallic value
  81463. */
  81464. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81465. /**
  81466. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81467. * @param glTFMaterial glTF material
  81468. * @param babylonMaterial Babylon material
  81469. */
  81470. private static _SetAlphaMode;
  81471. /**
  81472. * Converts a Babylon Standard Material to a glTF Material
  81473. * @param babylonStandardMaterial BJS Standard Material
  81474. * @param mimeType mime type to use for the textures
  81475. * @param images array of glTF image interfaces
  81476. * @param textures array of glTF texture interfaces
  81477. * @param materials array of glTF material interfaces
  81478. * @param imageData map of image file name to data
  81479. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81480. */
  81481. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81482. private _finishMaterial;
  81483. /**
  81484. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81485. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81486. * @param mimeType mime type to use for the textures
  81487. * @param images array of glTF image interfaces
  81488. * @param textures array of glTF texture interfaces
  81489. * @param materials array of glTF material interfaces
  81490. * @param imageData map of image file name to data
  81491. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81492. */
  81493. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81494. /**
  81495. * Converts an image typed array buffer to a base64 image
  81496. * @param buffer typed array buffer
  81497. * @param width width of the image
  81498. * @param height height of the image
  81499. * @param mimeType mimetype of the image
  81500. * @returns base64 image string
  81501. */
  81502. private _createBase64FromCanvasAsync;
  81503. /**
  81504. * Generates a white texture based on the specified width and height
  81505. * @param width width of the texture in pixels
  81506. * @param height height of the texture in pixels
  81507. * @param scene babylonjs scene
  81508. * @returns white texture
  81509. */
  81510. private _createWhiteTexture;
  81511. /**
  81512. * 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
  81513. * @param texture1 first texture to resize
  81514. * @param texture2 second texture to resize
  81515. * @param scene babylonjs scene
  81516. * @returns resized textures or null
  81517. */
  81518. private _resizeTexturesToSameDimensions;
  81519. /**
  81520. * Converts an array of pixels to a Float32Array
  81521. * Throws an error if the pixel format is not supported
  81522. * @param pixels - array buffer containing pixel values
  81523. * @returns Float32 of pixels
  81524. */
  81525. private _convertPixelArrayToFloat32;
  81526. /**
  81527. * Convert Specular Glossiness Textures to Metallic Roughness
  81528. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81529. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81530. * @param diffuseTexture texture used to store diffuse information
  81531. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81532. * @param factors specular glossiness material factors
  81533. * @param mimeType the mime type to use for the texture
  81534. * @returns pbr metallic roughness interface or null
  81535. */
  81536. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81537. /**
  81538. * Converts specular glossiness material properties to metallic roughness
  81539. * @param specularGlossiness interface with specular glossiness material properties
  81540. * @returns interface with metallic roughness material properties
  81541. */
  81542. private _convertSpecularGlossinessToMetallicRoughness;
  81543. /**
  81544. * Calculates the surface reflectance, independent of lighting conditions
  81545. * @param color Color source to calculate brightness from
  81546. * @returns number representing the perceived brightness, or zero if color is undefined
  81547. */
  81548. private _getPerceivedBrightness;
  81549. /**
  81550. * Returns the maximum color component value
  81551. * @param color
  81552. * @returns maximum color component value, or zero if color is null or undefined
  81553. */
  81554. private _getMaxComponent;
  81555. /**
  81556. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81557. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81558. * @param mimeType mime type to use for the textures
  81559. * @param images array of glTF image interfaces
  81560. * @param textures array of glTF texture interfaces
  81561. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81562. * @param imageData map of image file name to data
  81563. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81564. * @returns glTF PBR Metallic Roughness factors
  81565. */
  81566. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81567. private _getGLTFTextureSampler;
  81568. private _getGLTFTextureWrapMode;
  81569. private _getGLTFTextureWrapModesSampler;
  81570. /**
  81571. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81572. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81573. * @param mimeType mime type to use for the textures
  81574. * @param images array of glTF image interfaces
  81575. * @param textures array of glTF texture interfaces
  81576. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81577. * @param imageData map of image file name to data
  81578. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81579. * @returns glTF PBR Metallic Roughness factors
  81580. */
  81581. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81582. /**
  81583. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81584. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81585. * @param mimeType mime type to use for the textures
  81586. * @param images array of glTF image interfaces
  81587. * @param textures array of glTF texture interfaces
  81588. * @param materials array of glTF material interfaces
  81589. * @param imageData map of image file name to data
  81590. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81591. */
  81592. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81593. private setMetallicRoughnessPbrMaterial;
  81594. private getPixelsFromTexture;
  81595. /**
  81596. * Extracts a texture from a Babylon texture into file data and glTF data
  81597. * @param babylonTexture Babylon texture to extract
  81598. * @param mimeType Mime Type of the babylonTexture
  81599. * @return glTF texture info, or null if the texture format is not supported
  81600. */
  81601. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81602. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81603. /**
  81604. * Builds a texture from base64 string
  81605. * @param base64Texture base64 texture string
  81606. * @param baseTextureName Name to use for the texture
  81607. * @param mimeType image mime type for the texture
  81608. * @param images array of images
  81609. * @param textures array of textures
  81610. * @param imageData map of image data
  81611. * @returns glTF texture info, or null if the texture format is not supported
  81612. */
  81613. private _getTextureInfoFromBase64;
  81614. }
  81615. }
  81616. declare module BABYLON {
  81617. /**
  81618. * Class for holding and downloading glTF file data
  81619. */
  81620. export class GLTFData {
  81621. /**
  81622. * Object which contains the file name as the key and its data as the value
  81623. */
  81624. glTFFiles: {
  81625. [fileName: string]: string | Blob;
  81626. };
  81627. /**
  81628. * Initializes the glTF file object
  81629. */
  81630. constructor();
  81631. /**
  81632. * Downloads the glTF data as files based on their names and data
  81633. */
  81634. downloadFiles(): void;
  81635. }
  81636. }
  81637. declare module BABYLON {
  81638. /**
  81639. * Holds a collection of exporter options and parameters
  81640. */
  81641. export interface IExportOptions {
  81642. /**
  81643. * Function which indicates whether a babylon node should be exported or not
  81644. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81645. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81646. */
  81647. shouldExportNode?(node: Node): boolean;
  81648. /**
  81649. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81650. * @param metadata source metadata to read from
  81651. * @returns the data to store to glTF node extras
  81652. */
  81653. metadataSelector?(metadata: any): any;
  81654. /**
  81655. * The sample rate to bake animation curves
  81656. */
  81657. animationSampleRate?: number;
  81658. /**
  81659. * Begin serialization without waiting for the scene to be ready
  81660. */
  81661. exportWithoutWaitingForScene?: boolean;
  81662. /**
  81663. * Indicates if coordinate system swapping root nodes should be included in export
  81664. */
  81665. includeCoordinateSystemConversionNodes?: boolean;
  81666. }
  81667. /**
  81668. * Class for generating glTF data from a Babylon scene.
  81669. */
  81670. export class GLTF2Export {
  81671. /**
  81672. * Exports the geometry of the scene to .gltf file format asynchronously
  81673. * @param scene Babylon scene with scene hierarchy information
  81674. * @param filePrefix File prefix to use when generating the glTF file
  81675. * @param options Exporter options
  81676. * @returns Returns an object with a .gltf file and associates texture names
  81677. * as keys and their data and paths as values
  81678. */
  81679. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81680. private static _PreExportAsync;
  81681. private static _PostExportAsync;
  81682. /**
  81683. * Exports the geometry of the scene to .glb file format asychronously
  81684. * @param scene Babylon scene with scene hierarchy information
  81685. * @param filePrefix File prefix to use when generating glb file
  81686. * @param options Exporter options
  81687. * @returns Returns an object with a .glb filename as key and data as value
  81688. */
  81689. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81690. }
  81691. }
  81692. declare module BABYLON.GLTF2.Exporter {
  81693. /**
  81694. * @hidden
  81695. */
  81696. export class _GLTFUtilities {
  81697. /**
  81698. * Creates a buffer view based on the supplied arguments
  81699. * @param bufferIndex index value of the specified buffer
  81700. * @param byteOffset byte offset value
  81701. * @param byteLength byte length of the bufferView
  81702. * @param byteStride byte distance between conequential elements
  81703. * @param name name of the buffer view
  81704. * @returns bufferView for glTF
  81705. */
  81706. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81707. /**
  81708. * Creates an accessor based on the supplied arguments
  81709. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81710. * @param name The name of the accessor
  81711. * @param type The type of the accessor
  81712. * @param componentType The datatype of components in the attribute
  81713. * @param count The number of attributes referenced by this accessor
  81714. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81715. * @param min Minimum value of each component in this attribute
  81716. * @param max Maximum value of each component in this attribute
  81717. * @returns accessor for glTF
  81718. */
  81719. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81720. /**
  81721. * Calculates the minimum and maximum values of an array of position floats
  81722. * @param positions Positions array of a mesh
  81723. * @param vertexStart Starting vertex offset to calculate min and max values
  81724. * @param vertexCount Number of vertices to check for min and max values
  81725. * @returns min number array and max number array
  81726. */
  81727. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81728. min: number[];
  81729. max: number[];
  81730. };
  81731. /**
  81732. * Converts a new right-handed Vector3
  81733. * @param vector vector3 array
  81734. * @returns right-handed Vector3
  81735. */
  81736. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81737. /**
  81738. * Converts a Vector3 to right-handed
  81739. * @param vector Vector3 to convert to right-handed
  81740. */
  81741. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81742. /**
  81743. * Converts a three element number array to right-handed
  81744. * @param vector number array to convert to right-handed
  81745. */
  81746. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81747. /**
  81748. * Converts a new right-handed Vector3
  81749. * @param vector vector3 array
  81750. * @returns right-handed Vector3
  81751. */
  81752. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81753. /**
  81754. * Converts a Vector3 to right-handed
  81755. * @param vector Vector3 to convert to right-handed
  81756. */
  81757. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81758. /**
  81759. * Converts a three element number array to right-handed
  81760. * @param vector number array to convert to right-handed
  81761. */
  81762. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81763. /**
  81764. * Converts a Vector4 to right-handed
  81765. * @param vector Vector4 to convert to right-handed
  81766. */
  81767. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81768. /**
  81769. * Converts a Vector4 to right-handed
  81770. * @param vector Vector4 to convert to right-handed
  81771. */
  81772. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81773. /**
  81774. * Converts a Quaternion to right-handed
  81775. * @param quaternion Source quaternion to convert to right-handed
  81776. */
  81777. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81778. /**
  81779. * Converts a Quaternion to right-handed
  81780. * @param quaternion Source quaternion to convert to right-handed
  81781. */
  81782. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81783. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81784. }
  81785. }
  81786. declare module BABYLON.GLTF2.Exporter {
  81787. /**
  81788. * Converts Babylon Scene into glTF 2.0.
  81789. * @hidden
  81790. */
  81791. export class _Exporter {
  81792. /**
  81793. * Stores the glTF to export
  81794. */
  81795. _glTF: IGLTF;
  81796. /**
  81797. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81798. */
  81799. _bufferViews: IBufferView[];
  81800. /**
  81801. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81802. */
  81803. _accessors: IAccessor[];
  81804. /**
  81805. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81806. */
  81807. _nodes: INode[];
  81808. /**
  81809. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81810. */
  81811. private _scenes;
  81812. /**
  81813. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81814. */
  81815. private _meshes;
  81816. /**
  81817. * Stores all the generated material information, which represents the appearance of each primitive
  81818. */
  81819. _materials: IMaterial[];
  81820. _materialMap: {
  81821. [materialID: number]: number;
  81822. };
  81823. /**
  81824. * Stores all the generated texture information, which is referenced by glTF materials
  81825. */
  81826. _textures: ITexture[];
  81827. /**
  81828. * Stores all the generated image information, which is referenced by glTF textures
  81829. */
  81830. _images: IImage[];
  81831. /**
  81832. * Stores all the texture samplers
  81833. */
  81834. _samplers: ISampler[];
  81835. /**
  81836. * Stores all the generated animation samplers, which is referenced by glTF animations
  81837. */
  81838. /**
  81839. * Stores the animations for glTF models
  81840. */
  81841. private _animations;
  81842. /**
  81843. * Stores the total amount of bytes stored in the glTF buffer
  81844. */
  81845. private _totalByteLength;
  81846. /**
  81847. * Stores a reference to the Babylon scene containing the source geometry and material information
  81848. */
  81849. _babylonScene: Scene;
  81850. /**
  81851. * Stores a map of the image data, where the key is the file name and the value
  81852. * is the image data
  81853. */
  81854. _imageData: {
  81855. [fileName: string]: {
  81856. data: Uint8Array;
  81857. mimeType: ImageMimeType;
  81858. };
  81859. };
  81860. /**
  81861. * Stores a map of the unique id of a node to its index in the node array
  81862. */
  81863. _nodeMap: {
  81864. [key: number]: number;
  81865. };
  81866. /**
  81867. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81868. */
  81869. _convertToRightHandedSystem: boolean;
  81870. /**
  81871. * Specifies if a Babylon node should be converted to right-handed on export
  81872. */
  81873. _convertToRightHandedSystemMap: {
  81874. [nodeId: number]: boolean;
  81875. };
  81876. _includeCoordinateSystemConversionNodes: boolean;
  81877. /**
  81878. * Baked animation sample rate
  81879. */
  81880. private _animationSampleRate;
  81881. private _options;
  81882. private _localEngine;
  81883. _glTFMaterialExporter: _GLTFMaterialExporter;
  81884. private _extensions;
  81885. private static _ExtensionNames;
  81886. private static _ExtensionFactories;
  81887. private _applyExtension;
  81888. private _applyExtensions;
  81889. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81890. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81891. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81892. [key: number]: number;
  81893. }): Promise<Nullable<INode>>;
  81894. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81895. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81896. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81897. private _forEachExtensions;
  81898. private _extensionsOnExporting;
  81899. /**
  81900. * Load glTF serializer extensions
  81901. */
  81902. private _loadExtensions;
  81903. /**
  81904. * Creates a glTF Exporter instance, which can accept optional exporter options
  81905. * @param babylonScene Babylon scene object
  81906. * @param options Options to modify the behavior of the exporter
  81907. */
  81908. constructor(babylonScene: Scene, options?: IExportOptions);
  81909. dispose(): void;
  81910. /**
  81911. * Registers a glTF exporter extension
  81912. * @param name Name of the extension to export
  81913. * @param factory The factory function that creates the exporter extension
  81914. */
  81915. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81916. /**
  81917. * Un-registers an exporter extension
  81918. * @param name The name fo the exporter extension
  81919. * @returns A boolean indicating whether the extension has been un-registered
  81920. */
  81921. static UnregisterExtension(name: string): boolean;
  81922. /**
  81923. * Lazy load a local engine
  81924. */
  81925. _getLocalEngine(): Engine;
  81926. private reorderIndicesBasedOnPrimitiveMode;
  81927. /**
  81928. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81929. * clock-wise during export to glTF
  81930. * @param submesh BabylonJS submesh
  81931. * @param primitiveMode Primitive mode of the mesh
  81932. * @param sideOrientation the winding order of the submesh
  81933. * @param vertexBufferKind The type of vertex attribute
  81934. * @param meshAttributeArray The vertex attribute data
  81935. * @param byteOffset The offset to the binary data
  81936. * @param binaryWriter The binary data for the glTF file
  81937. * @param convertToRightHandedSystem Converts the values to right-handed
  81938. */
  81939. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81940. /**
  81941. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81942. * clock-wise during export to glTF
  81943. * @param submesh BabylonJS submesh
  81944. * @param primitiveMode Primitive mode of the mesh
  81945. * @param sideOrientation the winding order of the submesh
  81946. * @param vertexBufferKind The type of vertex attribute
  81947. * @param meshAttributeArray The vertex attribute data
  81948. * @param byteOffset The offset to the binary data
  81949. * @param binaryWriter The binary data for the glTF file
  81950. * @param convertToRightHandedSystem Converts the values to right-handed
  81951. */
  81952. private reorderTriangleFillMode;
  81953. /**
  81954. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81955. * clock-wise during export to glTF
  81956. * @param submesh BabylonJS submesh
  81957. * @param primitiveMode Primitive mode of the mesh
  81958. * @param sideOrientation the winding order of the submesh
  81959. * @param vertexBufferKind The type of vertex attribute
  81960. * @param meshAttributeArray The vertex attribute data
  81961. * @param byteOffset The offset to the binary data
  81962. * @param binaryWriter The binary data for the glTF file
  81963. * @param convertToRightHandedSystem Converts the values to right-handed
  81964. */
  81965. private reorderTriangleStripDrawMode;
  81966. /**
  81967. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81968. * clock-wise during export to glTF
  81969. * @param submesh BabylonJS submesh
  81970. * @param primitiveMode Primitive mode of the mesh
  81971. * @param sideOrientation the winding order of the submesh
  81972. * @param vertexBufferKind The type of vertex attribute
  81973. * @param meshAttributeArray The vertex attribute data
  81974. * @param byteOffset The offset to the binary data
  81975. * @param binaryWriter The binary data for the glTF file
  81976. * @param convertToRightHandedSystem Converts the values to right-handed
  81977. */
  81978. private reorderTriangleFanMode;
  81979. /**
  81980. * Writes the vertex attribute data to binary
  81981. * @param vertices The vertices to write to the binary writer
  81982. * @param byteOffset The offset into the binary writer to overwrite binary data
  81983. * @param vertexAttributeKind The vertex attribute type
  81984. * @param meshAttributeArray The vertex attribute data
  81985. * @param binaryWriter The writer containing the binary data
  81986. * @param convertToRightHandedSystem Converts the values to right-handed
  81987. */
  81988. private writeVertexAttributeData;
  81989. /**
  81990. * Writes mesh attribute data to a data buffer
  81991. * Returns the bytelength of the data
  81992. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81993. * @param meshAttributeArray Array containing the attribute data
  81994. * @param binaryWriter The buffer to write the binary data to
  81995. * @param indices Used to specify the order of the vertex data
  81996. * @param convertToRightHandedSystem Converts the values to right-handed
  81997. */
  81998. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81999. /**
  82000. * Generates glTF json data
  82001. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82002. * @param glTFPrefix Text to use when prefixing a glTF file
  82003. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82004. * @returns json data as string
  82005. */
  82006. private generateJSON;
  82007. /**
  82008. * Generates data for .gltf and .bin files based on the glTF prefix string
  82009. * @param glTFPrefix Text to use when prefixing a glTF file
  82010. * @param dispose Dispose the exporter
  82011. * @returns GLTFData with glTF file data
  82012. */
  82013. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82014. /**
  82015. * Creates a binary buffer for glTF
  82016. * @returns array buffer for binary data
  82017. */
  82018. private _generateBinaryAsync;
  82019. /**
  82020. * Pads the number to a multiple of 4
  82021. * @param num number to pad
  82022. * @returns padded number
  82023. */
  82024. private _getPadding;
  82025. /**
  82026. * @hidden
  82027. */
  82028. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82029. /**
  82030. * Sets the TRS for each node
  82031. * @param node glTF Node for storing the transformation data
  82032. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82033. * @param convertToRightHandedSystem Converts the values to right-handed
  82034. */
  82035. private setNodeTransformation;
  82036. private getVertexBufferFromMesh;
  82037. /**
  82038. * Creates a bufferview based on the vertices type for the Babylon mesh
  82039. * @param kind Indicates the type of vertices data
  82040. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82041. * @param binaryWriter The buffer to write the bufferview data to
  82042. * @param convertToRightHandedSystem Converts the values to right-handed
  82043. */
  82044. private createBufferViewKind;
  82045. /**
  82046. * The primitive mode of the Babylon mesh
  82047. * @param babylonMesh The BabylonJS mesh
  82048. */
  82049. private getMeshPrimitiveMode;
  82050. /**
  82051. * Sets the primitive mode of the glTF mesh primitive
  82052. * @param meshPrimitive glTF mesh primitive
  82053. * @param primitiveMode The primitive mode
  82054. */
  82055. private setPrimitiveMode;
  82056. /**
  82057. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82058. * @param meshPrimitive glTF mesh primitive
  82059. * @param attributeKind vertex attribute
  82060. * @returns boolean specifying if uv coordinates are present
  82061. */
  82062. private setAttributeKind;
  82063. /**
  82064. * Sets data for the primitive attributes of each submesh
  82065. * @param mesh glTF Mesh object to store the primitive attribute information
  82066. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82067. * @param binaryWriter Buffer to write the attribute data to
  82068. * @param convertToRightHandedSystem Converts the values to right-handed
  82069. */
  82070. private setPrimitiveAttributesAsync;
  82071. /**
  82072. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82073. * @param node The node to check
  82074. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82075. */
  82076. private isBabylonCoordinateSystemConvertingNode;
  82077. /**
  82078. * Creates a glTF scene based on the array of meshes
  82079. * Returns the the total byte offset
  82080. * @param babylonScene Babylon scene to get the mesh data from
  82081. * @param binaryWriter Buffer to write binary data to
  82082. */
  82083. private createSceneAsync;
  82084. /**
  82085. * Creates a mapping of Node unique id to node index and handles animations
  82086. * @param babylonScene Babylon Scene
  82087. * @param nodes Babylon transform nodes
  82088. * @param binaryWriter Buffer to write binary data to
  82089. * @returns Node mapping of unique id to index
  82090. */
  82091. private createNodeMapAndAnimationsAsync;
  82092. /**
  82093. * Creates a glTF node from a Babylon mesh
  82094. * @param babylonMesh Source Babylon mesh
  82095. * @param binaryWriter Buffer for storing geometry data
  82096. * @param convertToRightHandedSystem Converts the values to right-handed
  82097. * @param nodeMap Node mapping of unique id to glTF node index
  82098. * @returns glTF node
  82099. */
  82100. private createNodeAsync;
  82101. }
  82102. /**
  82103. * @hidden
  82104. *
  82105. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82106. */
  82107. export class _BinaryWriter {
  82108. /**
  82109. * Array buffer which stores all binary data
  82110. */
  82111. private _arrayBuffer;
  82112. /**
  82113. * View of the array buffer
  82114. */
  82115. private _dataView;
  82116. /**
  82117. * byte offset of data in array buffer
  82118. */
  82119. private _byteOffset;
  82120. /**
  82121. * Initialize binary writer with an initial byte length
  82122. * @param byteLength Initial byte length of the array buffer
  82123. */
  82124. constructor(byteLength: number);
  82125. /**
  82126. * Resize the array buffer to the specified byte length
  82127. * @param byteLength
  82128. */
  82129. private resizeBuffer;
  82130. /**
  82131. * Get an array buffer with the length of the byte offset
  82132. * @returns ArrayBuffer resized to the byte offset
  82133. */
  82134. getArrayBuffer(): ArrayBuffer;
  82135. /**
  82136. * Get the byte offset of the array buffer
  82137. * @returns byte offset
  82138. */
  82139. getByteOffset(): number;
  82140. /**
  82141. * Stores an UInt8 in the array buffer
  82142. * @param entry
  82143. * @param byteOffset If defined, specifies where to set the value as an offset.
  82144. */
  82145. setUInt8(entry: number, byteOffset?: number): void;
  82146. /**
  82147. * Gets an UInt32 in the array buffer
  82148. * @param entry
  82149. * @param byteOffset If defined, specifies where to set the value as an offset.
  82150. */
  82151. getUInt32(byteOffset: number): number;
  82152. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82153. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82154. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82155. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82156. /**
  82157. * Stores a Float32 in the array buffer
  82158. * @param entry
  82159. */
  82160. setFloat32(entry: number, byteOffset?: number): void;
  82161. /**
  82162. * Stores an UInt32 in the array buffer
  82163. * @param entry
  82164. * @param byteOffset If defined, specifies where to set the value as an offset.
  82165. */
  82166. setUInt32(entry: number, byteOffset?: number): void;
  82167. }
  82168. }
  82169. declare module BABYLON.GLTF2.Exporter {
  82170. /**
  82171. * @hidden
  82172. * Interface to store animation data.
  82173. */
  82174. export interface _IAnimationData {
  82175. /**
  82176. * Keyframe data.
  82177. */
  82178. inputs: number[];
  82179. /**
  82180. * Value data.
  82181. */
  82182. outputs: number[][];
  82183. /**
  82184. * Animation interpolation data.
  82185. */
  82186. samplerInterpolation: AnimationSamplerInterpolation;
  82187. /**
  82188. * Minimum keyframe value.
  82189. */
  82190. inputsMin: number;
  82191. /**
  82192. * Maximum keyframe value.
  82193. */
  82194. inputsMax: number;
  82195. }
  82196. /**
  82197. * @hidden
  82198. */
  82199. export interface _IAnimationInfo {
  82200. /**
  82201. * The target channel for the animation
  82202. */
  82203. animationChannelTargetPath: AnimationChannelTargetPath;
  82204. /**
  82205. * The glTF accessor type for the data.
  82206. */
  82207. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82208. /**
  82209. * Specifies if quaternions should be used.
  82210. */
  82211. useQuaternion: boolean;
  82212. }
  82213. /**
  82214. * @hidden
  82215. * Utility class for generating glTF animation data from BabylonJS.
  82216. */
  82217. export class _GLTFAnimation {
  82218. /**
  82219. * @ignore
  82220. *
  82221. * Creates glTF channel animation from BabylonJS animation.
  82222. * @param babylonTransformNode - BabylonJS mesh.
  82223. * @param animation - animation.
  82224. * @param animationChannelTargetPath - The target animation channel.
  82225. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82226. * @param useQuaternion - Specifies if quaternions are used.
  82227. * @returns nullable IAnimationData
  82228. */
  82229. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82230. private static _DeduceAnimationInfo;
  82231. /**
  82232. * @ignore
  82233. * Create node animations from the transform node animations
  82234. * @param babylonNode
  82235. * @param runtimeGLTFAnimation
  82236. * @param idleGLTFAnimations
  82237. * @param nodeMap
  82238. * @param nodes
  82239. * @param binaryWriter
  82240. * @param bufferViews
  82241. * @param accessors
  82242. * @param convertToRightHandedSystem
  82243. * @param animationSampleRate
  82244. */
  82245. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82246. [key: number]: number;
  82247. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82248. /**
  82249. * @ignore
  82250. * Create node animations from the animation groups
  82251. * @param babylonScene
  82252. * @param glTFAnimations
  82253. * @param nodeMap
  82254. * @param nodes
  82255. * @param binaryWriter
  82256. * @param bufferViews
  82257. * @param accessors
  82258. * @param convertToRightHandedSystemMap
  82259. * @param animationSampleRate
  82260. */
  82261. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82262. [key: number]: number;
  82263. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82264. [nodeId: number]: boolean;
  82265. }, animationSampleRate: number): void;
  82266. private static AddAnimation;
  82267. /**
  82268. * Create a baked animation
  82269. * @param babylonTransformNode BabylonJS mesh
  82270. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82271. * @param animationChannelTargetPath animation target channel
  82272. * @param minFrame minimum animation frame
  82273. * @param maxFrame maximum animation frame
  82274. * @param fps frames per second of the animation
  82275. * @param inputs input key frames of the animation
  82276. * @param outputs output key frame data of the animation
  82277. * @param convertToRightHandedSystem converts the values to right-handed
  82278. * @param useQuaternion specifies if quaternions should be used
  82279. */
  82280. private static _CreateBakedAnimation;
  82281. private static _ConvertFactorToVector3OrQuaternion;
  82282. private static _SetInterpolatedValue;
  82283. /**
  82284. * Creates linear animation from the animation key frames
  82285. * @param babylonTransformNode BabylonJS mesh
  82286. * @param animation BabylonJS animation
  82287. * @param animationChannelTargetPath The target animation channel
  82288. * @param frameDelta The difference between the last and first frame of the animation
  82289. * @param inputs Array to store the key frame times
  82290. * @param outputs Array to store the key frame data
  82291. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82292. * @param useQuaternion Specifies if quaternions are used in the animation
  82293. */
  82294. private static _CreateLinearOrStepAnimation;
  82295. /**
  82296. * Creates cubic spline animation from the animation key frames
  82297. * @param babylonTransformNode BabylonJS mesh
  82298. * @param animation BabylonJS animation
  82299. * @param animationChannelTargetPath The target animation channel
  82300. * @param frameDelta The difference between the last and first frame of the animation
  82301. * @param inputs Array to store the key frame times
  82302. * @param outputs Array to store the key frame data
  82303. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82304. * @param useQuaternion Specifies if quaternions are used in the animation
  82305. */
  82306. private static _CreateCubicSplineAnimation;
  82307. private static _GetBasePositionRotationOrScale;
  82308. /**
  82309. * Adds a key frame value
  82310. * @param keyFrame
  82311. * @param animation
  82312. * @param outputs
  82313. * @param animationChannelTargetPath
  82314. * @param basePositionRotationOrScale
  82315. * @param convertToRightHandedSystem
  82316. * @param useQuaternion
  82317. */
  82318. private static _AddKeyframeValue;
  82319. /**
  82320. * Determine the interpolation based on the key frames
  82321. * @param keyFrames
  82322. * @param animationChannelTargetPath
  82323. * @param useQuaternion
  82324. */
  82325. private static _DeduceInterpolation;
  82326. /**
  82327. * Adds an input tangent or output tangent to the output data
  82328. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82329. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82330. * @param outputs The animation data by keyframe
  82331. * @param animationChannelTargetPath The target animation channel
  82332. * @param interpolation The interpolation type
  82333. * @param keyFrame The key frame with the animation data
  82334. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82335. * @param useQuaternion Specifies if quaternions are used
  82336. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82337. */
  82338. private static AddSplineTangent;
  82339. /**
  82340. * Get the minimum and maximum key frames' frame values
  82341. * @param keyFrames animation key frames
  82342. * @returns the minimum and maximum key frame value
  82343. */
  82344. private static calculateMinMaxKeyFrames;
  82345. }
  82346. }
  82347. declare module BABYLON.GLTF2.Exporter {
  82348. /** @hidden */
  82349. export var textureTransformPixelShader: {
  82350. name: string;
  82351. shader: string;
  82352. };
  82353. }
  82354. declare module BABYLON.GLTF2.Exporter.Extensions {
  82355. /**
  82356. * @hidden
  82357. */
  82358. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82359. private _recordedTextures;
  82360. /** Name of this extension */
  82361. readonly name: string;
  82362. /** Defines whether this extension is enabled */
  82363. enabled: boolean;
  82364. /** Defines whether this extension is required */
  82365. required: boolean;
  82366. /** Reference to the glTF exporter */
  82367. private _wasUsed;
  82368. constructor(exporter: _Exporter);
  82369. dispose(): void;
  82370. /** @hidden */
  82371. get wasUsed(): boolean;
  82372. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82373. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82374. /**
  82375. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82376. * @param babylonTexture
  82377. * @param offset
  82378. * @param rotation
  82379. * @param scale
  82380. * @param scene
  82381. */
  82382. private _textureTransformTextureAsync;
  82383. }
  82384. }
  82385. declare module BABYLON.GLTF2.Exporter.Extensions {
  82386. /**
  82387. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82388. */
  82389. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82390. /** The name of this extension. */
  82391. readonly name: string;
  82392. /** Defines whether this extension is enabled. */
  82393. enabled: boolean;
  82394. /** Defines whether this extension is required */
  82395. required: boolean;
  82396. /** Reference to the glTF exporter */
  82397. private _exporter;
  82398. private _lights;
  82399. /** @hidden */
  82400. constructor(exporter: _Exporter);
  82401. /** @hidden */
  82402. dispose(): void;
  82403. /** @hidden */
  82404. get wasUsed(): boolean;
  82405. /** @hidden */
  82406. onExporting(): void;
  82407. /**
  82408. * Define this method to modify the default behavior when exporting a node
  82409. * @param context The context when exporting the node
  82410. * @param node glTF node
  82411. * @param babylonNode BabylonJS node
  82412. * @param nodeMap Node mapping of unique id to glTF node index
  82413. * @returns nullable INode promise
  82414. */
  82415. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82416. [key: number]: number;
  82417. }): Promise<Nullable<INode>>;
  82418. }
  82419. }
  82420. declare module BABYLON.GLTF2.Exporter.Extensions {
  82421. /**
  82422. * @hidden
  82423. */
  82424. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82425. /** Name of this extension */
  82426. readonly name: string;
  82427. /** Defines whether this extension is enabled */
  82428. enabled: boolean;
  82429. /** Defines whether this extension is required */
  82430. required: boolean;
  82431. /** Reference to the glTF exporter */
  82432. private _textureInfos;
  82433. private _exportedTextures;
  82434. private _wasUsed;
  82435. constructor(exporter: _Exporter);
  82436. dispose(): void;
  82437. /** @hidden */
  82438. get wasUsed(): boolean;
  82439. private _getTextureIndex;
  82440. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82441. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82442. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82443. }
  82444. }
  82445. declare module BABYLON.GLTF2.Exporter.Extensions {
  82446. /**
  82447. * @hidden
  82448. */
  82449. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82450. /** Name of this extension */
  82451. readonly name: string;
  82452. /** Defines whether this extension is enabled */
  82453. enabled: boolean;
  82454. /** Defines whether this extension is required */
  82455. required: boolean;
  82456. private _wasUsed;
  82457. constructor(exporter: _Exporter);
  82458. /** @hidden */
  82459. get wasUsed(): boolean;
  82460. dispose(): void;
  82461. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82462. }
  82463. }
  82464. declare module BABYLON {
  82465. /**
  82466. * Class for generating STL data from a Babylon scene.
  82467. */
  82468. export class STLExport {
  82469. /**
  82470. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82471. * @param meshes list defines the mesh to serialize
  82472. * @param download triggers the automatic download of the file.
  82473. * @param fileName changes the downloads fileName.
  82474. * @param binary changes the STL to a binary type.
  82475. * @param isLittleEndian toggle for binary type exporter.
  82476. * @returns the STL as UTF8 string
  82477. */
  82478. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82479. }
  82480. }
  82481. declare module "babylonjs-gltf2interface" {
  82482. export = BABYLON.GLTF2;
  82483. }
  82484. /**
  82485. * Module for glTF 2.0 Interface
  82486. */
  82487. declare module BABYLON.GLTF2 {
  82488. /**
  82489. * The datatype of the components in the attribute
  82490. */
  82491. const enum AccessorComponentType {
  82492. /**
  82493. * Byte
  82494. */
  82495. BYTE = 5120,
  82496. /**
  82497. * Unsigned Byte
  82498. */
  82499. UNSIGNED_BYTE = 5121,
  82500. /**
  82501. * Short
  82502. */
  82503. SHORT = 5122,
  82504. /**
  82505. * Unsigned Short
  82506. */
  82507. UNSIGNED_SHORT = 5123,
  82508. /**
  82509. * Unsigned Int
  82510. */
  82511. UNSIGNED_INT = 5125,
  82512. /**
  82513. * Float
  82514. */
  82515. FLOAT = 5126,
  82516. }
  82517. /**
  82518. * Specifies if the attirbute is a scalar, vector, or matrix
  82519. */
  82520. const enum AccessorType {
  82521. /**
  82522. * Scalar
  82523. */
  82524. SCALAR = "SCALAR",
  82525. /**
  82526. * Vector2
  82527. */
  82528. VEC2 = "VEC2",
  82529. /**
  82530. * Vector3
  82531. */
  82532. VEC3 = "VEC3",
  82533. /**
  82534. * Vector4
  82535. */
  82536. VEC4 = "VEC4",
  82537. /**
  82538. * Matrix2x2
  82539. */
  82540. MAT2 = "MAT2",
  82541. /**
  82542. * Matrix3x3
  82543. */
  82544. MAT3 = "MAT3",
  82545. /**
  82546. * Matrix4x4
  82547. */
  82548. MAT4 = "MAT4",
  82549. }
  82550. /**
  82551. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82552. */
  82553. const enum AnimationChannelTargetPath {
  82554. /**
  82555. * Translation
  82556. */
  82557. TRANSLATION = "translation",
  82558. /**
  82559. * Rotation
  82560. */
  82561. ROTATION = "rotation",
  82562. /**
  82563. * Scale
  82564. */
  82565. SCALE = "scale",
  82566. /**
  82567. * Weights
  82568. */
  82569. WEIGHTS = "weights",
  82570. }
  82571. /**
  82572. * Interpolation algorithm
  82573. */
  82574. const enum AnimationSamplerInterpolation {
  82575. /**
  82576. * The animated values are linearly interpolated between keyframes
  82577. */
  82578. LINEAR = "LINEAR",
  82579. /**
  82580. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82581. */
  82582. STEP = "STEP",
  82583. /**
  82584. * The animation's interpolation is computed using a cubic spline with specified tangents
  82585. */
  82586. CUBICSPLINE = "CUBICSPLINE",
  82587. }
  82588. /**
  82589. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82590. */
  82591. const enum CameraType {
  82592. /**
  82593. * A perspective camera containing properties to create a perspective projection matrix
  82594. */
  82595. PERSPECTIVE = "perspective",
  82596. /**
  82597. * An orthographic camera containing properties to create an orthographic projection matrix
  82598. */
  82599. ORTHOGRAPHIC = "orthographic",
  82600. }
  82601. /**
  82602. * The mime-type of the image
  82603. */
  82604. const enum ImageMimeType {
  82605. /**
  82606. * JPEG Mime-type
  82607. */
  82608. JPEG = "image/jpeg",
  82609. /**
  82610. * PNG Mime-type
  82611. */
  82612. PNG = "image/png",
  82613. }
  82614. /**
  82615. * The alpha rendering mode of the material
  82616. */
  82617. const enum MaterialAlphaMode {
  82618. /**
  82619. * The alpha value is ignored and the rendered output is fully opaque
  82620. */
  82621. OPAQUE = "OPAQUE",
  82622. /**
  82623. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82624. */
  82625. MASK = "MASK",
  82626. /**
  82627. * 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)
  82628. */
  82629. BLEND = "BLEND",
  82630. }
  82631. /**
  82632. * The type of the primitives to render
  82633. */
  82634. const enum MeshPrimitiveMode {
  82635. /**
  82636. * Points
  82637. */
  82638. POINTS = 0,
  82639. /**
  82640. * Lines
  82641. */
  82642. LINES = 1,
  82643. /**
  82644. * Line Loop
  82645. */
  82646. LINE_LOOP = 2,
  82647. /**
  82648. * Line Strip
  82649. */
  82650. LINE_STRIP = 3,
  82651. /**
  82652. * Triangles
  82653. */
  82654. TRIANGLES = 4,
  82655. /**
  82656. * Triangle Strip
  82657. */
  82658. TRIANGLE_STRIP = 5,
  82659. /**
  82660. * Triangle Fan
  82661. */
  82662. TRIANGLE_FAN = 6,
  82663. }
  82664. /**
  82665. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82666. */
  82667. const enum TextureMagFilter {
  82668. /**
  82669. * Nearest
  82670. */
  82671. NEAREST = 9728,
  82672. /**
  82673. * Linear
  82674. */
  82675. LINEAR = 9729,
  82676. }
  82677. /**
  82678. * Minification filter. All valid values correspond to WebGL enums
  82679. */
  82680. const enum TextureMinFilter {
  82681. /**
  82682. * Nearest
  82683. */
  82684. NEAREST = 9728,
  82685. /**
  82686. * Linear
  82687. */
  82688. LINEAR = 9729,
  82689. /**
  82690. * Nearest Mip-Map Nearest
  82691. */
  82692. NEAREST_MIPMAP_NEAREST = 9984,
  82693. /**
  82694. * Linear Mipmap Nearest
  82695. */
  82696. LINEAR_MIPMAP_NEAREST = 9985,
  82697. /**
  82698. * Nearest Mipmap Linear
  82699. */
  82700. NEAREST_MIPMAP_LINEAR = 9986,
  82701. /**
  82702. * Linear Mipmap Linear
  82703. */
  82704. LINEAR_MIPMAP_LINEAR = 9987,
  82705. }
  82706. /**
  82707. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82708. */
  82709. const enum TextureWrapMode {
  82710. /**
  82711. * Clamp to Edge
  82712. */
  82713. CLAMP_TO_EDGE = 33071,
  82714. /**
  82715. * Mirrored Repeat
  82716. */
  82717. MIRRORED_REPEAT = 33648,
  82718. /**
  82719. * Repeat
  82720. */
  82721. REPEAT = 10497,
  82722. }
  82723. /**
  82724. * glTF Property
  82725. */
  82726. interface IProperty {
  82727. /**
  82728. * Dictionary object with extension-specific objects
  82729. */
  82730. extensions?: {
  82731. [key: string]: any;
  82732. };
  82733. /**
  82734. * Application-Specific data
  82735. */
  82736. extras?: any;
  82737. }
  82738. /**
  82739. * glTF Child of Root Property
  82740. */
  82741. interface IChildRootProperty extends IProperty {
  82742. /**
  82743. * The user-defined name of this object
  82744. */
  82745. name?: string;
  82746. }
  82747. /**
  82748. * Indices of those attributes that deviate from their initialization value
  82749. */
  82750. interface IAccessorSparseIndices extends IProperty {
  82751. /**
  82752. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82753. */
  82754. bufferView: number;
  82755. /**
  82756. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82757. */
  82758. byteOffset?: number;
  82759. /**
  82760. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82761. */
  82762. componentType: AccessorComponentType;
  82763. }
  82764. /**
  82765. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82766. */
  82767. interface IAccessorSparseValues extends IProperty {
  82768. /**
  82769. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82770. */
  82771. bufferView: number;
  82772. /**
  82773. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82774. */
  82775. byteOffset?: number;
  82776. }
  82777. /**
  82778. * Sparse storage of attributes that deviate from their initialization value
  82779. */
  82780. interface IAccessorSparse extends IProperty {
  82781. /**
  82782. * The number of attributes encoded in this sparse accessor
  82783. */
  82784. count: number;
  82785. /**
  82786. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82787. */
  82788. indices: IAccessorSparseIndices;
  82789. /**
  82790. * 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
  82791. */
  82792. values: IAccessorSparseValues;
  82793. }
  82794. /**
  82795. * 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
  82796. */
  82797. interface IAccessor extends IChildRootProperty {
  82798. /**
  82799. * The index of the bufferview
  82800. */
  82801. bufferView?: number;
  82802. /**
  82803. * The offset relative to the start of the bufferView in bytes
  82804. */
  82805. byteOffset?: number;
  82806. /**
  82807. * The datatype of components in the attribute
  82808. */
  82809. componentType: AccessorComponentType;
  82810. /**
  82811. * Specifies whether integer data values should be normalized
  82812. */
  82813. normalized?: boolean;
  82814. /**
  82815. * The number of attributes referenced by this accessor
  82816. */
  82817. count: number;
  82818. /**
  82819. * Specifies if the attribute is a scalar, vector, or matrix
  82820. */
  82821. type: AccessorType;
  82822. /**
  82823. * Maximum value of each component in this attribute
  82824. */
  82825. max?: number[];
  82826. /**
  82827. * Minimum value of each component in this attribute
  82828. */
  82829. min?: number[];
  82830. /**
  82831. * Sparse storage of attributes that deviate from their initialization value
  82832. */
  82833. sparse?: IAccessorSparse;
  82834. }
  82835. /**
  82836. * Targets an animation's sampler at a node's property
  82837. */
  82838. interface IAnimationChannel extends IProperty {
  82839. /**
  82840. * The index of a sampler in this animation used to compute the value for the target
  82841. */
  82842. sampler: number;
  82843. /**
  82844. * The index of the node and TRS property to target
  82845. */
  82846. target: IAnimationChannelTarget;
  82847. }
  82848. /**
  82849. * The index of the node and TRS property that an animation channel targets
  82850. */
  82851. interface IAnimationChannelTarget extends IProperty {
  82852. /**
  82853. * The index of the node to target
  82854. */
  82855. node: number;
  82856. /**
  82857. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82858. */
  82859. path: AnimationChannelTargetPath;
  82860. }
  82861. /**
  82862. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82863. */
  82864. interface IAnimationSampler extends IProperty {
  82865. /**
  82866. * The index of an accessor containing keyframe input values, e.g., time
  82867. */
  82868. input: number;
  82869. /**
  82870. * Interpolation algorithm
  82871. */
  82872. interpolation?: AnimationSamplerInterpolation;
  82873. /**
  82874. * The index of an accessor, containing keyframe output values
  82875. */
  82876. output: number;
  82877. }
  82878. /**
  82879. * A keyframe animation
  82880. */
  82881. interface IAnimation extends IChildRootProperty {
  82882. /**
  82883. * An array of channels, each of which targets an animation's sampler at a node's property
  82884. */
  82885. channels: IAnimationChannel[];
  82886. /**
  82887. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82888. */
  82889. samplers: IAnimationSampler[];
  82890. }
  82891. /**
  82892. * Metadata about the glTF asset
  82893. */
  82894. interface IAsset extends IChildRootProperty {
  82895. /**
  82896. * A copyright message suitable for display to credit the content creator
  82897. */
  82898. copyright?: string;
  82899. /**
  82900. * Tool that generated this glTF model. Useful for debugging
  82901. */
  82902. generator?: string;
  82903. /**
  82904. * The glTF version that this asset targets
  82905. */
  82906. version: string;
  82907. /**
  82908. * The minimum glTF version that this asset targets
  82909. */
  82910. minVersion?: string;
  82911. }
  82912. /**
  82913. * A buffer points to binary geometry, animation, or skins
  82914. */
  82915. interface IBuffer extends IChildRootProperty {
  82916. /**
  82917. * 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
  82918. */
  82919. uri?: string;
  82920. /**
  82921. * The length of the buffer in bytes
  82922. */
  82923. byteLength: number;
  82924. }
  82925. /**
  82926. * A view into a buffer generally representing a subset of the buffer
  82927. */
  82928. interface IBufferView extends IChildRootProperty {
  82929. /**
  82930. * The index of the buffer
  82931. */
  82932. buffer: number;
  82933. /**
  82934. * The offset into the buffer in bytes
  82935. */
  82936. byteOffset?: number;
  82937. /**
  82938. * The lenth of the bufferView in bytes
  82939. */
  82940. byteLength: number;
  82941. /**
  82942. * The stride, in bytes
  82943. */
  82944. byteStride?: number;
  82945. }
  82946. /**
  82947. * An orthographic camera containing properties to create an orthographic projection matrix
  82948. */
  82949. interface ICameraOrthographic extends IProperty {
  82950. /**
  82951. * The floating-point horizontal magnification of the view. Must not be zero
  82952. */
  82953. xmag: number;
  82954. /**
  82955. * The floating-point vertical magnification of the view. Must not be zero
  82956. */
  82957. ymag: number;
  82958. /**
  82959. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82960. */
  82961. zfar: number;
  82962. /**
  82963. * The floating-point distance to the near clipping plane
  82964. */
  82965. znear: number;
  82966. }
  82967. /**
  82968. * A perspective camera containing properties to create a perspective projection matrix
  82969. */
  82970. interface ICameraPerspective extends IProperty {
  82971. /**
  82972. * The floating-point aspect ratio of the field of view
  82973. */
  82974. aspectRatio?: number;
  82975. /**
  82976. * The floating-point vertical field of view in radians
  82977. */
  82978. yfov: number;
  82979. /**
  82980. * The floating-point distance to the far clipping plane
  82981. */
  82982. zfar?: number;
  82983. /**
  82984. * The floating-point distance to the near clipping plane
  82985. */
  82986. znear: number;
  82987. }
  82988. /**
  82989. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82990. */
  82991. interface ICamera extends IChildRootProperty {
  82992. /**
  82993. * An orthographic camera containing properties to create an orthographic projection matrix
  82994. */
  82995. orthographic?: ICameraOrthographic;
  82996. /**
  82997. * A perspective camera containing properties to create a perspective projection matrix
  82998. */
  82999. perspective?: ICameraPerspective;
  83000. /**
  83001. * Specifies if the camera uses a perspective or orthographic projection
  83002. */
  83003. type: CameraType;
  83004. }
  83005. /**
  83006. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83007. */
  83008. interface IImage extends IChildRootProperty {
  83009. /**
  83010. * 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
  83011. */
  83012. uri?: string;
  83013. /**
  83014. * The image's MIME type
  83015. */
  83016. mimeType?: ImageMimeType;
  83017. /**
  83018. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83019. */
  83020. bufferView?: number;
  83021. }
  83022. /**
  83023. * Material Normal Texture Info
  83024. */
  83025. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83026. /**
  83027. * The scalar multiplier applied to each normal vector of the normal texture
  83028. */
  83029. scale?: number;
  83030. }
  83031. /**
  83032. * Material Occlusion Texture Info
  83033. */
  83034. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83035. /**
  83036. * A scalar multiplier controlling the amount of occlusion applied
  83037. */
  83038. strength?: number;
  83039. }
  83040. /**
  83041. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83042. */
  83043. interface IMaterialPbrMetallicRoughness {
  83044. /**
  83045. * The material's base color factor
  83046. */
  83047. baseColorFactor?: number[];
  83048. /**
  83049. * The base color texture
  83050. */
  83051. baseColorTexture?: ITextureInfo;
  83052. /**
  83053. * The metalness of the material
  83054. */
  83055. metallicFactor?: number;
  83056. /**
  83057. * The roughness of the material
  83058. */
  83059. roughnessFactor?: number;
  83060. /**
  83061. * The metallic-roughness texture
  83062. */
  83063. metallicRoughnessTexture?: ITextureInfo;
  83064. }
  83065. /**
  83066. * The material appearance of a primitive
  83067. */
  83068. interface IMaterial extends IChildRootProperty {
  83069. /**
  83070. * 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
  83071. */
  83072. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83073. /**
  83074. * The normal map texture
  83075. */
  83076. normalTexture?: IMaterialNormalTextureInfo;
  83077. /**
  83078. * The occlusion map texture
  83079. */
  83080. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83081. /**
  83082. * The emissive map texture
  83083. */
  83084. emissiveTexture?: ITextureInfo;
  83085. /**
  83086. * 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
  83087. */
  83088. emissiveFactor?: number[];
  83089. /**
  83090. * The alpha rendering mode of the material
  83091. */
  83092. alphaMode?: MaterialAlphaMode;
  83093. /**
  83094. * The alpha cutoff value of the material
  83095. */
  83096. alphaCutoff?: number;
  83097. /**
  83098. * Specifies whether the material is double sided
  83099. */
  83100. doubleSided?: boolean;
  83101. }
  83102. /**
  83103. * Geometry to be rendered with the given material
  83104. */
  83105. interface IMeshPrimitive extends IProperty {
  83106. /**
  83107. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83108. */
  83109. attributes: {
  83110. [name: string]: number;
  83111. };
  83112. /**
  83113. * The index of the accessor that contains the indices
  83114. */
  83115. indices?: number;
  83116. /**
  83117. * The index of the material to apply to this primitive when rendering
  83118. */
  83119. material?: number;
  83120. /**
  83121. * The type of primitives to render. All valid values correspond to WebGL enums
  83122. */
  83123. mode?: MeshPrimitiveMode;
  83124. /**
  83125. * 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
  83126. */
  83127. targets?: {
  83128. [name: string]: number;
  83129. }[];
  83130. }
  83131. /**
  83132. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83133. */
  83134. interface IMesh extends IChildRootProperty {
  83135. /**
  83136. * An array of primitives, each defining geometry to be rendered with a material
  83137. */
  83138. primitives: IMeshPrimitive[];
  83139. /**
  83140. * Array of weights to be applied to the Morph Targets
  83141. */
  83142. weights?: number[];
  83143. }
  83144. /**
  83145. * A node in the node hierarchy
  83146. */
  83147. interface INode extends IChildRootProperty {
  83148. /**
  83149. * The index of the camera referenced by this node
  83150. */
  83151. camera?: number;
  83152. /**
  83153. * The indices of this node's children
  83154. */
  83155. children?: number[];
  83156. /**
  83157. * The index of the skin referenced by this node
  83158. */
  83159. skin?: number;
  83160. /**
  83161. * A floating-point 4x4 transformation matrix stored in column-major order
  83162. */
  83163. matrix?: number[];
  83164. /**
  83165. * The index of the mesh in this node
  83166. */
  83167. mesh?: number;
  83168. /**
  83169. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83170. */
  83171. rotation?: number[];
  83172. /**
  83173. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83174. */
  83175. scale?: number[];
  83176. /**
  83177. * The node's translation along the x, y, and z axes
  83178. */
  83179. translation?: number[];
  83180. /**
  83181. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83182. */
  83183. weights?: number[];
  83184. }
  83185. /**
  83186. * Texture sampler properties for filtering and wrapping modes
  83187. */
  83188. interface ISampler extends IChildRootProperty {
  83189. /**
  83190. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83191. */
  83192. magFilter?: TextureMagFilter;
  83193. /**
  83194. * Minification filter. All valid values correspond to WebGL enums
  83195. */
  83196. minFilter?: TextureMinFilter;
  83197. /**
  83198. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83199. */
  83200. wrapS?: TextureWrapMode;
  83201. /**
  83202. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83203. */
  83204. wrapT?: TextureWrapMode;
  83205. }
  83206. /**
  83207. * The root nodes of a scene
  83208. */
  83209. interface IScene extends IChildRootProperty {
  83210. /**
  83211. * The indices of each root node
  83212. */
  83213. nodes: number[];
  83214. }
  83215. /**
  83216. * Joints and matrices defining a skin
  83217. */
  83218. interface ISkin extends IChildRootProperty {
  83219. /**
  83220. * 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
  83221. */
  83222. inverseBindMatrices?: number;
  83223. /**
  83224. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83225. */
  83226. skeleton?: number;
  83227. /**
  83228. * 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)
  83229. */
  83230. joints: number[];
  83231. }
  83232. /**
  83233. * A texture and its sampler
  83234. */
  83235. interface ITexture extends IChildRootProperty {
  83236. /**
  83237. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83238. */
  83239. sampler?: number;
  83240. /**
  83241. * The index of the image used by this texture
  83242. */
  83243. source: number;
  83244. }
  83245. /**
  83246. * Reference to a texture
  83247. */
  83248. interface ITextureInfo extends IProperty {
  83249. /**
  83250. * The index of the texture
  83251. */
  83252. index: number;
  83253. /**
  83254. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83255. */
  83256. texCoord?: number;
  83257. }
  83258. /**
  83259. * The root object for a glTF asset
  83260. */
  83261. interface IGLTF extends IProperty {
  83262. /**
  83263. * An array of accessors. An accessor is a typed view into a bufferView
  83264. */
  83265. accessors?: IAccessor[];
  83266. /**
  83267. * An array of keyframe animations
  83268. */
  83269. animations?: IAnimation[];
  83270. /**
  83271. * Metadata about the glTF asset
  83272. */
  83273. asset: IAsset;
  83274. /**
  83275. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83276. */
  83277. buffers?: IBuffer[];
  83278. /**
  83279. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83280. */
  83281. bufferViews?: IBufferView[];
  83282. /**
  83283. * An array of cameras
  83284. */
  83285. cameras?: ICamera[];
  83286. /**
  83287. * Names of glTF extensions used somewhere in this asset
  83288. */
  83289. extensionsUsed?: string[];
  83290. /**
  83291. * Names of glTF extensions required to properly load this asset
  83292. */
  83293. extensionsRequired?: string[];
  83294. /**
  83295. * An array of images. An image defines data used to create a texture
  83296. */
  83297. images?: IImage[];
  83298. /**
  83299. * An array of materials. A material defines the appearance of a primitive
  83300. */
  83301. materials?: IMaterial[];
  83302. /**
  83303. * An array of meshes. A mesh is a set of primitives to be rendered
  83304. */
  83305. meshes?: IMesh[];
  83306. /**
  83307. * An array of nodes
  83308. */
  83309. nodes?: INode[];
  83310. /**
  83311. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83312. */
  83313. samplers?: ISampler[];
  83314. /**
  83315. * The index of the default scene
  83316. */
  83317. scene?: number;
  83318. /**
  83319. * An array of scenes
  83320. */
  83321. scenes?: IScene[];
  83322. /**
  83323. * An array of skins. A skin is defined by joints and matrices
  83324. */
  83325. skins?: ISkin[];
  83326. /**
  83327. * An array of textures
  83328. */
  83329. textures?: ITexture[];
  83330. }
  83331. /**
  83332. * The glTF validation results
  83333. * @ignore
  83334. */
  83335. interface IGLTFValidationResults {
  83336. info: {
  83337. generator: string;
  83338. hasAnimations: boolean;
  83339. hasDefaultScene: boolean;
  83340. hasMaterials: boolean;
  83341. hasMorphTargets: boolean;
  83342. hasSkins: boolean;
  83343. hasTextures: boolean;
  83344. maxAttributesUsed: number;
  83345. primitivesCount: number
  83346. };
  83347. issues: {
  83348. messages: Array<string>;
  83349. numErrors: number;
  83350. numHints: number;
  83351. numInfos: number;
  83352. numWarnings: number;
  83353. truncated: boolean
  83354. };
  83355. mimeType: string;
  83356. uri: string;
  83357. validatedAt: string;
  83358. validatorVersion: string;
  83359. }
  83360. /**
  83361. * The glTF validation options
  83362. */
  83363. interface IGLTFValidationOptions {
  83364. /** Uri to use */
  83365. uri?: string;
  83366. /** Function used to load external resources */
  83367. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83368. /** Boolean indicating that we need to validate accessor data */
  83369. validateAccessorData?: boolean;
  83370. /** max number of issues allowed */
  83371. maxIssues?: number;
  83372. /** Ignored issues */
  83373. ignoredIssues?: Array<string>;
  83374. /** Value to override severy settings */
  83375. severityOverrides?: Object;
  83376. }
  83377. /**
  83378. * The glTF validator object
  83379. * @ignore
  83380. */
  83381. interface IGLTFValidator {
  83382. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83383. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83384. }
  83385. /**
  83386. * Interfaces from the EXT_lights_image_based extension
  83387. */
  83388. /** @hidden */
  83389. interface IEXTLightsImageBased_LightReferenceImageBased {
  83390. light: number;
  83391. }
  83392. /** @hidden */
  83393. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83394. intensity: number;
  83395. rotation: number[];
  83396. specularImageSize: number;
  83397. specularImages: number[][];
  83398. irradianceCoefficients: number[][];
  83399. }
  83400. /** @hidden */
  83401. interface IEXTLightsImageBased {
  83402. lights: IEXTLightsImageBased_LightImageBased[];
  83403. }
  83404. /**
  83405. * Interfaces from the EXT_mesh_gpu_instancing extension
  83406. * !!! Experimental Extension Subject to Changes !!!
  83407. */
  83408. /** @hidden */
  83409. interface IEXTMeshGpuInstancing {
  83410. mesh?: number;
  83411. attributes: { [name: string]: number };
  83412. }
  83413. /**
  83414. * Interfaces from the KHR_draco_mesh_compression extension
  83415. */
  83416. /** @hidden */
  83417. interface IKHRDracoMeshCompression {
  83418. bufferView: number;
  83419. attributes: { [name: string]: number };
  83420. }
  83421. /**
  83422. * Interfaces from the KHR_lights_punctual extension
  83423. */
  83424. /** @hidden */
  83425. const enum IKHRLightsPunctual_LightType {
  83426. DIRECTIONAL = "directional",
  83427. POINT = "point",
  83428. SPOT = "spot"
  83429. }
  83430. /** @hidden */
  83431. interface IKHRLightsPunctual_LightReference {
  83432. light: number;
  83433. }
  83434. /** @hidden */
  83435. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83436. type: IKHRLightsPunctual_LightType;
  83437. color?: number[];
  83438. intensity?: number;
  83439. range?: number;
  83440. spot?: {
  83441. innerConeAngle?: number;
  83442. outerConeAngle?: number;
  83443. };
  83444. }
  83445. /** @hidden */
  83446. interface IKHRLightsPunctual {
  83447. lights: IKHRLightsPunctual_Light[];
  83448. }
  83449. /**
  83450. * Interfaces from the KHR_materials_clearcoat extension
  83451. * !!! Experimental Extension Subject to Changes !!!
  83452. */
  83453. /** @hidden */
  83454. interface IKHRMaterialsClearcoat {
  83455. clearcoatFactor: number;
  83456. clearcoatTexture: ITextureInfo;
  83457. clearcoatRoughnessFactor: number;
  83458. clearcoatRoughnessTexture: ITextureInfo;
  83459. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83460. }
  83461. /**
  83462. * Interfaces from the KHR_materials_ior extension
  83463. * !!! Experimental Extension Subject to Changes !!!
  83464. */
  83465. /** @hidden */
  83466. interface IKHRMaterialsIor {
  83467. ior: number;
  83468. }
  83469. /**
  83470. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83471. */
  83472. /** @hidden */
  83473. interface IKHRMaterialsPbrSpecularGlossiness {
  83474. diffuseFactor: number[];
  83475. diffuseTexture: ITextureInfo;
  83476. specularFactor: number[];
  83477. glossinessFactor: number;
  83478. specularGlossinessTexture: ITextureInfo;
  83479. }
  83480. /**
  83481. * Interfaces from the KHR_materials_sheen extension
  83482. * !!! Experimental Extension Subject to Changes !!!
  83483. */
  83484. /** @hidden */
  83485. interface IKHRMaterialsSheen {
  83486. sheenColorFactor?: number[];
  83487. sheenTexture?: ITextureInfo;
  83488. sheenRoughnessFactor?: number;
  83489. }
  83490. /**
  83491. * Interfaces from the KHR_materials_specular extension
  83492. * !!! Experimental Extension Subject to Changes !!!
  83493. */
  83494. /** @hidden */
  83495. interface IKHRMaterialsSpecular {
  83496. specularFactor: number;
  83497. specularColorFactor: number[];
  83498. specularTexture: ITextureInfo;
  83499. }
  83500. /**
  83501. * Interfaces from the KHR_materials_transmission extension
  83502. * !!! Experimental Extension Subject to Changes !!!
  83503. */
  83504. /** @hidden */
  83505. interface IKHRMaterialsTransmission {
  83506. transmissionFactor?: number;
  83507. transmissionTexture?: ITextureInfo;
  83508. }
  83509. /**
  83510. * Interfaces from the KHR_materials_variants extension
  83511. * !!! Experimental Extension Subject to Changes !!!
  83512. */
  83513. /** @hidden */
  83514. interface IKHRMaterialVariants_Mapping {
  83515. tags: string[];
  83516. material: number;
  83517. }
  83518. /** @hidden */
  83519. interface IKHRMaterialVariants {
  83520. mapping: IKHRMaterialVariants_Mapping[];
  83521. }
  83522. /**
  83523. * Interfaces from the KHR_texture_basisu extension
  83524. * !!! Experimental Extension Subject to Changes !!!
  83525. */
  83526. /** @hidden */
  83527. interface IKHRTextureBasisU {
  83528. source: number;
  83529. }
  83530. /**
  83531. * Interfaces from the KHR_texture_transform extension
  83532. */
  83533. /** @hidden */
  83534. interface IKHRTextureTransform {
  83535. offset?: number[];
  83536. rotation?: number;
  83537. scale?: number[];
  83538. texCoord?: number;
  83539. }
  83540. /**
  83541. * Interfaces from the KHR_xmp extension
  83542. * !!! Experimental Extension Subject to Changes !!!
  83543. */
  83544. /** @hidden */
  83545. interface IKHRXmp_Data {
  83546. [key: string]: unknown;
  83547. }
  83548. /** @hidden */
  83549. interface IKHRXmp_Gltf {
  83550. packets: IKHRXmp_Data[];
  83551. }
  83552. /** @hidden */
  83553. interface IKHRXmp_Node {
  83554. packet: number;
  83555. }
  83556. /**
  83557. * Interfaces from the MSFT_audio_emitter extension
  83558. */
  83559. /** @hidden */
  83560. interface IMSFTAudioEmitter_ClipReference {
  83561. clip: number;
  83562. weight?: number;
  83563. }
  83564. /** @hidden */
  83565. interface IMSFTAudioEmitter_EmittersReference {
  83566. emitters: number[];
  83567. }
  83568. /** @hidden */
  83569. const enum IMSFTAudioEmitter_DistanceModel {
  83570. linear = "linear",
  83571. inverse = "inverse",
  83572. exponential = "exponential",
  83573. }
  83574. /** @hidden */
  83575. interface IMSFTAudioEmitter_Emitter {
  83576. name?: string;
  83577. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  83578. refDistance?: number;
  83579. maxDistance?: number;
  83580. rolloffFactor?: number;
  83581. innerAngle?: number;
  83582. outerAngle?: number;
  83583. loop?: boolean;
  83584. volume?: number;
  83585. clips: IMSFTAudioEmitter_ClipReference[];
  83586. }
  83587. /** @hidden */
  83588. const enum IMSFTAudioEmitter_AudioMimeType {
  83589. WAV = "audio/wav",
  83590. }
  83591. /** @hidden */
  83592. interface IMSFTAudioEmitter_Clip extends IProperty {
  83593. uri?: string;
  83594. bufferView?: number;
  83595. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  83596. }
  83597. /** @hidden */
  83598. const enum IMSFTAudioEmitter_AnimationEventAction {
  83599. play = "play",
  83600. pause = "pause",
  83601. stop = "stop",
  83602. }
  83603. /** @hidden */
  83604. interface IMSFTAudioEmitter_AnimationEvent {
  83605. action: IMSFTAudioEmitter_AnimationEventAction;
  83606. emitter: number;
  83607. time: number;
  83608. startOffset?: number;
  83609. }
  83610. /**
  83611. * Interfaces from the MSFT_lod extension
  83612. */
  83613. /** @hidden */
  83614. interface IMSFTLOD {
  83615. ids: number[];
  83616. }
  83617. }
  83618. declare module BABYLON {
  83619. /** @hidden */
  83620. export var cellPixelShader: {
  83621. name: string;
  83622. shader: string;
  83623. };
  83624. }
  83625. declare module BABYLON {
  83626. /** @hidden */
  83627. export var cellVertexShader: {
  83628. name: string;
  83629. shader: string;
  83630. };
  83631. }
  83632. declare module BABYLON {
  83633. export class CellMaterial extends BABYLON.PushMaterial {
  83634. private _diffuseTexture;
  83635. diffuseTexture: BABYLON.BaseTexture;
  83636. diffuseColor: BABYLON.Color3;
  83637. _computeHighLevel: boolean;
  83638. computeHighLevel: boolean;
  83639. private _disableLighting;
  83640. disableLighting: boolean;
  83641. private _maxSimultaneousLights;
  83642. maxSimultaneousLights: number;
  83643. constructor(name: string, scene: BABYLON.Scene);
  83644. needAlphaBlending(): boolean;
  83645. needAlphaTesting(): boolean;
  83646. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83647. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83648. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83649. getAnimatables(): BABYLON.IAnimatable[];
  83650. getActiveTextures(): BABYLON.BaseTexture[];
  83651. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83652. dispose(forceDisposeEffect?: boolean): void;
  83653. getClassName(): string;
  83654. clone(name: string): CellMaterial;
  83655. serialize(): any;
  83656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83657. }
  83658. }
  83659. declare module BABYLON {
  83660. export class CustomShaderStructure {
  83661. FragmentStore: string;
  83662. VertexStore: string;
  83663. constructor();
  83664. }
  83665. export class ShaderSpecialParts {
  83666. constructor();
  83667. Fragment_Begin: string;
  83668. Fragment_Definitions: string;
  83669. Fragment_MainBegin: string;
  83670. Fragment_Custom_Diffuse: string;
  83671. Fragment_Before_Lights: string;
  83672. Fragment_Before_Fog: string;
  83673. Fragment_Custom_Alpha: string;
  83674. Fragment_Before_FragColor: string;
  83675. Vertex_Begin: string;
  83676. Vertex_Definitions: string;
  83677. Vertex_MainBegin: string;
  83678. Vertex_Before_PositionUpdated: string;
  83679. Vertex_Before_NormalUpdated: string;
  83680. Vertex_After_WorldPosComputed: string;
  83681. Vertex_MainEnd: string;
  83682. }
  83683. export class CustomMaterial extends BABYLON.StandardMaterial {
  83684. static ShaderIndexer: number;
  83685. CustomParts: ShaderSpecialParts;
  83686. _isCreatedShader: boolean;
  83687. _createdShaderName: string;
  83688. _customUniform: string[];
  83689. _newUniforms: string[];
  83690. _newUniformInstances: {
  83691. [name: string]: any;
  83692. };
  83693. _newSamplerInstances: {
  83694. [name: string]: BABYLON.Texture;
  83695. };
  83696. _customAttributes: string[];
  83697. FragmentShader: string;
  83698. VertexShader: string;
  83699. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83700. ReviewUniform(name: string, arr: string[]): string[];
  83701. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83702. constructor(name: string, scene: BABYLON.Scene);
  83703. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  83704. AddAttribute(name: string): CustomMaterial;
  83705. Fragment_Begin(shaderPart: string): CustomMaterial;
  83706. Fragment_Definitions(shaderPart: string): CustomMaterial;
  83707. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  83708. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  83709. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  83710. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  83711. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  83712. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  83713. Vertex_Begin(shaderPart: string): CustomMaterial;
  83714. Vertex_Definitions(shaderPart: string): CustomMaterial;
  83715. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  83716. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  83717. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  83718. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  83719. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  83720. }
  83721. }
  83722. declare module BABYLON {
  83723. export class ShaderAlebdoParts {
  83724. constructor();
  83725. Fragment_Begin: string;
  83726. Fragment_Definitions: string;
  83727. Fragment_MainBegin: string;
  83728. Fragment_Custom_Albedo: string;
  83729. Fragment_Before_Lights: string;
  83730. Fragment_Custom_MetallicRoughness: string;
  83731. Fragment_Custom_MicroSurface: string;
  83732. Fragment_Before_Fog: string;
  83733. Fragment_Custom_Alpha: string;
  83734. Fragment_Before_FragColor: string;
  83735. Vertex_Begin: string;
  83736. Vertex_Definitions: string;
  83737. Vertex_MainBegin: string;
  83738. Vertex_Before_PositionUpdated: string;
  83739. Vertex_Before_NormalUpdated: string;
  83740. Vertex_After_WorldPosComputed: string;
  83741. Vertex_MainEnd: string;
  83742. }
  83743. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83744. static ShaderIndexer: number;
  83745. CustomParts: ShaderAlebdoParts;
  83746. _isCreatedShader: boolean;
  83747. _createdShaderName: string;
  83748. _customUniform: string[];
  83749. _newUniforms: string[];
  83750. _newUniformInstances: {
  83751. [name: string]: any;
  83752. };
  83753. _newSamplerInstances: {
  83754. [name: string]: BABYLON.Texture;
  83755. };
  83756. _customAttributes: string[];
  83757. FragmentShader: string;
  83758. VertexShader: string;
  83759. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83760. ReviewUniform(name: string, arr: string[]): string[];
  83761. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83762. constructor(name: string, scene: BABYLON.Scene);
  83763. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83764. AddAttribute(name: string): PBRCustomMaterial;
  83765. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83766. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83767. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83768. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83769. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83770. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83771. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83772. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83773. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83774. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83775. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83776. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83777. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83778. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83779. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83780. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83781. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83782. }
  83783. }
  83784. declare module BABYLON {
  83785. /** @hidden */
  83786. export var firePixelShader: {
  83787. name: string;
  83788. shader: string;
  83789. };
  83790. }
  83791. declare module BABYLON {
  83792. /** @hidden */
  83793. export var fireVertexShader: {
  83794. name: string;
  83795. shader: string;
  83796. };
  83797. }
  83798. declare module BABYLON {
  83799. export class FireMaterial extends BABYLON.PushMaterial {
  83800. private _diffuseTexture;
  83801. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83802. private _distortionTexture;
  83803. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83804. private _opacityTexture;
  83805. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83806. diffuseColor: BABYLON.Color3;
  83807. speed: number;
  83808. private _scaledDiffuse;
  83809. private _lastTime;
  83810. constructor(name: string, scene: BABYLON.Scene);
  83811. needAlphaBlending(): boolean;
  83812. needAlphaTesting(): boolean;
  83813. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83814. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83815. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83816. getAnimatables(): BABYLON.IAnimatable[];
  83817. getActiveTextures(): BABYLON.BaseTexture[];
  83818. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83819. getClassName(): string;
  83820. dispose(forceDisposeEffect?: boolean): void;
  83821. clone(name: string): FireMaterial;
  83822. serialize(): any;
  83823. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83824. }
  83825. }
  83826. declare module BABYLON {
  83827. /** @hidden */
  83828. export var furPixelShader: {
  83829. name: string;
  83830. shader: string;
  83831. };
  83832. }
  83833. declare module BABYLON {
  83834. /** @hidden */
  83835. export var furVertexShader: {
  83836. name: string;
  83837. shader: string;
  83838. };
  83839. }
  83840. declare module BABYLON {
  83841. export class FurMaterial extends BABYLON.PushMaterial {
  83842. private _diffuseTexture;
  83843. diffuseTexture: BABYLON.BaseTexture;
  83844. private _heightTexture;
  83845. heightTexture: BABYLON.BaseTexture;
  83846. diffuseColor: BABYLON.Color3;
  83847. furLength: number;
  83848. furAngle: number;
  83849. furColor: BABYLON.Color3;
  83850. furOffset: number;
  83851. furSpacing: number;
  83852. furGravity: BABYLON.Vector3;
  83853. furSpeed: number;
  83854. furDensity: number;
  83855. furOcclusion: number;
  83856. furTexture: BABYLON.DynamicTexture;
  83857. private _disableLighting;
  83858. disableLighting: boolean;
  83859. private _maxSimultaneousLights;
  83860. maxSimultaneousLights: number;
  83861. highLevelFur: boolean;
  83862. _meshes: BABYLON.AbstractMesh[];
  83863. private _furTime;
  83864. constructor(name: string, scene: BABYLON.Scene);
  83865. get furTime(): number;
  83866. set furTime(furTime: number);
  83867. needAlphaBlending(): boolean;
  83868. needAlphaTesting(): boolean;
  83869. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83870. updateFur(): void;
  83871. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83872. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83873. getAnimatables(): BABYLON.IAnimatable[];
  83874. getActiveTextures(): BABYLON.BaseTexture[];
  83875. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83876. dispose(forceDisposeEffect?: boolean): void;
  83877. clone(name: string): FurMaterial;
  83878. serialize(): any;
  83879. getClassName(): string;
  83880. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83881. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83882. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83883. }
  83884. }
  83885. declare module BABYLON {
  83886. /** @hidden */
  83887. export var gradientPixelShader: {
  83888. name: string;
  83889. shader: string;
  83890. };
  83891. }
  83892. declare module BABYLON {
  83893. /** @hidden */
  83894. export var gradientVertexShader: {
  83895. name: string;
  83896. shader: string;
  83897. };
  83898. }
  83899. declare module BABYLON {
  83900. export class GradientMaterial extends BABYLON.PushMaterial {
  83901. private _maxSimultaneousLights;
  83902. maxSimultaneousLights: number;
  83903. topColor: BABYLON.Color3;
  83904. topColorAlpha: number;
  83905. bottomColor: BABYLON.Color3;
  83906. bottomColorAlpha: number;
  83907. offset: number;
  83908. scale: number;
  83909. smoothness: number;
  83910. private _disableLighting;
  83911. disableLighting: boolean;
  83912. constructor(name: string, scene: BABYLON.Scene);
  83913. needAlphaBlending(): boolean;
  83914. needAlphaTesting(): boolean;
  83915. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83916. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83917. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83918. getAnimatables(): BABYLON.IAnimatable[];
  83919. dispose(forceDisposeEffect?: boolean): void;
  83920. clone(name: string): GradientMaterial;
  83921. serialize(): any;
  83922. getClassName(): string;
  83923. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83924. }
  83925. }
  83926. declare module BABYLON {
  83927. /** @hidden */
  83928. export var gridPixelShader: {
  83929. name: string;
  83930. shader: string;
  83931. };
  83932. }
  83933. declare module BABYLON {
  83934. /** @hidden */
  83935. export var gridVertexShader: {
  83936. name: string;
  83937. shader: string;
  83938. };
  83939. }
  83940. declare module BABYLON {
  83941. /**
  83942. * The grid materials allows you to wrap any shape with a grid.
  83943. * Colors are customizable.
  83944. */
  83945. export class GridMaterial extends BABYLON.PushMaterial {
  83946. /**
  83947. * Main color of the grid (e.g. between lines)
  83948. */
  83949. mainColor: BABYLON.Color3;
  83950. /**
  83951. * Color of the grid lines.
  83952. */
  83953. lineColor: BABYLON.Color3;
  83954. /**
  83955. * The scale of the grid compared to unit.
  83956. */
  83957. gridRatio: number;
  83958. /**
  83959. * Allows setting an offset for the grid lines.
  83960. */
  83961. gridOffset: BABYLON.Vector3;
  83962. /**
  83963. * The frequency of thicker lines.
  83964. */
  83965. majorUnitFrequency: number;
  83966. /**
  83967. * The visibility of minor units in the grid.
  83968. */
  83969. minorUnitVisibility: number;
  83970. /**
  83971. * The grid opacity outside of the lines.
  83972. */
  83973. opacity: number;
  83974. /**
  83975. * Determine RBG output is premultiplied by alpha value.
  83976. */
  83977. preMultiplyAlpha: boolean;
  83978. private _opacityTexture;
  83979. opacityTexture: BABYLON.BaseTexture;
  83980. private _gridControl;
  83981. /**
  83982. * constructor
  83983. * @param name The name given to the material in order to identify it afterwards.
  83984. * @param scene The scene the material is used in.
  83985. */
  83986. constructor(name: string, scene: BABYLON.Scene);
  83987. /**
  83988. * Returns wehter or not the grid requires alpha blending.
  83989. */
  83990. needAlphaBlending(): boolean;
  83991. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83993. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83994. /**
  83995. * Dispose the material and its associated resources.
  83996. * @param forceDisposeEffect will also dispose the used effect when true
  83997. */
  83998. dispose(forceDisposeEffect?: boolean): void;
  83999. clone(name: string): GridMaterial;
  84000. serialize(): any;
  84001. getClassName(): string;
  84002. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84003. }
  84004. }
  84005. declare module BABYLON {
  84006. /** @hidden */
  84007. export var lavaPixelShader: {
  84008. name: string;
  84009. shader: string;
  84010. };
  84011. }
  84012. declare module BABYLON {
  84013. /** @hidden */
  84014. export var lavaVertexShader: {
  84015. name: string;
  84016. shader: string;
  84017. };
  84018. }
  84019. declare module BABYLON {
  84020. export class LavaMaterial extends BABYLON.PushMaterial {
  84021. private _diffuseTexture;
  84022. diffuseTexture: BABYLON.BaseTexture;
  84023. noiseTexture: BABYLON.BaseTexture;
  84024. fogColor: BABYLON.Color3;
  84025. speed: number;
  84026. movingSpeed: number;
  84027. lowFrequencySpeed: number;
  84028. fogDensity: number;
  84029. private _lastTime;
  84030. diffuseColor: BABYLON.Color3;
  84031. private _disableLighting;
  84032. disableLighting: boolean;
  84033. private _unlit;
  84034. unlit: boolean;
  84035. private _maxSimultaneousLights;
  84036. maxSimultaneousLights: number;
  84037. private _scaledDiffuse;
  84038. constructor(name: string, scene: BABYLON.Scene);
  84039. needAlphaBlending(): boolean;
  84040. needAlphaTesting(): boolean;
  84041. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84042. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84043. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84044. getAnimatables(): BABYLON.IAnimatable[];
  84045. getActiveTextures(): BABYLON.BaseTexture[];
  84046. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84047. dispose(forceDisposeEffect?: boolean): void;
  84048. clone(name: string): LavaMaterial;
  84049. serialize(): any;
  84050. getClassName(): string;
  84051. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84052. }
  84053. }
  84054. declare module BABYLON {
  84055. /** @hidden */
  84056. export var mixPixelShader: {
  84057. name: string;
  84058. shader: string;
  84059. };
  84060. }
  84061. declare module BABYLON {
  84062. /** @hidden */
  84063. export var mixVertexShader: {
  84064. name: string;
  84065. shader: string;
  84066. };
  84067. }
  84068. declare module BABYLON {
  84069. export class MixMaterial extends BABYLON.PushMaterial {
  84070. /**
  84071. * Mix textures
  84072. */
  84073. private _mixTexture1;
  84074. mixTexture1: BABYLON.BaseTexture;
  84075. private _mixTexture2;
  84076. mixTexture2: BABYLON.BaseTexture;
  84077. /**
  84078. * Diffuse textures
  84079. */
  84080. private _diffuseTexture1;
  84081. diffuseTexture1: BABYLON.Texture;
  84082. private _diffuseTexture2;
  84083. diffuseTexture2: BABYLON.Texture;
  84084. private _diffuseTexture3;
  84085. diffuseTexture3: BABYLON.Texture;
  84086. private _diffuseTexture4;
  84087. diffuseTexture4: BABYLON.Texture;
  84088. private _diffuseTexture5;
  84089. diffuseTexture5: BABYLON.Texture;
  84090. private _diffuseTexture6;
  84091. diffuseTexture6: BABYLON.Texture;
  84092. private _diffuseTexture7;
  84093. diffuseTexture7: BABYLON.Texture;
  84094. private _diffuseTexture8;
  84095. diffuseTexture8: BABYLON.Texture;
  84096. /**
  84097. * Uniforms
  84098. */
  84099. diffuseColor: BABYLON.Color3;
  84100. specularColor: BABYLON.Color3;
  84101. specularPower: number;
  84102. private _disableLighting;
  84103. disableLighting: boolean;
  84104. private _maxSimultaneousLights;
  84105. maxSimultaneousLights: number;
  84106. constructor(name: string, scene: BABYLON.Scene);
  84107. needAlphaBlending(): boolean;
  84108. needAlphaTesting(): boolean;
  84109. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84110. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84111. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84112. getAnimatables(): BABYLON.IAnimatable[];
  84113. getActiveTextures(): BABYLON.BaseTexture[];
  84114. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84115. dispose(forceDisposeEffect?: boolean): void;
  84116. clone(name: string): MixMaterial;
  84117. serialize(): any;
  84118. getClassName(): string;
  84119. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84120. }
  84121. }
  84122. declare module BABYLON {
  84123. /** @hidden */
  84124. export var normalPixelShader: {
  84125. name: string;
  84126. shader: string;
  84127. };
  84128. }
  84129. declare module BABYLON {
  84130. /** @hidden */
  84131. export var normalVertexShader: {
  84132. name: string;
  84133. shader: string;
  84134. };
  84135. }
  84136. declare module BABYLON {
  84137. export class NormalMaterial extends BABYLON.PushMaterial {
  84138. private _diffuseTexture;
  84139. diffuseTexture: BABYLON.BaseTexture;
  84140. diffuseColor: BABYLON.Color3;
  84141. private _disableLighting;
  84142. disableLighting: boolean;
  84143. private _maxSimultaneousLights;
  84144. maxSimultaneousLights: number;
  84145. constructor(name: string, scene: BABYLON.Scene);
  84146. needAlphaBlending(): boolean;
  84147. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84148. needAlphaTesting(): boolean;
  84149. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84150. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84152. getAnimatables(): BABYLON.IAnimatable[];
  84153. getActiveTextures(): BABYLON.BaseTexture[];
  84154. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84155. dispose(forceDisposeEffect?: boolean): void;
  84156. clone(name: string): NormalMaterial;
  84157. serialize(): any;
  84158. getClassName(): string;
  84159. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84160. }
  84161. }
  84162. declare module BABYLON {
  84163. /** @hidden */
  84164. export var shadowOnlyPixelShader: {
  84165. name: string;
  84166. shader: string;
  84167. };
  84168. }
  84169. declare module BABYLON {
  84170. /** @hidden */
  84171. export var shadowOnlyVertexShader: {
  84172. name: string;
  84173. shader: string;
  84174. };
  84175. }
  84176. declare module BABYLON {
  84177. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84178. private _activeLight;
  84179. private _needAlphaBlending;
  84180. constructor(name: string, scene: BABYLON.Scene);
  84181. shadowColor: BABYLON.Color3;
  84182. needAlphaBlending(): boolean;
  84183. needAlphaTesting(): boolean;
  84184. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84185. get activeLight(): BABYLON.IShadowLight;
  84186. set activeLight(light: BABYLON.IShadowLight);
  84187. private _getFirstShadowLightForMesh;
  84188. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84189. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84190. clone(name: string): ShadowOnlyMaterial;
  84191. serialize(): any;
  84192. getClassName(): string;
  84193. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84194. }
  84195. }
  84196. declare module BABYLON {
  84197. /** @hidden */
  84198. export var simplePixelShader: {
  84199. name: string;
  84200. shader: string;
  84201. };
  84202. }
  84203. declare module BABYLON {
  84204. /** @hidden */
  84205. export var simpleVertexShader: {
  84206. name: string;
  84207. shader: string;
  84208. };
  84209. }
  84210. declare module BABYLON {
  84211. export class SimpleMaterial extends BABYLON.PushMaterial {
  84212. private _diffuseTexture;
  84213. diffuseTexture: BABYLON.BaseTexture;
  84214. diffuseColor: BABYLON.Color3;
  84215. private _disableLighting;
  84216. disableLighting: boolean;
  84217. private _maxSimultaneousLights;
  84218. maxSimultaneousLights: number;
  84219. constructor(name: string, scene: BABYLON.Scene);
  84220. needAlphaBlending(): boolean;
  84221. needAlphaTesting(): boolean;
  84222. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84223. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84224. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84225. getAnimatables(): BABYLON.IAnimatable[];
  84226. getActiveTextures(): BABYLON.BaseTexture[];
  84227. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84228. dispose(forceDisposeEffect?: boolean): void;
  84229. clone(name: string): SimpleMaterial;
  84230. serialize(): any;
  84231. getClassName(): string;
  84232. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84233. }
  84234. }
  84235. declare module BABYLON {
  84236. /** @hidden */
  84237. export var skyPixelShader: {
  84238. name: string;
  84239. shader: string;
  84240. };
  84241. }
  84242. declare module BABYLON {
  84243. /** @hidden */
  84244. export var skyVertexShader: {
  84245. name: string;
  84246. shader: string;
  84247. };
  84248. }
  84249. declare module BABYLON {
  84250. /**
  84251. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84252. * @see https://doc.babylonjs.com/extensions/sky
  84253. */
  84254. export class SkyMaterial extends BABYLON.PushMaterial {
  84255. /**
  84256. * Defines the overall luminance of sky in interval ]0, 1[.
  84257. */
  84258. luminance: number;
  84259. /**
  84260. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84261. */
  84262. turbidity: number;
  84263. /**
  84264. * Defines the sky appearance (light intensity).
  84265. */
  84266. rayleigh: number;
  84267. /**
  84268. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84269. */
  84270. mieCoefficient: number;
  84271. /**
  84272. * Defines the amount of haze particles following the Mie scattering theory.
  84273. */
  84274. mieDirectionalG: number;
  84275. /**
  84276. * Defines the distance of the sun according to the active scene camera.
  84277. */
  84278. distance: number;
  84279. /**
  84280. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84281. * "inclined".
  84282. */
  84283. inclination: number;
  84284. /**
  84285. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84286. * an object direction and a reference direction.
  84287. */
  84288. azimuth: number;
  84289. /**
  84290. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84291. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84292. */
  84293. sunPosition: BABYLON.Vector3;
  84294. /**
  84295. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84296. * .sunPosition property.
  84297. */
  84298. useSunPosition: boolean;
  84299. /**
  84300. * Defines an offset vector used to get a horizon offset.
  84301. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84302. */
  84303. cameraOffset: BABYLON.Vector3;
  84304. private _cameraPosition;
  84305. /**
  84306. * Instantiates a new sky material.
  84307. * This material allows to create dynamic and texture free
  84308. * effects for skyboxes by taking care of the atmosphere state.
  84309. * @see https://doc.babylonjs.com/extensions/sky
  84310. * @param name Define the name of the material in the scene
  84311. * @param scene Define the scene the material belong to
  84312. */
  84313. constructor(name: string, scene: BABYLON.Scene);
  84314. /**
  84315. * Specifies if the material will require alpha blending
  84316. * @returns a boolean specifying if alpha blending is needed
  84317. */
  84318. needAlphaBlending(): boolean;
  84319. /**
  84320. * Specifies if this material should be rendered in alpha test mode
  84321. * @returns false as the sky material doesn't need alpha testing.
  84322. */
  84323. needAlphaTesting(): boolean;
  84324. /**
  84325. * Get the texture used for alpha test purpose.
  84326. * @returns null as the sky material has no texture.
  84327. */
  84328. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84329. /**
  84330. * Get if the submesh is ready to be used and all its information available.
  84331. * Child classes can use it to update shaders
  84332. * @param mesh defines the mesh to check
  84333. * @param subMesh defines which submesh to check
  84334. * @param useInstances specifies that instances should be used
  84335. * @returns a boolean indicating that the submesh is ready or not
  84336. */
  84337. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84338. /**
  84339. * Binds the submesh to this material by preparing the effect and shader to draw
  84340. * @param world defines the world transformation matrix
  84341. * @param mesh defines the mesh containing the submesh
  84342. * @param subMesh defines the submesh to bind the material to
  84343. */
  84344. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84345. /**
  84346. * Get the list of animatables in the material.
  84347. * @returns the list of animatables object used in the material
  84348. */
  84349. getAnimatables(): BABYLON.IAnimatable[];
  84350. /**
  84351. * Disposes the material
  84352. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84353. */
  84354. dispose(forceDisposeEffect?: boolean): void;
  84355. /**
  84356. * Makes a duplicate of the material, and gives it a new name
  84357. * @param name defines the new name for the duplicated material
  84358. * @returns the cloned material
  84359. */
  84360. clone(name: string): SkyMaterial;
  84361. /**
  84362. * Serializes this material in a JSON representation
  84363. * @returns the serialized material object
  84364. */
  84365. serialize(): any;
  84366. /**
  84367. * Gets the current class name of the material e.g. "SkyMaterial"
  84368. * Mainly use in serialization.
  84369. * @returns the class name
  84370. */
  84371. getClassName(): string;
  84372. /**
  84373. * Creates a sky material from parsed material data
  84374. * @param source defines the JSON representation of the material
  84375. * @param scene defines the hosting scene
  84376. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84377. * @returns a new sky material
  84378. */
  84379. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84380. }
  84381. }
  84382. declare module BABYLON {
  84383. /** @hidden */
  84384. export var terrainPixelShader: {
  84385. name: string;
  84386. shader: string;
  84387. };
  84388. }
  84389. declare module BABYLON {
  84390. /** @hidden */
  84391. export var terrainVertexShader: {
  84392. name: string;
  84393. shader: string;
  84394. };
  84395. }
  84396. declare module BABYLON {
  84397. export class TerrainMaterial extends BABYLON.PushMaterial {
  84398. private _mixTexture;
  84399. mixTexture: BABYLON.BaseTexture;
  84400. private _diffuseTexture1;
  84401. diffuseTexture1: BABYLON.Texture;
  84402. private _diffuseTexture2;
  84403. diffuseTexture2: BABYLON.Texture;
  84404. private _diffuseTexture3;
  84405. diffuseTexture3: BABYLON.Texture;
  84406. private _bumpTexture1;
  84407. bumpTexture1: BABYLON.Texture;
  84408. private _bumpTexture2;
  84409. bumpTexture2: BABYLON.Texture;
  84410. private _bumpTexture3;
  84411. bumpTexture3: BABYLON.Texture;
  84412. diffuseColor: BABYLON.Color3;
  84413. specularColor: BABYLON.Color3;
  84414. specularPower: number;
  84415. private _disableLighting;
  84416. disableLighting: boolean;
  84417. private _maxSimultaneousLights;
  84418. maxSimultaneousLights: number;
  84419. constructor(name: string, scene: BABYLON.Scene);
  84420. needAlphaBlending(): boolean;
  84421. needAlphaTesting(): boolean;
  84422. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84423. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84424. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84425. getAnimatables(): BABYLON.IAnimatable[];
  84426. getActiveTextures(): BABYLON.BaseTexture[];
  84427. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84428. dispose(forceDisposeEffect?: boolean): void;
  84429. clone(name: string): TerrainMaterial;
  84430. serialize(): any;
  84431. getClassName(): string;
  84432. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84433. }
  84434. }
  84435. declare module BABYLON {
  84436. /** @hidden */
  84437. export var triplanarPixelShader: {
  84438. name: string;
  84439. shader: string;
  84440. };
  84441. }
  84442. declare module BABYLON {
  84443. /** @hidden */
  84444. export var triplanarVertexShader: {
  84445. name: string;
  84446. shader: string;
  84447. };
  84448. }
  84449. declare module BABYLON {
  84450. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84451. mixTexture: BABYLON.BaseTexture;
  84452. private _diffuseTextureX;
  84453. diffuseTextureX: BABYLON.BaseTexture;
  84454. private _diffuseTextureY;
  84455. diffuseTextureY: BABYLON.BaseTexture;
  84456. private _diffuseTextureZ;
  84457. diffuseTextureZ: BABYLON.BaseTexture;
  84458. private _normalTextureX;
  84459. normalTextureX: BABYLON.BaseTexture;
  84460. private _normalTextureY;
  84461. normalTextureY: BABYLON.BaseTexture;
  84462. private _normalTextureZ;
  84463. normalTextureZ: BABYLON.BaseTexture;
  84464. tileSize: number;
  84465. diffuseColor: BABYLON.Color3;
  84466. specularColor: BABYLON.Color3;
  84467. specularPower: number;
  84468. private _disableLighting;
  84469. disableLighting: boolean;
  84470. private _maxSimultaneousLights;
  84471. maxSimultaneousLights: number;
  84472. constructor(name: string, scene: BABYLON.Scene);
  84473. needAlphaBlending(): boolean;
  84474. needAlphaTesting(): boolean;
  84475. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84476. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84477. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84478. getAnimatables(): BABYLON.IAnimatable[];
  84479. getActiveTextures(): BABYLON.BaseTexture[];
  84480. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84481. dispose(forceDisposeEffect?: boolean): void;
  84482. clone(name: string): TriPlanarMaterial;
  84483. serialize(): any;
  84484. getClassName(): string;
  84485. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84486. }
  84487. }
  84488. declare module BABYLON {
  84489. /** @hidden */
  84490. export var waterPixelShader: {
  84491. name: string;
  84492. shader: string;
  84493. };
  84494. }
  84495. declare module BABYLON {
  84496. /** @hidden */
  84497. export var waterVertexShader: {
  84498. name: string;
  84499. shader: string;
  84500. };
  84501. }
  84502. declare module BABYLON {
  84503. export class WaterMaterial extends BABYLON.PushMaterial {
  84504. renderTargetSize: BABYLON.Vector2;
  84505. private _bumpTexture;
  84506. bumpTexture: BABYLON.BaseTexture;
  84507. diffuseColor: BABYLON.Color3;
  84508. specularColor: BABYLON.Color3;
  84509. specularPower: number;
  84510. private _disableLighting;
  84511. disableLighting: boolean;
  84512. private _maxSimultaneousLights;
  84513. maxSimultaneousLights: number;
  84514. /**
  84515. * @param {number}: Represents the wind force
  84516. */
  84517. windForce: number;
  84518. /**
  84519. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84520. */
  84521. windDirection: BABYLON.Vector2;
  84522. /**
  84523. * @param {number}: Wave height, represents the height of the waves
  84524. */
  84525. waveHeight: number;
  84526. /**
  84527. * @param {number}: Bump height, represents the bump height related to the bump map
  84528. */
  84529. bumpHeight: number;
  84530. /**
  84531. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84532. */
  84533. private _bumpSuperimpose;
  84534. bumpSuperimpose: boolean;
  84535. /**
  84536. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84537. */
  84538. private _fresnelSeparate;
  84539. fresnelSeparate: boolean;
  84540. /**
  84541. * @param {boolean}: bump Waves modify the reflection.
  84542. */
  84543. private _bumpAffectsReflection;
  84544. bumpAffectsReflection: boolean;
  84545. /**
  84546. * @param {number}: The water color blended with the refraction (near)
  84547. */
  84548. waterColor: BABYLON.Color3;
  84549. /**
  84550. * @param {number}: The blend factor related to the water color
  84551. */
  84552. colorBlendFactor: number;
  84553. /**
  84554. * @param {number}: The water color blended with the reflection (far)
  84555. */
  84556. waterColor2: BABYLON.Color3;
  84557. /**
  84558. * @param {number}: The blend factor related to the water color (reflection, far)
  84559. */
  84560. colorBlendFactor2: number;
  84561. /**
  84562. * @param {number}: Represents the maximum length of a wave
  84563. */
  84564. waveLength: number;
  84565. /**
  84566. * @param {number}: Defines the waves speed
  84567. */
  84568. waveSpeed: number;
  84569. /**
  84570. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84571. * will avoid calculating useless pixels in the pixel shader of the water material.
  84572. */
  84573. disableClipPlane: boolean;
  84574. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84575. private _mesh;
  84576. private _refractionRTT;
  84577. private _reflectionRTT;
  84578. private _reflectionTransform;
  84579. private _lastTime;
  84580. private _lastDeltaTime;
  84581. private _useLogarithmicDepth;
  84582. private _waitingRenderList;
  84583. private _imageProcessingConfiguration;
  84584. private _imageProcessingObserver;
  84585. /**
  84586. * Gets a boolean indicating that current material needs to register RTT
  84587. */
  84588. get hasRenderTargetTextures(): boolean;
  84589. /**
  84590. * Constructor
  84591. */
  84592. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84593. get useLogarithmicDepth(): boolean;
  84594. set useLogarithmicDepth(value: boolean);
  84595. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84596. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84597. addToRenderList(node: any): void;
  84598. enableRenderTargets(enable: boolean): void;
  84599. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84600. get renderTargetsEnabled(): boolean;
  84601. needAlphaBlending(): boolean;
  84602. needAlphaTesting(): boolean;
  84603. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84604. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84605. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84606. private _createRenderTargets;
  84607. getAnimatables(): BABYLON.IAnimatable[];
  84608. getActiveTextures(): BABYLON.BaseTexture[];
  84609. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84610. dispose(forceDisposeEffect?: boolean): void;
  84611. clone(name: string): WaterMaterial;
  84612. serialize(): any;
  84613. getClassName(): string;
  84614. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84615. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84616. }
  84617. }
  84618. declare module BABYLON {
  84619. /** @hidden */
  84620. export var asciiartPixelShader: {
  84621. name: string;
  84622. shader: string;
  84623. };
  84624. }
  84625. declare module BABYLON {
  84626. /**
  84627. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84628. *
  84629. * It basically takes care rendering the font front the given font size to a texture.
  84630. * This is used later on in the postprocess.
  84631. */
  84632. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84633. private _font;
  84634. private _text;
  84635. private _charSize;
  84636. /**
  84637. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84638. */
  84639. get charSize(): number;
  84640. /**
  84641. * Create a new instance of the Ascii Art FontTexture class
  84642. * @param name the name of the texture
  84643. * @param font the font to use, use the W3C CSS notation
  84644. * @param text the caracter set to use in the rendering.
  84645. * @param scene the scene that owns the texture
  84646. */
  84647. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84648. /**
  84649. * Gets the max char width of a font.
  84650. * @param font the font to use, use the W3C CSS notation
  84651. * @return the max char width
  84652. */
  84653. private getFontWidth;
  84654. /**
  84655. * Gets the max char height of a font.
  84656. * @param font the font to use, use the W3C CSS notation
  84657. * @return the max char height
  84658. */
  84659. private getFontHeight;
  84660. /**
  84661. * Clones the current AsciiArtTexture.
  84662. * @return the clone of the texture.
  84663. */
  84664. clone(): AsciiArtFontTexture;
  84665. /**
  84666. * Parses a json object representing the texture and returns an instance of it.
  84667. * @param source the source JSON representation
  84668. * @param scene the scene to create the texture for
  84669. * @return the parsed texture
  84670. */
  84671. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84672. }
  84673. /**
  84674. * Option available in the Ascii Art Post Process.
  84675. */
  84676. export interface IAsciiArtPostProcessOptions {
  84677. /**
  84678. * The font to use following the w3c font definition.
  84679. */
  84680. font?: string;
  84681. /**
  84682. * The character set to use in the postprocess.
  84683. */
  84684. characterSet?: string;
  84685. /**
  84686. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84687. * This number is defined between 0 and 1;
  84688. */
  84689. mixToTile?: number;
  84690. /**
  84691. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84692. * This number is defined between 0 and 1;
  84693. */
  84694. mixToNormal?: number;
  84695. }
  84696. /**
  84697. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  84698. *
  84699. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84700. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  84701. */
  84702. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  84703. /**
  84704. * The font texture used to render the char in the post process.
  84705. */
  84706. private _asciiArtFontTexture;
  84707. /**
  84708. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84709. * This number is defined between 0 and 1;
  84710. */
  84711. mixToTile: number;
  84712. /**
  84713. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84714. * This number is defined between 0 and 1;
  84715. */
  84716. mixToNormal: number;
  84717. /**
  84718. * Instantiates a new Ascii Art Post Process.
  84719. * @param name the name to give to the postprocess
  84720. * @camera the camera to apply the post process to.
  84721. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  84722. */
  84723. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  84724. }
  84725. }
  84726. declare module BABYLON {
  84727. /** @hidden */
  84728. export var digitalrainPixelShader: {
  84729. name: string;
  84730. shader: string;
  84731. };
  84732. }
  84733. declare module BABYLON {
  84734. /**
  84735. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84736. *
  84737. * It basically takes care rendering the font front the given font size to a texture.
  84738. * This is used later on in the postprocess.
  84739. */
  84740. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84741. private _font;
  84742. private _text;
  84743. private _charSize;
  84744. /**
  84745. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84746. */
  84747. get charSize(): number;
  84748. /**
  84749. * Create a new instance of the Digital Rain FontTexture class
  84750. * @param name the name of the texture
  84751. * @param font the font to use, use the W3C CSS notation
  84752. * @param text the caracter set to use in the rendering.
  84753. * @param scene the scene that owns the texture
  84754. */
  84755. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84756. /**
  84757. * Gets the max char width of a font.
  84758. * @param font the font to use, use the W3C CSS notation
  84759. * @return the max char width
  84760. */
  84761. private getFontWidth;
  84762. /**
  84763. * Gets the max char height of a font.
  84764. * @param font the font to use, use the W3C CSS notation
  84765. * @return the max char height
  84766. */
  84767. private getFontHeight;
  84768. /**
  84769. * Clones the current DigitalRainFontTexture.
  84770. * @return the clone of the texture.
  84771. */
  84772. clone(): DigitalRainFontTexture;
  84773. /**
  84774. * Parses a json object representing the texture and returns an instance of it.
  84775. * @param source the source JSON representation
  84776. * @param scene the scene to create the texture for
  84777. * @return the parsed texture
  84778. */
  84779. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84780. }
  84781. /**
  84782. * Option available in the Digital Rain Post Process.
  84783. */
  84784. export interface IDigitalRainPostProcessOptions {
  84785. /**
  84786. * The font to use following the w3c font definition.
  84787. */
  84788. font?: string;
  84789. /**
  84790. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84791. * This number is defined between 0 and 1;
  84792. */
  84793. mixToTile?: number;
  84794. /**
  84795. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84796. * This number is defined between 0 and 1;
  84797. */
  84798. mixToNormal?: number;
  84799. }
  84800. /**
  84801. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84802. *
  84803. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84804. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84805. */
  84806. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84807. /**
  84808. * The font texture used to render the char in the post process.
  84809. */
  84810. private _digitalRainFontTexture;
  84811. /**
  84812. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84813. * This number is defined between 0 and 1;
  84814. */
  84815. mixToTile: number;
  84816. /**
  84817. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84818. * This number is defined between 0 and 1;
  84819. */
  84820. mixToNormal: number;
  84821. /**
  84822. * Instantiates a new Digital Rain Post Process.
  84823. * @param name the name to give to the postprocess
  84824. * @camera the camera to apply the post process to.
  84825. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84826. */
  84827. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84828. }
  84829. }
  84830. declare module BABYLON {
  84831. /** @hidden */
  84832. export var brickProceduralTexturePixelShader: {
  84833. name: string;
  84834. shader: string;
  84835. };
  84836. }
  84837. declare module BABYLON {
  84838. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84839. private _numberOfBricksHeight;
  84840. private _numberOfBricksWidth;
  84841. private _jointColor;
  84842. private _brickColor;
  84843. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84844. updateShaderUniforms(): void;
  84845. get numberOfBricksHeight(): number;
  84846. set numberOfBricksHeight(value: number);
  84847. get numberOfBricksWidth(): number;
  84848. set numberOfBricksWidth(value: number);
  84849. get jointColor(): BABYLON.Color3;
  84850. set jointColor(value: BABYLON.Color3);
  84851. get brickColor(): BABYLON.Color3;
  84852. set brickColor(value: BABYLON.Color3);
  84853. /**
  84854. * Serializes this brick procedural texture
  84855. * @returns a serialized brick procedural texture object
  84856. */
  84857. serialize(): any;
  84858. /**
  84859. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84860. * @param parsedTexture defines parsed texture data
  84861. * @param scene defines the current scene
  84862. * @param rootUrl defines the root URL containing brick procedural texture information
  84863. * @returns a parsed Brick Procedural BABYLON.Texture
  84864. */
  84865. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84866. }
  84867. }
  84868. declare module BABYLON {
  84869. /** @hidden */
  84870. export var cloudProceduralTexturePixelShader: {
  84871. name: string;
  84872. shader: string;
  84873. };
  84874. }
  84875. declare module BABYLON {
  84876. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84877. private _skyColor;
  84878. private _cloudColor;
  84879. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84880. updateShaderUniforms(): void;
  84881. get skyColor(): BABYLON.Color4;
  84882. set skyColor(value: BABYLON.Color4);
  84883. get cloudColor(): BABYLON.Color4;
  84884. set cloudColor(value: BABYLON.Color4);
  84885. /**
  84886. * Serializes this cloud procedural texture
  84887. * @returns a serialized cloud procedural texture object
  84888. */
  84889. serialize(): any;
  84890. /**
  84891. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84892. * @param parsedTexture defines parsed texture data
  84893. * @param scene defines the current scene
  84894. * @param rootUrl defines the root URL containing cloud procedural texture information
  84895. * @returns a parsed Cloud Procedural BABYLON.Texture
  84896. */
  84897. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84898. }
  84899. }
  84900. declare module BABYLON {
  84901. /** @hidden */
  84902. export var fireProceduralTexturePixelShader: {
  84903. name: string;
  84904. shader: string;
  84905. };
  84906. }
  84907. declare module BABYLON {
  84908. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84909. private _time;
  84910. private _speed;
  84911. private _autoGenerateTime;
  84912. private _fireColors;
  84913. private _alphaThreshold;
  84914. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84915. updateShaderUniforms(): void;
  84916. render(useCameraPostProcess?: boolean): void;
  84917. static get PurpleFireColors(): BABYLON.Color3[];
  84918. static get GreenFireColors(): BABYLON.Color3[];
  84919. static get RedFireColors(): BABYLON.Color3[];
  84920. static get BlueFireColors(): BABYLON.Color3[];
  84921. get autoGenerateTime(): boolean;
  84922. set autoGenerateTime(value: boolean);
  84923. get fireColors(): BABYLON.Color3[];
  84924. set fireColors(value: BABYLON.Color3[]);
  84925. get time(): number;
  84926. set time(value: number);
  84927. get speed(): BABYLON.Vector2;
  84928. set speed(value: BABYLON.Vector2);
  84929. get alphaThreshold(): number;
  84930. set alphaThreshold(value: number);
  84931. /**
  84932. * Serializes this fire procedural texture
  84933. * @returns a serialized fire procedural texture object
  84934. */
  84935. serialize(): any;
  84936. /**
  84937. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84938. * @param parsedTexture defines parsed texture data
  84939. * @param scene defines the current scene
  84940. * @param rootUrl defines the root URL containing fire procedural texture information
  84941. * @returns a parsed Fire Procedural BABYLON.Texture
  84942. */
  84943. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84944. }
  84945. }
  84946. declare module BABYLON {
  84947. /** @hidden */
  84948. export var grassProceduralTexturePixelShader: {
  84949. name: string;
  84950. shader: string;
  84951. };
  84952. }
  84953. declare module BABYLON {
  84954. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84955. private _grassColors;
  84956. private _groundColor;
  84957. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84958. updateShaderUniforms(): void;
  84959. get grassColors(): BABYLON.Color3[];
  84960. set grassColors(value: BABYLON.Color3[]);
  84961. get groundColor(): BABYLON.Color3;
  84962. set groundColor(value: BABYLON.Color3);
  84963. /**
  84964. * Serializes this grass procedural texture
  84965. * @returns a serialized grass procedural texture object
  84966. */
  84967. serialize(): any;
  84968. /**
  84969. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84970. * @param parsedTexture defines parsed texture data
  84971. * @param scene defines the current scene
  84972. * @param rootUrl defines the root URL containing grass procedural texture information
  84973. * @returns a parsed Grass Procedural BABYLON.Texture
  84974. */
  84975. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84976. }
  84977. }
  84978. declare module BABYLON {
  84979. /** @hidden */
  84980. export var marbleProceduralTexturePixelShader: {
  84981. name: string;
  84982. shader: string;
  84983. };
  84984. }
  84985. declare module BABYLON {
  84986. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84987. private _numberOfTilesHeight;
  84988. private _numberOfTilesWidth;
  84989. private _amplitude;
  84990. private _jointColor;
  84991. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84992. updateShaderUniforms(): void;
  84993. get numberOfTilesHeight(): number;
  84994. set numberOfTilesHeight(value: number);
  84995. get amplitude(): number;
  84996. set amplitude(value: number);
  84997. get numberOfTilesWidth(): number;
  84998. set numberOfTilesWidth(value: number);
  84999. get jointColor(): BABYLON.Color3;
  85000. set jointColor(value: BABYLON.Color3);
  85001. /**
  85002. * Serializes this marble procedural texture
  85003. * @returns a serialized marble procedural texture object
  85004. */
  85005. serialize(): any;
  85006. /**
  85007. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85008. * @param parsedTexture defines parsed texture data
  85009. * @param scene defines the current scene
  85010. * @param rootUrl defines the root URL containing marble procedural texture information
  85011. * @returns a parsed Marble Procedural BABYLON.Texture
  85012. */
  85013. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85014. }
  85015. }
  85016. declare module BABYLON {
  85017. /** @hidden */
  85018. export var normalMapProceduralTexturePixelShader: {
  85019. name: string;
  85020. shader: string;
  85021. };
  85022. }
  85023. declare module BABYLON {
  85024. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85025. private _baseTexture;
  85026. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85027. updateShaderUniforms(): void;
  85028. render(useCameraPostProcess?: boolean): void;
  85029. resize(size: any, generateMipMaps: any): void;
  85030. get baseTexture(): BABYLON.Texture;
  85031. set baseTexture(texture: BABYLON.Texture);
  85032. /**
  85033. * Serializes this normal map procedural texture
  85034. * @returns a serialized normal map procedural texture object
  85035. */
  85036. serialize(): any;
  85037. /**
  85038. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85039. * @param parsedTexture defines parsed texture data
  85040. * @param scene defines the current scene
  85041. * @param rootUrl defines the root URL containing normal map procedural texture information
  85042. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85043. */
  85044. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85045. }
  85046. }
  85047. declare module BABYLON {
  85048. /** @hidden */
  85049. export var perlinNoiseProceduralTexturePixelShader: {
  85050. name: string;
  85051. shader: string;
  85052. };
  85053. }
  85054. declare module BABYLON {
  85055. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85056. time: number;
  85057. timeScale: number;
  85058. translationSpeed: number;
  85059. private _currentTranslation;
  85060. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85061. updateShaderUniforms(): void;
  85062. render(useCameraPostProcess?: boolean): void;
  85063. resize(size: any, generateMipMaps: any): void;
  85064. /**
  85065. * Serializes this perlin noise procedural texture
  85066. * @returns a serialized perlin noise procedural texture object
  85067. */
  85068. serialize(): any;
  85069. /**
  85070. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85071. * @param parsedTexture defines parsed texture data
  85072. * @param scene defines the current scene
  85073. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85074. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85075. */
  85076. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85077. }
  85078. }
  85079. declare module BABYLON {
  85080. /** @hidden */
  85081. export var roadProceduralTexturePixelShader: {
  85082. name: string;
  85083. shader: string;
  85084. };
  85085. }
  85086. declare module BABYLON {
  85087. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85088. private _roadColor;
  85089. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85090. updateShaderUniforms(): void;
  85091. get roadColor(): BABYLON.Color3;
  85092. set roadColor(value: BABYLON.Color3);
  85093. /**
  85094. * Serializes this road procedural texture
  85095. * @returns a serialized road procedural texture object
  85096. */
  85097. serialize(): any;
  85098. /**
  85099. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85100. * @param parsedTexture defines parsed texture data
  85101. * @param scene defines the current scene
  85102. * @param rootUrl defines the root URL containing road procedural texture information
  85103. * @returns a parsed Road Procedural BABYLON.Texture
  85104. */
  85105. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85106. }
  85107. }
  85108. declare module BABYLON {
  85109. /** @hidden */
  85110. export var starfieldProceduralTexturePixelShader: {
  85111. name: string;
  85112. shader: string;
  85113. };
  85114. }
  85115. declare module BABYLON {
  85116. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85117. private _time;
  85118. private _alpha;
  85119. private _beta;
  85120. private _zoom;
  85121. private _formuparam;
  85122. private _stepsize;
  85123. private _tile;
  85124. private _brightness;
  85125. private _darkmatter;
  85126. private _distfading;
  85127. private _saturation;
  85128. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85129. updateShaderUniforms(): void;
  85130. get time(): number;
  85131. set time(value: number);
  85132. get alpha(): number;
  85133. set alpha(value: number);
  85134. get beta(): number;
  85135. set beta(value: number);
  85136. get formuparam(): number;
  85137. set formuparam(value: number);
  85138. get stepsize(): number;
  85139. set stepsize(value: number);
  85140. get zoom(): number;
  85141. set zoom(value: number);
  85142. get tile(): number;
  85143. set tile(value: number);
  85144. get brightness(): number;
  85145. set brightness(value: number);
  85146. get darkmatter(): number;
  85147. set darkmatter(value: number);
  85148. get distfading(): number;
  85149. set distfading(value: number);
  85150. get saturation(): number;
  85151. set saturation(value: number);
  85152. /**
  85153. * Serializes this starfield procedural texture
  85154. * @returns a serialized starfield procedural texture object
  85155. */
  85156. serialize(): any;
  85157. /**
  85158. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85159. * @param parsedTexture defines parsed texture data
  85160. * @param scene defines the current scene
  85161. * @param rootUrl defines the root URL containing startfield procedural texture information
  85162. * @returns a parsed Starfield Procedural BABYLON.Texture
  85163. */
  85164. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85165. }
  85166. }
  85167. declare module BABYLON {
  85168. /** @hidden */
  85169. export var woodProceduralTexturePixelShader: {
  85170. name: string;
  85171. shader: string;
  85172. };
  85173. }
  85174. declare module BABYLON {
  85175. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85176. private _ampScale;
  85177. private _woodColor;
  85178. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85179. updateShaderUniforms(): void;
  85180. get ampScale(): number;
  85181. set ampScale(value: number);
  85182. get woodColor(): BABYLON.Color3;
  85183. set woodColor(value: BABYLON.Color3);
  85184. /**
  85185. * Serializes this wood procedural texture
  85186. * @returns a serialized wood procedural texture object
  85187. */
  85188. serialize(): any;
  85189. /**
  85190. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85191. * @param parsedTexture defines parsed texture data
  85192. * @param scene defines the current scene
  85193. * @param rootUrl defines the root URL containing wood procedural texture information
  85194. * @returns a parsed Wood Procedural BABYLON.Texture
  85195. */
  85196. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85197. }
  85198. }