documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356
  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. /**
  46048. * Rendering context of the canvas which can be used to display/mirror xr content
  46049. */
  46050. canvasContext: WebGLRenderingContext;
  46051. /**
  46052. * xr layer for the canvas
  46053. */
  46054. xrLayer: Nullable<XRWebGLLayer>;
  46055. /**
  46056. * Initializes the canvas to be added/removed upon entering/exiting xr
  46057. * @param _xrSessionManager The XR Session manager
  46058. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46059. */
  46060. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46061. /**
  46062. * Disposes of the object
  46063. */
  46064. dispose(): void;
  46065. /**
  46066. * Initializes the xr layer for the session
  46067. * @param xrSession xr session
  46068. * @returns a promise that will resolve once the XR Layer has been created
  46069. */
  46070. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46071. private _addCanvas;
  46072. private _removeCanvas;
  46073. private _setManagedOutputCanvas;
  46074. }
  46075. }
  46076. declare module BABYLON {
  46077. /**
  46078. * Manages an XRSession to work with Babylon's engine
  46079. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46080. */
  46081. export class WebXRSessionManager implements IDisposable {
  46082. /** The scene which the session should be created for */
  46083. scene: Scene;
  46084. private _referenceSpace;
  46085. private _rttProvider;
  46086. private _sessionEnded;
  46087. private _xrNavigator;
  46088. private baseLayer;
  46089. /**
  46090. * The base reference space from which the session started. good if you want to reset your
  46091. * reference space
  46092. */
  46093. baseReferenceSpace: XRReferenceSpace;
  46094. /**
  46095. * Current XR frame
  46096. */
  46097. currentFrame: Nullable<XRFrame>;
  46098. /** WebXR timestamp updated every frame */
  46099. currentTimestamp: number;
  46100. /**
  46101. * Used just in case of a failure to initialize an immersive session.
  46102. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46103. */
  46104. defaultHeightCompensation: number;
  46105. /**
  46106. * Fires every time a new xrFrame arrives which can be used to update the camera
  46107. */
  46108. onXRFrameObservable: Observable<XRFrame>;
  46109. /**
  46110. * Fires when the reference space changed
  46111. */
  46112. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46113. /**
  46114. * Fires when the xr session is ended either by the device or manually done
  46115. */
  46116. onXRSessionEnded: Observable<any>;
  46117. /**
  46118. * Fires when the xr session is ended either by the device or manually done
  46119. */
  46120. onXRSessionInit: Observable<XRSession>;
  46121. /**
  46122. * Underlying xr session
  46123. */
  46124. session: XRSession;
  46125. /**
  46126. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46127. * or get the offset the player is currently at.
  46128. */
  46129. viewerReferenceSpace: XRReferenceSpace;
  46130. /**
  46131. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46132. * @param scene The scene which the session should be created for
  46133. */
  46134. constructor(
  46135. /** The scene which the session should be created for */
  46136. scene: Scene);
  46137. /**
  46138. * The current reference space used in this session. This reference space can constantly change!
  46139. * It is mainly used to offset the camera's position.
  46140. */
  46141. get referenceSpace(): XRReferenceSpace;
  46142. /**
  46143. * Set a new reference space and triggers the observable
  46144. */
  46145. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46146. /**
  46147. * Disposes of the session manager
  46148. */
  46149. dispose(): void;
  46150. /**
  46151. * Stops the xrSession and restores the render loop
  46152. * @returns Promise which resolves after it exits XR
  46153. */
  46154. exitXRAsync(): Promise<void>;
  46155. /**
  46156. * Gets the correct render target texture to be rendered this frame for this eye
  46157. * @param eye the eye for which to get the render target
  46158. * @returns the render target for the specified eye
  46159. */
  46160. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46161. /**
  46162. * Creates a WebXRRenderTarget object for the XR session
  46163. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46164. * @param options optional options to provide when creating a new render target
  46165. * @returns a WebXR render target to which the session can render
  46166. */
  46167. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46168. /**
  46169. * Initializes the manager
  46170. * After initialization enterXR can be called to start an XR session
  46171. * @returns Promise which resolves after it is initialized
  46172. */
  46173. initializeAsync(): Promise<void>;
  46174. /**
  46175. * Initializes an xr session
  46176. * @param xrSessionMode mode to initialize
  46177. * @param xrSessionInit defines optional and required values to pass to the session builder
  46178. * @returns a promise which will resolve once the session has been initialized
  46179. */
  46180. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46181. /**
  46182. * Checks if a session would be supported for the creation options specified
  46183. * @param sessionMode session mode to check if supported eg. immersive-vr
  46184. * @returns A Promise that resolves to true if supported and false if not
  46185. */
  46186. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46187. /**
  46188. * Resets the reference space to the one started the session
  46189. */
  46190. resetReferenceSpace(): void;
  46191. /**
  46192. * Starts rendering to the xr layer
  46193. */
  46194. runXRRenderLoop(): void;
  46195. /**
  46196. * Sets the reference space on the xr session
  46197. * @param referenceSpaceType space to set
  46198. * @returns a promise that will resolve once the reference space has been set
  46199. */
  46200. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46201. /**
  46202. * Updates the render state of the session
  46203. * @param state state to set
  46204. * @returns a promise that resolves once the render state has been updated
  46205. */
  46206. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46207. /**
  46208. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46209. * @param sessionMode defines the session to test
  46210. * @returns a promise with boolean as final value
  46211. */
  46212. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46213. private _createRenderTargetTexture;
  46214. }
  46215. }
  46216. declare module BABYLON {
  46217. /**
  46218. * WebXR Camera which holds the views for the xrSession
  46219. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46220. */
  46221. export class WebXRCamera extends FreeCamera {
  46222. private _xrSessionManager;
  46223. private _firstFrame;
  46224. private _referenceQuaternion;
  46225. private _referencedPosition;
  46226. private _xrInvPositionCache;
  46227. private _xrInvQuaternionCache;
  46228. /**
  46229. * Should position compensation execute on first frame.
  46230. * This is used when copying the position from a native (non XR) camera
  46231. */
  46232. compensateOnFirstFrame: boolean;
  46233. /**
  46234. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46235. * @param name the name of the camera
  46236. * @param scene the scene to add the camera to
  46237. * @param _xrSessionManager a constructed xr session manager
  46238. */
  46239. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46240. /**
  46241. * Return the user's height, unrelated to the current ground.
  46242. * This will be the y position of this camera, when ground level is 0.
  46243. */
  46244. get realWorldHeight(): number;
  46245. /** @hidden */
  46246. _updateForDualEyeDebugging(): void;
  46247. /**
  46248. * Sets this camera's transformation based on a non-vr camera
  46249. * @param otherCamera the non-vr camera to copy the transformation from
  46250. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46251. */
  46252. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46253. /**
  46254. * Gets the current instance class name ("WebXRCamera").
  46255. * @returns the class name
  46256. */
  46257. getClassName(): string;
  46258. /**
  46259. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46260. */
  46261. _getViewMatrix(): Matrix;
  46262. private _rotate180;
  46263. private _updateFromXRSession;
  46264. private _updateNumberOfRigCameras;
  46265. private _updateReferenceSpace;
  46266. private _updateReferenceSpaceOffset;
  46267. }
  46268. }
  46269. declare module BABYLON {
  46270. /**
  46271. * Defining the interface required for a (webxr) feature
  46272. */
  46273. export interface IWebXRFeature extends IDisposable {
  46274. /**
  46275. * Is this feature attached
  46276. */
  46277. attached: boolean;
  46278. /**
  46279. * Should auto-attach be disabled?
  46280. */
  46281. disableAutoAttach: boolean;
  46282. /**
  46283. * Attach the feature to the session
  46284. * Will usually be called by the features manager
  46285. *
  46286. * @param force should attachment be forced (even when already attached)
  46287. * @returns true if successful.
  46288. */
  46289. attach(force?: boolean): boolean;
  46290. /**
  46291. * Detach the feature from the session
  46292. * Will usually be called by the features manager
  46293. *
  46294. * @returns true if successful.
  46295. */
  46296. detach(): boolean;
  46297. }
  46298. /**
  46299. * A list of the currently available features without referencing them
  46300. */
  46301. export class WebXRFeatureName {
  46302. /**
  46303. * The name of the anchor system feature
  46304. */
  46305. static ANCHOR_SYSTEM: string;
  46306. /**
  46307. * The name of the background remover feature
  46308. */
  46309. static BACKGROUND_REMOVER: string;
  46310. /**
  46311. * The name of the hit test feature
  46312. */
  46313. static HIT_TEST: string;
  46314. /**
  46315. * physics impostors for xr controllers feature
  46316. */
  46317. static PHYSICS_CONTROLLERS: string;
  46318. /**
  46319. * The name of the plane detection feature
  46320. */
  46321. static PLANE_DETECTION: string;
  46322. /**
  46323. * The name of the pointer selection feature
  46324. */
  46325. static POINTER_SELECTION: string;
  46326. /**
  46327. * The name of the teleportation feature
  46328. */
  46329. static TELEPORTATION: string;
  46330. }
  46331. /**
  46332. * Defining the constructor of a feature. Used to register the modules.
  46333. */
  46334. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46335. /**
  46336. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46337. * It is mainly used in AR sessions.
  46338. *
  46339. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46340. */
  46341. export class WebXRFeaturesManager implements IDisposable {
  46342. private _xrSessionManager;
  46343. private static readonly _AvailableFeatures;
  46344. private _features;
  46345. /**
  46346. * constructs a new features manages.
  46347. *
  46348. * @param _xrSessionManager an instance of WebXRSessionManager
  46349. */
  46350. constructor(_xrSessionManager: WebXRSessionManager);
  46351. /**
  46352. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46353. * Mainly used internally.
  46354. *
  46355. * @param featureName the name of the feature to register
  46356. * @param constructorFunction the function used to construct the module
  46357. * @param version the (babylon) version of the module
  46358. * @param stable is that a stable version of this module
  46359. */
  46360. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46361. /**
  46362. * Returns a constructor of a specific feature.
  46363. *
  46364. * @param featureName the name of the feature to construct
  46365. * @param version the version of the feature to load
  46366. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46367. * @param options optional options provided to the module.
  46368. * @returns a function that, when called, will return a new instance of this feature
  46369. */
  46370. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46371. /**
  46372. * Can be used to return the list of features currently registered
  46373. *
  46374. * @returns an Array of available features
  46375. */
  46376. static GetAvailableFeatures(): string[];
  46377. /**
  46378. * Gets the versions available for a specific feature
  46379. * @param featureName the name of the feature
  46380. * @returns an array with the available versions
  46381. */
  46382. static GetAvailableVersions(featureName: string): string[];
  46383. /**
  46384. * Return the latest unstable version of this feature
  46385. * @param featureName the name of the feature to search
  46386. * @returns the version number. if not found will return -1
  46387. */
  46388. static GetLatestVersionOfFeature(featureName: string): number;
  46389. /**
  46390. * Return the latest stable 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 GetStableVersionOfFeature(featureName: string): number;
  46395. /**
  46396. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46397. * Can be used during a session to start a feature
  46398. * @param featureName the name of feature to attach
  46399. */
  46400. attachFeature(featureName: string): void;
  46401. /**
  46402. * Can be used inside a session or when the session ends to detach a specific feature
  46403. * @param featureName the name of the feature to detach
  46404. */
  46405. detachFeature(featureName: string): void;
  46406. /**
  46407. * Used to disable an already-enabled feature
  46408. * The feature will be disposed and will be recreated once enabled.
  46409. * @param featureName the feature to disable
  46410. * @returns true if disable was successful
  46411. */
  46412. disableFeature(featureName: string | {
  46413. Name: string;
  46414. }): boolean;
  46415. /**
  46416. * dispose this features manager
  46417. */
  46418. dispose(): void;
  46419. /**
  46420. * 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.
  46421. * 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.
  46422. *
  46423. * @param featureName the name of the feature to load or the class of the feature
  46424. * @param version optional version to load. if not provided the latest version will be enabled
  46425. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46426. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46427. * @returns a new constructed feature or throws an error if feature not found.
  46428. */
  46429. enableFeature(featureName: string | {
  46430. Name: string;
  46431. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46432. /**
  46433. * get the implementation of an enabled feature.
  46434. * @param featureName the name of the feature to load
  46435. * @returns the feature class, if found
  46436. */
  46437. getEnabledFeature(featureName: string): IWebXRFeature;
  46438. /**
  46439. * Get the list of enabled features
  46440. * @returns an array of enabled features
  46441. */
  46442. getEnabledFeatures(): string[];
  46443. }
  46444. }
  46445. declare module BABYLON {
  46446. /**
  46447. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46448. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  46449. */
  46450. export class WebXRExperienceHelper implements IDisposable {
  46451. private scene;
  46452. private _nonVRCamera;
  46453. private _originalSceneAutoClear;
  46454. private _supported;
  46455. /**
  46456. * Camera used to render xr content
  46457. */
  46458. camera: WebXRCamera;
  46459. /** A features manager for this xr session */
  46460. featuresManager: WebXRFeaturesManager;
  46461. /**
  46462. * Observers registered here will be triggered after the camera's initial transformation is set
  46463. * This can be used to set a different ground level or an extra rotation.
  46464. *
  46465. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46466. * to the position set after this observable is done executing.
  46467. */
  46468. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46469. /**
  46470. * Fires when the state of the experience helper has changed
  46471. */
  46472. onStateChangedObservable: Observable<WebXRState>;
  46473. /** Session manager used to keep track of xr session */
  46474. sessionManager: WebXRSessionManager;
  46475. /**
  46476. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46477. */
  46478. state: WebXRState;
  46479. /**
  46480. * Creates a WebXRExperienceHelper
  46481. * @param scene The scene the helper should be created in
  46482. */
  46483. private constructor();
  46484. /**
  46485. * Creates the experience helper
  46486. * @param scene the scene to attach the experience helper to
  46487. * @returns a promise for the experience helper
  46488. */
  46489. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46490. /**
  46491. * Disposes of the experience helper
  46492. */
  46493. dispose(): void;
  46494. /**
  46495. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46496. * @param sessionMode options for the XR session
  46497. * @param referenceSpaceType frame of reference of the XR session
  46498. * @param renderTarget the output canvas that will be used to enter XR mode
  46499. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46500. * @returns promise that resolves after xr mode has entered
  46501. */
  46502. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46503. /**
  46504. * Exits XR mode and returns the scene to its original state
  46505. * @returns promise that resolves after xr mode has exited
  46506. */
  46507. exitXRAsync(): Promise<void>;
  46508. private _nonXRToXRCamera;
  46509. private _setState;
  46510. }
  46511. }
  46512. declare module BABYLON {
  46513. /**
  46514. * X-Y values for axes in WebXR
  46515. */
  46516. export interface IWebXRMotionControllerAxesValue {
  46517. /**
  46518. * The value of the x axis
  46519. */
  46520. x: number;
  46521. /**
  46522. * The value of the y-axis
  46523. */
  46524. y: number;
  46525. }
  46526. /**
  46527. * changed / previous values for the values of this component
  46528. */
  46529. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46530. /**
  46531. * current (this frame) value
  46532. */
  46533. current: T;
  46534. /**
  46535. * previous (last change) value
  46536. */
  46537. previous: T;
  46538. }
  46539. /**
  46540. * Represents changes in the component between current frame and last values recorded
  46541. */
  46542. export interface IWebXRMotionControllerComponentChanges {
  46543. /**
  46544. * will be populated with previous and current values if axes changed
  46545. */
  46546. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46547. /**
  46548. * will be populated with previous and current values if pressed changed
  46549. */
  46550. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46551. /**
  46552. * will be populated with previous and current values if touched changed
  46553. */
  46554. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46555. /**
  46556. * will be populated with previous and current values if value changed
  46557. */
  46558. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46559. }
  46560. /**
  46561. * This class represents a single component (for example button or thumbstick) of a motion controller
  46562. */
  46563. export class WebXRControllerComponent implements IDisposable {
  46564. /**
  46565. * the id of this component
  46566. */
  46567. id: string;
  46568. /**
  46569. * the type of the component
  46570. */
  46571. type: MotionControllerComponentType;
  46572. private _buttonIndex;
  46573. private _axesIndices;
  46574. private _axes;
  46575. private _changes;
  46576. private _currentValue;
  46577. private _hasChanges;
  46578. private _pressed;
  46579. private _touched;
  46580. /**
  46581. * button component type
  46582. */
  46583. static BUTTON_TYPE: MotionControllerComponentType;
  46584. /**
  46585. * squeeze component type
  46586. */
  46587. static SQUEEZE_TYPE: MotionControllerComponentType;
  46588. /**
  46589. * Thumbstick component type
  46590. */
  46591. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46592. /**
  46593. * Touchpad component type
  46594. */
  46595. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46596. /**
  46597. * trigger component type
  46598. */
  46599. static TRIGGER_TYPE: MotionControllerComponentType;
  46600. /**
  46601. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46602. * the axes data changes
  46603. */
  46604. onAxisValueChangedObservable: Observable<{
  46605. x: number;
  46606. y: number;
  46607. }>;
  46608. /**
  46609. * Observers registered here will be triggered when the state of a button changes
  46610. * State change is either pressed / touched / value
  46611. */
  46612. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46613. /**
  46614. * Creates a new component for a motion controller.
  46615. * It is created by the motion controller itself
  46616. *
  46617. * @param id the id of this component
  46618. * @param type the type of the component
  46619. * @param _buttonIndex index in the buttons array of the gamepad
  46620. * @param _axesIndices indices of the values in the axes array of the gamepad
  46621. */
  46622. constructor(
  46623. /**
  46624. * the id of this component
  46625. */
  46626. id: string,
  46627. /**
  46628. * the type of the component
  46629. */
  46630. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46631. /**
  46632. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46633. */
  46634. get axes(): IWebXRMotionControllerAxesValue;
  46635. /**
  46636. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46637. */
  46638. get changes(): IWebXRMotionControllerComponentChanges;
  46639. /**
  46640. * Return whether or not the component changed the last frame
  46641. */
  46642. get hasChanges(): boolean;
  46643. /**
  46644. * is the button currently pressed
  46645. */
  46646. get pressed(): boolean;
  46647. /**
  46648. * is the button currently touched
  46649. */
  46650. get touched(): boolean;
  46651. /**
  46652. * Get the current value of this component
  46653. */
  46654. get value(): number;
  46655. /**
  46656. * Dispose this component
  46657. */
  46658. dispose(): void;
  46659. /**
  46660. * Are there axes correlating to this component
  46661. * @return true is axes data is available
  46662. */
  46663. isAxes(): boolean;
  46664. /**
  46665. * Is this component a button (hence - pressable)
  46666. * @returns true if can be pressed
  46667. */
  46668. isButton(): boolean;
  46669. /**
  46670. * update this component using the gamepad object it is in. Called on every frame
  46671. * @param nativeController the native gamepad controller object
  46672. */
  46673. update(nativeController: IMinimalMotionControllerObject): void;
  46674. }
  46675. }
  46676. declare module BABYLON {
  46677. /**
  46678. * Interface used to represent data loading progression
  46679. */
  46680. export interface ISceneLoaderProgressEvent {
  46681. /**
  46682. * Defines if data length to load can be evaluated
  46683. */
  46684. readonly lengthComputable: boolean;
  46685. /**
  46686. * Defines the loaded data length
  46687. */
  46688. readonly loaded: number;
  46689. /**
  46690. * Defines the data length to load
  46691. */
  46692. readonly total: number;
  46693. }
  46694. /**
  46695. * Interface used by SceneLoader plugins to define supported file extensions
  46696. */
  46697. export interface ISceneLoaderPluginExtensions {
  46698. /**
  46699. * Defines the list of supported extensions
  46700. */
  46701. [extension: string]: {
  46702. isBinary: boolean;
  46703. };
  46704. }
  46705. /**
  46706. * Interface used by SceneLoader plugin factory
  46707. */
  46708. export interface ISceneLoaderPluginFactory {
  46709. /**
  46710. * Defines the name of the factory
  46711. */
  46712. name: string;
  46713. /**
  46714. * Function called to create a new plugin
  46715. * @return the new plugin
  46716. */
  46717. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46718. /**
  46719. * The callback that returns true if the data can be directly loaded.
  46720. * @param data string containing the file data
  46721. * @returns if the data can be loaded directly
  46722. */
  46723. canDirectLoad?(data: string): boolean;
  46724. }
  46725. /**
  46726. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46727. */
  46728. export interface ISceneLoaderPluginBase {
  46729. /**
  46730. * The friendly name of this plugin.
  46731. */
  46732. name: string;
  46733. /**
  46734. * The file extensions supported by this plugin.
  46735. */
  46736. extensions: string | ISceneLoaderPluginExtensions;
  46737. /**
  46738. * The callback called when loading from a url.
  46739. * @param scene scene loading this url
  46740. * @param url url to load
  46741. * @param onSuccess callback called when the file successfully loads
  46742. * @param onProgress callback called while file is loading (if the server supports this mode)
  46743. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46744. * @param onError callback called when the file fails to load
  46745. * @returns a file request object
  46746. */
  46747. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46748. /**
  46749. * The callback called when loading from a file object.
  46750. * @param scene scene loading this file
  46751. * @param file defines the file to load
  46752. * @param onSuccess defines the callback to call when data is loaded
  46753. * @param onProgress defines the callback to call during loading process
  46754. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46755. * @param onError defines the callback to call when an error occurs
  46756. * @returns a file request object
  46757. */
  46758. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46759. /**
  46760. * The callback that returns true if the data can be directly loaded.
  46761. * @param data string containing the file data
  46762. * @returns if the data can be loaded directly
  46763. */
  46764. canDirectLoad?(data: string): boolean;
  46765. /**
  46766. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46767. * @param scene scene loading this data
  46768. * @param data string containing the data
  46769. * @returns data to pass to the plugin
  46770. */
  46771. directLoad?(scene: Scene, data: string): any;
  46772. /**
  46773. * The callback that allows custom handling of the root url based on the response url.
  46774. * @param rootUrl the original root url
  46775. * @param responseURL the response url if available
  46776. * @returns the new root url
  46777. */
  46778. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46779. }
  46780. /**
  46781. * Interface used to define a SceneLoader plugin
  46782. */
  46783. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46784. /**
  46785. * Import meshes into a scene.
  46786. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46787. * @param scene The scene to import into
  46788. * @param data The data to import
  46789. * @param rootUrl The root url for scene and resources
  46790. * @param meshes The meshes array to import into
  46791. * @param particleSystems The particle systems array to import into
  46792. * @param skeletons The skeletons array to import into
  46793. * @param onError The callback when import fails
  46794. * @returns True if successful or false otherwise
  46795. */
  46796. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46797. /**
  46798. * Load into a scene.
  46799. * @param scene The scene to load into
  46800. * @param data The data to import
  46801. * @param rootUrl The root url for scene and resources
  46802. * @param onError The callback when import fails
  46803. * @returns True if successful or false otherwise
  46804. */
  46805. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46806. /**
  46807. * Load into an asset container.
  46808. * @param scene The scene to load into
  46809. * @param data The data to import
  46810. * @param rootUrl The root url for scene and resources
  46811. * @param onError The callback when import fails
  46812. * @returns The loaded asset container
  46813. */
  46814. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46815. }
  46816. /**
  46817. * Interface used to define an async SceneLoader plugin
  46818. */
  46819. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46820. /**
  46821. * Import meshes into a scene.
  46822. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46823. * @param scene The scene to import into
  46824. * @param data The data to import
  46825. * @param rootUrl The root url for scene and resources
  46826. * @param onProgress The callback when the load progresses
  46827. * @param fileName Defines the name of the file to load
  46828. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46829. */
  46830. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46831. meshes: AbstractMesh[];
  46832. particleSystems: IParticleSystem[];
  46833. skeletons: Skeleton[];
  46834. animationGroups: AnimationGroup[];
  46835. }>;
  46836. /**
  46837. * Load into a scene.
  46838. * @param scene The scene to load into
  46839. * @param data The data to import
  46840. * @param rootUrl The root url for scene and resources
  46841. * @param onProgress The callback when the load progresses
  46842. * @param fileName Defines the name of the file to load
  46843. * @returns Nothing
  46844. */
  46845. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46846. /**
  46847. * Load into an asset container.
  46848. * @param scene The scene to load into
  46849. * @param data The data to import
  46850. * @param rootUrl The root url for scene and resources
  46851. * @param onProgress The callback when the load progresses
  46852. * @param fileName Defines the name of the file to load
  46853. * @returns The loaded asset container
  46854. */
  46855. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46856. }
  46857. /**
  46858. * Mode that determines how to handle old animation groups before loading new ones.
  46859. */
  46860. export enum SceneLoaderAnimationGroupLoadingMode {
  46861. /**
  46862. * Reset all old animations to initial state then dispose them.
  46863. */
  46864. Clean = 0,
  46865. /**
  46866. * Stop all old animations.
  46867. */
  46868. Stop = 1,
  46869. /**
  46870. * Restart old animations from first frame.
  46871. */
  46872. Sync = 2,
  46873. /**
  46874. * Old animations remains untouched.
  46875. */
  46876. NoSync = 3
  46877. }
  46878. /**
  46879. * Class used to load scene from various file formats using registered plugins
  46880. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  46881. */
  46882. export class SceneLoader {
  46883. /**
  46884. * No logging while loading
  46885. */
  46886. static readonly NO_LOGGING: number;
  46887. /**
  46888. * Minimal logging while loading
  46889. */
  46890. static readonly MINIMAL_LOGGING: number;
  46891. /**
  46892. * Summary logging while loading
  46893. */
  46894. static readonly SUMMARY_LOGGING: number;
  46895. /**
  46896. * Detailled logging while loading
  46897. */
  46898. static readonly DETAILED_LOGGING: number;
  46899. /**
  46900. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46901. */
  46902. static get ForceFullSceneLoadingForIncremental(): boolean;
  46903. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46904. /**
  46905. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46906. */
  46907. static get ShowLoadingScreen(): boolean;
  46908. static set ShowLoadingScreen(value: boolean);
  46909. /**
  46910. * Defines the current logging level (while loading the scene)
  46911. * @ignorenaming
  46912. */
  46913. static get loggingLevel(): number;
  46914. static set loggingLevel(value: number);
  46915. /**
  46916. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46917. */
  46918. static get CleanBoneMatrixWeights(): boolean;
  46919. static set CleanBoneMatrixWeights(value: boolean);
  46920. /**
  46921. * Event raised when a plugin is used to load a scene
  46922. */
  46923. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46924. private static _registeredPlugins;
  46925. private static _getDefaultPlugin;
  46926. private static _getPluginForExtension;
  46927. private static _getPluginForDirectLoad;
  46928. private static _getPluginForFilename;
  46929. private static _getDirectLoad;
  46930. private static _loadData;
  46931. private static _getFileInfo;
  46932. /**
  46933. * Gets a plugin that can load the given extension
  46934. * @param extension defines the extension to load
  46935. * @returns a plugin or null if none works
  46936. */
  46937. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46938. /**
  46939. * Gets a boolean indicating that the given extension can be loaded
  46940. * @param extension defines the extension to load
  46941. * @returns true if the extension is supported
  46942. */
  46943. static IsPluginForExtensionAvailable(extension: string): boolean;
  46944. /**
  46945. * Adds a new plugin to the list of registered plugins
  46946. * @param plugin defines the plugin to add
  46947. */
  46948. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46949. /**
  46950. * Import meshes into a scene
  46951. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46952. * @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)
  46953. * @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)
  46954. * @param scene the instance of BABYLON.Scene to append to
  46955. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46956. * @param onProgress a callback with a progress event for each file being loaded
  46957. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46958. * @param pluginExtension the extension used to determine the plugin
  46959. * @returns The loaded plugin
  46960. */
  46961. 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>;
  46962. /**
  46963. * Import meshes into a scene
  46964. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46965. * @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)
  46966. * @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)
  46967. * @param scene the instance of BABYLON.Scene to append to
  46968. * @param onProgress a callback with a progress event for each file being loaded
  46969. * @param pluginExtension the extension used to determine the plugin
  46970. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46971. */
  46972. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46973. meshes: AbstractMesh[];
  46974. particleSystems: IParticleSystem[];
  46975. skeletons: Skeleton[];
  46976. animationGroups: AnimationGroup[];
  46977. }>;
  46978. /**
  46979. * Load a scene
  46980. * @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)
  46981. * @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)
  46982. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46983. * @param onSuccess a callback with the scene when import succeeds
  46984. * @param onProgress a callback with a progress event for each file being loaded
  46985. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46986. * @param pluginExtension the extension used to determine the plugin
  46987. * @returns The loaded plugin
  46988. */
  46989. 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>;
  46990. /**
  46991. * Load a scene
  46992. * @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)
  46993. * @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)
  46994. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46995. * @param onProgress a callback with a progress event for each file being loaded
  46996. * @param pluginExtension the extension used to determine the plugin
  46997. * @returns The loaded scene
  46998. */
  46999. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47000. /**
  47001. * Append a scene
  47002. * @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)
  47003. * @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)
  47004. * @param scene is the instance of BABYLON.Scene to append to
  47005. * @param onSuccess a callback with the scene when import succeeds
  47006. * @param onProgress a callback with a progress event for each file being loaded
  47007. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47008. * @param pluginExtension the extension used to determine the plugin
  47009. * @returns The loaded plugin
  47010. */
  47011. 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>;
  47012. /**
  47013. * Append a scene
  47014. * @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)
  47015. * @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)
  47016. * @param scene is the instance of BABYLON.Scene to append to
  47017. * @param onProgress a callback with a progress event for each file being loaded
  47018. * @param pluginExtension the extension used to determine the plugin
  47019. * @returns The given scene
  47020. */
  47021. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47022. /**
  47023. * Load a scene into an asset container
  47024. * @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)
  47025. * @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)
  47026. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47027. * @param onSuccess a callback with the scene when import succeeds
  47028. * @param onProgress a callback with a progress event for each file being loaded
  47029. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47030. * @param pluginExtension the extension used to determine the plugin
  47031. * @returns The loaded plugin
  47032. */
  47033. 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>;
  47034. /**
  47035. * Load a scene into an asset container
  47036. * @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)
  47037. * @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)
  47038. * @param scene is the instance of Scene to append to
  47039. * @param onProgress a callback with a progress event for each file being loaded
  47040. * @param pluginExtension the extension used to determine the plugin
  47041. * @returns The loaded asset container
  47042. */
  47043. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47044. /**
  47045. * Import animations from a file into a scene
  47046. * @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)
  47047. * @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)
  47048. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47049. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47050. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47051. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47052. * @param onSuccess a callback with the scene when import succeeds
  47053. * @param onProgress a callback with a progress event for each file being loaded
  47054. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47055. * @param pluginExtension the extension used to determine the plugin
  47056. */
  47057. 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;
  47058. /**
  47059. * Import animations from a file into a scene
  47060. * @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)
  47061. * @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)
  47062. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47063. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47064. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47065. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47066. * @param onSuccess a callback with the scene when import succeeds
  47067. * @param onProgress a callback with a progress event for each file being loaded
  47068. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47069. * @param pluginExtension the extension used to determine the plugin
  47070. * @returns the updated scene with imported animations
  47071. */
  47072. 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>;
  47073. }
  47074. }
  47075. declare module BABYLON {
  47076. /**
  47077. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47078. */
  47079. export type MotionControllerHandedness = "none" | "left" | "right";
  47080. /**
  47081. * The type of components available in motion controllers.
  47082. * This is not the name of the component.
  47083. */
  47084. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47085. /**
  47086. * The state of a controller component
  47087. */
  47088. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47089. /**
  47090. * The schema of motion controller layout.
  47091. * No object will be initialized using this interface
  47092. * This is used just to define the profile.
  47093. */
  47094. export interface IMotionControllerLayout {
  47095. /**
  47096. * Path to load the assets. Usually relative to the base path
  47097. */
  47098. assetPath: string;
  47099. /**
  47100. * Available components (unsorted)
  47101. */
  47102. components: {
  47103. /**
  47104. * A map of component Ids
  47105. */
  47106. [componentId: string]: {
  47107. /**
  47108. * The type of input the component outputs
  47109. */
  47110. type: MotionControllerComponentType;
  47111. /**
  47112. * The indices of this component in the gamepad object
  47113. */
  47114. gamepadIndices: {
  47115. /**
  47116. * Index of button
  47117. */
  47118. button?: number;
  47119. /**
  47120. * If available, index of x-axis
  47121. */
  47122. xAxis?: number;
  47123. /**
  47124. * If available, index of y-axis
  47125. */
  47126. yAxis?: number;
  47127. };
  47128. /**
  47129. * The mesh's root node name
  47130. */
  47131. rootNodeName: string;
  47132. /**
  47133. * Animation definitions for this model
  47134. */
  47135. visualResponses: {
  47136. [stateKey: string]: {
  47137. /**
  47138. * What property will be animated
  47139. */
  47140. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47141. /**
  47142. * What states influence this visual response
  47143. */
  47144. states: MotionControllerComponentStateType[];
  47145. /**
  47146. * Type of animation - movement or visibility
  47147. */
  47148. valueNodeProperty: "transform" | "visibility";
  47149. /**
  47150. * Base node name to move. Its position will be calculated according to the min and max nodes
  47151. */
  47152. valueNodeName?: string;
  47153. /**
  47154. * Minimum movement node
  47155. */
  47156. minNodeName?: string;
  47157. /**
  47158. * Max movement node
  47159. */
  47160. maxNodeName?: string;
  47161. };
  47162. };
  47163. /**
  47164. * If touch enabled, what is the name of node to display user feedback
  47165. */
  47166. touchPointNodeName?: string;
  47167. };
  47168. };
  47169. /**
  47170. * Is it xr standard mapping or not
  47171. */
  47172. gamepadMapping: "" | "xr-standard";
  47173. /**
  47174. * Base root node of this entire model
  47175. */
  47176. rootNodeName: string;
  47177. /**
  47178. * Defines the main button component id
  47179. */
  47180. selectComponentId: string;
  47181. }
  47182. /**
  47183. * A definition for the layout map in the input profile
  47184. */
  47185. export interface IMotionControllerLayoutMap {
  47186. /**
  47187. * Layouts with handedness type as a key
  47188. */
  47189. [handedness: string]: IMotionControllerLayout;
  47190. }
  47191. /**
  47192. * The XR Input profile schema
  47193. * Profiles can be found here:
  47194. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47195. */
  47196. export interface IMotionControllerProfile {
  47197. /**
  47198. * fallback profiles for this profileId
  47199. */
  47200. fallbackProfileIds: string[];
  47201. /**
  47202. * The layout map, with handedness as key
  47203. */
  47204. layouts: IMotionControllerLayoutMap;
  47205. /**
  47206. * The id of this profile
  47207. * correlates to the profile(s) in the xrInput.profiles array
  47208. */
  47209. profileId: string;
  47210. }
  47211. /**
  47212. * A helper-interface for the 3 meshes needed for controller button animation
  47213. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47214. */
  47215. export interface IMotionControllerButtonMeshMap {
  47216. /**
  47217. * the mesh that defines the pressed value mesh position.
  47218. * This is used to find the max-position of this button
  47219. */
  47220. pressedMesh: AbstractMesh;
  47221. /**
  47222. * the mesh that defines the unpressed value mesh position.
  47223. * This is used to find the min (or initial) position of this button
  47224. */
  47225. unpressedMesh: AbstractMesh;
  47226. /**
  47227. * The mesh that will be changed when value changes
  47228. */
  47229. valueMesh: AbstractMesh;
  47230. }
  47231. /**
  47232. * A helper-interface for the 3 meshes needed for controller axis animation.
  47233. * This will be expanded when touchpad animations are fully supported
  47234. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47235. */
  47236. export interface IMotionControllerMeshMap {
  47237. /**
  47238. * the mesh that defines the maximum value mesh position.
  47239. */
  47240. maxMesh?: AbstractMesh;
  47241. /**
  47242. * the mesh that defines the minimum value mesh position.
  47243. */
  47244. minMesh?: AbstractMesh;
  47245. /**
  47246. * The mesh that will be changed when axis value changes
  47247. */
  47248. valueMesh: AbstractMesh;
  47249. }
  47250. /**
  47251. * The elements needed for change-detection of the gamepad objects in motion controllers
  47252. */
  47253. export interface IMinimalMotionControllerObject {
  47254. /**
  47255. * Available axes of this controller
  47256. */
  47257. axes: number[];
  47258. /**
  47259. * An array of available buttons
  47260. */
  47261. buttons: Array<{
  47262. /**
  47263. * Value of the button/trigger
  47264. */
  47265. value: number;
  47266. /**
  47267. * If the button/trigger is currently touched
  47268. */
  47269. touched: boolean;
  47270. /**
  47271. * If the button/trigger is currently pressed
  47272. */
  47273. pressed: boolean;
  47274. }>;
  47275. /**
  47276. * EXPERIMENTAL haptic support.
  47277. */
  47278. hapticActuators?: Array<{
  47279. pulse: (value: number, duration: number) => Promise<boolean>;
  47280. }>;
  47281. }
  47282. /**
  47283. * An Abstract Motion controller
  47284. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47285. * Each component has an observable to check for changes in value and state
  47286. */
  47287. export abstract class WebXRAbstractMotionController implements IDisposable {
  47288. protected scene: Scene;
  47289. protected layout: IMotionControllerLayout;
  47290. /**
  47291. * The gamepad object correlating to this controller
  47292. */
  47293. gamepadObject: IMinimalMotionControllerObject;
  47294. /**
  47295. * handedness (left/right/none) of this controller
  47296. */
  47297. handedness: MotionControllerHandedness;
  47298. private _initComponent;
  47299. private _modelReady;
  47300. /**
  47301. * A map of components (WebXRControllerComponent) in this motion controller
  47302. * Components have a ComponentType and can also have both button and axis definitions
  47303. */
  47304. readonly components: {
  47305. [id: string]: WebXRControllerComponent;
  47306. };
  47307. /**
  47308. * Disable the model's animation. Can be set at any time.
  47309. */
  47310. disableAnimation: boolean;
  47311. /**
  47312. * Observers registered here will be triggered when the model of this controller is done loading
  47313. */
  47314. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47315. /**
  47316. * The profile id of this motion controller
  47317. */
  47318. abstract profileId: string;
  47319. /**
  47320. * The root mesh of the model. It is null if the model was not yet initialized
  47321. */
  47322. rootMesh: Nullable<AbstractMesh>;
  47323. /**
  47324. * constructs a new abstract motion controller
  47325. * @param scene the scene to which the model of the controller will be added
  47326. * @param layout The profile layout to load
  47327. * @param gamepadObject The gamepad object correlating to this controller
  47328. * @param handedness handedness (left/right/none) of this controller
  47329. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47330. */
  47331. constructor(scene: Scene, layout: IMotionControllerLayout,
  47332. /**
  47333. * The gamepad object correlating to this controller
  47334. */
  47335. gamepadObject: IMinimalMotionControllerObject,
  47336. /**
  47337. * handedness (left/right/none) of this controller
  47338. */
  47339. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47340. /**
  47341. * Dispose this controller, the model mesh and all its components
  47342. */
  47343. dispose(): void;
  47344. /**
  47345. * Returns all components of specific type
  47346. * @param type the type to search for
  47347. * @return an array of components with this type
  47348. */
  47349. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47350. /**
  47351. * get a component based an its component id as defined in layout.components
  47352. * @param id the id of the component
  47353. * @returns the component correlates to the id or undefined if not found
  47354. */
  47355. getComponent(id: string): WebXRControllerComponent;
  47356. /**
  47357. * Get the list of components available in this motion controller
  47358. * @returns an array of strings correlating to available components
  47359. */
  47360. getComponentIds(): string[];
  47361. /**
  47362. * Get the first component of specific type
  47363. * @param type type of component to find
  47364. * @return a controller component or null if not found
  47365. */
  47366. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47367. /**
  47368. * Get the main (Select) component of this controller as defined in the layout
  47369. * @returns the main component of this controller
  47370. */
  47371. getMainComponent(): WebXRControllerComponent;
  47372. /**
  47373. * Loads the model correlating to this controller
  47374. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47375. * @returns A promise fulfilled with the result of the model loading
  47376. */
  47377. loadModel(): Promise<boolean>;
  47378. /**
  47379. * Update this model using the current XRFrame
  47380. * @param xrFrame the current xr frame to use and update the model
  47381. */
  47382. updateFromXRFrame(xrFrame: XRFrame): void;
  47383. /**
  47384. * Backwards compatibility due to a deeply-integrated typo
  47385. */
  47386. get handness(): XREye;
  47387. /**
  47388. * Pulse (vibrate) this controller
  47389. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47390. * Consecutive calls to this function will cancel the last pulse call
  47391. *
  47392. * @param value the strength of the pulse in 0.0...1.0 range
  47393. * @param duration Duration of the pulse in milliseconds
  47394. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47395. * @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
  47396. */
  47397. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47398. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47399. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47400. /**
  47401. * Moves the axis on the controller mesh based on its current state
  47402. * @param axis the index of the axis
  47403. * @param axisValue the value of the axis which determines the meshes new position
  47404. * @hidden
  47405. */
  47406. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47407. /**
  47408. * Update the model itself with the current frame data
  47409. * @param xrFrame the frame to use for updating the model mesh
  47410. */
  47411. protected updateModel(xrFrame: XRFrame): void;
  47412. /**
  47413. * Get the filename and path for this controller's model
  47414. * @returns a map of filename and path
  47415. */
  47416. protected abstract _getFilenameAndPath(): {
  47417. filename: string;
  47418. path: string;
  47419. };
  47420. /**
  47421. * This function is called before the mesh is loaded. It checks for loading constraints.
  47422. * For example, this function can check if the GLB loader is available
  47423. * If this function returns false, the generic controller will be loaded instead
  47424. * @returns Is the client ready to load the mesh
  47425. */
  47426. protected abstract _getModelLoadingConstraints(): boolean;
  47427. /**
  47428. * This function will be called after the model was successfully loaded and can be used
  47429. * for mesh transformations before it is available for the user
  47430. * @param meshes the loaded meshes
  47431. */
  47432. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47433. /**
  47434. * Set the root mesh for this controller. Important for the WebXR controller class
  47435. * @param meshes the loaded meshes
  47436. */
  47437. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47438. /**
  47439. * A function executed each frame that updates the mesh (if needed)
  47440. * @param xrFrame the current xrFrame
  47441. */
  47442. protected abstract _updateModel(xrFrame: XRFrame): void;
  47443. private _getGenericFilenameAndPath;
  47444. private _getGenericParentMesh;
  47445. }
  47446. }
  47447. declare module BABYLON {
  47448. /**
  47449. * A generic trigger-only motion controller for WebXR
  47450. */
  47451. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47452. /**
  47453. * Static version of the profile id of this controller
  47454. */
  47455. static ProfileId: string;
  47456. profileId: string;
  47457. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47458. protected _getFilenameAndPath(): {
  47459. filename: string;
  47460. path: string;
  47461. };
  47462. protected _getModelLoadingConstraints(): boolean;
  47463. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47464. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47465. protected _updateModel(): void;
  47466. }
  47467. }
  47468. declare module BABYLON {
  47469. /**
  47470. * Class containing static functions to help procedurally build meshes
  47471. */
  47472. export class SphereBuilder {
  47473. /**
  47474. * Creates a sphere mesh
  47475. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47476. * * 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`)
  47477. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47478. * * 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
  47479. * * 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)
  47480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47481. * * 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
  47482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47483. * @param name defines the name of the mesh
  47484. * @param options defines the options used to create the mesh
  47485. * @param scene defines the hosting scene
  47486. * @returns the sphere mesh
  47487. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47488. */
  47489. static CreateSphere(name: string, options: {
  47490. segments?: number;
  47491. diameter?: number;
  47492. diameterX?: number;
  47493. diameterY?: number;
  47494. diameterZ?: number;
  47495. arc?: number;
  47496. slice?: number;
  47497. sideOrientation?: number;
  47498. frontUVs?: Vector4;
  47499. backUVs?: Vector4;
  47500. updatable?: boolean;
  47501. }, scene?: Nullable<Scene>): Mesh;
  47502. }
  47503. }
  47504. declare module BABYLON {
  47505. /**
  47506. * A profiled motion controller has its profile loaded from an online repository.
  47507. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47508. */
  47509. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47510. private _repositoryUrl;
  47511. private _buttonMeshMapping;
  47512. private _touchDots;
  47513. /**
  47514. * The profile ID of this controller. Will be populated when the controller initializes.
  47515. */
  47516. profileId: string;
  47517. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47518. dispose(): void;
  47519. protected _getFilenameAndPath(): {
  47520. filename: string;
  47521. path: string;
  47522. };
  47523. protected _getModelLoadingConstraints(): boolean;
  47524. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47525. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47526. protected _updateModel(_xrFrame: XRFrame): void;
  47527. }
  47528. }
  47529. declare module BABYLON {
  47530. /**
  47531. * A construction function type to create a new controller based on an xrInput object
  47532. */
  47533. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47534. /**
  47535. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47536. *
  47537. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47538. * it should be replaced with auto-loaded controllers.
  47539. *
  47540. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47541. */
  47542. export class WebXRMotionControllerManager {
  47543. private static _AvailableControllers;
  47544. private static _Fallbacks;
  47545. private static _ProfileLoadingPromises;
  47546. private static _ProfilesList;
  47547. /**
  47548. * The base URL of the online controller repository. Can be changed at any time.
  47549. */
  47550. static BaseRepositoryUrl: string;
  47551. /**
  47552. * Which repository gets priority - local or online
  47553. */
  47554. static PrioritizeOnlineRepository: boolean;
  47555. /**
  47556. * Use the online repository, or use only locally-defined controllers
  47557. */
  47558. static UseOnlineRepository: boolean;
  47559. /**
  47560. * Clear the cache used for profile loading and reload when requested again
  47561. */
  47562. static ClearProfilesCache(): void;
  47563. /**
  47564. * Register the default fallbacks.
  47565. * This function is called automatically when this file is imported.
  47566. */
  47567. static DefaultFallbacks(): void;
  47568. /**
  47569. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47570. * @param profileId the profile to which a fallback needs to be found
  47571. * @return an array with corresponding fallback profiles
  47572. */
  47573. static FindFallbackWithProfileId(profileId: string): string[];
  47574. /**
  47575. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47576. * The order of search:
  47577. *
  47578. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47579. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47580. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47581. * 4) return the generic trigger controller if none were found
  47582. *
  47583. * @param xrInput the xrInput to which a new controller is initialized
  47584. * @param scene the scene to which the model will be added
  47585. * @param forceProfile force a certain profile for this controller
  47586. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47587. */
  47588. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47589. /**
  47590. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47591. *
  47592. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47593. *
  47594. * @param type the profile type to register
  47595. * @param constructFunction the function to be called when loading this profile
  47596. */
  47597. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47598. /**
  47599. * Register a fallback to a specific profile.
  47600. * @param profileId the profileId that will receive the fallbacks
  47601. * @param fallbacks A list of fallback profiles
  47602. */
  47603. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47604. /**
  47605. * Will update the list of profiles available in the repository
  47606. * @return a promise that resolves to a map of profiles available online
  47607. */
  47608. static UpdateProfilesList(): Promise<{
  47609. [profile: string]: string;
  47610. }>;
  47611. private static _LoadProfileFromRepository;
  47612. private static _LoadProfilesFromAvailableControllers;
  47613. }
  47614. }
  47615. declare module BABYLON {
  47616. /**
  47617. * Configuration options for the WebXR controller creation
  47618. */
  47619. export interface IWebXRControllerOptions {
  47620. /**
  47621. * Should the controller mesh be animated when a user interacts with it
  47622. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47623. */
  47624. disableMotionControllerAnimation?: boolean;
  47625. /**
  47626. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47627. */
  47628. doNotLoadControllerMesh?: boolean;
  47629. /**
  47630. * Force a specific controller type for this controller.
  47631. * This can be used when creating your own profile or when testing different controllers
  47632. */
  47633. forceControllerProfile?: string;
  47634. /**
  47635. * Defines a rendering group ID for meshes that will be loaded.
  47636. * This is for the default controllers only.
  47637. */
  47638. renderingGroupId?: number;
  47639. }
  47640. /**
  47641. * Represents an XR controller
  47642. */
  47643. export class WebXRInputSource {
  47644. private _scene;
  47645. /** The underlying input source for the controller */
  47646. inputSource: XRInputSource;
  47647. private _options;
  47648. private _tmpVector;
  47649. private _uniqueId;
  47650. /**
  47651. * 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
  47652. */
  47653. grip?: AbstractMesh;
  47654. /**
  47655. * If available, this is the gamepad object related to this controller.
  47656. * Using this object it is possible to get click events and trackpad changes of the
  47657. * webxr controller that is currently being used.
  47658. */
  47659. motionController?: WebXRAbstractMotionController;
  47660. /**
  47661. * Event that fires when the controller is removed/disposed.
  47662. * The object provided as event data is this controller, after associated assets were disposed.
  47663. * uniqueId is still available.
  47664. */
  47665. onDisposeObservable: Observable<WebXRInputSource>;
  47666. /**
  47667. * Will be triggered when the mesh associated with the motion controller is done loading.
  47668. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47669. * A shortened version of controller -> motion controller -> on mesh loaded.
  47670. */
  47671. onMeshLoadedObservable: Observable<AbstractMesh>;
  47672. /**
  47673. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47674. */
  47675. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47676. /**
  47677. * Pointer which can be used to select objects or attach a visible laser to
  47678. */
  47679. pointer: AbstractMesh;
  47680. /**
  47681. * Creates the input source object
  47682. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  47683. * @param _scene the scene which the controller should be associated to
  47684. * @param inputSource the underlying input source for the controller
  47685. * @param _options options for this controller creation
  47686. */
  47687. constructor(_scene: Scene,
  47688. /** The underlying input source for the controller */
  47689. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47690. /**
  47691. * Get this controllers unique id
  47692. */
  47693. get uniqueId(): string;
  47694. /**
  47695. * Disposes of the object
  47696. */
  47697. dispose(): void;
  47698. /**
  47699. * Gets a world space ray coming from the pointer or grip
  47700. * @param result the resulting ray
  47701. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47702. */
  47703. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47704. /**
  47705. * Updates the controller pose based on the given XRFrame
  47706. * @param xrFrame xr frame to update the pose with
  47707. * @param referenceSpace reference space to use
  47708. */
  47709. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47710. }
  47711. }
  47712. declare module BABYLON {
  47713. /**
  47714. * The schema for initialization options of the XR Input class
  47715. */
  47716. export interface IWebXRInputOptions {
  47717. /**
  47718. * If set to true no model will be automatically loaded
  47719. */
  47720. doNotLoadControllerMeshes?: boolean;
  47721. /**
  47722. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47723. * If not found, the xr input profile data will be used.
  47724. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47725. */
  47726. forceInputProfile?: string;
  47727. /**
  47728. * Do not send a request to the controller repository to load the profile.
  47729. *
  47730. * Instead, use the controllers available in babylon itself.
  47731. */
  47732. disableOnlineControllerRepository?: boolean;
  47733. /**
  47734. * A custom URL for the controllers repository
  47735. */
  47736. customControllersRepositoryURL?: string;
  47737. /**
  47738. * Should the controller model's components not move according to the user input
  47739. */
  47740. disableControllerAnimation?: boolean;
  47741. /**
  47742. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47743. */
  47744. controllerOptions?: IWebXRControllerOptions;
  47745. }
  47746. /**
  47747. * XR input used to track XR inputs such as controllers/rays
  47748. */
  47749. export class WebXRInput implements IDisposable {
  47750. /**
  47751. * the xr session manager for this session
  47752. */
  47753. xrSessionManager: WebXRSessionManager;
  47754. /**
  47755. * the WebXR camera for this session. Mainly used for teleportation
  47756. */
  47757. xrCamera: WebXRCamera;
  47758. private readonly options;
  47759. /**
  47760. * XR controllers being tracked
  47761. */
  47762. controllers: Array<WebXRInputSource>;
  47763. private _frameObserver;
  47764. private _sessionEndedObserver;
  47765. private _sessionInitObserver;
  47766. /**
  47767. * Event when a controller has been connected/added
  47768. */
  47769. onControllerAddedObservable: Observable<WebXRInputSource>;
  47770. /**
  47771. * Event when a controller has been removed/disconnected
  47772. */
  47773. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47774. /**
  47775. * Initializes the WebXRInput
  47776. * @param xrSessionManager the xr session manager for this session
  47777. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47778. * @param options = initialization options for this xr input
  47779. */
  47780. constructor(
  47781. /**
  47782. * the xr session manager for this session
  47783. */
  47784. xrSessionManager: WebXRSessionManager,
  47785. /**
  47786. * the WebXR camera for this session. Mainly used for teleportation
  47787. */
  47788. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47789. private _onInputSourcesChange;
  47790. private _addAndRemoveControllers;
  47791. /**
  47792. * Disposes of the object
  47793. */
  47794. dispose(): void;
  47795. }
  47796. }
  47797. declare module BABYLON {
  47798. /**
  47799. * This is the base class for all WebXR features.
  47800. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47801. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47802. */
  47803. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47804. protected _xrSessionManager: WebXRSessionManager;
  47805. private _attached;
  47806. private _removeOnDetach;
  47807. /**
  47808. * Should auto-attach be disabled?
  47809. */
  47810. disableAutoAttach: boolean;
  47811. /**
  47812. * Construct a new (abstract) WebXR feature
  47813. * @param _xrSessionManager the xr session manager for this feature
  47814. */
  47815. constructor(_xrSessionManager: WebXRSessionManager);
  47816. /**
  47817. * Is this feature attached
  47818. */
  47819. get attached(): boolean;
  47820. /**
  47821. * attach this feature
  47822. *
  47823. * @param force should attachment be forced (even when already attached)
  47824. * @returns true if successful, false is failed or already attached
  47825. */
  47826. attach(force?: boolean): boolean;
  47827. /**
  47828. * detach this feature.
  47829. *
  47830. * @returns true if successful, false if failed or already detached
  47831. */
  47832. detach(): boolean;
  47833. /**
  47834. * Dispose this feature and all of the resources attached
  47835. */
  47836. dispose(): void;
  47837. /**
  47838. * This is used to register callbacks that will automatically be removed when detach is called.
  47839. * @param observable the observable to which the observer will be attached
  47840. * @param callback the callback to register
  47841. */
  47842. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47843. /**
  47844. * Code in this function will be executed on each xrFrame received from the browser.
  47845. * This function will not execute after the feature is detached.
  47846. * @param _xrFrame the current frame
  47847. */
  47848. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47849. }
  47850. }
  47851. declare module BABYLON {
  47852. /**
  47853. * Renders a layer on top of an existing scene
  47854. */
  47855. export class UtilityLayerRenderer implements IDisposable {
  47856. /** the original scene that will be rendered on top of */
  47857. originalScene: Scene;
  47858. private _pointerCaptures;
  47859. private _lastPointerEvents;
  47860. private static _DefaultUtilityLayer;
  47861. private static _DefaultKeepDepthUtilityLayer;
  47862. private _sharedGizmoLight;
  47863. private _renderCamera;
  47864. /**
  47865. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47866. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47867. * @returns the camera that is used when rendering the utility layer
  47868. */
  47869. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47870. /**
  47871. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47872. * @param cam the camera that should be used when rendering the utility layer
  47873. */
  47874. setRenderCamera(cam: Nullable<Camera>): void;
  47875. /**
  47876. * @hidden
  47877. * Light which used by gizmos to get light shading
  47878. */
  47879. _getSharedGizmoLight(): HemisphericLight;
  47880. /**
  47881. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47882. */
  47883. pickUtilitySceneFirst: boolean;
  47884. /**
  47885. * 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)
  47886. */
  47887. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47888. /**
  47889. * 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)
  47890. */
  47891. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47892. /**
  47893. * The scene that is rendered on top of the original scene
  47894. */
  47895. utilityLayerScene: Scene;
  47896. /**
  47897. * If the utility layer should automatically be rendered on top of existing scene
  47898. */
  47899. shouldRender: boolean;
  47900. /**
  47901. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47902. */
  47903. onlyCheckPointerDownEvents: boolean;
  47904. /**
  47905. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47906. */
  47907. processAllEvents: boolean;
  47908. /**
  47909. * Observable raised when the pointer move from the utility layer scene to the main scene
  47910. */
  47911. onPointerOutObservable: Observable<number>;
  47912. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47913. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47914. private _afterRenderObserver;
  47915. private _sceneDisposeObserver;
  47916. private _originalPointerObserver;
  47917. /**
  47918. * Instantiates a UtilityLayerRenderer
  47919. * @param originalScene the original scene that will be rendered on top of
  47920. * @param handleEvents boolean indicating if the utility layer should handle events
  47921. */
  47922. constructor(
  47923. /** the original scene that will be rendered on top of */
  47924. originalScene: Scene, handleEvents?: boolean);
  47925. private _notifyObservers;
  47926. /**
  47927. * Renders the utility layers scene on top of the original scene
  47928. */
  47929. render(): void;
  47930. /**
  47931. * Disposes of the renderer
  47932. */
  47933. dispose(): void;
  47934. private _updateCamera;
  47935. }
  47936. }
  47937. declare module BABYLON {
  47938. /**
  47939. * Options interface for the pointer selection module
  47940. */
  47941. export interface IWebXRControllerPointerSelectionOptions {
  47942. /**
  47943. * if provided, this scene will be used to render meshes.
  47944. */
  47945. customUtilityLayerScene?: Scene;
  47946. /**
  47947. * 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)
  47948. * If not disabled, the last picked point will be used to execute a pointer up event
  47949. * If disabled, pointer up event will be triggered right after the pointer down event.
  47950. * Used in screen and gaze target ray mode only
  47951. */
  47952. disablePointerUpOnTouchOut: boolean;
  47953. /**
  47954. * For gaze mode (time to select instead of press)
  47955. */
  47956. forceGazeMode: boolean;
  47957. /**
  47958. * 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
  47959. * to start a new countdown to the pointer down event.
  47960. * Defaults to 1.
  47961. */
  47962. gazeModePointerMovedFactor?: number;
  47963. /**
  47964. * Different button type to use instead of the main component
  47965. */
  47966. overrideButtonId?: string;
  47967. /**
  47968. * use this rendering group id for the meshes (optional)
  47969. */
  47970. renderingGroupId?: number;
  47971. /**
  47972. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47973. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47974. * 3000 means 3 seconds between pointing at something and selecting it
  47975. */
  47976. timeToSelect?: number;
  47977. /**
  47978. * Should meshes created here be added to a utility layer or the main scene
  47979. */
  47980. useUtilityLayer?: boolean;
  47981. /**
  47982. * the xr input to use with this pointer selection
  47983. */
  47984. xrInput: WebXRInput;
  47985. }
  47986. /**
  47987. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47988. */
  47989. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47990. private readonly _options;
  47991. private static _idCounter;
  47992. private _attachController;
  47993. private _controllers;
  47994. private _scene;
  47995. private _tmpVectorForPickCompare;
  47996. /**
  47997. * The module's name
  47998. */
  47999. static readonly Name: string;
  48000. /**
  48001. * The (Babylon) version of this module.
  48002. * This is an integer representing the implementation version.
  48003. * This number does not correspond to the WebXR specs version
  48004. */
  48005. static readonly Version: number;
  48006. /**
  48007. * Disable lighting on the laser pointer (so it will always be visible)
  48008. */
  48009. disablePointerLighting: boolean;
  48010. /**
  48011. * Disable lighting on the selection mesh (so it will always be visible)
  48012. */
  48013. disableSelectionMeshLighting: boolean;
  48014. /**
  48015. * Should the laser pointer be displayed
  48016. */
  48017. displayLaserPointer: boolean;
  48018. /**
  48019. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48020. */
  48021. displaySelectionMesh: boolean;
  48022. /**
  48023. * This color will be set to the laser pointer when selection is triggered
  48024. */
  48025. laserPointerPickedColor: Color3;
  48026. /**
  48027. * Default color of the laser pointer
  48028. */
  48029. laserPointerDefaultColor: Color3;
  48030. /**
  48031. * default color of the selection ring
  48032. */
  48033. selectionMeshDefaultColor: Color3;
  48034. /**
  48035. * This color will be applied to the selection ring when selection is triggered
  48036. */
  48037. selectionMeshPickedColor: Color3;
  48038. /**
  48039. * Optional filter to be used for ray selection. This predicate shares behavior with
  48040. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48041. */
  48042. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48043. /**
  48044. * constructs a new background remover module
  48045. * @param _xrSessionManager the session manager for this module
  48046. * @param _options read-only options to be used in this module
  48047. */
  48048. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48049. /**
  48050. * attach this feature
  48051. * Will usually be called by the features manager
  48052. *
  48053. * @returns true if successful.
  48054. */
  48055. attach(): boolean;
  48056. /**
  48057. * detach this feature.
  48058. * Will usually be called by the features manager
  48059. *
  48060. * @returns true if successful.
  48061. */
  48062. detach(): boolean;
  48063. /**
  48064. * Will get the mesh under a specific pointer.
  48065. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48066. * @param controllerId the controllerId to check
  48067. * @returns The mesh under pointer or null if no mesh is under the pointer
  48068. */
  48069. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48070. /**
  48071. * Get the xr controller that correlates to the pointer id in the pointer event
  48072. *
  48073. * @param id the pointer id to search for
  48074. * @returns the controller that correlates to this id or null if not found
  48075. */
  48076. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48077. protected _onXRFrame(_xrFrame: XRFrame): void;
  48078. private _attachGazeMode;
  48079. private _attachScreenRayMode;
  48080. private _attachTrackedPointerRayMode;
  48081. private _convertNormalToDirectionOfRay;
  48082. private _detachController;
  48083. private _generateNewMeshPair;
  48084. private _pickingMoved;
  48085. private _updatePointerDistance;
  48086. /** @hidden */
  48087. get lasterPointerDefaultColor(): Color3;
  48088. }
  48089. }
  48090. declare module BABYLON {
  48091. /**
  48092. * Button which can be used to enter a different mode of XR
  48093. */
  48094. export class WebXREnterExitUIButton {
  48095. /** button element */
  48096. element: HTMLElement;
  48097. /** XR initialization options for the button */
  48098. sessionMode: XRSessionMode;
  48099. /** Reference space type */
  48100. referenceSpaceType: XRReferenceSpaceType;
  48101. /**
  48102. * Creates a WebXREnterExitUIButton
  48103. * @param element button element
  48104. * @param sessionMode XR initialization session mode
  48105. * @param referenceSpaceType the type of reference space to be used
  48106. */
  48107. constructor(
  48108. /** button element */
  48109. element: HTMLElement,
  48110. /** XR initialization options for the button */
  48111. sessionMode: XRSessionMode,
  48112. /** Reference space type */
  48113. referenceSpaceType: XRReferenceSpaceType);
  48114. /**
  48115. * Extendable function which can be used to update the button's visuals when the state changes
  48116. * @param activeButton the current active button in the UI
  48117. */
  48118. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48119. }
  48120. /**
  48121. * Options to create the webXR UI
  48122. */
  48123. export class WebXREnterExitUIOptions {
  48124. /**
  48125. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48126. */
  48127. customButtons?: Array<WebXREnterExitUIButton>;
  48128. /**
  48129. * A reference space type to use when creating the default button.
  48130. * Default is local-floor
  48131. */
  48132. referenceSpaceType?: XRReferenceSpaceType;
  48133. /**
  48134. * Context to enter xr with
  48135. */
  48136. renderTarget?: Nullable<WebXRRenderTarget>;
  48137. /**
  48138. * A session mode to use when creating the default button.
  48139. * Default is immersive-vr
  48140. */
  48141. sessionMode?: XRSessionMode;
  48142. /**
  48143. * A list of optional features to init the session with
  48144. */
  48145. optionalFeatures?: string[];
  48146. }
  48147. /**
  48148. * UI to allow the user to enter/exit XR mode
  48149. */
  48150. export class WebXREnterExitUI implements IDisposable {
  48151. private scene;
  48152. /** version of the options passed to this UI */
  48153. options: WebXREnterExitUIOptions;
  48154. private _activeButton;
  48155. private _buttons;
  48156. private _overlay;
  48157. /**
  48158. * Fired every time the active button is changed.
  48159. *
  48160. * When xr is entered via a button that launches xr that button will be the callback parameter
  48161. *
  48162. * When exiting xr the callback parameter will be null)
  48163. */
  48164. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48165. /**
  48166. *
  48167. * @param scene babylon scene object to use
  48168. * @param options (read-only) version of the options passed to this UI
  48169. */
  48170. private constructor();
  48171. /**
  48172. * Creates UI to allow the user to enter/exit XR mode
  48173. * @param scene the scene to add the ui to
  48174. * @param helper the xr experience helper to enter/exit xr with
  48175. * @param options options to configure the UI
  48176. * @returns the created ui
  48177. */
  48178. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48179. /**
  48180. * Disposes of the XR UI component
  48181. */
  48182. dispose(): void;
  48183. private _updateButtons;
  48184. }
  48185. }
  48186. declare module BABYLON {
  48187. /**
  48188. * Class containing static functions to help procedurally build meshes
  48189. */
  48190. export class LinesBuilder {
  48191. /**
  48192. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48193. * * 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
  48194. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48195. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48196. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48197. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48198. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48199. * * 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
  48200. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48203. * @param name defines the name of the new line system
  48204. * @param options defines the options used to create the line system
  48205. * @param scene defines the hosting scene
  48206. * @returns a new line system mesh
  48207. */
  48208. static CreateLineSystem(name: string, options: {
  48209. lines: Vector3[][];
  48210. updatable?: boolean;
  48211. instance?: Nullable<LinesMesh>;
  48212. colors?: Nullable<Color4[][]>;
  48213. useVertexAlpha?: boolean;
  48214. }, scene: Nullable<Scene>): LinesMesh;
  48215. /**
  48216. * Creates a line mesh
  48217. * 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
  48218. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48219. * * The parameter `points` is an array successive Vector3
  48220. * * 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
  48221. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48222. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48223. * * When updating an instance, remember that only point positions can change, not the number of points
  48224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48226. * @param name defines the name of the new line system
  48227. * @param options defines the options used to create the line system
  48228. * @param scene defines the hosting scene
  48229. * @returns a new line mesh
  48230. */
  48231. static CreateLines(name: string, options: {
  48232. points: Vector3[];
  48233. updatable?: boolean;
  48234. instance?: Nullable<LinesMesh>;
  48235. colors?: Color4[];
  48236. useVertexAlpha?: boolean;
  48237. }, scene?: Nullable<Scene>): LinesMesh;
  48238. /**
  48239. * Creates a dashed line mesh
  48240. * * 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
  48241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48242. * * The parameter `points` is an array successive Vector3
  48243. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48244. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48245. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48246. * * 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
  48247. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48248. * * When updating an instance, remember that only point positions can change, not the number of points
  48249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48250. * @param name defines the name of the mesh
  48251. * @param options defines the options used to create the mesh
  48252. * @param scene defines the hosting scene
  48253. * @returns the dashed line mesh
  48254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48255. */
  48256. static CreateDashedLines(name: string, options: {
  48257. points: Vector3[];
  48258. dashSize?: number;
  48259. gapSize?: number;
  48260. dashNb?: number;
  48261. updatable?: boolean;
  48262. instance?: LinesMesh;
  48263. useVertexAlpha?: boolean;
  48264. }, scene?: Nullable<Scene>): LinesMesh;
  48265. }
  48266. }
  48267. declare module BABYLON {
  48268. /**
  48269. * Construction options for a timer
  48270. */
  48271. export interface ITimerOptions<T> {
  48272. /**
  48273. * Time-to-end
  48274. */
  48275. timeout: number;
  48276. /**
  48277. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48278. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48279. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48280. */
  48281. contextObservable: Observable<T>;
  48282. /**
  48283. * Optional parameters when adding an observer to the observable
  48284. */
  48285. observableParameters?: {
  48286. mask?: number;
  48287. insertFirst?: boolean;
  48288. scope?: any;
  48289. };
  48290. /**
  48291. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48292. */
  48293. breakCondition?: (data?: ITimerData<T>) => boolean;
  48294. /**
  48295. * Will be triggered when the time condition has met
  48296. */
  48297. onEnded?: (data: ITimerData<any>) => void;
  48298. /**
  48299. * Will be triggered when the break condition has met (prematurely ended)
  48300. */
  48301. onAborted?: (data: ITimerData<any>) => void;
  48302. /**
  48303. * Optional function to execute on each tick (or count)
  48304. */
  48305. onTick?: (data: ITimerData<any>) => void;
  48306. }
  48307. /**
  48308. * An interface defining the data sent by the timer
  48309. */
  48310. export interface ITimerData<T> {
  48311. /**
  48312. * When did it start
  48313. */
  48314. startTime: number;
  48315. /**
  48316. * Time now
  48317. */
  48318. currentTime: number;
  48319. /**
  48320. * Time passed since started
  48321. */
  48322. deltaTime: number;
  48323. /**
  48324. * How much is completed, in [0.0...1.0].
  48325. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48326. */
  48327. completeRate: number;
  48328. /**
  48329. * What the registered observable sent in the last count
  48330. */
  48331. payload: T;
  48332. }
  48333. /**
  48334. * The current state of the timer
  48335. */
  48336. export enum TimerState {
  48337. /**
  48338. * Timer initialized, not yet started
  48339. */
  48340. INIT = 0,
  48341. /**
  48342. * Timer started and counting
  48343. */
  48344. STARTED = 1,
  48345. /**
  48346. * Timer ended (whether aborted or time reached)
  48347. */
  48348. ENDED = 2
  48349. }
  48350. /**
  48351. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48352. *
  48353. * @param options options with which to initialize this timer
  48354. */
  48355. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48356. /**
  48357. * An advanced implementation of a timer class
  48358. */
  48359. export class AdvancedTimer<T = any> implements IDisposable {
  48360. /**
  48361. * Will notify each time the timer calculates the remaining time
  48362. */
  48363. onEachCountObservable: Observable<ITimerData<T>>;
  48364. /**
  48365. * Will trigger when the timer was aborted due to the break condition
  48366. */
  48367. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48368. /**
  48369. * Will trigger when the timer ended successfully
  48370. */
  48371. onTimerEndedObservable: Observable<ITimerData<T>>;
  48372. /**
  48373. * Will trigger when the timer state has changed
  48374. */
  48375. onStateChangedObservable: Observable<TimerState>;
  48376. private _observer;
  48377. private _contextObservable;
  48378. private _observableParameters;
  48379. private _startTime;
  48380. private _timer;
  48381. private _state;
  48382. private _breakCondition;
  48383. private _timeToEnd;
  48384. private _breakOnNextTick;
  48385. /**
  48386. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48387. * @param options construction options for this advanced timer
  48388. */
  48389. constructor(options: ITimerOptions<T>);
  48390. /**
  48391. * set a breaking condition for this timer. Default is to never break during count
  48392. * @param predicate the new break condition. Returns true to break, false otherwise
  48393. */
  48394. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48395. /**
  48396. * Reset ALL associated observables in this advanced timer
  48397. */
  48398. clearObservables(): void;
  48399. /**
  48400. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48401. *
  48402. * @param timeToEnd how much time to measure until timer ended
  48403. */
  48404. start(timeToEnd?: number): void;
  48405. /**
  48406. * Will force a stop on the next tick.
  48407. */
  48408. stop(): void;
  48409. /**
  48410. * Dispose this timer, clearing all resources
  48411. */
  48412. dispose(): void;
  48413. private _setState;
  48414. private _tick;
  48415. private _stop;
  48416. }
  48417. }
  48418. declare module BABYLON {
  48419. /**
  48420. * The options container for the teleportation module
  48421. */
  48422. export interface IWebXRTeleportationOptions {
  48423. /**
  48424. * if provided, this scene will be used to render meshes.
  48425. */
  48426. customUtilityLayerScene?: Scene;
  48427. /**
  48428. * Values to configure the default target mesh
  48429. */
  48430. defaultTargetMeshOptions?: {
  48431. /**
  48432. * Fill color of the teleportation area
  48433. */
  48434. teleportationFillColor?: string;
  48435. /**
  48436. * Border color for the teleportation area
  48437. */
  48438. teleportationBorderColor?: string;
  48439. /**
  48440. * Disable the mesh's animation sequence
  48441. */
  48442. disableAnimation?: boolean;
  48443. /**
  48444. * Disable lighting on the material or the ring and arrow
  48445. */
  48446. disableLighting?: boolean;
  48447. /**
  48448. * Override the default material of the torus and arrow
  48449. */
  48450. torusArrowMaterial?: Material;
  48451. };
  48452. /**
  48453. * A list of meshes to use as floor meshes.
  48454. * Meshes can be added and removed after initializing the feature using the
  48455. * addFloorMesh and removeFloorMesh functions
  48456. * If empty, rotation will still work
  48457. */
  48458. floorMeshes?: AbstractMesh[];
  48459. /**
  48460. * use this rendering group id for the meshes (optional)
  48461. */
  48462. renderingGroupId?: number;
  48463. /**
  48464. * Should teleportation move only to snap points
  48465. */
  48466. snapPointsOnly?: boolean;
  48467. /**
  48468. * An array of points to which the teleportation will snap to.
  48469. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48470. */
  48471. snapPositions?: Vector3[];
  48472. /**
  48473. * How close should the teleportation ray be in order to snap to position.
  48474. * Default to 0.8 units (meters)
  48475. */
  48476. snapToPositionRadius?: number;
  48477. /**
  48478. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48479. * If you want to support rotation, make sure your mesh has a direction indicator.
  48480. *
  48481. * When left untouched, the default mesh will be initialized.
  48482. */
  48483. teleportationTargetMesh?: AbstractMesh;
  48484. /**
  48485. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48486. */
  48487. timeToTeleport?: number;
  48488. /**
  48489. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48490. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48491. */
  48492. useMainComponentOnly?: boolean;
  48493. /**
  48494. * Should meshes created here be added to a utility layer or the main scene
  48495. */
  48496. useUtilityLayer?: boolean;
  48497. /**
  48498. * Babylon XR Input class for controller
  48499. */
  48500. xrInput: WebXRInput;
  48501. }
  48502. /**
  48503. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48504. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48505. * the input of the attached controllers.
  48506. */
  48507. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48508. private _options;
  48509. private _controllers;
  48510. private _currentTeleportationControllerId;
  48511. private _floorMeshes;
  48512. private _quadraticBezierCurve;
  48513. private _selectionFeature;
  48514. private _snapToPositions;
  48515. private _snappedToPoint;
  48516. private _teleportationRingMaterial?;
  48517. private _tmpRay;
  48518. private _tmpVector;
  48519. /**
  48520. * The module's name
  48521. */
  48522. static readonly Name: string;
  48523. /**
  48524. * The (Babylon) version of this module.
  48525. * This is an integer representing the implementation version.
  48526. * This number does not correspond to the webxr specs version
  48527. */
  48528. static readonly Version: number;
  48529. /**
  48530. * Is movement backwards enabled
  48531. */
  48532. backwardsMovementEnabled: boolean;
  48533. /**
  48534. * Distance to travel when moving backwards
  48535. */
  48536. backwardsTeleportationDistance: number;
  48537. /**
  48538. * The distance from the user to the inspection point in the direction of the controller
  48539. * A higher number will allow the user to move further
  48540. * defaults to 5 (meters, in xr units)
  48541. */
  48542. parabolicCheckRadius: number;
  48543. /**
  48544. * Should the module support parabolic ray on top of direct ray
  48545. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48546. * Very helpful when moving between floors / different heights
  48547. */
  48548. parabolicRayEnabled: boolean;
  48549. /**
  48550. * How much rotation should be applied when rotating right and left
  48551. */
  48552. rotationAngle: number;
  48553. /**
  48554. * Is rotation enabled when moving forward?
  48555. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48556. */
  48557. rotationEnabled: boolean;
  48558. /**
  48559. * constructs a new anchor system
  48560. * @param _xrSessionManager an instance of WebXRSessionManager
  48561. * @param _options configuration object for this feature
  48562. */
  48563. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48564. /**
  48565. * Get the snapPointsOnly flag
  48566. */
  48567. get snapPointsOnly(): boolean;
  48568. /**
  48569. * Sets the snapPointsOnly flag
  48570. * @param snapToPoints should teleportation be exclusively to snap points
  48571. */
  48572. set snapPointsOnly(snapToPoints: boolean);
  48573. /**
  48574. * Add a new mesh to the floor meshes array
  48575. * @param mesh the mesh to use as floor mesh
  48576. */
  48577. addFloorMesh(mesh: AbstractMesh): void;
  48578. /**
  48579. * Add a new snap-to point to fix teleportation to this position
  48580. * @param newSnapPoint The new Snap-To point
  48581. */
  48582. addSnapPoint(newSnapPoint: Vector3): void;
  48583. attach(): boolean;
  48584. detach(): boolean;
  48585. dispose(): void;
  48586. /**
  48587. * Remove a mesh from the floor meshes array
  48588. * @param mesh the mesh to remove
  48589. */
  48590. removeFloorMesh(mesh: AbstractMesh): void;
  48591. /**
  48592. * Remove a mesh from the floor meshes array using its name
  48593. * @param name the mesh name to remove
  48594. */
  48595. removeFloorMeshByName(name: string): void;
  48596. /**
  48597. * 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
  48598. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48599. * @returns was the point found and removed or not
  48600. */
  48601. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48602. /**
  48603. * This function sets a selection feature that will be disabled when
  48604. * the forward ray is shown and will be reattached when hidden.
  48605. * This is used to remove the selection rays when moving.
  48606. * @param selectionFeature the feature to disable when forward movement is enabled
  48607. */
  48608. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48609. protected _onXRFrame(_xrFrame: XRFrame): void;
  48610. private _attachController;
  48611. private _createDefaultTargetMesh;
  48612. private _detachController;
  48613. private _findClosestSnapPointWithRadius;
  48614. private _setTargetMeshPosition;
  48615. private _setTargetMeshVisibility;
  48616. private _showParabolicPath;
  48617. private _teleportForward;
  48618. }
  48619. }
  48620. declare module BABYLON {
  48621. /**
  48622. * Options for the default xr helper
  48623. */
  48624. export class WebXRDefaultExperienceOptions {
  48625. /**
  48626. * Enable or disable default UI to enter XR
  48627. */
  48628. disableDefaultUI?: boolean;
  48629. /**
  48630. * Should teleportation not initialize. defaults to false.
  48631. */
  48632. disableTeleportation?: boolean;
  48633. /**
  48634. * Floor meshes that will be used for teleport
  48635. */
  48636. floorMeshes?: Array<AbstractMesh>;
  48637. /**
  48638. * If set to true, the first frame will not be used to reset position
  48639. * The first frame is mainly used when copying transformation from the old camera
  48640. * Mainly used in AR
  48641. */
  48642. ignoreNativeCameraTransformation?: boolean;
  48643. /**
  48644. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48645. */
  48646. inputOptions?: IWebXRInputOptions;
  48647. /**
  48648. * optional configuration for the output canvas
  48649. */
  48650. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48651. /**
  48652. * optional UI options. This can be used among other to change session mode and reference space type
  48653. */
  48654. uiOptions?: WebXREnterExitUIOptions;
  48655. /**
  48656. * When loading teleportation and pointer select, use stable versions instead of latest.
  48657. */
  48658. useStablePlugins?: boolean;
  48659. /**
  48660. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48661. */
  48662. renderingGroupId?: number;
  48663. /**
  48664. * A list of optional features to init the session with
  48665. * If set to true, all features we support will be added
  48666. */
  48667. optionalFeatures?: boolean | string[];
  48668. }
  48669. /**
  48670. * Default experience which provides a similar setup to the previous webVRExperience
  48671. */
  48672. export class WebXRDefaultExperience {
  48673. /**
  48674. * Base experience
  48675. */
  48676. baseExperience: WebXRExperienceHelper;
  48677. /**
  48678. * Enables ui for entering/exiting xr
  48679. */
  48680. enterExitUI: WebXREnterExitUI;
  48681. /**
  48682. * Input experience extension
  48683. */
  48684. input: WebXRInput;
  48685. /**
  48686. * Enables laser pointer and selection
  48687. */
  48688. pointerSelection: WebXRControllerPointerSelection;
  48689. /**
  48690. * Default target xr should render to
  48691. */
  48692. renderTarget: WebXRRenderTarget;
  48693. /**
  48694. * Enables teleportation
  48695. */
  48696. teleportation: WebXRMotionControllerTeleportation;
  48697. private constructor();
  48698. /**
  48699. * Creates the default xr experience
  48700. * @param scene scene
  48701. * @param options options for basic configuration
  48702. * @returns resulting WebXRDefaultExperience
  48703. */
  48704. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48705. /**
  48706. * DIsposes of the experience helper
  48707. */
  48708. dispose(): void;
  48709. }
  48710. }
  48711. declare module BABYLON {
  48712. /**
  48713. * Options to modify the vr teleportation behavior.
  48714. */
  48715. export interface VRTeleportationOptions {
  48716. /**
  48717. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48718. */
  48719. floorMeshName?: string;
  48720. /**
  48721. * A list of meshes to be used as the teleportation floor. (default: empty)
  48722. */
  48723. floorMeshes?: Mesh[];
  48724. /**
  48725. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48726. */
  48727. teleportationMode?: number;
  48728. /**
  48729. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48730. */
  48731. teleportationTime?: number;
  48732. /**
  48733. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48734. */
  48735. teleportationSpeed?: number;
  48736. /**
  48737. * The easing function used in the animation or null for Linear. (default CircleEase)
  48738. */
  48739. easingFunction?: EasingFunction;
  48740. }
  48741. /**
  48742. * Options to modify the vr experience helper's behavior.
  48743. */
  48744. export interface VRExperienceHelperOptions extends WebVROptions {
  48745. /**
  48746. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48747. */
  48748. createDeviceOrientationCamera?: boolean;
  48749. /**
  48750. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48751. */
  48752. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48753. /**
  48754. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48755. */
  48756. laserToggle?: boolean;
  48757. /**
  48758. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48759. */
  48760. floorMeshes?: Mesh[];
  48761. /**
  48762. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48763. */
  48764. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48765. /**
  48766. * Defines if WebXR should be used instead of WebVR (if available)
  48767. */
  48768. useXR?: boolean;
  48769. }
  48770. /**
  48771. * Event containing information after VR has been entered
  48772. */
  48773. export class OnAfterEnteringVRObservableEvent {
  48774. /**
  48775. * If entering vr was successful
  48776. */
  48777. success: boolean;
  48778. }
  48779. /**
  48780. * Helps to quickly add VR support to an existing scene.
  48781. * See https://doc.babylonjs.com/how_to/webvr_helper
  48782. */
  48783. export class VRExperienceHelper {
  48784. /** Options to modify the vr experience helper's behavior. */
  48785. webVROptions: VRExperienceHelperOptions;
  48786. private _scene;
  48787. private _position;
  48788. private _btnVR;
  48789. private _btnVRDisplayed;
  48790. private _webVRsupported;
  48791. private _webVRready;
  48792. private _webVRrequesting;
  48793. private _webVRpresenting;
  48794. private _hasEnteredVR;
  48795. private _fullscreenVRpresenting;
  48796. private _inputElement;
  48797. private _webVRCamera;
  48798. private _vrDeviceOrientationCamera;
  48799. private _deviceOrientationCamera;
  48800. private _existingCamera;
  48801. private _onKeyDown;
  48802. private _onVrDisplayPresentChange;
  48803. private _onVRDisplayChanged;
  48804. private _onVRRequestPresentStart;
  48805. private _onVRRequestPresentComplete;
  48806. /**
  48807. * 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)
  48808. */
  48809. enableGazeEvenWhenNoPointerLock: boolean;
  48810. /**
  48811. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48812. */
  48813. exitVROnDoubleTap: boolean;
  48814. /**
  48815. * Observable raised right before entering VR.
  48816. */
  48817. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48818. /**
  48819. * Observable raised when entering VR has completed.
  48820. */
  48821. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48822. /**
  48823. * Observable raised when exiting VR.
  48824. */
  48825. onExitingVRObservable: Observable<VRExperienceHelper>;
  48826. /**
  48827. * Observable raised when controller mesh is loaded.
  48828. */
  48829. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48830. /** Return this.onEnteringVRObservable
  48831. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48832. */
  48833. get onEnteringVR(): Observable<VRExperienceHelper>;
  48834. /** Return this.onExitingVRObservable
  48835. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48836. */
  48837. get onExitingVR(): Observable<VRExperienceHelper>;
  48838. /** Return this.onControllerMeshLoadedObservable
  48839. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48840. */
  48841. get onControllerMeshLoaded(): Observable<WebVRController>;
  48842. private _rayLength;
  48843. private _useCustomVRButton;
  48844. private _teleportationRequested;
  48845. private _teleportActive;
  48846. private _floorMeshName;
  48847. private _floorMeshesCollection;
  48848. private _teleportationMode;
  48849. private _teleportationTime;
  48850. private _teleportationSpeed;
  48851. private _teleportationEasing;
  48852. private _rotationAllowed;
  48853. private _teleportBackwardsVector;
  48854. private _teleportationTarget;
  48855. private _isDefaultTeleportationTarget;
  48856. private _postProcessMove;
  48857. private _teleportationFillColor;
  48858. private _teleportationBorderColor;
  48859. private _rotationAngle;
  48860. private _haloCenter;
  48861. private _cameraGazer;
  48862. private _padSensibilityUp;
  48863. private _padSensibilityDown;
  48864. private _leftController;
  48865. private _rightController;
  48866. private _gazeColor;
  48867. private _laserColor;
  48868. private _pickedLaserColor;
  48869. private _pickedGazeColor;
  48870. /**
  48871. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48872. */
  48873. onNewMeshSelected: Observable<AbstractMesh>;
  48874. /**
  48875. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48876. * This observable will provide the mesh and the controller used to select the mesh
  48877. */
  48878. onMeshSelectedWithController: Observable<{
  48879. mesh: AbstractMesh;
  48880. controller: WebVRController;
  48881. }>;
  48882. /**
  48883. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48884. */
  48885. onNewMeshPicked: Observable<PickingInfo>;
  48886. private _circleEase;
  48887. /**
  48888. * Observable raised before camera teleportation
  48889. */
  48890. onBeforeCameraTeleport: Observable<Vector3>;
  48891. /**
  48892. * Observable raised after camera teleportation
  48893. */
  48894. onAfterCameraTeleport: Observable<Vector3>;
  48895. /**
  48896. * Observable raised when current selected mesh gets unselected
  48897. */
  48898. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48899. private _raySelectionPredicate;
  48900. /**
  48901. * To be optionaly changed by user to define custom ray selection
  48902. */
  48903. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48904. /**
  48905. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48906. */
  48907. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48908. /**
  48909. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48910. */
  48911. teleportationEnabled: boolean;
  48912. private _defaultHeight;
  48913. private _teleportationInitialized;
  48914. private _interactionsEnabled;
  48915. private _interactionsRequested;
  48916. private _displayGaze;
  48917. private _displayLaserPointer;
  48918. /**
  48919. * The mesh used to display where the user is going to teleport.
  48920. */
  48921. get teleportationTarget(): Mesh;
  48922. /**
  48923. * Sets the mesh to be used to display where the user is going to teleport.
  48924. */
  48925. set teleportationTarget(value: Mesh);
  48926. /**
  48927. * 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
  48928. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48929. * See https://doc.babylonjs.com/resources/baking_transformations
  48930. */
  48931. get gazeTrackerMesh(): Mesh;
  48932. set gazeTrackerMesh(value: Mesh);
  48933. /**
  48934. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48935. */
  48936. updateGazeTrackerScale: boolean;
  48937. /**
  48938. * If the gaze trackers color should be updated when selecting meshes
  48939. */
  48940. updateGazeTrackerColor: boolean;
  48941. /**
  48942. * If the controller laser color should be updated when selecting meshes
  48943. */
  48944. updateControllerLaserColor: boolean;
  48945. /**
  48946. * The gaze tracking mesh corresponding to the left controller
  48947. */
  48948. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48949. /**
  48950. * The gaze tracking mesh corresponding to the right controller
  48951. */
  48952. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48953. /**
  48954. * If the ray of the gaze should be displayed.
  48955. */
  48956. get displayGaze(): boolean;
  48957. /**
  48958. * Sets if the ray of the gaze should be displayed.
  48959. */
  48960. set displayGaze(value: boolean);
  48961. /**
  48962. * If the ray of the LaserPointer should be displayed.
  48963. */
  48964. get displayLaserPointer(): boolean;
  48965. /**
  48966. * Sets if the ray of the LaserPointer should be displayed.
  48967. */
  48968. set displayLaserPointer(value: boolean);
  48969. /**
  48970. * The deviceOrientationCamera used as the camera when not in VR.
  48971. */
  48972. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48973. /**
  48974. * Based on the current WebVR support, returns the current VR camera used.
  48975. */
  48976. get currentVRCamera(): Nullable<Camera>;
  48977. /**
  48978. * The webVRCamera which is used when in VR.
  48979. */
  48980. get webVRCamera(): WebVRFreeCamera;
  48981. /**
  48982. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48983. */
  48984. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48985. /**
  48986. * The html button that is used to trigger entering into VR.
  48987. */
  48988. get vrButton(): Nullable<HTMLButtonElement>;
  48989. private get _teleportationRequestInitiated();
  48990. /**
  48991. * Defines whether or not Pointer lock should be requested when switching to
  48992. * full screen.
  48993. */
  48994. requestPointerLockOnFullScreen: boolean;
  48995. /**
  48996. * If asking to force XR, this will be populated with the default xr experience
  48997. */
  48998. xr: WebXRDefaultExperience;
  48999. /**
  49000. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49001. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49002. */
  49003. xrTestDone: boolean;
  49004. /**
  49005. * Instantiates a VRExperienceHelper.
  49006. * Helps to quickly add VR support to an existing scene.
  49007. * @param scene The scene the VRExperienceHelper belongs to.
  49008. * @param webVROptions Options to modify the vr experience helper's behavior.
  49009. */
  49010. constructor(scene: Scene,
  49011. /** Options to modify the vr experience helper's behavior. */
  49012. webVROptions?: VRExperienceHelperOptions);
  49013. private completeVRInit;
  49014. private _onDefaultMeshLoaded;
  49015. private _onResize;
  49016. private _onFullscreenChange;
  49017. /**
  49018. * Gets a value indicating if we are currently in VR mode.
  49019. */
  49020. get isInVRMode(): boolean;
  49021. private onVrDisplayPresentChange;
  49022. private onVRDisplayChanged;
  49023. private moveButtonToBottomRight;
  49024. private displayVRButton;
  49025. private updateButtonVisibility;
  49026. private _cachedAngularSensibility;
  49027. /**
  49028. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49029. * Otherwise, will use the fullscreen API.
  49030. */
  49031. enterVR(): void;
  49032. /**
  49033. * Attempt to exit VR, or fullscreen.
  49034. */
  49035. exitVR(): void;
  49036. /**
  49037. * The position of the vr experience helper.
  49038. */
  49039. get position(): Vector3;
  49040. /**
  49041. * Sets the position of the vr experience helper.
  49042. */
  49043. set position(value: Vector3);
  49044. /**
  49045. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49046. */
  49047. enableInteractions(): void;
  49048. private get _noControllerIsActive();
  49049. private beforeRender;
  49050. private _isTeleportationFloor;
  49051. /**
  49052. * Adds a floor mesh to be used for teleportation.
  49053. * @param floorMesh the mesh to be used for teleportation.
  49054. */
  49055. addFloorMesh(floorMesh: Mesh): void;
  49056. /**
  49057. * Removes a floor mesh from being used for teleportation.
  49058. * @param floorMesh the mesh to be removed.
  49059. */
  49060. removeFloorMesh(floorMesh: Mesh): void;
  49061. /**
  49062. * Enables interactions and teleportation using the VR controllers and gaze.
  49063. * @param vrTeleportationOptions options to modify teleportation behavior.
  49064. */
  49065. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49066. private _onNewGamepadConnected;
  49067. private _tryEnableInteractionOnController;
  49068. private _onNewGamepadDisconnected;
  49069. private _enableInteractionOnController;
  49070. private _checkTeleportWithRay;
  49071. private _checkRotate;
  49072. private _checkTeleportBackwards;
  49073. private _enableTeleportationOnController;
  49074. private _createTeleportationCircles;
  49075. private _displayTeleportationTarget;
  49076. private _hideTeleportationTarget;
  49077. private _rotateCamera;
  49078. private _moveTeleportationSelectorTo;
  49079. private _workingVector;
  49080. private _workingQuaternion;
  49081. private _workingMatrix;
  49082. /**
  49083. * Time Constant Teleportation Mode
  49084. */
  49085. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49086. /**
  49087. * Speed Constant Teleportation Mode
  49088. */
  49089. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49090. /**
  49091. * Teleports the users feet to the desired location
  49092. * @param location The location where the user's feet should be placed
  49093. */
  49094. teleportCamera(location: Vector3): void;
  49095. private _convertNormalToDirectionOfRay;
  49096. private _castRayAndSelectObject;
  49097. private _notifySelectedMeshUnselected;
  49098. /**
  49099. * Permanently set new colors for the laser pointer
  49100. * @param color the new laser color
  49101. * @param pickedColor the new laser color when picked mesh detected
  49102. */
  49103. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49104. /**
  49105. * Set lighting enabled / disabled on the laser pointer of both controllers
  49106. * @param enabled should the lighting be enabled on the laser pointer
  49107. */
  49108. setLaserLightingState(enabled?: boolean): void;
  49109. /**
  49110. * Permanently set new colors for the gaze pointer
  49111. * @param color the new gaze color
  49112. * @param pickedColor the new gaze color when picked mesh detected
  49113. */
  49114. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49115. /**
  49116. * Sets the color of the laser ray from the vr controllers.
  49117. * @param color new color for the ray.
  49118. */
  49119. changeLaserColor(color: Color3): void;
  49120. /**
  49121. * Sets the color of the ray from the vr headsets gaze.
  49122. * @param color new color for the ray.
  49123. */
  49124. changeGazeColor(color: Color3): void;
  49125. /**
  49126. * Exits VR and disposes of the vr experience helper
  49127. */
  49128. dispose(): void;
  49129. /**
  49130. * Gets the name of the VRExperienceHelper class
  49131. * @returns "VRExperienceHelper"
  49132. */
  49133. getClassName(): string;
  49134. }
  49135. }
  49136. declare module BABYLON {
  49137. /**
  49138. * Contains an array of blocks representing the octree
  49139. */
  49140. export interface IOctreeContainer<T> {
  49141. /**
  49142. * Blocks within the octree
  49143. */
  49144. blocks: Array<OctreeBlock<T>>;
  49145. }
  49146. /**
  49147. * Class used to store a cell in an octree
  49148. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49149. */
  49150. export class OctreeBlock<T> {
  49151. /**
  49152. * Gets the content of the current block
  49153. */
  49154. entries: T[];
  49155. /**
  49156. * Gets the list of block children
  49157. */
  49158. blocks: Array<OctreeBlock<T>>;
  49159. private _depth;
  49160. private _maxDepth;
  49161. private _capacity;
  49162. private _minPoint;
  49163. private _maxPoint;
  49164. private _boundingVectors;
  49165. private _creationFunc;
  49166. /**
  49167. * Creates a new block
  49168. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49169. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49170. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49171. * @param depth defines the current depth of this block in the octree
  49172. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49173. * @param creationFunc defines a callback to call when an element is added to the block
  49174. */
  49175. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49176. /**
  49177. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49178. */
  49179. get capacity(): number;
  49180. /**
  49181. * Gets the minimum vector (in world space) of the block's bounding box
  49182. */
  49183. get minPoint(): Vector3;
  49184. /**
  49185. * Gets the maximum vector (in world space) of the block's bounding box
  49186. */
  49187. get maxPoint(): Vector3;
  49188. /**
  49189. * Add a new element to this block
  49190. * @param entry defines the element to add
  49191. */
  49192. addEntry(entry: T): void;
  49193. /**
  49194. * Remove an element from this block
  49195. * @param entry defines the element to remove
  49196. */
  49197. removeEntry(entry: T): void;
  49198. /**
  49199. * Add an array of elements to this block
  49200. * @param entries defines the array of elements to add
  49201. */
  49202. addEntries(entries: T[]): void;
  49203. /**
  49204. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49205. * @param frustumPlanes defines the frustum planes to test
  49206. * @param selection defines the array to store current content if selection is positive
  49207. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49208. */
  49209. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49210. /**
  49211. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49212. * @param sphereCenter defines the bounding sphere center
  49213. * @param sphereRadius defines the bounding sphere radius
  49214. * @param selection defines the array to store current content if selection is positive
  49215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49216. */
  49217. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49218. /**
  49219. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49220. * @param ray defines the ray to test with
  49221. * @param selection defines the array to store current content if selection is positive
  49222. */
  49223. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49224. /**
  49225. * Subdivide the content into child blocks (this block will then be empty)
  49226. */
  49227. createInnerBlocks(): void;
  49228. /**
  49229. * @hidden
  49230. */
  49231. 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;
  49232. }
  49233. }
  49234. declare module BABYLON {
  49235. /**
  49236. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49238. */
  49239. export class Octree<T> {
  49240. /** 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.) */
  49241. maxDepth: number;
  49242. /**
  49243. * Blocks within the octree containing objects
  49244. */
  49245. blocks: Array<OctreeBlock<T>>;
  49246. /**
  49247. * Content stored in the octree
  49248. */
  49249. dynamicContent: T[];
  49250. private _maxBlockCapacity;
  49251. private _selectionContent;
  49252. private _creationFunc;
  49253. /**
  49254. * Creates a octree
  49255. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49256. * @param creationFunc function to be used to instatiate the octree
  49257. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49258. * @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.)
  49259. */
  49260. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49261. /** 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.) */
  49262. maxDepth?: number);
  49263. /**
  49264. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49265. * @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);
  49266. * @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);
  49267. * @param entries meshes to be added to the octree blocks
  49268. */
  49269. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49270. /**
  49271. * Adds a mesh to the octree
  49272. * @param entry Mesh to add to the octree
  49273. */
  49274. addMesh(entry: T): void;
  49275. /**
  49276. * Remove an element from the octree
  49277. * @param entry defines the element to remove
  49278. */
  49279. removeMesh(entry: T): void;
  49280. /**
  49281. * Selects an array of meshes within the frustum
  49282. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49283. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49284. * @returns array of meshes within the frustum
  49285. */
  49286. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49287. /**
  49288. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49289. * @param sphereCenter defines the bounding sphere center
  49290. * @param sphereRadius defines the bounding sphere radius
  49291. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49292. * @returns an array of objects that intersect the sphere
  49293. */
  49294. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49295. /**
  49296. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49297. * @param ray defines the ray to test with
  49298. * @returns array of intersected objects
  49299. */
  49300. intersectsRay(ray: Ray): SmartArray<T>;
  49301. /**
  49302. * Adds a mesh into the octree block if it intersects the block
  49303. */
  49304. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49305. /**
  49306. * Adds a submesh into the octree block if it intersects the block
  49307. */
  49308. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49309. }
  49310. }
  49311. declare module BABYLON {
  49312. interface Scene {
  49313. /**
  49314. * @hidden
  49315. * Backing Filed
  49316. */
  49317. _selectionOctree: Octree<AbstractMesh>;
  49318. /**
  49319. * Gets the octree used to boost mesh selection (picking)
  49320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49321. */
  49322. selectionOctree: Octree<AbstractMesh>;
  49323. /**
  49324. * Creates or updates the octree used to boost selection (picking)
  49325. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49326. * @param maxCapacity defines the maximum capacity per leaf
  49327. * @param maxDepth defines the maximum depth of the octree
  49328. * @returns an octree of AbstractMesh
  49329. */
  49330. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49331. }
  49332. interface AbstractMesh {
  49333. /**
  49334. * @hidden
  49335. * Backing Field
  49336. */
  49337. _submeshesOctree: Octree<SubMesh>;
  49338. /**
  49339. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49340. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49341. * @param maxCapacity defines the maximum size of each block (64 by default)
  49342. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49343. * @returns the new octree
  49344. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49345. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49346. */
  49347. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49348. }
  49349. /**
  49350. * Defines the octree scene component responsible to manage any octrees
  49351. * in a given scene.
  49352. */
  49353. export class OctreeSceneComponent {
  49354. /**
  49355. * The component name help to identify the component in the list of scene components.
  49356. */
  49357. readonly name: string;
  49358. /**
  49359. * The scene the component belongs to.
  49360. */
  49361. scene: Scene;
  49362. /**
  49363. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49364. */
  49365. readonly checksIsEnabled: boolean;
  49366. /**
  49367. * Creates a new instance of the component for the given scene
  49368. * @param scene Defines the scene to register the component in
  49369. */
  49370. constructor(scene: Scene);
  49371. /**
  49372. * Registers the component in a given scene
  49373. */
  49374. register(): void;
  49375. /**
  49376. * Return the list of active meshes
  49377. * @returns the list of active meshes
  49378. */
  49379. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49380. /**
  49381. * Return the list of active sub meshes
  49382. * @param mesh The mesh to get the candidates sub meshes from
  49383. * @returns the list of active sub meshes
  49384. */
  49385. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49386. private _tempRay;
  49387. /**
  49388. * Return the list of sub meshes intersecting with a given local ray
  49389. * @param mesh defines the mesh to find the submesh for
  49390. * @param localRay defines the ray in local space
  49391. * @returns the list of intersecting sub meshes
  49392. */
  49393. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49394. /**
  49395. * Return the list of sub meshes colliding with a collider
  49396. * @param mesh defines the mesh to find the submesh for
  49397. * @param collider defines the collider to evaluate the collision against
  49398. * @returns the list of colliding sub meshes
  49399. */
  49400. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49401. /**
  49402. * Rebuilds the elements related to this component in case of
  49403. * context lost for instance.
  49404. */
  49405. rebuild(): void;
  49406. /**
  49407. * Disposes the component and the associated ressources.
  49408. */
  49409. dispose(): void;
  49410. }
  49411. }
  49412. declare module BABYLON {
  49413. /**
  49414. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49415. */
  49416. export class Gizmo implements IDisposable {
  49417. /** The utility layer the gizmo will be added to */
  49418. gizmoLayer: UtilityLayerRenderer;
  49419. /**
  49420. * The root mesh of the gizmo
  49421. */
  49422. _rootMesh: Mesh;
  49423. private _attachedMesh;
  49424. /**
  49425. * Ratio for the scale of the gizmo (Default: 1)
  49426. */
  49427. scaleRatio: number;
  49428. /**
  49429. * If a custom mesh has been set (Default: false)
  49430. */
  49431. protected _customMeshSet: boolean;
  49432. /**
  49433. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49434. * * When set, interactions will be enabled
  49435. */
  49436. get attachedMesh(): Nullable<AbstractMesh>;
  49437. set attachedMesh(value: Nullable<AbstractMesh>);
  49438. /**
  49439. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49440. * @param mesh The mesh to replace the default mesh of the gizmo
  49441. */
  49442. setCustomMesh(mesh: Mesh): void;
  49443. /**
  49444. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49445. */
  49446. updateGizmoRotationToMatchAttachedMesh: boolean;
  49447. /**
  49448. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49449. */
  49450. updateGizmoPositionToMatchAttachedMesh: boolean;
  49451. /**
  49452. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49453. */
  49454. updateScale: boolean;
  49455. protected _interactionsEnabled: boolean;
  49456. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49457. private _beforeRenderObserver;
  49458. private _tempVector;
  49459. /**
  49460. * Creates a gizmo
  49461. * @param gizmoLayer The utility layer the gizmo will be added to
  49462. */
  49463. constructor(
  49464. /** The utility layer the gizmo will be added to */
  49465. gizmoLayer?: UtilityLayerRenderer);
  49466. /**
  49467. * Updates the gizmo to match the attached mesh's position/rotation
  49468. */
  49469. protected _update(): void;
  49470. /**
  49471. * Disposes of the gizmo
  49472. */
  49473. dispose(): void;
  49474. }
  49475. }
  49476. declare module BABYLON {
  49477. /**
  49478. * Single plane drag gizmo
  49479. */
  49480. export class PlaneDragGizmo extends Gizmo {
  49481. /**
  49482. * Drag behavior responsible for the gizmos dragging interactions
  49483. */
  49484. dragBehavior: PointerDragBehavior;
  49485. private _pointerObserver;
  49486. /**
  49487. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49488. */
  49489. snapDistance: number;
  49490. /**
  49491. * Event that fires each time the gizmo snaps to a new location.
  49492. * * snapDistance is the the change in distance
  49493. */
  49494. onSnapObservable: Observable<{
  49495. snapDistance: number;
  49496. }>;
  49497. private _plane;
  49498. private _coloredMaterial;
  49499. private _hoverMaterial;
  49500. private _isEnabled;
  49501. private _parent;
  49502. /** @hidden */
  49503. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49504. /** @hidden */
  49505. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49506. /**
  49507. * Creates a PlaneDragGizmo
  49508. * @param gizmoLayer The utility layer the gizmo will be added to
  49509. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49510. * @param color The color of the gizmo
  49511. */
  49512. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49514. /**
  49515. * If the gizmo is enabled
  49516. */
  49517. set isEnabled(value: boolean);
  49518. get isEnabled(): boolean;
  49519. /**
  49520. * Disposes of the gizmo
  49521. */
  49522. dispose(): void;
  49523. }
  49524. }
  49525. declare module BABYLON {
  49526. /**
  49527. * Gizmo that enables dragging a mesh along 3 axis
  49528. */
  49529. export class PositionGizmo extends Gizmo {
  49530. /**
  49531. * Internal gizmo used for interactions on the x axis
  49532. */
  49533. xGizmo: AxisDragGizmo;
  49534. /**
  49535. * Internal gizmo used for interactions on the y axis
  49536. */
  49537. yGizmo: AxisDragGizmo;
  49538. /**
  49539. * Internal gizmo used for interactions on the z axis
  49540. */
  49541. zGizmo: AxisDragGizmo;
  49542. /**
  49543. * Internal gizmo used for interactions on the yz plane
  49544. */
  49545. xPlaneGizmo: PlaneDragGizmo;
  49546. /**
  49547. * Internal gizmo used for interactions on the xz plane
  49548. */
  49549. yPlaneGizmo: PlaneDragGizmo;
  49550. /**
  49551. * Internal gizmo used for interactions on the xy plane
  49552. */
  49553. zPlaneGizmo: PlaneDragGizmo;
  49554. /**
  49555. * private variables
  49556. */
  49557. private _meshAttached;
  49558. private _updateGizmoRotationToMatchAttachedMesh;
  49559. private _snapDistance;
  49560. private _scaleRatio;
  49561. /** Fires an event when any of it's sub gizmos are dragged */
  49562. onDragStartObservable: Observable<unknown>;
  49563. /** Fires an event when any of it's sub gizmos are released from dragging */
  49564. onDragEndObservable: Observable<unknown>;
  49565. /**
  49566. * If set to true, planar drag is enabled
  49567. */
  49568. private _planarGizmoEnabled;
  49569. get attachedMesh(): Nullable<AbstractMesh>;
  49570. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49571. /**
  49572. * Creates a PositionGizmo
  49573. * @param gizmoLayer The utility layer the gizmo will be added to
  49574. */
  49575. constructor(gizmoLayer?: UtilityLayerRenderer);
  49576. /**
  49577. * If the planar drag gizmo is enabled
  49578. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49579. */
  49580. set planarGizmoEnabled(value: boolean);
  49581. get planarGizmoEnabled(): boolean;
  49582. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49583. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49584. /**
  49585. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49586. */
  49587. set snapDistance(value: number);
  49588. get snapDistance(): number;
  49589. /**
  49590. * Ratio for the scale of the gizmo (Default: 1)
  49591. */
  49592. set scaleRatio(value: number);
  49593. get scaleRatio(): number;
  49594. /**
  49595. * Disposes of the gizmo
  49596. */
  49597. dispose(): void;
  49598. /**
  49599. * CustomMeshes are not supported by this gizmo
  49600. * @param mesh The mesh to replace the default mesh of the gizmo
  49601. */
  49602. setCustomMesh(mesh: Mesh): void;
  49603. }
  49604. }
  49605. declare module BABYLON {
  49606. /**
  49607. * Single axis drag gizmo
  49608. */
  49609. export class AxisDragGizmo extends Gizmo {
  49610. /**
  49611. * Drag behavior responsible for the gizmos dragging interactions
  49612. */
  49613. dragBehavior: PointerDragBehavior;
  49614. private _pointerObserver;
  49615. /**
  49616. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49617. */
  49618. snapDistance: number;
  49619. /**
  49620. * Event that fires each time the gizmo snaps to a new location.
  49621. * * snapDistance is the the change in distance
  49622. */
  49623. onSnapObservable: Observable<{
  49624. snapDistance: number;
  49625. }>;
  49626. private _isEnabled;
  49627. private _parent;
  49628. private _arrow;
  49629. private _coloredMaterial;
  49630. private _hoverMaterial;
  49631. /** @hidden */
  49632. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49633. /** @hidden */
  49634. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49635. /**
  49636. * Creates an AxisDragGizmo
  49637. * @param gizmoLayer The utility layer the gizmo will be added to
  49638. * @param dragAxis The axis which the gizmo will be able to drag on
  49639. * @param color The color of the gizmo
  49640. */
  49641. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49642. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49643. /**
  49644. * If the gizmo is enabled
  49645. */
  49646. set isEnabled(value: boolean);
  49647. get isEnabled(): boolean;
  49648. /**
  49649. * Disposes of the gizmo
  49650. */
  49651. dispose(): void;
  49652. }
  49653. }
  49654. declare module BABYLON.Debug {
  49655. /**
  49656. * The Axes viewer will show 3 axes in a specific point in space
  49657. */
  49658. export class AxesViewer {
  49659. private _xAxis;
  49660. private _yAxis;
  49661. private _zAxis;
  49662. private _scaleLinesFactor;
  49663. private _instanced;
  49664. /**
  49665. * Gets the hosting scene
  49666. */
  49667. scene: Scene;
  49668. /**
  49669. * Gets or sets a number used to scale line length
  49670. */
  49671. scaleLines: number;
  49672. /** Gets the node hierarchy used to render x-axis */
  49673. get xAxis(): TransformNode;
  49674. /** Gets the node hierarchy used to render y-axis */
  49675. get yAxis(): TransformNode;
  49676. /** Gets the node hierarchy used to render z-axis */
  49677. get zAxis(): TransformNode;
  49678. /**
  49679. * Creates a new AxesViewer
  49680. * @param scene defines the hosting scene
  49681. * @param scaleLines defines a number used to scale line length (1 by default)
  49682. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49683. * @param xAxis defines the node hierarchy used to render the x-axis
  49684. * @param yAxis defines the node hierarchy used to render the y-axis
  49685. * @param zAxis defines the node hierarchy used to render the z-axis
  49686. */
  49687. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49688. /**
  49689. * Force the viewer to update
  49690. * @param position defines the position of the viewer
  49691. * @param xaxis defines the x axis of the viewer
  49692. * @param yaxis defines the y axis of the viewer
  49693. * @param zaxis defines the z axis of the viewer
  49694. */
  49695. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49696. /**
  49697. * Creates an instance of this axes viewer.
  49698. * @returns a new axes viewer with instanced meshes
  49699. */
  49700. createInstance(): AxesViewer;
  49701. /** Releases resources */
  49702. dispose(): void;
  49703. private static _SetRenderingGroupId;
  49704. }
  49705. }
  49706. declare module BABYLON.Debug {
  49707. /**
  49708. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49709. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49710. */
  49711. export class BoneAxesViewer extends AxesViewer {
  49712. /**
  49713. * Gets or sets the target mesh where to display the axes viewer
  49714. */
  49715. mesh: Nullable<Mesh>;
  49716. /**
  49717. * Gets or sets the target bone where to display the axes viewer
  49718. */
  49719. bone: Nullable<Bone>;
  49720. /** Gets current position */
  49721. pos: Vector3;
  49722. /** Gets direction of X axis */
  49723. xaxis: Vector3;
  49724. /** Gets direction of Y axis */
  49725. yaxis: Vector3;
  49726. /** Gets direction of Z axis */
  49727. zaxis: Vector3;
  49728. /**
  49729. * Creates a new BoneAxesViewer
  49730. * @param scene defines the hosting scene
  49731. * @param bone defines the target bone
  49732. * @param mesh defines the target mesh
  49733. * @param scaleLines defines a scaling factor for line length (1 by default)
  49734. */
  49735. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49736. /**
  49737. * Force the viewer to update
  49738. */
  49739. update(): void;
  49740. /** Releases resources */
  49741. dispose(): void;
  49742. }
  49743. }
  49744. declare module BABYLON {
  49745. /**
  49746. * Interface used to define scene explorer extensibility option
  49747. */
  49748. export interface IExplorerExtensibilityOption {
  49749. /**
  49750. * Define the option label
  49751. */
  49752. label: string;
  49753. /**
  49754. * Defines the action to execute on click
  49755. */
  49756. action: (entity: any) => void;
  49757. }
  49758. /**
  49759. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49760. */
  49761. export interface IExplorerExtensibilityGroup {
  49762. /**
  49763. * Defines a predicate to test if a given type mut be extended
  49764. */
  49765. predicate: (entity: any) => boolean;
  49766. /**
  49767. * Gets the list of options added to a type
  49768. */
  49769. entries: IExplorerExtensibilityOption[];
  49770. }
  49771. /**
  49772. * Interface used to define the options to use to create the Inspector
  49773. */
  49774. export interface IInspectorOptions {
  49775. /**
  49776. * Display in overlay mode (default: false)
  49777. */
  49778. overlay?: boolean;
  49779. /**
  49780. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49781. */
  49782. globalRoot?: HTMLElement;
  49783. /**
  49784. * Display the Scene explorer
  49785. */
  49786. showExplorer?: boolean;
  49787. /**
  49788. * Display the property inspector
  49789. */
  49790. showInspector?: boolean;
  49791. /**
  49792. * Display in embed mode (both panes on the right)
  49793. */
  49794. embedMode?: boolean;
  49795. /**
  49796. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49797. */
  49798. handleResize?: boolean;
  49799. /**
  49800. * Allow the panes to popup (default: true)
  49801. */
  49802. enablePopup?: boolean;
  49803. /**
  49804. * Allow the panes to be closed by users (default: true)
  49805. */
  49806. enableClose?: boolean;
  49807. /**
  49808. * Optional list of extensibility entries
  49809. */
  49810. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49811. /**
  49812. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49813. */
  49814. inspectorURL?: string;
  49815. /**
  49816. * Optional initial tab (default to DebugLayerTab.Properties)
  49817. */
  49818. initialTab?: DebugLayerTab;
  49819. }
  49820. interface Scene {
  49821. /**
  49822. * @hidden
  49823. * Backing field
  49824. */
  49825. _debugLayer: DebugLayer;
  49826. /**
  49827. * Gets the debug layer (aka Inspector) associated with the scene
  49828. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49829. */
  49830. debugLayer: DebugLayer;
  49831. }
  49832. /**
  49833. * Enum of inspector action tab
  49834. */
  49835. export enum DebugLayerTab {
  49836. /**
  49837. * Properties tag (default)
  49838. */
  49839. Properties = 0,
  49840. /**
  49841. * Debug tab
  49842. */
  49843. Debug = 1,
  49844. /**
  49845. * Statistics tab
  49846. */
  49847. Statistics = 2,
  49848. /**
  49849. * Tools tab
  49850. */
  49851. Tools = 3,
  49852. /**
  49853. * Settings tab
  49854. */
  49855. Settings = 4
  49856. }
  49857. /**
  49858. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49859. * what is happening in your scene
  49860. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49861. */
  49862. export class DebugLayer {
  49863. /**
  49864. * Define the url to get the inspector script from.
  49865. * By default it uses the babylonjs CDN.
  49866. * @ignoreNaming
  49867. */
  49868. static InspectorURL: string;
  49869. private _scene;
  49870. private BJSINSPECTOR;
  49871. private _onPropertyChangedObservable?;
  49872. /**
  49873. * Observable triggered when a property is changed through the inspector.
  49874. */
  49875. get onPropertyChangedObservable(): any;
  49876. /**
  49877. * Instantiates a new debug layer.
  49878. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49879. * what is happening in your scene
  49880. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49881. * @param scene Defines the scene to inspect
  49882. */
  49883. constructor(scene: Scene);
  49884. /** Creates the inspector window. */
  49885. private _createInspector;
  49886. /**
  49887. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49888. * @param entity defines the entity to select
  49889. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49890. */
  49891. select(entity: any, lineContainerTitles?: string | string[]): void;
  49892. /** Get the inspector from bundle or global */
  49893. private _getGlobalInspector;
  49894. /**
  49895. * Get if the inspector is visible or not.
  49896. * @returns true if visible otherwise, false
  49897. */
  49898. isVisible(): boolean;
  49899. /**
  49900. * Hide the inspector and close its window.
  49901. */
  49902. hide(): void;
  49903. /**
  49904. * Update the scene in the inspector
  49905. */
  49906. setAsActiveScene(): void;
  49907. /**
  49908. * Launch the debugLayer.
  49909. * @param config Define the configuration of the inspector
  49910. * @return a promise fulfilled when the debug layer is visible
  49911. */
  49912. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49913. }
  49914. }
  49915. declare module BABYLON {
  49916. /**
  49917. * Class containing static functions to help procedurally build meshes
  49918. */
  49919. export class BoxBuilder {
  49920. /**
  49921. * Creates a box mesh
  49922. * * The parameter `size` sets the size (float) of each box side (default 1)
  49923. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49924. * * 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)
  49925. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49927. * * 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
  49928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49929. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49930. * @param name defines the name of the mesh
  49931. * @param options defines the options used to create the mesh
  49932. * @param scene defines the hosting scene
  49933. * @returns the box mesh
  49934. */
  49935. static CreateBox(name: string, options: {
  49936. size?: number;
  49937. width?: number;
  49938. height?: number;
  49939. depth?: number;
  49940. faceUV?: Vector4[];
  49941. faceColors?: Color4[];
  49942. sideOrientation?: number;
  49943. frontUVs?: Vector4;
  49944. backUVs?: Vector4;
  49945. wrap?: boolean;
  49946. topBaseAt?: number;
  49947. bottomBaseAt?: number;
  49948. updatable?: boolean;
  49949. }, scene?: Nullable<Scene>): Mesh;
  49950. }
  49951. }
  49952. declare module BABYLON.Debug {
  49953. /**
  49954. * Used to show the physics impostor around the specific mesh
  49955. */
  49956. export class PhysicsViewer {
  49957. /** @hidden */
  49958. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49959. /** @hidden */
  49960. protected _meshes: Array<Nullable<AbstractMesh>>;
  49961. /** @hidden */
  49962. protected _scene: Nullable<Scene>;
  49963. /** @hidden */
  49964. protected _numMeshes: number;
  49965. /** @hidden */
  49966. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49967. private _renderFunction;
  49968. private _utilityLayer;
  49969. private _debugBoxMesh;
  49970. private _debugSphereMesh;
  49971. private _debugCylinderMesh;
  49972. private _debugMaterial;
  49973. private _debugMeshMeshes;
  49974. /**
  49975. * Creates a new PhysicsViewer
  49976. * @param scene defines the hosting scene
  49977. */
  49978. constructor(scene: Scene);
  49979. /** @hidden */
  49980. protected _updateDebugMeshes(): void;
  49981. /**
  49982. * Renders a specified physic impostor
  49983. * @param impostor defines the impostor to render
  49984. * @param targetMesh defines the mesh represented by the impostor
  49985. * @returns the new debug mesh used to render the impostor
  49986. */
  49987. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49988. /**
  49989. * Hides a specified physic impostor
  49990. * @param impostor defines the impostor to hide
  49991. */
  49992. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49993. private _getDebugMaterial;
  49994. private _getDebugBoxMesh;
  49995. private _getDebugSphereMesh;
  49996. private _getDebugCylinderMesh;
  49997. private _getDebugMeshMesh;
  49998. private _getDebugMesh;
  49999. /** Releases all resources */
  50000. dispose(): void;
  50001. }
  50002. }
  50003. declare module BABYLON {
  50004. /**
  50005. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50006. * in order to better appreciate the issue one might have.
  50007. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50008. */
  50009. export class RayHelper {
  50010. /**
  50011. * Defines the ray we are currently tryin to visualize.
  50012. */
  50013. ray: Nullable<Ray>;
  50014. private _renderPoints;
  50015. private _renderLine;
  50016. private _renderFunction;
  50017. private _scene;
  50018. private _updateToMeshFunction;
  50019. private _attachedToMesh;
  50020. private _meshSpaceDirection;
  50021. private _meshSpaceOrigin;
  50022. /**
  50023. * Helper function to create a colored helper in a scene in one line.
  50024. * @param ray Defines the ray we are currently tryin to visualize
  50025. * @param scene Defines the scene the ray is used in
  50026. * @param color Defines the color we want to see the ray in
  50027. * @returns The newly created ray helper.
  50028. */
  50029. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50030. /**
  50031. * Instantiate a new ray helper.
  50032. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50033. * in order to better appreciate the issue one might have.
  50034. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50035. * @param ray Defines the ray we are currently tryin to visualize
  50036. */
  50037. constructor(ray: Ray);
  50038. /**
  50039. * Shows the ray we are willing to debug.
  50040. * @param scene Defines the scene the ray needs to be rendered in
  50041. * @param color Defines the color the ray needs to be rendered in
  50042. */
  50043. show(scene: Scene, color?: Color3): void;
  50044. /**
  50045. * Hides the ray we are debugging.
  50046. */
  50047. hide(): void;
  50048. private _render;
  50049. /**
  50050. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50051. * @param mesh Defines the mesh we want the helper attached to
  50052. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50053. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50054. * @param length Defines the length of the ray
  50055. */
  50056. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50057. /**
  50058. * Detach the ray helper from the mesh it has previously been attached to.
  50059. */
  50060. detachFromMesh(): void;
  50061. private _updateToMesh;
  50062. /**
  50063. * Dispose the helper and release its associated resources.
  50064. */
  50065. dispose(): void;
  50066. }
  50067. }
  50068. declare module BABYLON.Debug {
  50069. /**
  50070. * Class used to render a debug view of a given skeleton
  50071. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50072. */
  50073. export class SkeletonViewer {
  50074. /** defines the skeleton to render */
  50075. skeleton: Skeleton;
  50076. /** defines the mesh attached to the skeleton */
  50077. mesh: AbstractMesh;
  50078. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50079. autoUpdateBonesMatrices: boolean;
  50080. /** defines the rendering group id to use with the viewer */
  50081. renderingGroupId: number;
  50082. /** Gets or sets the color used to render the skeleton */
  50083. color: Color3;
  50084. private _scene;
  50085. private _debugLines;
  50086. private _debugMesh;
  50087. private _isEnabled;
  50088. private _renderFunction;
  50089. private _utilityLayer;
  50090. /**
  50091. * Returns the mesh used to render the bones
  50092. */
  50093. get debugMesh(): Nullable<LinesMesh>;
  50094. /**
  50095. * Creates a new SkeletonViewer
  50096. * @param skeleton defines the skeleton to render
  50097. * @param mesh defines the mesh attached to the skeleton
  50098. * @param scene defines the hosting scene
  50099. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50100. * @param renderingGroupId defines the rendering group id to use with the viewer
  50101. */
  50102. constructor(
  50103. /** defines the skeleton to render */
  50104. skeleton: Skeleton,
  50105. /** defines the mesh attached to the skeleton */
  50106. mesh: AbstractMesh, scene: Scene,
  50107. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50108. autoUpdateBonesMatrices?: boolean,
  50109. /** defines the rendering group id to use with the viewer */
  50110. renderingGroupId?: number);
  50111. /** Gets or sets a boolean indicating if the viewer is enabled */
  50112. set isEnabled(value: boolean);
  50113. get isEnabled(): boolean;
  50114. private _getBonePosition;
  50115. private _getLinesForBonesWithLength;
  50116. private _getLinesForBonesNoLength;
  50117. /** Update the viewer to sync with current skeleton state */
  50118. update(): void;
  50119. /** Release associated resources */
  50120. dispose(): void;
  50121. }
  50122. }
  50123. declare module BABYLON {
  50124. /**
  50125. * Enum for Device Types
  50126. */
  50127. export enum DeviceType {
  50128. /** Generic */
  50129. Generic = 0,
  50130. /** Keyboard */
  50131. Keyboard = 1,
  50132. /** Mouse */
  50133. Mouse = 2,
  50134. /** Touch Pointers */
  50135. Touch = 3,
  50136. /** PS4 Dual Shock */
  50137. DualShock = 4,
  50138. /** Xbox */
  50139. Xbox = 5,
  50140. /** Switch Controller */
  50141. Switch = 6
  50142. }
  50143. /**
  50144. * Enum for All Pointers (Touch/Mouse)
  50145. */
  50146. export enum PointerInput {
  50147. /** Horizontal Axis */
  50148. Horizontal = 0,
  50149. /** Vertical Axis */
  50150. Vertical = 1,
  50151. /** Left Click or Touch */
  50152. LeftClick = 2,
  50153. /** Middle Click */
  50154. MiddleClick = 3,
  50155. /** Right Click */
  50156. RightClick = 4,
  50157. /** Browser Back */
  50158. BrowserBack = 5,
  50159. /** Browser Forward */
  50160. BrowserForward = 6
  50161. }
  50162. /**
  50163. * Enum for Dual Shock Gamepad
  50164. */
  50165. export enum DualShockInput {
  50166. /** Cross */
  50167. Cross = 0,
  50168. /** Circle */
  50169. Circle = 1,
  50170. /** Square */
  50171. Square = 2,
  50172. /** Triangle */
  50173. Triangle = 3,
  50174. /** L1 */
  50175. L1 = 4,
  50176. /** R1 */
  50177. R1 = 5,
  50178. /** L2 */
  50179. L2 = 6,
  50180. /** R2 */
  50181. R2 = 7,
  50182. /** Share */
  50183. Share = 8,
  50184. /** Options */
  50185. Options = 9,
  50186. /** L3 */
  50187. L3 = 10,
  50188. /** R3 */
  50189. R3 = 11,
  50190. /** DPadUp */
  50191. DPadUp = 12,
  50192. /** DPadDown */
  50193. DPadDown = 13,
  50194. /** DPadLeft */
  50195. DPadLeft = 14,
  50196. /** DRight */
  50197. DPadRight = 15,
  50198. /** Home */
  50199. Home = 16,
  50200. /** TouchPad */
  50201. TouchPad = 17,
  50202. /** LStickXAxis */
  50203. LStickXAxis = 18,
  50204. /** LStickYAxis */
  50205. LStickYAxis = 19,
  50206. /** RStickXAxis */
  50207. RStickXAxis = 20,
  50208. /** RStickYAxis */
  50209. RStickYAxis = 21
  50210. }
  50211. /**
  50212. * Enum for Xbox Gamepad
  50213. */
  50214. export enum XboxInput {
  50215. /** A */
  50216. A = 0,
  50217. /** B */
  50218. B = 1,
  50219. /** X */
  50220. X = 2,
  50221. /** Y */
  50222. Y = 3,
  50223. /** LB */
  50224. LB = 4,
  50225. /** RB */
  50226. RB = 5,
  50227. /** LT */
  50228. LT = 6,
  50229. /** RT */
  50230. RT = 7,
  50231. /** Back */
  50232. Back = 8,
  50233. /** Start */
  50234. Start = 9,
  50235. /** LS */
  50236. LS = 10,
  50237. /** RS */
  50238. RS = 11,
  50239. /** DPadUp */
  50240. DPadUp = 12,
  50241. /** DPadDown */
  50242. DPadDown = 13,
  50243. /** DPadLeft */
  50244. DPadLeft = 14,
  50245. /** DRight */
  50246. DPadRight = 15,
  50247. /** Home */
  50248. Home = 16,
  50249. /** LStickXAxis */
  50250. LStickXAxis = 17,
  50251. /** LStickYAxis */
  50252. LStickYAxis = 18,
  50253. /** RStickXAxis */
  50254. RStickXAxis = 19,
  50255. /** RStickYAxis */
  50256. RStickYAxis = 20
  50257. }
  50258. /**
  50259. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50260. */
  50261. export enum SwitchInput {
  50262. /** B */
  50263. B = 0,
  50264. /** A */
  50265. A = 1,
  50266. /** Y */
  50267. Y = 2,
  50268. /** X */
  50269. X = 3,
  50270. /** L */
  50271. L = 4,
  50272. /** R */
  50273. R = 5,
  50274. /** ZL */
  50275. ZL = 6,
  50276. /** ZR */
  50277. ZR = 7,
  50278. /** Minus */
  50279. Minus = 8,
  50280. /** Plus */
  50281. Plus = 9,
  50282. /** LS */
  50283. LS = 10,
  50284. /** RS */
  50285. RS = 11,
  50286. /** DPadUp */
  50287. DPadUp = 12,
  50288. /** DPadDown */
  50289. DPadDown = 13,
  50290. /** DPadLeft */
  50291. DPadLeft = 14,
  50292. /** DRight */
  50293. DPadRight = 15,
  50294. /** Home */
  50295. Home = 16,
  50296. /** Capture */
  50297. Capture = 17,
  50298. /** LStickXAxis */
  50299. LStickXAxis = 18,
  50300. /** LStickYAxis */
  50301. LStickYAxis = 19,
  50302. /** RStickXAxis */
  50303. RStickXAxis = 20,
  50304. /** RStickYAxis */
  50305. RStickYAxis = 21
  50306. }
  50307. }
  50308. declare module BABYLON {
  50309. /**
  50310. * This class will take all inputs from Keyboard, Pointer, and
  50311. * any Gamepads and provide a polling system that all devices
  50312. * will use. This class assumes that there will only be one
  50313. * pointer device and one keyboard.
  50314. */
  50315. export class DeviceInputSystem implements IDisposable {
  50316. /**
  50317. * Callback to be triggered when a device is connected
  50318. */
  50319. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50320. /**
  50321. * Callback to be triggered when a device is disconnected
  50322. */
  50323. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50324. /**
  50325. * Callback to be triggered when event driven input is updated
  50326. */
  50327. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50328. private _inputs;
  50329. private _gamepads;
  50330. private _keyboardActive;
  50331. private _pointerActive;
  50332. private _elementToAttachTo;
  50333. private _keyboardDownEvent;
  50334. private _keyboardUpEvent;
  50335. private _pointerMoveEvent;
  50336. private _pointerDownEvent;
  50337. private _pointerUpEvent;
  50338. private _gamepadConnectedEvent;
  50339. private _gamepadDisconnectedEvent;
  50340. private static _MAX_KEYCODES;
  50341. private static _MAX_POINTER_INPUTS;
  50342. private constructor();
  50343. /**
  50344. * Creates a new DeviceInputSystem instance
  50345. * @param engine Engine to pull input element from
  50346. * @returns The new instance
  50347. */
  50348. static Create(engine: Engine): DeviceInputSystem;
  50349. /**
  50350. * Checks for current device input value, given an id and input index
  50351. * @param deviceName Id of connected device
  50352. * @param inputIndex Index of device input
  50353. * @returns Current value of input
  50354. */
  50355. /**
  50356. * Checks for current device input value, given an id and input index
  50357. * @param deviceType Enum specifiying device type
  50358. * @param deviceSlot "Slot" or index that device is referenced in
  50359. * @param inputIndex Id of input to be checked
  50360. * @returns Current value of input
  50361. */
  50362. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50363. /**
  50364. * Dispose of all the eventlisteners
  50365. */
  50366. dispose(): void;
  50367. /**
  50368. * Add device and inputs to device array
  50369. * @param deviceType Enum specifiying device type
  50370. * @param deviceSlot "Slot" or index that device is referenced in
  50371. * @param numberOfInputs Number of input entries to create for given device
  50372. */
  50373. private _registerDevice;
  50374. /**
  50375. * Given a specific device name, remove that device from the device map
  50376. * @param deviceType Enum specifiying device type
  50377. * @param deviceSlot "Slot" or index that device is referenced in
  50378. */
  50379. private _unregisterDevice;
  50380. /**
  50381. * Handle all actions that come from keyboard interaction
  50382. */
  50383. private _handleKeyActions;
  50384. /**
  50385. * Handle all actions that come from pointer interaction
  50386. */
  50387. private _handlePointerActions;
  50388. /**
  50389. * Handle all actions that come from gamepad interaction
  50390. */
  50391. private _handleGamepadActions;
  50392. /**
  50393. * Update all non-event based devices with each frame
  50394. * @param deviceType Enum specifiying device type
  50395. * @param deviceSlot "Slot" or index that device is referenced in
  50396. * @param inputIndex Id of input to be checked
  50397. */
  50398. private _updateDevice;
  50399. /**
  50400. * Gets DeviceType from the device name
  50401. * @param deviceName Name of Device from DeviceInputSystem
  50402. * @returns DeviceType enum value
  50403. */
  50404. private _getGamepadDeviceType;
  50405. }
  50406. }
  50407. declare module BABYLON {
  50408. /**
  50409. * Type to handle enforcement of inputs
  50410. */
  50411. 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;
  50412. }
  50413. declare module BABYLON {
  50414. /**
  50415. * Class that handles all input for a specific device
  50416. */
  50417. export class DeviceSource<T extends DeviceType> {
  50418. /** Type of device */
  50419. readonly deviceType: DeviceType;
  50420. /** "Slot" or index that device is referenced in */
  50421. readonly deviceSlot: number;
  50422. /**
  50423. * Observable to handle device input changes per device
  50424. */
  50425. readonly onInputChangedObservable: Observable<{
  50426. inputIndex: DeviceInput<T>;
  50427. previousState: Nullable<number>;
  50428. currentState: Nullable<number>;
  50429. }>;
  50430. private readonly _deviceInputSystem;
  50431. /**
  50432. * Default Constructor
  50433. * @param deviceInputSystem Reference to DeviceInputSystem
  50434. * @param deviceType Type of device
  50435. * @param deviceSlot "Slot" or index that device is referenced in
  50436. */
  50437. constructor(deviceInputSystem: DeviceInputSystem,
  50438. /** Type of device */
  50439. deviceType: DeviceType,
  50440. /** "Slot" or index that device is referenced in */
  50441. deviceSlot?: number);
  50442. /**
  50443. * Get input for specific input
  50444. * @param inputIndex index of specific input on device
  50445. * @returns Input value from DeviceInputSystem
  50446. */
  50447. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50448. }
  50449. /**
  50450. * Class to keep track of devices
  50451. */
  50452. export class DeviceSourceManager implements IDisposable {
  50453. /**
  50454. * Observable to be triggered when before a device is connected
  50455. */
  50456. readonly onBeforeDeviceConnectedObservable: Observable<{
  50457. deviceType: DeviceType;
  50458. deviceSlot: number;
  50459. }>;
  50460. /**
  50461. * Observable to be triggered when before a device is disconnected
  50462. */
  50463. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50464. deviceType: DeviceType;
  50465. deviceSlot: number;
  50466. }>;
  50467. /**
  50468. * Observable to be triggered when after a device is connected
  50469. */
  50470. readonly onAfterDeviceConnectedObservable: Observable<{
  50471. deviceType: DeviceType;
  50472. deviceSlot: number;
  50473. }>;
  50474. /**
  50475. * Observable to be triggered when after a device is disconnected
  50476. */
  50477. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50478. deviceType: DeviceType;
  50479. deviceSlot: number;
  50480. }>;
  50481. private readonly _devices;
  50482. private readonly _firstDevice;
  50483. private readonly _deviceInputSystem;
  50484. /**
  50485. * Default Constructor
  50486. * @param engine engine to pull input element from
  50487. */
  50488. constructor(engine: Engine);
  50489. /**
  50490. * Gets a DeviceSource, given a type and slot
  50491. * @param deviceType Enum specifying device type
  50492. * @param deviceSlot "Slot" or index that device is referenced in
  50493. * @returns DeviceSource object
  50494. */
  50495. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50496. /**
  50497. * Gets an array of DeviceSource objects for a given device type
  50498. * @param deviceType Enum specifying device type
  50499. * @returns Array of DeviceSource objects
  50500. */
  50501. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50502. /**
  50503. * Dispose of DeviceInputSystem and other parts
  50504. */
  50505. dispose(): void;
  50506. /**
  50507. * Function to add device name to device list
  50508. * @param deviceType Enum specifying device type
  50509. * @param deviceSlot "Slot" or index that device is referenced in
  50510. */
  50511. private _addDevice;
  50512. /**
  50513. * Function to remove 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 _removeDevice;
  50518. /**
  50519. * Updates array storing first connected device of each type
  50520. * @param type Type of Device
  50521. */
  50522. private _updateFirstDevices;
  50523. }
  50524. }
  50525. declare module BABYLON {
  50526. /**
  50527. * Options to create the null engine
  50528. */
  50529. export class NullEngineOptions {
  50530. /**
  50531. * Render width (Default: 512)
  50532. */
  50533. renderWidth: number;
  50534. /**
  50535. * Render height (Default: 256)
  50536. */
  50537. renderHeight: number;
  50538. /**
  50539. * Texture size (Default: 512)
  50540. */
  50541. textureSize: number;
  50542. /**
  50543. * If delta time between frames should be constant
  50544. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50545. */
  50546. deterministicLockstep: boolean;
  50547. /**
  50548. * Maximum about of steps between frames (Default: 4)
  50549. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50550. */
  50551. lockstepMaxSteps: number;
  50552. }
  50553. /**
  50554. * The null engine class provides support for headless version of babylon.js.
  50555. * This can be used in server side scenario or for testing purposes
  50556. */
  50557. export class NullEngine extends Engine {
  50558. private _options;
  50559. /**
  50560. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50561. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50562. * @returns true if engine is in deterministic lock step mode
  50563. */
  50564. isDeterministicLockStep(): boolean;
  50565. /**
  50566. * Gets the max steps when engine is running in deterministic lock step
  50567. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50568. * @returns the max steps
  50569. */
  50570. getLockstepMaxSteps(): number;
  50571. /**
  50572. * Gets the current hardware scaling level.
  50573. * By default the hardware scaling level is computed from the window device ratio.
  50574. * 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.
  50575. * @returns a number indicating the current hardware scaling level
  50576. */
  50577. getHardwareScalingLevel(): number;
  50578. constructor(options?: NullEngineOptions);
  50579. /**
  50580. * Creates a vertex buffer
  50581. * @param vertices the data for the vertex buffer
  50582. * @returns the new WebGL static buffer
  50583. */
  50584. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50585. /**
  50586. * Creates a new index buffer
  50587. * @param indices defines the content of the index buffer
  50588. * @param updatable defines if the index buffer must be updatable
  50589. * @returns a new webGL buffer
  50590. */
  50591. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50592. /**
  50593. * Clear the current render buffer or the current render target (if any is set up)
  50594. * @param color defines the color to use
  50595. * @param backBuffer defines if the back buffer must be cleared
  50596. * @param depth defines if the depth buffer must be cleared
  50597. * @param stencil defines if the stencil buffer must be cleared
  50598. */
  50599. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50600. /**
  50601. * Gets the current render width
  50602. * @param useScreen defines if screen size must be used (or the current render target if any)
  50603. * @returns a number defining the current render width
  50604. */
  50605. getRenderWidth(useScreen?: boolean): number;
  50606. /**
  50607. * Gets the current render height
  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 height
  50610. */
  50611. getRenderHeight(useScreen?: boolean): number;
  50612. /**
  50613. * Set the WebGL's viewport
  50614. * @param viewport defines the viewport element to be used
  50615. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50616. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50617. */
  50618. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50619. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50620. /**
  50621. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50622. * @param pipelineContext defines the pipeline context to use
  50623. * @param uniformsNames defines the list of uniform names
  50624. * @returns an array of webGL uniform locations
  50625. */
  50626. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50627. /**
  50628. * Gets the lsit of active attributes for a given webGL program
  50629. * @param pipelineContext defines the pipeline context to use
  50630. * @param attributesNames defines the list of attribute names to get
  50631. * @returns an array of indices indicating the offset of each attribute
  50632. */
  50633. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50634. /**
  50635. * Binds an effect to the webGL context
  50636. * @param effect defines the effect to bind
  50637. */
  50638. bindSamplers(effect: Effect): void;
  50639. /**
  50640. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50641. * @param effect defines the effect to activate
  50642. */
  50643. enableEffect(effect: Effect): void;
  50644. /**
  50645. * Set various states to the webGL context
  50646. * @param culling defines backface culling state
  50647. * @param zOffset defines the value to apply to zOffset (0 by default)
  50648. * @param force defines if states must be applied even if cache is up to date
  50649. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50650. */
  50651. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50652. /**
  50653. * Set the value of an uniform to an array of int32
  50654. * @param uniform defines the webGL uniform location where to store the value
  50655. * @param array defines the array of int32 to store
  50656. */
  50657. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50658. /**
  50659. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50664. /**
  50665. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50670. /**
  50671. * Set the value of an uniform to an array of int32 (stored as vec4)
  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. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50676. /**
  50677. * Set the value of an uniform to an array of float32
  50678. * @param uniform defines the webGL uniform location where to store the value
  50679. * @param array defines the array of float32 to store
  50680. */
  50681. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50682. /**
  50683. * Set the value of an uniform to an array of float32 (stored as vec2)
  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. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50688. /**
  50689. * Set the value of an uniform to an array of float32 (stored as vec3)
  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. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50694. /**
  50695. * Set the value of an uniform to an array of float32 (stored as vec4)
  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. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50700. /**
  50701. * Set the value of an uniform to an array of number
  50702. * @param uniform defines the webGL uniform location where to store the value
  50703. * @param array defines the array of number to store
  50704. */
  50705. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50706. /**
  50707. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50712. /**
  50713. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50718. /**
  50719. * Set the value of an uniform to an array of number (stored as vec4)
  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. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50724. /**
  50725. * Set the value of an uniform to an array of float32 (stored as matrices)
  50726. * @param uniform defines the webGL uniform location where to store the value
  50727. * @param matrices defines the array of float32 to store
  50728. */
  50729. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50730. /**
  50731. * Set the value of an uniform to a matrix (3x3)
  50732. * @param uniform defines the webGL uniform location where to store the value
  50733. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50734. */
  50735. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50736. /**
  50737. * Set the value of an uniform to a matrix (2x2)
  50738. * @param uniform defines the webGL uniform location where to store the value
  50739. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50740. */
  50741. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50742. /**
  50743. * Set the value of an uniform to a number (float)
  50744. * @param uniform defines the webGL uniform location where to store the value
  50745. * @param value defines the float number to store
  50746. */
  50747. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50748. /**
  50749. * Set the value of an uniform to a vec2
  50750. * @param uniform defines the webGL uniform location where to store the value
  50751. * @param x defines the 1st component of the value
  50752. * @param y defines the 2nd component of the value
  50753. */
  50754. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50755. /**
  50756. * Set the value of an uniform to a vec3
  50757. * @param uniform defines the webGL uniform location where to store the value
  50758. * @param x defines the 1st component of the value
  50759. * @param y defines the 2nd component of the value
  50760. * @param z defines the 3rd component of the value
  50761. */
  50762. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50763. /**
  50764. * Set the value of an uniform to a boolean
  50765. * @param uniform defines the webGL uniform location where to store the value
  50766. * @param bool defines the boolean to store
  50767. */
  50768. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50769. /**
  50770. * Set the value of an uniform to a vec4
  50771. * @param uniform defines the webGL uniform location where to store the value
  50772. * @param x defines the 1st component of the value
  50773. * @param y defines the 2nd component of the value
  50774. * @param z defines the 3rd component of the value
  50775. * @param w defines the 4th component of the value
  50776. */
  50777. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50778. /**
  50779. * Sets the current alpha mode
  50780. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50781. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50782. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50783. */
  50784. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50785. /**
  50786. * Bind webGl buffers directly to the webGL context
  50787. * @param vertexBuffers defines the vertex buffer to bind
  50788. * @param indexBuffer defines the index buffer to bind
  50789. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50790. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50791. * @param effect defines the effect associated with the vertex buffer
  50792. */
  50793. bindBuffers(vertexBuffers: {
  50794. [key: string]: VertexBuffer;
  50795. }, indexBuffer: DataBuffer, effect: Effect): void;
  50796. /**
  50797. * Force the entire cache to be cleared
  50798. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50799. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50800. */
  50801. wipeCaches(bruteForce?: boolean): void;
  50802. /**
  50803. * Send a draw order
  50804. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50805. * @param indexStart defines the starting index
  50806. * @param indexCount defines the number of index to draw
  50807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50808. */
  50809. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50810. /**
  50811. * Draw a list of indexed primitives
  50812. * @param fillMode defines the primitive to use
  50813. * @param indexStart defines the starting index
  50814. * @param indexCount defines the number of index to draw
  50815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50816. */
  50817. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50818. /**
  50819. * Draw a list of unindexed primitives
  50820. * @param fillMode defines the primitive to use
  50821. * @param verticesStart defines the index of first vertex to draw
  50822. * @param verticesCount defines the count of vertices to draw
  50823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50824. */
  50825. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50826. /** @hidden */
  50827. _createTexture(): WebGLTexture;
  50828. /** @hidden */
  50829. _releaseTexture(texture: InternalTexture): void;
  50830. /**
  50831. * Usually called from Texture.ts.
  50832. * Passed information to create a WebGLTexture
  50833. * @param urlArg defines a value which contains one of the following:
  50834. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50835. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50836. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50837. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50838. * @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)
  50839. * @param scene needed for loading to the correct scene
  50840. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50841. * @param onLoad optional callback to be called upon successful completion
  50842. * @param onError optional callback to be called upon failure
  50843. * @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
  50844. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50845. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50846. * @param forcedExtension defines the extension to use to pick the right loader
  50847. * @param mimeType defines an optional mime type
  50848. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50849. */
  50850. 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;
  50851. /**
  50852. * Creates a new render target texture
  50853. * @param size defines the size of the texture
  50854. * @param options defines the options used to create the texture
  50855. * @returns a new render target texture stored in an InternalTexture
  50856. */
  50857. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50858. /**
  50859. * Update the sampling mode of a given texture
  50860. * @param samplingMode defines the required sampling mode
  50861. * @param texture defines the texture to update
  50862. */
  50863. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50864. /**
  50865. * Binds the frame buffer to the specified texture.
  50866. * @param texture The texture to render to or null for the default canvas
  50867. * @param faceIndex The face of the texture to render to in case of cube texture
  50868. * @param requiredWidth The width of the target to render to
  50869. * @param requiredHeight The height of the target to render to
  50870. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50871. * @param lodLevel defines le lod level to bind to the frame buffer
  50872. */
  50873. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50874. /**
  50875. * Unbind the current render target texture from the webGL context
  50876. * @param texture defines the render target texture to unbind
  50877. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50878. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50879. */
  50880. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50881. /**
  50882. * Creates a dynamic vertex buffer
  50883. * @param vertices the data for the dynamic vertex buffer
  50884. * @returns the new WebGL dynamic buffer
  50885. */
  50886. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50887. /**
  50888. * Update the content of a dynamic texture
  50889. * @param texture defines the texture to update
  50890. * @param canvas defines the canvas containing the source
  50891. * @param invertY defines if data must be stored with Y axis inverted
  50892. * @param premulAlpha defines if alpha is stored as premultiplied
  50893. * @param format defines the format of the data
  50894. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50895. */
  50896. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50897. /**
  50898. * Gets a boolean indicating if all created effects are ready
  50899. * @returns true if all effects are ready
  50900. */
  50901. areAllEffectsReady(): boolean;
  50902. /**
  50903. * @hidden
  50904. * Get the current error code of the webGL context
  50905. * @returns the error code
  50906. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50907. */
  50908. getError(): number;
  50909. /** @hidden */
  50910. _getUnpackAlignement(): number;
  50911. /** @hidden */
  50912. _unpackFlipY(value: boolean): void;
  50913. /**
  50914. * Update a dynamic index buffer
  50915. * @param indexBuffer defines the target index buffer
  50916. * @param indices defines the data to update
  50917. * @param offset defines the offset in the target index buffer where update should start
  50918. */
  50919. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50920. /**
  50921. * Updates a dynamic vertex buffer.
  50922. * @param vertexBuffer the vertex buffer to update
  50923. * @param vertices the data used to update the vertex buffer
  50924. * @param byteOffset the byte offset of the data (optional)
  50925. * @param byteLength the byte length of the data (optional)
  50926. */
  50927. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50928. /** @hidden */
  50929. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50930. /** @hidden */
  50931. _bindTexture(channel: number, texture: InternalTexture): void;
  50932. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50933. /**
  50934. * 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
  50935. */
  50936. releaseEffects(): void;
  50937. displayLoadingUI(): void;
  50938. hideLoadingUI(): void;
  50939. /** @hidden */
  50940. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50941. /** @hidden */
  50942. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50943. /** @hidden */
  50944. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50945. /** @hidden */
  50946. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50947. }
  50948. }
  50949. declare module BABYLON {
  50950. /**
  50951. * @hidden
  50952. **/
  50953. export class _TimeToken {
  50954. _startTimeQuery: Nullable<WebGLQuery>;
  50955. _endTimeQuery: Nullable<WebGLQuery>;
  50956. _timeElapsedQuery: Nullable<WebGLQuery>;
  50957. _timeElapsedQueryEnded: boolean;
  50958. }
  50959. }
  50960. declare module BABYLON {
  50961. /** @hidden */
  50962. export class _OcclusionDataStorage {
  50963. /** @hidden */
  50964. occlusionInternalRetryCounter: number;
  50965. /** @hidden */
  50966. isOcclusionQueryInProgress: boolean;
  50967. /** @hidden */
  50968. isOccluded: boolean;
  50969. /** @hidden */
  50970. occlusionRetryCount: number;
  50971. /** @hidden */
  50972. occlusionType: number;
  50973. /** @hidden */
  50974. occlusionQueryAlgorithmType: number;
  50975. }
  50976. interface Engine {
  50977. /**
  50978. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50979. * @return the new query
  50980. */
  50981. createQuery(): WebGLQuery;
  50982. /**
  50983. * Delete and release a webGL query
  50984. * @param query defines the query to delete
  50985. * @return the current engine
  50986. */
  50987. deleteQuery(query: WebGLQuery): Engine;
  50988. /**
  50989. * Check if a given query has resolved and got its value
  50990. * @param query defines the query to check
  50991. * @returns true if the query got its value
  50992. */
  50993. isQueryResultAvailable(query: WebGLQuery): boolean;
  50994. /**
  50995. * Gets the value of a given query
  50996. * @param query defines the query to check
  50997. * @returns the value of the query
  50998. */
  50999. getQueryResult(query: WebGLQuery): number;
  51000. /**
  51001. * Initiates an occlusion query
  51002. * @param algorithmType defines the algorithm to use
  51003. * @param query defines the query to use
  51004. * @returns the current engine
  51005. * @see https://doc.babylonjs.com/features/occlusionquery
  51006. */
  51007. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51008. /**
  51009. * Ends an occlusion query
  51010. * @see https://doc.babylonjs.com/features/occlusionquery
  51011. * @param algorithmType defines the algorithm to use
  51012. * @returns the current engine
  51013. */
  51014. endOcclusionQuery(algorithmType: number): Engine;
  51015. /**
  51016. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51017. * Please note that only one query can be issued at a time
  51018. * @returns a time token used to track the time span
  51019. */
  51020. startTimeQuery(): Nullable<_TimeToken>;
  51021. /**
  51022. * Ends a time query
  51023. * @param token defines the token used to measure the time span
  51024. * @returns the time spent (in ns)
  51025. */
  51026. endTimeQuery(token: _TimeToken): int;
  51027. /** @hidden */
  51028. _currentNonTimestampToken: Nullable<_TimeToken>;
  51029. /** @hidden */
  51030. _createTimeQuery(): WebGLQuery;
  51031. /** @hidden */
  51032. _deleteTimeQuery(query: WebGLQuery): void;
  51033. /** @hidden */
  51034. _getGlAlgorithmType(algorithmType: number): number;
  51035. /** @hidden */
  51036. _getTimeQueryResult(query: WebGLQuery): any;
  51037. /** @hidden */
  51038. _getTimeQueryAvailability(query: WebGLQuery): any;
  51039. }
  51040. interface AbstractMesh {
  51041. /**
  51042. * Backing filed
  51043. * @hidden
  51044. */
  51045. __occlusionDataStorage: _OcclusionDataStorage;
  51046. /**
  51047. * Access property
  51048. * @hidden
  51049. */
  51050. _occlusionDataStorage: _OcclusionDataStorage;
  51051. /**
  51052. * 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.
  51053. * The default value is -1 which means don't break the query and wait till the result
  51054. * @see https://doc.babylonjs.com/features/occlusionquery
  51055. */
  51056. occlusionRetryCount: number;
  51057. /**
  51058. * 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:
  51059. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51060. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51061. * * 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.
  51062. * @see https://doc.babylonjs.com/features/occlusionquery
  51063. */
  51064. occlusionType: number;
  51065. /**
  51066. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51067. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51068. * * 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.
  51069. * @see https://doc.babylonjs.com/features/occlusionquery
  51070. */
  51071. occlusionQueryAlgorithmType: number;
  51072. /**
  51073. * 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
  51074. * @see https://doc.babylonjs.com/features/occlusionquery
  51075. */
  51076. isOccluded: boolean;
  51077. /**
  51078. * Flag to check the progress status of the query
  51079. * @see https://doc.babylonjs.com/features/occlusionquery
  51080. */
  51081. isOcclusionQueryInProgress: boolean;
  51082. }
  51083. }
  51084. declare module BABYLON {
  51085. /** @hidden */
  51086. export var _forceTransformFeedbackToBundle: boolean;
  51087. interface Engine {
  51088. /**
  51089. * Creates a webGL transform feedback object
  51090. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51091. * @returns the webGL transform feedback object
  51092. */
  51093. createTransformFeedback(): WebGLTransformFeedback;
  51094. /**
  51095. * Delete a webGL transform feedback object
  51096. * @param value defines the webGL transform feedback object to delete
  51097. */
  51098. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51099. /**
  51100. * Bind a webGL transform feedback object to the webgl context
  51101. * @param value defines the webGL transform feedback object to bind
  51102. */
  51103. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51104. /**
  51105. * Begins a transform feedback operation
  51106. * @param usePoints defines if points or triangles must be used
  51107. */
  51108. beginTransformFeedback(usePoints: boolean): void;
  51109. /**
  51110. * Ends a transform feedback operation
  51111. */
  51112. endTransformFeedback(): void;
  51113. /**
  51114. * Specify the varyings to use with transform feedback
  51115. * @param program defines the associated webGL program
  51116. * @param value defines the list of strings representing the varying names
  51117. */
  51118. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51119. /**
  51120. * Bind a webGL buffer for a transform feedback operation
  51121. * @param value defines the webGL buffer to bind
  51122. */
  51123. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51124. }
  51125. }
  51126. declare module BABYLON {
  51127. /**
  51128. * Creation options of the multi render target texture.
  51129. */
  51130. export interface IMultiRenderTargetOptions {
  51131. /**
  51132. * Define if the texture needs to create mip maps after render.
  51133. */
  51134. generateMipMaps?: boolean;
  51135. /**
  51136. * Define the types of all the draw buffers we want to create
  51137. */
  51138. types?: number[];
  51139. /**
  51140. * Define the sampling modes of all the draw buffers we want to create
  51141. */
  51142. samplingModes?: number[];
  51143. /**
  51144. * Define if a depth buffer is required
  51145. */
  51146. generateDepthBuffer?: boolean;
  51147. /**
  51148. * Define if a stencil buffer is required
  51149. */
  51150. generateStencilBuffer?: boolean;
  51151. /**
  51152. * Define if a depth texture is required instead of a depth buffer
  51153. */
  51154. generateDepthTexture?: boolean;
  51155. /**
  51156. * Define the number of desired draw buffers
  51157. */
  51158. textureCount?: number;
  51159. /**
  51160. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51161. */
  51162. doNotChangeAspectRatio?: boolean;
  51163. /**
  51164. * Define the default type of the buffers we are creating
  51165. */
  51166. defaultType?: number;
  51167. }
  51168. /**
  51169. * A multi render target, like a render target provides the ability to render to a texture.
  51170. * Unlike the render target, it can render to several draw buffers in one draw.
  51171. * This is specially interesting in deferred rendering or for any effects requiring more than
  51172. * just one color from a single pass.
  51173. */
  51174. export class MultiRenderTarget extends RenderTargetTexture {
  51175. private _internalTextures;
  51176. private _textures;
  51177. private _multiRenderTargetOptions;
  51178. private _count;
  51179. /**
  51180. * Get if draw buffers are currently supported by the used hardware and browser.
  51181. */
  51182. get isSupported(): boolean;
  51183. /**
  51184. * Get the list of textures generated by the multi render target.
  51185. */
  51186. get textures(): Texture[];
  51187. /**
  51188. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  51189. */
  51190. get count(): number;
  51191. /**
  51192. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51193. */
  51194. get depthTexture(): Texture;
  51195. /**
  51196. * Set the wrapping mode on U of all the textures we are rendering to.
  51197. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51198. */
  51199. set wrapU(wrap: number);
  51200. /**
  51201. * Set the wrapping mode on V of all the textures we are rendering to.
  51202. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51203. */
  51204. set wrapV(wrap: number);
  51205. /**
  51206. * Instantiate a new multi render target texture.
  51207. * A multi render target, like a render target provides the ability to render to a texture.
  51208. * Unlike the render target, it can render to several draw buffers in one draw.
  51209. * This is specially interesting in deferred rendering or for any effects requiring more than
  51210. * just one color from a single pass.
  51211. * @param name Define the name of the texture
  51212. * @param size Define the size of the buffers to render to
  51213. * @param count Define the number of target we are rendering into
  51214. * @param scene Define the scene the texture belongs to
  51215. * @param options Define the options used to create the multi render target
  51216. */
  51217. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51218. /** @hidden */
  51219. _rebuild(): void;
  51220. private _createInternalTextures;
  51221. private _createTextures;
  51222. /**
  51223. * Define the number of samples used if MSAA is enabled.
  51224. */
  51225. get samples(): number;
  51226. set samples(value: number);
  51227. /**
  51228. * Resize all the textures in the multi render target.
  51229. * Be carrefull as it will recreate all the data in the new texture.
  51230. * @param size Define the new size
  51231. */
  51232. resize(size: any): void;
  51233. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51234. /**
  51235. * Dispose the render targets and their associated resources
  51236. */
  51237. dispose(): void;
  51238. /**
  51239. * Release all the underlying texture used as draw buffers.
  51240. */
  51241. releaseInternalTextures(): void;
  51242. }
  51243. }
  51244. declare module BABYLON {
  51245. interface ThinEngine {
  51246. /**
  51247. * Unbind a list of render target textures from the webGL context
  51248. * This is used only when drawBuffer extension or webGL2 are active
  51249. * @param textures defines the render target textures to unbind
  51250. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51251. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51252. */
  51253. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51254. /**
  51255. * Create a multi render target texture
  51256. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  51257. * @param size defines the size of the texture
  51258. * @param options defines the creation options
  51259. * @returns the cube texture as an InternalTexture
  51260. */
  51261. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51262. /**
  51263. * Update the sample count for a given multiple render target texture
  51264. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51265. * @param textures defines the textures to update
  51266. * @param samples defines the sample count to set
  51267. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51268. */
  51269. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51270. /**
  51271. * Select a subsets of attachments to draw to.
  51272. * @param attachments gl attachments
  51273. */
  51274. bindAttachments(attachments: number[]): void;
  51275. }
  51276. }
  51277. declare module BABYLON {
  51278. /**
  51279. * Class used to define an additional view for the engine
  51280. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51281. */
  51282. export class EngineView {
  51283. /** Defines the canvas where to render the view */
  51284. target: HTMLCanvasElement;
  51285. /** Defines an optional camera used to render the view (will use active camera else) */
  51286. camera?: Camera;
  51287. }
  51288. interface Engine {
  51289. /**
  51290. * Gets or sets the HTML element to use for attaching events
  51291. */
  51292. inputElement: Nullable<HTMLElement>;
  51293. /**
  51294. * Gets the current engine view
  51295. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51296. */
  51297. activeView: Nullable<EngineView>;
  51298. /** Gets or sets the list of views */
  51299. views: EngineView[];
  51300. /**
  51301. * Register a new child canvas
  51302. * @param canvas defines the canvas to register
  51303. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51304. * @returns the associated view
  51305. */
  51306. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51307. /**
  51308. * Remove a registered child canvas
  51309. * @param canvas defines the canvas to remove
  51310. * @returns the current engine
  51311. */
  51312. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51313. }
  51314. }
  51315. declare module BABYLON {
  51316. interface Engine {
  51317. /** @hidden */
  51318. _excludedCompressedTextures: string[];
  51319. /** @hidden */
  51320. _textureFormatInUse: string;
  51321. /**
  51322. * Gets the list of texture formats supported
  51323. */
  51324. readonly texturesSupported: Array<string>;
  51325. /**
  51326. * Gets the texture format in use
  51327. */
  51328. readonly textureFormatInUse: Nullable<string>;
  51329. /**
  51330. * Set the compressed texture extensions or file names to skip.
  51331. *
  51332. * @param skippedFiles defines the list of those texture files you want to skip
  51333. * Example: [".dds", ".env", "myfile.png"]
  51334. */
  51335. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51336. /**
  51337. * Set the compressed texture format to use, based on the formats you have, and the formats
  51338. * supported by the hardware / browser.
  51339. *
  51340. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51341. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51342. * to API arguments needed to compressed textures. This puts the burden on the container
  51343. * generator to house the arcane code for determining these for current & future formats.
  51344. *
  51345. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51346. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51347. *
  51348. * Note: The result of this call is not taken into account when a texture is base64.
  51349. *
  51350. * @param formatsAvailable defines the list of those format families you have created
  51351. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51352. *
  51353. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51354. * @returns The extension selected.
  51355. */
  51356. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51357. }
  51358. }
  51359. declare module BABYLON {
  51360. /**
  51361. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51362. */
  51363. export interface CubeMapInfo {
  51364. /**
  51365. * The pixel array for the front face.
  51366. * This is stored in format, left to right, up to down format.
  51367. */
  51368. front: Nullable<ArrayBufferView>;
  51369. /**
  51370. * The pixel array for the back face.
  51371. * This is stored in format, left to right, up to down format.
  51372. */
  51373. back: Nullable<ArrayBufferView>;
  51374. /**
  51375. * The pixel array for the left face.
  51376. * This is stored in format, left to right, up to down format.
  51377. */
  51378. left: Nullable<ArrayBufferView>;
  51379. /**
  51380. * The pixel array for the right face.
  51381. * This is stored in format, left to right, up to down format.
  51382. */
  51383. right: Nullable<ArrayBufferView>;
  51384. /**
  51385. * The pixel array for the up face.
  51386. * This is stored in format, left to right, up to down format.
  51387. */
  51388. up: Nullable<ArrayBufferView>;
  51389. /**
  51390. * The pixel array for the down face.
  51391. * This is stored in format, left to right, up to down format.
  51392. */
  51393. down: Nullable<ArrayBufferView>;
  51394. /**
  51395. * The size of the cubemap stored.
  51396. *
  51397. * Each faces will be size * size pixels.
  51398. */
  51399. size: number;
  51400. /**
  51401. * The format of the texture.
  51402. *
  51403. * RGBA, RGB.
  51404. */
  51405. format: number;
  51406. /**
  51407. * The type of the texture data.
  51408. *
  51409. * UNSIGNED_INT, FLOAT.
  51410. */
  51411. type: number;
  51412. /**
  51413. * Specifies whether the texture is in gamma space.
  51414. */
  51415. gammaSpace: boolean;
  51416. }
  51417. /**
  51418. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51419. */
  51420. export class PanoramaToCubeMapTools {
  51421. private static FACE_LEFT;
  51422. private static FACE_RIGHT;
  51423. private static FACE_FRONT;
  51424. private static FACE_BACK;
  51425. private static FACE_DOWN;
  51426. private static FACE_UP;
  51427. /**
  51428. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51429. *
  51430. * @param float32Array The source data.
  51431. * @param inputWidth The width of the input panorama.
  51432. * @param inputHeight The height of the input panorama.
  51433. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51434. * @return The cubemap data
  51435. */
  51436. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51437. private static CreateCubemapTexture;
  51438. private static CalcProjectionSpherical;
  51439. }
  51440. }
  51441. declare module BABYLON {
  51442. /**
  51443. * Helper class dealing with the extraction of spherical polynomial dataArray
  51444. * from a cube map.
  51445. */
  51446. export class CubeMapToSphericalPolynomialTools {
  51447. private static FileFaces;
  51448. /**
  51449. * Converts a texture to the according Spherical Polynomial data.
  51450. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51451. *
  51452. * @param texture The texture to extract the information from.
  51453. * @return The Spherical Polynomial data.
  51454. */
  51455. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51456. /**
  51457. * Converts a cubemap to the according Spherical Polynomial data.
  51458. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51459. *
  51460. * @param cubeInfo The Cube map to extract the information from.
  51461. * @return The Spherical Polynomial data.
  51462. */
  51463. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51464. }
  51465. }
  51466. declare module BABYLON {
  51467. interface BaseTexture {
  51468. /**
  51469. * Get the polynomial representation of the texture data.
  51470. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51471. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51472. */
  51473. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51474. }
  51475. }
  51476. declare module BABYLON {
  51477. /** @hidden */
  51478. export var rgbdEncodePixelShader: {
  51479. name: string;
  51480. shader: string;
  51481. };
  51482. }
  51483. declare module BABYLON {
  51484. /** @hidden */
  51485. export var rgbdDecodePixelShader: {
  51486. name: string;
  51487. shader: string;
  51488. };
  51489. }
  51490. declare module BABYLON {
  51491. /**
  51492. * Raw texture data and descriptor sufficient for WebGL texture upload
  51493. */
  51494. export interface EnvironmentTextureInfo {
  51495. /**
  51496. * Version of the environment map
  51497. */
  51498. version: number;
  51499. /**
  51500. * Width of image
  51501. */
  51502. width: number;
  51503. /**
  51504. * Irradiance information stored in the file.
  51505. */
  51506. irradiance: any;
  51507. /**
  51508. * Specular information stored in the file.
  51509. */
  51510. specular: any;
  51511. }
  51512. /**
  51513. * Defines One Image in the file. It requires only the position in the file
  51514. * as well as the length.
  51515. */
  51516. interface BufferImageData {
  51517. /**
  51518. * Length of the image data.
  51519. */
  51520. length: number;
  51521. /**
  51522. * Position of the data from the null terminator delimiting the end of the JSON.
  51523. */
  51524. position: number;
  51525. }
  51526. /**
  51527. * Defines the specular data enclosed in the file.
  51528. * This corresponds to the version 1 of the data.
  51529. */
  51530. export interface EnvironmentTextureSpecularInfoV1 {
  51531. /**
  51532. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51533. */
  51534. specularDataPosition?: number;
  51535. /**
  51536. * This contains all the images data needed to reconstruct the cubemap.
  51537. */
  51538. mipmaps: Array<BufferImageData>;
  51539. /**
  51540. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51541. */
  51542. lodGenerationScale: number;
  51543. }
  51544. /**
  51545. * Sets of helpers addressing the serialization and deserialization of environment texture
  51546. * stored in a BabylonJS env file.
  51547. * Those files are usually stored as .env files.
  51548. */
  51549. export class EnvironmentTextureTools {
  51550. /**
  51551. * Magic number identifying the env file.
  51552. */
  51553. private static _MagicBytes;
  51554. /**
  51555. * Gets the environment info from an env file.
  51556. * @param data The array buffer containing the .env bytes.
  51557. * @returns the environment file info (the json header) if successfully parsed.
  51558. */
  51559. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51560. /**
  51561. * Creates an environment texture from a loaded cube texture.
  51562. * @param texture defines the cube texture to convert in env file
  51563. * @return a promise containing the environment data if succesfull.
  51564. */
  51565. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51566. /**
  51567. * Creates a JSON representation of the spherical data.
  51568. * @param texture defines the texture containing the polynomials
  51569. * @return the JSON representation of the spherical info
  51570. */
  51571. private static _CreateEnvTextureIrradiance;
  51572. /**
  51573. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51574. * @param data the image data
  51575. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51576. * @return the views described by info providing access to the underlying buffer
  51577. */
  51578. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51579. /**
  51580. * Uploads the texture info contained in the env file to the GPU.
  51581. * @param texture defines the internal texture to upload to
  51582. * @param data defines the data to load
  51583. * @param info defines the texture info retrieved through the GetEnvInfo method
  51584. * @returns a promise
  51585. */
  51586. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51587. private static _OnImageReadyAsync;
  51588. /**
  51589. * Uploads the levels of image data to the GPU.
  51590. * @param texture defines the internal texture to upload to
  51591. * @param imageData defines the array buffer views of image data [mipmap][face]
  51592. * @returns a promise
  51593. */
  51594. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51595. /**
  51596. * Uploads spherical polynomials information to the texture.
  51597. * @param texture defines the texture we are trying to upload the information to
  51598. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51599. */
  51600. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51601. /** @hidden */
  51602. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51603. }
  51604. }
  51605. declare module BABYLON {
  51606. /**
  51607. * Class used to inline functions in shader code
  51608. */
  51609. export class ShaderCodeInliner {
  51610. private static readonly _RegexpFindFunctionNameAndType;
  51611. private _sourceCode;
  51612. private _functionDescr;
  51613. private _numMaxIterations;
  51614. /** Gets or sets the token used to mark the functions to inline */
  51615. inlineToken: string;
  51616. /** Gets or sets the debug mode */
  51617. debug: boolean;
  51618. /** Gets the code after the inlining process */
  51619. get code(): string;
  51620. /**
  51621. * Initializes the inliner
  51622. * @param sourceCode shader code source to inline
  51623. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51624. */
  51625. constructor(sourceCode: string, numMaxIterations?: number);
  51626. /**
  51627. * Start the processing of the shader code
  51628. */
  51629. processCode(): void;
  51630. private _collectFunctions;
  51631. private _processInlining;
  51632. private _extractBetweenMarkers;
  51633. private _skipWhitespaces;
  51634. private _removeComments;
  51635. private _replaceFunctionCallsByCode;
  51636. private _findBackward;
  51637. private _escapeRegExp;
  51638. private _replaceNames;
  51639. }
  51640. }
  51641. declare module BABYLON {
  51642. /**
  51643. * Container for accessors for natively-stored mesh data buffers.
  51644. */
  51645. class NativeDataBuffer extends DataBuffer {
  51646. /**
  51647. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51648. */
  51649. nativeIndexBuffer?: any;
  51650. /**
  51651. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51652. */
  51653. nativeVertexBuffer?: any;
  51654. }
  51655. /** @hidden */
  51656. class NativeTexture extends InternalTexture {
  51657. getInternalTexture(): InternalTexture;
  51658. getViewCount(): number;
  51659. }
  51660. /** @hidden */
  51661. export class NativeEngine extends Engine {
  51662. private readonly _native;
  51663. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51664. private readonly INVALID_HANDLE;
  51665. getHardwareScalingLevel(): number;
  51666. constructor();
  51667. dispose(): void;
  51668. /**
  51669. * Can be used to override the current requestAnimationFrame requester.
  51670. * @hidden
  51671. */
  51672. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51673. /**
  51674. * Override default engine behavior.
  51675. * @param color
  51676. * @param backBuffer
  51677. * @param depth
  51678. * @param stencil
  51679. */
  51680. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51681. /**
  51682. * Gets host document
  51683. * @returns the host document object
  51684. */
  51685. getHostDocument(): Nullable<Document>;
  51686. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51687. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51688. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51689. recordVertexArrayObject(vertexBuffers: {
  51690. [key: string]: VertexBuffer;
  51691. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51692. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51693. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51694. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51695. /**
  51696. * Draw a list of indexed primitives
  51697. * @param fillMode defines the primitive to use
  51698. * @param indexStart defines the starting index
  51699. * @param indexCount defines the number of index to draw
  51700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51701. */
  51702. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51703. /**
  51704. * Draw a list of unindexed primitives
  51705. * @param fillMode defines the primitive to use
  51706. * @param verticesStart defines the index of first vertex to draw
  51707. * @param verticesCount defines the count of vertices to draw
  51708. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51709. */
  51710. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51711. createPipelineContext(): IPipelineContext;
  51712. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51713. /** @hidden */
  51714. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51715. /** @hidden */
  51716. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51717. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51718. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51719. protected _setProgram(program: WebGLProgram): void;
  51720. _releaseEffect(effect: Effect): void;
  51721. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51722. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51723. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51724. bindSamplers(effect: Effect): void;
  51725. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51726. getRenderWidth(useScreen?: boolean): number;
  51727. getRenderHeight(useScreen?: boolean): number;
  51728. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51729. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51730. /**
  51731. * Set the z offset to apply to current rendering
  51732. * @param value defines the offset to apply
  51733. */
  51734. setZOffset(value: number): void;
  51735. /**
  51736. * Gets the current value of the zOffset
  51737. * @returns the current zOffset state
  51738. */
  51739. getZOffset(): number;
  51740. /**
  51741. * Enable or disable depth buffering
  51742. * @param enable defines the state to set
  51743. */
  51744. setDepthBuffer(enable: boolean): void;
  51745. /**
  51746. * Gets a boolean indicating if depth writing is enabled
  51747. * @returns the current depth writing state
  51748. */
  51749. getDepthWrite(): boolean;
  51750. /**
  51751. * Enable or disable depth writing
  51752. * @param enable defines the state to set
  51753. */
  51754. setDepthWrite(enable: boolean): void;
  51755. /**
  51756. * Enable or disable color writing
  51757. * @param enable defines the state to set
  51758. */
  51759. setColorWrite(enable: boolean): void;
  51760. /**
  51761. * Gets a boolean indicating if color writing is enabled
  51762. * @returns the current color writing state
  51763. */
  51764. getColorWrite(): boolean;
  51765. /**
  51766. * Sets alpha constants used by some alpha blending modes
  51767. * @param r defines the red component
  51768. * @param g defines the green component
  51769. * @param b defines the blue component
  51770. * @param a defines the alpha component
  51771. */
  51772. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51773. /**
  51774. * Sets the current alpha mode
  51775. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51776. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51777. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51778. */
  51779. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51780. /**
  51781. * Gets the current alpha mode
  51782. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51783. * @returns the current alpha mode
  51784. */
  51785. getAlphaMode(): number;
  51786. setInt(uniform: WebGLUniformLocation, int: number): void;
  51787. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51788. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51789. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51790. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51791. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51792. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51793. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51794. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51795. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51796. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51797. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51798. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51799. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51800. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51801. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51802. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51803. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51804. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51805. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51806. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51807. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51808. wipeCaches(bruteForce?: boolean): void;
  51809. _createTexture(): WebGLTexture;
  51810. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51811. /**
  51812. * Usually called from Texture.ts.
  51813. * Passed information to create a WebGLTexture
  51814. * @param url defines a value which contains one of the following:
  51815. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51816. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51817. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51818. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51819. * @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)
  51820. * @param scene needed for loading to the correct scene
  51821. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51822. * @param onLoad optional callback to be called upon successful completion
  51823. * @param onError optional callback to be called upon failure
  51824. * @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
  51825. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51826. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51827. * @param forcedExtension defines the extension to use to pick the right loader
  51828. * @param mimeType defines an optional mime type
  51829. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51830. */
  51831. 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;
  51832. /**
  51833. * Creates a cube texture
  51834. * @param rootUrl defines the url where the files to load is located
  51835. * @param scene defines the current scene
  51836. * @param files defines the list of files to load (1 per face)
  51837. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51838. * @param onLoad defines an optional callback raised when the texture is loaded
  51839. * @param onError defines an optional callback raised if there is an issue to load the texture
  51840. * @param format defines the format of the data
  51841. * @param forcedExtension defines the extension to use to pick the right loader
  51842. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51843. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51844. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51845. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51846. * @returns the cube texture as an InternalTexture
  51847. */
  51848. 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;
  51849. private _getSamplingFilter;
  51850. private static _GetNativeTextureFormat;
  51851. createRenderTargetTexture(size: number | {
  51852. width: number;
  51853. height: number;
  51854. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51855. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51856. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51857. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51858. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51859. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51860. /**
  51861. * Updates a dynamic vertex buffer.
  51862. * @param vertexBuffer the vertex buffer to update
  51863. * @param data the data used to update the vertex buffer
  51864. * @param byteOffset the byte offset of the data (optional)
  51865. * @param byteLength the byte length of the data (optional)
  51866. */
  51867. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51868. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51869. private _updateAnisotropicLevel;
  51870. private _getAddressMode;
  51871. /** @hidden */
  51872. _bindTexture(channel: number, texture: InternalTexture): void;
  51873. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51874. releaseEffects(): void;
  51875. /** @hidden */
  51876. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51877. /** @hidden */
  51878. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51879. /** @hidden */
  51880. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51881. /** @hidden */
  51882. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51883. }
  51884. }
  51885. declare module BABYLON {
  51886. /**
  51887. * Gather the list of clipboard event types as constants.
  51888. */
  51889. export class ClipboardEventTypes {
  51890. /**
  51891. * The clipboard event is fired when a copy command is active (pressed).
  51892. */
  51893. static readonly COPY: number;
  51894. /**
  51895. * The clipboard event is fired when a cut command is active (pressed).
  51896. */
  51897. static readonly CUT: number;
  51898. /**
  51899. * The clipboard event is fired when a paste command is active (pressed).
  51900. */
  51901. static readonly PASTE: number;
  51902. }
  51903. /**
  51904. * This class is used to store clipboard related info for the onClipboardObservable event.
  51905. */
  51906. export class ClipboardInfo {
  51907. /**
  51908. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51909. */
  51910. type: number;
  51911. /**
  51912. * Defines the related dom event
  51913. */
  51914. event: ClipboardEvent;
  51915. /**
  51916. *Creates an instance of ClipboardInfo.
  51917. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51918. * @param event Defines the related dom event
  51919. */
  51920. constructor(
  51921. /**
  51922. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51923. */
  51924. type: number,
  51925. /**
  51926. * Defines the related dom event
  51927. */
  51928. event: ClipboardEvent);
  51929. /**
  51930. * Get the clipboard event's type from the keycode.
  51931. * @param keyCode Defines the keyCode for the current keyboard event.
  51932. * @return {number}
  51933. */
  51934. static GetTypeFromCharacter(keyCode: number): number;
  51935. }
  51936. }
  51937. declare module BABYLON {
  51938. /**
  51939. * Google Daydream controller
  51940. */
  51941. export class DaydreamController extends WebVRController {
  51942. /**
  51943. * Base Url for the controller model.
  51944. */
  51945. static MODEL_BASE_URL: string;
  51946. /**
  51947. * File name for the controller model.
  51948. */
  51949. static MODEL_FILENAME: string;
  51950. /**
  51951. * Gamepad Id prefix used to identify Daydream Controller.
  51952. */
  51953. static readonly GAMEPAD_ID_PREFIX: string;
  51954. /**
  51955. * Creates a new DaydreamController from a gamepad
  51956. * @param vrGamepad the gamepad that the controller should be created from
  51957. */
  51958. constructor(vrGamepad: any);
  51959. /**
  51960. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51961. * @param scene scene in which to add meshes
  51962. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51963. */
  51964. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51965. /**
  51966. * Called once for each button that changed state since the last frame
  51967. * @param buttonIdx Which button index changed
  51968. * @param state New state of the button
  51969. * @param changes Which properties on the state changed since last frame
  51970. */
  51971. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51972. }
  51973. }
  51974. declare module BABYLON {
  51975. /**
  51976. * Gear VR Controller
  51977. */
  51978. export class GearVRController extends WebVRController {
  51979. /**
  51980. * Base Url for the controller model.
  51981. */
  51982. static MODEL_BASE_URL: string;
  51983. /**
  51984. * File name for the controller model.
  51985. */
  51986. static MODEL_FILENAME: string;
  51987. /**
  51988. * Gamepad Id prefix used to identify this controller.
  51989. */
  51990. static readonly GAMEPAD_ID_PREFIX: string;
  51991. private readonly _buttonIndexToObservableNameMap;
  51992. /**
  51993. * Creates a new GearVRController from a gamepad
  51994. * @param vrGamepad the gamepad that the controller should be created from
  51995. */
  51996. constructor(vrGamepad: any);
  51997. /**
  51998. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51999. * @param scene scene in which to add meshes
  52000. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52001. */
  52002. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52003. /**
  52004. * Called once for each button that changed state since the last frame
  52005. * @param buttonIdx Which button index changed
  52006. * @param state New state of the button
  52007. * @param changes Which properties on the state changed since last frame
  52008. */
  52009. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52010. }
  52011. }
  52012. declare module BABYLON {
  52013. /**
  52014. * Generic Controller
  52015. */
  52016. export class GenericController extends WebVRController {
  52017. /**
  52018. * Base Url for the controller model.
  52019. */
  52020. static readonly MODEL_BASE_URL: string;
  52021. /**
  52022. * File name for the controller model.
  52023. */
  52024. static readonly MODEL_FILENAME: string;
  52025. /**
  52026. * Creates a new GenericController from a gamepad
  52027. * @param vrGamepad the gamepad that the controller should be created from
  52028. */
  52029. constructor(vrGamepad: any);
  52030. /**
  52031. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52032. * @param scene scene in which to add meshes
  52033. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52034. */
  52035. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52036. /**
  52037. * Called once for each button that changed state since the last frame
  52038. * @param buttonIdx Which button index changed
  52039. * @param state New state of the button
  52040. * @param changes Which properties on the state changed since last frame
  52041. */
  52042. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52043. }
  52044. }
  52045. declare module BABYLON {
  52046. /**
  52047. * Oculus Touch Controller
  52048. */
  52049. export class OculusTouchController extends WebVRController {
  52050. /**
  52051. * Base Url for the controller model.
  52052. */
  52053. static MODEL_BASE_URL: string;
  52054. /**
  52055. * File name for the left controller model.
  52056. */
  52057. static MODEL_LEFT_FILENAME: string;
  52058. /**
  52059. * File name for the right controller model.
  52060. */
  52061. static MODEL_RIGHT_FILENAME: string;
  52062. /**
  52063. * Base Url for the Quest controller model.
  52064. */
  52065. static QUEST_MODEL_BASE_URL: string;
  52066. /**
  52067. * @hidden
  52068. * If the controllers are running on a device that needs the updated Quest controller models
  52069. */
  52070. static _IsQuest: boolean;
  52071. /**
  52072. * Fired when the secondary trigger on this controller is modified
  52073. */
  52074. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52075. /**
  52076. * Fired when the thumb rest on this controller is modified
  52077. */
  52078. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52079. /**
  52080. * Creates a new OculusTouchController from a gamepad
  52081. * @param vrGamepad the gamepad that the controller should be created from
  52082. */
  52083. constructor(vrGamepad: any);
  52084. /**
  52085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52086. * @param scene scene in which to add meshes
  52087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52088. */
  52089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52090. /**
  52091. * Fired when the A button on this controller is modified
  52092. */
  52093. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52094. /**
  52095. * Fired when the B button on this controller is modified
  52096. */
  52097. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52098. /**
  52099. * Fired when the X button on this controller is modified
  52100. */
  52101. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52102. /**
  52103. * Fired when the Y button on this controller is modified
  52104. */
  52105. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52106. /**
  52107. * Called once for each button that changed state since the last frame
  52108. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52109. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52110. * 2) secondary trigger (same)
  52111. * 3) A (right) X (left), touch, pressed = value
  52112. * 4) B / Y
  52113. * 5) thumb rest
  52114. * @param buttonIdx Which button index changed
  52115. * @param state New state of the button
  52116. * @param changes Which properties on the state changed since last frame
  52117. */
  52118. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52119. }
  52120. }
  52121. declare module BABYLON {
  52122. /**
  52123. * Vive Controller
  52124. */
  52125. export class ViveController extends WebVRController {
  52126. /**
  52127. * Base Url for the controller model.
  52128. */
  52129. static MODEL_BASE_URL: string;
  52130. /**
  52131. * File name for the controller model.
  52132. */
  52133. static MODEL_FILENAME: string;
  52134. /**
  52135. * Creates a new ViveController from a gamepad
  52136. * @param vrGamepad the gamepad that the controller should be created from
  52137. */
  52138. constructor(vrGamepad: any);
  52139. /**
  52140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52141. * @param scene scene in which to add meshes
  52142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52143. */
  52144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52145. /**
  52146. * Fired when the left button on this controller is modified
  52147. */
  52148. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52149. /**
  52150. * Fired when the right button on this controller is modified
  52151. */
  52152. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52153. /**
  52154. * Fired when the menu button on this controller is modified
  52155. */
  52156. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52157. /**
  52158. * Called once for each button that changed state since the last frame
  52159. * Vive mapping:
  52160. * 0: touchpad
  52161. * 1: trigger
  52162. * 2: left AND right buttons
  52163. * 3: menu button
  52164. * @param buttonIdx Which button index changed
  52165. * @param state New state of the button
  52166. * @param changes Which properties on the state changed since last frame
  52167. */
  52168. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52169. }
  52170. }
  52171. declare module BABYLON {
  52172. /**
  52173. * Defines the WindowsMotionController object that the state of the windows motion controller
  52174. */
  52175. export class WindowsMotionController extends WebVRController {
  52176. /**
  52177. * The base url used to load the left and right controller models
  52178. */
  52179. static MODEL_BASE_URL: string;
  52180. /**
  52181. * The name of the left controller model file
  52182. */
  52183. static MODEL_LEFT_FILENAME: string;
  52184. /**
  52185. * The name of the right controller model file
  52186. */
  52187. static MODEL_RIGHT_FILENAME: string;
  52188. /**
  52189. * The controller name prefix for this controller type
  52190. */
  52191. static readonly GAMEPAD_ID_PREFIX: string;
  52192. /**
  52193. * The controller id pattern for this controller type
  52194. */
  52195. private static readonly GAMEPAD_ID_PATTERN;
  52196. private _loadedMeshInfo;
  52197. protected readonly _mapping: {
  52198. buttons: string[];
  52199. buttonMeshNames: {
  52200. trigger: string;
  52201. menu: string;
  52202. grip: string;
  52203. thumbstick: string;
  52204. trackpad: string;
  52205. };
  52206. buttonObservableNames: {
  52207. trigger: string;
  52208. menu: string;
  52209. grip: string;
  52210. thumbstick: string;
  52211. trackpad: string;
  52212. };
  52213. axisMeshNames: string[];
  52214. pointingPoseMeshName: string;
  52215. };
  52216. /**
  52217. * Fired when the trackpad on this controller is clicked
  52218. */
  52219. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52220. /**
  52221. * Fired when the trackpad on this controller is modified
  52222. */
  52223. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52224. /**
  52225. * The current x and y values of this controller's trackpad
  52226. */
  52227. trackpad: StickValues;
  52228. /**
  52229. * Creates a new WindowsMotionController from a gamepad
  52230. * @param vrGamepad the gamepad that the controller should be created from
  52231. */
  52232. constructor(vrGamepad: any);
  52233. /**
  52234. * Fired when the trigger on this controller is modified
  52235. */
  52236. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52237. /**
  52238. * Fired when the menu button on this controller is modified
  52239. */
  52240. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52241. /**
  52242. * Fired when the grip button on this controller is modified
  52243. */
  52244. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52245. /**
  52246. * Fired when the thumbstick button on this controller is modified
  52247. */
  52248. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52249. /**
  52250. * Fired when the touchpad button on this controller is modified
  52251. */
  52252. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52253. /**
  52254. * Fired when the touchpad values on this controller are modified
  52255. */
  52256. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52257. protected _updateTrackpad(): void;
  52258. /**
  52259. * Called once per frame by the engine.
  52260. */
  52261. update(): void;
  52262. /**
  52263. * Called once for each button that changed state since the last frame
  52264. * @param buttonIdx Which button index changed
  52265. * @param state New state of the button
  52266. * @param changes Which properties on the state changed since last frame
  52267. */
  52268. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52269. /**
  52270. * Moves the buttons on the controller mesh based on their current state
  52271. * @param buttonName the name of the button to move
  52272. * @param buttonValue the value of the button which determines the buttons new position
  52273. */
  52274. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52275. /**
  52276. * Moves the axis on the controller mesh based on its current state
  52277. * @param axis the index of the axis
  52278. * @param axisValue the value of the axis which determines the meshes new position
  52279. * @hidden
  52280. */
  52281. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52282. /**
  52283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52284. * @param scene scene in which to add meshes
  52285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52286. */
  52287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52288. /**
  52289. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52290. * can be transformed by button presses and axes values, based on this._mapping.
  52291. *
  52292. * @param scene scene in which the meshes exist
  52293. * @param meshes list of meshes that make up the controller model to process
  52294. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52295. */
  52296. private processModel;
  52297. private createMeshInfo;
  52298. /**
  52299. * Gets the ray of the controller in the direction the controller is pointing
  52300. * @param length the length the resulting ray should be
  52301. * @returns a ray in the direction the controller is pointing
  52302. */
  52303. getForwardRay(length?: number): Ray;
  52304. /**
  52305. * Disposes of the controller
  52306. */
  52307. dispose(): void;
  52308. }
  52309. /**
  52310. * This class represents a new windows motion controller in XR.
  52311. */
  52312. export class XRWindowsMotionController extends WindowsMotionController {
  52313. /**
  52314. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52315. */
  52316. protected readonly _mapping: {
  52317. buttons: string[];
  52318. buttonMeshNames: {
  52319. trigger: string;
  52320. menu: string;
  52321. grip: string;
  52322. thumbstick: string;
  52323. trackpad: string;
  52324. };
  52325. buttonObservableNames: {
  52326. trigger: string;
  52327. menu: string;
  52328. grip: string;
  52329. thumbstick: string;
  52330. trackpad: string;
  52331. };
  52332. axisMeshNames: string[];
  52333. pointingPoseMeshName: string;
  52334. };
  52335. /**
  52336. * Construct a new XR-Based windows motion controller
  52337. *
  52338. * @param gamepadInfo the gamepad object from the browser
  52339. */
  52340. constructor(gamepadInfo: any);
  52341. /**
  52342. * holds the thumbstick values (X,Y)
  52343. */
  52344. thumbstickValues: StickValues;
  52345. /**
  52346. * Fired when the thumbstick on this controller is clicked
  52347. */
  52348. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52349. /**
  52350. * Fired when the thumbstick on this controller is modified
  52351. */
  52352. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52353. /**
  52354. * Fired when the touchpad button on this controller is modified
  52355. */
  52356. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52357. /**
  52358. * Fired when the touchpad values on this controller are modified
  52359. */
  52360. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52361. /**
  52362. * Fired when the thumbstick button on this controller is modified
  52363. * here to prevent breaking changes
  52364. */
  52365. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52366. /**
  52367. * updating the thumbstick(!) and not the trackpad.
  52368. * This is named this way due to the difference between WebVR and XR and to avoid
  52369. * changing the parent class.
  52370. */
  52371. protected _updateTrackpad(): void;
  52372. /**
  52373. * Disposes the class with joy
  52374. */
  52375. dispose(): void;
  52376. }
  52377. }
  52378. declare module BABYLON {
  52379. /**
  52380. * Class containing static functions to help procedurally build meshes
  52381. */
  52382. export class PolyhedronBuilder {
  52383. /**
  52384. * Creates a polyhedron mesh
  52385. * * 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
  52386. * * The parameter `size` (positive float, default 1) sets the polygon size
  52387. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52388. * * 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`
  52389. * * 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
  52390. * * 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)`)
  52391. * * 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
  52392. * * 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
  52393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52394. * * 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
  52395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52396. * @param name defines the name of the mesh
  52397. * @param options defines the options used to create the mesh
  52398. * @param scene defines the hosting scene
  52399. * @returns the polyhedron mesh
  52400. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52401. */
  52402. static CreatePolyhedron(name: string, options: {
  52403. type?: number;
  52404. size?: number;
  52405. sizeX?: number;
  52406. sizeY?: number;
  52407. sizeZ?: number;
  52408. custom?: any;
  52409. faceUV?: Vector4[];
  52410. faceColors?: Color4[];
  52411. flat?: boolean;
  52412. updatable?: boolean;
  52413. sideOrientation?: number;
  52414. frontUVs?: Vector4;
  52415. backUVs?: Vector4;
  52416. }, scene?: Nullable<Scene>): Mesh;
  52417. }
  52418. }
  52419. declare module BABYLON {
  52420. /**
  52421. * Gizmo that enables scaling a mesh along 3 axis
  52422. */
  52423. export class ScaleGizmo extends Gizmo {
  52424. /**
  52425. * Internal gizmo used for interactions on the x axis
  52426. */
  52427. xGizmo: AxisScaleGizmo;
  52428. /**
  52429. * Internal gizmo used for interactions on the y axis
  52430. */
  52431. yGizmo: AxisScaleGizmo;
  52432. /**
  52433. * Internal gizmo used for interactions on the z axis
  52434. */
  52435. zGizmo: AxisScaleGizmo;
  52436. /**
  52437. * Internal gizmo used to scale all axis equally
  52438. */
  52439. uniformScaleGizmo: AxisScaleGizmo;
  52440. private _meshAttached;
  52441. private _updateGizmoRotationToMatchAttachedMesh;
  52442. private _snapDistance;
  52443. private _scaleRatio;
  52444. private _uniformScalingMesh;
  52445. private _octahedron;
  52446. private _sensitivity;
  52447. /** Fires an event when any of it's sub gizmos are dragged */
  52448. onDragStartObservable: Observable<unknown>;
  52449. /** Fires an event when any of it's sub gizmos are released from dragging */
  52450. onDragEndObservable: Observable<unknown>;
  52451. get attachedMesh(): Nullable<AbstractMesh>;
  52452. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52453. /**
  52454. * Creates a ScaleGizmo
  52455. * @param gizmoLayer The utility layer the gizmo will be added to
  52456. */
  52457. constructor(gizmoLayer?: UtilityLayerRenderer);
  52458. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52459. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52460. /**
  52461. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52462. */
  52463. set snapDistance(value: number);
  52464. get snapDistance(): number;
  52465. /**
  52466. * Ratio for the scale of the gizmo (Default: 1)
  52467. */
  52468. set scaleRatio(value: number);
  52469. get scaleRatio(): number;
  52470. /**
  52471. * Sensitivity factor for dragging (Default: 1)
  52472. */
  52473. set sensitivity(value: number);
  52474. get sensitivity(): number;
  52475. /**
  52476. * Disposes of the gizmo
  52477. */
  52478. dispose(): void;
  52479. }
  52480. }
  52481. declare module BABYLON {
  52482. /**
  52483. * Single axis scale gizmo
  52484. */
  52485. export class AxisScaleGizmo extends Gizmo {
  52486. /**
  52487. * Drag behavior responsible for the gizmos dragging interactions
  52488. */
  52489. dragBehavior: PointerDragBehavior;
  52490. private _pointerObserver;
  52491. /**
  52492. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52493. */
  52494. snapDistance: number;
  52495. /**
  52496. * Event that fires each time the gizmo snaps to a new location.
  52497. * * snapDistance is the the change in distance
  52498. */
  52499. onSnapObservable: Observable<{
  52500. snapDistance: number;
  52501. }>;
  52502. /**
  52503. * If the scaling operation should be done on all axis (default: false)
  52504. */
  52505. uniformScaling: boolean;
  52506. /**
  52507. * Custom sensitivity value for the drag strength
  52508. */
  52509. sensitivity: number;
  52510. private _isEnabled;
  52511. private _parent;
  52512. private _arrow;
  52513. private _coloredMaterial;
  52514. private _hoverMaterial;
  52515. /**
  52516. * Creates an AxisScaleGizmo
  52517. * @param gizmoLayer The utility layer the gizmo will be added to
  52518. * @param dragAxis The axis which the gizmo will be able to scale on
  52519. * @param color The color of the gizmo
  52520. */
  52521. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52522. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52523. /**
  52524. * If the gizmo is enabled
  52525. */
  52526. set isEnabled(value: boolean);
  52527. get isEnabled(): boolean;
  52528. /**
  52529. * Disposes of the gizmo
  52530. */
  52531. dispose(): void;
  52532. /**
  52533. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52534. * @param mesh The mesh to replace the default mesh of the gizmo
  52535. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52536. */
  52537. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52538. }
  52539. }
  52540. declare module BABYLON {
  52541. /**
  52542. * Bounding box gizmo
  52543. */
  52544. export class BoundingBoxGizmo extends Gizmo {
  52545. private _lineBoundingBox;
  52546. private _rotateSpheresParent;
  52547. private _scaleBoxesParent;
  52548. private _boundingDimensions;
  52549. private _renderObserver;
  52550. private _pointerObserver;
  52551. private _scaleDragSpeed;
  52552. private _tmpQuaternion;
  52553. private _tmpVector;
  52554. private _tmpRotationMatrix;
  52555. /**
  52556. * 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)
  52557. */
  52558. ignoreChildren: boolean;
  52559. /**
  52560. * 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)
  52561. */
  52562. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52563. /**
  52564. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52565. */
  52566. rotationSphereSize: number;
  52567. /**
  52568. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52569. */
  52570. scaleBoxSize: number;
  52571. /**
  52572. * 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)
  52573. */
  52574. fixedDragMeshScreenSize: boolean;
  52575. /**
  52576. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52577. */
  52578. fixedDragMeshScreenSizeDistanceFactor: number;
  52579. /**
  52580. * Fired when a rotation sphere or scale box is dragged
  52581. */
  52582. onDragStartObservable: Observable<{}>;
  52583. /**
  52584. * Fired when a scale box is dragged
  52585. */
  52586. onScaleBoxDragObservable: Observable<{}>;
  52587. /**
  52588. * Fired when a scale box drag is ended
  52589. */
  52590. onScaleBoxDragEndObservable: Observable<{}>;
  52591. /**
  52592. * Fired when a rotation sphere is dragged
  52593. */
  52594. onRotationSphereDragObservable: Observable<{}>;
  52595. /**
  52596. * Fired when a rotation sphere drag is ended
  52597. */
  52598. onRotationSphereDragEndObservable: Observable<{}>;
  52599. /**
  52600. * 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)
  52601. */
  52602. scalePivot: Nullable<Vector3>;
  52603. /**
  52604. * Mesh used as a pivot to rotate the attached mesh
  52605. */
  52606. private _anchorMesh;
  52607. private _existingMeshScale;
  52608. private _dragMesh;
  52609. private pointerDragBehavior;
  52610. private coloredMaterial;
  52611. private hoverColoredMaterial;
  52612. /**
  52613. * Sets the color of the bounding box gizmo
  52614. * @param color the color to set
  52615. */
  52616. setColor(color: Color3): void;
  52617. /**
  52618. * Creates an BoundingBoxGizmo
  52619. * @param gizmoLayer The utility layer the gizmo will be added to
  52620. * @param color The color of the gizmo
  52621. */
  52622. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52623. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52624. private _selectNode;
  52625. /**
  52626. * Updates the bounding box information for the Gizmo
  52627. */
  52628. updateBoundingBox(): void;
  52629. private _updateRotationSpheres;
  52630. private _updateScaleBoxes;
  52631. /**
  52632. * Enables rotation on the specified axis and disables rotation on the others
  52633. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52634. */
  52635. setEnabledRotationAxis(axis: string): void;
  52636. /**
  52637. * Enables/disables scaling
  52638. * @param enable if scaling should be enabled
  52639. * @param homogeneousScaling defines if scaling should only be homogeneous
  52640. */
  52641. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52642. private _updateDummy;
  52643. /**
  52644. * Enables a pointer drag behavior on the bounding box of the gizmo
  52645. */
  52646. enableDragBehavior(): void;
  52647. /**
  52648. * Disposes of the gizmo
  52649. */
  52650. dispose(): void;
  52651. /**
  52652. * 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)
  52653. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52654. * @returns the bounding box mesh with the passed in mesh as a child
  52655. */
  52656. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52657. /**
  52658. * CustomMeshes are not supported by this gizmo
  52659. * @param mesh The mesh to replace the default mesh of the gizmo
  52660. */
  52661. setCustomMesh(mesh: Mesh): void;
  52662. }
  52663. }
  52664. declare module BABYLON {
  52665. /**
  52666. * Single plane rotation gizmo
  52667. */
  52668. export class PlaneRotationGizmo extends Gizmo {
  52669. /**
  52670. * Drag behavior responsible for the gizmos dragging interactions
  52671. */
  52672. dragBehavior: PointerDragBehavior;
  52673. private _pointerObserver;
  52674. /**
  52675. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52676. */
  52677. snapDistance: number;
  52678. /**
  52679. * Event that fires each time the gizmo snaps to a new location.
  52680. * * snapDistance is the the change in distance
  52681. */
  52682. onSnapObservable: Observable<{
  52683. snapDistance: number;
  52684. }>;
  52685. private _isEnabled;
  52686. private _parent;
  52687. /**
  52688. * Creates a PlaneRotationGizmo
  52689. * @param gizmoLayer The utility layer the gizmo will be added to
  52690. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52691. * @param color The color of the gizmo
  52692. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52693. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52694. */
  52695. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52696. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52697. /**
  52698. * If the gizmo is enabled
  52699. */
  52700. set isEnabled(value: boolean);
  52701. get isEnabled(): boolean;
  52702. /**
  52703. * Disposes of the gizmo
  52704. */
  52705. dispose(): void;
  52706. }
  52707. }
  52708. declare module BABYLON {
  52709. /**
  52710. * Gizmo that enables rotating a mesh along 3 axis
  52711. */
  52712. export class RotationGizmo extends Gizmo {
  52713. /**
  52714. * Internal gizmo used for interactions on the x axis
  52715. */
  52716. xGizmo: PlaneRotationGizmo;
  52717. /**
  52718. * Internal gizmo used for interactions on the y axis
  52719. */
  52720. yGizmo: PlaneRotationGizmo;
  52721. /**
  52722. * Internal gizmo used for interactions on the z axis
  52723. */
  52724. zGizmo: PlaneRotationGizmo;
  52725. /** Fires an event when any of it's sub gizmos are dragged */
  52726. onDragStartObservable: Observable<unknown>;
  52727. /** Fires an event when any of it's sub gizmos are released from dragging */
  52728. onDragEndObservable: Observable<unknown>;
  52729. private _meshAttached;
  52730. get attachedMesh(): Nullable<AbstractMesh>;
  52731. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52732. /**
  52733. * Creates a RotationGizmo
  52734. * @param gizmoLayer The utility layer the gizmo will be added to
  52735. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52736. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52737. */
  52738. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52739. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52740. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52741. /**
  52742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52743. */
  52744. set snapDistance(value: number);
  52745. get snapDistance(): number;
  52746. /**
  52747. * Ratio for the scale of the gizmo (Default: 1)
  52748. */
  52749. set scaleRatio(value: number);
  52750. get scaleRatio(): number;
  52751. /**
  52752. * Disposes of the gizmo
  52753. */
  52754. dispose(): void;
  52755. /**
  52756. * CustomMeshes are not supported by this gizmo
  52757. * @param mesh The mesh to replace the default mesh of the gizmo
  52758. */
  52759. setCustomMesh(mesh: Mesh): void;
  52760. }
  52761. }
  52762. declare module BABYLON {
  52763. /**
  52764. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52765. */
  52766. export class GizmoManager implements IDisposable {
  52767. private scene;
  52768. /**
  52769. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52770. */
  52771. gizmos: {
  52772. positionGizmo: Nullable<PositionGizmo>;
  52773. rotationGizmo: Nullable<RotationGizmo>;
  52774. scaleGizmo: Nullable<ScaleGizmo>;
  52775. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52776. };
  52777. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52778. clearGizmoOnEmptyPointerEvent: boolean;
  52779. /** Fires an event when the manager is attached to a mesh */
  52780. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52781. private _gizmosEnabled;
  52782. private _pointerObserver;
  52783. private _attachedMesh;
  52784. private _boundingBoxColor;
  52785. private _defaultUtilityLayer;
  52786. private _defaultKeepDepthUtilityLayer;
  52787. /**
  52788. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52789. */
  52790. boundingBoxDragBehavior: SixDofDragBehavior;
  52791. /**
  52792. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52793. */
  52794. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52795. /**
  52796. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52797. */
  52798. usePointerToAttachGizmos: boolean;
  52799. /**
  52800. * Utility layer that the bounding box gizmo belongs to
  52801. */
  52802. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52803. /**
  52804. * Utility layer that all gizmos besides bounding box belong to
  52805. */
  52806. get utilityLayer(): UtilityLayerRenderer;
  52807. /**
  52808. * Instatiates a gizmo manager
  52809. * @param scene the scene to overlay the gizmos on top of
  52810. */
  52811. constructor(scene: Scene);
  52812. /**
  52813. * Attaches a set of gizmos to the specified mesh
  52814. * @param mesh The mesh the gizmo's should be attached to
  52815. */
  52816. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52817. /**
  52818. * If the position gizmo is enabled
  52819. */
  52820. set positionGizmoEnabled(value: boolean);
  52821. get positionGizmoEnabled(): boolean;
  52822. /**
  52823. * If the rotation gizmo is enabled
  52824. */
  52825. set rotationGizmoEnabled(value: boolean);
  52826. get rotationGizmoEnabled(): boolean;
  52827. /**
  52828. * If the scale gizmo is enabled
  52829. */
  52830. set scaleGizmoEnabled(value: boolean);
  52831. get scaleGizmoEnabled(): boolean;
  52832. /**
  52833. * If the boundingBox gizmo is enabled
  52834. */
  52835. set boundingBoxGizmoEnabled(value: boolean);
  52836. get boundingBoxGizmoEnabled(): boolean;
  52837. /**
  52838. * Disposes of the gizmo manager
  52839. */
  52840. dispose(): void;
  52841. }
  52842. }
  52843. declare module BABYLON {
  52844. /**
  52845. * A directional light is defined by a direction (what a surprise!).
  52846. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52847. * 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.
  52848. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52849. */
  52850. export class DirectionalLight extends ShadowLight {
  52851. private _shadowFrustumSize;
  52852. /**
  52853. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52854. */
  52855. get shadowFrustumSize(): number;
  52856. /**
  52857. * Specifies a fix frustum size for the shadow generation.
  52858. */
  52859. set shadowFrustumSize(value: number);
  52860. private _shadowOrthoScale;
  52861. /**
  52862. * Gets the shadow projection scale against the optimal computed one.
  52863. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52864. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52865. */
  52866. get shadowOrthoScale(): number;
  52867. /**
  52868. * Sets 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. set shadowOrthoScale(value: number);
  52873. /**
  52874. * Automatically compute the projection matrix to best fit (including all the casters)
  52875. * on each frame.
  52876. */
  52877. autoUpdateExtends: boolean;
  52878. /**
  52879. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52880. * on each frame. autoUpdateExtends must be set to true for this to work
  52881. */
  52882. autoCalcShadowZBounds: boolean;
  52883. private _orthoLeft;
  52884. private _orthoRight;
  52885. private _orthoTop;
  52886. private _orthoBottom;
  52887. /**
  52888. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52889. * The directional light is emitted from everywhere in the given direction.
  52890. * It can cast shadows.
  52891. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52892. * @param name The friendly name of the light
  52893. * @param direction The direction of the light
  52894. * @param scene The scene the light belongs to
  52895. */
  52896. constructor(name: string, direction: Vector3, scene: Scene);
  52897. /**
  52898. * Returns the string "DirectionalLight".
  52899. * @return The class name
  52900. */
  52901. getClassName(): string;
  52902. /**
  52903. * Returns the integer 1.
  52904. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52905. */
  52906. getTypeID(): number;
  52907. /**
  52908. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52909. * Returns the DirectionalLight Shadow projection matrix.
  52910. */
  52911. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52912. /**
  52913. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52914. * Returns the DirectionalLight Shadow projection matrix.
  52915. */
  52916. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52917. /**
  52918. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52919. * Returns the DirectionalLight Shadow projection matrix.
  52920. */
  52921. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52922. protected _buildUniformLayout(): void;
  52923. /**
  52924. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52925. * @param effect The effect to update
  52926. * @param lightIndex The index of the light in the effect to update
  52927. * @returns The directional light
  52928. */
  52929. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52930. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52931. /**
  52932. * Gets the minZ used for shadow according to both the scene and the light.
  52933. *
  52934. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52935. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52936. * @param activeCamera The camera we are returning the min for
  52937. * @returns the depth min z
  52938. */
  52939. getDepthMinZ(activeCamera: Camera): number;
  52940. /**
  52941. * Gets the maxZ used for shadow according to both the scene and the light.
  52942. *
  52943. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52944. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52945. * @param activeCamera The camera we are returning the max for
  52946. * @returns the depth max z
  52947. */
  52948. getDepthMaxZ(activeCamera: Camera): number;
  52949. /**
  52950. * Prepares the list of defines specific to the light type.
  52951. * @param defines the list of defines
  52952. * @param lightIndex defines the index of the light for the effect
  52953. */
  52954. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52955. }
  52956. }
  52957. declare module BABYLON {
  52958. /**
  52959. * Class containing static functions to help procedurally build meshes
  52960. */
  52961. export class HemisphereBuilder {
  52962. /**
  52963. * Creates a hemisphere mesh
  52964. * @param name defines the name of the mesh
  52965. * @param options defines the options used to create the mesh
  52966. * @param scene defines the hosting scene
  52967. * @returns the hemisphere mesh
  52968. */
  52969. static CreateHemisphere(name: string, options: {
  52970. segments?: number;
  52971. diameter?: number;
  52972. sideOrientation?: number;
  52973. }, scene: any): Mesh;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /**
  52978. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52979. * These values define a cone of light starting from the position, emitting toward the direction.
  52980. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52981. * and the exponent defines the speed of the decay of the light with distance (reach).
  52982. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52983. */
  52984. export class SpotLight extends ShadowLight {
  52985. private _angle;
  52986. private _innerAngle;
  52987. private _cosHalfAngle;
  52988. private _lightAngleScale;
  52989. private _lightAngleOffset;
  52990. /**
  52991. * Gets the cone angle of the spot light in Radians.
  52992. */
  52993. get angle(): number;
  52994. /**
  52995. * Sets the cone angle of the spot light in Radians.
  52996. */
  52997. set angle(value: number);
  52998. /**
  52999. * Only used in gltf falloff mode, this defines the angle where
  53000. * the directional falloff will start before cutting at angle which could be seen
  53001. * as outer angle.
  53002. */
  53003. get innerAngle(): 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. set innerAngle(value: number);
  53010. private _shadowAngleScale;
  53011. /**
  53012. * Allows scaling the angle of the light for shadow generation only.
  53013. */
  53014. get shadowAngleScale(): number;
  53015. /**
  53016. * Allows scaling the angle of the light for shadow generation only.
  53017. */
  53018. set shadowAngleScale(value: number);
  53019. /**
  53020. * The light decay speed with the distance from the emission spot.
  53021. */
  53022. exponent: number;
  53023. private _projectionTextureMatrix;
  53024. /**
  53025. * Allows reading the projecton texture
  53026. */
  53027. get projectionTextureMatrix(): Matrix;
  53028. protected _projectionTextureLightNear: number;
  53029. /**
  53030. * Gets the near clip of the Spotlight for texture projection.
  53031. */
  53032. get projectionTextureLightNear(): number;
  53033. /**
  53034. * Sets the near clip of the Spotlight for texture projection.
  53035. */
  53036. set projectionTextureLightNear(value: number);
  53037. protected _projectionTextureLightFar: number;
  53038. /**
  53039. * Gets the far clip of the Spotlight for texture projection.
  53040. */
  53041. get projectionTextureLightFar(): number;
  53042. /**
  53043. * Sets the far clip of the Spotlight for texture projection.
  53044. */
  53045. set projectionTextureLightFar(value: number);
  53046. protected _projectionTextureUpDirection: Vector3;
  53047. /**
  53048. * Gets the Up vector of the Spotlight for texture projection.
  53049. */
  53050. get projectionTextureUpDirection(): Vector3;
  53051. /**
  53052. * Sets the Up vector of the Spotlight for texture projection.
  53053. */
  53054. set projectionTextureUpDirection(value: Vector3);
  53055. private _projectionTexture;
  53056. /**
  53057. * Gets the projection texture of the light.
  53058. */
  53059. get projectionTexture(): Nullable<BaseTexture>;
  53060. /**
  53061. * Sets the projection texture of the light.
  53062. */
  53063. set projectionTexture(value: Nullable<BaseTexture>);
  53064. private _projectionTextureViewLightDirty;
  53065. private _projectionTextureProjectionLightDirty;
  53066. private _projectionTextureDirty;
  53067. private _projectionTextureViewTargetVector;
  53068. private _projectionTextureViewLightMatrix;
  53069. private _projectionTextureProjectionLightMatrix;
  53070. private _projectionTextureScalingMatrix;
  53071. /**
  53072. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53073. * It can cast shadows.
  53074. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53075. * @param name The light friendly name
  53076. * @param position The position of the spot light in the scene
  53077. * @param direction The direction of the light in the scene
  53078. * @param angle The cone angle of the light in Radians
  53079. * @param exponent The light decay speed with the distance from the emission spot
  53080. * @param scene The scene the lights belongs to
  53081. */
  53082. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53083. /**
  53084. * Returns the string "SpotLight".
  53085. * @returns the class name
  53086. */
  53087. getClassName(): string;
  53088. /**
  53089. * Returns the integer 2.
  53090. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53091. */
  53092. getTypeID(): number;
  53093. /**
  53094. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53095. */
  53096. protected _setDirection(value: Vector3): void;
  53097. /**
  53098. * Overrides the position setter to recompute the projection texture view light Matrix.
  53099. */
  53100. protected _setPosition(value: Vector3): void;
  53101. /**
  53102. * 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.
  53103. * Returns the SpotLight.
  53104. */
  53105. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53106. protected _computeProjectionTextureViewLightMatrix(): void;
  53107. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53108. /**
  53109. * Main function for light texture projection matrix computing.
  53110. */
  53111. protected _computeProjectionTextureMatrix(): void;
  53112. protected _buildUniformLayout(): void;
  53113. private _computeAngleValues;
  53114. /**
  53115. * Sets the passed Effect "effect" with the Light textures.
  53116. * @param effect The effect to update
  53117. * @param lightIndex The index of the light in the effect to update
  53118. * @returns The light
  53119. */
  53120. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53121. /**
  53122. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53123. * @param effect The effect to update
  53124. * @param lightIndex The index of the light in the effect to update
  53125. * @returns The spot light
  53126. */
  53127. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53128. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53129. /**
  53130. * Disposes the light and the associated resources.
  53131. */
  53132. dispose(): void;
  53133. /**
  53134. * Prepares the list of defines specific to the light type.
  53135. * @param defines the list of defines
  53136. * @param lightIndex defines the index of the light for the effect
  53137. */
  53138. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53139. }
  53140. }
  53141. declare module BABYLON {
  53142. /**
  53143. * Gizmo that enables viewing a light
  53144. */
  53145. export class LightGizmo extends Gizmo {
  53146. private _lightMesh;
  53147. private _material;
  53148. private _cachedPosition;
  53149. private _cachedForward;
  53150. private _attachedMeshParent;
  53151. /**
  53152. * Creates a LightGizmo
  53153. * @param gizmoLayer The utility layer the gizmo will be added to
  53154. */
  53155. constructor(gizmoLayer?: UtilityLayerRenderer);
  53156. private _light;
  53157. /**
  53158. * The light that the gizmo is attached to
  53159. */
  53160. set light(light: Nullable<Light>);
  53161. get light(): Nullable<Light>;
  53162. /**
  53163. * Gets the material used to render the light gizmo
  53164. */
  53165. get material(): StandardMaterial;
  53166. /**
  53167. * @hidden
  53168. * Updates the gizmo to match the attached mesh's position/rotation
  53169. */
  53170. protected _update(): void;
  53171. private static _Scale;
  53172. /**
  53173. * Creates the lines for a light mesh
  53174. */
  53175. private static _CreateLightLines;
  53176. /**
  53177. * Disposes of the light gizmo
  53178. */
  53179. dispose(): void;
  53180. private static _CreateHemisphericLightMesh;
  53181. private static _CreatePointLightMesh;
  53182. private static _CreateSpotLightMesh;
  53183. private static _CreateDirectionalLightMesh;
  53184. }
  53185. }
  53186. declare module BABYLON {
  53187. /** @hidden */
  53188. export var backgroundFragmentDeclaration: {
  53189. name: string;
  53190. shader: string;
  53191. };
  53192. }
  53193. declare module BABYLON {
  53194. /** @hidden */
  53195. export var backgroundUboDeclaration: {
  53196. name: string;
  53197. shader: string;
  53198. };
  53199. }
  53200. declare module BABYLON {
  53201. /** @hidden */
  53202. export var backgroundPixelShader: {
  53203. name: string;
  53204. shader: string;
  53205. };
  53206. }
  53207. declare module BABYLON {
  53208. /** @hidden */
  53209. export var backgroundVertexDeclaration: {
  53210. name: string;
  53211. shader: string;
  53212. };
  53213. }
  53214. declare module BABYLON {
  53215. /** @hidden */
  53216. export var backgroundVertexShader: {
  53217. name: string;
  53218. shader: string;
  53219. };
  53220. }
  53221. declare module BABYLON {
  53222. /**
  53223. * Background material used to create an efficient environement around your scene.
  53224. */
  53225. export class BackgroundMaterial extends PushMaterial {
  53226. /**
  53227. * Standard reflectance value at parallel view angle.
  53228. */
  53229. static StandardReflectance0: number;
  53230. /**
  53231. * Standard reflectance value at grazing angle.
  53232. */
  53233. static StandardReflectance90: number;
  53234. protected _primaryColor: Color3;
  53235. /**
  53236. * Key light Color (multiply against the environement texture)
  53237. */
  53238. primaryColor: Color3;
  53239. protected __perceptualColor: Nullable<Color3>;
  53240. /**
  53241. * Experimental Internal Use Only.
  53242. *
  53243. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53244. * This acts as a helper to set the primary color to a more "human friendly" value.
  53245. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53246. * output color as close as possible from the chosen value.
  53247. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53248. * part of lighting setup.)
  53249. */
  53250. get _perceptualColor(): Nullable<Color3>;
  53251. set _perceptualColor(value: Nullable<Color3>);
  53252. protected _primaryColorShadowLevel: float;
  53253. /**
  53254. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53255. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53256. */
  53257. get primaryColorShadowLevel(): float;
  53258. set primaryColorShadowLevel(value: float);
  53259. protected _primaryColorHighlightLevel: float;
  53260. /**
  53261. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53262. * The primary color is used at the level chosen to define what the white area would look.
  53263. */
  53264. get primaryColorHighlightLevel(): float;
  53265. set primaryColorHighlightLevel(value: float);
  53266. protected _reflectionTexture: Nullable<BaseTexture>;
  53267. /**
  53268. * Reflection Texture used in the material.
  53269. * Should be author in a specific way for the best result (refer to the documentation).
  53270. */
  53271. reflectionTexture: Nullable<BaseTexture>;
  53272. protected _reflectionBlur: float;
  53273. /**
  53274. * Reflection Texture level of blur.
  53275. *
  53276. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53277. * texture twice.
  53278. */
  53279. reflectionBlur: float;
  53280. protected _diffuseTexture: Nullable<BaseTexture>;
  53281. /**
  53282. * Diffuse Texture used in the material.
  53283. * Should be author in a specific way for the best result (refer to the documentation).
  53284. */
  53285. diffuseTexture: Nullable<BaseTexture>;
  53286. protected _shadowLights: Nullable<IShadowLight[]>;
  53287. /**
  53288. * Specify the list of lights casting shadow on the material.
  53289. * All scene shadow lights will be included if null.
  53290. */
  53291. shadowLights: Nullable<IShadowLight[]>;
  53292. protected _shadowLevel: float;
  53293. /**
  53294. * Helps adjusting the shadow to a softer level if required.
  53295. * 0 means black shadows and 1 means no shadows.
  53296. */
  53297. shadowLevel: float;
  53298. protected _sceneCenter: Vector3;
  53299. /**
  53300. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53301. * It is usually zero but might be interesting to modify according to your setup.
  53302. */
  53303. sceneCenter: Vector3;
  53304. protected _opacityFresnel: boolean;
  53305. /**
  53306. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53307. * This helps ensuring a nice transition when the camera goes under the ground.
  53308. */
  53309. opacityFresnel: boolean;
  53310. protected _reflectionFresnel: boolean;
  53311. /**
  53312. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53313. * This helps adding a mirror texture on the ground.
  53314. */
  53315. reflectionFresnel: boolean;
  53316. protected _reflectionFalloffDistance: number;
  53317. /**
  53318. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53319. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53320. */
  53321. reflectionFalloffDistance: number;
  53322. protected _reflectionAmount: number;
  53323. /**
  53324. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53325. */
  53326. reflectionAmount: number;
  53327. protected _reflectionReflectance0: number;
  53328. /**
  53329. * This specifies the weight of the reflection at grazing angle.
  53330. */
  53331. reflectionReflectance0: number;
  53332. protected _reflectionReflectance90: number;
  53333. /**
  53334. * This specifies the weight of the reflection at a perpendicular point of view.
  53335. */
  53336. reflectionReflectance90: number;
  53337. /**
  53338. * Sets the reflection reflectance fresnel values according to the default standard
  53339. * empirically know to work well :-)
  53340. */
  53341. set reflectionStandardFresnelWeight(value: number);
  53342. protected _useRGBColor: boolean;
  53343. /**
  53344. * Helps to directly use the maps channels instead of their level.
  53345. */
  53346. useRGBColor: boolean;
  53347. protected _enableNoise: boolean;
  53348. /**
  53349. * This helps reducing the banding effect that could occur on the background.
  53350. */
  53351. enableNoise: boolean;
  53352. /**
  53353. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53354. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53355. * Recommended to be keep at 1.0 except for special cases.
  53356. */
  53357. get fovMultiplier(): number;
  53358. set fovMultiplier(value: number);
  53359. private _fovMultiplier;
  53360. /**
  53361. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53362. */
  53363. useEquirectangularFOV: boolean;
  53364. private _maxSimultaneousLights;
  53365. /**
  53366. * Number of Simultaneous lights allowed on the material.
  53367. */
  53368. maxSimultaneousLights: int;
  53369. private _shadowOnly;
  53370. /**
  53371. * Make the material only render shadows
  53372. */
  53373. shadowOnly: boolean;
  53374. /**
  53375. * Default configuration related to image processing available in the Background Material.
  53376. */
  53377. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53378. /**
  53379. * Keep track of the image processing observer to allow dispose and replace.
  53380. */
  53381. private _imageProcessingObserver;
  53382. /**
  53383. * Attaches a new image processing configuration to the PBR Material.
  53384. * @param configuration (if null the scene configuration will be use)
  53385. */
  53386. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53387. /**
  53388. * Gets the image processing configuration used either in this material.
  53389. */
  53390. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53391. /**
  53392. * Sets the Default image processing configuration used either in the this material.
  53393. *
  53394. * If sets to null, the scene one is in use.
  53395. */
  53396. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53397. /**
  53398. * Gets wether the color curves effect is enabled.
  53399. */
  53400. get cameraColorCurvesEnabled(): boolean;
  53401. /**
  53402. * Sets wether the color curves effect is enabled.
  53403. */
  53404. set cameraColorCurvesEnabled(value: boolean);
  53405. /**
  53406. * Gets wether the color grading effect is enabled.
  53407. */
  53408. get cameraColorGradingEnabled(): boolean;
  53409. /**
  53410. * Gets wether the color grading effect is enabled.
  53411. */
  53412. set cameraColorGradingEnabled(value: boolean);
  53413. /**
  53414. * Gets wether tonemapping is enabled or not.
  53415. */
  53416. get cameraToneMappingEnabled(): boolean;
  53417. /**
  53418. * Sets wether tonemapping is enabled or not
  53419. */
  53420. set cameraToneMappingEnabled(value: boolean);
  53421. /**
  53422. * The camera exposure used on this material.
  53423. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53424. * This corresponds to a photographic exposure.
  53425. */
  53426. get cameraExposure(): float;
  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. set cameraExposure(value: float);
  53433. /**
  53434. * Gets The camera contrast used on this material.
  53435. */
  53436. get cameraContrast(): float;
  53437. /**
  53438. * Sets The camera contrast used on this material.
  53439. */
  53440. set cameraContrast(value: float);
  53441. /**
  53442. * Gets the Color Grading 2D Lookup Texture.
  53443. */
  53444. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53445. /**
  53446. * Sets the Color Grading 2D Lookup Texture.
  53447. */
  53448. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53449. /**
  53450. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53451. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53452. * 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;
  53453. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53454. */
  53455. get cameraColorCurves(): Nullable<ColorCurves>;
  53456. /**
  53457. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53458. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53459. * 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;
  53460. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53461. */
  53462. set cameraColorCurves(value: Nullable<ColorCurves>);
  53463. /**
  53464. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53465. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53466. */
  53467. switchToBGR: boolean;
  53468. private _renderTargets;
  53469. private _reflectionControls;
  53470. private _white;
  53471. private _primaryShadowColor;
  53472. private _primaryHighlightColor;
  53473. /**
  53474. * Instantiates a Background Material in the given scene
  53475. * @param name The friendly name of the material
  53476. * @param scene The scene to add the material to
  53477. */
  53478. constructor(name: string, scene: Scene);
  53479. /**
  53480. * Gets a boolean indicating that current material needs to register RTT
  53481. */
  53482. get hasRenderTargetTextures(): boolean;
  53483. /**
  53484. * The entire material has been created in order to prevent overdraw.
  53485. * @returns false
  53486. */
  53487. needAlphaTesting(): boolean;
  53488. /**
  53489. * The entire material has been created in order to prevent overdraw.
  53490. * @returns true if blending is enable
  53491. */
  53492. needAlphaBlending(): boolean;
  53493. /**
  53494. * Checks wether the material is ready to be rendered for a given mesh.
  53495. * @param mesh The mesh to render
  53496. * @param subMesh The submesh to check against
  53497. * @param useInstances Specify wether or not the material is used with instances
  53498. * @returns true if all the dependencies are ready (Textures, Effects...)
  53499. */
  53500. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53501. /**
  53502. * Compute the primary color according to the chosen perceptual color.
  53503. */
  53504. private _computePrimaryColorFromPerceptualColor;
  53505. /**
  53506. * Compute the highlights and shadow colors according to their chosen levels.
  53507. */
  53508. private _computePrimaryColors;
  53509. /**
  53510. * Build the uniform buffer used in the material.
  53511. */
  53512. buildUniformLayout(): void;
  53513. /**
  53514. * Unbind the material.
  53515. */
  53516. unbind(): void;
  53517. /**
  53518. * Bind only the world matrix to the material.
  53519. * @param world The world matrix to bind.
  53520. */
  53521. bindOnlyWorldMatrix(world: Matrix): void;
  53522. /**
  53523. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53524. * @param world The world matrix to bind.
  53525. * @param subMesh The submesh to bind for.
  53526. */
  53527. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53528. /**
  53529. * Checks to see if a texture is used in the material.
  53530. * @param texture - Base texture to use.
  53531. * @returns - Boolean specifying if a texture is used in the material.
  53532. */
  53533. hasTexture(texture: BaseTexture): boolean;
  53534. /**
  53535. * Dispose the material.
  53536. * @param forceDisposeEffect Force disposal of the associated effect.
  53537. * @param forceDisposeTextures Force disposal of the associated textures.
  53538. */
  53539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53540. /**
  53541. * Clones the material.
  53542. * @param name The cloned name.
  53543. * @returns The cloned material.
  53544. */
  53545. clone(name: string): BackgroundMaterial;
  53546. /**
  53547. * Serializes the current material to its JSON representation.
  53548. * @returns The JSON representation.
  53549. */
  53550. serialize(): any;
  53551. /**
  53552. * Gets the class name of the material
  53553. * @returns "BackgroundMaterial"
  53554. */
  53555. getClassName(): string;
  53556. /**
  53557. * Parse a JSON input to create back a background material.
  53558. * @param source The JSON data to parse
  53559. * @param scene The scene to create the parsed material in
  53560. * @param rootUrl The root url of the assets the material depends upon
  53561. * @returns the instantiated BackgroundMaterial.
  53562. */
  53563. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53564. }
  53565. }
  53566. declare module BABYLON {
  53567. /**
  53568. * Represents the different options available during the creation of
  53569. * a Environment helper.
  53570. *
  53571. * This can control the default ground, skybox and image processing setup of your scene.
  53572. */
  53573. export interface IEnvironmentHelperOptions {
  53574. /**
  53575. * Specifies whether or not to create a ground.
  53576. * True by default.
  53577. */
  53578. createGround: boolean;
  53579. /**
  53580. * Specifies the ground size.
  53581. * 15 by default.
  53582. */
  53583. groundSize: number;
  53584. /**
  53585. * The texture used on the ground for the main color.
  53586. * Comes from the BabylonJS CDN by default.
  53587. *
  53588. * Remarks: Can be either a texture or a url.
  53589. */
  53590. groundTexture: string | BaseTexture;
  53591. /**
  53592. * The color mixed in the ground texture by default.
  53593. * BabylonJS clearColor by default.
  53594. */
  53595. groundColor: Color3;
  53596. /**
  53597. * Specifies the ground opacity.
  53598. * 1 by default.
  53599. */
  53600. groundOpacity: number;
  53601. /**
  53602. * Enables the ground to receive shadows.
  53603. * True by default.
  53604. */
  53605. enableGroundShadow: boolean;
  53606. /**
  53607. * Helps preventing the shadow to be fully black on the ground.
  53608. * 0.5 by default.
  53609. */
  53610. groundShadowLevel: number;
  53611. /**
  53612. * Creates a mirror texture attach to the ground.
  53613. * false by default.
  53614. */
  53615. enableGroundMirror: boolean;
  53616. /**
  53617. * Specifies the ground mirror size ratio.
  53618. * 0.3 by default as the default kernel is 64.
  53619. */
  53620. groundMirrorSizeRatio: number;
  53621. /**
  53622. * Specifies the ground mirror blur kernel size.
  53623. * 64 by default.
  53624. */
  53625. groundMirrorBlurKernel: number;
  53626. /**
  53627. * Specifies the ground mirror visibility amount.
  53628. * 1 by default
  53629. */
  53630. groundMirrorAmount: number;
  53631. /**
  53632. * Specifies the ground mirror reflectance weight.
  53633. * This uses the standard weight of the background material to setup the fresnel effect
  53634. * of the mirror.
  53635. * 1 by default.
  53636. */
  53637. groundMirrorFresnelWeight: number;
  53638. /**
  53639. * Specifies the ground mirror Falloff distance.
  53640. * This can helps reducing the size of the reflection.
  53641. * 0 by Default.
  53642. */
  53643. groundMirrorFallOffDistance: number;
  53644. /**
  53645. * Specifies the ground mirror texture type.
  53646. * Unsigned Int by Default.
  53647. */
  53648. groundMirrorTextureType: number;
  53649. /**
  53650. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53651. * the shown objects.
  53652. */
  53653. groundYBias: number;
  53654. /**
  53655. * Specifies whether or not to create a skybox.
  53656. * True by default.
  53657. */
  53658. createSkybox: boolean;
  53659. /**
  53660. * Specifies the skybox size.
  53661. * 20 by default.
  53662. */
  53663. skyboxSize: number;
  53664. /**
  53665. * The texture used on the skybox for the main color.
  53666. * Comes from the BabylonJS CDN by default.
  53667. *
  53668. * Remarks: Can be either a texture or a url.
  53669. */
  53670. skyboxTexture: string | BaseTexture;
  53671. /**
  53672. * The color mixed in the skybox texture by default.
  53673. * BabylonJS clearColor by default.
  53674. */
  53675. skyboxColor: Color3;
  53676. /**
  53677. * The background rotation around the Y axis of the scene.
  53678. * This helps aligning the key lights of your scene with the background.
  53679. * 0 by default.
  53680. */
  53681. backgroundYRotation: number;
  53682. /**
  53683. * Compute automatically the size of the elements to best fit with the scene.
  53684. */
  53685. sizeAuto: boolean;
  53686. /**
  53687. * Default position of the rootMesh if autoSize is not true.
  53688. */
  53689. rootPosition: Vector3;
  53690. /**
  53691. * Sets up the image processing in the scene.
  53692. * true by default.
  53693. */
  53694. setupImageProcessing: boolean;
  53695. /**
  53696. * The texture used as your environment texture in the scene.
  53697. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53698. *
  53699. * Remarks: Can be either a texture or a url.
  53700. */
  53701. environmentTexture: string | BaseTexture;
  53702. /**
  53703. * The value of the exposure to apply to the scene.
  53704. * 0.6 by default if setupImageProcessing is true.
  53705. */
  53706. cameraExposure: number;
  53707. /**
  53708. * The value of the contrast to apply to the scene.
  53709. * 1.6 by default if setupImageProcessing is true.
  53710. */
  53711. cameraContrast: number;
  53712. /**
  53713. * Specifies whether or not tonemapping should be enabled in the scene.
  53714. * true by default if setupImageProcessing is true.
  53715. */
  53716. toneMappingEnabled: boolean;
  53717. }
  53718. /**
  53719. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53720. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53721. * It also helps with the default setup of your imageProcessing configuration.
  53722. */
  53723. export class EnvironmentHelper {
  53724. /**
  53725. * Default ground texture URL.
  53726. */
  53727. private static _groundTextureCDNUrl;
  53728. /**
  53729. * Default skybox texture URL.
  53730. */
  53731. private static _skyboxTextureCDNUrl;
  53732. /**
  53733. * Default environment texture URL.
  53734. */
  53735. private static _environmentTextureCDNUrl;
  53736. /**
  53737. * Creates the default options for the helper.
  53738. */
  53739. private static _getDefaultOptions;
  53740. private _rootMesh;
  53741. /**
  53742. * Gets the root mesh created by the helper.
  53743. */
  53744. get rootMesh(): Mesh;
  53745. private _skybox;
  53746. /**
  53747. * Gets the skybox created by the helper.
  53748. */
  53749. get skybox(): Nullable<Mesh>;
  53750. private _skyboxTexture;
  53751. /**
  53752. * Gets the skybox texture created by the helper.
  53753. */
  53754. get skyboxTexture(): Nullable<BaseTexture>;
  53755. private _skyboxMaterial;
  53756. /**
  53757. * Gets the skybox material created by the helper.
  53758. */
  53759. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53760. private _ground;
  53761. /**
  53762. * Gets the ground mesh created by the helper.
  53763. */
  53764. get ground(): Nullable<Mesh>;
  53765. private _groundTexture;
  53766. /**
  53767. * Gets the ground texture created by the helper.
  53768. */
  53769. get groundTexture(): Nullable<BaseTexture>;
  53770. private _groundMirror;
  53771. /**
  53772. * Gets the ground mirror created by the helper.
  53773. */
  53774. get groundMirror(): Nullable<MirrorTexture>;
  53775. /**
  53776. * Gets the ground mirror render list to helps pushing the meshes
  53777. * you wish in the ground reflection.
  53778. */
  53779. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53780. private _groundMaterial;
  53781. /**
  53782. * Gets the ground material created by the helper.
  53783. */
  53784. get groundMaterial(): Nullable<BackgroundMaterial>;
  53785. /**
  53786. * Stores the creation options.
  53787. */
  53788. private readonly _scene;
  53789. private _options;
  53790. /**
  53791. * This observable will be notified with any error during the creation of the environment,
  53792. * mainly texture creation errors.
  53793. */
  53794. onErrorObservable: Observable<{
  53795. message?: string;
  53796. exception?: any;
  53797. }>;
  53798. /**
  53799. * constructor
  53800. * @param options Defines the options we want to customize the helper
  53801. * @param scene The scene to add the material to
  53802. */
  53803. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53804. /**
  53805. * Updates the background according to the new options
  53806. * @param options
  53807. */
  53808. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53809. /**
  53810. * Sets the primary color of all the available elements.
  53811. * @param color the main color to affect to the ground and the background
  53812. */
  53813. setMainColor(color: Color3): void;
  53814. /**
  53815. * Setup the image processing according to the specified options.
  53816. */
  53817. private _setupImageProcessing;
  53818. /**
  53819. * Setup the environment texture according to the specified options.
  53820. */
  53821. private _setupEnvironmentTexture;
  53822. /**
  53823. * Setup the background according to the specified options.
  53824. */
  53825. private _setupBackground;
  53826. /**
  53827. * Get the scene sizes according to the setup.
  53828. */
  53829. private _getSceneSize;
  53830. /**
  53831. * Setup the ground according to the specified options.
  53832. */
  53833. private _setupGround;
  53834. /**
  53835. * Setup the ground material according to the specified options.
  53836. */
  53837. private _setupGroundMaterial;
  53838. /**
  53839. * Setup the ground diffuse texture according to the specified options.
  53840. */
  53841. private _setupGroundDiffuseTexture;
  53842. /**
  53843. * Setup the ground mirror texture according to the specified options.
  53844. */
  53845. private _setupGroundMirrorTexture;
  53846. /**
  53847. * Setup the ground to receive the mirror texture.
  53848. */
  53849. private _setupMirrorInGroundMaterial;
  53850. /**
  53851. * Setup the skybox according to the specified options.
  53852. */
  53853. private _setupSkybox;
  53854. /**
  53855. * Setup the skybox material according to the specified options.
  53856. */
  53857. private _setupSkyboxMaterial;
  53858. /**
  53859. * Setup the skybox reflection texture according to the specified options.
  53860. */
  53861. private _setupSkyboxReflectionTexture;
  53862. private _errorHandler;
  53863. /**
  53864. * Dispose all the elements created by the Helper.
  53865. */
  53866. dispose(): void;
  53867. }
  53868. }
  53869. declare module BABYLON {
  53870. /**
  53871. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53872. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53873. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53874. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53875. */
  53876. export class PhotoDome extends TransformNode {
  53877. /**
  53878. * Define the image as a Monoscopic panoramic 360 image.
  53879. */
  53880. static readonly MODE_MONOSCOPIC: number;
  53881. /**
  53882. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53883. */
  53884. static readonly MODE_TOPBOTTOM: number;
  53885. /**
  53886. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53887. */
  53888. static readonly MODE_SIDEBYSIDE: number;
  53889. private _useDirectMapping;
  53890. /**
  53891. * The texture being displayed on the sphere
  53892. */
  53893. protected _photoTexture: Texture;
  53894. /**
  53895. * Gets or sets the texture being displayed on the sphere
  53896. */
  53897. get photoTexture(): Texture;
  53898. set photoTexture(value: Texture);
  53899. /**
  53900. * Observable raised when an error occured while loading the 360 image
  53901. */
  53902. onLoadErrorObservable: Observable<string>;
  53903. /**
  53904. * The skybox material
  53905. */
  53906. protected _material: BackgroundMaterial;
  53907. /**
  53908. * The surface used for the skybox
  53909. */
  53910. protected _mesh: Mesh;
  53911. /**
  53912. * Gets the mesh used for the skybox.
  53913. */
  53914. get mesh(): Mesh;
  53915. /**
  53916. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53917. * Also see the options.resolution property.
  53918. */
  53919. get fovMultiplier(): number;
  53920. set fovMultiplier(value: number);
  53921. private _imageMode;
  53922. /**
  53923. * Gets or set the current video mode for the video. It can be:
  53924. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53925. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53926. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53927. */
  53928. get imageMode(): number;
  53929. set imageMode(value: number);
  53930. /**
  53931. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53932. * @param name Element's name, child elements will append suffixes for their own names.
  53933. * @param urlsOfPhoto defines the url of the photo to display
  53934. * @param options defines an object containing optional or exposed sub element properties
  53935. * @param onError defines a callback called when an error occured while loading the texture
  53936. */
  53937. constructor(name: string, urlOfPhoto: string, options: {
  53938. resolution?: number;
  53939. size?: number;
  53940. useDirectMapping?: boolean;
  53941. faceForward?: boolean;
  53942. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53943. private _onBeforeCameraRenderObserver;
  53944. private _changeImageMode;
  53945. /**
  53946. * Releases resources associated with this node.
  53947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53949. */
  53950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53951. }
  53952. }
  53953. declare module BABYLON {
  53954. /**
  53955. * Class used to host RGBD texture specific utilities
  53956. */
  53957. export class RGBDTextureTools {
  53958. /**
  53959. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53960. * @param texture the texture to expand.
  53961. */
  53962. static ExpandRGBDTexture(texture: Texture): void;
  53963. }
  53964. }
  53965. declare module BABYLON {
  53966. /**
  53967. * Class used to host texture specific utilities
  53968. */
  53969. export class BRDFTextureTools {
  53970. /**
  53971. * Prevents texture cache collision
  53972. */
  53973. private static _instanceNumber;
  53974. /**
  53975. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53976. * @param scene defines the hosting scene
  53977. * @returns the environment BRDF texture
  53978. */
  53979. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53980. private static _environmentBRDFBase64Texture;
  53981. }
  53982. }
  53983. declare module BABYLON {
  53984. /**
  53985. * @hidden
  53986. */
  53987. export interface IMaterialClearCoatDefines {
  53988. CLEARCOAT: boolean;
  53989. CLEARCOAT_DEFAULTIOR: boolean;
  53990. CLEARCOAT_TEXTURE: boolean;
  53991. CLEARCOAT_TEXTUREDIRECTUV: number;
  53992. CLEARCOAT_BUMP: boolean;
  53993. CLEARCOAT_BUMPDIRECTUV: number;
  53994. CLEARCOAT_TINT: boolean;
  53995. CLEARCOAT_TINT_TEXTURE: boolean;
  53996. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53997. /** @hidden */
  53998. _areTexturesDirty: boolean;
  53999. }
  54000. /**
  54001. * Define the code related to the clear coat parameters of the pbr material.
  54002. */
  54003. export class PBRClearCoatConfiguration {
  54004. /**
  54005. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54006. * The default fits with a polyurethane material.
  54007. */
  54008. private static readonly _DefaultIndexOfRefraction;
  54009. private _isEnabled;
  54010. /**
  54011. * Defines if the clear coat is enabled in the material.
  54012. */
  54013. isEnabled: boolean;
  54014. /**
  54015. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54016. */
  54017. intensity: number;
  54018. /**
  54019. * Defines the clear coat layer roughness.
  54020. */
  54021. roughness: number;
  54022. private _indexOfRefraction;
  54023. /**
  54024. * Defines the index of refraction of the clear coat.
  54025. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54026. * The default fits with a polyurethane material.
  54027. * Changing the default value is more performance intensive.
  54028. */
  54029. indexOfRefraction: number;
  54030. private _texture;
  54031. /**
  54032. * Stores the clear coat values in a texture.
  54033. */
  54034. texture: Nullable<BaseTexture>;
  54035. private _bumpTexture;
  54036. /**
  54037. * Define the clear coat specific bump texture.
  54038. */
  54039. bumpTexture: Nullable<BaseTexture>;
  54040. private _isTintEnabled;
  54041. /**
  54042. * Defines if the clear coat tint is enabled in the material.
  54043. */
  54044. isTintEnabled: boolean;
  54045. /**
  54046. * Defines the clear coat tint of the material.
  54047. * This is only use if tint is enabled
  54048. */
  54049. tintColor: Color3;
  54050. /**
  54051. * Defines the distance at which the tint color should be found in the
  54052. * clear coat media.
  54053. * This is only use if tint is enabled
  54054. */
  54055. tintColorAtDistance: number;
  54056. /**
  54057. * Defines the clear coat layer thickness.
  54058. * This is only use if tint is enabled
  54059. */
  54060. tintThickness: number;
  54061. private _tintTexture;
  54062. /**
  54063. * Stores the clear tint values in a texture.
  54064. * rgb is tint
  54065. * a is a thickness factor
  54066. */
  54067. tintTexture: Nullable<BaseTexture>;
  54068. /** @hidden */
  54069. private _internalMarkAllSubMeshesAsTexturesDirty;
  54070. /** @hidden */
  54071. _markAllSubMeshesAsTexturesDirty(): void;
  54072. /**
  54073. * Instantiate a new istance of clear coat configuration.
  54074. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54075. */
  54076. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54077. /**
  54078. * Gets wehter the submesh is ready to be used or not.
  54079. * @param defines the list of "defines" to update.
  54080. * @param scene defines the scene the material belongs to.
  54081. * @param engine defines the engine the material belongs to.
  54082. * @param disableBumpMap defines wether the material disables bump or not.
  54083. * @returns - boolean indicating that the submesh is ready or not.
  54084. */
  54085. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54086. /**
  54087. * Checks to see if a texture is used in the material.
  54088. * @param defines the list of "defines" to update.
  54089. * @param scene defines the scene to the material belongs to.
  54090. */
  54091. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54092. /**
  54093. * Binds the material data.
  54094. * @param uniformBuffer defines the Uniform buffer to fill in.
  54095. * @param scene defines the scene the material belongs to.
  54096. * @param engine defines the engine the material belongs to.
  54097. * @param disableBumpMap defines wether the material disables bump or not.
  54098. * @param isFrozen defines wether the material is frozen or not.
  54099. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54100. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54101. */
  54102. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54103. /**
  54104. * Checks to see if a texture is used in the material.
  54105. * @param texture - Base texture to use.
  54106. * @returns - Boolean specifying if a texture is used in the material.
  54107. */
  54108. hasTexture(texture: BaseTexture): boolean;
  54109. /**
  54110. * Returns an array of the actively used textures.
  54111. * @param activeTextures Array of BaseTextures
  54112. */
  54113. getActiveTextures(activeTextures: BaseTexture[]): void;
  54114. /**
  54115. * Returns the animatable textures.
  54116. * @param animatables Array of animatable textures.
  54117. */
  54118. getAnimatables(animatables: IAnimatable[]): void;
  54119. /**
  54120. * Disposes the resources of the material.
  54121. * @param forceDisposeTextures - Forces the disposal of all textures.
  54122. */
  54123. dispose(forceDisposeTextures?: boolean): void;
  54124. /**
  54125. * Get the current class name of the texture useful for serialization or dynamic coding.
  54126. * @returns "PBRClearCoatConfiguration"
  54127. */
  54128. getClassName(): string;
  54129. /**
  54130. * Add fallbacks to the effect fallbacks list.
  54131. * @param defines defines the Base texture to use.
  54132. * @param fallbacks defines the current fallback list.
  54133. * @param currentRank defines the current fallback rank.
  54134. * @returns the new fallback rank.
  54135. */
  54136. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54137. /**
  54138. * Add the required uniforms to the current list.
  54139. * @param uniforms defines the current uniform list.
  54140. */
  54141. static AddUniforms(uniforms: string[]): void;
  54142. /**
  54143. * Add the required samplers to the current list.
  54144. * @param samplers defines the current sampler list.
  54145. */
  54146. static AddSamplers(samplers: string[]): void;
  54147. /**
  54148. * Add the required uniforms to the current buffer.
  54149. * @param uniformBuffer defines the current uniform buffer.
  54150. */
  54151. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54152. /**
  54153. * Makes a duplicate of the current configuration into another one.
  54154. * @param clearCoatConfiguration define the config where to copy the info
  54155. */
  54156. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54157. /**
  54158. * Serializes this clear coat configuration.
  54159. * @returns - An object with the serialized config.
  54160. */
  54161. serialize(): any;
  54162. /**
  54163. * Parses a anisotropy Configuration from a serialized object.
  54164. * @param source - Serialized object.
  54165. * @param scene Defines the scene we are parsing for
  54166. * @param rootUrl Defines the rootUrl to load from
  54167. */
  54168. parse(source: any, scene: Scene, rootUrl: string): void;
  54169. }
  54170. }
  54171. declare module BABYLON {
  54172. /**
  54173. * @hidden
  54174. */
  54175. export interface IMaterialAnisotropicDefines {
  54176. ANISOTROPIC: boolean;
  54177. ANISOTROPIC_TEXTURE: boolean;
  54178. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54179. MAINUV1: boolean;
  54180. _areTexturesDirty: boolean;
  54181. _needUVs: boolean;
  54182. }
  54183. /**
  54184. * Define the code related to the anisotropic parameters of the pbr material.
  54185. */
  54186. export class PBRAnisotropicConfiguration {
  54187. private _isEnabled;
  54188. /**
  54189. * Defines if the anisotropy is enabled in the material.
  54190. */
  54191. isEnabled: boolean;
  54192. /**
  54193. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54194. */
  54195. intensity: number;
  54196. /**
  54197. * Defines if the effect is along the tangents, bitangents or in between.
  54198. * By default, the effect is "strectching" the highlights along the tangents.
  54199. */
  54200. direction: Vector2;
  54201. private _texture;
  54202. /**
  54203. * Stores the anisotropy values in a texture.
  54204. * rg is direction (like normal from -1 to 1)
  54205. * b is a intensity
  54206. */
  54207. texture: Nullable<BaseTexture>;
  54208. /** @hidden */
  54209. private _internalMarkAllSubMeshesAsTexturesDirty;
  54210. /** @hidden */
  54211. _markAllSubMeshesAsTexturesDirty(): void;
  54212. /**
  54213. * Instantiate a new istance of anisotropy configuration.
  54214. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54215. */
  54216. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54217. /**
  54218. * Specifies that the submesh is ready to be used.
  54219. * @param defines the list of "defines" to update.
  54220. * @param scene defines the scene the material belongs to.
  54221. * @returns - boolean indicating that the submesh is ready or not.
  54222. */
  54223. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54224. /**
  54225. * Checks to see if a texture is used in the material.
  54226. * @param defines the list of "defines" to update.
  54227. * @param mesh the mesh we are preparing the defines for.
  54228. * @param scene defines the scene the material belongs to.
  54229. */
  54230. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54231. /**
  54232. * Binds the material data.
  54233. * @param uniformBuffer defines the Uniform buffer to fill in.
  54234. * @param scene defines the scene the material belongs to.
  54235. * @param isFrozen defines wether the material is frozen or not.
  54236. */
  54237. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54238. /**
  54239. * Checks to see if a texture is used in the material.
  54240. * @param texture - Base texture to use.
  54241. * @returns - Boolean specifying if a texture is used in the material.
  54242. */
  54243. hasTexture(texture: BaseTexture): boolean;
  54244. /**
  54245. * Returns an array of the actively used textures.
  54246. * @param activeTextures Array of BaseTextures
  54247. */
  54248. getActiveTextures(activeTextures: BaseTexture[]): void;
  54249. /**
  54250. * Returns the animatable textures.
  54251. * @param animatables Array of animatable textures.
  54252. */
  54253. getAnimatables(animatables: IAnimatable[]): void;
  54254. /**
  54255. * Disposes the resources of the material.
  54256. * @param forceDisposeTextures - Forces the disposal of all textures.
  54257. */
  54258. dispose(forceDisposeTextures?: boolean): void;
  54259. /**
  54260. * Get the current class name of the texture useful for serialization or dynamic coding.
  54261. * @returns "PBRAnisotropicConfiguration"
  54262. */
  54263. getClassName(): string;
  54264. /**
  54265. * Add fallbacks to the effect fallbacks list.
  54266. * @param defines defines the Base texture to use.
  54267. * @param fallbacks defines the current fallback list.
  54268. * @param currentRank defines the current fallback rank.
  54269. * @returns the new fallback rank.
  54270. */
  54271. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54272. /**
  54273. * Add the required uniforms to the current list.
  54274. * @param uniforms defines the current uniform list.
  54275. */
  54276. static AddUniforms(uniforms: string[]): void;
  54277. /**
  54278. * Add the required uniforms to the current buffer.
  54279. * @param uniformBuffer defines the current uniform buffer.
  54280. */
  54281. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54282. /**
  54283. * Add the required samplers to the current list.
  54284. * @param samplers defines the current sampler list.
  54285. */
  54286. static AddSamplers(samplers: string[]): void;
  54287. /**
  54288. * Makes a duplicate of the current configuration into another one.
  54289. * @param anisotropicConfiguration define the config where to copy the info
  54290. */
  54291. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54292. /**
  54293. * Serializes this anisotropy configuration.
  54294. * @returns - An object with the serialized config.
  54295. */
  54296. serialize(): any;
  54297. /**
  54298. * Parses a anisotropy Configuration from a serialized object.
  54299. * @param source - Serialized object.
  54300. * @param scene Defines the scene we are parsing for
  54301. * @param rootUrl Defines the rootUrl to load from
  54302. */
  54303. parse(source: any, scene: Scene, rootUrl: string): void;
  54304. }
  54305. }
  54306. declare module BABYLON {
  54307. /**
  54308. * @hidden
  54309. */
  54310. export interface IMaterialBRDFDefines {
  54311. BRDF_V_HEIGHT_CORRELATED: boolean;
  54312. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54313. SPHERICAL_HARMONICS: boolean;
  54314. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54315. /** @hidden */
  54316. _areMiscDirty: boolean;
  54317. }
  54318. /**
  54319. * Define the code related to the BRDF parameters of the pbr material.
  54320. */
  54321. export class PBRBRDFConfiguration {
  54322. /**
  54323. * Default value used for the energy conservation.
  54324. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54325. */
  54326. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54327. /**
  54328. * Default value used for the Smith Visibility Height Correlated mode.
  54329. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54330. */
  54331. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54332. /**
  54333. * Default value used for the IBL diffuse part.
  54334. * This can help switching back to the polynomials mode globally which is a tiny bit
  54335. * less GPU intensive at the drawback of a lower quality.
  54336. */
  54337. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54338. /**
  54339. * Default value used for activating energy conservation for the specular workflow.
  54340. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54341. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54342. */
  54343. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54344. private _useEnergyConservation;
  54345. /**
  54346. * Defines if the material uses energy conservation.
  54347. */
  54348. useEnergyConservation: boolean;
  54349. private _useSmithVisibilityHeightCorrelated;
  54350. /**
  54351. * LEGACY Mode set to false
  54352. * Defines if the material uses height smith correlated visibility term.
  54353. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54354. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54355. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54356. * Not relying on height correlated will also disable energy conservation.
  54357. */
  54358. useSmithVisibilityHeightCorrelated: boolean;
  54359. private _useSphericalHarmonics;
  54360. /**
  54361. * LEGACY Mode set to false
  54362. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54363. * diffuse part of the IBL.
  54364. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54365. * to the ground truth.
  54366. */
  54367. useSphericalHarmonics: boolean;
  54368. private _useSpecularGlossinessInputEnergyConservation;
  54369. /**
  54370. * Defines if the material uses energy conservation, when the specular workflow is active.
  54371. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54372. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54373. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54374. */
  54375. useSpecularGlossinessInputEnergyConservation: boolean;
  54376. /** @hidden */
  54377. private _internalMarkAllSubMeshesAsMiscDirty;
  54378. /** @hidden */
  54379. _markAllSubMeshesAsMiscDirty(): void;
  54380. /**
  54381. * Instantiate a new istance of clear coat configuration.
  54382. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54383. */
  54384. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54385. /**
  54386. * Checks to see if a texture is used in the material.
  54387. * @param defines the list of "defines" to update.
  54388. */
  54389. prepareDefines(defines: IMaterialBRDFDefines): void;
  54390. /**
  54391. * Get the current class name of the texture useful for serialization or dynamic coding.
  54392. * @returns "PBRClearCoatConfiguration"
  54393. */
  54394. getClassName(): string;
  54395. /**
  54396. * Makes a duplicate of the current configuration into another one.
  54397. * @param brdfConfiguration define the config where to copy the info
  54398. */
  54399. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54400. /**
  54401. * Serializes this BRDF configuration.
  54402. * @returns - An object with the serialized config.
  54403. */
  54404. serialize(): any;
  54405. /**
  54406. * Parses a anisotropy Configuration from a serialized object.
  54407. * @param source - Serialized object.
  54408. * @param scene Defines the scene we are parsing for
  54409. * @param rootUrl Defines the rootUrl to load from
  54410. */
  54411. parse(source: any, scene: Scene, rootUrl: string): void;
  54412. }
  54413. }
  54414. declare module BABYLON {
  54415. /**
  54416. * @hidden
  54417. */
  54418. export interface IMaterialSheenDefines {
  54419. SHEEN: boolean;
  54420. SHEEN_TEXTURE: boolean;
  54421. SHEEN_TEXTUREDIRECTUV: number;
  54422. SHEEN_LINKWITHALBEDO: boolean;
  54423. SHEEN_ROUGHNESS: boolean;
  54424. SHEEN_ALBEDOSCALING: boolean;
  54425. /** @hidden */
  54426. _areTexturesDirty: boolean;
  54427. }
  54428. /**
  54429. * Define the code related to the Sheen parameters of the pbr material.
  54430. */
  54431. export class PBRSheenConfiguration {
  54432. private _isEnabled;
  54433. /**
  54434. * Defines if the material uses sheen.
  54435. */
  54436. isEnabled: boolean;
  54437. private _linkSheenWithAlbedo;
  54438. /**
  54439. * Defines if the sheen is linked to the sheen color.
  54440. */
  54441. linkSheenWithAlbedo: boolean;
  54442. /**
  54443. * Defines the sheen intensity.
  54444. */
  54445. intensity: number;
  54446. /**
  54447. * Defines the sheen color.
  54448. */
  54449. color: Color3;
  54450. private _texture;
  54451. /**
  54452. * Stores the sheen tint values in a texture.
  54453. * rgb is tint
  54454. * a is a intensity or roughness if roughness has been defined
  54455. */
  54456. texture: Nullable<BaseTexture>;
  54457. private _roughness;
  54458. /**
  54459. * Defines the sheen roughness.
  54460. * It is not taken into account if linkSheenWithAlbedo is true.
  54461. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54462. */
  54463. roughness: Nullable<number>;
  54464. private _albedoScaling;
  54465. /**
  54466. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54467. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54468. * making it easier to setup and tweak the effect
  54469. */
  54470. albedoScaling: boolean;
  54471. /** @hidden */
  54472. private _internalMarkAllSubMeshesAsTexturesDirty;
  54473. /** @hidden */
  54474. _markAllSubMeshesAsTexturesDirty(): void;
  54475. /**
  54476. * Instantiate a new istance of clear coat configuration.
  54477. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54478. */
  54479. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54480. /**
  54481. * Specifies that the submesh is ready to be used.
  54482. * @param defines the list of "defines" to update.
  54483. * @param scene defines the scene the material belongs to.
  54484. * @returns - boolean indicating that the submesh is ready or not.
  54485. */
  54486. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54487. /**
  54488. * Checks to see if a texture is used in the material.
  54489. * @param defines the list of "defines" to update.
  54490. * @param scene defines the scene the material belongs to.
  54491. */
  54492. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54493. /**
  54494. * Binds the material data.
  54495. * @param uniformBuffer defines the Uniform buffer to fill in.
  54496. * @param scene defines the scene the material belongs to.
  54497. * @param isFrozen defines wether the material is frozen or not.
  54498. */
  54499. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54500. /**
  54501. * Checks to see if a texture is used in the material.
  54502. * @param texture - Base texture to use.
  54503. * @returns - Boolean specifying if a texture is used in the material.
  54504. */
  54505. hasTexture(texture: BaseTexture): boolean;
  54506. /**
  54507. * Returns an array of the actively used textures.
  54508. * @param activeTextures Array of BaseTextures
  54509. */
  54510. getActiveTextures(activeTextures: BaseTexture[]): void;
  54511. /**
  54512. * Returns the animatable textures.
  54513. * @param animatables Array of animatable textures.
  54514. */
  54515. getAnimatables(animatables: IAnimatable[]): void;
  54516. /**
  54517. * Disposes the resources of the material.
  54518. * @param forceDisposeTextures - Forces the disposal of all textures.
  54519. */
  54520. dispose(forceDisposeTextures?: boolean): void;
  54521. /**
  54522. * Get the current class name of the texture useful for serialization or dynamic coding.
  54523. * @returns "PBRSheenConfiguration"
  54524. */
  54525. getClassName(): string;
  54526. /**
  54527. * Add fallbacks to the effect fallbacks list.
  54528. * @param defines defines the Base texture to use.
  54529. * @param fallbacks defines the current fallback list.
  54530. * @param currentRank defines the current fallback rank.
  54531. * @returns the new fallback rank.
  54532. */
  54533. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54534. /**
  54535. * Add the required uniforms to the current list.
  54536. * @param uniforms defines the current uniform list.
  54537. */
  54538. static AddUniforms(uniforms: string[]): void;
  54539. /**
  54540. * Add the required uniforms to the current buffer.
  54541. * @param uniformBuffer defines the current uniform buffer.
  54542. */
  54543. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54544. /**
  54545. * Add the required samplers to the current list.
  54546. * @param samplers defines the current sampler list.
  54547. */
  54548. static AddSamplers(samplers: string[]): void;
  54549. /**
  54550. * Makes a duplicate of the current configuration into another one.
  54551. * @param sheenConfiguration define the config where to copy the info
  54552. */
  54553. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54554. /**
  54555. * Serializes this BRDF configuration.
  54556. * @returns - An object with the serialized config.
  54557. */
  54558. serialize(): any;
  54559. /**
  54560. * Parses a anisotropy Configuration from a serialized object.
  54561. * @param source - Serialized object.
  54562. * @param scene Defines the scene we are parsing for
  54563. * @param rootUrl Defines the rootUrl to load from
  54564. */
  54565. parse(source: any, scene: Scene, rootUrl: string): void;
  54566. }
  54567. }
  54568. declare module BABYLON {
  54569. /**
  54570. * @hidden
  54571. */
  54572. export interface IMaterialSubSurfaceDefines {
  54573. SUBSURFACE: boolean;
  54574. SS_REFRACTION: boolean;
  54575. SS_TRANSLUCENCY: boolean;
  54576. SS_SCATTERING: boolean;
  54577. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54578. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54579. SS_REFRACTIONMAP_3D: boolean;
  54580. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54581. SS_LODINREFRACTIONALPHA: boolean;
  54582. SS_GAMMAREFRACTION: boolean;
  54583. SS_RGBDREFRACTION: boolean;
  54584. SS_LINEARSPECULARREFRACTION: boolean;
  54585. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54586. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54587. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54588. /** @hidden */
  54589. _areTexturesDirty: boolean;
  54590. }
  54591. /**
  54592. * Define the code related to the sub surface parameters of the pbr material.
  54593. */
  54594. export class PBRSubSurfaceConfiguration {
  54595. private _isRefractionEnabled;
  54596. /**
  54597. * Defines if the refraction is enabled in the material.
  54598. */
  54599. isRefractionEnabled: boolean;
  54600. private _isTranslucencyEnabled;
  54601. /**
  54602. * Defines if the translucency is enabled in the material.
  54603. */
  54604. isTranslucencyEnabled: boolean;
  54605. private _isScatteringEnabled;
  54606. /**
  54607. * Defines if the sub surface scattering is enabled in the material.
  54608. */
  54609. isScatteringEnabled: boolean;
  54610. private _scatteringDiffusionProfileIndex;
  54611. /**
  54612. * Diffusion profile for subsurface scattering.
  54613. * Useful for better scattering in the skins or foliages.
  54614. */
  54615. get scatteringDiffusionProfile(): Nullable<Color3>;
  54616. set scatteringDiffusionProfile(c: Nullable<Color3>);
  54617. /**
  54618. * Defines the refraction intensity of the material.
  54619. * The refraction when enabled replaces the Diffuse part of the material.
  54620. * The intensity helps transitionning between diffuse and refraction.
  54621. */
  54622. refractionIntensity: number;
  54623. /**
  54624. * Defines the translucency intensity of the material.
  54625. * When translucency has been enabled, this defines how much of the "translucency"
  54626. * is addded to the diffuse part of the material.
  54627. */
  54628. translucencyIntensity: number;
  54629. /**
  54630. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54631. */
  54632. useAlbedoToTintRefraction: boolean;
  54633. private _thicknessTexture;
  54634. /**
  54635. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54636. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54637. * 0 would mean minimumThickness
  54638. * 1 would mean maximumThickness
  54639. * The other channels might be use as a mask to vary the different effects intensity.
  54640. */
  54641. thicknessTexture: Nullable<BaseTexture>;
  54642. private _refractionTexture;
  54643. /**
  54644. * Defines the texture to use for refraction.
  54645. */
  54646. refractionTexture: Nullable<BaseTexture>;
  54647. private _indexOfRefraction;
  54648. /**
  54649. * Index of refraction of the material base layer.
  54650. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54651. *
  54652. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54653. *
  54654. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54655. */
  54656. indexOfRefraction: number;
  54657. private _volumeIndexOfRefraction;
  54658. /**
  54659. * Index of refraction of the material's volume.
  54660. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54661. *
  54662. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54663. * the volume will use the same IOR as the surface.
  54664. */
  54665. get volumeIndexOfRefraction(): number;
  54666. set volumeIndexOfRefraction(value: number);
  54667. private _invertRefractionY;
  54668. /**
  54669. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54670. */
  54671. invertRefractionY: boolean;
  54672. private _linkRefractionWithTransparency;
  54673. /**
  54674. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54675. * Materials half opaque for instance using refraction could benefit from this control.
  54676. */
  54677. linkRefractionWithTransparency: boolean;
  54678. /**
  54679. * Defines the minimum thickness stored in the thickness map.
  54680. * If no thickness map is defined, this value will be used to simulate thickness.
  54681. */
  54682. minimumThickness: number;
  54683. /**
  54684. * Defines the maximum thickness stored in the thickness map.
  54685. */
  54686. maximumThickness: number;
  54687. /**
  54688. * Defines the volume tint of the material.
  54689. * This is used for both translucency and scattering.
  54690. */
  54691. tintColor: Color3;
  54692. /**
  54693. * Defines the distance at which the tint color should be found in the media.
  54694. * This is used for refraction only.
  54695. */
  54696. tintColorAtDistance: number;
  54697. /**
  54698. * Defines how far each channel transmit through the media.
  54699. * It is defined as a color to simplify it selection.
  54700. */
  54701. diffusionDistance: Color3;
  54702. private _useMaskFromThicknessTexture;
  54703. /**
  54704. * Stores the intensity of the different subsurface effects in the thickness texture.
  54705. * * the green channel is the translucency intensity.
  54706. * * the blue channel is the scattering intensity.
  54707. * * the alpha channel is the refraction intensity.
  54708. */
  54709. useMaskFromThicknessTexture: boolean;
  54710. private _scene;
  54711. /** @hidden */
  54712. private _internalMarkAllSubMeshesAsTexturesDirty;
  54713. private _internalMarkScenePrePassDirty;
  54714. /** @hidden */
  54715. _markAllSubMeshesAsTexturesDirty(): void;
  54716. /** @hidden */
  54717. _markScenePrePassDirty(): void;
  54718. /**
  54719. * Instantiate a new istance of sub surface configuration.
  54720. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54721. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  54722. * @param scene The scene
  54723. */
  54724. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  54725. /**
  54726. * Gets wehter the submesh is ready to be used or not.
  54727. * @param defines the list of "defines" to update.
  54728. * @param scene defines the scene the material belongs to.
  54729. * @returns - boolean indicating that the submesh is ready or not.
  54730. */
  54731. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54732. /**
  54733. * Checks to see if a texture is used in the material.
  54734. * @param defines the list of "defines" to update.
  54735. * @param scene defines the scene to the material belongs to.
  54736. */
  54737. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54738. /**
  54739. * Binds the material data.
  54740. * @param uniformBuffer defines the Uniform buffer to fill in.
  54741. * @param scene defines the scene the material belongs to.
  54742. * @param engine defines the engine the material belongs to.
  54743. * @param isFrozen defines whether the material is frozen or not.
  54744. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54745. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54746. */
  54747. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54748. /**
  54749. * Unbinds the material from the mesh.
  54750. * @param activeEffect defines the effect that should be unbound from.
  54751. * @returns true if unbound, otherwise false
  54752. */
  54753. unbind(activeEffect: Effect): boolean;
  54754. /**
  54755. * Returns the texture used for refraction or null if none is used.
  54756. * @param scene defines the scene the material belongs to.
  54757. * @returns - Refraction texture if present. If no refraction texture and refraction
  54758. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54759. */
  54760. private _getRefractionTexture;
  54761. /**
  54762. * Returns true if alpha blending should be disabled.
  54763. */
  54764. get disableAlphaBlending(): boolean;
  54765. /**
  54766. * Fills the list of render target textures.
  54767. * @param renderTargets the list of render targets to update
  54768. */
  54769. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54770. /**
  54771. * Checks to see if a texture is used in the material.
  54772. * @param texture - Base texture to use.
  54773. * @returns - Boolean specifying if a texture is used in the material.
  54774. */
  54775. hasTexture(texture: BaseTexture): boolean;
  54776. /**
  54777. * Gets a boolean indicating that current material needs to register RTT
  54778. * @returns true if this uses a render target otherwise false.
  54779. */
  54780. hasRenderTargetTextures(): boolean;
  54781. /**
  54782. * Returns an array of the actively used textures.
  54783. * @param activeTextures Array of BaseTextures
  54784. */
  54785. getActiveTextures(activeTextures: BaseTexture[]): void;
  54786. /**
  54787. * Returns the animatable textures.
  54788. * @param animatables Array of animatable textures.
  54789. */
  54790. getAnimatables(animatables: IAnimatable[]): void;
  54791. /**
  54792. * Disposes the resources of the material.
  54793. * @param forceDisposeTextures - Forces the disposal of all textures.
  54794. */
  54795. dispose(forceDisposeTextures?: boolean): void;
  54796. /**
  54797. * Get the current class name of the texture useful for serialization or dynamic coding.
  54798. * @returns "PBRSubSurfaceConfiguration"
  54799. */
  54800. getClassName(): string;
  54801. /**
  54802. * Add fallbacks to the effect fallbacks list.
  54803. * @param defines defines the Base texture to use.
  54804. * @param fallbacks defines the current fallback list.
  54805. * @param currentRank defines the current fallback rank.
  54806. * @returns the new fallback rank.
  54807. */
  54808. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54809. /**
  54810. * Add the required uniforms to the current list.
  54811. * @param uniforms defines the current uniform list.
  54812. */
  54813. static AddUniforms(uniforms: string[]): void;
  54814. /**
  54815. * Add the required samplers to the current list.
  54816. * @param samplers defines the current sampler list.
  54817. */
  54818. static AddSamplers(samplers: string[]): void;
  54819. /**
  54820. * Add the required uniforms to the current buffer.
  54821. * @param uniformBuffer defines the current uniform buffer.
  54822. */
  54823. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54824. /**
  54825. * Makes a duplicate of the current configuration into another one.
  54826. * @param configuration define the config where to copy the info
  54827. */
  54828. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54829. /**
  54830. * Serializes this Sub Surface configuration.
  54831. * @returns - An object with the serialized config.
  54832. */
  54833. serialize(): any;
  54834. /**
  54835. * Parses a anisotropy Configuration from a serialized object.
  54836. * @param source - Serialized object.
  54837. * @param scene Defines the scene we are parsing for
  54838. * @param rootUrl Defines the rootUrl to load from
  54839. */
  54840. parse(source: any, scene: Scene, rootUrl: string): void;
  54841. }
  54842. }
  54843. declare module BABYLON {
  54844. /** @hidden */
  54845. export var prePassDeclaration: {
  54846. name: string;
  54847. shader: string;
  54848. };
  54849. }
  54850. declare module BABYLON {
  54851. /** @hidden */
  54852. export var pbrFragmentDeclaration: {
  54853. name: string;
  54854. shader: string;
  54855. };
  54856. }
  54857. declare module BABYLON {
  54858. /** @hidden */
  54859. export var pbrUboDeclaration: {
  54860. name: string;
  54861. shader: string;
  54862. };
  54863. }
  54864. declare module BABYLON {
  54865. /** @hidden */
  54866. export var pbrFragmentExtraDeclaration: {
  54867. name: string;
  54868. shader: string;
  54869. };
  54870. }
  54871. declare module BABYLON {
  54872. /** @hidden */
  54873. export var pbrFragmentSamplersDeclaration: {
  54874. name: string;
  54875. shader: string;
  54876. };
  54877. }
  54878. declare module BABYLON {
  54879. /** @hidden */
  54880. export var subSurfaceScatteringFunctions: {
  54881. name: string;
  54882. shader: string;
  54883. };
  54884. }
  54885. declare module BABYLON {
  54886. /** @hidden */
  54887. export var importanceSampling: {
  54888. name: string;
  54889. shader: string;
  54890. };
  54891. }
  54892. declare module BABYLON {
  54893. /** @hidden */
  54894. export var pbrHelperFunctions: {
  54895. name: string;
  54896. shader: string;
  54897. };
  54898. }
  54899. declare module BABYLON {
  54900. /** @hidden */
  54901. export var harmonicsFunctions: {
  54902. name: string;
  54903. shader: string;
  54904. };
  54905. }
  54906. declare module BABYLON {
  54907. /** @hidden */
  54908. export var pbrDirectLightingSetupFunctions: {
  54909. name: string;
  54910. shader: string;
  54911. };
  54912. }
  54913. declare module BABYLON {
  54914. /** @hidden */
  54915. export var pbrDirectLightingFalloffFunctions: {
  54916. name: string;
  54917. shader: string;
  54918. };
  54919. }
  54920. declare module BABYLON {
  54921. /** @hidden */
  54922. export var pbrBRDFFunctions: {
  54923. name: string;
  54924. shader: string;
  54925. };
  54926. }
  54927. declare module BABYLON {
  54928. /** @hidden */
  54929. export var hdrFilteringFunctions: {
  54930. name: string;
  54931. shader: string;
  54932. };
  54933. }
  54934. declare module BABYLON {
  54935. /** @hidden */
  54936. export var pbrDirectLightingFunctions: {
  54937. name: string;
  54938. shader: string;
  54939. };
  54940. }
  54941. declare module BABYLON {
  54942. /** @hidden */
  54943. export var pbrIBLFunctions: {
  54944. name: string;
  54945. shader: string;
  54946. };
  54947. }
  54948. declare module BABYLON {
  54949. /** @hidden */
  54950. export var pbrBlockAlbedoOpacity: {
  54951. name: string;
  54952. shader: string;
  54953. };
  54954. }
  54955. declare module BABYLON {
  54956. /** @hidden */
  54957. export var pbrBlockReflectivity: {
  54958. name: string;
  54959. shader: string;
  54960. };
  54961. }
  54962. declare module BABYLON {
  54963. /** @hidden */
  54964. export var pbrBlockAmbientOcclusion: {
  54965. name: string;
  54966. shader: string;
  54967. };
  54968. }
  54969. declare module BABYLON {
  54970. /** @hidden */
  54971. export var pbrBlockAlphaFresnel: {
  54972. name: string;
  54973. shader: string;
  54974. };
  54975. }
  54976. declare module BABYLON {
  54977. /** @hidden */
  54978. export var pbrBlockAnisotropic: {
  54979. name: string;
  54980. shader: string;
  54981. };
  54982. }
  54983. declare module BABYLON {
  54984. /** @hidden */
  54985. export var pbrBlockReflection: {
  54986. name: string;
  54987. shader: string;
  54988. };
  54989. }
  54990. declare module BABYLON {
  54991. /** @hidden */
  54992. export var pbrBlockSheen: {
  54993. name: string;
  54994. shader: string;
  54995. };
  54996. }
  54997. declare module BABYLON {
  54998. /** @hidden */
  54999. export var pbrBlockClearcoat: {
  55000. name: string;
  55001. shader: string;
  55002. };
  55003. }
  55004. declare module BABYLON {
  55005. /** @hidden */
  55006. export var pbrBlockSubSurface: {
  55007. name: string;
  55008. shader: string;
  55009. };
  55010. }
  55011. declare module BABYLON {
  55012. /** @hidden */
  55013. export var pbrBlockNormalGeometric: {
  55014. name: string;
  55015. shader: string;
  55016. };
  55017. }
  55018. declare module BABYLON {
  55019. /** @hidden */
  55020. export var pbrBlockNormalFinal: {
  55021. name: string;
  55022. shader: string;
  55023. };
  55024. }
  55025. declare module BABYLON {
  55026. /** @hidden */
  55027. export var pbrBlockGeometryInfo: {
  55028. name: string;
  55029. shader: string;
  55030. };
  55031. }
  55032. declare module BABYLON {
  55033. /** @hidden */
  55034. export var pbrBlockReflectance0: {
  55035. name: string;
  55036. shader: string;
  55037. };
  55038. }
  55039. declare module BABYLON {
  55040. /** @hidden */
  55041. export var pbrBlockReflectance: {
  55042. name: string;
  55043. shader: string;
  55044. };
  55045. }
  55046. declare module BABYLON {
  55047. /** @hidden */
  55048. export var pbrBlockDirectLighting: {
  55049. name: string;
  55050. shader: string;
  55051. };
  55052. }
  55053. declare module BABYLON {
  55054. /** @hidden */
  55055. export var pbrBlockFinalLitComponents: {
  55056. name: string;
  55057. shader: string;
  55058. };
  55059. }
  55060. declare module BABYLON {
  55061. /** @hidden */
  55062. export var pbrBlockFinalUnlitComponents: {
  55063. name: string;
  55064. shader: string;
  55065. };
  55066. }
  55067. declare module BABYLON {
  55068. /** @hidden */
  55069. export var pbrBlockFinalColorComposition: {
  55070. name: string;
  55071. shader: string;
  55072. };
  55073. }
  55074. declare module BABYLON {
  55075. /** @hidden */
  55076. export var pbrBlockImageProcessing: {
  55077. name: string;
  55078. shader: string;
  55079. };
  55080. }
  55081. declare module BABYLON {
  55082. /** @hidden */
  55083. export var pbrDebug: {
  55084. name: string;
  55085. shader: string;
  55086. };
  55087. }
  55088. declare module BABYLON {
  55089. /** @hidden */
  55090. export var pbrPixelShader: {
  55091. name: string;
  55092. shader: string;
  55093. };
  55094. }
  55095. declare module BABYLON {
  55096. /** @hidden */
  55097. export var pbrVertexDeclaration: {
  55098. name: string;
  55099. shader: string;
  55100. };
  55101. }
  55102. declare module BABYLON {
  55103. /** @hidden */
  55104. export var pbrVertexShader: {
  55105. name: string;
  55106. shader: string;
  55107. };
  55108. }
  55109. declare module BABYLON {
  55110. /**
  55111. * Manages the defines for the PBR Material.
  55112. * @hidden
  55113. */
  55114. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55115. PBR: boolean;
  55116. NUM_SAMPLES: string;
  55117. REALTIME_FILTERING: boolean;
  55118. MAINUV1: boolean;
  55119. MAINUV2: boolean;
  55120. UV1: boolean;
  55121. UV2: boolean;
  55122. ALBEDO: boolean;
  55123. GAMMAALBEDO: boolean;
  55124. ALBEDODIRECTUV: number;
  55125. VERTEXCOLOR: boolean;
  55126. DETAIL: boolean;
  55127. DETAILDIRECTUV: number;
  55128. DETAIL_NORMALBLENDMETHOD: number;
  55129. AMBIENT: boolean;
  55130. AMBIENTDIRECTUV: number;
  55131. AMBIENTINGRAYSCALE: boolean;
  55132. OPACITY: boolean;
  55133. VERTEXALPHA: boolean;
  55134. OPACITYDIRECTUV: number;
  55135. OPACITYRGB: boolean;
  55136. ALPHATEST: boolean;
  55137. DEPTHPREPASS: boolean;
  55138. ALPHABLEND: boolean;
  55139. ALPHAFROMALBEDO: boolean;
  55140. ALPHATESTVALUE: string;
  55141. SPECULAROVERALPHA: boolean;
  55142. RADIANCEOVERALPHA: boolean;
  55143. ALPHAFRESNEL: boolean;
  55144. LINEARALPHAFRESNEL: boolean;
  55145. PREMULTIPLYALPHA: boolean;
  55146. EMISSIVE: boolean;
  55147. EMISSIVEDIRECTUV: number;
  55148. REFLECTIVITY: boolean;
  55149. REFLECTIVITYDIRECTUV: number;
  55150. SPECULARTERM: boolean;
  55151. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55152. MICROSURFACEAUTOMATIC: boolean;
  55153. LODBASEDMICROSFURACE: boolean;
  55154. MICROSURFACEMAP: boolean;
  55155. MICROSURFACEMAPDIRECTUV: number;
  55156. METALLICWORKFLOW: boolean;
  55157. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55158. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55159. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55160. AOSTOREINMETALMAPRED: boolean;
  55161. METALLIC_REFLECTANCE: boolean;
  55162. METALLIC_REFLECTANCEDIRECTUV: number;
  55163. ENVIRONMENTBRDF: boolean;
  55164. ENVIRONMENTBRDF_RGBD: boolean;
  55165. NORMAL: boolean;
  55166. TANGENT: boolean;
  55167. BUMP: boolean;
  55168. BUMPDIRECTUV: number;
  55169. OBJECTSPACE_NORMALMAP: boolean;
  55170. PARALLAX: boolean;
  55171. PARALLAXOCCLUSION: boolean;
  55172. NORMALXYSCALE: boolean;
  55173. LIGHTMAP: boolean;
  55174. LIGHTMAPDIRECTUV: number;
  55175. USELIGHTMAPASSHADOWMAP: boolean;
  55176. GAMMALIGHTMAP: boolean;
  55177. RGBDLIGHTMAP: boolean;
  55178. REFLECTION: boolean;
  55179. REFLECTIONMAP_3D: boolean;
  55180. REFLECTIONMAP_SPHERICAL: boolean;
  55181. REFLECTIONMAP_PLANAR: boolean;
  55182. REFLECTIONMAP_CUBIC: boolean;
  55183. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55184. REFLECTIONMAP_PROJECTION: boolean;
  55185. REFLECTIONMAP_SKYBOX: boolean;
  55186. REFLECTIONMAP_EXPLICIT: boolean;
  55187. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55188. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55189. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55190. INVERTCUBICMAP: boolean;
  55191. USESPHERICALFROMREFLECTIONMAP: boolean;
  55192. USEIRRADIANCEMAP: boolean;
  55193. SPHERICAL_HARMONICS: boolean;
  55194. USESPHERICALINVERTEX: boolean;
  55195. REFLECTIONMAP_OPPOSITEZ: boolean;
  55196. LODINREFLECTIONALPHA: boolean;
  55197. GAMMAREFLECTION: boolean;
  55198. RGBDREFLECTION: boolean;
  55199. LINEARSPECULARREFLECTION: boolean;
  55200. RADIANCEOCCLUSION: boolean;
  55201. HORIZONOCCLUSION: boolean;
  55202. INSTANCES: boolean;
  55203. THIN_INSTANCES: boolean;
  55204. PREPASS: boolean;
  55205. SCENE_MRT_COUNT: number;
  55206. NUM_BONE_INFLUENCERS: number;
  55207. BonesPerMesh: number;
  55208. BONETEXTURE: boolean;
  55209. NONUNIFORMSCALING: boolean;
  55210. MORPHTARGETS: boolean;
  55211. MORPHTARGETS_NORMAL: boolean;
  55212. MORPHTARGETS_TANGENT: boolean;
  55213. MORPHTARGETS_UV: boolean;
  55214. NUM_MORPH_INFLUENCERS: number;
  55215. IMAGEPROCESSING: boolean;
  55216. VIGNETTE: boolean;
  55217. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55218. VIGNETTEBLENDMODEOPAQUE: boolean;
  55219. TONEMAPPING: boolean;
  55220. TONEMAPPING_ACES: boolean;
  55221. CONTRAST: boolean;
  55222. COLORCURVES: boolean;
  55223. COLORGRADING: boolean;
  55224. COLORGRADING3D: boolean;
  55225. SAMPLER3DGREENDEPTH: boolean;
  55226. SAMPLER3DBGRMAP: boolean;
  55227. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55228. EXPOSURE: boolean;
  55229. MULTIVIEW: boolean;
  55230. USEPHYSICALLIGHTFALLOFF: boolean;
  55231. USEGLTFLIGHTFALLOFF: boolean;
  55232. TWOSIDEDLIGHTING: boolean;
  55233. SHADOWFLOAT: boolean;
  55234. CLIPPLANE: boolean;
  55235. CLIPPLANE2: boolean;
  55236. CLIPPLANE3: boolean;
  55237. CLIPPLANE4: boolean;
  55238. CLIPPLANE5: boolean;
  55239. CLIPPLANE6: boolean;
  55240. POINTSIZE: boolean;
  55241. FOG: boolean;
  55242. LOGARITHMICDEPTH: boolean;
  55243. FORCENORMALFORWARD: boolean;
  55244. SPECULARAA: boolean;
  55245. CLEARCOAT: boolean;
  55246. CLEARCOAT_DEFAULTIOR: boolean;
  55247. CLEARCOAT_TEXTURE: boolean;
  55248. CLEARCOAT_TEXTUREDIRECTUV: number;
  55249. CLEARCOAT_BUMP: boolean;
  55250. CLEARCOAT_BUMPDIRECTUV: number;
  55251. CLEARCOAT_TINT: boolean;
  55252. CLEARCOAT_TINT_TEXTURE: boolean;
  55253. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55254. ANISOTROPIC: boolean;
  55255. ANISOTROPIC_TEXTURE: boolean;
  55256. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55257. BRDF_V_HEIGHT_CORRELATED: boolean;
  55258. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55259. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55260. SHEEN: boolean;
  55261. SHEEN_TEXTURE: boolean;
  55262. SHEEN_TEXTUREDIRECTUV: number;
  55263. SHEEN_LINKWITHALBEDO: boolean;
  55264. SHEEN_ROUGHNESS: boolean;
  55265. SHEEN_ALBEDOSCALING: boolean;
  55266. SUBSURFACE: boolean;
  55267. SS_REFRACTION: boolean;
  55268. SS_TRANSLUCENCY: boolean;
  55269. SS_SCATTERING: boolean;
  55270. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55271. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55272. SS_REFRACTIONMAP_3D: boolean;
  55273. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55274. SS_LODINREFRACTIONALPHA: boolean;
  55275. SS_GAMMAREFRACTION: boolean;
  55276. SS_RGBDREFRACTION: boolean;
  55277. SS_LINEARSPECULARREFRACTION: boolean;
  55278. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55279. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55280. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55281. UNLIT: boolean;
  55282. DEBUGMODE: number;
  55283. /**
  55284. * Initializes the PBR Material defines.
  55285. */
  55286. constructor();
  55287. /**
  55288. * Resets the PBR Material defines.
  55289. */
  55290. reset(): void;
  55291. }
  55292. /**
  55293. * The Physically based material base class of BJS.
  55294. *
  55295. * This offers the main features of a standard PBR material.
  55296. * For more information, please refer to the documentation :
  55297. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55298. */
  55299. export abstract class PBRBaseMaterial extends PushMaterial {
  55300. /**
  55301. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55302. */
  55303. static readonly PBRMATERIAL_OPAQUE: number;
  55304. /**
  55305. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55306. */
  55307. static readonly PBRMATERIAL_ALPHATEST: number;
  55308. /**
  55309. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55310. */
  55311. static readonly PBRMATERIAL_ALPHABLEND: number;
  55312. /**
  55313. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55314. * They are also discarded below the alpha cutoff threshold to improve performances.
  55315. */
  55316. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55317. /**
  55318. * Defines the default value of how much AO map is occluding the analytical lights
  55319. * (point spot...).
  55320. */
  55321. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55322. /**
  55323. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55324. */
  55325. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55326. /**
  55327. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55328. * to enhance interoperability with other engines.
  55329. */
  55330. static readonly LIGHTFALLOFF_GLTF: number;
  55331. /**
  55332. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55333. * to enhance interoperability with other materials.
  55334. */
  55335. static readonly LIGHTFALLOFF_STANDARD: number;
  55336. /**
  55337. * Intensity of the direct lights e.g. the four lights available in your scene.
  55338. * This impacts both the direct diffuse and specular highlights.
  55339. */
  55340. protected _directIntensity: number;
  55341. /**
  55342. * Intensity of the emissive part of the material.
  55343. * This helps controlling the emissive effect without modifying the emissive color.
  55344. */
  55345. protected _emissiveIntensity: number;
  55346. /**
  55347. * Intensity of the environment e.g. how much the environment will light the object
  55348. * either through harmonics for rough material or through the refelction for shiny ones.
  55349. */
  55350. protected _environmentIntensity: number;
  55351. /**
  55352. * This is a special control allowing the reduction of the specular highlights coming from the
  55353. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55354. */
  55355. protected _specularIntensity: number;
  55356. /**
  55357. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55358. */
  55359. private _lightingInfos;
  55360. /**
  55361. * Debug Control allowing disabling the bump map on this material.
  55362. */
  55363. protected _disableBumpMap: boolean;
  55364. /**
  55365. * AKA Diffuse Texture in standard nomenclature.
  55366. */
  55367. protected _albedoTexture: Nullable<BaseTexture>;
  55368. /**
  55369. * AKA Occlusion Texture in other nomenclature.
  55370. */
  55371. protected _ambientTexture: Nullable<BaseTexture>;
  55372. /**
  55373. * AKA Occlusion Texture Intensity in other nomenclature.
  55374. */
  55375. protected _ambientTextureStrength: number;
  55376. /**
  55377. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55378. * 1 means it completely occludes it
  55379. * 0 mean it has no impact
  55380. */
  55381. protected _ambientTextureImpactOnAnalyticalLights: number;
  55382. /**
  55383. * Stores the alpha values in a texture.
  55384. */
  55385. protected _opacityTexture: Nullable<BaseTexture>;
  55386. /**
  55387. * Stores the reflection values in a texture.
  55388. */
  55389. protected _reflectionTexture: Nullable<BaseTexture>;
  55390. /**
  55391. * Stores the emissive values in a texture.
  55392. */
  55393. protected _emissiveTexture: Nullable<BaseTexture>;
  55394. /**
  55395. * AKA Specular texture in other nomenclature.
  55396. */
  55397. protected _reflectivityTexture: Nullable<BaseTexture>;
  55398. /**
  55399. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55400. */
  55401. protected _metallicTexture: Nullable<BaseTexture>;
  55402. /**
  55403. * Specifies the metallic scalar of the metallic/roughness workflow.
  55404. * Can also be used to scale the metalness values of the metallic texture.
  55405. */
  55406. protected _metallic: Nullable<number>;
  55407. /**
  55408. * Specifies the roughness scalar of the metallic/roughness workflow.
  55409. * Can also be used to scale the roughness values of the metallic texture.
  55410. */
  55411. protected _roughness: Nullable<number>;
  55412. /**
  55413. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55414. * By default the indexOfrefraction is used to compute F0;
  55415. *
  55416. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55417. *
  55418. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55419. * F90 = metallicReflectanceColor;
  55420. */
  55421. protected _metallicF0Factor: number;
  55422. /**
  55423. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55424. * By default the F90 is always 1;
  55425. *
  55426. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55427. *
  55428. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55429. * F90 = metallicReflectanceColor;
  55430. */
  55431. protected _metallicReflectanceColor: Color3;
  55432. /**
  55433. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55434. * This is multiply against the scalar values defined in the material.
  55435. */
  55436. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55437. /**
  55438. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55439. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55440. */
  55441. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55442. /**
  55443. * Stores surface normal data used to displace a mesh in a texture.
  55444. */
  55445. protected _bumpTexture: Nullable<BaseTexture>;
  55446. /**
  55447. * Stores the pre-calculated light information of a mesh in a texture.
  55448. */
  55449. protected _lightmapTexture: Nullable<BaseTexture>;
  55450. /**
  55451. * The color of a material in ambient lighting.
  55452. */
  55453. protected _ambientColor: Color3;
  55454. /**
  55455. * AKA Diffuse Color in other nomenclature.
  55456. */
  55457. protected _albedoColor: Color3;
  55458. /**
  55459. * AKA Specular Color in other nomenclature.
  55460. */
  55461. protected _reflectivityColor: Color3;
  55462. /**
  55463. * The color applied when light is reflected from a material.
  55464. */
  55465. protected _reflectionColor: Color3;
  55466. /**
  55467. * The color applied when light is emitted from a material.
  55468. */
  55469. protected _emissiveColor: Color3;
  55470. /**
  55471. * AKA Glossiness in other nomenclature.
  55472. */
  55473. protected _microSurface: number;
  55474. /**
  55475. * Specifies that the material will use the light map as a show map.
  55476. */
  55477. protected _useLightmapAsShadowmap: boolean;
  55478. /**
  55479. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55480. * makes the reflect vector face the model (under horizon).
  55481. */
  55482. protected _useHorizonOcclusion: boolean;
  55483. /**
  55484. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55485. * too much the area relying on ambient texture to define their ambient occlusion.
  55486. */
  55487. protected _useRadianceOcclusion: boolean;
  55488. /**
  55489. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55490. */
  55491. protected _useAlphaFromAlbedoTexture: boolean;
  55492. /**
  55493. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55494. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55495. */
  55496. protected _useSpecularOverAlpha: boolean;
  55497. /**
  55498. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55499. */
  55500. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55501. /**
  55502. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55503. */
  55504. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55505. /**
  55506. * Specifies if the metallic texture contains the roughness information in its green channel.
  55507. */
  55508. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55509. /**
  55510. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55511. */
  55512. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55513. /**
  55514. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55515. */
  55516. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55517. /**
  55518. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55519. */
  55520. protected _useAmbientInGrayScale: boolean;
  55521. /**
  55522. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55523. * The material will try to infer what glossiness each pixel should be.
  55524. */
  55525. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55526. /**
  55527. * Defines the falloff type used in this material.
  55528. * It by default is Physical.
  55529. */
  55530. protected _lightFalloff: number;
  55531. /**
  55532. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55533. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55534. */
  55535. protected _useRadianceOverAlpha: boolean;
  55536. /**
  55537. * Allows using an object space normal map (instead of tangent space).
  55538. */
  55539. protected _useObjectSpaceNormalMap: boolean;
  55540. /**
  55541. * Allows using the bump map in parallax mode.
  55542. */
  55543. protected _useParallax: boolean;
  55544. /**
  55545. * Allows using the bump map in parallax occlusion mode.
  55546. */
  55547. protected _useParallaxOcclusion: boolean;
  55548. /**
  55549. * Controls the scale bias of the parallax mode.
  55550. */
  55551. protected _parallaxScaleBias: number;
  55552. /**
  55553. * If sets to true, disables all the lights affecting the material.
  55554. */
  55555. protected _disableLighting: boolean;
  55556. /**
  55557. * Number of Simultaneous lights allowed on the material.
  55558. */
  55559. protected _maxSimultaneousLights: number;
  55560. /**
  55561. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55562. */
  55563. protected _invertNormalMapX: boolean;
  55564. /**
  55565. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55566. */
  55567. protected _invertNormalMapY: boolean;
  55568. /**
  55569. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55570. */
  55571. protected _twoSidedLighting: boolean;
  55572. /**
  55573. * Defines the alpha limits in alpha test mode.
  55574. */
  55575. protected _alphaCutOff: number;
  55576. /**
  55577. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55578. */
  55579. protected _forceAlphaTest: boolean;
  55580. /**
  55581. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55582. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55583. */
  55584. protected _useAlphaFresnel: boolean;
  55585. /**
  55586. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55587. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55588. */
  55589. protected _useLinearAlphaFresnel: boolean;
  55590. /**
  55591. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55592. * from cos thetav and roughness:
  55593. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55594. */
  55595. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55596. /**
  55597. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55598. */
  55599. protected _forceIrradianceInFragment: boolean;
  55600. private _realTimeFiltering;
  55601. /**
  55602. * Enables realtime filtering on the texture.
  55603. */
  55604. get realTimeFiltering(): boolean;
  55605. set realTimeFiltering(b: boolean);
  55606. private _realTimeFilteringQuality;
  55607. /**
  55608. * Quality switch for realtime filtering
  55609. */
  55610. get realTimeFilteringQuality(): number;
  55611. set realTimeFilteringQuality(n: number);
  55612. /**
  55613. * Should this material render to several textures at once
  55614. */
  55615. get shouldRenderToMRT(): boolean;
  55616. /**
  55617. * Force normal to face away from face.
  55618. */
  55619. protected _forceNormalForward: boolean;
  55620. /**
  55621. * Enables specular anti aliasing in the PBR shader.
  55622. * It will both interacts on the Geometry for analytical and IBL lighting.
  55623. * It also prefilter the roughness map based on the bump values.
  55624. */
  55625. protected _enableSpecularAntiAliasing: boolean;
  55626. /**
  55627. * Default configuration related to image processing available in the PBR Material.
  55628. */
  55629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55630. /**
  55631. * Keep track of the image processing observer to allow dispose and replace.
  55632. */
  55633. private _imageProcessingObserver;
  55634. /**
  55635. * Attaches a new image processing configuration to the PBR Material.
  55636. * @param configuration
  55637. */
  55638. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55639. /**
  55640. * Stores the available render targets.
  55641. */
  55642. private _renderTargets;
  55643. /**
  55644. * Sets the global ambient color for the material used in lighting calculations.
  55645. */
  55646. private _globalAmbientColor;
  55647. /**
  55648. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55649. */
  55650. private _useLogarithmicDepth;
  55651. /**
  55652. * If set to true, no lighting calculations will be applied.
  55653. */
  55654. private _unlit;
  55655. private _debugMode;
  55656. /**
  55657. * @hidden
  55658. * This is reserved for the inspector.
  55659. * Defines the material debug mode.
  55660. * It helps seeing only some components of the material while troubleshooting.
  55661. */
  55662. debugMode: number;
  55663. /**
  55664. * @hidden
  55665. * This is reserved for the inspector.
  55666. * Specify from where on screen the debug mode should start.
  55667. * The value goes from -1 (full screen) to 1 (not visible)
  55668. * It helps with side by side comparison against the final render
  55669. * This defaults to -1
  55670. */
  55671. private debugLimit;
  55672. /**
  55673. * @hidden
  55674. * This is reserved for the inspector.
  55675. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55676. * You can use the factor to better multiply the final value.
  55677. */
  55678. private debugFactor;
  55679. /**
  55680. * Defines the clear coat layer parameters for the material.
  55681. */
  55682. readonly clearCoat: PBRClearCoatConfiguration;
  55683. /**
  55684. * Defines the anisotropic parameters for the material.
  55685. */
  55686. readonly anisotropy: PBRAnisotropicConfiguration;
  55687. /**
  55688. * Defines the BRDF parameters for the material.
  55689. */
  55690. readonly brdf: PBRBRDFConfiguration;
  55691. /**
  55692. * Defines the Sheen parameters for the material.
  55693. */
  55694. readonly sheen: PBRSheenConfiguration;
  55695. /**
  55696. * Defines the SubSurface parameters for the material.
  55697. */
  55698. readonly subSurface: PBRSubSurfaceConfiguration;
  55699. /**
  55700. * Defines the detail map parameters for the material.
  55701. */
  55702. readonly detailMap: DetailMapConfiguration;
  55703. protected _rebuildInParallel: boolean;
  55704. /**
  55705. * Instantiates a new PBRMaterial instance.
  55706. *
  55707. * @param name The material name
  55708. * @param scene The scene the material will be use in.
  55709. */
  55710. constructor(name: string, scene: Scene);
  55711. /**
  55712. * Gets a boolean indicating that current material needs to register RTT
  55713. */
  55714. get hasRenderTargetTextures(): boolean;
  55715. /**
  55716. * Gets the name of the material class.
  55717. */
  55718. getClassName(): string;
  55719. /**
  55720. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55721. */
  55722. get useLogarithmicDepth(): boolean;
  55723. /**
  55724. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55725. */
  55726. set useLogarithmicDepth(value: boolean);
  55727. /**
  55728. * Returns true if alpha blending should be disabled.
  55729. */
  55730. protected get _disableAlphaBlending(): boolean;
  55731. /**
  55732. * Specifies whether or not this material should be rendered in alpha blend mode.
  55733. */
  55734. needAlphaBlending(): boolean;
  55735. /**
  55736. * Specifies whether or not this material should be rendered in alpha test mode.
  55737. */
  55738. needAlphaTesting(): boolean;
  55739. /**
  55740. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55741. */
  55742. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55743. /**
  55744. * Gets the texture used for the alpha test.
  55745. */
  55746. getAlphaTestTexture(): Nullable<BaseTexture>;
  55747. /**
  55748. * Specifies that the submesh is ready to be used.
  55749. * @param mesh - BJS mesh.
  55750. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55751. * @param useInstances - Specifies that instances should be used.
  55752. * @returns - boolean indicating that the submesh is ready or not.
  55753. */
  55754. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55755. /**
  55756. * Specifies if the material uses metallic roughness workflow.
  55757. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55758. */
  55759. isMetallicWorkflow(): boolean;
  55760. private _prepareEffect;
  55761. private _prepareDefines;
  55762. /**
  55763. * Force shader compilation
  55764. */
  55765. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55766. /**
  55767. * Initializes the uniform buffer layout for the shader.
  55768. */
  55769. buildUniformLayout(): void;
  55770. /**
  55771. * Unbinds the material from the mesh
  55772. */
  55773. unbind(): void;
  55774. /**
  55775. * Binds the submesh data.
  55776. * @param world - The world matrix.
  55777. * @param mesh - The BJS mesh.
  55778. * @param subMesh - A submesh of the BJS mesh.
  55779. */
  55780. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55781. /**
  55782. * Returns the animatable textures.
  55783. * @returns - Array of animatable textures.
  55784. */
  55785. getAnimatables(): IAnimatable[];
  55786. /**
  55787. * Returns the texture used for reflections.
  55788. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55789. */
  55790. private _getReflectionTexture;
  55791. /**
  55792. * Returns an array of the actively used textures.
  55793. * @returns - Array of BaseTextures
  55794. */
  55795. getActiveTextures(): BaseTexture[];
  55796. /**
  55797. * Checks to see if a texture is used in the material.
  55798. * @param texture - Base texture to use.
  55799. * @returns - Boolean specifying if a texture is used in the material.
  55800. */
  55801. hasTexture(texture: BaseTexture): boolean;
  55802. /**
  55803. * Disposes the resources of the material.
  55804. * @param forceDisposeEffect - Forces the disposal of effects.
  55805. * @param forceDisposeTextures - Forces the disposal of all textures.
  55806. */
  55807. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55808. }
  55809. }
  55810. declare module BABYLON {
  55811. /**
  55812. * The Physically based material of BJS.
  55813. *
  55814. * This offers the main features of a standard PBR material.
  55815. * For more information, please refer to the documentation :
  55816. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55817. */
  55818. export class PBRMaterial extends PBRBaseMaterial {
  55819. /**
  55820. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55821. */
  55822. static readonly PBRMATERIAL_OPAQUE: number;
  55823. /**
  55824. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55825. */
  55826. static readonly PBRMATERIAL_ALPHATEST: number;
  55827. /**
  55828. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55829. */
  55830. static readonly PBRMATERIAL_ALPHABLEND: number;
  55831. /**
  55832. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55833. * They are also discarded below the alpha cutoff threshold to improve performances.
  55834. */
  55835. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55836. /**
  55837. * Defines the default value of how much AO map is occluding the analytical lights
  55838. * (point spot...).
  55839. */
  55840. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55841. /**
  55842. * Intensity of the direct lights e.g. the four lights available in your scene.
  55843. * This impacts both the direct diffuse and specular highlights.
  55844. */
  55845. directIntensity: number;
  55846. /**
  55847. * Intensity of the emissive part of the material.
  55848. * This helps controlling the emissive effect without modifying the emissive color.
  55849. */
  55850. emissiveIntensity: number;
  55851. /**
  55852. * Intensity of the environment e.g. how much the environment will light the object
  55853. * either through harmonics for rough material or through the refelction for shiny ones.
  55854. */
  55855. environmentIntensity: number;
  55856. /**
  55857. * This is a special control allowing the reduction of the specular highlights coming from the
  55858. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55859. */
  55860. specularIntensity: number;
  55861. /**
  55862. * Debug Control allowing disabling the bump map on this material.
  55863. */
  55864. disableBumpMap: boolean;
  55865. /**
  55866. * AKA Diffuse Texture in standard nomenclature.
  55867. */
  55868. albedoTexture: BaseTexture;
  55869. /**
  55870. * AKA Occlusion Texture in other nomenclature.
  55871. */
  55872. ambientTexture: BaseTexture;
  55873. /**
  55874. * AKA Occlusion Texture Intensity in other nomenclature.
  55875. */
  55876. ambientTextureStrength: number;
  55877. /**
  55878. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55879. * 1 means it completely occludes it
  55880. * 0 mean it has no impact
  55881. */
  55882. ambientTextureImpactOnAnalyticalLights: number;
  55883. /**
  55884. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55885. */
  55886. opacityTexture: BaseTexture;
  55887. /**
  55888. * Stores the reflection values in a texture.
  55889. */
  55890. reflectionTexture: Nullable<BaseTexture>;
  55891. /**
  55892. * Stores the emissive values in a texture.
  55893. */
  55894. emissiveTexture: BaseTexture;
  55895. /**
  55896. * AKA Specular texture in other nomenclature.
  55897. */
  55898. reflectivityTexture: BaseTexture;
  55899. /**
  55900. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55901. */
  55902. metallicTexture: BaseTexture;
  55903. /**
  55904. * Specifies the metallic scalar of the metallic/roughness workflow.
  55905. * Can also be used to scale the metalness values of the metallic texture.
  55906. */
  55907. metallic: Nullable<number>;
  55908. /**
  55909. * Specifies the roughness scalar of the metallic/roughness workflow.
  55910. * Can also be used to scale the roughness values of the metallic texture.
  55911. */
  55912. roughness: Nullable<number>;
  55913. /**
  55914. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55915. * By default the indexOfrefraction is used to compute F0;
  55916. *
  55917. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55918. *
  55919. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55920. * F90 = metallicReflectanceColor;
  55921. */
  55922. metallicF0Factor: number;
  55923. /**
  55924. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55925. * By default the F90 is always 1;
  55926. *
  55927. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55928. *
  55929. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55930. * F90 = metallicReflectanceColor;
  55931. */
  55932. metallicReflectanceColor: Color3;
  55933. /**
  55934. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55935. * This is multiply against the scalar values defined in the material.
  55936. */
  55937. metallicReflectanceTexture: Nullable<BaseTexture>;
  55938. /**
  55939. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55940. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55941. */
  55942. microSurfaceTexture: BaseTexture;
  55943. /**
  55944. * Stores surface normal data used to displace a mesh in a texture.
  55945. */
  55946. bumpTexture: BaseTexture;
  55947. /**
  55948. * Stores the pre-calculated light information of a mesh in a texture.
  55949. */
  55950. lightmapTexture: BaseTexture;
  55951. /**
  55952. * Stores the refracted light information in a texture.
  55953. */
  55954. get refractionTexture(): Nullable<BaseTexture>;
  55955. set refractionTexture(value: Nullable<BaseTexture>);
  55956. /**
  55957. * The color of a material in ambient lighting.
  55958. */
  55959. ambientColor: Color3;
  55960. /**
  55961. * AKA Diffuse Color in other nomenclature.
  55962. */
  55963. albedoColor: Color3;
  55964. /**
  55965. * AKA Specular Color in other nomenclature.
  55966. */
  55967. reflectivityColor: Color3;
  55968. /**
  55969. * The color reflected from the material.
  55970. */
  55971. reflectionColor: Color3;
  55972. /**
  55973. * The color emitted from the material.
  55974. */
  55975. emissiveColor: Color3;
  55976. /**
  55977. * AKA Glossiness in other nomenclature.
  55978. */
  55979. microSurface: number;
  55980. /**
  55981. * Index of refraction of the material base layer.
  55982. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55983. *
  55984. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55985. *
  55986. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55987. */
  55988. get indexOfRefraction(): number;
  55989. set indexOfRefraction(value: number);
  55990. /**
  55991. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55992. */
  55993. get invertRefractionY(): boolean;
  55994. set invertRefractionY(value: boolean);
  55995. /**
  55996. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55997. * Materials half opaque for instance using refraction could benefit from this control.
  55998. */
  55999. get linkRefractionWithTransparency(): boolean;
  56000. set linkRefractionWithTransparency(value: boolean);
  56001. /**
  56002. * If true, the light map contains occlusion information instead of lighting info.
  56003. */
  56004. useLightmapAsShadowmap: boolean;
  56005. /**
  56006. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56007. */
  56008. useAlphaFromAlbedoTexture: boolean;
  56009. /**
  56010. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56011. */
  56012. forceAlphaTest: boolean;
  56013. /**
  56014. * Defines the alpha limits in alpha test mode.
  56015. */
  56016. alphaCutOff: number;
  56017. /**
  56018. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56019. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56020. */
  56021. useSpecularOverAlpha: boolean;
  56022. /**
  56023. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56024. */
  56025. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56026. /**
  56027. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56028. */
  56029. useRoughnessFromMetallicTextureAlpha: boolean;
  56030. /**
  56031. * Specifies if the metallic texture contains the roughness information in its green channel.
  56032. */
  56033. useRoughnessFromMetallicTextureGreen: boolean;
  56034. /**
  56035. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56036. */
  56037. useMetallnessFromMetallicTextureBlue: boolean;
  56038. /**
  56039. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56040. */
  56041. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56042. /**
  56043. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56044. */
  56045. useAmbientInGrayScale: boolean;
  56046. /**
  56047. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56048. * The material will try to infer what glossiness each pixel should be.
  56049. */
  56050. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56051. /**
  56052. * BJS is using an harcoded light falloff based on a manually sets up range.
  56053. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56054. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56055. */
  56056. get usePhysicalLightFalloff(): 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. set usePhysicalLightFalloff(value: boolean);
  56063. /**
  56064. * In order to support the falloff compatibility with gltf, a special mode has been added
  56065. * to reproduce the gltf light falloff.
  56066. */
  56067. get useGLTFLightFalloff(): boolean;
  56068. /**
  56069. * In order to support the falloff compatibility with gltf, a special mode has been added
  56070. * to reproduce the gltf light falloff.
  56071. */
  56072. set useGLTFLightFalloff(value: boolean);
  56073. /**
  56074. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56075. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56076. */
  56077. useRadianceOverAlpha: boolean;
  56078. /**
  56079. * Allows using an object space normal map (instead of tangent space).
  56080. */
  56081. useObjectSpaceNormalMap: boolean;
  56082. /**
  56083. * Allows using the bump map in parallax mode.
  56084. */
  56085. useParallax: boolean;
  56086. /**
  56087. * Allows using the bump map in parallax occlusion mode.
  56088. */
  56089. useParallaxOcclusion: boolean;
  56090. /**
  56091. * Controls the scale bias of the parallax mode.
  56092. */
  56093. parallaxScaleBias: number;
  56094. /**
  56095. * If sets to true, disables all the lights affecting the material.
  56096. */
  56097. disableLighting: boolean;
  56098. /**
  56099. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56100. */
  56101. forceIrradianceInFragment: boolean;
  56102. /**
  56103. * Number of Simultaneous lights allowed on the material.
  56104. */
  56105. maxSimultaneousLights: number;
  56106. /**
  56107. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56108. */
  56109. invertNormalMapX: boolean;
  56110. /**
  56111. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56112. */
  56113. invertNormalMapY: boolean;
  56114. /**
  56115. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56116. */
  56117. twoSidedLighting: boolean;
  56118. /**
  56119. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56120. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56121. */
  56122. useAlphaFresnel: boolean;
  56123. /**
  56124. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56125. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56126. */
  56127. useLinearAlphaFresnel: boolean;
  56128. /**
  56129. * Let user defines the brdf lookup texture used for IBL.
  56130. * A default 8bit version is embedded but you could point at :
  56131. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56132. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56133. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56134. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56135. */
  56136. environmentBRDFTexture: Nullable<BaseTexture>;
  56137. /**
  56138. * Force normal to face away from face.
  56139. */
  56140. forceNormalForward: boolean;
  56141. /**
  56142. * Enables specular anti aliasing in the PBR shader.
  56143. * It will both interacts on the Geometry for analytical and IBL lighting.
  56144. * It also prefilter the roughness map based on the bump values.
  56145. */
  56146. enableSpecularAntiAliasing: boolean;
  56147. /**
  56148. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56149. * makes the reflect vector face the model (under horizon).
  56150. */
  56151. useHorizonOcclusion: boolean;
  56152. /**
  56153. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56154. * too much the area relying on ambient texture to define their ambient occlusion.
  56155. */
  56156. useRadianceOcclusion: boolean;
  56157. /**
  56158. * If set to true, no lighting calculations will be applied.
  56159. */
  56160. unlit: boolean;
  56161. /**
  56162. * Gets the image processing configuration used either in this material.
  56163. */
  56164. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56165. /**
  56166. * Sets the Default image processing configuration used either in the this material.
  56167. *
  56168. * If sets to null, the scene one is in use.
  56169. */
  56170. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56171. /**
  56172. * Gets wether the color curves effect is enabled.
  56173. */
  56174. get cameraColorCurvesEnabled(): boolean;
  56175. /**
  56176. * Sets wether the color curves effect is enabled.
  56177. */
  56178. set cameraColorCurvesEnabled(value: boolean);
  56179. /**
  56180. * Gets wether the color grading effect is enabled.
  56181. */
  56182. get cameraColorGradingEnabled(): boolean;
  56183. /**
  56184. * Gets wether the color grading effect is enabled.
  56185. */
  56186. set cameraColorGradingEnabled(value: boolean);
  56187. /**
  56188. * Gets wether tonemapping is enabled or not.
  56189. */
  56190. get cameraToneMappingEnabled(): boolean;
  56191. /**
  56192. * Sets wether tonemapping is enabled or not
  56193. */
  56194. set cameraToneMappingEnabled(value: boolean);
  56195. /**
  56196. * The camera exposure used on this material.
  56197. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56198. * This corresponds to a photographic exposure.
  56199. */
  56200. get cameraExposure(): number;
  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. set cameraExposure(value: number);
  56207. /**
  56208. * Gets The camera contrast used on this material.
  56209. */
  56210. get cameraContrast(): number;
  56211. /**
  56212. * Sets The camera contrast used on this material.
  56213. */
  56214. set cameraContrast(value: number);
  56215. /**
  56216. * Gets the Color Grading 2D Lookup Texture.
  56217. */
  56218. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56219. /**
  56220. * Sets the Color Grading 2D Lookup Texture.
  56221. */
  56222. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56223. /**
  56224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56226. * 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;
  56227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56228. */
  56229. get cameraColorCurves(): Nullable<ColorCurves>;
  56230. /**
  56231. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56232. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56233. * 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;
  56234. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56235. */
  56236. set cameraColorCurves(value: Nullable<ColorCurves>);
  56237. /**
  56238. * Instantiates a new PBRMaterial instance.
  56239. *
  56240. * @param name The material name
  56241. * @param scene The scene the material will be use in.
  56242. */
  56243. constructor(name: string, scene: Scene);
  56244. /**
  56245. * Returns the name of this material class.
  56246. */
  56247. getClassName(): string;
  56248. /**
  56249. * Makes a duplicate of the current material.
  56250. * @param name - name to use for the new material.
  56251. */
  56252. clone(name: string): PBRMaterial;
  56253. /**
  56254. * Serializes this PBR Material.
  56255. * @returns - An object with the serialized material.
  56256. */
  56257. serialize(): any;
  56258. /**
  56259. * Parses a PBR Material from a serialized object.
  56260. * @param source - Serialized object.
  56261. * @param scene - BJS scene instance.
  56262. * @param rootUrl - url for the scene object
  56263. * @returns - PBRMaterial
  56264. */
  56265. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56266. }
  56267. }
  56268. declare module BABYLON {
  56269. /**
  56270. * Direct draw surface info
  56271. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56272. */
  56273. export interface DDSInfo {
  56274. /**
  56275. * Width of the texture
  56276. */
  56277. width: number;
  56278. /**
  56279. * Width of the texture
  56280. */
  56281. height: number;
  56282. /**
  56283. * Number of Mipmaps for the texture
  56284. * @see https://en.wikipedia.org/wiki/Mipmap
  56285. */
  56286. mipmapCount: number;
  56287. /**
  56288. * If the textures format is a known fourCC format
  56289. * @see https://www.fourcc.org/
  56290. */
  56291. isFourCC: boolean;
  56292. /**
  56293. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56294. */
  56295. isRGB: boolean;
  56296. /**
  56297. * If the texture is a lumincance format
  56298. */
  56299. isLuminance: boolean;
  56300. /**
  56301. * If this is a cube texture
  56302. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56303. */
  56304. isCube: boolean;
  56305. /**
  56306. * If the texture is a compressed format eg. FOURCC_DXT1
  56307. */
  56308. isCompressed: boolean;
  56309. /**
  56310. * The dxgiFormat of the texture
  56311. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56312. */
  56313. dxgiFormat: number;
  56314. /**
  56315. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56316. */
  56317. textureType: number;
  56318. /**
  56319. * Sphericle polynomial created for the dds texture
  56320. */
  56321. sphericalPolynomial?: SphericalPolynomial;
  56322. }
  56323. /**
  56324. * Class used to provide DDS decompression tools
  56325. */
  56326. export class DDSTools {
  56327. /**
  56328. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56329. */
  56330. static StoreLODInAlphaChannel: boolean;
  56331. /**
  56332. * Gets DDS information from an array buffer
  56333. * @param data defines the array buffer view to read data from
  56334. * @returns the DDS information
  56335. */
  56336. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56337. private static _FloatView;
  56338. private static _Int32View;
  56339. private static _ToHalfFloat;
  56340. private static _FromHalfFloat;
  56341. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56342. private static _GetHalfFloatRGBAArrayBuffer;
  56343. private static _GetFloatRGBAArrayBuffer;
  56344. private static _GetFloatAsUIntRGBAArrayBuffer;
  56345. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56346. private static _GetRGBAArrayBuffer;
  56347. private static _ExtractLongWordOrder;
  56348. private static _GetRGBArrayBuffer;
  56349. private static _GetLuminanceArrayBuffer;
  56350. /**
  56351. * Uploads DDS Levels to a Babylon Texture
  56352. * @hidden
  56353. */
  56354. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56355. }
  56356. interface ThinEngine {
  56357. /**
  56358. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56359. * @param rootUrl defines the url where the file to load is located
  56360. * @param scene defines the current scene
  56361. * @param lodScale defines scale to apply to the mip map selection
  56362. * @param lodOffset defines offset to apply to the mip map selection
  56363. * @param onLoad defines an optional callback raised when the texture is loaded
  56364. * @param onError defines an optional callback raised if there is an issue to load the texture
  56365. * @param format defines the format of the data
  56366. * @param forcedExtension defines the extension to use to pick the right loader
  56367. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56368. * @returns the cube texture as an InternalTexture
  56369. */
  56370. 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;
  56371. }
  56372. }
  56373. declare module BABYLON {
  56374. /**
  56375. * Implementation of the DDS Texture Loader.
  56376. * @hidden
  56377. */
  56378. export class _DDSTextureLoader implements IInternalTextureLoader {
  56379. /**
  56380. * Defines wether the loader supports cascade loading the different faces.
  56381. */
  56382. readonly supportCascades: boolean;
  56383. /**
  56384. * This returns if the loader support the current file information.
  56385. * @param extension defines the file extension of the file being loaded
  56386. * @returns true if the loader can load the specified file
  56387. */
  56388. canLoad(extension: string): boolean;
  56389. /**
  56390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56391. * @param data contains the texture data
  56392. * @param texture defines the BabylonJS internal texture
  56393. * @param createPolynomials will be true if polynomials have been requested
  56394. * @param onLoad defines the callback to trigger once the texture is ready
  56395. * @param onError defines the callback to trigger in case of error
  56396. */
  56397. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56398. /**
  56399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56400. * @param data contains the texture data
  56401. * @param texture defines the BabylonJS internal texture
  56402. * @param callback defines the method to call once ready to upload
  56403. */
  56404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56405. }
  56406. }
  56407. declare module BABYLON {
  56408. /**
  56409. * Implementation of the ENV Texture Loader.
  56410. * @hidden
  56411. */
  56412. export class _ENVTextureLoader implements IInternalTextureLoader {
  56413. /**
  56414. * Defines wether the loader supports cascade loading the different faces.
  56415. */
  56416. readonly supportCascades: boolean;
  56417. /**
  56418. * This returns if the loader support the current file information.
  56419. * @param extension defines the file extension of the file being loaded
  56420. * @returns true if the loader can load the specified file
  56421. */
  56422. canLoad(extension: string): boolean;
  56423. /**
  56424. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56425. * @param data contains the texture data
  56426. * @param texture defines the BabylonJS internal texture
  56427. * @param createPolynomials will be true if polynomials have been requested
  56428. * @param onLoad defines the callback to trigger once the texture is ready
  56429. * @param onError defines the callback to trigger in case of error
  56430. */
  56431. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56432. /**
  56433. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56434. * @param data contains the texture data
  56435. * @param texture defines the BabylonJS internal texture
  56436. * @param callback defines the method to call once ready to upload
  56437. */
  56438. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56439. }
  56440. }
  56441. declare module BABYLON {
  56442. /**
  56443. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56444. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56445. */
  56446. export class KhronosTextureContainer {
  56447. /** contents of the KTX container file */
  56448. data: ArrayBufferView;
  56449. private static HEADER_LEN;
  56450. private static COMPRESSED_2D;
  56451. private static COMPRESSED_3D;
  56452. private static TEX_2D;
  56453. private static TEX_3D;
  56454. /**
  56455. * Gets the openGL type
  56456. */
  56457. glType: number;
  56458. /**
  56459. * Gets the openGL type size
  56460. */
  56461. glTypeSize: number;
  56462. /**
  56463. * Gets the openGL format
  56464. */
  56465. glFormat: number;
  56466. /**
  56467. * Gets the openGL internal format
  56468. */
  56469. glInternalFormat: number;
  56470. /**
  56471. * Gets the base internal format
  56472. */
  56473. glBaseInternalFormat: number;
  56474. /**
  56475. * Gets image width in pixel
  56476. */
  56477. pixelWidth: number;
  56478. /**
  56479. * Gets image height in pixel
  56480. */
  56481. pixelHeight: number;
  56482. /**
  56483. * Gets image depth in pixels
  56484. */
  56485. pixelDepth: number;
  56486. /**
  56487. * Gets the number of array elements
  56488. */
  56489. numberOfArrayElements: number;
  56490. /**
  56491. * Gets the number of faces
  56492. */
  56493. numberOfFaces: number;
  56494. /**
  56495. * Gets the number of mipmap levels
  56496. */
  56497. numberOfMipmapLevels: number;
  56498. /**
  56499. * Gets the bytes of key value data
  56500. */
  56501. bytesOfKeyValueData: number;
  56502. /**
  56503. * Gets the load type
  56504. */
  56505. loadType: number;
  56506. /**
  56507. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56508. */
  56509. isInvalid: boolean;
  56510. /**
  56511. * Creates a new KhronosTextureContainer
  56512. * @param data contents of the KTX container file
  56513. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56514. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56515. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56516. */
  56517. constructor(
  56518. /** contents of the KTX container file */
  56519. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56520. /**
  56521. * Uploads KTX content to a Babylon Texture.
  56522. * It is assumed that the texture has already been created & is currently bound
  56523. * @hidden
  56524. */
  56525. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56526. private _upload2DCompressedLevels;
  56527. /**
  56528. * Checks if the given data starts with a KTX file identifier.
  56529. * @param data the data to check
  56530. * @returns true if the data is a KTX file or false otherwise
  56531. */
  56532. static IsValid(data: ArrayBufferView): boolean;
  56533. }
  56534. }
  56535. declare module BABYLON {
  56536. /**
  56537. * Class for loading KTX2 files
  56538. * !!! Experimental Extension Subject to Changes !!!
  56539. * @hidden
  56540. */
  56541. export class KhronosTextureContainer2 {
  56542. private static _ModulePromise;
  56543. private static _TranscodeFormat;
  56544. constructor(engine: ThinEngine);
  56545. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56546. private _determineTranscodeFormat;
  56547. /**
  56548. * Checks if the given data starts with a KTX2 file identifier.
  56549. * @param data the data to check
  56550. * @returns true if the data is a KTX2 file or false otherwise
  56551. */
  56552. static IsValid(data: ArrayBufferView): boolean;
  56553. }
  56554. }
  56555. declare module BABYLON {
  56556. /**
  56557. * Implementation of the KTX Texture Loader.
  56558. * @hidden
  56559. */
  56560. export class _KTXTextureLoader implements IInternalTextureLoader {
  56561. /**
  56562. * Defines wether the loader supports cascade loading the different faces.
  56563. */
  56564. readonly supportCascades: boolean;
  56565. /**
  56566. * This returns if the loader support the current file information.
  56567. * @param extension defines the file extension of the file being loaded
  56568. * @param mimeType defines the optional mime type of the file being loaded
  56569. * @returns true if the loader can load the specified file
  56570. */
  56571. canLoad(extension: string, mimeType?: string): boolean;
  56572. /**
  56573. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56574. * @param data contains the texture data
  56575. * @param texture defines the BabylonJS internal texture
  56576. * @param createPolynomials will be true if polynomials have been requested
  56577. * @param onLoad defines the callback to trigger once the texture is ready
  56578. * @param onError defines the callback to trigger in case of error
  56579. */
  56580. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56581. /**
  56582. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56583. * @param data contains the texture data
  56584. * @param texture defines the BabylonJS internal texture
  56585. * @param callback defines the method to call once ready to upload
  56586. */
  56587. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56588. }
  56589. }
  56590. declare module BABYLON {
  56591. /** @hidden */
  56592. export var _forceSceneHelpersToBundle: boolean;
  56593. interface Scene {
  56594. /**
  56595. * Creates a default light for the scene.
  56596. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56597. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56598. */
  56599. createDefaultLight(replace?: boolean): void;
  56600. /**
  56601. * Creates a default camera for the scene.
  56602. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56603. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56604. * @param replace has default false, when true replaces the active camera in the scene
  56605. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56606. */
  56607. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56608. /**
  56609. * Creates a default camera and a default light.
  56610. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56611. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56612. * @param replace has the default false, when true replaces the active camera/light in the scene
  56613. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56614. */
  56615. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56616. /**
  56617. * Creates a new sky box
  56618. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56619. * @param environmentTexture defines the texture to use as environment texture
  56620. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56621. * @param scale defines the overall scale of the skybox
  56622. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56623. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56624. * @returns a new mesh holding the sky box
  56625. */
  56626. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56627. /**
  56628. * Creates a new environment
  56629. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56630. * @param options defines the options you can use to configure the environment
  56631. * @returns the new EnvironmentHelper
  56632. */
  56633. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56634. /**
  56635. * Creates a new VREXperienceHelper
  56636. * @see https://doc.babylonjs.com/how_to/webvr_helper
  56637. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56638. * @returns a new VREXperienceHelper
  56639. */
  56640. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56641. /**
  56642. * Creates a new WebXRDefaultExperience
  56643. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  56644. * @param options experience options
  56645. * @returns a promise for a new WebXRDefaultExperience
  56646. */
  56647. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56648. }
  56649. }
  56650. declare module BABYLON {
  56651. /**
  56652. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56653. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56654. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56655. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56656. */
  56657. export class VideoDome extends TransformNode {
  56658. /**
  56659. * Define the video source as a Monoscopic panoramic 360 video.
  56660. */
  56661. static readonly MODE_MONOSCOPIC: number;
  56662. /**
  56663. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56664. */
  56665. static readonly MODE_TOPBOTTOM: number;
  56666. /**
  56667. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56668. */
  56669. static readonly MODE_SIDEBYSIDE: number;
  56670. private _halfDome;
  56671. private _useDirectMapping;
  56672. /**
  56673. * The video texture being displayed on the sphere
  56674. */
  56675. protected _videoTexture: VideoTexture;
  56676. /**
  56677. * Gets the video texture being displayed on the sphere
  56678. */
  56679. get videoTexture(): VideoTexture;
  56680. /**
  56681. * The skybox material
  56682. */
  56683. protected _material: BackgroundMaterial;
  56684. /**
  56685. * The surface used for the skybox
  56686. */
  56687. protected _mesh: Mesh;
  56688. /**
  56689. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56690. */
  56691. private _halfDomeMask;
  56692. /**
  56693. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56694. * Also see the options.resolution property.
  56695. */
  56696. get fovMultiplier(): number;
  56697. set fovMultiplier(value: number);
  56698. private _videoMode;
  56699. /**
  56700. * Gets or set the current video mode for the video. It can be:
  56701. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56702. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56703. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56704. */
  56705. get videoMode(): number;
  56706. set videoMode(value: number);
  56707. /**
  56708. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56709. *
  56710. */
  56711. get halfDome(): boolean;
  56712. /**
  56713. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56714. */
  56715. set halfDome(enabled: boolean);
  56716. /**
  56717. * Oberserver used in Stereoscopic VR Mode.
  56718. */
  56719. private _onBeforeCameraRenderObserver;
  56720. /**
  56721. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56722. * @param name Element's name, child elements will append suffixes for their own names.
  56723. * @param urlsOrVideo defines the url(s) or the video element to use
  56724. * @param options An object containing optional or exposed sub element properties
  56725. */
  56726. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56727. resolution?: number;
  56728. clickToPlay?: boolean;
  56729. autoPlay?: boolean;
  56730. loop?: boolean;
  56731. size?: number;
  56732. poster?: string;
  56733. faceForward?: boolean;
  56734. useDirectMapping?: boolean;
  56735. halfDomeMode?: boolean;
  56736. }, scene: Scene);
  56737. private _changeVideoMode;
  56738. /**
  56739. * Releases resources associated with this node.
  56740. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56741. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56742. */
  56743. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56744. }
  56745. }
  56746. declare module BABYLON {
  56747. /**
  56748. * This class can be used to get instrumentation data from a Babylon engine
  56749. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56750. */
  56751. export class EngineInstrumentation implements IDisposable {
  56752. /**
  56753. * Define the instrumented engine.
  56754. */
  56755. engine: Engine;
  56756. private _captureGPUFrameTime;
  56757. private _gpuFrameTimeToken;
  56758. private _gpuFrameTime;
  56759. private _captureShaderCompilationTime;
  56760. private _shaderCompilationTime;
  56761. private _onBeginFrameObserver;
  56762. private _onEndFrameObserver;
  56763. private _onBeforeShaderCompilationObserver;
  56764. private _onAfterShaderCompilationObserver;
  56765. /**
  56766. * Gets the perf counter used for GPU frame time
  56767. */
  56768. get gpuFrameTimeCounter(): PerfCounter;
  56769. /**
  56770. * Gets the GPU frame time capture status
  56771. */
  56772. get captureGPUFrameTime(): boolean;
  56773. /**
  56774. * Enable or disable the GPU frame time capture
  56775. */
  56776. set captureGPUFrameTime(value: boolean);
  56777. /**
  56778. * Gets the perf counter used for shader compilation time
  56779. */
  56780. get shaderCompilationTimeCounter(): PerfCounter;
  56781. /**
  56782. * Gets the shader compilation time capture status
  56783. */
  56784. get captureShaderCompilationTime(): boolean;
  56785. /**
  56786. * Enable or disable the shader compilation time capture
  56787. */
  56788. set captureShaderCompilationTime(value: boolean);
  56789. /**
  56790. * Instantiates a new engine instrumentation.
  56791. * This class can be used to get instrumentation data from a Babylon engine
  56792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56793. * @param engine Defines the engine to instrument
  56794. */
  56795. constructor(
  56796. /**
  56797. * Define the instrumented engine.
  56798. */
  56799. engine: Engine);
  56800. /**
  56801. * Dispose and release associated resources.
  56802. */
  56803. dispose(): void;
  56804. }
  56805. }
  56806. declare module BABYLON {
  56807. /**
  56808. * This class can be used to get instrumentation data from a Babylon engine
  56809. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56810. */
  56811. export class SceneInstrumentation implements IDisposable {
  56812. /**
  56813. * Defines the scene to instrument
  56814. */
  56815. scene: Scene;
  56816. private _captureActiveMeshesEvaluationTime;
  56817. private _activeMeshesEvaluationTime;
  56818. private _captureRenderTargetsRenderTime;
  56819. private _renderTargetsRenderTime;
  56820. private _captureFrameTime;
  56821. private _frameTime;
  56822. private _captureRenderTime;
  56823. private _renderTime;
  56824. private _captureInterFrameTime;
  56825. private _interFrameTime;
  56826. private _captureParticlesRenderTime;
  56827. private _particlesRenderTime;
  56828. private _captureSpritesRenderTime;
  56829. private _spritesRenderTime;
  56830. private _capturePhysicsTime;
  56831. private _physicsTime;
  56832. private _captureAnimationsTime;
  56833. private _animationsTime;
  56834. private _captureCameraRenderTime;
  56835. private _cameraRenderTime;
  56836. private _onBeforeActiveMeshesEvaluationObserver;
  56837. private _onAfterActiveMeshesEvaluationObserver;
  56838. private _onBeforeRenderTargetsRenderObserver;
  56839. private _onAfterRenderTargetsRenderObserver;
  56840. private _onAfterRenderObserver;
  56841. private _onBeforeDrawPhaseObserver;
  56842. private _onAfterDrawPhaseObserver;
  56843. private _onBeforeAnimationsObserver;
  56844. private _onBeforeParticlesRenderingObserver;
  56845. private _onAfterParticlesRenderingObserver;
  56846. private _onBeforeSpritesRenderingObserver;
  56847. private _onAfterSpritesRenderingObserver;
  56848. private _onBeforePhysicsObserver;
  56849. private _onAfterPhysicsObserver;
  56850. private _onAfterAnimationsObserver;
  56851. private _onBeforeCameraRenderObserver;
  56852. private _onAfterCameraRenderObserver;
  56853. /**
  56854. * Gets the perf counter used for active meshes evaluation time
  56855. */
  56856. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56857. /**
  56858. * Gets the active meshes evaluation time capture status
  56859. */
  56860. get captureActiveMeshesEvaluationTime(): boolean;
  56861. /**
  56862. * Enable or disable the active meshes evaluation time capture
  56863. */
  56864. set captureActiveMeshesEvaluationTime(value: boolean);
  56865. /**
  56866. * Gets the perf counter used for render targets render time
  56867. */
  56868. get renderTargetsRenderTimeCounter(): PerfCounter;
  56869. /**
  56870. * Gets the render targets render time capture status
  56871. */
  56872. get captureRenderTargetsRenderTime(): boolean;
  56873. /**
  56874. * Enable or disable the render targets render time capture
  56875. */
  56876. set captureRenderTargetsRenderTime(value: boolean);
  56877. /**
  56878. * Gets the perf counter used for particles render time
  56879. */
  56880. get particlesRenderTimeCounter(): PerfCounter;
  56881. /**
  56882. * Gets the particles render time capture status
  56883. */
  56884. get captureParticlesRenderTime(): boolean;
  56885. /**
  56886. * Enable or disable the particles render time capture
  56887. */
  56888. set captureParticlesRenderTime(value: boolean);
  56889. /**
  56890. * Gets the perf counter used for sprites render time
  56891. */
  56892. get spritesRenderTimeCounter(): PerfCounter;
  56893. /**
  56894. * Gets the sprites render time capture status
  56895. */
  56896. get captureSpritesRenderTime(): boolean;
  56897. /**
  56898. * Enable or disable the sprites render time capture
  56899. */
  56900. set captureSpritesRenderTime(value: boolean);
  56901. /**
  56902. * Gets the perf counter used for physics time
  56903. */
  56904. get physicsTimeCounter(): PerfCounter;
  56905. /**
  56906. * Gets the physics time capture status
  56907. */
  56908. get capturePhysicsTime(): boolean;
  56909. /**
  56910. * Enable or disable the physics time capture
  56911. */
  56912. set capturePhysicsTime(value: boolean);
  56913. /**
  56914. * Gets the perf counter used for animations time
  56915. */
  56916. get animationsTimeCounter(): PerfCounter;
  56917. /**
  56918. * Gets the animations time capture status
  56919. */
  56920. get captureAnimationsTime(): boolean;
  56921. /**
  56922. * Enable or disable the animations time capture
  56923. */
  56924. set captureAnimationsTime(value: boolean);
  56925. /**
  56926. * Gets the perf counter used for frame time capture
  56927. */
  56928. get frameTimeCounter(): PerfCounter;
  56929. /**
  56930. * Gets the frame time capture status
  56931. */
  56932. get captureFrameTime(): boolean;
  56933. /**
  56934. * Enable or disable the frame time capture
  56935. */
  56936. set captureFrameTime(value: boolean);
  56937. /**
  56938. * Gets the perf counter used for inter-frames time capture
  56939. */
  56940. get interFrameTimeCounter(): PerfCounter;
  56941. /**
  56942. * Gets the inter-frames time capture status
  56943. */
  56944. get captureInterFrameTime(): boolean;
  56945. /**
  56946. * Enable or disable the inter-frames time capture
  56947. */
  56948. set captureInterFrameTime(value: boolean);
  56949. /**
  56950. * Gets the perf counter used for render time capture
  56951. */
  56952. get renderTimeCounter(): PerfCounter;
  56953. /**
  56954. * Gets the render time capture status
  56955. */
  56956. get captureRenderTime(): boolean;
  56957. /**
  56958. * Enable or disable the render time capture
  56959. */
  56960. set captureRenderTime(value: boolean);
  56961. /**
  56962. * Gets the perf counter used for camera render time capture
  56963. */
  56964. get cameraRenderTimeCounter(): PerfCounter;
  56965. /**
  56966. * Gets the camera render time capture status
  56967. */
  56968. get captureCameraRenderTime(): boolean;
  56969. /**
  56970. * Enable or disable the camera render time capture
  56971. */
  56972. set captureCameraRenderTime(value: boolean);
  56973. /**
  56974. * Gets the perf counter used for draw calls
  56975. */
  56976. get drawCallsCounter(): PerfCounter;
  56977. /**
  56978. * Instantiates a new scene instrumentation.
  56979. * This class can be used to get instrumentation data from a Babylon engine
  56980. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56981. * @param scene Defines the scene to instrument
  56982. */
  56983. constructor(
  56984. /**
  56985. * Defines the scene to instrument
  56986. */
  56987. scene: Scene);
  56988. /**
  56989. * Dispose and release associated resources.
  56990. */
  56991. dispose(): void;
  56992. }
  56993. }
  56994. declare module BABYLON {
  56995. /** @hidden */
  56996. export var glowMapGenerationPixelShader: {
  56997. name: string;
  56998. shader: string;
  56999. };
  57000. }
  57001. declare module BABYLON {
  57002. /** @hidden */
  57003. export var glowMapGenerationVertexShader: {
  57004. name: string;
  57005. shader: string;
  57006. };
  57007. }
  57008. declare module BABYLON {
  57009. /**
  57010. * Effect layer options. This helps customizing the behaviour
  57011. * of the effect layer.
  57012. */
  57013. export interface IEffectLayerOptions {
  57014. /**
  57015. * Multiplication factor apply to the canvas size to compute the render target size
  57016. * used to generated the objects (the smaller the faster).
  57017. */
  57018. mainTextureRatio: number;
  57019. /**
  57020. * Enforces a fixed size texture to ensure effect stability across devices.
  57021. */
  57022. mainTextureFixedSize?: number;
  57023. /**
  57024. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57025. */
  57026. alphaBlendingMode: number;
  57027. /**
  57028. * The camera attached to the layer.
  57029. */
  57030. camera: Nullable<Camera>;
  57031. /**
  57032. * The rendering group to draw the layer in.
  57033. */
  57034. renderingGroupId: number;
  57035. }
  57036. /**
  57037. * The effect layer Helps adding post process effect blended with the main pass.
  57038. *
  57039. * This can be for instance use to generate glow or higlight effects on the scene.
  57040. *
  57041. * The effect layer class can not be used directly and is intented to inherited from to be
  57042. * customized per effects.
  57043. */
  57044. export abstract class EffectLayer {
  57045. private _vertexBuffers;
  57046. private _indexBuffer;
  57047. private _cachedDefines;
  57048. private _effectLayerMapGenerationEffect;
  57049. private _effectLayerOptions;
  57050. private _mergeEffect;
  57051. protected _scene: Scene;
  57052. protected _engine: Engine;
  57053. protected _maxSize: number;
  57054. protected _mainTextureDesiredSize: ISize;
  57055. protected _mainTexture: RenderTargetTexture;
  57056. protected _shouldRender: boolean;
  57057. protected _postProcesses: PostProcess[];
  57058. protected _textures: BaseTexture[];
  57059. protected _emissiveTextureAndColor: {
  57060. texture: Nullable<BaseTexture>;
  57061. color: Color4;
  57062. };
  57063. /**
  57064. * The name of the layer
  57065. */
  57066. name: string;
  57067. /**
  57068. * The clear color of the texture used to generate the glow map.
  57069. */
  57070. neutralColor: Color4;
  57071. /**
  57072. * Specifies whether the highlight layer is enabled or not.
  57073. */
  57074. isEnabled: boolean;
  57075. /**
  57076. * Gets the camera attached to the layer.
  57077. */
  57078. get camera(): Nullable<Camera>;
  57079. /**
  57080. * Gets the rendering group id the layer should render in.
  57081. */
  57082. get renderingGroupId(): number;
  57083. set renderingGroupId(renderingGroupId: number);
  57084. /**
  57085. * An event triggered when the effect layer has been disposed.
  57086. */
  57087. onDisposeObservable: Observable<EffectLayer>;
  57088. /**
  57089. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57090. */
  57091. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57092. /**
  57093. * An event triggered when the generated texture is being merged in the scene.
  57094. */
  57095. onBeforeComposeObservable: Observable<EffectLayer>;
  57096. /**
  57097. * An event triggered when the mesh is rendered into the effect render target.
  57098. */
  57099. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57100. /**
  57101. * An event triggered after the mesh has been rendered into the effect render target.
  57102. */
  57103. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57104. /**
  57105. * An event triggered when the generated texture has been merged in the scene.
  57106. */
  57107. onAfterComposeObservable: Observable<EffectLayer>;
  57108. /**
  57109. * An event triggered when the efffect layer changes its size.
  57110. */
  57111. onSizeChangedObservable: Observable<EffectLayer>;
  57112. /** @hidden */
  57113. static _SceneComponentInitialization: (scene: Scene) => void;
  57114. /**
  57115. * Instantiates a new effect Layer and references it in the scene.
  57116. * @param name The name of the layer
  57117. * @param scene The scene to use the layer in
  57118. */
  57119. constructor(
  57120. /** The Friendly of the effect in the scene */
  57121. name: string, scene: Scene);
  57122. /**
  57123. * Get the effect name of the layer.
  57124. * @return The effect name
  57125. */
  57126. abstract getEffectName(): string;
  57127. /**
  57128. * Checks for the readiness of the element composing the layer.
  57129. * @param subMesh the mesh to check for
  57130. * @param useInstances specify whether or not to use instances to render the mesh
  57131. * @return true if ready otherwise, false
  57132. */
  57133. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57134. /**
  57135. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57136. * @returns true if the effect requires stencil during the main canvas render pass.
  57137. */
  57138. abstract needStencil(): boolean;
  57139. /**
  57140. * Create the merge effect. This is the shader use to blit the information back
  57141. * to the main canvas at the end of the scene rendering.
  57142. * @returns The effect containing the shader used to merge the effect on the main canvas
  57143. */
  57144. protected abstract _createMergeEffect(): Effect;
  57145. /**
  57146. * Creates the render target textures and post processes used in the effect layer.
  57147. */
  57148. protected abstract _createTextureAndPostProcesses(): void;
  57149. /**
  57150. * Implementation specific of rendering the generating effect on the main canvas.
  57151. * @param effect The effect used to render through
  57152. */
  57153. protected abstract _internalRender(effect: Effect): void;
  57154. /**
  57155. * Sets the required values for both the emissive texture and and the main color.
  57156. */
  57157. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57158. /**
  57159. * Free any resources and references associated to a mesh.
  57160. * Internal use
  57161. * @param mesh The mesh to free.
  57162. */
  57163. abstract _disposeMesh(mesh: Mesh): void;
  57164. /**
  57165. * Serializes this layer (Glow or Highlight for example)
  57166. * @returns a serialized layer object
  57167. */
  57168. abstract serialize?(): any;
  57169. /**
  57170. * Initializes the effect layer with the required options.
  57171. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57172. */
  57173. protected _init(options: Partial<IEffectLayerOptions>): void;
  57174. /**
  57175. * Generates the index buffer of the full screen quad blending to the main canvas.
  57176. */
  57177. private _generateIndexBuffer;
  57178. /**
  57179. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57180. */
  57181. private _generateVertexBuffer;
  57182. /**
  57183. * Sets the main texture desired size which is the closest power of two
  57184. * of the engine canvas size.
  57185. */
  57186. private _setMainTextureSize;
  57187. /**
  57188. * Creates the main texture for the effect layer.
  57189. */
  57190. protected _createMainTexture(): void;
  57191. /**
  57192. * Adds specific effects defines.
  57193. * @param defines The defines to add specifics to.
  57194. */
  57195. protected _addCustomEffectDefines(defines: string[]): void;
  57196. /**
  57197. * Checks for the readiness of the element composing the layer.
  57198. * @param subMesh the mesh to check for
  57199. * @param useInstances specify whether or not to use instances to render the mesh
  57200. * @param emissiveTexture the associated emissive texture used to generate the glow
  57201. * @return true if ready otherwise, false
  57202. */
  57203. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57204. /**
  57205. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57206. */
  57207. render(): void;
  57208. /**
  57209. * Determine if a given mesh will be used in the current effect.
  57210. * @param mesh mesh to test
  57211. * @returns true if the mesh will be used
  57212. */
  57213. hasMesh(mesh: AbstractMesh): boolean;
  57214. /**
  57215. * Returns true if the layer contains information to display, otherwise false.
  57216. * @returns true if the glow layer should be rendered
  57217. */
  57218. shouldRender(): boolean;
  57219. /**
  57220. * Returns true if the mesh should render, otherwise false.
  57221. * @param mesh The mesh to render
  57222. * @returns true if it should render otherwise false
  57223. */
  57224. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57225. /**
  57226. * Returns true if the mesh can be rendered, otherwise false.
  57227. * @param mesh The mesh to render
  57228. * @param material The material used on the mesh
  57229. * @returns true if it can be rendered otherwise false
  57230. */
  57231. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57232. /**
  57233. * Returns true if the mesh should render, otherwise false.
  57234. * @param mesh The mesh to render
  57235. * @returns true if it should render otherwise false
  57236. */
  57237. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57238. /**
  57239. * Renders the submesh passed in parameter to the generation map.
  57240. */
  57241. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57242. /**
  57243. * Defines whether the current material of the mesh should be use to render the effect.
  57244. * @param mesh defines the current mesh to render
  57245. */
  57246. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57247. /**
  57248. * Rebuild the required buffers.
  57249. * @hidden Internal use only.
  57250. */
  57251. _rebuild(): void;
  57252. /**
  57253. * Dispose only the render target textures and post process.
  57254. */
  57255. private _disposeTextureAndPostProcesses;
  57256. /**
  57257. * Dispose the highlight layer and free resources.
  57258. */
  57259. dispose(): void;
  57260. /**
  57261. * Gets the class name of the effect layer
  57262. * @returns the string with the class name of the effect layer
  57263. */
  57264. getClassName(): string;
  57265. /**
  57266. * Creates an effect layer from parsed effect layer data
  57267. * @param parsedEffectLayer defines effect layer data
  57268. * @param scene defines the current scene
  57269. * @param rootUrl defines the root URL containing the effect layer information
  57270. * @returns a parsed effect Layer
  57271. */
  57272. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57273. }
  57274. }
  57275. declare module BABYLON {
  57276. interface AbstractScene {
  57277. /**
  57278. * The list of effect layers (highlights/glow) added to the scene
  57279. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57280. * @see https://doc.babylonjs.com/how_to/glow_layer
  57281. */
  57282. effectLayers: Array<EffectLayer>;
  57283. /**
  57284. * Removes the given effect layer from this scene.
  57285. * @param toRemove defines the effect layer to remove
  57286. * @returns the index of the removed effect layer
  57287. */
  57288. removeEffectLayer(toRemove: EffectLayer): number;
  57289. /**
  57290. * Adds the given effect layer to this scene
  57291. * @param newEffectLayer defines the effect layer to add
  57292. */
  57293. addEffectLayer(newEffectLayer: EffectLayer): void;
  57294. }
  57295. /**
  57296. * Defines the layer scene component responsible to manage any effect layers
  57297. * in a given scene.
  57298. */
  57299. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57300. /**
  57301. * The component name helpfull to identify the component in the list of scene components.
  57302. */
  57303. readonly name: string;
  57304. /**
  57305. * The scene the component belongs to.
  57306. */
  57307. scene: Scene;
  57308. private _engine;
  57309. private _renderEffects;
  57310. private _needStencil;
  57311. private _previousStencilState;
  57312. /**
  57313. * Creates a new instance of the component for the given scene
  57314. * @param scene Defines the scene to register the component in
  57315. */
  57316. constructor(scene: Scene);
  57317. /**
  57318. * Registers the component in a given scene
  57319. */
  57320. register(): void;
  57321. /**
  57322. * Rebuilds the elements related to this component in case of
  57323. * context lost for instance.
  57324. */
  57325. rebuild(): void;
  57326. /**
  57327. * Serializes the component data to the specified json object
  57328. * @param serializationObject The object to serialize to
  57329. */
  57330. serialize(serializationObject: any): void;
  57331. /**
  57332. * Adds all the elements from the container to the scene
  57333. * @param container the container holding the elements
  57334. */
  57335. addFromContainer(container: AbstractScene): void;
  57336. /**
  57337. * Removes all the elements in the container from the scene
  57338. * @param container contains the elements to remove
  57339. * @param dispose if the removed element should be disposed (default: false)
  57340. */
  57341. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57342. /**
  57343. * Disposes the component and the associated ressources.
  57344. */
  57345. dispose(): void;
  57346. private _isReadyForMesh;
  57347. private _renderMainTexture;
  57348. private _setStencil;
  57349. private _setStencilBack;
  57350. private _draw;
  57351. private _drawCamera;
  57352. private _drawRenderingGroup;
  57353. }
  57354. }
  57355. declare module BABYLON {
  57356. /** @hidden */
  57357. export var glowMapMergePixelShader: {
  57358. name: string;
  57359. shader: string;
  57360. };
  57361. }
  57362. declare module BABYLON {
  57363. /** @hidden */
  57364. export var glowMapMergeVertexShader: {
  57365. name: string;
  57366. shader: string;
  57367. };
  57368. }
  57369. declare module BABYLON {
  57370. interface AbstractScene {
  57371. /**
  57372. * Return a the first highlight layer of the scene with a given name.
  57373. * @param name The name of the highlight layer to look for.
  57374. * @return The highlight layer if found otherwise null.
  57375. */
  57376. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57377. }
  57378. /**
  57379. * Glow layer options. This helps customizing the behaviour
  57380. * of the glow layer.
  57381. */
  57382. export interface IGlowLayerOptions {
  57383. /**
  57384. * Multiplication factor apply to the canvas size to compute the render target size
  57385. * used to generated the glowing objects (the smaller the faster).
  57386. */
  57387. mainTextureRatio: number;
  57388. /**
  57389. * Enforces a fixed size texture to ensure resize independant blur.
  57390. */
  57391. mainTextureFixedSize?: number;
  57392. /**
  57393. * How big is the kernel of the blur texture.
  57394. */
  57395. blurKernelSize: number;
  57396. /**
  57397. * The camera attached to the layer.
  57398. */
  57399. camera: Nullable<Camera>;
  57400. /**
  57401. * Enable MSAA by chosing the number of samples.
  57402. */
  57403. mainTextureSamples?: number;
  57404. /**
  57405. * The rendering group to draw the layer in.
  57406. */
  57407. renderingGroupId: number;
  57408. }
  57409. /**
  57410. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57411. *
  57412. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57413. *
  57414. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57415. */
  57416. export class GlowLayer extends EffectLayer {
  57417. /**
  57418. * Effect Name of the layer.
  57419. */
  57420. static readonly EffectName: string;
  57421. /**
  57422. * The default blur kernel size used for the glow.
  57423. */
  57424. static DefaultBlurKernelSize: number;
  57425. /**
  57426. * The default texture size ratio used for the glow.
  57427. */
  57428. static DefaultTextureRatio: number;
  57429. /**
  57430. * Sets the kernel size of the blur.
  57431. */
  57432. set blurKernelSize(value: number);
  57433. /**
  57434. * Gets the kernel size of the blur.
  57435. */
  57436. get blurKernelSize(): number;
  57437. /**
  57438. * Sets the glow intensity.
  57439. */
  57440. set intensity(value: number);
  57441. /**
  57442. * Gets the glow intensity.
  57443. */
  57444. get intensity(): number;
  57445. private _options;
  57446. private _intensity;
  57447. private _horizontalBlurPostprocess1;
  57448. private _verticalBlurPostprocess1;
  57449. private _horizontalBlurPostprocess2;
  57450. private _verticalBlurPostprocess2;
  57451. private _blurTexture1;
  57452. private _blurTexture2;
  57453. private _postProcesses1;
  57454. private _postProcesses2;
  57455. private _includedOnlyMeshes;
  57456. private _excludedMeshes;
  57457. private _meshesUsingTheirOwnMaterials;
  57458. /**
  57459. * Callback used to let the user override the color selection on a per mesh basis
  57460. */
  57461. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57462. /**
  57463. * Callback used to let the user override the texture selection on a per mesh basis
  57464. */
  57465. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57466. /**
  57467. * Instantiates a new glow Layer and references it to the scene.
  57468. * @param name The name of the layer
  57469. * @param scene The scene to use the layer in
  57470. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57471. */
  57472. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57473. /**
  57474. * Get the effect name of the layer.
  57475. * @return The effect name
  57476. */
  57477. getEffectName(): string;
  57478. /**
  57479. * Create the merge effect. This is the shader use to blit the information back
  57480. * to the main canvas at the end of the scene rendering.
  57481. */
  57482. protected _createMergeEffect(): Effect;
  57483. /**
  57484. * Creates the render target textures and post processes used in the glow layer.
  57485. */
  57486. protected _createTextureAndPostProcesses(): void;
  57487. /**
  57488. * Checks for the readiness of the element composing the layer.
  57489. * @param subMesh the mesh to check for
  57490. * @param useInstances specify wether or not to use instances to render the mesh
  57491. * @param emissiveTexture the associated emissive texture used to generate the glow
  57492. * @return true if ready otherwise, false
  57493. */
  57494. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57495. /**
  57496. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57497. */
  57498. needStencil(): boolean;
  57499. /**
  57500. * Returns true if the mesh can be rendered, otherwise false.
  57501. * @param mesh The mesh to render
  57502. * @param material The material used on the mesh
  57503. * @returns true if it can be rendered otherwise false
  57504. */
  57505. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57506. /**
  57507. * Implementation specific of rendering the generating effect on the main canvas.
  57508. * @param effect The effect used to render through
  57509. */
  57510. protected _internalRender(effect: Effect): void;
  57511. /**
  57512. * Sets the required values for both the emissive texture and and the main color.
  57513. */
  57514. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57515. /**
  57516. * Returns true if the mesh should render, otherwise false.
  57517. * @param mesh The mesh to render
  57518. * @returns true if it should render otherwise false
  57519. */
  57520. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57521. /**
  57522. * Adds specific effects defines.
  57523. * @param defines The defines to add specifics to.
  57524. */
  57525. protected _addCustomEffectDefines(defines: string[]): void;
  57526. /**
  57527. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57528. * @param mesh The mesh to exclude from the glow layer
  57529. */
  57530. addExcludedMesh(mesh: Mesh): void;
  57531. /**
  57532. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57533. * @param mesh The mesh to remove
  57534. */
  57535. removeExcludedMesh(mesh: Mesh): void;
  57536. /**
  57537. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57538. * @param mesh The mesh to include in the glow layer
  57539. */
  57540. addIncludedOnlyMesh(mesh: Mesh): void;
  57541. /**
  57542. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57543. * @param mesh The mesh to remove
  57544. */
  57545. removeIncludedOnlyMesh(mesh: Mesh): void;
  57546. /**
  57547. * Determine if a given mesh will be used in the glow layer
  57548. * @param mesh The mesh to test
  57549. * @returns true if the mesh will be highlighted by the current glow layer
  57550. */
  57551. hasMesh(mesh: AbstractMesh): boolean;
  57552. /**
  57553. * Defines whether the current material of the mesh should be use to render the effect.
  57554. * @param mesh defines the current mesh to render
  57555. */
  57556. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57557. /**
  57558. * Add a mesh to be rendered through its own material and not with emissive only.
  57559. * @param mesh The mesh for which we need to use its material
  57560. */
  57561. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57562. /**
  57563. * Remove a mesh from being rendered through its own material and not with emissive only.
  57564. * @param mesh The mesh for which we need to not use its material
  57565. */
  57566. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57567. /**
  57568. * Free any resources and references associated to a mesh.
  57569. * Internal use
  57570. * @param mesh The mesh to free.
  57571. * @hidden
  57572. */
  57573. _disposeMesh(mesh: Mesh): void;
  57574. /**
  57575. * Gets the class name of the effect layer
  57576. * @returns the string with the class name of the effect layer
  57577. */
  57578. getClassName(): string;
  57579. /**
  57580. * Serializes this glow layer
  57581. * @returns a serialized glow layer object
  57582. */
  57583. serialize(): any;
  57584. /**
  57585. * Creates a Glow Layer from parsed glow layer data
  57586. * @param parsedGlowLayer defines glow layer data
  57587. * @param scene defines the current scene
  57588. * @param rootUrl defines the root URL containing the glow layer information
  57589. * @returns a parsed Glow Layer
  57590. */
  57591. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57592. }
  57593. }
  57594. declare module BABYLON {
  57595. /** @hidden */
  57596. export var glowBlurPostProcessPixelShader: {
  57597. name: string;
  57598. shader: string;
  57599. };
  57600. }
  57601. declare module BABYLON {
  57602. interface AbstractScene {
  57603. /**
  57604. * Return a the first highlight layer of the scene with a given name.
  57605. * @param name The name of the highlight layer to look for.
  57606. * @return The highlight layer if found otherwise null.
  57607. */
  57608. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57609. }
  57610. /**
  57611. * Highlight layer options. This helps customizing the behaviour
  57612. * of the highlight layer.
  57613. */
  57614. export interface IHighlightLayerOptions {
  57615. /**
  57616. * Multiplication factor apply to the canvas size to compute the render target size
  57617. * used to generated the glowing objects (the smaller the faster).
  57618. */
  57619. mainTextureRatio: number;
  57620. /**
  57621. * Enforces a fixed size texture to ensure resize independant blur.
  57622. */
  57623. mainTextureFixedSize?: number;
  57624. /**
  57625. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57626. * of the picture to blur (the smaller the faster).
  57627. */
  57628. blurTextureSizeRatio: number;
  57629. /**
  57630. * How big in texel of the blur texture is the vertical blur.
  57631. */
  57632. blurVerticalSize: number;
  57633. /**
  57634. * How big in texel of the blur texture is the horizontal blur.
  57635. */
  57636. blurHorizontalSize: number;
  57637. /**
  57638. * Alpha blending mode used to apply the blur. Default is combine.
  57639. */
  57640. alphaBlendingMode: number;
  57641. /**
  57642. * The camera attached to the layer.
  57643. */
  57644. camera: Nullable<Camera>;
  57645. /**
  57646. * Should we display highlight as a solid stroke?
  57647. */
  57648. isStroke?: boolean;
  57649. /**
  57650. * The rendering group to draw the layer in.
  57651. */
  57652. renderingGroupId: number;
  57653. }
  57654. /**
  57655. * The highlight layer Helps adding a glow effect around a mesh.
  57656. *
  57657. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57658. * glowy meshes to your scene.
  57659. *
  57660. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57661. */
  57662. export class HighlightLayer extends EffectLayer {
  57663. name: string;
  57664. /**
  57665. * Effect Name of the highlight layer.
  57666. */
  57667. static readonly EffectName: string;
  57668. /**
  57669. * The neutral color used during the preparation of the glow effect.
  57670. * This is black by default as the blend operation is a blend operation.
  57671. */
  57672. static NeutralColor: Color4;
  57673. /**
  57674. * Stencil value used for glowing meshes.
  57675. */
  57676. static GlowingMeshStencilReference: number;
  57677. /**
  57678. * Stencil value used for the other meshes in the scene.
  57679. */
  57680. static NormalMeshStencilReference: number;
  57681. /**
  57682. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57683. */
  57684. innerGlow: boolean;
  57685. /**
  57686. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57687. */
  57688. outerGlow: boolean;
  57689. /**
  57690. * Specifies the horizontal size of the blur.
  57691. */
  57692. set blurHorizontalSize(value: number);
  57693. /**
  57694. * Specifies the vertical size of the blur.
  57695. */
  57696. set blurVerticalSize(value: number);
  57697. /**
  57698. * Gets the horizontal size of the blur.
  57699. */
  57700. get blurHorizontalSize(): number;
  57701. /**
  57702. * Gets the vertical size of the blur.
  57703. */
  57704. get blurVerticalSize(): number;
  57705. /**
  57706. * An event triggered when the highlight layer is being blurred.
  57707. */
  57708. onBeforeBlurObservable: Observable<HighlightLayer>;
  57709. /**
  57710. * An event triggered when the highlight layer has been blurred.
  57711. */
  57712. onAfterBlurObservable: Observable<HighlightLayer>;
  57713. private _instanceGlowingMeshStencilReference;
  57714. private _options;
  57715. private _downSamplePostprocess;
  57716. private _horizontalBlurPostprocess;
  57717. private _verticalBlurPostprocess;
  57718. private _blurTexture;
  57719. private _meshes;
  57720. private _excludedMeshes;
  57721. /**
  57722. * Instantiates a new highlight Layer and references it to the scene..
  57723. * @param name The name of the layer
  57724. * @param scene The scene to use the layer in
  57725. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57726. */
  57727. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57728. /**
  57729. * Get the effect name of the layer.
  57730. * @return The effect name
  57731. */
  57732. getEffectName(): string;
  57733. /**
  57734. * Create the merge effect. This is the shader use to blit the information back
  57735. * to the main canvas at the end of the scene rendering.
  57736. */
  57737. protected _createMergeEffect(): Effect;
  57738. /**
  57739. * Creates the render target textures and post processes used in the highlight layer.
  57740. */
  57741. protected _createTextureAndPostProcesses(): void;
  57742. /**
  57743. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57744. */
  57745. needStencil(): boolean;
  57746. /**
  57747. * Checks for the readiness of the element composing the layer.
  57748. * @param subMesh the mesh to check for
  57749. * @param useInstances specify wether or not to use instances to render the mesh
  57750. * @param emissiveTexture the associated emissive texture used to generate the glow
  57751. * @return true if ready otherwise, false
  57752. */
  57753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57754. /**
  57755. * Implementation specific of rendering the generating effect on the main canvas.
  57756. * @param effect The effect used to render through
  57757. */
  57758. protected _internalRender(effect: Effect): void;
  57759. /**
  57760. * Returns true if the layer contains information to display, otherwise false.
  57761. */
  57762. shouldRender(): boolean;
  57763. /**
  57764. * Returns true if the mesh should render, otherwise false.
  57765. * @param mesh The mesh to render
  57766. * @returns true if it should render otherwise false
  57767. */
  57768. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57769. /**
  57770. * Returns true if the mesh can be rendered, otherwise false.
  57771. * @param mesh The mesh to render
  57772. * @param material The material used on the mesh
  57773. * @returns true if it can be rendered otherwise false
  57774. */
  57775. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57776. /**
  57777. * Adds specific effects defines.
  57778. * @param defines The defines to add specifics to.
  57779. */
  57780. protected _addCustomEffectDefines(defines: string[]): void;
  57781. /**
  57782. * Sets the required values for both the emissive texture and and the main color.
  57783. */
  57784. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57785. /**
  57786. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57787. * @param mesh The mesh to exclude from the highlight layer
  57788. */
  57789. addExcludedMesh(mesh: Mesh): void;
  57790. /**
  57791. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57792. * @param mesh The mesh to highlight
  57793. */
  57794. removeExcludedMesh(mesh: Mesh): void;
  57795. /**
  57796. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57797. * @param mesh mesh to test
  57798. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57799. */
  57800. hasMesh(mesh: AbstractMesh): boolean;
  57801. /**
  57802. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57803. * @param mesh The mesh to highlight
  57804. * @param color The color of the highlight
  57805. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57806. */
  57807. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57808. /**
  57809. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57810. * @param mesh The mesh to highlight
  57811. */
  57812. removeMesh(mesh: Mesh): void;
  57813. /**
  57814. * Remove all the meshes currently referenced in the highlight layer
  57815. */
  57816. removeAllMeshes(): void;
  57817. /**
  57818. * Force the stencil to the normal expected value for none glowing parts
  57819. */
  57820. private _defaultStencilReference;
  57821. /**
  57822. * Free any resources and references associated to a mesh.
  57823. * Internal use
  57824. * @param mesh The mesh to free.
  57825. * @hidden
  57826. */
  57827. _disposeMesh(mesh: Mesh): void;
  57828. /**
  57829. * Dispose the highlight layer and free resources.
  57830. */
  57831. dispose(): void;
  57832. /**
  57833. * Gets the class name of the effect layer
  57834. * @returns the string with the class name of the effect layer
  57835. */
  57836. getClassName(): string;
  57837. /**
  57838. * Serializes this Highlight layer
  57839. * @returns a serialized Highlight layer object
  57840. */
  57841. serialize(): any;
  57842. /**
  57843. * Creates a Highlight layer from parsed Highlight layer data
  57844. * @param parsedHightlightLayer defines the Highlight layer data
  57845. * @param scene defines the current scene
  57846. * @param rootUrl defines the root URL containing the Highlight layer information
  57847. * @returns a parsed Highlight layer
  57848. */
  57849. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57850. }
  57851. }
  57852. declare module BABYLON {
  57853. interface AbstractScene {
  57854. /**
  57855. * The list of layers (background and foreground) of the scene
  57856. */
  57857. layers: Array<Layer>;
  57858. }
  57859. /**
  57860. * Defines the layer scene component responsible to manage any layers
  57861. * in a given scene.
  57862. */
  57863. export class LayerSceneComponent implements ISceneComponent {
  57864. /**
  57865. * The component name helpfull to identify the component in the list of scene components.
  57866. */
  57867. readonly name: string;
  57868. /**
  57869. * The scene the component belongs to.
  57870. */
  57871. scene: Scene;
  57872. private _engine;
  57873. /**
  57874. * Creates a new instance of the component for the given scene
  57875. * @param scene Defines the scene to register the component in
  57876. */
  57877. constructor(scene: Scene);
  57878. /**
  57879. * Registers the component in a given scene
  57880. */
  57881. register(): void;
  57882. /**
  57883. * Rebuilds the elements related to this component in case of
  57884. * context lost for instance.
  57885. */
  57886. rebuild(): void;
  57887. /**
  57888. * Disposes the component and the associated ressources.
  57889. */
  57890. dispose(): void;
  57891. private _draw;
  57892. private _drawCameraPredicate;
  57893. private _drawCameraBackground;
  57894. private _drawCameraForeground;
  57895. private _drawRenderTargetPredicate;
  57896. private _drawRenderTargetBackground;
  57897. private _drawRenderTargetForeground;
  57898. /**
  57899. * Adds all the elements from the container to the scene
  57900. * @param container the container holding the elements
  57901. */
  57902. addFromContainer(container: AbstractScene): void;
  57903. /**
  57904. * Removes all the elements in the container from the scene
  57905. * @param container contains the elements to remove
  57906. * @param dispose if the removed element should be disposed (default: false)
  57907. */
  57908. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57909. }
  57910. }
  57911. declare module BABYLON {
  57912. /** @hidden */
  57913. export var layerPixelShader: {
  57914. name: string;
  57915. shader: string;
  57916. };
  57917. }
  57918. declare module BABYLON {
  57919. /** @hidden */
  57920. export var layerVertexShader: {
  57921. name: string;
  57922. shader: string;
  57923. };
  57924. }
  57925. declare module BABYLON {
  57926. /**
  57927. * This represents a full screen 2d layer.
  57928. * This can be useful to display a picture in the background of your scene for instance.
  57929. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57930. */
  57931. export class Layer {
  57932. /**
  57933. * Define the name of the layer.
  57934. */
  57935. name: string;
  57936. /**
  57937. * Define the texture the layer should display.
  57938. */
  57939. texture: Nullable<Texture>;
  57940. /**
  57941. * Is the layer in background or foreground.
  57942. */
  57943. isBackground: boolean;
  57944. /**
  57945. * Define the color of the layer (instead of texture).
  57946. */
  57947. color: Color4;
  57948. /**
  57949. * Define the scale of the layer in order to zoom in out of the texture.
  57950. */
  57951. scale: Vector2;
  57952. /**
  57953. * Define an offset for the layer in order to shift the texture.
  57954. */
  57955. offset: Vector2;
  57956. /**
  57957. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57958. */
  57959. alphaBlendingMode: number;
  57960. /**
  57961. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57962. * Alpha test will not mix with the background color in case of transparency.
  57963. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57964. */
  57965. alphaTest: boolean;
  57966. /**
  57967. * Define a mask to restrict the layer to only some of the scene cameras.
  57968. */
  57969. layerMask: number;
  57970. /**
  57971. * Define the list of render target the layer is visible into.
  57972. */
  57973. renderTargetTextures: RenderTargetTexture[];
  57974. /**
  57975. * Define if the layer is only used in renderTarget or if it also
  57976. * renders in the main frame buffer of the canvas.
  57977. */
  57978. renderOnlyInRenderTargetTextures: boolean;
  57979. private _scene;
  57980. private _vertexBuffers;
  57981. private _indexBuffer;
  57982. private _effect;
  57983. private _previousDefines;
  57984. /**
  57985. * An event triggered when the layer is disposed.
  57986. */
  57987. onDisposeObservable: Observable<Layer>;
  57988. private _onDisposeObserver;
  57989. /**
  57990. * Back compatibility with callback before the onDisposeObservable existed.
  57991. * The set callback will be triggered when the layer has been disposed.
  57992. */
  57993. set onDispose(callback: () => void);
  57994. /**
  57995. * An event triggered before rendering the scene
  57996. */
  57997. onBeforeRenderObservable: Observable<Layer>;
  57998. private _onBeforeRenderObserver;
  57999. /**
  58000. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58001. * The set callback will be triggered just before rendering the layer.
  58002. */
  58003. set onBeforeRender(callback: () => void);
  58004. /**
  58005. * An event triggered after rendering the scene
  58006. */
  58007. onAfterRenderObservable: Observable<Layer>;
  58008. private _onAfterRenderObserver;
  58009. /**
  58010. * Back compatibility with callback before the onAfterRenderObservable existed.
  58011. * The set callback will be triggered just after rendering the layer.
  58012. */
  58013. set onAfterRender(callback: () => void);
  58014. /**
  58015. * Instantiates a new layer.
  58016. * This represents a full screen 2d layer.
  58017. * This can be useful to display a picture in the background of your scene for instance.
  58018. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58019. * @param name Define the name of the layer in the scene
  58020. * @param imgUrl Define the url of the texture to display in the layer
  58021. * @param scene Define the scene the layer belongs to
  58022. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58023. * @param color Defines a color for the layer
  58024. */
  58025. constructor(
  58026. /**
  58027. * Define the name of the layer.
  58028. */
  58029. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58030. private _createIndexBuffer;
  58031. /** @hidden */
  58032. _rebuild(): void;
  58033. /**
  58034. * Renders the layer in the scene.
  58035. */
  58036. render(): void;
  58037. /**
  58038. * Disposes and releases the associated ressources.
  58039. */
  58040. dispose(): void;
  58041. }
  58042. }
  58043. declare module BABYLON {
  58044. /** @hidden */
  58045. export var lensFlarePixelShader: {
  58046. name: string;
  58047. shader: string;
  58048. };
  58049. }
  58050. declare module BABYLON {
  58051. /** @hidden */
  58052. export var lensFlareVertexShader: {
  58053. name: string;
  58054. shader: string;
  58055. };
  58056. }
  58057. declare module BABYLON {
  58058. /**
  58059. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58060. * It is usually composed of several `lensFlare`.
  58061. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58062. */
  58063. export class LensFlareSystem {
  58064. /**
  58065. * Define the name of the lens flare system
  58066. */
  58067. name: string;
  58068. /**
  58069. * List of lens flares used in this system.
  58070. */
  58071. lensFlares: LensFlare[];
  58072. /**
  58073. * Define a limit from the border the lens flare can be visible.
  58074. */
  58075. borderLimit: number;
  58076. /**
  58077. * Define a viewport border we do not want to see the lens flare in.
  58078. */
  58079. viewportBorder: number;
  58080. /**
  58081. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58082. */
  58083. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58084. /**
  58085. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58086. */
  58087. layerMask: number;
  58088. /**
  58089. * Define the id of the lens flare system in the scene.
  58090. * (equal to name by default)
  58091. */
  58092. id: string;
  58093. private _scene;
  58094. private _emitter;
  58095. private _vertexBuffers;
  58096. private _indexBuffer;
  58097. private _effect;
  58098. private _positionX;
  58099. private _positionY;
  58100. private _isEnabled;
  58101. /** @hidden */
  58102. static _SceneComponentInitialization: (scene: Scene) => void;
  58103. /**
  58104. * Instantiates a lens flare system.
  58105. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58106. * It is usually composed of several `lensFlare`.
  58107. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58108. * @param name Define the name of the lens flare system in the scene
  58109. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58110. * @param scene Define the scene the lens flare system belongs to
  58111. */
  58112. constructor(
  58113. /**
  58114. * Define the name of the lens flare system
  58115. */
  58116. name: string, emitter: any, scene: Scene);
  58117. /**
  58118. * Define if the lens flare system is enabled.
  58119. */
  58120. get isEnabled(): boolean;
  58121. set isEnabled(value: boolean);
  58122. /**
  58123. * Get the scene the effects belongs to.
  58124. * @returns the scene holding the lens flare system
  58125. */
  58126. getScene(): Scene;
  58127. /**
  58128. * Get the emitter of the lens flare system.
  58129. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58130. * @returns the emitter of the lens flare system
  58131. */
  58132. getEmitter(): any;
  58133. /**
  58134. * Set 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. * @param newEmitter Define the new emitter of the system
  58137. */
  58138. setEmitter(newEmitter: any): void;
  58139. /**
  58140. * Get the lens flare system emitter position.
  58141. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58142. * @returns the position
  58143. */
  58144. getEmitterPosition(): Vector3;
  58145. /**
  58146. * @hidden
  58147. */
  58148. computeEffectivePosition(globalViewport: Viewport): boolean;
  58149. /** @hidden */
  58150. _isVisible(): boolean;
  58151. /**
  58152. * @hidden
  58153. */
  58154. render(): boolean;
  58155. /**
  58156. * Dispose and release the lens flare with its associated resources.
  58157. */
  58158. dispose(): void;
  58159. /**
  58160. * Parse a lens flare system from a JSON repressentation
  58161. * @param parsedLensFlareSystem Define the JSON to parse
  58162. * @param scene Define the scene the parsed system should be instantiated in
  58163. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58164. * @returns the parsed system
  58165. */
  58166. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58167. /**
  58168. * Serialize the current Lens Flare System into a JSON representation.
  58169. * @returns the serialized JSON
  58170. */
  58171. serialize(): any;
  58172. }
  58173. }
  58174. declare module BABYLON {
  58175. /**
  58176. * This represents one of the lens effect in a `lensFlareSystem`.
  58177. * It controls one of the indiviual texture used in the effect.
  58178. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58179. */
  58180. export class LensFlare {
  58181. /**
  58182. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58183. */
  58184. size: number;
  58185. /**
  58186. * 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.
  58187. */
  58188. position: number;
  58189. /**
  58190. * Define the lens color.
  58191. */
  58192. color: Color3;
  58193. /**
  58194. * Define the lens texture.
  58195. */
  58196. texture: Nullable<Texture>;
  58197. /**
  58198. * Define the alpha mode to render this particular lens.
  58199. */
  58200. alphaMode: number;
  58201. private _system;
  58202. /**
  58203. * Creates a new Lens Flare.
  58204. * This represents one of the lens effect in a `lensFlareSystem`.
  58205. * It controls one of the indiviual texture used in the effect.
  58206. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58207. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58208. * @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.
  58209. * @param color Define the lens color
  58210. * @param imgUrl Define the lens texture url
  58211. * @param system Define the `lensFlareSystem` this flare is part of
  58212. * @returns The newly created Lens Flare
  58213. */
  58214. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58215. /**
  58216. * Instantiates a new Lens Flare.
  58217. * This represents one of the lens effect in a `lensFlareSystem`.
  58218. * It controls one of the indiviual texture used in the effect.
  58219. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58220. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58221. * @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.
  58222. * @param color Define the lens color
  58223. * @param imgUrl Define the lens texture url
  58224. * @param system Define the `lensFlareSystem` this flare is part of
  58225. */
  58226. constructor(
  58227. /**
  58228. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58229. */
  58230. size: number,
  58231. /**
  58232. * 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.
  58233. */
  58234. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58235. /**
  58236. * Dispose and release the lens flare with its associated resources.
  58237. */
  58238. dispose(): void;
  58239. }
  58240. }
  58241. declare module BABYLON {
  58242. interface AbstractScene {
  58243. /**
  58244. * The list of lens flare system added to the scene
  58245. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58246. */
  58247. lensFlareSystems: Array<LensFlareSystem>;
  58248. /**
  58249. * Removes the given lens flare system from this scene.
  58250. * @param toRemove The lens flare system to remove
  58251. * @returns The index of the removed lens flare system
  58252. */
  58253. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58254. /**
  58255. * Adds the given lens flare system to this scene
  58256. * @param newLensFlareSystem The lens flare system to add
  58257. */
  58258. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58259. /**
  58260. * Gets a lens flare system using its name
  58261. * @param name defines the name to look for
  58262. * @returns the lens flare system or null if not found
  58263. */
  58264. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58265. /**
  58266. * Gets a lens flare system using its id
  58267. * @param id defines the id to look for
  58268. * @returns the lens flare system or null if not found
  58269. */
  58270. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58271. }
  58272. /**
  58273. * Defines the lens flare scene component responsible to manage any lens flares
  58274. * in a given scene.
  58275. */
  58276. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58277. /**
  58278. * The component name helpfull to identify the component in the list of scene components.
  58279. */
  58280. readonly name: string;
  58281. /**
  58282. * The scene the component belongs to.
  58283. */
  58284. scene: Scene;
  58285. /**
  58286. * Creates a new instance of the component for the given scene
  58287. * @param scene Defines the scene to register the component in
  58288. */
  58289. constructor(scene: Scene);
  58290. /**
  58291. * Registers the component in a given scene
  58292. */
  58293. register(): void;
  58294. /**
  58295. * Rebuilds the elements related to this component in case of
  58296. * context lost for instance.
  58297. */
  58298. rebuild(): void;
  58299. /**
  58300. * Adds all the elements from the container to the scene
  58301. * @param container the container holding the elements
  58302. */
  58303. addFromContainer(container: AbstractScene): void;
  58304. /**
  58305. * Removes all the elements in the container from the scene
  58306. * @param container contains the elements to remove
  58307. * @param dispose if the removed element should be disposed (default: false)
  58308. */
  58309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58310. /**
  58311. * Serializes the component data to the specified json object
  58312. * @param serializationObject The object to serialize to
  58313. */
  58314. serialize(serializationObject: any): void;
  58315. /**
  58316. * Disposes the component and the associated ressources.
  58317. */
  58318. dispose(): void;
  58319. private _draw;
  58320. }
  58321. }
  58322. declare module BABYLON {
  58323. /** @hidden */
  58324. export var depthPixelShader: {
  58325. name: string;
  58326. shader: string;
  58327. };
  58328. }
  58329. declare module BABYLON {
  58330. /** @hidden */
  58331. export var depthVertexShader: {
  58332. name: string;
  58333. shader: string;
  58334. };
  58335. }
  58336. declare module BABYLON {
  58337. /**
  58338. * This represents a depth renderer in Babylon.
  58339. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58340. */
  58341. export class DepthRenderer {
  58342. private _scene;
  58343. private _depthMap;
  58344. private _effect;
  58345. private readonly _storeNonLinearDepth;
  58346. private readonly _clearColor;
  58347. /** Get if the depth renderer is using packed depth or not */
  58348. readonly isPacked: boolean;
  58349. private _cachedDefines;
  58350. private _camera;
  58351. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58352. enabled: boolean;
  58353. /**
  58354. * Specifiess that the depth renderer will only be used within
  58355. * the camera it is created for.
  58356. * This can help forcing its rendering during the camera processing.
  58357. */
  58358. useOnlyInActiveCamera: boolean;
  58359. /** @hidden */
  58360. static _SceneComponentInitialization: (scene: Scene) => void;
  58361. /**
  58362. * Instantiates a depth renderer
  58363. * @param scene The scene the renderer belongs to
  58364. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58365. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58366. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58367. */
  58368. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58369. /**
  58370. * Creates the depth rendering effect and checks if the effect is ready.
  58371. * @param subMesh The submesh to be used to render the depth map of
  58372. * @param useInstances If multiple world instances should be used
  58373. * @returns if the depth renderer is ready to render the depth map
  58374. */
  58375. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58376. /**
  58377. * Gets the texture which the depth map will be written to.
  58378. * @returns The depth map texture
  58379. */
  58380. getDepthMap(): RenderTargetTexture;
  58381. /**
  58382. * Disposes of the depth renderer.
  58383. */
  58384. dispose(): void;
  58385. }
  58386. }
  58387. declare module BABYLON {
  58388. /** @hidden */
  58389. export var minmaxReduxPixelShader: {
  58390. name: string;
  58391. shader: string;
  58392. };
  58393. }
  58394. declare module BABYLON {
  58395. /**
  58396. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58397. * and maximum values from all values of the texture.
  58398. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58399. * The source values are read from the red channel of the texture.
  58400. */
  58401. export class MinMaxReducer {
  58402. /**
  58403. * Observable triggered when the computation has been performed
  58404. */
  58405. onAfterReductionPerformed: Observable<{
  58406. min: number;
  58407. max: number;
  58408. }>;
  58409. protected _camera: Camera;
  58410. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58411. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58412. protected _postProcessManager: PostProcessManager;
  58413. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58414. protected _forceFullscreenViewport: boolean;
  58415. /**
  58416. * Creates a min/max reducer
  58417. * @param camera The camera to use for the post processes
  58418. */
  58419. constructor(camera: Camera);
  58420. /**
  58421. * Gets the texture used to read the values from.
  58422. */
  58423. get sourceTexture(): Nullable<RenderTargetTexture>;
  58424. /**
  58425. * Sets the source texture to read the values from.
  58426. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58427. * because in such textures '1' value must not be taken into account to compute the maximum
  58428. * as this value is used to clear the texture.
  58429. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58430. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58431. * @param depthRedux Indicates if the texture is a depth texture or not
  58432. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58433. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58434. */
  58435. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58436. /**
  58437. * Defines the refresh rate of the computation.
  58438. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58439. */
  58440. get refreshRate(): number;
  58441. set refreshRate(value: number);
  58442. protected _activated: boolean;
  58443. /**
  58444. * Gets the activation status of the reducer
  58445. */
  58446. get activated(): boolean;
  58447. /**
  58448. * Activates the reduction computation.
  58449. * When activated, the observers registered in onAfterReductionPerformed are
  58450. * called after the compuation is performed
  58451. */
  58452. activate(): void;
  58453. /**
  58454. * Deactivates the reduction computation.
  58455. */
  58456. deactivate(): void;
  58457. /**
  58458. * Disposes the min/max reducer
  58459. * @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.
  58460. */
  58461. dispose(disposeAll?: boolean): void;
  58462. }
  58463. }
  58464. declare module BABYLON {
  58465. /**
  58466. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58467. */
  58468. export class DepthReducer extends MinMaxReducer {
  58469. private _depthRenderer;
  58470. private _depthRendererId;
  58471. /**
  58472. * Gets the depth renderer used for the computation.
  58473. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58474. */
  58475. get depthRenderer(): Nullable<DepthRenderer>;
  58476. /**
  58477. * Creates a depth reducer
  58478. * @param camera The camera used to render the depth texture
  58479. */
  58480. constructor(camera: Camera);
  58481. /**
  58482. * Sets the depth renderer to use to generate the depth map
  58483. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58484. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58485. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58486. */
  58487. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58488. /** @hidden */
  58489. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58490. /**
  58491. * Activates the reduction computation.
  58492. * When activated, the observers registered in onAfterReductionPerformed are
  58493. * called after the compuation is performed
  58494. */
  58495. activate(): void;
  58496. /**
  58497. * Deactivates the reduction computation.
  58498. */
  58499. deactivate(): void;
  58500. /**
  58501. * Disposes the depth reducer
  58502. * @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.
  58503. */
  58504. dispose(disposeAll?: boolean): void;
  58505. }
  58506. }
  58507. declare module BABYLON {
  58508. /**
  58509. * A CSM implementation allowing casting shadows on large scenes.
  58510. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58511. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58512. */
  58513. export class CascadedShadowGenerator extends ShadowGenerator {
  58514. private static readonly frustumCornersNDCSpace;
  58515. /**
  58516. * Name of the CSM class
  58517. */
  58518. static CLASSNAME: string;
  58519. /**
  58520. * Defines the default number of cascades used by the CSM.
  58521. */
  58522. static readonly DEFAULT_CASCADES_COUNT: number;
  58523. /**
  58524. * Defines the minimum number of cascades used by the CSM.
  58525. */
  58526. static readonly MIN_CASCADES_COUNT: number;
  58527. /**
  58528. * Defines the maximum number of cascades used by the CSM.
  58529. */
  58530. static readonly MAX_CASCADES_COUNT: number;
  58531. protected _validateFilter(filter: number): number;
  58532. /**
  58533. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58534. */
  58535. penumbraDarkness: number;
  58536. private _numCascades;
  58537. /**
  58538. * Gets or set the number of cascades used by the CSM.
  58539. */
  58540. get numCascades(): number;
  58541. set numCascades(value: number);
  58542. /**
  58543. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58544. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58545. */
  58546. stabilizeCascades: boolean;
  58547. private _freezeShadowCastersBoundingInfo;
  58548. private _freezeShadowCastersBoundingInfoObservable;
  58549. /**
  58550. * Enables or disables the shadow casters bounding info computation.
  58551. * If your shadow casters don't move, you can disable this feature.
  58552. * If it is enabled, the bounding box computation is done every frame.
  58553. */
  58554. get freezeShadowCastersBoundingInfo(): boolean;
  58555. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58556. private _scbiMin;
  58557. private _scbiMax;
  58558. protected _computeShadowCastersBoundingInfo(): void;
  58559. protected _shadowCastersBoundingInfo: BoundingInfo;
  58560. /**
  58561. * Gets or sets the shadow casters bounding info.
  58562. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58563. * so that the system won't overwrite the bounds you provide
  58564. */
  58565. get shadowCastersBoundingInfo(): BoundingInfo;
  58566. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58567. protected _breaksAreDirty: boolean;
  58568. protected _minDistance: number;
  58569. protected _maxDistance: number;
  58570. /**
  58571. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58572. *
  58573. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58574. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58575. * @param min minimal distance for the breaks (default to 0.)
  58576. * @param max maximal distance for the breaks (default to 1.)
  58577. */
  58578. setMinMaxDistance(min: number, max: number): void;
  58579. /** Gets the minimal distance used in the cascade break computation */
  58580. get minDistance(): number;
  58581. /** Gets the maximal distance used in the cascade break computation */
  58582. get maxDistance(): number;
  58583. /**
  58584. * Gets the class name of that object
  58585. * @returns "CascadedShadowGenerator"
  58586. */
  58587. getClassName(): string;
  58588. private _cascadeMinExtents;
  58589. private _cascadeMaxExtents;
  58590. /**
  58591. * Gets a cascade minimum extents
  58592. * @param cascadeIndex index of the cascade
  58593. * @returns the minimum cascade extents
  58594. */
  58595. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58596. /**
  58597. * Gets a cascade maximum extents
  58598. * @param cascadeIndex index of the cascade
  58599. * @returns the maximum cascade extents
  58600. */
  58601. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58602. private _cascades;
  58603. private _currentLayer;
  58604. private _viewSpaceFrustumsZ;
  58605. private _viewMatrices;
  58606. private _projectionMatrices;
  58607. private _transformMatrices;
  58608. private _transformMatricesAsArray;
  58609. private _frustumLengths;
  58610. private _lightSizeUVCorrection;
  58611. private _depthCorrection;
  58612. private _frustumCornersWorldSpace;
  58613. private _frustumCenter;
  58614. private _shadowCameraPos;
  58615. private _shadowMaxZ;
  58616. /**
  58617. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58618. * It defaults to camera.maxZ
  58619. */
  58620. get shadowMaxZ(): number;
  58621. /**
  58622. * Sets the shadow max z distance.
  58623. */
  58624. set shadowMaxZ(value: number);
  58625. protected _debug: boolean;
  58626. /**
  58627. * Gets or sets the debug flag.
  58628. * When enabled, the cascades are materialized by different colors on the screen.
  58629. */
  58630. get debug(): boolean;
  58631. set debug(dbg: boolean);
  58632. private _depthClamp;
  58633. /**
  58634. * Gets or sets the depth clamping value.
  58635. *
  58636. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58637. * to account for the shadow casters far away.
  58638. *
  58639. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58640. */
  58641. get depthClamp(): boolean;
  58642. set depthClamp(value: boolean);
  58643. private _cascadeBlendPercentage;
  58644. /**
  58645. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58646. * It defaults to 0.1 (10% blending).
  58647. */
  58648. get cascadeBlendPercentage(): number;
  58649. set cascadeBlendPercentage(value: number);
  58650. private _lambda;
  58651. /**
  58652. * Gets or set the lambda parameter.
  58653. * This parameter is used to split the camera frustum and create the cascades.
  58654. * 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.
  58655. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58656. */
  58657. get lambda(): number;
  58658. set lambda(value: number);
  58659. /**
  58660. * Gets the view matrix corresponding to a given cascade
  58661. * @param cascadeNum cascade to retrieve the view matrix from
  58662. * @returns the cascade view matrix
  58663. */
  58664. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58665. /**
  58666. * Gets the projection matrix corresponding to a given cascade
  58667. * @param cascadeNum cascade to retrieve the projection matrix from
  58668. * @returns the cascade projection matrix
  58669. */
  58670. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58671. /**
  58672. * Gets the transformation matrix corresponding to a given cascade
  58673. * @param cascadeNum cascade to retrieve the transformation matrix from
  58674. * @returns the cascade transformation matrix
  58675. */
  58676. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58677. private _depthRenderer;
  58678. /**
  58679. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58680. *
  58681. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58682. *
  58683. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58684. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58685. * @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
  58686. */
  58687. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58688. private _depthReducer;
  58689. private _autoCalcDepthBounds;
  58690. /**
  58691. * Gets or sets the autoCalcDepthBounds property.
  58692. *
  58693. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58694. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58695. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58696. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58697. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58698. */
  58699. get autoCalcDepthBounds(): boolean;
  58700. set autoCalcDepthBounds(value: boolean);
  58701. /**
  58702. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58703. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58704. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58705. * for setting the refresh rate on the renderer yourself!
  58706. */
  58707. get autoCalcDepthBoundsRefreshRate(): number;
  58708. set autoCalcDepthBoundsRefreshRate(value: number);
  58709. /**
  58710. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58711. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58712. * you change the camera near/far planes!
  58713. */
  58714. splitFrustum(): void;
  58715. private _splitFrustum;
  58716. private _computeMatrices;
  58717. private _computeFrustumInWorldSpace;
  58718. private _computeCascadeFrustum;
  58719. /**
  58720. * Support test.
  58721. */
  58722. static get IsSupported(): boolean;
  58723. /** @hidden */
  58724. static _SceneComponentInitialization: (scene: Scene) => void;
  58725. /**
  58726. * Creates a Cascaded Shadow Generator object.
  58727. * A ShadowGenerator is the required tool to use the shadows.
  58728. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58729. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58730. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58731. * @param light The directional light object generating the shadows.
  58732. * @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.
  58733. */
  58734. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58735. protected _initializeGenerator(): void;
  58736. protected _createTargetRenderTexture(): void;
  58737. protected _initializeShadowMap(): void;
  58738. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58739. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58740. /**
  58741. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58742. * @param defines Defines of the material we want to update
  58743. * @param lightIndex Index of the light in the enabled light list of the material
  58744. */
  58745. prepareDefines(defines: any, lightIndex: number): void;
  58746. /**
  58747. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58748. * defined in the generator but impacting the effect).
  58749. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58750. * @param effect The effect we are binfing the information for
  58751. */
  58752. bindShadowLight(lightIndex: string, effect: Effect): void;
  58753. /**
  58754. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58755. * (eq to view projection * shadow projection matrices)
  58756. * @returns The transform matrix used to create the shadow map
  58757. */
  58758. getTransformMatrix(): Matrix;
  58759. /**
  58760. * Disposes the ShadowGenerator.
  58761. * Returns nothing.
  58762. */
  58763. dispose(): void;
  58764. /**
  58765. * Serializes the shadow generator setup to a json object.
  58766. * @returns The serialized JSON object
  58767. */
  58768. serialize(): any;
  58769. /**
  58770. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58771. * @param parsedShadowGenerator The JSON object to parse
  58772. * @param scene The scene to create the shadow map for
  58773. * @returns The parsed shadow generator
  58774. */
  58775. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58776. }
  58777. }
  58778. declare module BABYLON {
  58779. /**
  58780. * Defines the shadow generator component responsible to manage any shadow generators
  58781. * in a given scene.
  58782. */
  58783. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58784. /**
  58785. * The component name helpfull to identify the component in the list of scene components.
  58786. */
  58787. readonly name: string;
  58788. /**
  58789. * The scene the component belongs to.
  58790. */
  58791. scene: Scene;
  58792. /**
  58793. * Creates a new instance of the component for the given scene
  58794. * @param scene Defines the scene to register the component in
  58795. */
  58796. constructor(scene: Scene);
  58797. /**
  58798. * Registers the component in a given scene
  58799. */
  58800. register(): void;
  58801. /**
  58802. * Rebuilds the elements related to this component in case of
  58803. * context lost for instance.
  58804. */
  58805. rebuild(): void;
  58806. /**
  58807. * Serializes the component data to the specified json object
  58808. * @param serializationObject The object to serialize to
  58809. */
  58810. serialize(serializationObject: any): void;
  58811. /**
  58812. * Adds all the elements from the container to the scene
  58813. * @param container the container holding the elements
  58814. */
  58815. addFromContainer(container: AbstractScene): void;
  58816. /**
  58817. * Removes all the elements in the container from the scene
  58818. * @param container contains the elements to remove
  58819. * @param dispose if the removed element should be disposed (default: false)
  58820. */
  58821. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58822. /**
  58823. * Rebuilds the elements related to this component in case of
  58824. * context lost for instance.
  58825. */
  58826. dispose(): void;
  58827. private _gatherRenderTargets;
  58828. }
  58829. }
  58830. declare module BABYLON {
  58831. /**
  58832. * A point light is a light defined by an unique point in world space.
  58833. * The light is emitted in every direction from this point.
  58834. * A good example of a point light is a standard light bulb.
  58835. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58836. */
  58837. export class PointLight extends ShadowLight {
  58838. private _shadowAngle;
  58839. /**
  58840. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58841. * This specifies what angle the shadow will use to be created.
  58842. *
  58843. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58844. */
  58845. get shadowAngle(): number;
  58846. /**
  58847. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58848. * This specifies what angle the shadow will use to be created.
  58849. *
  58850. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58851. */
  58852. set shadowAngle(value: number);
  58853. /**
  58854. * Gets the direction if it has been set.
  58855. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58856. */
  58857. get direction(): Vector3;
  58858. /**
  58859. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58860. */
  58861. set direction(value: Vector3);
  58862. /**
  58863. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58864. * A PointLight emits the light in every direction.
  58865. * It can cast shadows.
  58866. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58867. * ```javascript
  58868. * var pointLight = new PointLight("pl", camera.position, scene);
  58869. * ```
  58870. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58871. * @param name The light friendly name
  58872. * @param position The position of the point light in the scene
  58873. * @param scene The scene the lights belongs to
  58874. */
  58875. constructor(name: string, position: Vector3, scene: Scene);
  58876. /**
  58877. * Returns the string "PointLight"
  58878. * @returns the class name
  58879. */
  58880. getClassName(): string;
  58881. /**
  58882. * Returns the integer 0.
  58883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58884. */
  58885. getTypeID(): number;
  58886. /**
  58887. * Specifies wether or not the shadowmap should be a cube texture.
  58888. * @returns true if the shadowmap needs to be a cube texture.
  58889. */
  58890. needCube(): boolean;
  58891. /**
  58892. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58893. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58894. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58895. */
  58896. getShadowDirection(faceIndex?: number): Vector3;
  58897. /**
  58898. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58899. * - fov = PI / 2
  58900. * - aspect ratio : 1.0
  58901. * - z-near and far equal to the active camera minZ and maxZ.
  58902. * Returns the PointLight.
  58903. */
  58904. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58905. protected _buildUniformLayout(): void;
  58906. /**
  58907. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58908. * @param effect The effect to update
  58909. * @param lightIndex The index of the light in the effect to update
  58910. * @returns The point light
  58911. */
  58912. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58913. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58914. /**
  58915. * Prepares the list of defines specific to the light type.
  58916. * @param defines the list of defines
  58917. * @param lightIndex defines the index of the light for the effect
  58918. */
  58919. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58920. }
  58921. }
  58922. declare module BABYLON {
  58923. /**
  58924. * Header information of HDR texture files.
  58925. */
  58926. export interface HDRInfo {
  58927. /**
  58928. * The height of the texture in pixels.
  58929. */
  58930. height: number;
  58931. /**
  58932. * The width of the texture in pixels.
  58933. */
  58934. width: number;
  58935. /**
  58936. * The index of the beginning of the data in the binary file.
  58937. */
  58938. dataPosition: number;
  58939. }
  58940. /**
  58941. * This groups tools to convert HDR texture to native colors array.
  58942. */
  58943. export class HDRTools {
  58944. private static Ldexp;
  58945. private static Rgbe2float;
  58946. private static readStringLine;
  58947. /**
  58948. * Reads header information from an RGBE texture stored in a native array.
  58949. * More information on this format are available here:
  58950. * https://en.wikipedia.org/wiki/RGBE_image_format
  58951. *
  58952. * @param uint8array The binary file stored in native array.
  58953. * @return The header information.
  58954. */
  58955. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58956. /**
  58957. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58958. * This RGBE texture needs to store the information as a panorama.
  58959. *
  58960. * More information on this format are available here:
  58961. * https://en.wikipedia.org/wiki/RGBE_image_format
  58962. *
  58963. * @param buffer The binary file stored in an array buffer.
  58964. * @param size The expected size of the extracted cubemap.
  58965. * @return The Cube Map information.
  58966. */
  58967. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58968. /**
  58969. * Returns the pixels data extracted from an RGBE texture.
  58970. * This pixels will be stored left to right up to down in the R G B order in one array.
  58971. *
  58972. * More information on this format are available here:
  58973. * https://en.wikipedia.org/wiki/RGBE_image_format
  58974. *
  58975. * @param uint8array The binary file stored in an array buffer.
  58976. * @param hdrInfo The header information of the file.
  58977. * @return The pixels data in RGB right to left up to down order.
  58978. */
  58979. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58980. private static RGBE_ReadPixels_RLE;
  58981. }
  58982. }
  58983. declare module BABYLON {
  58984. /**
  58985. * Effect Render Options
  58986. */
  58987. export interface IEffectRendererOptions {
  58988. /**
  58989. * Defines the vertices positions.
  58990. */
  58991. positions?: number[];
  58992. /**
  58993. * Defines the indices.
  58994. */
  58995. indices?: number[];
  58996. }
  58997. /**
  58998. * Helper class to render one or more effects.
  58999. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59000. */
  59001. export class EffectRenderer {
  59002. private engine;
  59003. private static _DefaultOptions;
  59004. private _vertexBuffers;
  59005. private _indexBuffer;
  59006. private _fullscreenViewport;
  59007. /**
  59008. * Creates an effect renderer
  59009. * @param engine the engine to use for rendering
  59010. * @param options defines the options of the effect renderer
  59011. */
  59012. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59013. /**
  59014. * Sets the current viewport in normalized coordinates 0-1
  59015. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59016. */
  59017. setViewport(viewport?: Viewport): void;
  59018. /**
  59019. * Binds the embedded attributes buffer to the effect.
  59020. * @param effect Defines the effect to bind the attributes for
  59021. */
  59022. bindBuffers(effect: Effect): void;
  59023. /**
  59024. * Sets the current effect wrapper to use during draw.
  59025. * The effect needs to be ready before calling this api.
  59026. * This also sets the default full screen position attribute.
  59027. * @param effectWrapper Defines the effect to draw with
  59028. */
  59029. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59030. /**
  59031. * Restores engine states
  59032. */
  59033. restoreStates(): void;
  59034. /**
  59035. * Draws a full screen quad.
  59036. */
  59037. draw(): void;
  59038. private isRenderTargetTexture;
  59039. /**
  59040. * renders one or more effects to a specified texture
  59041. * @param effectWrapper the effect to renderer
  59042. * @param outputTexture texture to draw to, if null it will render to the screen.
  59043. */
  59044. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59045. /**
  59046. * Disposes of the effect renderer
  59047. */
  59048. dispose(): void;
  59049. }
  59050. /**
  59051. * Options to create an EffectWrapper
  59052. */
  59053. interface EffectWrapperCreationOptions {
  59054. /**
  59055. * Engine to use to create the effect
  59056. */
  59057. engine: ThinEngine;
  59058. /**
  59059. * Fragment shader for the effect
  59060. */
  59061. fragmentShader: string;
  59062. /**
  59063. * Use the shader store instead of direct source code
  59064. */
  59065. useShaderStore?: boolean;
  59066. /**
  59067. * Vertex shader for the effect
  59068. */
  59069. vertexShader?: string;
  59070. /**
  59071. * Attributes to use in the shader
  59072. */
  59073. attributeNames?: Array<string>;
  59074. /**
  59075. * Uniforms to use in the shader
  59076. */
  59077. uniformNames?: Array<string>;
  59078. /**
  59079. * Texture sampler names to use in the shader
  59080. */
  59081. samplerNames?: Array<string>;
  59082. /**
  59083. * Defines to use in the shader
  59084. */
  59085. defines?: Array<string>;
  59086. /**
  59087. * Callback when effect is compiled
  59088. */
  59089. onCompiled?: Nullable<(effect: Effect) => void>;
  59090. /**
  59091. * The friendly name of the effect displayed in Spector.
  59092. */
  59093. name?: string;
  59094. }
  59095. /**
  59096. * Wraps an effect to be used for rendering
  59097. */
  59098. export class EffectWrapper {
  59099. /**
  59100. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59101. */
  59102. onApplyObservable: Observable<{}>;
  59103. /**
  59104. * The underlying effect
  59105. */
  59106. effect: Effect;
  59107. /**
  59108. * Creates an effect to be renderer
  59109. * @param creationOptions options to create the effect
  59110. */
  59111. constructor(creationOptions: EffectWrapperCreationOptions);
  59112. /**
  59113. * Disposes of the effect wrapper
  59114. */
  59115. dispose(): void;
  59116. }
  59117. }
  59118. declare module BABYLON {
  59119. /** @hidden */
  59120. export var hdrFilteringVertexShader: {
  59121. name: string;
  59122. shader: string;
  59123. };
  59124. }
  59125. declare module BABYLON {
  59126. /** @hidden */
  59127. export var hdrFilteringPixelShader: {
  59128. name: string;
  59129. shader: string;
  59130. };
  59131. }
  59132. declare module BABYLON {
  59133. /**
  59134. * Options for texture filtering
  59135. */
  59136. interface IHDRFilteringOptions {
  59137. /**
  59138. * Scales pixel intensity for the input HDR map.
  59139. */
  59140. hdrScale?: number;
  59141. /**
  59142. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59143. */
  59144. quality?: number;
  59145. }
  59146. /**
  59147. * Filters HDR maps to get correct renderings of PBR reflections
  59148. */
  59149. export class HDRFiltering {
  59150. private _engine;
  59151. private _effectRenderer;
  59152. private _effectWrapper;
  59153. private _lodGenerationOffset;
  59154. private _lodGenerationScale;
  59155. /**
  59156. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59157. * you care about baking speed.
  59158. */
  59159. quality: number;
  59160. /**
  59161. * Scales pixel intensity for the input HDR map.
  59162. */
  59163. hdrScale: number;
  59164. /**
  59165. * Instantiates HDR filter for reflection maps
  59166. *
  59167. * @param engine Thin engine
  59168. * @param options Options
  59169. */
  59170. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59171. private _createRenderTarget;
  59172. private _prefilterInternal;
  59173. private _createEffect;
  59174. /**
  59175. * Get a value indicating if the filter is ready to be used
  59176. * @param texture Texture to filter
  59177. * @returns true if the filter is ready
  59178. */
  59179. isReady(texture: BaseTexture): boolean;
  59180. /**
  59181. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59182. * Prefiltering will be invoked at the end of next rendering pass.
  59183. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59184. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59185. * @param texture Texture to filter
  59186. * @param onFinished Callback when filtering is done
  59187. * @return Promise called when prefiltering is done
  59188. */
  59189. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59190. }
  59191. }
  59192. declare module BABYLON {
  59193. /**
  59194. * This represents a texture coming from an HDR input.
  59195. *
  59196. * The only supported format is currently panorama picture stored in RGBE format.
  59197. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59198. */
  59199. export class HDRCubeTexture extends BaseTexture {
  59200. private static _facesMapping;
  59201. private _generateHarmonics;
  59202. private _noMipmap;
  59203. private _prefilterOnLoad;
  59204. private _textureMatrix;
  59205. private _size;
  59206. private _onLoad;
  59207. private _onError;
  59208. /**
  59209. * The texture URL.
  59210. */
  59211. url: string;
  59212. /**
  59213. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59214. */
  59215. coordinatesMode: number;
  59216. protected _isBlocking: boolean;
  59217. /**
  59218. * Sets wether or not the texture is blocking during loading.
  59219. */
  59220. set isBlocking(value: boolean);
  59221. /**
  59222. * Gets wether or not the texture is blocking during loading.
  59223. */
  59224. get isBlocking(): boolean;
  59225. protected _rotationY: number;
  59226. /**
  59227. * Sets texture matrix rotation angle around Y axis in radians.
  59228. */
  59229. set rotationY(value: number);
  59230. /**
  59231. * Gets texture matrix rotation angle around Y axis radians.
  59232. */
  59233. get rotationY(): number;
  59234. /**
  59235. * Gets or sets the center of the bounding box associated with the cube texture
  59236. * It must define where the camera used to render the texture was set
  59237. */
  59238. boundingBoxPosition: Vector3;
  59239. private _boundingBoxSize;
  59240. /**
  59241. * Gets or sets the size of the bounding box associated with the cube texture
  59242. * When defined, the cubemap will switch to local mode
  59243. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59244. * @example https://www.babylonjs-playground.com/#RNASML
  59245. */
  59246. set boundingBoxSize(value: Vector3);
  59247. get boundingBoxSize(): Vector3;
  59248. /**
  59249. * Instantiates an HDRTexture from the following parameters.
  59250. *
  59251. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59252. * @param sceneOrEngine The scene or engine the texture will be used in
  59253. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59254. * @param noMipmap Forces to not generate the mipmap if true
  59255. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59256. * @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)
  59257. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59258. */
  59259. 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>);
  59260. /**
  59261. * Get the current class name of the texture useful for serialization or dynamic coding.
  59262. * @returns "HDRCubeTexture"
  59263. */
  59264. getClassName(): string;
  59265. /**
  59266. * Occurs when the file is raw .hdr file.
  59267. */
  59268. private loadTexture;
  59269. clone(): HDRCubeTexture;
  59270. delayLoad(): void;
  59271. /**
  59272. * Get the texture reflection matrix used to rotate/transform the reflection.
  59273. * @returns the reflection matrix
  59274. */
  59275. getReflectionTextureMatrix(): Matrix;
  59276. /**
  59277. * Set the texture reflection matrix used to rotate/transform the reflection.
  59278. * @param value Define the reflection matrix to set
  59279. */
  59280. setReflectionTextureMatrix(value: Matrix): void;
  59281. /**
  59282. * Parses a JSON representation of an HDR Texture in order to create the texture
  59283. * @param parsedTexture Define the JSON representation
  59284. * @param scene Define the scene the texture should be created in
  59285. * @param rootUrl Define the root url in case we need to load relative dependencies
  59286. * @returns the newly created texture after parsing
  59287. */
  59288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59289. serialize(): any;
  59290. }
  59291. }
  59292. declare module BABYLON {
  59293. /**
  59294. * Class used to control physics engine
  59295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59296. */
  59297. export class PhysicsEngine implements IPhysicsEngine {
  59298. private _physicsPlugin;
  59299. /**
  59300. * Global value used to control the smallest number supported by the simulation
  59301. */
  59302. static Epsilon: number;
  59303. private _impostors;
  59304. private _joints;
  59305. private _subTimeStep;
  59306. /**
  59307. * Gets the gravity vector used by the simulation
  59308. */
  59309. gravity: Vector3;
  59310. /**
  59311. * Factory used to create the default physics plugin.
  59312. * @returns The default physics plugin
  59313. */
  59314. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59315. /**
  59316. * Creates a new Physics Engine
  59317. * @param gravity defines the gravity vector used by the simulation
  59318. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59319. */
  59320. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59321. /**
  59322. * Sets the gravity vector used by the simulation
  59323. * @param gravity defines the gravity vector to use
  59324. */
  59325. setGravity(gravity: Vector3): void;
  59326. /**
  59327. * Set the time step of the physics engine.
  59328. * Default is 1/60.
  59329. * To slow it down, enter 1/600 for example.
  59330. * To speed it up, 1/30
  59331. * @param newTimeStep defines the new timestep to apply to this world.
  59332. */
  59333. setTimeStep(newTimeStep?: number): void;
  59334. /**
  59335. * Get the time step of the physics engine.
  59336. * @returns the current time step
  59337. */
  59338. getTimeStep(): number;
  59339. /**
  59340. * Set the sub time step of the physics engine.
  59341. * Default is 0 meaning there is no sub steps
  59342. * To increase physics resolution precision, set a small value (like 1 ms)
  59343. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59344. */
  59345. setSubTimeStep(subTimeStep?: number): void;
  59346. /**
  59347. * Get the sub time step of the physics engine.
  59348. * @returns the current sub time step
  59349. */
  59350. getSubTimeStep(): number;
  59351. /**
  59352. * Release all resources
  59353. */
  59354. dispose(): void;
  59355. /**
  59356. * Gets the name of the current physics plugin
  59357. * @returns the name of the plugin
  59358. */
  59359. getPhysicsPluginName(): string;
  59360. /**
  59361. * Adding a new impostor for the impostor tracking.
  59362. * This will be done by the impostor itself.
  59363. * @param impostor the impostor to add
  59364. */
  59365. addImpostor(impostor: PhysicsImpostor): void;
  59366. /**
  59367. * Remove an impostor from the engine.
  59368. * This impostor and its mesh will not longer be updated by the physics engine.
  59369. * @param impostor the impostor to remove
  59370. */
  59371. removeImpostor(impostor: PhysicsImpostor): void;
  59372. /**
  59373. * Add a joint to the physics engine
  59374. * @param mainImpostor defines the main impostor to which the joint is added.
  59375. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59376. * @param joint defines the joint that will connect both impostors.
  59377. */
  59378. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59379. /**
  59380. * Removes a joint from the simulation
  59381. * @param mainImpostor defines the impostor used with the joint
  59382. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59383. * @param joint defines the joint to remove
  59384. */
  59385. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59386. /**
  59387. * Called by the scene. No need to call it.
  59388. * @param delta defines the timespam between frames
  59389. */
  59390. _step(delta: number): void;
  59391. /**
  59392. * Gets the current plugin used to run the simulation
  59393. * @returns current plugin
  59394. */
  59395. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59396. /**
  59397. * Gets the list of physic impostors
  59398. * @returns an array of PhysicsImpostor
  59399. */
  59400. getImpostors(): Array<PhysicsImpostor>;
  59401. /**
  59402. * Gets the impostor for a physics enabled object
  59403. * @param object defines the object impersonated by the impostor
  59404. * @returns the PhysicsImpostor or null if not found
  59405. */
  59406. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59407. /**
  59408. * Gets the impostor for a physics body object
  59409. * @param body defines physics body used by the impostor
  59410. * @returns the PhysicsImpostor or null if not found
  59411. */
  59412. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59413. /**
  59414. * Does a raycast in the physics world
  59415. * @param from when should the ray start?
  59416. * @param to when should the ray end?
  59417. * @returns PhysicsRaycastResult
  59418. */
  59419. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59420. }
  59421. }
  59422. declare module BABYLON {
  59423. /** @hidden */
  59424. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59425. private _useDeltaForWorldStep;
  59426. world: any;
  59427. name: string;
  59428. private _physicsMaterials;
  59429. private _fixedTimeStep;
  59430. private _cannonRaycastResult;
  59431. private _raycastResult;
  59432. private _physicsBodysToRemoveAfterStep;
  59433. private _firstFrame;
  59434. BJSCANNON: any;
  59435. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59436. setGravity(gravity: Vector3): void;
  59437. setTimeStep(timeStep: number): void;
  59438. getTimeStep(): number;
  59439. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59440. private _removeMarkedPhysicsBodiesFromWorld;
  59441. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59442. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59443. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59444. private _processChildMeshes;
  59445. removePhysicsBody(impostor: PhysicsImpostor): void;
  59446. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59447. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59448. private _addMaterial;
  59449. private _checkWithEpsilon;
  59450. private _createShape;
  59451. private _createHeightmap;
  59452. private _minus90X;
  59453. private _plus90X;
  59454. private _tmpPosition;
  59455. private _tmpDeltaPosition;
  59456. private _tmpUnityRotation;
  59457. private _updatePhysicsBodyTransformation;
  59458. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59459. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59460. isSupported(): boolean;
  59461. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59462. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59463. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59464. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59465. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59466. getBodyMass(impostor: PhysicsImpostor): number;
  59467. getBodyFriction(impostor: PhysicsImpostor): number;
  59468. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59469. getBodyRestitution(impostor: PhysicsImpostor): number;
  59470. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59471. sleepBody(impostor: PhysicsImpostor): void;
  59472. wakeUpBody(impostor: PhysicsImpostor): void;
  59473. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59474. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59475. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59476. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59477. getRadius(impostor: PhysicsImpostor): number;
  59478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59479. dispose(): void;
  59480. private _extendNamespace;
  59481. /**
  59482. * Does a raycast in the physics world
  59483. * @param from when should the ray start?
  59484. * @param to when should the ray end?
  59485. * @returns PhysicsRaycastResult
  59486. */
  59487. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59488. }
  59489. }
  59490. declare module BABYLON {
  59491. /** @hidden */
  59492. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59493. private _useDeltaForWorldStep;
  59494. world: any;
  59495. name: string;
  59496. BJSOIMO: any;
  59497. private _raycastResult;
  59498. private _fixedTimeStep;
  59499. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59500. setGravity(gravity: Vector3): void;
  59501. setTimeStep(timeStep: number): void;
  59502. getTimeStep(): number;
  59503. private _tmpImpostorsArray;
  59504. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59505. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59506. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59507. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59508. private _tmpPositionVector;
  59509. removePhysicsBody(impostor: PhysicsImpostor): void;
  59510. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59511. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59512. isSupported(): boolean;
  59513. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59514. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59515. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59516. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59517. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59518. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59519. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59520. getBodyMass(impostor: PhysicsImpostor): number;
  59521. getBodyFriction(impostor: PhysicsImpostor): number;
  59522. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59523. getBodyRestitution(impostor: PhysicsImpostor): number;
  59524. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59525. sleepBody(impostor: PhysicsImpostor): void;
  59526. wakeUpBody(impostor: PhysicsImpostor): void;
  59527. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59528. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59529. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59530. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59531. getRadius(impostor: PhysicsImpostor): number;
  59532. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59533. dispose(): void;
  59534. /**
  59535. * Does a raycast in the physics world
  59536. * @param from when should the ray start?
  59537. * @param to when should the ray end?
  59538. * @returns PhysicsRaycastResult
  59539. */
  59540. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59541. }
  59542. }
  59543. declare module BABYLON {
  59544. /**
  59545. * Class containing static functions to help procedurally build meshes
  59546. */
  59547. export class RibbonBuilder {
  59548. /**
  59549. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59550. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59551. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59552. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59553. * * 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
  59554. * * 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
  59555. * * 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
  59556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59557. * * 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
  59558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59559. * * 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
  59560. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59561. * * 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
  59562. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59564. * @param name defines the name of the mesh
  59565. * @param options defines the options used to create the mesh
  59566. * @param scene defines the hosting scene
  59567. * @returns the ribbon mesh
  59568. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59569. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59570. */
  59571. static CreateRibbon(name: string, options: {
  59572. pathArray: Vector3[][];
  59573. closeArray?: boolean;
  59574. closePath?: boolean;
  59575. offset?: number;
  59576. updatable?: boolean;
  59577. sideOrientation?: number;
  59578. frontUVs?: Vector4;
  59579. backUVs?: Vector4;
  59580. instance?: Mesh;
  59581. invertUV?: boolean;
  59582. uvs?: Vector2[];
  59583. colors?: Color4[];
  59584. }, scene?: Nullable<Scene>): Mesh;
  59585. }
  59586. }
  59587. declare module BABYLON {
  59588. /**
  59589. * Class containing static functions to help procedurally build meshes
  59590. */
  59591. export class ShapeBuilder {
  59592. /**
  59593. * 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.
  59594. * * 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.
  59595. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59596. * * 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.
  59597. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59598. * * 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
  59599. * * 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
  59600. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59602. * * 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
  59603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59605. * @param name defines the name of the mesh
  59606. * @param options defines the options used to create the mesh
  59607. * @param scene defines the hosting scene
  59608. * @returns the extruded shape mesh
  59609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59611. */
  59612. static ExtrudeShape(name: string, options: {
  59613. shape: Vector3[];
  59614. path: Vector3[];
  59615. scale?: number;
  59616. rotation?: number;
  59617. cap?: number;
  59618. updatable?: boolean;
  59619. sideOrientation?: number;
  59620. frontUVs?: Vector4;
  59621. backUVs?: Vector4;
  59622. instance?: Mesh;
  59623. invertUV?: boolean;
  59624. }, scene?: Nullable<Scene>): Mesh;
  59625. /**
  59626. * Creates an custom extruded shape mesh.
  59627. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59628. * * 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.
  59629. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59630. * * 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
  59631. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59632. * * 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
  59633. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59634. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59635. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59636. * * 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
  59637. * * 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
  59638. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59640. * * 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
  59641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59643. * @param name defines the name of the mesh
  59644. * @param options defines the options used to create the mesh
  59645. * @param scene defines the hosting scene
  59646. * @returns the custom extruded shape mesh
  59647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59648. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59650. */
  59651. static ExtrudeShapeCustom(name: string, options: {
  59652. shape: Vector3[];
  59653. path: Vector3[];
  59654. scaleFunction?: any;
  59655. rotationFunction?: any;
  59656. ribbonCloseArray?: boolean;
  59657. ribbonClosePath?: boolean;
  59658. cap?: number;
  59659. updatable?: boolean;
  59660. sideOrientation?: number;
  59661. frontUVs?: Vector4;
  59662. backUVs?: Vector4;
  59663. instance?: Mesh;
  59664. invertUV?: boolean;
  59665. }, scene?: Nullable<Scene>): Mesh;
  59666. private static _ExtrudeShapeGeneric;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /**
  59671. * AmmoJS Physics plugin
  59672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59673. * @see https://github.com/kripken/ammo.js/
  59674. */
  59675. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59676. private _useDeltaForWorldStep;
  59677. /**
  59678. * Reference to the Ammo library
  59679. */
  59680. bjsAMMO: any;
  59681. /**
  59682. * Created ammoJS world which physics bodies are added to
  59683. */
  59684. world: any;
  59685. /**
  59686. * Name of the plugin
  59687. */
  59688. name: string;
  59689. private _timeStep;
  59690. private _fixedTimeStep;
  59691. private _maxSteps;
  59692. private _tmpQuaternion;
  59693. private _tmpAmmoTransform;
  59694. private _tmpAmmoQuaternion;
  59695. private _tmpAmmoConcreteContactResultCallback;
  59696. private _collisionConfiguration;
  59697. private _dispatcher;
  59698. private _overlappingPairCache;
  59699. private _solver;
  59700. private _softBodySolver;
  59701. private _tmpAmmoVectorA;
  59702. private _tmpAmmoVectorB;
  59703. private _tmpAmmoVectorC;
  59704. private _tmpAmmoVectorD;
  59705. private _tmpContactCallbackResult;
  59706. private _tmpAmmoVectorRCA;
  59707. private _tmpAmmoVectorRCB;
  59708. private _raycastResult;
  59709. private static readonly DISABLE_COLLISION_FLAG;
  59710. private static readonly KINEMATIC_FLAG;
  59711. private static readonly DISABLE_DEACTIVATION_FLAG;
  59712. /**
  59713. * Initializes the ammoJS plugin
  59714. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59715. * @param ammoInjection can be used to inject your own ammo reference
  59716. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59717. */
  59718. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59719. /**
  59720. * Sets the gravity of the physics world (m/(s^2))
  59721. * @param gravity Gravity to set
  59722. */
  59723. setGravity(gravity: Vector3): void;
  59724. /**
  59725. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59726. * @param timeStep timestep to use in seconds
  59727. */
  59728. setTimeStep(timeStep: number): void;
  59729. /**
  59730. * 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)
  59731. * @param fixedTimeStep fixedTimeStep to use in seconds
  59732. */
  59733. setFixedTimeStep(fixedTimeStep: number): void;
  59734. /**
  59735. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59736. * @param maxSteps the maximum number of steps by the physics engine per frame
  59737. */
  59738. setMaxSteps(maxSteps: number): void;
  59739. /**
  59740. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59741. * @returns the current timestep in seconds
  59742. */
  59743. getTimeStep(): number;
  59744. /**
  59745. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59746. */
  59747. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59748. private _isImpostorInContact;
  59749. private _isImpostorPairInContact;
  59750. private _stepSimulation;
  59751. /**
  59752. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59753. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59754. * After the step the babylon meshes are set to the position of the physics imposters
  59755. * @param delta amount of time to step forward
  59756. * @param impostors array of imposters to update before/after the step
  59757. */
  59758. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59759. /**
  59760. * Update babylon mesh to match physics world object
  59761. * @param impostor imposter to match
  59762. */
  59763. private _afterSoftStep;
  59764. /**
  59765. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59766. * @param impostor imposter to match
  59767. */
  59768. private _ropeStep;
  59769. /**
  59770. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59771. * @param impostor imposter to match
  59772. */
  59773. private _softbodyOrClothStep;
  59774. private _tmpMatrix;
  59775. /**
  59776. * Applies an impulse on the imposter
  59777. * @param impostor imposter to apply impulse to
  59778. * @param force amount of force to be applied to the imposter
  59779. * @param contactPoint the location to apply the impulse on the imposter
  59780. */
  59781. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59782. /**
  59783. * Applies a force on the imposter
  59784. * @param impostor imposter to apply force
  59785. * @param force amount of force to be applied to the imposter
  59786. * @param contactPoint the location to apply the force on the imposter
  59787. */
  59788. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59789. /**
  59790. * Creates a physics body using the plugin
  59791. * @param impostor the imposter to create the physics body on
  59792. */
  59793. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59794. /**
  59795. * Removes the physics body from the imposter and disposes of the body's memory
  59796. * @param impostor imposter to remove the physics body from
  59797. */
  59798. removePhysicsBody(impostor: PhysicsImpostor): void;
  59799. /**
  59800. * Generates a joint
  59801. * @param impostorJoint the imposter joint to create the joint with
  59802. */
  59803. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59804. /**
  59805. * Removes a joint
  59806. * @param impostorJoint the imposter joint to remove the joint from
  59807. */
  59808. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59809. private _addMeshVerts;
  59810. /**
  59811. * Initialise the soft body vertices to match its object's (mesh) vertices
  59812. * Softbody vertices (nodes) are in world space and to match this
  59813. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59814. * @param impostor to create the softbody for
  59815. */
  59816. private _softVertexData;
  59817. /**
  59818. * Create an impostor's soft body
  59819. * @param impostor to create the softbody for
  59820. */
  59821. private _createSoftbody;
  59822. /**
  59823. * Create cloth for an impostor
  59824. * @param impostor to create the softbody for
  59825. */
  59826. private _createCloth;
  59827. /**
  59828. * Create rope for an impostor
  59829. * @param impostor to create the softbody for
  59830. */
  59831. private _createRope;
  59832. /**
  59833. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59834. * @param impostor to create the custom physics shape for
  59835. */
  59836. private _createCustom;
  59837. private _addHullVerts;
  59838. private _createShape;
  59839. /**
  59840. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59841. * @param impostor imposter containing the physics body and babylon object
  59842. */
  59843. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59844. /**
  59845. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59846. * @param impostor imposter containing the physics body and babylon object
  59847. * @param newPosition new position
  59848. * @param newRotation new rotation
  59849. */
  59850. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59851. /**
  59852. * If this plugin is supported
  59853. * @returns true if its supported
  59854. */
  59855. isSupported(): boolean;
  59856. /**
  59857. * Sets the linear velocity of the physics body
  59858. * @param impostor imposter to set the velocity on
  59859. * @param velocity velocity to set
  59860. */
  59861. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59862. /**
  59863. * Sets the angular velocity of the physics body
  59864. * @param impostor imposter to set the velocity on
  59865. * @param velocity velocity to set
  59866. */
  59867. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59868. /**
  59869. * gets the linear velocity
  59870. * @param impostor imposter to get linear velocity from
  59871. * @returns linear velocity
  59872. */
  59873. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59874. /**
  59875. * gets the angular velocity
  59876. * @param impostor imposter to get angular velocity from
  59877. * @returns angular velocity
  59878. */
  59879. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59880. /**
  59881. * Sets the mass of physics body
  59882. * @param impostor imposter to set the mass on
  59883. * @param mass mass to set
  59884. */
  59885. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59886. /**
  59887. * Gets the mass of the physics body
  59888. * @param impostor imposter to get the mass from
  59889. * @returns mass
  59890. */
  59891. getBodyMass(impostor: PhysicsImpostor): number;
  59892. /**
  59893. * Gets friction of the impostor
  59894. * @param impostor impostor to get friction from
  59895. * @returns friction value
  59896. */
  59897. getBodyFriction(impostor: PhysicsImpostor): number;
  59898. /**
  59899. * Sets friction of the impostor
  59900. * @param impostor impostor to set friction on
  59901. * @param friction friction value
  59902. */
  59903. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59904. /**
  59905. * Gets restitution of the impostor
  59906. * @param impostor impostor to get restitution from
  59907. * @returns restitution value
  59908. */
  59909. getBodyRestitution(impostor: PhysicsImpostor): number;
  59910. /**
  59911. * Sets resitution of the impostor
  59912. * @param impostor impostor to set resitution on
  59913. * @param restitution resitution value
  59914. */
  59915. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59916. /**
  59917. * Gets pressure inside the impostor
  59918. * @param impostor impostor to get pressure from
  59919. * @returns pressure value
  59920. */
  59921. getBodyPressure(impostor: PhysicsImpostor): number;
  59922. /**
  59923. * Sets pressure inside a soft body impostor
  59924. * Cloth and rope must remain 0 pressure
  59925. * @param impostor impostor to set pressure on
  59926. * @param pressure pressure value
  59927. */
  59928. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59929. /**
  59930. * Gets stiffness of the impostor
  59931. * @param impostor impostor to get stiffness from
  59932. * @returns pressure value
  59933. */
  59934. getBodyStiffness(impostor: PhysicsImpostor): number;
  59935. /**
  59936. * Sets stiffness of the impostor
  59937. * @param impostor impostor to set stiffness on
  59938. * @param stiffness stiffness value from 0 to 1
  59939. */
  59940. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59941. /**
  59942. * Gets velocityIterations of the impostor
  59943. * @param impostor impostor to get velocity iterations from
  59944. * @returns velocityIterations value
  59945. */
  59946. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59947. /**
  59948. * Sets velocityIterations of the impostor
  59949. * @param impostor impostor to set velocity iterations on
  59950. * @param velocityIterations velocityIterations value
  59951. */
  59952. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59953. /**
  59954. * Gets positionIterations of the impostor
  59955. * @param impostor impostor to get position iterations from
  59956. * @returns positionIterations value
  59957. */
  59958. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59959. /**
  59960. * Sets positionIterations of the impostor
  59961. * @param impostor impostor to set position on
  59962. * @param positionIterations positionIterations value
  59963. */
  59964. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59965. /**
  59966. * Append an anchor to a cloth object
  59967. * @param impostor is the cloth impostor to add anchor to
  59968. * @param otherImpostor is the rigid impostor to anchor to
  59969. * @param width ratio across width from 0 to 1
  59970. * @param height ratio up height from 0 to 1
  59971. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59972. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59973. */
  59974. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59975. /**
  59976. * Append an hook to a rope object
  59977. * @param impostor is the rope impostor to add hook to
  59978. * @param otherImpostor is the rigid impostor to hook to
  59979. * @param length ratio along the rope from 0 to 1
  59980. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59981. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59982. */
  59983. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59984. /**
  59985. * Sleeps the physics body and stops it from being active
  59986. * @param impostor impostor to sleep
  59987. */
  59988. sleepBody(impostor: PhysicsImpostor): void;
  59989. /**
  59990. * Activates the physics body
  59991. * @param impostor impostor to activate
  59992. */
  59993. wakeUpBody(impostor: PhysicsImpostor): void;
  59994. /**
  59995. * Updates the distance parameters of the joint
  59996. * @param joint joint to update
  59997. * @param maxDistance maximum distance of the joint
  59998. * @param minDistance minimum distance of the joint
  59999. */
  60000. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60001. /**
  60002. * Sets a motor on the joint
  60003. * @param joint joint to set motor on
  60004. * @param speed speed of the motor
  60005. * @param maxForce maximum force of the motor
  60006. * @param motorIndex index of the motor
  60007. */
  60008. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60009. /**
  60010. * Sets the motors limit
  60011. * @param joint joint to set limit on
  60012. * @param upperLimit upper limit
  60013. * @param lowerLimit lower limit
  60014. */
  60015. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60016. /**
  60017. * Syncs the position and rotation of a mesh with the impostor
  60018. * @param mesh mesh to sync
  60019. * @param impostor impostor to update the mesh with
  60020. */
  60021. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60022. /**
  60023. * Gets the radius of the impostor
  60024. * @param impostor impostor to get radius from
  60025. * @returns the radius
  60026. */
  60027. getRadius(impostor: PhysicsImpostor): number;
  60028. /**
  60029. * Gets the box size of the impostor
  60030. * @param impostor impostor to get box size from
  60031. * @param result the resulting box size
  60032. */
  60033. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60034. /**
  60035. * Disposes of the impostor
  60036. */
  60037. dispose(): void;
  60038. /**
  60039. * Does a raycast in the physics world
  60040. * @param from when should the ray start?
  60041. * @param to when should the ray end?
  60042. * @returns PhysicsRaycastResult
  60043. */
  60044. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60045. }
  60046. }
  60047. declare module BABYLON {
  60048. interface AbstractScene {
  60049. /**
  60050. * The list of reflection probes added to the scene
  60051. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60052. */
  60053. reflectionProbes: Array<ReflectionProbe>;
  60054. /**
  60055. * Removes the given reflection probe from this scene.
  60056. * @param toRemove The reflection probe to remove
  60057. * @returns The index of the removed reflection probe
  60058. */
  60059. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60060. /**
  60061. * Adds the given reflection probe to this scene.
  60062. * @param newReflectionProbe The reflection probe to add
  60063. */
  60064. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60065. }
  60066. /**
  60067. * Class used to generate realtime reflection / refraction cube textures
  60068. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60069. */
  60070. export class ReflectionProbe {
  60071. /** defines the name of the probe */
  60072. name: string;
  60073. private _scene;
  60074. private _renderTargetTexture;
  60075. private _projectionMatrix;
  60076. private _viewMatrix;
  60077. private _target;
  60078. private _add;
  60079. private _attachedMesh;
  60080. private _invertYAxis;
  60081. /** Gets or sets probe position (center of the cube map) */
  60082. position: Vector3;
  60083. /**
  60084. * Creates a new reflection probe
  60085. * @param name defines the name of the probe
  60086. * @param size defines the texture resolution (for each face)
  60087. * @param scene defines the hosting scene
  60088. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60089. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60090. */
  60091. constructor(
  60092. /** defines the name of the probe */
  60093. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60094. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60095. get samples(): number;
  60096. set samples(value: number);
  60097. /** Gets or sets the refresh rate to use (on every frame by default) */
  60098. get refreshRate(): number;
  60099. set refreshRate(value: number);
  60100. /**
  60101. * Gets the hosting scene
  60102. * @returns a Scene
  60103. */
  60104. getScene(): Scene;
  60105. /** Gets the internal CubeTexture used to render to */
  60106. get cubeTexture(): RenderTargetTexture;
  60107. /** Gets the list of meshes to render */
  60108. get renderList(): Nullable<AbstractMesh[]>;
  60109. /**
  60110. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60111. * @param mesh defines the mesh to attach to
  60112. */
  60113. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60114. /**
  60115. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60116. * @param renderingGroupId The rendering group id corresponding to its index
  60117. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60118. */
  60119. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60120. /**
  60121. * Clean all associated resources
  60122. */
  60123. dispose(): void;
  60124. /**
  60125. * Converts the reflection probe information to a readable string for debug purpose.
  60126. * @param fullDetails Supports for multiple levels of logging within scene loading
  60127. * @returns the human readable reflection probe info
  60128. */
  60129. toString(fullDetails?: boolean): string;
  60130. /**
  60131. * Get the class name of the relfection probe.
  60132. * @returns "ReflectionProbe"
  60133. */
  60134. getClassName(): string;
  60135. /**
  60136. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60137. * @returns The JSON representation of the texture
  60138. */
  60139. serialize(): any;
  60140. /**
  60141. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60142. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60143. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60144. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60145. * @returns The parsed reflection probe if successful
  60146. */
  60147. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60148. }
  60149. }
  60150. declare module BABYLON {
  60151. /** @hidden */
  60152. export var _BabylonLoaderRegistered: boolean;
  60153. /**
  60154. * Helps setting up some configuration for the babylon file loader.
  60155. */
  60156. export class BabylonFileLoaderConfiguration {
  60157. /**
  60158. * The loader does not allow injecting custom physix engine into the plugins.
  60159. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60160. * So you could set this variable to your engine import to make it work.
  60161. */
  60162. static LoaderInjectedPhysicsEngine: any;
  60163. }
  60164. }
  60165. declare module BABYLON {
  60166. /**
  60167. * The Physically based simple base material of BJS.
  60168. *
  60169. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60170. * It is used as the base class for both the specGloss and metalRough conventions.
  60171. */
  60172. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60173. /**
  60174. * Number of Simultaneous lights allowed on the material.
  60175. */
  60176. maxSimultaneousLights: number;
  60177. /**
  60178. * If sets to true, disables all the lights affecting the material.
  60179. */
  60180. disableLighting: boolean;
  60181. /**
  60182. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60183. */
  60184. environmentTexture: BaseTexture;
  60185. /**
  60186. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60187. */
  60188. invertNormalMapX: boolean;
  60189. /**
  60190. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60191. */
  60192. invertNormalMapY: boolean;
  60193. /**
  60194. * Normal map used in the model.
  60195. */
  60196. normalTexture: BaseTexture;
  60197. /**
  60198. * Emissivie color used to self-illuminate the model.
  60199. */
  60200. emissiveColor: Color3;
  60201. /**
  60202. * Emissivie texture used to self-illuminate the model.
  60203. */
  60204. emissiveTexture: BaseTexture;
  60205. /**
  60206. * Occlusion Channel Strenght.
  60207. */
  60208. occlusionStrength: number;
  60209. /**
  60210. * Occlusion Texture of the material (adding extra occlusion effects).
  60211. */
  60212. occlusionTexture: BaseTexture;
  60213. /**
  60214. * Defines the alpha limits in alpha test mode.
  60215. */
  60216. alphaCutOff: number;
  60217. /**
  60218. * Gets the current double sided mode.
  60219. */
  60220. get doubleSided(): boolean;
  60221. /**
  60222. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60223. */
  60224. set doubleSided(value: boolean);
  60225. /**
  60226. * Stores the pre-calculated light information of a mesh in a texture.
  60227. */
  60228. lightmapTexture: BaseTexture;
  60229. /**
  60230. * If true, the light map contains occlusion information instead of lighting info.
  60231. */
  60232. useLightmapAsShadowmap: boolean;
  60233. /**
  60234. * Instantiates a new PBRMaterial instance.
  60235. *
  60236. * @param name The material name
  60237. * @param scene The scene the material will be use in.
  60238. */
  60239. constructor(name: string, scene: Scene);
  60240. getClassName(): string;
  60241. }
  60242. }
  60243. declare module BABYLON {
  60244. /**
  60245. * The PBR material of BJS following the metal roughness convention.
  60246. *
  60247. * This fits to the PBR convention in the GLTF definition:
  60248. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60249. */
  60250. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60251. /**
  60252. * The base color has two different interpretations depending on the value of metalness.
  60253. * When the material is a metal, the base color is the specific measured reflectance value
  60254. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60255. * of the material.
  60256. */
  60257. baseColor: Color3;
  60258. /**
  60259. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60260. * well as opacity information in the alpha channel.
  60261. */
  60262. baseTexture: BaseTexture;
  60263. /**
  60264. * Specifies the metallic scalar value of the material.
  60265. * Can also be used to scale the metalness values of the metallic texture.
  60266. */
  60267. metallic: number;
  60268. /**
  60269. * Specifies the roughness scalar value of the material.
  60270. * Can also be used to scale the roughness values of the metallic texture.
  60271. */
  60272. roughness: number;
  60273. /**
  60274. * Texture containing both the metallic value in the B channel and the
  60275. * roughness value in the G channel to keep better precision.
  60276. */
  60277. metallicRoughnessTexture: BaseTexture;
  60278. /**
  60279. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60280. *
  60281. * @param name The material name
  60282. * @param scene The scene the material will be use in.
  60283. */
  60284. constructor(name: string, scene: Scene);
  60285. /**
  60286. * Return the currrent class name of the material.
  60287. */
  60288. getClassName(): string;
  60289. /**
  60290. * Makes a duplicate of the current material.
  60291. * @param name - name to use for the new material.
  60292. */
  60293. clone(name: string): PBRMetallicRoughnessMaterial;
  60294. /**
  60295. * Serialize the material to a parsable JSON object.
  60296. */
  60297. serialize(): any;
  60298. /**
  60299. * Parses a JSON object correponding to the serialize function.
  60300. */
  60301. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60302. }
  60303. }
  60304. declare module BABYLON {
  60305. /**
  60306. * The PBR material of BJS following the specular glossiness convention.
  60307. *
  60308. * This fits to the PBR convention in the GLTF definition:
  60309. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60310. */
  60311. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60312. /**
  60313. * Specifies the diffuse color of the material.
  60314. */
  60315. diffuseColor: Color3;
  60316. /**
  60317. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60318. * channel.
  60319. */
  60320. diffuseTexture: BaseTexture;
  60321. /**
  60322. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60323. */
  60324. specularColor: Color3;
  60325. /**
  60326. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60327. */
  60328. glossiness: number;
  60329. /**
  60330. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60331. */
  60332. specularGlossinessTexture: BaseTexture;
  60333. /**
  60334. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60335. *
  60336. * @param name The material name
  60337. * @param scene The scene the material will be use in.
  60338. */
  60339. constructor(name: string, scene: Scene);
  60340. /**
  60341. * Return the currrent class name of the material.
  60342. */
  60343. getClassName(): string;
  60344. /**
  60345. * Makes a duplicate of the current material.
  60346. * @param name - name to use for the new material.
  60347. */
  60348. clone(name: string): PBRSpecularGlossinessMaterial;
  60349. /**
  60350. * Serialize the material to a parsable JSON object.
  60351. */
  60352. serialize(): any;
  60353. /**
  60354. * Parses a JSON object correponding to the serialize function.
  60355. */
  60356. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60357. }
  60358. }
  60359. declare module BABYLON {
  60360. /**
  60361. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60362. * It can help converting any input color in a desired output one. This can then be used to create effects
  60363. * from sepia, black and white to sixties or futuristic rendering...
  60364. *
  60365. * The only supported format is currently 3dl.
  60366. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60367. */
  60368. export class ColorGradingTexture extends BaseTexture {
  60369. /**
  60370. * The texture URL.
  60371. */
  60372. url: string;
  60373. /**
  60374. * Empty line regex stored for GC.
  60375. */
  60376. private static _noneEmptyLineRegex;
  60377. private _textureMatrix;
  60378. private _onLoad;
  60379. /**
  60380. * Instantiates a ColorGradingTexture from the following parameters.
  60381. *
  60382. * @param url The location of the color gradind data (currently only supporting 3dl)
  60383. * @param sceneOrEngine The scene or engine the texture will be used in
  60384. * @param onLoad defines a callback triggered when the texture has been loaded
  60385. */
  60386. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60387. /**
  60388. * Fires the onload event from the constructor if requested.
  60389. */
  60390. private _triggerOnLoad;
  60391. /**
  60392. * Returns the texture matrix used in most of the material.
  60393. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60394. */
  60395. getTextureMatrix(): Matrix;
  60396. /**
  60397. * Occurs when the file being loaded is a .3dl LUT file.
  60398. */
  60399. private load3dlTexture;
  60400. /**
  60401. * Starts the loading process of the texture.
  60402. */
  60403. private loadTexture;
  60404. /**
  60405. * Clones the color gradind texture.
  60406. */
  60407. clone(): ColorGradingTexture;
  60408. /**
  60409. * Called during delayed load for textures.
  60410. */
  60411. delayLoad(): void;
  60412. /**
  60413. * Parses a color grading texture serialized by Babylon.
  60414. * @param parsedTexture The texture information being parsedTexture
  60415. * @param scene The scene to load the texture in
  60416. * @param rootUrl The root url of the data assets to load
  60417. * @return A color gradind texture
  60418. */
  60419. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60420. /**
  60421. * Serializes the LUT texture to json format.
  60422. */
  60423. serialize(): any;
  60424. }
  60425. }
  60426. declare module BABYLON {
  60427. /**
  60428. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60429. */
  60430. export class EquiRectangularCubeTexture extends BaseTexture {
  60431. /** The six faces of the cube. */
  60432. private static _FacesMapping;
  60433. private _noMipmap;
  60434. private _onLoad;
  60435. private _onError;
  60436. /** The size of the cubemap. */
  60437. private _size;
  60438. /** The buffer of the image. */
  60439. private _buffer;
  60440. /** The width of the input image. */
  60441. private _width;
  60442. /** The height of the input image. */
  60443. private _height;
  60444. /** The URL to the image. */
  60445. url: string;
  60446. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60447. coordinatesMode: number;
  60448. /**
  60449. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60450. * @param url The location of the image
  60451. * @param scene The scene the texture will be used in
  60452. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60453. * @param noMipmap Forces to not generate the mipmap if true
  60454. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60455. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60456. * @param onLoad — defines a callback called when texture is loaded
  60457. * @param onError — defines a callback called if there is an error
  60458. */
  60459. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60460. /**
  60461. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60462. */
  60463. private loadImage;
  60464. /**
  60465. * Convert the image buffer into a cubemap and create a CubeTexture.
  60466. */
  60467. private loadTexture;
  60468. /**
  60469. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60470. * @param buffer The ArrayBuffer that should be converted.
  60471. * @returns The buffer as Float32Array.
  60472. */
  60473. private getFloat32ArrayFromArrayBuffer;
  60474. /**
  60475. * Get the current class name of the texture useful for serialization or dynamic coding.
  60476. * @returns "EquiRectangularCubeTexture"
  60477. */
  60478. getClassName(): string;
  60479. /**
  60480. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60481. * @returns A clone of the current EquiRectangularCubeTexture.
  60482. */
  60483. clone(): EquiRectangularCubeTexture;
  60484. }
  60485. }
  60486. declare module BABYLON {
  60487. /**
  60488. * Defines the options related to the creation of an HtmlElementTexture
  60489. */
  60490. export interface IHtmlElementTextureOptions {
  60491. /**
  60492. * Defines wether mip maps should be created or not.
  60493. */
  60494. generateMipMaps?: boolean;
  60495. /**
  60496. * Defines the sampling mode of the texture.
  60497. */
  60498. samplingMode?: number;
  60499. /**
  60500. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60501. */
  60502. engine: Nullable<ThinEngine>;
  60503. /**
  60504. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60505. */
  60506. scene: Nullable<Scene>;
  60507. }
  60508. /**
  60509. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60510. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60511. * is automatically managed.
  60512. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60513. * in your application.
  60514. *
  60515. * As the update is not automatic, you need to call them manually.
  60516. */
  60517. export class HtmlElementTexture extends BaseTexture {
  60518. /**
  60519. * The texture URL.
  60520. */
  60521. element: HTMLVideoElement | HTMLCanvasElement;
  60522. private static readonly DefaultOptions;
  60523. private _textureMatrix;
  60524. private _isVideo;
  60525. private _generateMipMaps;
  60526. private _samplingMode;
  60527. /**
  60528. * Instantiates a HtmlElementTexture from the following parameters.
  60529. *
  60530. * @param name Defines the name of the texture
  60531. * @param element Defines the video or canvas the texture is filled with
  60532. * @param options Defines the other none mandatory texture creation options
  60533. */
  60534. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60535. private _createInternalTexture;
  60536. /**
  60537. * Returns the texture matrix used in most of the material.
  60538. */
  60539. getTextureMatrix(): Matrix;
  60540. /**
  60541. * Updates the content of the texture.
  60542. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60543. */
  60544. update(invertY?: Nullable<boolean>): void;
  60545. }
  60546. }
  60547. declare module BABYLON {
  60548. /**
  60549. * Based on jsTGALoader - Javascript loader for TGA file
  60550. * By Vincent Thibault
  60551. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60552. */
  60553. export class TGATools {
  60554. private static _TYPE_INDEXED;
  60555. private static _TYPE_RGB;
  60556. private static _TYPE_GREY;
  60557. private static _TYPE_RLE_INDEXED;
  60558. private static _TYPE_RLE_RGB;
  60559. private static _TYPE_RLE_GREY;
  60560. private static _ORIGIN_MASK;
  60561. private static _ORIGIN_SHIFT;
  60562. private static _ORIGIN_BL;
  60563. private static _ORIGIN_BR;
  60564. private static _ORIGIN_UL;
  60565. private static _ORIGIN_UR;
  60566. /**
  60567. * Gets the header of a TGA file
  60568. * @param data defines the TGA data
  60569. * @returns the header
  60570. */
  60571. static GetTGAHeader(data: Uint8Array): any;
  60572. /**
  60573. * Uploads TGA content to a Babylon Texture
  60574. * @hidden
  60575. */
  60576. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60577. /** @hidden */
  60578. 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;
  60579. /** @hidden */
  60580. 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;
  60581. /** @hidden */
  60582. 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;
  60583. /** @hidden */
  60584. 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;
  60585. /** @hidden */
  60586. 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;
  60587. /** @hidden */
  60588. 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;
  60589. }
  60590. }
  60591. declare module BABYLON {
  60592. /**
  60593. * Implementation of the TGA Texture Loader.
  60594. * @hidden
  60595. */
  60596. export class _TGATextureLoader implements IInternalTextureLoader {
  60597. /**
  60598. * Defines wether the loader supports cascade loading the different faces.
  60599. */
  60600. readonly supportCascades: boolean;
  60601. /**
  60602. * This returns if the loader support the current file information.
  60603. * @param extension defines the file extension of the file being loaded
  60604. * @returns true if the loader can load the specified file
  60605. */
  60606. canLoad(extension: string): boolean;
  60607. /**
  60608. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60609. * @param data contains the texture data
  60610. * @param texture defines the BabylonJS internal texture
  60611. * @param createPolynomials will be true if polynomials have been requested
  60612. * @param onLoad defines the callback to trigger once the texture is ready
  60613. * @param onError defines the callback to trigger in case of error
  60614. */
  60615. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60616. /**
  60617. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60618. * @param data contains the texture data
  60619. * @param texture defines the BabylonJS internal texture
  60620. * @param callback defines the method to call once ready to upload
  60621. */
  60622. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60623. }
  60624. }
  60625. declare module BABYLON {
  60626. /**
  60627. * Info about the .basis files
  60628. */
  60629. class BasisFileInfo {
  60630. /**
  60631. * If the file has alpha
  60632. */
  60633. hasAlpha: boolean;
  60634. /**
  60635. * Info about each image of the basis file
  60636. */
  60637. images: Array<{
  60638. levels: Array<{
  60639. width: number;
  60640. height: number;
  60641. transcodedPixels: ArrayBufferView;
  60642. }>;
  60643. }>;
  60644. }
  60645. /**
  60646. * Result of transcoding a basis file
  60647. */
  60648. class TranscodeResult {
  60649. /**
  60650. * Info about the .basis file
  60651. */
  60652. fileInfo: BasisFileInfo;
  60653. /**
  60654. * Format to use when loading the file
  60655. */
  60656. format: number;
  60657. }
  60658. /**
  60659. * Configuration options for the Basis transcoder
  60660. */
  60661. export class BasisTranscodeConfiguration {
  60662. /**
  60663. * Supported compression formats used to determine the supported output format of the transcoder
  60664. */
  60665. supportedCompressionFormats?: {
  60666. /**
  60667. * etc1 compression format
  60668. */
  60669. etc1?: boolean;
  60670. /**
  60671. * s3tc compression format
  60672. */
  60673. s3tc?: boolean;
  60674. /**
  60675. * pvrtc compression format
  60676. */
  60677. pvrtc?: boolean;
  60678. /**
  60679. * etc2 compression format
  60680. */
  60681. etc2?: boolean;
  60682. };
  60683. /**
  60684. * If mipmap levels should be loaded for transcoded images (Default: true)
  60685. */
  60686. loadMipmapLevels?: boolean;
  60687. /**
  60688. * Index of a single image to load (Default: all images)
  60689. */
  60690. loadSingleImage?: number;
  60691. }
  60692. /**
  60693. * Used to load .Basis files
  60694. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60695. */
  60696. export class BasisTools {
  60697. private static _IgnoreSupportedFormats;
  60698. /**
  60699. * URL to use when loading the basis transcoder
  60700. */
  60701. static JSModuleURL: string;
  60702. /**
  60703. * URL to use when loading the wasm module for the transcoder
  60704. */
  60705. static WasmModuleURL: string;
  60706. /**
  60707. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60708. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60709. * @returns internal format corresponding to the Basis format
  60710. */
  60711. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60712. private static _WorkerPromise;
  60713. private static _Worker;
  60714. private static _actionId;
  60715. private static _CreateWorkerAsync;
  60716. /**
  60717. * Transcodes a loaded image file to compressed pixel data
  60718. * @param data image data to transcode
  60719. * @param config configuration options for the transcoding
  60720. * @returns a promise resulting in the transcoded image
  60721. */
  60722. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60723. /**
  60724. * Loads a texture from the transcode result
  60725. * @param texture texture load to
  60726. * @param transcodeResult the result of transcoding the basis file to load from
  60727. */
  60728. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60729. }
  60730. }
  60731. declare module BABYLON {
  60732. /**
  60733. * Loader for .basis file format
  60734. */
  60735. export class _BasisTextureLoader implements IInternalTextureLoader {
  60736. /**
  60737. * Defines whether the loader supports cascade loading the different faces.
  60738. */
  60739. readonly supportCascades: boolean;
  60740. /**
  60741. * This returns if the loader support the current file information.
  60742. * @param extension defines the file extension of the file being loaded
  60743. * @returns true if the loader can load the specified file
  60744. */
  60745. canLoad(extension: string): boolean;
  60746. /**
  60747. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60748. * @param data contains the texture data
  60749. * @param texture defines the BabylonJS internal texture
  60750. * @param createPolynomials will be true if polynomials have been requested
  60751. * @param onLoad defines the callback to trigger once the texture is ready
  60752. * @param onError defines the callback to trigger in case of error
  60753. */
  60754. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60755. /**
  60756. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60757. * @param data contains the texture data
  60758. * @param texture defines the BabylonJS internal texture
  60759. * @param callback defines the method to call once ready to upload
  60760. */
  60761. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60762. }
  60763. }
  60764. declare module BABYLON {
  60765. /**
  60766. * Defines the basic options interface of a TexturePacker Frame
  60767. */
  60768. export interface ITexturePackerFrame {
  60769. /**
  60770. * The frame ID
  60771. */
  60772. id: number;
  60773. /**
  60774. * The frames Scale
  60775. */
  60776. scale: Vector2;
  60777. /**
  60778. * The Frames offset
  60779. */
  60780. offset: Vector2;
  60781. }
  60782. /**
  60783. * This is a support class for frame Data on texture packer sets.
  60784. */
  60785. export class TexturePackerFrame implements ITexturePackerFrame {
  60786. /**
  60787. * The frame ID
  60788. */
  60789. id: number;
  60790. /**
  60791. * The frames Scale
  60792. */
  60793. scale: Vector2;
  60794. /**
  60795. * The Frames offset
  60796. */
  60797. offset: Vector2;
  60798. /**
  60799. * Initializes a texture package frame.
  60800. * @param id The numerical frame identifier
  60801. * @param scale Scalar Vector2 for UV frame
  60802. * @param offset Vector2 for the frame position in UV units.
  60803. * @returns TexturePackerFrame
  60804. */
  60805. constructor(id: number, scale: Vector2, offset: Vector2);
  60806. }
  60807. }
  60808. declare module BABYLON {
  60809. /**
  60810. * Defines the basic options interface of a TexturePacker
  60811. */
  60812. export interface ITexturePackerOptions {
  60813. /**
  60814. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60815. */
  60816. map?: string[];
  60817. /**
  60818. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60819. */
  60820. uvsIn?: string;
  60821. /**
  60822. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60823. */
  60824. uvsOut?: string;
  60825. /**
  60826. * number representing the layout style. Defaults to LAYOUT_STRIP
  60827. */
  60828. layout?: number;
  60829. /**
  60830. * number of columns if using custom column count layout(2). This defaults to 4.
  60831. */
  60832. colnum?: number;
  60833. /**
  60834. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60835. */
  60836. updateInputMeshes?: boolean;
  60837. /**
  60838. * boolean flag to dispose all the source textures. Defaults to true.
  60839. */
  60840. disposeSources?: boolean;
  60841. /**
  60842. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60843. */
  60844. fillBlanks?: boolean;
  60845. /**
  60846. * string value representing the context fill style color. Defaults to 'black'.
  60847. */
  60848. customFillColor?: string;
  60849. /**
  60850. * Width and Height Value of each Frame in the TexturePacker Sets
  60851. */
  60852. frameSize?: number;
  60853. /**
  60854. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60855. */
  60856. paddingRatio?: number;
  60857. /**
  60858. * Number that declares the fill method for the padding gutter.
  60859. */
  60860. paddingMode?: number;
  60861. /**
  60862. * If in SUBUV_COLOR padding mode what color to use.
  60863. */
  60864. paddingColor?: Color3 | Color4;
  60865. }
  60866. /**
  60867. * Defines the basic interface of a TexturePacker JSON File
  60868. */
  60869. export interface ITexturePackerJSON {
  60870. /**
  60871. * The frame ID
  60872. */
  60873. name: string;
  60874. /**
  60875. * The base64 channel data
  60876. */
  60877. sets: any;
  60878. /**
  60879. * The options of the Packer
  60880. */
  60881. options: ITexturePackerOptions;
  60882. /**
  60883. * The frame data of the Packer
  60884. */
  60885. frames: Array<number>;
  60886. }
  60887. /**
  60888. * This is a support class that generates a series of packed texture sets.
  60889. * @see https://doc.babylonjs.com/babylon101/materials
  60890. */
  60891. export class TexturePacker {
  60892. /** Packer Layout Constant 0 */
  60893. static readonly LAYOUT_STRIP: number;
  60894. /** Packer Layout Constant 1 */
  60895. static readonly LAYOUT_POWER2: number;
  60896. /** Packer Layout Constant 2 */
  60897. static readonly LAYOUT_COLNUM: number;
  60898. /** Packer Layout Constant 0 */
  60899. static readonly SUBUV_WRAP: number;
  60900. /** Packer Layout Constant 1 */
  60901. static readonly SUBUV_EXTEND: number;
  60902. /** Packer Layout Constant 2 */
  60903. static readonly SUBUV_COLOR: number;
  60904. /** The Name of the Texture Package */
  60905. name: string;
  60906. /** The scene scope of the TexturePacker */
  60907. scene: Scene;
  60908. /** The Meshes to target */
  60909. meshes: AbstractMesh[];
  60910. /** Arguments passed with the Constructor */
  60911. options: ITexturePackerOptions;
  60912. /** The promise that is started upon initialization */
  60913. promise: Nullable<Promise<TexturePacker | string>>;
  60914. /** The Container object for the channel sets that are generated */
  60915. sets: object;
  60916. /** The Container array for the frames that are generated */
  60917. frames: TexturePackerFrame[];
  60918. /** The expected number of textures the system is parsing. */
  60919. private _expecting;
  60920. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60921. private _paddingValue;
  60922. /**
  60923. * Initializes a texture package series from an array of meshes or a single mesh.
  60924. * @param name The name of the package
  60925. * @param meshes The target meshes to compose the package from
  60926. * @param options The arguments that texture packer should follow while building.
  60927. * @param scene The scene which the textures are scoped to.
  60928. * @returns TexturePacker
  60929. */
  60930. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60931. /**
  60932. * Starts the package process
  60933. * @param resolve The promises resolution function
  60934. * @returns TexturePacker
  60935. */
  60936. private _createFrames;
  60937. /**
  60938. * Calculates the Size of the Channel Sets
  60939. * @returns Vector2
  60940. */
  60941. private _calculateSize;
  60942. /**
  60943. * Calculates the UV data for the frames.
  60944. * @param baseSize the base frameSize
  60945. * @param padding the base frame padding
  60946. * @param dtSize size of the Dynamic Texture for that channel
  60947. * @param dtUnits is 1/dtSize
  60948. * @param update flag to update the input meshes
  60949. */
  60950. private _calculateMeshUVFrames;
  60951. /**
  60952. * Calculates the frames Offset.
  60953. * @param index of the frame
  60954. * @returns Vector2
  60955. */
  60956. private _getFrameOffset;
  60957. /**
  60958. * Updates a Mesh to the frame data
  60959. * @param mesh that is the target
  60960. * @param frameID or the frame index
  60961. */
  60962. private _updateMeshUV;
  60963. /**
  60964. * Updates a Meshes materials to use the texture packer channels
  60965. * @param m is the mesh to target
  60966. * @param force all channels on the packer to be set.
  60967. */
  60968. private _updateTextureReferences;
  60969. /**
  60970. * Public method to set a Mesh to a frame
  60971. * @param m that is the target
  60972. * @param frameID or the frame index
  60973. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60974. */
  60975. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60976. /**
  60977. * Starts the async promise to compile the texture packer.
  60978. * @returns Promise<void>
  60979. */
  60980. processAsync(): Promise<void>;
  60981. /**
  60982. * Disposes all textures associated with this packer
  60983. */
  60984. dispose(): void;
  60985. /**
  60986. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60987. * @param imageType is the image type to use.
  60988. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60989. */
  60990. download(imageType?: string, quality?: number): void;
  60991. /**
  60992. * Public method to load a texturePacker JSON file.
  60993. * @param data of the JSON file in string format.
  60994. */
  60995. updateFromJSON(data: string): void;
  60996. }
  60997. }
  60998. declare module BABYLON {
  60999. /**
  61000. * 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.
  61001. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61002. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61003. */
  61004. export class CustomProceduralTexture extends ProceduralTexture {
  61005. private _animate;
  61006. private _time;
  61007. private _config;
  61008. private _texturePath;
  61009. /**
  61010. * Instantiates a new Custom Procedural Texture.
  61011. * 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.
  61012. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61013. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61014. * @param name Define the name of the texture
  61015. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61016. * @param size Define the size of the texture to create
  61017. * @param scene Define the scene the texture belongs to
  61018. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61019. * @param generateMipMaps Define if the texture should creates mip maps or not
  61020. */
  61021. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61022. private _loadJson;
  61023. /**
  61024. * Is the texture ready to be used ? (rendered at least once)
  61025. * @returns true if ready, otherwise, false.
  61026. */
  61027. isReady(): boolean;
  61028. /**
  61029. * Render the texture to its associated render target.
  61030. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61031. */
  61032. render(useCameraPostProcess?: boolean): void;
  61033. /**
  61034. * Update the list of dependant textures samplers in the shader.
  61035. */
  61036. updateTextures(): void;
  61037. /**
  61038. * Update the uniform values of the procedural texture in the shader.
  61039. */
  61040. updateShaderUniforms(): void;
  61041. /**
  61042. * Define if the texture animates or not.
  61043. */
  61044. get animate(): boolean;
  61045. set animate(value: boolean);
  61046. }
  61047. }
  61048. declare module BABYLON {
  61049. /** @hidden */
  61050. export var noisePixelShader: {
  61051. name: string;
  61052. shader: string;
  61053. };
  61054. }
  61055. declare module BABYLON {
  61056. /**
  61057. * Class used to generate noise procedural textures
  61058. */
  61059. export class NoiseProceduralTexture extends ProceduralTexture {
  61060. private _time;
  61061. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61062. brightness: number;
  61063. /** Defines the number of octaves to process */
  61064. octaves: number;
  61065. /** Defines the level of persistence (0.8 by default) */
  61066. persistence: number;
  61067. /** Gets or sets animation speed factor (default is 1) */
  61068. animationSpeedFactor: number;
  61069. /**
  61070. * Creates a new NoiseProceduralTexture
  61071. * @param name defines the name fo the texture
  61072. * @param size defines the size of the texture (default is 256)
  61073. * @param scene defines the hosting scene
  61074. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61075. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61076. */
  61077. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61078. private _updateShaderUniforms;
  61079. protected _getDefines(): string;
  61080. /** Generate the current state of the procedural texture */
  61081. render(useCameraPostProcess?: boolean): void;
  61082. /**
  61083. * Serializes this noise procedural texture
  61084. * @returns a serialized noise procedural texture object
  61085. */
  61086. serialize(): any;
  61087. /**
  61088. * Clone the texture.
  61089. * @returns the cloned texture
  61090. */
  61091. clone(): NoiseProceduralTexture;
  61092. /**
  61093. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61094. * @param parsedTexture defines parsed texture data
  61095. * @param scene defines the current scene
  61096. * @param rootUrl defines the root URL containing noise procedural texture information
  61097. * @returns a parsed NoiseProceduralTexture
  61098. */
  61099. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61100. }
  61101. }
  61102. declare module BABYLON {
  61103. /**
  61104. * Raw cube texture where the raw buffers are passed in
  61105. */
  61106. export class RawCubeTexture extends CubeTexture {
  61107. /**
  61108. * Creates a cube texture where the raw buffers are passed in.
  61109. * @param scene defines the scene the texture is attached to
  61110. * @param data defines the array of data to use to create each face
  61111. * @param size defines the size of the textures
  61112. * @param format defines the format of the data
  61113. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61114. * @param generateMipMaps defines if the engine should generate the mip levels
  61115. * @param invertY defines if data must be stored with Y axis inverted
  61116. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61117. * @param compression defines the compression used (null by default)
  61118. */
  61119. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61120. /**
  61121. * Updates the raw cube texture.
  61122. * @param data defines the data to store
  61123. * @param format defines the data format
  61124. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61125. * @param invertY defines if data must be stored with Y axis inverted
  61126. * @param compression defines the compression used (null by default)
  61127. * @param level defines which level of the texture to update
  61128. */
  61129. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61130. /**
  61131. * Updates a raw cube texture with RGBD encoded data.
  61132. * @param data defines the array of data [mipmap][face] to use to create each face
  61133. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61134. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61135. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61136. * @returns a promsie that resolves when the operation is complete
  61137. */
  61138. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61139. /**
  61140. * Clones the raw cube texture.
  61141. * @return a new cube texture
  61142. */
  61143. clone(): CubeTexture;
  61144. /** @hidden */
  61145. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61146. }
  61147. }
  61148. declare module BABYLON {
  61149. /**
  61150. * Class used to store 2D array textures containing user data
  61151. */
  61152. export class RawTexture2DArray extends Texture {
  61153. /** Gets or sets the texture format to use */
  61154. format: number;
  61155. /**
  61156. * Create a new RawTexture2DArray
  61157. * @param data defines the data of the texture
  61158. * @param width defines the width of the texture
  61159. * @param height defines the height of the texture
  61160. * @param depth defines the number of layers of the texture
  61161. * @param format defines the texture format to use
  61162. * @param scene defines the hosting scene
  61163. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61164. * @param invertY defines if texture must be stored with Y axis inverted
  61165. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61166. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61167. */
  61168. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61169. /** Gets or sets the texture format to use */
  61170. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61171. /**
  61172. * Update the texture with new data
  61173. * @param data defines the data to store in the texture
  61174. */
  61175. update(data: ArrayBufferView): void;
  61176. }
  61177. }
  61178. declare module BABYLON {
  61179. /**
  61180. * Class used to store 3D textures containing user data
  61181. */
  61182. export class RawTexture3D extends Texture {
  61183. /** Gets or sets the texture format to use */
  61184. format: number;
  61185. /**
  61186. * Create a new RawTexture3D
  61187. * @param data defines the data of the texture
  61188. * @param width defines the width of the texture
  61189. * @param height defines the height of the texture
  61190. * @param depth defines the depth of the texture
  61191. * @param format defines the texture format to use
  61192. * @param scene defines the hosting scene
  61193. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61194. * @param invertY defines if texture must be stored with Y axis inverted
  61195. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61196. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61197. */
  61198. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61199. /** Gets or sets the texture format to use */
  61200. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61201. /**
  61202. * Update the texture with new data
  61203. * @param data defines the data to store in the texture
  61204. */
  61205. update(data: ArrayBufferView): void;
  61206. }
  61207. }
  61208. declare module BABYLON {
  61209. /**
  61210. * Creates a refraction texture used by refraction channel of the standard material.
  61211. * It is like a mirror but to see through a material.
  61212. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61213. */
  61214. export class RefractionTexture extends RenderTargetTexture {
  61215. /**
  61216. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61217. * 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.
  61218. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61219. */
  61220. refractionPlane: Plane;
  61221. /**
  61222. * Define how deep under the surface we should see.
  61223. */
  61224. depth: number;
  61225. /**
  61226. * Creates a refraction texture used by refraction channel of the standard material.
  61227. * It is like a mirror but to see through a material.
  61228. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61229. * @param name Define the texture name
  61230. * @param size Define the size of the underlying texture
  61231. * @param scene Define the scene the refraction belongs to
  61232. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61233. */
  61234. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61235. /**
  61236. * Clone the refraction texture.
  61237. * @returns the cloned texture
  61238. */
  61239. clone(): RefractionTexture;
  61240. /**
  61241. * Serialize the texture to a JSON representation you could use in Parse later on
  61242. * @returns the serialized JSON representation
  61243. */
  61244. serialize(): any;
  61245. }
  61246. }
  61247. declare module BABYLON {
  61248. /**
  61249. * Block used to add support for vertex skinning (bones)
  61250. */
  61251. export class BonesBlock extends NodeMaterialBlock {
  61252. /**
  61253. * Creates a new BonesBlock
  61254. * @param name defines the block name
  61255. */
  61256. constructor(name: string);
  61257. /**
  61258. * Initialize the block and prepare the context for build
  61259. * @param state defines the state that will be used for the build
  61260. */
  61261. initialize(state: NodeMaterialBuildState): void;
  61262. /**
  61263. * Gets the current class name
  61264. * @returns the class name
  61265. */
  61266. getClassName(): string;
  61267. /**
  61268. * Gets the matrix indices input component
  61269. */
  61270. get matricesIndices(): NodeMaterialConnectionPoint;
  61271. /**
  61272. * Gets the matrix weights input component
  61273. */
  61274. get matricesWeights(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Gets the extra matrix indices input component
  61277. */
  61278. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Gets the extra matrix weights input component
  61281. */
  61282. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61283. /**
  61284. * Gets the world input component
  61285. */
  61286. get world(): NodeMaterialConnectionPoint;
  61287. /**
  61288. * Gets the output component
  61289. */
  61290. get output(): NodeMaterialConnectionPoint;
  61291. autoConfigure(material: NodeMaterial): void;
  61292. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61294. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61295. protected _buildBlock(state: NodeMaterialBuildState): this;
  61296. }
  61297. }
  61298. declare module BABYLON {
  61299. /**
  61300. * Block used to add support for instances
  61301. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61302. */
  61303. export class InstancesBlock extends NodeMaterialBlock {
  61304. /**
  61305. * Creates a new InstancesBlock
  61306. * @param name defines the block name
  61307. */
  61308. constructor(name: string);
  61309. /**
  61310. * Gets the current class name
  61311. * @returns the class name
  61312. */
  61313. getClassName(): string;
  61314. /**
  61315. * Gets the first world row input component
  61316. */
  61317. get world0(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the second world row input component
  61320. */
  61321. get world1(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the third world row input component
  61324. */
  61325. get world2(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the forth world row input component
  61328. */
  61329. get world3(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the world input component
  61332. */
  61333. get world(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the output component
  61336. */
  61337. get output(): NodeMaterialConnectionPoint;
  61338. /**
  61339. * Gets the isntanceID component
  61340. */
  61341. get instanceID(): NodeMaterialConnectionPoint;
  61342. autoConfigure(material: NodeMaterial): void;
  61343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61344. protected _buildBlock(state: NodeMaterialBuildState): this;
  61345. }
  61346. }
  61347. declare module BABYLON {
  61348. /**
  61349. * Block used to add morph targets support to vertex shader
  61350. */
  61351. export class MorphTargetsBlock extends NodeMaterialBlock {
  61352. private _repeatableContentAnchor;
  61353. /**
  61354. * Create a new MorphTargetsBlock
  61355. * @param name defines the block name
  61356. */
  61357. constructor(name: string);
  61358. /**
  61359. * Gets the current class name
  61360. * @returns the class name
  61361. */
  61362. getClassName(): string;
  61363. /**
  61364. * Gets the position input component
  61365. */
  61366. get position(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the normal input component
  61369. */
  61370. get normal(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the tangent input component
  61373. */
  61374. get tangent(): NodeMaterialConnectionPoint;
  61375. /**
  61376. * Gets the tangent input component
  61377. */
  61378. get uv(): NodeMaterialConnectionPoint;
  61379. /**
  61380. * Gets the position output component
  61381. */
  61382. get positionOutput(): NodeMaterialConnectionPoint;
  61383. /**
  61384. * Gets the normal output component
  61385. */
  61386. get normalOutput(): NodeMaterialConnectionPoint;
  61387. /**
  61388. * Gets the tangent output component
  61389. */
  61390. get tangentOutput(): NodeMaterialConnectionPoint;
  61391. /**
  61392. * Gets the tangent output component
  61393. */
  61394. get uvOutput(): NodeMaterialConnectionPoint;
  61395. initialize(state: NodeMaterialBuildState): void;
  61396. autoConfigure(material: NodeMaterial): void;
  61397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61398. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61399. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61400. protected _buildBlock(state: NodeMaterialBuildState): this;
  61401. }
  61402. }
  61403. declare module BABYLON {
  61404. /**
  61405. * Block used to get data information from a light
  61406. */
  61407. export class LightInformationBlock extends NodeMaterialBlock {
  61408. private _lightDataUniformName;
  61409. private _lightColorUniformName;
  61410. private _lightTypeDefineName;
  61411. /**
  61412. * Gets or sets the light associated with this block
  61413. */
  61414. light: Nullable<Light>;
  61415. /**
  61416. * Creates a new LightInformationBlock
  61417. * @param name defines the block name
  61418. */
  61419. constructor(name: string);
  61420. /**
  61421. * Gets the current class name
  61422. * @returns the class name
  61423. */
  61424. getClassName(): string;
  61425. /**
  61426. * Gets the world position input component
  61427. */
  61428. get worldPosition(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the direction output component
  61431. */
  61432. get direction(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the direction output component
  61435. */
  61436. get color(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the direction output component
  61439. */
  61440. get intensity(): NodeMaterialConnectionPoint;
  61441. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61443. protected _buildBlock(state: NodeMaterialBuildState): this;
  61444. serialize(): any;
  61445. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61446. }
  61447. }
  61448. declare module BABYLON {
  61449. /**
  61450. * Block used to add image processing support to fragment shader
  61451. */
  61452. export class ImageProcessingBlock extends NodeMaterialBlock {
  61453. /**
  61454. * Create a new ImageProcessingBlock
  61455. * @param name defines the block name
  61456. */
  61457. constructor(name: string);
  61458. /**
  61459. * Gets the current class name
  61460. * @returns the class name
  61461. */
  61462. getClassName(): string;
  61463. /**
  61464. * Gets the color input component
  61465. */
  61466. get color(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the output component
  61469. */
  61470. get output(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Initialize the block and prepare the context for build
  61473. * @param state defines the state that will be used for the build
  61474. */
  61475. initialize(state: NodeMaterialBuildState): void;
  61476. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61477. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61479. protected _buildBlock(state: NodeMaterialBuildState): this;
  61480. }
  61481. }
  61482. declare module BABYLON {
  61483. /**
  61484. * Block used to pertub normals based on a normal map
  61485. */
  61486. export class PerturbNormalBlock extends NodeMaterialBlock {
  61487. private _tangentSpaceParameterName;
  61488. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61489. invertX: boolean;
  61490. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61491. invertY: boolean;
  61492. /**
  61493. * Create a new PerturbNormalBlock
  61494. * @param name defines the block name
  61495. */
  61496. constructor(name: string);
  61497. /**
  61498. * Gets the current class name
  61499. * @returns the class name
  61500. */
  61501. getClassName(): string;
  61502. /**
  61503. * Gets the world position input component
  61504. */
  61505. get worldPosition(): NodeMaterialConnectionPoint;
  61506. /**
  61507. * Gets the world normal input component
  61508. */
  61509. get worldNormal(): NodeMaterialConnectionPoint;
  61510. /**
  61511. * Gets the world tangent input component
  61512. */
  61513. get worldTangent(): NodeMaterialConnectionPoint;
  61514. /**
  61515. * Gets the uv input component
  61516. */
  61517. get uv(): NodeMaterialConnectionPoint;
  61518. /**
  61519. * Gets the normal map color input component
  61520. */
  61521. get normalMapColor(): NodeMaterialConnectionPoint;
  61522. /**
  61523. * Gets the strength input component
  61524. */
  61525. get strength(): NodeMaterialConnectionPoint;
  61526. /**
  61527. * Gets the output component
  61528. */
  61529. get output(): NodeMaterialConnectionPoint;
  61530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61531. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61532. autoConfigure(material: NodeMaterial): void;
  61533. protected _buildBlock(state: NodeMaterialBuildState): this;
  61534. protected _dumpPropertiesCode(): string;
  61535. serialize(): any;
  61536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61537. }
  61538. }
  61539. declare module BABYLON {
  61540. /**
  61541. * Block used to discard a pixel if a value is smaller than a cutoff
  61542. */
  61543. export class DiscardBlock extends NodeMaterialBlock {
  61544. /**
  61545. * Create a new DiscardBlock
  61546. * @param name defines the block name
  61547. */
  61548. constructor(name: string);
  61549. /**
  61550. * Gets the current class name
  61551. * @returns the class name
  61552. */
  61553. getClassName(): string;
  61554. /**
  61555. * Gets the color input component
  61556. */
  61557. get value(): NodeMaterialConnectionPoint;
  61558. /**
  61559. * Gets the cutoff input component
  61560. */
  61561. get cutoff(): NodeMaterialConnectionPoint;
  61562. protected _buildBlock(state: NodeMaterialBuildState): this;
  61563. }
  61564. }
  61565. declare module BABYLON {
  61566. /**
  61567. * Block used to test if the fragment shader is front facing
  61568. */
  61569. export class FrontFacingBlock extends NodeMaterialBlock {
  61570. /**
  61571. * Creates a new FrontFacingBlock
  61572. * @param name defines the block name
  61573. */
  61574. constructor(name: string);
  61575. /**
  61576. * Gets the current class name
  61577. * @returns the class name
  61578. */
  61579. getClassName(): string;
  61580. /**
  61581. * Gets the output component
  61582. */
  61583. get output(): NodeMaterialConnectionPoint;
  61584. protected _buildBlock(state: NodeMaterialBuildState): this;
  61585. }
  61586. }
  61587. declare module BABYLON {
  61588. /**
  61589. * Block used to get the derivative value on x and y of a given input
  61590. */
  61591. export class DerivativeBlock extends NodeMaterialBlock {
  61592. /**
  61593. * Create a new DerivativeBlock
  61594. * @param name defines the block name
  61595. */
  61596. constructor(name: string);
  61597. /**
  61598. * Gets the current class name
  61599. * @returns the class name
  61600. */
  61601. getClassName(): string;
  61602. /**
  61603. * Gets the input component
  61604. */
  61605. get input(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the derivative output on x
  61608. */
  61609. get dx(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the derivative output on y
  61612. */
  61613. get dy(): NodeMaterialConnectionPoint;
  61614. protected _buildBlock(state: NodeMaterialBuildState): this;
  61615. }
  61616. }
  61617. declare module BABYLON {
  61618. /**
  61619. * Block used to make gl_FragCoord available
  61620. */
  61621. export class FragCoordBlock extends NodeMaterialBlock {
  61622. /**
  61623. * Creates a new FragCoordBlock
  61624. * @param name defines the block name
  61625. */
  61626. constructor(name: string);
  61627. /**
  61628. * Gets the current class name
  61629. * @returns the class name
  61630. */
  61631. getClassName(): string;
  61632. /**
  61633. * Gets the xy component
  61634. */
  61635. get xy(): NodeMaterialConnectionPoint;
  61636. /**
  61637. * Gets the xyz component
  61638. */
  61639. get xyz(): NodeMaterialConnectionPoint;
  61640. /**
  61641. * Gets the xyzw component
  61642. */
  61643. get xyzw(): NodeMaterialConnectionPoint;
  61644. /**
  61645. * Gets the x component
  61646. */
  61647. get x(): NodeMaterialConnectionPoint;
  61648. /**
  61649. * Gets the y component
  61650. */
  61651. get y(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the z component
  61654. */
  61655. get z(): NodeMaterialConnectionPoint;
  61656. /**
  61657. * Gets the w component
  61658. */
  61659. get output(): NodeMaterialConnectionPoint;
  61660. protected writeOutputs(state: NodeMaterialBuildState): string;
  61661. protected _buildBlock(state: NodeMaterialBuildState): this;
  61662. }
  61663. }
  61664. declare module BABYLON {
  61665. /**
  61666. * Block used to get the screen sizes
  61667. */
  61668. export class ScreenSizeBlock extends NodeMaterialBlock {
  61669. private _varName;
  61670. private _scene;
  61671. /**
  61672. * Creates a new ScreenSizeBlock
  61673. * @param name defines the block name
  61674. */
  61675. constructor(name: string);
  61676. /**
  61677. * Gets the current class name
  61678. * @returns the class name
  61679. */
  61680. getClassName(): string;
  61681. /**
  61682. * Gets the xy component
  61683. */
  61684. get xy(): NodeMaterialConnectionPoint;
  61685. /**
  61686. * Gets the x component
  61687. */
  61688. get x(): NodeMaterialConnectionPoint;
  61689. /**
  61690. * Gets the y component
  61691. */
  61692. get y(): NodeMaterialConnectionPoint;
  61693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61694. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61695. protected _buildBlock(state: NodeMaterialBuildState): this;
  61696. }
  61697. }
  61698. declare module BABYLON {
  61699. /**
  61700. * Block used to add support for scene fog
  61701. */
  61702. export class FogBlock extends NodeMaterialBlock {
  61703. private _fogDistanceName;
  61704. private _fogParameters;
  61705. /**
  61706. * Create a new FogBlock
  61707. * @param name defines the block name
  61708. */
  61709. constructor(name: string);
  61710. /**
  61711. * Gets the current class name
  61712. * @returns the class name
  61713. */
  61714. getClassName(): string;
  61715. /**
  61716. * Gets the world position input component
  61717. */
  61718. get worldPosition(): NodeMaterialConnectionPoint;
  61719. /**
  61720. * Gets the view input component
  61721. */
  61722. get view(): NodeMaterialConnectionPoint;
  61723. /**
  61724. * Gets the color input component
  61725. */
  61726. get input(): NodeMaterialConnectionPoint;
  61727. /**
  61728. * Gets the fog color input component
  61729. */
  61730. get fogColor(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the output component
  61733. */
  61734. get output(): NodeMaterialConnectionPoint;
  61735. autoConfigure(material: NodeMaterial): void;
  61736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61738. protected _buildBlock(state: NodeMaterialBuildState): this;
  61739. }
  61740. }
  61741. declare module BABYLON {
  61742. /**
  61743. * Block used to add light in the fragment shader
  61744. */
  61745. export class LightBlock extends NodeMaterialBlock {
  61746. private _lightId;
  61747. /**
  61748. * Gets or sets the light associated with this block
  61749. */
  61750. light: Nullable<Light>;
  61751. /**
  61752. * Create a new LightBlock
  61753. * @param name defines the block name
  61754. */
  61755. constructor(name: string);
  61756. /**
  61757. * Gets the current class name
  61758. * @returns the class name
  61759. */
  61760. getClassName(): string;
  61761. /**
  61762. * Gets the world position input component
  61763. */
  61764. get worldPosition(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the world normal input component
  61767. */
  61768. get worldNormal(): NodeMaterialConnectionPoint;
  61769. /**
  61770. * Gets the camera (or eye) position component
  61771. */
  61772. get cameraPosition(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the glossiness component
  61775. */
  61776. get glossiness(): NodeMaterialConnectionPoint;
  61777. /**
  61778. * Gets the glossinness power component
  61779. */
  61780. get glossPower(): NodeMaterialConnectionPoint;
  61781. /**
  61782. * Gets the diffuse color component
  61783. */
  61784. get diffuseColor(): NodeMaterialConnectionPoint;
  61785. /**
  61786. * Gets the specular color component
  61787. */
  61788. get specularColor(): NodeMaterialConnectionPoint;
  61789. /**
  61790. * Gets the diffuse output component
  61791. */
  61792. get diffuseOutput(): NodeMaterialConnectionPoint;
  61793. /**
  61794. * Gets the specular output component
  61795. */
  61796. get specularOutput(): NodeMaterialConnectionPoint;
  61797. /**
  61798. * Gets the shadow output component
  61799. */
  61800. get shadow(): NodeMaterialConnectionPoint;
  61801. autoConfigure(material: NodeMaterial): void;
  61802. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61803. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61804. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61805. private _injectVertexCode;
  61806. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61807. serialize(): any;
  61808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61809. }
  61810. }
  61811. declare module BABYLON {
  61812. /**
  61813. * Block used to read a reflection texture from a sampler
  61814. */
  61815. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61816. /**
  61817. * Create a new ReflectionTextureBlock
  61818. * @param name defines the block name
  61819. */
  61820. constructor(name: string);
  61821. /**
  61822. * Gets the current class name
  61823. * @returns the class name
  61824. */
  61825. getClassName(): string;
  61826. /**
  61827. * Gets the world position input component
  61828. */
  61829. get position(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the world position input component
  61832. */
  61833. get worldPosition(): NodeMaterialConnectionPoint;
  61834. /**
  61835. * Gets the world normal input component
  61836. */
  61837. get worldNormal(): NodeMaterialConnectionPoint;
  61838. /**
  61839. * Gets the world input component
  61840. */
  61841. get world(): NodeMaterialConnectionPoint;
  61842. /**
  61843. * Gets the camera (or eye) position component
  61844. */
  61845. get cameraPosition(): NodeMaterialConnectionPoint;
  61846. /**
  61847. * Gets the view input component
  61848. */
  61849. get view(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the rgb output component
  61852. */
  61853. get rgb(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the rgba output component
  61856. */
  61857. get rgba(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the r output component
  61860. */
  61861. get r(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the g output component
  61864. */
  61865. get g(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the b output component
  61868. */
  61869. get b(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the a output component
  61872. */
  61873. get a(): NodeMaterialConnectionPoint;
  61874. autoConfigure(material: NodeMaterial): void;
  61875. protected _buildBlock(state: NodeMaterialBuildState): this;
  61876. }
  61877. }
  61878. declare module BABYLON {
  61879. /**
  61880. * Block used to add 2 vectors
  61881. */
  61882. export class AddBlock extends NodeMaterialBlock {
  61883. /**
  61884. * Creates a new AddBlock
  61885. * @param name defines the block name
  61886. */
  61887. constructor(name: string);
  61888. /**
  61889. * Gets the current class name
  61890. * @returns the class name
  61891. */
  61892. getClassName(): string;
  61893. /**
  61894. * Gets the left operand input component
  61895. */
  61896. get left(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the right operand input component
  61899. */
  61900. get right(): NodeMaterialConnectionPoint;
  61901. /**
  61902. * Gets the output component
  61903. */
  61904. get output(): NodeMaterialConnectionPoint;
  61905. protected _buildBlock(state: NodeMaterialBuildState): this;
  61906. }
  61907. }
  61908. declare module BABYLON {
  61909. /**
  61910. * Block used to scale a vector by a float
  61911. */
  61912. export class ScaleBlock extends NodeMaterialBlock {
  61913. /**
  61914. * Creates a new ScaleBlock
  61915. * @param name defines the block name
  61916. */
  61917. constructor(name: string);
  61918. /**
  61919. * Gets the current class name
  61920. * @returns the class name
  61921. */
  61922. getClassName(): string;
  61923. /**
  61924. * Gets the input component
  61925. */
  61926. get input(): NodeMaterialConnectionPoint;
  61927. /**
  61928. * Gets the factor input component
  61929. */
  61930. get factor(): NodeMaterialConnectionPoint;
  61931. /**
  61932. * Gets the output component
  61933. */
  61934. get output(): NodeMaterialConnectionPoint;
  61935. protected _buildBlock(state: NodeMaterialBuildState): this;
  61936. }
  61937. }
  61938. declare module BABYLON {
  61939. /**
  61940. * Block used to clamp a float
  61941. */
  61942. export class ClampBlock extends NodeMaterialBlock {
  61943. /** Gets or sets the minimum range */
  61944. minimum: number;
  61945. /** Gets or sets the maximum range */
  61946. maximum: number;
  61947. /**
  61948. * Creates a new ClampBlock
  61949. * @param name defines the block name
  61950. */
  61951. constructor(name: string);
  61952. /**
  61953. * Gets the current class name
  61954. * @returns the class name
  61955. */
  61956. getClassName(): string;
  61957. /**
  61958. * Gets the value input component
  61959. */
  61960. get value(): NodeMaterialConnectionPoint;
  61961. /**
  61962. * Gets the output component
  61963. */
  61964. get output(): NodeMaterialConnectionPoint;
  61965. protected _buildBlock(state: NodeMaterialBuildState): this;
  61966. protected _dumpPropertiesCode(): string;
  61967. serialize(): any;
  61968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61969. }
  61970. }
  61971. declare module BABYLON {
  61972. /**
  61973. * Block used to apply a cross product between 2 vectors
  61974. */
  61975. export class CrossBlock extends NodeMaterialBlock {
  61976. /**
  61977. * Creates a new CrossBlock
  61978. * @param name defines the block name
  61979. */
  61980. constructor(name: string);
  61981. /**
  61982. * Gets the current class name
  61983. * @returns the class name
  61984. */
  61985. getClassName(): string;
  61986. /**
  61987. * Gets the left operand input component
  61988. */
  61989. get left(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the right operand input component
  61992. */
  61993. get right(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the output component
  61996. */
  61997. get output(): NodeMaterialConnectionPoint;
  61998. protected _buildBlock(state: NodeMaterialBuildState): this;
  61999. }
  62000. }
  62001. declare module BABYLON {
  62002. /**
  62003. * Block used to apply a dot product between 2 vectors
  62004. */
  62005. export class DotBlock extends NodeMaterialBlock {
  62006. /**
  62007. * Creates a new DotBlock
  62008. * @param name defines the block name
  62009. */
  62010. constructor(name: string);
  62011. /**
  62012. * Gets the current class name
  62013. * @returns the class name
  62014. */
  62015. getClassName(): string;
  62016. /**
  62017. * Gets the left operand input component
  62018. */
  62019. get left(): NodeMaterialConnectionPoint;
  62020. /**
  62021. * Gets the right operand input component
  62022. */
  62023. get right(): NodeMaterialConnectionPoint;
  62024. /**
  62025. * Gets the output component
  62026. */
  62027. get output(): NodeMaterialConnectionPoint;
  62028. protected _buildBlock(state: NodeMaterialBuildState): this;
  62029. }
  62030. }
  62031. declare module BABYLON {
  62032. /**
  62033. * Block used to normalize a vector
  62034. */
  62035. export class NormalizeBlock extends NodeMaterialBlock {
  62036. /**
  62037. * Creates a new NormalizeBlock
  62038. * @param name defines the block name
  62039. */
  62040. constructor(name: string);
  62041. /**
  62042. * Gets the current class name
  62043. * @returns the class name
  62044. */
  62045. getClassName(): string;
  62046. /**
  62047. * Gets the input component
  62048. */
  62049. get input(): NodeMaterialConnectionPoint;
  62050. /**
  62051. * Gets the output component
  62052. */
  62053. get output(): NodeMaterialConnectionPoint;
  62054. protected _buildBlock(state: NodeMaterialBuildState): this;
  62055. }
  62056. }
  62057. declare module BABYLON {
  62058. /**
  62059. * Operations supported by the Trigonometry block
  62060. */
  62061. export enum TrigonometryBlockOperations {
  62062. /** Cos */
  62063. Cos = 0,
  62064. /** Sin */
  62065. Sin = 1,
  62066. /** Abs */
  62067. Abs = 2,
  62068. /** Exp */
  62069. Exp = 3,
  62070. /** Exp2 */
  62071. Exp2 = 4,
  62072. /** Round */
  62073. Round = 5,
  62074. /** Floor */
  62075. Floor = 6,
  62076. /** Ceiling */
  62077. Ceiling = 7,
  62078. /** Square root */
  62079. Sqrt = 8,
  62080. /** Log */
  62081. Log = 9,
  62082. /** Tangent */
  62083. Tan = 10,
  62084. /** Arc tangent */
  62085. ArcTan = 11,
  62086. /** Arc cosinus */
  62087. ArcCos = 12,
  62088. /** Arc sinus */
  62089. ArcSin = 13,
  62090. /** Fraction */
  62091. Fract = 14,
  62092. /** Sign */
  62093. Sign = 15,
  62094. /** To radians (from degrees) */
  62095. Radians = 16,
  62096. /** To degrees (from radians) */
  62097. Degrees = 17
  62098. }
  62099. /**
  62100. * Block used to apply trigonometry operation to floats
  62101. */
  62102. export class TrigonometryBlock extends NodeMaterialBlock {
  62103. /**
  62104. * Gets or sets the operation applied by the block
  62105. */
  62106. operation: TrigonometryBlockOperations;
  62107. /**
  62108. * Creates a new TrigonometryBlock
  62109. * @param name defines the block name
  62110. */
  62111. constructor(name: string);
  62112. /**
  62113. * Gets the current class name
  62114. * @returns the class name
  62115. */
  62116. getClassName(): string;
  62117. /**
  62118. * Gets the input component
  62119. */
  62120. get input(): NodeMaterialConnectionPoint;
  62121. /**
  62122. * Gets the output component
  62123. */
  62124. get output(): NodeMaterialConnectionPoint;
  62125. protected _buildBlock(state: NodeMaterialBuildState): this;
  62126. serialize(): any;
  62127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62128. protected _dumpPropertiesCode(): string;
  62129. }
  62130. }
  62131. declare module BABYLON {
  62132. /**
  62133. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62134. */
  62135. export class ColorMergerBlock extends NodeMaterialBlock {
  62136. /**
  62137. * Create a new ColorMergerBlock
  62138. * @param name defines the block name
  62139. */
  62140. constructor(name: string);
  62141. /**
  62142. * Gets the current class name
  62143. * @returns the class name
  62144. */
  62145. getClassName(): string;
  62146. /**
  62147. * Gets the rgb component (input)
  62148. */
  62149. get rgbIn(): NodeMaterialConnectionPoint;
  62150. /**
  62151. * Gets the r component (input)
  62152. */
  62153. get r(): NodeMaterialConnectionPoint;
  62154. /**
  62155. * Gets the g component (input)
  62156. */
  62157. get g(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the b component (input)
  62160. */
  62161. get b(): NodeMaterialConnectionPoint;
  62162. /**
  62163. * Gets the a component (input)
  62164. */
  62165. get a(): NodeMaterialConnectionPoint;
  62166. /**
  62167. * Gets the rgba component (output)
  62168. */
  62169. get rgba(): NodeMaterialConnectionPoint;
  62170. /**
  62171. * Gets the rgb component (output)
  62172. */
  62173. get rgbOut(): NodeMaterialConnectionPoint;
  62174. /**
  62175. * Gets the rgb component (output)
  62176. * @deprecated Please use rgbOut instead.
  62177. */
  62178. get rgb(): NodeMaterialConnectionPoint;
  62179. protected _buildBlock(state: NodeMaterialBuildState): this;
  62180. }
  62181. }
  62182. declare module BABYLON {
  62183. /**
  62184. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62185. */
  62186. export class VectorSplitterBlock extends NodeMaterialBlock {
  62187. /**
  62188. * Create a new VectorSplitterBlock
  62189. * @param name defines the block name
  62190. */
  62191. constructor(name: string);
  62192. /**
  62193. * Gets the current class name
  62194. * @returns the class name
  62195. */
  62196. getClassName(): string;
  62197. /**
  62198. * Gets the xyzw component (input)
  62199. */
  62200. get xyzw(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the xyz component (input)
  62203. */
  62204. get xyzIn(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the xy component (input)
  62207. */
  62208. get xyIn(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the xyz component (output)
  62211. */
  62212. get xyzOut(): NodeMaterialConnectionPoint;
  62213. /**
  62214. * Gets the xy component (output)
  62215. */
  62216. get xyOut(): NodeMaterialConnectionPoint;
  62217. /**
  62218. * Gets the x component (output)
  62219. */
  62220. get x(): NodeMaterialConnectionPoint;
  62221. /**
  62222. * Gets the y component (output)
  62223. */
  62224. get y(): NodeMaterialConnectionPoint;
  62225. /**
  62226. * Gets the z component (output)
  62227. */
  62228. get z(): NodeMaterialConnectionPoint;
  62229. /**
  62230. * Gets the w component (output)
  62231. */
  62232. get w(): NodeMaterialConnectionPoint;
  62233. protected _inputRename(name: string): string;
  62234. protected _outputRename(name: string): string;
  62235. protected _buildBlock(state: NodeMaterialBuildState): this;
  62236. }
  62237. }
  62238. declare module BABYLON {
  62239. /**
  62240. * Block used to lerp between 2 values
  62241. */
  62242. export class LerpBlock extends NodeMaterialBlock {
  62243. /**
  62244. * Creates a new LerpBlock
  62245. * @param name defines the block name
  62246. */
  62247. constructor(name: string);
  62248. /**
  62249. * Gets the current class name
  62250. * @returns the class name
  62251. */
  62252. getClassName(): string;
  62253. /**
  62254. * Gets the left operand input component
  62255. */
  62256. get left(): NodeMaterialConnectionPoint;
  62257. /**
  62258. * Gets the right operand input component
  62259. */
  62260. get right(): NodeMaterialConnectionPoint;
  62261. /**
  62262. * Gets the gradient operand input component
  62263. */
  62264. get gradient(): NodeMaterialConnectionPoint;
  62265. /**
  62266. * Gets the output component
  62267. */
  62268. get output(): NodeMaterialConnectionPoint;
  62269. protected _buildBlock(state: NodeMaterialBuildState): this;
  62270. }
  62271. }
  62272. declare module BABYLON {
  62273. /**
  62274. * Block used to divide 2 vectors
  62275. */
  62276. export class DivideBlock extends NodeMaterialBlock {
  62277. /**
  62278. * Creates a new DivideBlock
  62279. * @param name defines the block name
  62280. */
  62281. constructor(name: string);
  62282. /**
  62283. * Gets the current class name
  62284. * @returns the class name
  62285. */
  62286. getClassName(): string;
  62287. /**
  62288. * Gets the left operand input component
  62289. */
  62290. get left(): NodeMaterialConnectionPoint;
  62291. /**
  62292. * Gets the right operand input component
  62293. */
  62294. get right(): NodeMaterialConnectionPoint;
  62295. /**
  62296. * Gets the output component
  62297. */
  62298. get output(): NodeMaterialConnectionPoint;
  62299. protected _buildBlock(state: NodeMaterialBuildState): this;
  62300. }
  62301. }
  62302. declare module BABYLON {
  62303. /**
  62304. * Block used to subtract 2 vectors
  62305. */
  62306. export class SubtractBlock extends NodeMaterialBlock {
  62307. /**
  62308. * Creates a new SubtractBlock
  62309. * @param name defines the block name
  62310. */
  62311. constructor(name: string);
  62312. /**
  62313. * Gets the current class name
  62314. * @returns the class name
  62315. */
  62316. getClassName(): string;
  62317. /**
  62318. * Gets the left operand input component
  62319. */
  62320. get left(): NodeMaterialConnectionPoint;
  62321. /**
  62322. * Gets the right operand input component
  62323. */
  62324. get right(): NodeMaterialConnectionPoint;
  62325. /**
  62326. * Gets the output component
  62327. */
  62328. get output(): NodeMaterialConnectionPoint;
  62329. protected _buildBlock(state: NodeMaterialBuildState): this;
  62330. }
  62331. }
  62332. declare module BABYLON {
  62333. /**
  62334. * Block used to step a value
  62335. */
  62336. export class StepBlock extends NodeMaterialBlock {
  62337. /**
  62338. * Creates a new StepBlock
  62339. * @param name defines the block name
  62340. */
  62341. constructor(name: string);
  62342. /**
  62343. * Gets the current class name
  62344. * @returns the class name
  62345. */
  62346. getClassName(): string;
  62347. /**
  62348. * Gets the value operand input component
  62349. */
  62350. get value(): NodeMaterialConnectionPoint;
  62351. /**
  62352. * Gets the edge operand input component
  62353. */
  62354. get edge(): NodeMaterialConnectionPoint;
  62355. /**
  62356. * Gets the output component
  62357. */
  62358. get output(): NodeMaterialConnectionPoint;
  62359. protected _buildBlock(state: NodeMaterialBuildState): this;
  62360. }
  62361. }
  62362. declare module BABYLON {
  62363. /**
  62364. * Block used to get the opposite (1 - x) of a value
  62365. */
  62366. export class OneMinusBlock extends NodeMaterialBlock {
  62367. /**
  62368. * Creates a new OneMinusBlock
  62369. * @param name defines the block name
  62370. */
  62371. constructor(name: string);
  62372. /**
  62373. * Gets the current class name
  62374. * @returns the class name
  62375. */
  62376. getClassName(): string;
  62377. /**
  62378. * Gets the input component
  62379. */
  62380. get input(): NodeMaterialConnectionPoint;
  62381. /**
  62382. * Gets the output component
  62383. */
  62384. get output(): NodeMaterialConnectionPoint;
  62385. protected _buildBlock(state: NodeMaterialBuildState): this;
  62386. }
  62387. }
  62388. declare module BABYLON {
  62389. /**
  62390. * Block used to get the view direction
  62391. */
  62392. export class ViewDirectionBlock extends NodeMaterialBlock {
  62393. /**
  62394. * Creates a new ViewDirectionBlock
  62395. * @param name defines the block name
  62396. */
  62397. constructor(name: string);
  62398. /**
  62399. * Gets the current class name
  62400. * @returns the class name
  62401. */
  62402. getClassName(): string;
  62403. /**
  62404. * Gets the world position component
  62405. */
  62406. get worldPosition(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the camera position component
  62409. */
  62410. get cameraPosition(): NodeMaterialConnectionPoint;
  62411. /**
  62412. * Gets the output component
  62413. */
  62414. get output(): NodeMaterialConnectionPoint;
  62415. autoConfigure(material: NodeMaterial): void;
  62416. protected _buildBlock(state: NodeMaterialBuildState): this;
  62417. }
  62418. }
  62419. declare module BABYLON {
  62420. /**
  62421. * Block used to compute fresnel value
  62422. */
  62423. export class FresnelBlock extends NodeMaterialBlock {
  62424. /**
  62425. * Create a new FresnelBlock
  62426. * @param name defines the block name
  62427. */
  62428. constructor(name: string);
  62429. /**
  62430. * Gets the current class name
  62431. * @returns the class name
  62432. */
  62433. getClassName(): string;
  62434. /**
  62435. * Gets the world normal input component
  62436. */
  62437. get worldNormal(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the view direction input component
  62440. */
  62441. get viewDirection(): NodeMaterialConnectionPoint;
  62442. /**
  62443. * Gets the bias input component
  62444. */
  62445. get bias(): NodeMaterialConnectionPoint;
  62446. /**
  62447. * Gets the camera (or eye) position component
  62448. */
  62449. get power(): NodeMaterialConnectionPoint;
  62450. /**
  62451. * Gets the fresnel output component
  62452. */
  62453. get fresnel(): NodeMaterialConnectionPoint;
  62454. autoConfigure(material: NodeMaterial): void;
  62455. protected _buildBlock(state: NodeMaterialBuildState): this;
  62456. }
  62457. }
  62458. declare module BABYLON {
  62459. /**
  62460. * Block used to get the max of 2 values
  62461. */
  62462. export class MaxBlock extends NodeMaterialBlock {
  62463. /**
  62464. * Creates a new MaxBlock
  62465. * @param name defines the block name
  62466. */
  62467. constructor(name: string);
  62468. /**
  62469. * Gets the current class name
  62470. * @returns the class name
  62471. */
  62472. getClassName(): string;
  62473. /**
  62474. * Gets the left operand input component
  62475. */
  62476. get left(): NodeMaterialConnectionPoint;
  62477. /**
  62478. * Gets the right operand input component
  62479. */
  62480. get right(): NodeMaterialConnectionPoint;
  62481. /**
  62482. * Gets the output component
  62483. */
  62484. get output(): NodeMaterialConnectionPoint;
  62485. protected _buildBlock(state: NodeMaterialBuildState): this;
  62486. }
  62487. }
  62488. declare module BABYLON {
  62489. /**
  62490. * Block used to get the min of 2 values
  62491. */
  62492. export class MinBlock extends NodeMaterialBlock {
  62493. /**
  62494. * Creates a new MinBlock
  62495. * @param name defines the block name
  62496. */
  62497. constructor(name: string);
  62498. /**
  62499. * Gets the current class name
  62500. * @returns the class name
  62501. */
  62502. getClassName(): string;
  62503. /**
  62504. * Gets the left operand input component
  62505. */
  62506. get left(): NodeMaterialConnectionPoint;
  62507. /**
  62508. * Gets the right operand input component
  62509. */
  62510. get right(): NodeMaterialConnectionPoint;
  62511. /**
  62512. * Gets the output component
  62513. */
  62514. get output(): NodeMaterialConnectionPoint;
  62515. protected _buildBlock(state: NodeMaterialBuildState): this;
  62516. }
  62517. }
  62518. declare module BABYLON {
  62519. /**
  62520. * Block used to get the distance between 2 values
  62521. */
  62522. export class DistanceBlock extends NodeMaterialBlock {
  62523. /**
  62524. * Creates a new DistanceBlock
  62525. * @param name defines the block name
  62526. */
  62527. constructor(name: string);
  62528. /**
  62529. * Gets the current class name
  62530. * @returns the class name
  62531. */
  62532. getClassName(): string;
  62533. /**
  62534. * Gets the left operand input component
  62535. */
  62536. get left(): NodeMaterialConnectionPoint;
  62537. /**
  62538. * Gets the right operand input component
  62539. */
  62540. get right(): NodeMaterialConnectionPoint;
  62541. /**
  62542. * Gets the output component
  62543. */
  62544. get output(): NodeMaterialConnectionPoint;
  62545. protected _buildBlock(state: NodeMaterialBuildState): this;
  62546. }
  62547. }
  62548. declare module BABYLON {
  62549. /**
  62550. * Block used to get the length of a vector
  62551. */
  62552. export class LengthBlock extends NodeMaterialBlock {
  62553. /**
  62554. * Creates a new LengthBlock
  62555. * @param name defines the block name
  62556. */
  62557. constructor(name: string);
  62558. /**
  62559. * Gets the current class name
  62560. * @returns the class name
  62561. */
  62562. getClassName(): string;
  62563. /**
  62564. * Gets the value input component
  62565. */
  62566. get value(): NodeMaterialConnectionPoint;
  62567. /**
  62568. * Gets the output component
  62569. */
  62570. get output(): NodeMaterialConnectionPoint;
  62571. protected _buildBlock(state: NodeMaterialBuildState): this;
  62572. }
  62573. }
  62574. declare module BABYLON {
  62575. /**
  62576. * Block used to get negative version of a value (i.e. x * -1)
  62577. */
  62578. export class NegateBlock extends NodeMaterialBlock {
  62579. /**
  62580. * Creates a new NegateBlock
  62581. * @param name defines the block name
  62582. */
  62583. constructor(name: string);
  62584. /**
  62585. * Gets the current class name
  62586. * @returns the class name
  62587. */
  62588. getClassName(): string;
  62589. /**
  62590. * Gets the value input component
  62591. */
  62592. get value(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the output component
  62595. */
  62596. get output(): NodeMaterialConnectionPoint;
  62597. protected _buildBlock(state: NodeMaterialBuildState): this;
  62598. }
  62599. }
  62600. declare module BABYLON {
  62601. /**
  62602. * Block used to get the value of the first parameter raised to the power of the second
  62603. */
  62604. export class PowBlock extends NodeMaterialBlock {
  62605. /**
  62606. * Creates a new PowBlock
  62607. * @param name defines the block name
  62608. */
  62609. constructor(name: string);
  62610. /**
  62611. * Gets the current class name
  62612. * @returns the class name
  62613. */
  62614. getClassName(): string;
  62615. /**
  62616. * Gets the value operand input component
  62617. */
  62618. get value(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the power operand input component
  62621. */
  62622. get power(): NodeMaterialConnectionPoint;
  62623. /**
  62624. * Gets the output component
  62625. */
  62626. get output(): NodeMaterialConnectionPoint;
  62627. protected _buildBlock(state: NodeMaterialBuildState): this;
  62628. }
  62629. }
  62630. declare module BABYLON {
  62631. /**
  62632. * Block used to get a random number
  62633. */
  62634. export class RandomNumberBlock extends NodeMaterialBlock {
  62635. /**
  62636. * Creates a new RandomNumberBlock
  62637. * @param name defines the block name
  62638. */
  62639. constructor(name: string);
  62640. /**
  62641. * Gets the current class name
  62642. * @returns the class name
  62643. */
  62644. getClassName(): string;
  62645. /**
  62646. * Gets the seed input component
  62647. */
  62648. get seed(): NodeMaterialConnectionPoint;
  62649. /**
  62650. * Gets the output component
  62651. */
  62652. get output(): NodeMaterialConnectionPoint;
  62653. protected _buildBlock(state: NodeMaterialBuildState): this;
  62654. }
  62655. }
  62656. declare module BABYLON {
  62657. /**
  62658. * Block used to compute arc tangent of 2 values
  62659. */
  62660. export class ArcTan2Block extends NodeMaterialBlock {
  62661. /**
  62662. * Creates a new ArcTan2Block
  62663. * @param name defines the block name
  62664. */
  62665. constructor(name: string);
  62666. /**
  62667. * Gets the current class name
  62668. * @returns the class name
  62669. */
  62670. getClassName(): string;
  62671. /**
  62672. * Gets the x operand input component
  62673. */
  62674. get x(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the y operand input component
  62677. */
  62678. get y(): NodeMaterialConnectionPoint;
  62679. /**
  62680. * Gets the output component
  62681. */
  62682. get output(): NodeMaterialConnectionPoint;
  62683. protected _buildBlock(state: NodeMaterialBuildState): this;
  62684. }
  62685. }
  62686. declare module BABYLON {
  62687. /**
  62688. * Block used to smooth step a value
  62689. */
  62690. export class SmoothStepBlock extends NodeMaterialBlock {
  62691. /**
  62692. * Creates a new SmoothStepBlock
  62693. * @param name defines the block name
  62694. */
  62695. constructor(name: string);
  62696. /**
  62697. * Gets the current class name
  62698. * @returns the class name
  62699. */
  62700. getClassName(): string;
  62701. /**
  62702. * Gets the value operand input component
  62703. */
  62704. get value(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the first edge operand input component
  62707. */
  62708. get edge0(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the second edge operand input component
  62711. */
  62712. get edge1(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the output component
  62715. */
  62716. get output(): NodeMaterialConnectionPoint;
  62717. protected _buildBlock(state: NodeMaterialBuildState): this;
  62718. }
  62719. }
  62720. declare module BABYLON {
  62721. /**
  62722. * Block used to get the reciprocal (1 / x) of a value
  62723. */
  62724. export class ReciprocalBlock extends NodeMaterialBlock {
  62725. /**
  62726. * Creates a new ReciprocalBlock
  62727. * @param name defines the block name
  62728. */
  62729. constructor(name: string);
  62730. /**
  62731. * Gets the current class name
  62732. * @returns the class name
  62733. */
  62734. getClassName(): string;
  62735. /**
  62736. * Gets the input component
  62737. */
  62738. get input(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the output component
  62741. */
  62742. get output(): NodeMaterialConnectionPoint;
  62743. protected _buildBlock(state: NodeMaterialBuildState): this;
  62744. }
  62745. }
  62746. declare module BABYLON {
  62747. /**
  62748. * Block used to replace a color by another one
  62749. */
  62750. export class ReplaceColorBlock extends NodeMaterialBlock {
  62751. /**
  62752. * Creates a new ReplaceColorBlock
  62753. * @param name defines the block name
  62754. */
  62755. constructor(name: string);
  62756. /**
  62757. * Gets the current class name
  62758. * @returns the class name
  62759. */
  62760. getClassName(): string;
  62761. /**
  62762. * Gets the value input component
  62763. */
  62764. get value(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the reference input component
  62767. */
  62768. get reference(): NodeMaterialConnectionPoint;
  62769. /**
  62770. * Gets the distance input component
  62771. */
  62772. get distance(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the replacement input component
  62775. */
  62776. get replacement(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Gets the output component
  62779. */
  62780. get output(): NodeMaterialConnectionPoint;
  62781. protected _buildBlock(state: NodeMaterialBuildState): this;
  62782. }
  62783. }
  62784. declare module BABYLON {
  62785. /**
  62786. * Block used to posterize a value
  62787. * @see https://en.wikipedia.org/wiki/Posterization
  62788. */
  62789. export class PosterizeBlock extends NodeMaterialBlock {
  62790. /**
  62791. * Creates a new PosterizeBlock
  62792. * @param name defines the block name
  62793. */
  62794. constructor(name: string);
  62795. /**
  62796. * Gets the current class name
  62797. * @returns the class name
  62798. */
  62799. getClassName(): string;
  62800. /**
  62801. * Gets the value input component
  62802. */
  62803. get value(): NodeMaterialConnectionPoint;
  62804. /**
  62805. * Gets the steps input component
  62806. */
  62807. get steps(): NodeMaterialConnectionPoint;
  62808. /**
  62809. * Gets the output component
  62810. */
  62811. get output(): NodeMaterialConnectionPoint;
  62812. protected _buildBlock(state: NodeMaterialBuildState): this;
  62813. }
  62814. }
  62815. declare module BABYLON {
  62816. /**
  62817. * Operations supported by the Wave block
  62818. */
  62819. export enum WaveBlockKind {
  62820. /** SawTooth */
  62821. SawTooth = 0,
  62822. /** Square */
  62823. Square = 1,
  62824. /** Triangle */
  62825. Triangle = 2
  62826. }
  62827. /**
  62828. * Block used to apply wave operation to floats
  62829. */
  62830. export class WaveBlock extends NodeMaterialBlock {
  62831. /**
  62832. * Gets or sets the kibnd of wave to be applied by the block
  62833. */
  62834. kind: WaveBlockKind;
  62835. /**
  62836. * Creates a new WaveBlock
  62837. * @param name defines the block name
  62838. */
  62839. constructor(name: string);
  62840. /**
  62841. * Gets the current class name
  62842. * @returns the class name
  62843. */
  62844. getClassName(): string;
  62845. /**
  62846. * Gets the input component
  62847. */
  62848. get input(): NodeMaterialConnectionPoint;
  62849. /**
  62850. * Gets the output component
  62851. */
  62852. get output(): NodeMaterialConnectionPoint;
  62853. protected _buildBlock(state: NodeMaterialBuildState): this;
  62854. serialize(): any;
  62855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62856. }
  62857. }
  62858. declare module BABYLON {
  62859. /**
  62860. * Class used to store a color step for the GradientBlock
  62861. */
  62862. export class GradientBlockColorStep {
  62863. /**
  62864. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62865. */
  62866. step: number;
  62867. /**
  62868. * Gets or sets the color associated with this step
  62869. */
  62870. color: Color3;
  62871. /**
  62872. * Creates a new GradientBlockColorStep
  62873. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62874. * @param color defines the color associated with this step
  62875. */
  62876. constructor(
  62877. /**
  62878. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62879. */
  62880. step: number,
  62881. /**
  62882. * Gets or sets the color associated with this step
  62883. */
  62884. color: Color3);
  62885. }
  62886. /**
  62887. * Block used to return a color from a gradient based on an input value between 0 and 1
  62888. */
  62889. export class GradientBlock extends NodeMaterialBlock {
  62890. /**
  62891. * Gets or sets the list of color steps
  62892. */
  62893. colorSteps: GradientBlockColorStep[];
  62894. /**
  62895. * Creates a new GradientBlock
  62896. * @param name defines the block name
  62897. */
  62898. constructor(name: string);
  62899. /**
  62900. * Gets the current class name
  62901. * @returns the class name
  62902. */
  62903. getClassName(): string;
  62904. /**
  62905. * Gets the gradient input component
  62906. */
  62907. get gradient(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the output component
  62910. */
  62911. get output(): NodeMaterialConnectionPoint;
  62912. private _writeColorConstant;
  62913. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62914. serialize(): any;
  62915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62916. protected _dumpPropertiesCode(): string;
  62917. }
  62918. }
  62919. declare module BABYLON {
  62920. /**
  62921. * Block used to normalize lerp between 2 values
  62922. */
  62923. export class NLerpBlock extends NodeMaterialBlock {
  62924. /**
  62925. * Creates a new NLerpBlock
  62926. * @param name defines the block name
  62927. */
  62928. constructor(name: string);
  62929. /**
  62930. * Gets the current class name
  62931. * @returns the class name
  62932. */
  62933. getClassName(): string;
  62934. /**
  62935. * Gets the left operand input component
  62936. */
  62937. get left(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the right operand input component
  62940. */
  62941. get right(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Gets the gradient operand input component
  62944. */
  62945. get gradient(): NodeMaterialConnectionPoint;
  62946. /**
  62947. * Gets the output component
  62948. */
  62949. get output(): NodeMaterialConnectionPoint;
  62950. protected _buildBlock(state: NodeMaterialBuildState): this;
  62951. }
  62952. }
  62953. declare module BABYLON {
  62954. /**
  62955. * block used to Generate a Worley Noise 3D Noise Pattern
  62956. */
  62957. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62958. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62959. manhattanDistance: boolean;
  62960. /**
  62961. * Creates a new WorleyNoise3DBlock
  62962. * @param name defines the block name
  62963. */
  62964. constructor(name: string);
  62965. /**
  62966. * Gets the current class name
  62967. * @returns the class name
  62968. */
  62969. getClassName(): string;
  62970. /**
  62971. * Gets the seed input component
  62972. */
  62973. get seed(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the jitter input component
  62976. */
  62977. get jitter(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the output component
  62980. */
  62981. get output(): NodeMaterialConnectionPoint;
  62982. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62983. /**
  62984. * Exposes the properties to the UI?
  62985. */
  62986. protected _dumpPropertiesCode(): string;
  62987. /**
  62988. * Exposes the properties to the Seralize?
  62989. */
  62990. serialize(): any;
  62991. /**
  62992. * Exposes the properties to the deseralize?
  62993. */
  62994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62995. }
  62996. }
  62997. declare module BABYLON {
  62998. /**
  62999. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63000. */
  63001. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63002. /**
  63003. * Creates a new SimplexPerlin3DBlock
  63004. * @param name defines the block name
  63005. */
  63006. constructor(name: string);
  63007. /**
  63008. * Gets the current class name
  63009. * @returns the class name
  63010. */
  63011. getClassName(): string;
  63012. /**
  63013. * Gets the seed operand input component
  63014. */
  63015. get seed(): NodeMaterialConnectionPoint;
  63016. /**
  63017. * Gets the output component
  63018. */
  63019. get output(): NodeMaterialConnectionPoint;
  63020. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63021. }
  63022. }
  63023. declare module BABYLON {
  63024. /**
  63025. * Block used to blend normals
  63026. */
  63027. export class NormalBlendBlock extends NodeMaterialBlock {
  63028. /**
  63029. * Creates a new NormalBlendBlock
  63030. * @param name defines the block name
  63031. */
  63032. constructor(name: string);
  63033. /**
  63034. * Gets the current class name
  63035. * @returns the class name
  63036. */
  63037. getClassName(): string;
  63038. /**
  63039. * Gets the first input component
  63040. */
  63041. get normalMap0(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the second input component
  63044. */
  63045. get normalMap1(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the output component
  63048. */
  63049. get output(): NodeMaterialConnectionPoint;
  63050. protected _buildBlock(state: NodeMaterialBuildState): this;
  63051. }
  63052. }
  63053. declare module BABYLON {
  63054. /**
  63055. * Block used to rotate a 2d vector by a given angle
  63056. */
  63057. export class Rotate2dBlock extends NodeMaterialBlock {
  63058. /**
  63059. * Creates a new Rotate2dBlock
  63060. * @param name defines the block name
  63061. */
  63062. constructor(name: string);
  63063. /**
  63064. * Gets the current class name
  63065. * @returns the class name
  63066. */
  63067. getClassName(): string;
  63068. /**
  63069. * Gets the input vector
  63070. */
  63071. get input(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the input angle
  63074. */
  63075. get angle(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the output component
  63078. */
  63079. get output(): NodeMaterialConnectionPoint;
  63080. autoConfigure(material: NodeMaterial): void;
  63081. protected _buildBlock(state: NodeMaterialBuildState): this;
  63082. }
  63083. }
  63084. declare module BABYLON {
  63085. /**
  63086. * Block used to get the reflected vector from a direction and a normal
  63087. */
  63088. export class ReflectBlock extends NodeMaterialBlock {
  63089. /**
  63090. * Creates a new ReflectBlock
  63091. * @param name defines the block name
  63092. */
  63093. constructor(name: string);
  63094. /**
  63095. * Gets the current class name
  63096. * @returns the class name
  63097. */
  63098. getClassName(): string;
  63099. /**
  63100. * Gets the incident component
  63101. */
  63102. get incident(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the normal component
  63105. */
  63106. get normal(): NodeMaterialConnectionPoint;
  63107. /**
  63108. * Gets the output component
  63109. */
  63110. get output(): NodeMaterialConnectionPoint;
  63111. protected _buildBlock(state: NodeMaterialBuildState): this;
  63112. }
  63113. }
  63114. declare module BABYLON {
  63115. /**
  63116. * Block used to get the refracted vector from a direction and a normal
  63117. */
  63118. export class RefractBlock extends NodeMaterialBlock {
  63119. /**
  63120. * Creates a new RefractBlock
  63121. * @param name defines the block name
  63122. */
  63123. constructor(name: string);
  63124. /**
  63125. * Gets the current class name
  63126. * @returns the class name
  63127. */
  63128. getClassName(): string;
  63129. /**
  63130. * Gets the incident component
  63131. */
  63132. get incident(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the normal component
  63135. */
  63136. get normal(): NodeMaterialConnectionPoint;
  63137. /**
  63138. * Gets the index of refraction component
  63139. */
  63140. get ior(): NodeMaterialConnectionPoint;
  63141. /**
  63142. * Gets the output component
  63143. */
  63144. get output(): NodeMaterialConnectionPoint;
  63145. protected _buildBlock(state: NodeMaterialBuildState): this;
  63146. }
  63147. }
  63148. declare module BABYLON {
  63149. /**
  63150. * Block used to desaturate a color
  63151. */
  63152. export class DesaturateBlock extends NodeMaterialBlock {
  63153. /**
  63154. * Creates a new DesaturateBlock
  63155. * @param name defines the block name
  63156. */
  63157. constructor(name: string);
  63158. /**
  63159. * Gets the current class name
  63160. * @returns the class name
  63161. */
  63162. getClassName(): string;
  63163. /**
  63164. * Gets the color operand input component
  63165. */
  63166. get color(): NodeMaterialConnectionPoint;
  63167. /**
  63168. * Gets the level operand input component
  63169. */
  63170. get level(): NodeMaterialConnectionPoint;
  63171. /**
  63172. * Gets the output component
  63173. */
  63174. get output(): NodeMaterialConnectionPoint;
  63175. protected _buildBlock(state: NodeMaterialBuildState): this;
  63176. }
  63177. }
  63178. declare module BABYLON {
  63179. /**
  63180. * Block used to implement the ambient occlusion module of the PBR material
  63181. */
  63182. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63183. /**
  63184. * Create a new AmbientOcclusionBlock
  63185. * @param name defines the block name
  63186. */
  63187. constructor(name: string);
  63188. /**
  63189. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63190. */
  63191. useAmbientInGrayScale: boolean;
  63192. /**
  63193. * Initialize the block and prepare the context for build
  63194. * @param state defines the state that will be used for the build
  63195. */
  63196. initialize(state: NodeMaterialBuildState): void;
  63197. /**
  63198. * Gets the current class name
  63199. * @returns the class name
  63200. */
  63201. getClassName(): string;
  63202. /**
  63203. * Gets the texture input component
  63204. */
  63205. get texture(): NodeMaterialConnectionPoint;
  63206. /**
  63207. * Gets the texture intensity component
  63208. */
  63209. get intensity(): NodeMaterialConnectionPoint;
  63210. /**
  63211. * Gets the direct light intensity input component
  63212. */
  63213. get directLightIntensity(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the ambient occlusion object output component
  63216. */
  63217. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the main code of the block (fragment side)
  63220. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63221. * @returns the shader code
  63222. */
  63223. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63225. protected _buildBlock(state: NodeMaterialBuildState): this;
  63226. protected _dumpPropertiesCode(): string;
  63227. serialize(): any;
  63228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63229. }
  63230. }
  63231. declare module BABYLON {
  63232. /**
  63233. * Block used to implement the reflection module of the PBR material
  63234. */
  63235. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63236. /** @hidden */
  63237. _defineLODReflectionAlpha: string;
  63238. /** @hidden */
  63239. _defineLinearSpecularReflection: string;
  63240. private _vEnvironmentIrradianceName;
  63241. /** @hidden */
  63242. _vReflectionMicrosurfaceInfosName: string;
  63243. /** @hidden */
  63244. _vReflectionInfosName: string;
  63245. /** @hidden */
  63246. _vReflectionFilteringInfoName: string;
  63247. private _scene;
  63248. /**
  63249. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63250. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63251. * It's less burden on the user side in the editor part.
  63252. */
  63253. /** @hidden */
  63254. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63255. /** @hidden */
  63256. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63257. /** @hidden */
  63258. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63259. /**
  63260. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63261. * diffuse part of the IBL.
  63262. */
  63263. useSphericalHarmonics: boolean;
  63264. /**
  63265. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63266. */
  63267. forceIrradianceInFragment: boolean;
  63268. /**
  63269. * Create a new ReflectionBlock
  63270. * @param name defines the block name
  63271. */
  63272. constructor(name: string);
  63273. /**
  63274. * Gets the current class name
  63275. * @returns the class name
  63276. */
  63277. getClassName(): string;
  63278. /**
  63279. * Gets the position input component
  63280. */
  63281. get position(): NodeMaterialConnectionPoint;
  63282. /**
  63283. * Gets the world position input component
  63284. */
  63285. get worldPosition(): NodeMaterialConnectionPoint;
  63286. /**
  63287. * Gets the world normal input component
  63288. */
  63289. get worldNormal(): NodeMaterialConnectionPoint;
  63290. /**
  63291. * Gets the world input component
  63292. */
  63293. get world(): NodeMaterialConnectionPoint;
  63294. /**
  63295. * Gets the camera (or eye) position component
  63296. */
  63297. get cameraPosition(): NodeMaterialConnectionPoint;
  63298. /**
  63299. * Gets the view input component
  63300. */
  63301. get view(): NodeMaterialConnectionPoint;
  63302. /**
  63303. * Gets the color input component
  63304. */
  63305. get color(): NodeMaterialConnectionPoint;
  63306. /**
  63307. * Gets the reflection object output component
  63308. */
  63309. get reflection(): NodeMaterialConnectionPoint;
  63310. /**
  63311. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63312. */
  63313. get hasTexture(): boolean;
  63314. /**
  63315. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63316. */
  63317. get reflectionColor(): string;
  63318. protected _getTexture(): Nullable<BaseTexture>;
  63319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63320. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63321. /**
  63322. * Gets the code to inject in the vertex shader
  63323. * @param state current state of the node material building
  63324. * @returns the shader code
  63325. */
  63326. handleVertexSide(state: NodeMaterialBuildState): string;
  63327. /**
  63328. * Gets the main code of the block (fragment side)
  63329. * @param state current state of the node material building
  63330. * @param normalVarName name of the existing variable corresponding to the normal
  63331. * @returns the shader code
  63332. */
  63333. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63334. protected _buildBlock(state: NodeMaterialBuildState): this;
  63335. protected _dumpPropertiesCode(): string;
  63336. serialize(): any;
  63337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63338. }
  63339. }
  63340. declare module BABYLON {
  63341. /**
  63342. * Block used to implement the sheen module of the PBR material
  63343. */
  63344. export class SheenBlock extends NodeMaterialBlock {
  63345. /**
  63346. * Create a new SheenBlock
  63347. * @param name defines the block name
  63348. */
  63349. constructor(name: string);
  63350. /**
  63351. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63352. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63353. * making it easier to setup and tweak the effect
  63354. */
  63355. albedoScaling: boolean;
  63356. /**
  63357. * Defines if the sheen is linked to the sheen color.
  63358. */
  63359. linkSheenWithAlbedo: boolean;
  63360. /**
  63361. * Initialize the block and prepare the context for build
  63362. * @param state defines the state that will be used for the build
  63363. */
  63364. initialize(state: NodeMaterialBuildState): void;
  63365. /**
  63366. * Gets the current class name
  63367. * @returns the class name
  63368. */
  63369. getClassName(): string;
  63370. /**
  63371. * Gets the intensity input component
  63372. */
  63373. get intensity(): NodeMaterialConnectionPoint;
  63374. /**
  63375. * Gets the color input component
  63376. */
  63377. get color(): NodeMaterialConnectionPoint;
  63378. /**
  63379. * Gets the roughness input component
  63380. */
  63381. get roughness(): NodeMaterialConnectionPoint;
  63382. /**
  63383. * Gets the sheen object output component
  63384. */
  63385. get sheen(): NodeMaterialConnectionPoint;
  63386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63387. /**
  63388. * Gets the main code of the block (fragment side)
  63389. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63390. * @returns the shader code
  63391. */
  63392. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63393. protected _buildBlock(state: NodeMaterialBuildState): this;
  63394. protected _dumpPropertiesCode(): string;
  63395. serialize(): any;
  63396. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63397. }
  63398. }
  63399. declare module BABYLON {
  63400. /**
  63401. * Block used to implement the reflectivity module of the PBR material
  63402. */
  63403. export class ReflectivityBlock extends NodeMaterialBlock {
  63404. private _metallicReflectanceColor;
  63405. private _metallicF0Factor;
  63406. /** @hidden */
  63407. _vMetallicReflectanceFactorsName: string;
  63408. /**
  63409. * The property below is set by the main PBR block prior to calling methods of this class.
  63410. */
  63411. /** @hidden */
  63412. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63413. /**
  63414. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63415. */
  63416. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63417. /**
  63418. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63419. */
  63420. useMetallnessFromMetallicTextureBlue: boolean;
  63421. /**
  63422. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63423. */
  63424. useRoughnessFromMetallicTextureAlpha: boolean;
  63425. /**
  63426. * Specifies if the metallic texture contains the roughness information in its green channel.
  63427. */
  63428. useRoughnessFromMetallicTextureGreen: boolean;
  63429. /**
  63430. * Create a new ReflectivityBlock
  63431. * @param name defines the block name
  63432. */
  63433. constructor(name: string);
  63434. /**
  63435. * Initialize the block and prepare the context for build
  63436. * @param state defines the state that will be used for the build
  63437. */
  63438. initialize(state: NodeMaterialBuildState): void;
  63439. /**
  63440. * Gets the current class name
  63441. * @returns the class name
  63442. */
  63443. getClassName(): string;
  63444. /**
  63445. * Gets the metallic input component
  63446. */
  63447. get metallic(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the roughness input component
  63450. */
  63451. get roughness(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the texture input component
  63454. */
  63455. get texture(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the reflectivity object output component
  63458. */
  63459. get reflectivity(): NodeMaterialConnectionPoint;
  63460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63461. /**
  63462. * Gets the main code of the block (fragment side)
  63463. * @param state current state of the node material building
  63464. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63465. * @returns the shader code
  63466. */
  63467. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63469. protected _buildBlock(state: NodeMaterialBuildState): this;
  63470. protected _dumpPropertiesCode(): string;
  63471. serialize(): any;
  63472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63473. }
  63474. }
  63475. declare module BABYLON {
  63476. /**
  63477. * Block used to implement the anisotropy module of the PBR material
  63478. */
  63479. export class AnisotropyBlock extends NodeMaterialBlock {
  63480. /**
  63481. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63482. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63483. * It's less burden on the user side in the editor part.
  63484. */
  63485. /** @hidden */
  63486. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63487. /** @hidden */
  63488. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63489. /**
  63490. * Create a new AnisotropyBlock
  63491. * @param name defines the block name
  63492. */
  63493. constructor(name: string);
  63494. /**
  63495. * Initialize the block and prepare the context for build
  63496. * @param state defines the state that will be used for the build
  63497. */
  63498. initialize(state: NodeMaterialBuildState): void;
  63499. /**
  63500. * Gets the current class name
  63501. * @returns the class name
  63502. */
  63503. getClassName(): string;
  63504. /**
  63505. * Gets the intensity input component
  63506. */
  63507. get intensity(): NodeMaterialConnectionPoint;
  63508. /**
  63509. * Gets the direction input component
  63510. */
  63511. get direction(): NodeMaterialConnectionPoint;
  63512. /**
  63513. * Gets the texture input component
  63514. */
  63515. get texture(): NodeMaterialConnectionPoint;
  63516. /**
  63517. * Gets the uv input component
  63518. */
  63519. get uv(): NodeMaterialConnectionPoint;
  63520. /**
  63521. * Gets the worldTangent input component
  63522. */
  63523. get worldTangent(): NodeMaterialConnectionPoint;
  63524. /**
  63525. * Gets the anisotropy object output component
  63526. */
  63527. get anisotropy(): NodeMaterialConnectionPoint;
  63528. private _generateTBNSpace;
  63529. /**
  63530. * Gets the main code of the block (fragment side)
  63531. * @param state current state of the node material building
  63532. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63533. * @returns the shader code
  63534. */
  63535. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63537. protected _buildBlock(state: NodeMaterialBuildState): this;
  63538. }
  63539. }
  63540. declare module BABYLON {
  63541. /**
  63542. * Block used to implement the clear coat module of the PBR material
  63543. */
  63544. export class ClearCoatBlock extends NodeMaterialBlock {
  63545. private _scene;
  63546. /**
  63547. * Create a new ClearCoatBlock
  63548. * @param name defines the block name
  63549. */
  63550. constructor(name: string);
  63551. /**
  63552. * Initialize the block and prepare the context for build
  63553. * @param state defines the state that will be used for the build
  63554. */
  63555. initialize(state: NodeMaterialBuildState): void;
  63556. /**
  63557. * Gets the current class name
  63558. * @returns the class name
  63559. */
  63560. getClassName(): string;
  63561. /**
  63562. * Gets the intensity input component
  63563. */
  63564. get intensity(): NodeMaterialConnectionPoint;
  63565. /**
  63566. * Gets the roughness input component
  63567. */
  63568. get roughness(): NodeMaterialConnectionPoint;
  63569. /**
  63570. * Gets the ior input component
  63571. */
  63572. get ior(): NodeMaterialConnectionPoint;
  63573. /**
  63574. * Gets the texture input component
  63575. */
  63576. get texture(): NodeMaterialConnectionPoint;
  63577. /**
  63578. * Gets the bump texture input component
  63579. */
  63580. get bumpTexture(): NodeMaterialConnectionPoint;
  63581. /**
  63582. * Gets the uv input component
  63583. */
  63584. get uv(): NodeMaterialConnectionPoint;
  63585. /**
  63586. * Gets the tint color input component
  63587. */
  63588. get tintColor(): NodeMaterialConnectionPoint;
  63589. /**
  63590. * Gets the tint "at distance" input component
  63591. */
  63592. get tintAtDistance(): NodeMaterialConnectionPoint;
  63593. /**
  63594. * Gets the tint thickness input component
  63595. */
  63596. get tintThickness(): NodeMaterialConnectionPoint;
  63597. /**
  63598. * Gets the world tangent input component
  63599. */
  63600. get worldTangent(): NodeMaterialConnectionPoint;
  63601. /**
  63602. * Gets the clear coat object output component
  63603. */
  63604. get clearcoat(): NodeMaterialConnectionPoint;
  63605. autoConfigure(material: NodeMaterial): void;
  63606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63608. private _generateTBNSpace;
  63609. /**
  63610. * Gets the main code of the block (fragment side)
  63611. * @param state current state of the node material building
  63612. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63613. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63614. * @param worldPosVarName name of the variable holding the world position
  63615. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63616. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63617. * @param worldNormalVarName name of the variable holding the world normal
  63618. * @returns the shader code
  63619. */
  63620. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63621. protected _buildBlock(state: NodeMaterialBuildState): this;
  63622. }
  63623. }
  63624. declare module BABYLON {
  63625. /**
  63626. * Block used to implement the sub surface module of the PBR material
  63627. */
  63628. export class SubSurfaceBlock extends NodeMaterialBlock {
  63629. /**
  63630. * Create a new SubSurfaceBlock
  63631. * @param name defines the block name
  63632. */
  63633. constructor(name: string);
  63634. /**
  63635. * Stores the intensity of the different subsurface effects in the thickness texture.
  63636. * * the green channel is the translucency intensity.
  63637. * * the blue channel is the scattering intensity.
  63638. * * the alpha channel is the refraction intensity.
  63639. */
  63640. useMaskFromThicknessTexture: boolean;
  63641. /**
  63642. * Initialize the block and prepare the context for build
  63643. * @param state defines the state that will be used for the build
  63644. */
  63645. initialize(state: NodeMaterialBuildState): void;
  63646. /**
  63647. * Gets the current class name
  63648. * @returns the class name
  63649. */
  63650. getClassName(): string;
  63651. /**
  63652. * Gets the min thickness input component
  63653. */
  63654. get minThickness(): NodeMaterialConnectionPoint;
  63655. /**
  63656. * Gets the max thickness input component
  63657. */
  63658. get maxThickness(): NodeMaterialConnectionPoint;
  63659. /**
  63660. * Gets the thickness texture component
  63661. */
  63662. get thicknessTexture(): NodeMaterialConnectionPoint;
  63663. /**
  63664. * Gets the tint color input component
  63665. */
  63666. get tintColor(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the translucency intensity input component
  63669. */
  63670. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63671. /**
  63672. * Gets the translucency diffusion distance input component
  63673. */
  63674. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63675. /**
  63676. * Gets the refraction object parameters
  63677. */
  63678. get refraction(): NodeMaterialConnectionPoint;
  63679. /**
  63680. * Gets the sub surface object output component
  63681. */
  63682. get subsurface(): NodeMaterialConnectionPoint;
  63683. autoConfigure(material: NodeMaterial): void;
  63684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63685. /**
  63686. * Gets the main code of the block (fragment side)
  63687. * @param state current state of the node material building
  63688. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63689. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63690. * @param worldPosVarName name of the variable holding the world position
  63691. * @returns the shader code
  63692. */
  63693. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63694. protected _buildBlock(state: NodeMaterialBuildState): this;
  63695. }
  63696. }
  63697. declare module BABYLON {
  63698. /**
  63699. * Block used to implement the PBR metallic/roughness model
  63700. */
  63701. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63702. /**
  63703. * Gets or sets the light associated with this block
  63704. */
  63705. light: Nullable<Light>;
  63706. private _lightId;
  63707. private _scene;
  63708. private _environmentBRDFTexture;
  63709. private _environmentBrdfSamplerName;
  63710. private _vNormalWName;
  63711. private _invertNormalName;
  63712. /**
  63713. * Create a new ReflectionBlock
  63714. * @param name defines the block name
  63715. */
  63716. constructor(name: string);
  63717. /**
  63718. * Intensity of the direct lights e.g. the four lights available in your scene.
  63719. * This impacts both the direct diffuse and specular highlights.
  63720. */
  63721. directIntensity: number;
  63722. /**
  63723. * Intensity of the environment e.g. how much the environment will light the object
  63724. * either through harmonics for rough material or through the refelction for shiny ones.
  63725. */
  63726. environmentIntensity: number;
  63727. /**
  63728. * This is a special control allowing the reduction of the specular highlights coming from the
  63729. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63730. */
  63731. specularIntensity: number;
  63732. /**
  63733. * Defines the falloff type used in this material.
  63734. * It by default is Physical.
  63735. */
  63736. lightFalloff: number;
  63737. /**
  63738. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63739. */
  63740. useAlphaFromAlbedoTexture: boolean;
  63741. /**
  63742. * Specifies that alpha test should be used
  63743. */
  63744. useAlphaTest: boolean;
  63745. /**
  63746. * Defines the alpha limits in alpha test mode.
  63747. */
  63748. alphaTestCutoff: number;
  63749. /**
  63750. * Specifies that alpha blending should be used
  63751. */
  63752. useAlphaBlending: boolean;
  63753. /**
  63754. * Defines if the alpha value should be determined via the rgb values.
  63755. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63756. */
  63757. opacityRGB: boolean;
  63758. /**
  63759. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63760. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63761. */
  63762. useRadianceOverAlpha: boolean;
  63763. /**
  63764. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63765. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63766. */
  63767. useSpecularOverAlpha: boolean;
  63768. /**
  63769. * Enables specular anti aliasing in the PBR shader.
  63770. * It will both interacts on the Geometry for analytical and IBL lighting.
  63771. * It also prefilter the roughness map based on the bump values.
  63772. */
  63773. enableSpecularAntiAliasing: boolean;
  63774. /**
  63775. * Enables realtime filtering on the texture.
  63776. */
  63777. realTimeFiltering: boolean;
  63778. /**
  63779. * Quality switch for realtime filtering
  63780. */
  63781. realTimeFilteringQuality: number;
  63782. /**
  63783. * Defines if the material uses energy conservation.
  63784. */
  63785. useEnergyConservation: boolean;
  63786. /**
  63787. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63788. * too much the area relying on ambient texture to define their ambient occlusion.
  63789. */
  63790. useRadianceOcclusion: boolean;
  63791. /**
  63792. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63793. * makes the reflect vector face the model (under horizon).
  63794. */
  63795. useHorizonOcclusion: boolean;
  63796. /**
  63797. * If set to true, no lighting calculations will be applied.
  63798. */
  63799. unlit: boolean;
  63800. /**
  63801. * Force normal to face away from face.
  63802. */
  63803. forceNormalForward: boolean;
  63804. /**
  63805. * Defines the material debug mode.
  63806. * It helps seeing only some components of the material while troubleshooting.
  63807. */
  63808. debugMode: number;
  63809. /**
  63810. * Specify from where on screen the debug mode should start.
  63811. * The value goes from -1 (full screen) to 1 (not visible)
  63812. * It helps with side by side comparison against the final render
  63813. * This defaults to 0
  63814. */
  63815. debugLimit: number;
  63816. /**
  63817. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63818. * You can use the factor to better multiply the final value.
  63819. */
  63820. debugFactor: number;
  63821. /**
  63822. * Initialize the block and prepare the context for build
  63823. * @param state defines the state that will be used for the build
  63824. */
  63825. initialize(state: NodeMaterialBuildState): void;
  63826. /**
  63827. * Gets the current class name
  63828. * @returns the class name
  63829. */
  63830. getClassName(): string;
  63831. /**
  63832. * Gets the world position input component
  63833. */
  63834. get worldPosition(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the world normal input component
  63837. */
  63838. get worldNormal(): NodeMaterialConnectionPoint;
  63839. /**
  63840. * Gets the perturbed normal input component
  63841. */
  63842. get perturbedNormal(): NodeMaterialConnectionPoint;
  63843. /**
  63844. * Gets the camera position input component
  63845. */
  63846. get cameraPosition(): NodeMaterialConnectionPoint;
  63847. /**
  63848. * Gets the base color input component
  63849. */
  63850. get baseColor(): NodeMaterialConnectionPoint;
  63851. /**
  63852. * Gets the opacity texture input component
  63853. */
  63854. get opacityTexture(): NodeMaterialConnectionPoint;
  63855. /**
  63856. * Gets the ambient color input component
  63857. */
  63858. get ambientColor(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the reflectivity object parameters
  63861. */
  63862. get reflectivity(): NodeMaterialConnectionPoint;
  63863. /**
  63864. * Gets the ambient occlusion object parameters
  63865. */
  63866. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63867. /**
  63868. * Gets the reflection object parameters
  63869. */
  63870. get reflection(): NodeMaterialConnectionPoint;
  63871. /**
  63872. * Gets the sheen object parameters
  63873. */
  63874. get sheen(): NodeMaterialConnectionPoint;
  63875. /**
  63876. * Gets the clear coat object parameters
  63877. */
  63878. get clearcoat(): NodeMaterialConnectionPoint;
  63879. /**
  63880. * Gets the sub surface object parameters
  63881. */
  63882. get subsurface(): NodeMaterialConnectionPoint;
  63883. /**
  63884. * Gets the anisotropy object parameters
  63885. */
  63886. get anisotropy(): NodeMaterialConnectionPoint;
  63887. /**
  63888. * Gets the ambient output component
  63889. */
  63890. get ambient(): NodeMaterialConnectionPoint;
  63891. /**
  63892. * Gets the diffuse output component
  63893. */
  63894. get diffuse(): NodeMaterialConnectionPoint;
  63895. /**
  63896. * Gets the specular output component
  63897. */
  63898. get specular(): NodeMaterialConnectionPoint;
  63899. /**
  63900. * Gets the sheen output component
  63901. */
  63902. get sheenDir(): NodeMaterialConnectionPoint;
  63903. /**
  63904. * Gets the clear coat output component
  63905. */
  63906. get clearcoatDir(): NodeMaterialConnectionPoint;
  63907. /**
  63908. * Gets the indirect diffuse output component
  63909. */
  63910. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63911. /**
  63912. * Gets the indirect specular output component
  63913. */
  63914. get specularIndirect(): NodeMaterialConnectionPoint;
  63915. /**
  63916. * Gets the indirect sheen output component
  63917. */
  63918. get sheenIndirect(): NodeMaterialConnectionPoint;
  63919. /**
  63920. * Gets the indirect clear coat output component
  63921. */
  63922. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63923. /**
  63924. * Gets the refraction output component
  63925. */
  63926. get refraction(): NodeMaterialConnectionPoint;
  63927. /**
  63928. * Gets the global lighting output component
  63929. */
  63930. get lighting(): NodeMaterialConnectionPoint;
  63931. /**
  63932. * Gets the shadow output component
  63933. */
  63934. get shadow(): NodeMaterialConnectionPoint;
  63935. /**
  63936. * Gets the alpha output component
  63937. */
  63938. get alpha(): NodeMaterialConnectionPoint;
  63939. autoConfigure(material: NodeMaterial): void;
  63940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63941. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63943. private _injectVertexCode;
  63944. /**
  63945. * Gets the code corresponding to the albedo/opacity module
  63946. * @returns the shader code
  63947. */
  63948. getAlbedoOpacityCode(): string;
  63949. protected _buildBlock(state: NodeMaterialBuildState): this;
  63950. protected _dumpPropertiesCode(): string;
  63951. serialize(): any;
  63952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63953. }
  63954. }
  63955. declare module BABYLON {
  63956. /**
  63957. * Block used to compute value of one parameter modulo another
  63958. */
  63959. export class ModBlock extends NodeMaterialBlock {
  63960. /**
  63961. * Creates a new ModBlock
  63962. * @param name defines the block name
  63963. */
  63964. constructor(name: string);
  63965. /**
  63966. * Gets the current class name
  63967. * @returns the class name
  63968. */
  63969. getClassName(): string;
  63970. /**
  63971. * Gets the left operand input component
  63972. */
  63973. get left(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the right operand input component
  63976. */
  63977. get right(): NodeMaterialConnectionPoint;
  63978. /**
  63979. * Gets the output component
  63980. */
  63981. get output(): NodeMaterialConnectionPoint;
  63982. protected _buildBlock(state: NodeMaterialBuildState): this;
  63983. }
  63984. }
  63985. declare module BABYLON {
  63986. /**
  63987. * Helper class to push actions to a pool of workers.
  63988. */
  63989. export class WorkerPool implements IDisposable {
  63990. private _workerInfos;
  63991. private _pendingActions;
  63992. /**
  63993. * Constructor
  63994. * @param workers Array of workers to use for actions
  63995. */
  63996. constructor(workers: Array<Worker>);
  63997. /**
  63998. * Terminates all workers and clears any pending actions.
  63999. */
  64000. dispose(): void;
  64001. /**
  64002. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64003. * pended until a worker has completed its action.
  64004. * @param action The action to perform. Call onComplete when the action is complete.
  64005. */
  64006. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64007. private _execute;
  64008. }
  64009. }
  64010. declare module BABYLON {
  64011. /**
  64012. * Configuration for Draco compression
  64013. */
  64014. export interface IDracoCompressionConfiguration {
  64015. /**
  64016. * Configuration for the decoder.
  64017. */
  64018. decoder: {
  64019. /**
  64020. * The url to the WebAssembly module.
  64021. */
  64022. wasmUrl?: string;
  64023. /**
  64024. * The url to the WebAssembly binary.
  64025. */
  64026. wasmBinaryUrl?: string;
  64027. /**
  64028. * The url to the fallback JavaScript module.
  64029. */
  64030. fallbackUrl?: string;
  64031. };
  64032. }
  64033. /**
  64034. * Draco compression (https://google.github.io/draco/)
  64035. *
  64036. * This class wraps the Draco module.
  64037. *
  64038. * **Encoder**
  64039. *
  64040. * The encoder is not currently implemented.
  64041. *
  64042. * **Decoder**
  64043. *
  64044. * 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.
  64045. *
  64046. * To update the configuration, use the following code:
  64047. * ```javascript
  64048. * DracoCompression.Configuration = {
  64049. * decoder: {
  64050. * wasmUrl: "<url to the WebAssembly library>",
  64051. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64052. * fallbackUrl: "<url to the fallback JavaScript library>",
  64053. * }
  64054. * };
  64055. * ```
  64056. *
  64057. * 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.
  64058. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64059. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64060. *
  64061. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64062. * ```javascript
  64063. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64064. * ```
  64065. *
  64066. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64067. */
  64068. export class DracoCompression implements IDisposable {
  64069. private _workerPoolPromise?;
  64070. private _decoderModulePromise?;
  64071. /**
  64072. * The configuration. Defaults to the following urls:
  64073. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64074. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64075. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64076. */
  64077. static Configuration: IDracoCompressionConfiguration;
  64078. /**
  64079. * Returns true if the decoder configuration is available.
  64080. */
  64081. static get DecoderAvailable(): boolean;
  64082. /**
  64083. * Default number of workers to create when creating the draco compression object.
  64084. */
  64085. static DefaultNumWorkers: number;
  64086. private static GetDefaultNumWorkers;
  64087. private static _Default;
  64088. /**
  64089. * Default instance for the draco compression object.
  64090. */
  64091. static get Default(): DracoCompression;
  64092. /**
  64093. * Constructor
  64094. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64095. */
  64096. constructor(numWorkers?: number);
  64097. /**
  64098. * Stop all async operations and release resources.
  64099. */
  64100. dispose(): void;
  64101. /**
  64102. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64103. * @returns a promise that resolves when ready
  64104. */
  64105. whenReadyAsync(): Promise<void>;
  64106. /**
  64107. * Decode Draco compressed mesh data to vertex data.
  64108. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64109. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64110. * @returns A promise that resolves with the decoded vertex data
  64111. */
  64112. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64113. [kind: string]: number;
  64114. }): Promise<VertexData>;
  64115. }
  64116. }
  64117. declare module BABYLON {
  64118. /**
  64119. * Class for building Constructive Solid Geometry
  64120. */
  64121. export class CSG {
  64122. private polygons;
  64123. /**
  64124. * The world matrix
  64125. */
  64126. matrix: Matrix;
  64127. /**
  64128. * Stores the position
  64129. */
  64130. position: Vector3;
  64131. /**
  64132. * Stores the rotation
  64133. */
  64134. rotation: Vector3;
  64135. /**
  64136. * Stores the rotation quaternion
  64137. */
  64138. rotationQuaternion: Nullable<Quaternion>;
  64139. /**
  64140. * Stores the scaling vector
  64141. */
  64142. scaling: Vector3;
  64143. /**
  64144. * Convert the Mesh to CSG
  64145. * @param mesh The Mesh to convert to CSG
  64146. * @returns A new CSG from the Mesh
  64147. */
  64148. static FromMesh(mesh: Mesh): CSG;
  64149. /**
  64150. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64151. * @param polygons Polygons used to construct a CSG solid
  64152. */
  64153. private static FromPolygons;
  64154. /**
  64155. * Clones, or makes a deep copy, of the CSG
  64156. * @returns A new CSG
  64157. */
  64158. clone(): CSG;
  64159. /**
  64160. * Unions this CSG with another CSG
  64161. * @param csg The CSG to union against this CSG
  64162. * @returns The unioned CSG
  64163. */
  64164. union(csg: CSG): CSG;
  64165. /**
  64166. * Unions this CSG with another CSG in place
  64167. * @param csg The CSG to union against this CSG
  64168. */
  64169. unionInPlace(csg: CSG): void;
  64170. /**
  64171. * Subtracts this CSG with another CSG
  64172. * @param csg The CSG to subtract against this CSG
  64173. * @returns A new CSG
  64174. */
  64175. subtract(csg: CSG): CSG;
  64176. /**
  64177. * Subtracts this CSG with another CSG in place
  64178. * @param csg The CSG to subtact against this CSG
  64179. */
  64180. subtractInPlace(csg: CSG): void;
  64181. /**
  64182. * Intersect this CSG with another CSG
  64183. * @param csg The CSG to intersect against this CSG
  64184. * @returns A new CSG
  64185. */
  64186. intersect(csg: CSG): CSG;
  64187. /**
  64188. * Intersects this CSG with another CSG in place
  64189. * @param csg The CSG to intersect against this CSG
  64190. */
  64191. intersectInPlace(csg: CSG): void;
  64192. /**
  64193. * Return a new CSG solid with solid and empty space switched. This solid is
  64194. * not modified.
  64195. * @returns A new CSG solid with solid and empty space switched
  64196. */
  64197. inverse(): CSG;
  64198. /**
  64199. * Inverses the CSG in place
  64200. */
  64201. inverseInPlace(): void;
  64202. /**
  64203. * This is used to keep meshes transformations so they can be restored
  64204. * when we build back a Babylon Mesh
  64205. * NB : All CSG operations are performed in world coordinates
  64206. * @param csg The CSG to copy the transform attributes from
  64207. * @returns This CSG
  64208. */
  64209. copyTransformAttributes(csg: CSG): CSG;
  64210. /**
  64211. * Build Raw mesh from CSG
  64212. * Coordinates here are in world space
  64213. * @param name The name of the mesh geometry
  64214. * @param scene The Scene
  64215. * @param keepSubMeshes Specifies if the submeshes should be kept
  64216. * @returns A new Mesh
  64217. */
  64218. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64219. /**
  64220. * Build Mesh from CSG taking material and transforms into account
  64221. * @param name The name of the Mesh
  64222. * @param material The material of the Mesh
  64223. * @param scene The Scene
  64224. * @param keepSubMeshes Specifies if submeshes should be kept
  64225. * @returns The new Mesh
  64226. */
  64227. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64228. }
  64229. }
  64230. declare module BABYLON {
  64231. /**
  64232. * Class used to create a trail following a mesh
  64233. */
  64234. export class TrailMesh extends Mesh {
  64235. private _generator;
  64236. private _autoStart;
  64237. private _running;
  64238. private _diameter;
  64239. private _length;
  64240. private _sectionPolygonPointsCount;
  64241. private _sectionVectors;
  64242. private _sectionNormalVectors;
  64243. private _beforeRenderObserver;
  64244. /**
  64245. * @constructor
  64246. * @param name The value used by scene.getMeshByName() to do a lookup.
  64247. * @param generator The mesh or transform node to generate a trail.
  64248. * @param scene The scene to add this mesh to.
  64249. * @param diameter Diameter of trailing mesh. Default is 1.
  64250. * @param length Length of trailing mesh. Default is 60.
  64251. * @param autoStart Automatically start trailing mesh. Default true.
  64252. */
  64253. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64254. /**
  64255. * "TrailMesh"
  64256. * @returns "TrailMesh"
  64257. */
  64258. getClassName(): string;
  64259. private _createMesh;
  64260. /**
  64261. * Start trailing mesh.
  64262. */
  64263. start(): void;
  64264. /**
  64265. * Stop trailing mesh.
  64266. */
  64267. stop(): void;
  64268. /**
  64269. * Update trailing mesh geometry.
  64270. */
  64271. update(): void;
  64272. /**
  64273. * Returns a new TrailMesh object.
  64274. * @param name is a string, the name given to the new mesh
  64275. * @param newGenerator use new generator object for cloned trail mesh
  64276. * @returns a new mesh
  64277. */
  64278. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64279. /**
  64280. * Serializes this trail mesh
  64281. * @param serializationObject object to write serialization to
  64282. */
  64283. serialize(serializationObject: any): void;
  64284. /**
  64285. * Parses a serialized trail mesh
  64286. * @param parsedMesh the serialized mesh
  64287. * @param scene the scene to create the trail mesh in
  64288. * @returns the created trail mesh
  64289. */
  64290. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64291. }
  64292. }
  64293. declare module BABYLON {
  64294. /**
  64295. * Class containing static functions to help procedurally build meshes
  64296. */
  64297. export class TiledBoxBuilder {
  64298. /**
  64299. * Creates a box mesh
  64300. * 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)
  64301. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64303. * * 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
  64304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64305. * @param name defines the name of the mesh
  64306. * @param options defines the options used to create the mesh
  64307. * @param scene defines the hosting scene
  64308. * @returns the box mesh
  64309. */
  64310. static CreateTiledBox(name: string, options: {
  64311. pattern?: number;
  64312. width?: number;
  64313. height?: number;
  64314. depth?: number;
  64315. tileSize?: number;
  64316. tileWidth?: number;
  64317. tileHeight?: number;
  64318. alignHorizontal?: number;
  64319. alignVertical?: number;
  64320. faceUV?: Vector4[];
  64321. faceColors?: Color4[];
  64322. sideOrientation?: number;
  64323. updatable?: boolean;
  64324. }, scene?: Nullable<Scene>): Mesh;
  64325. }
  64326. }
  64327. declare module BABYLON {
  64328. /**
  64329. * Class containing static functions to help procedurally build meshes
  64330. */
  64331. export class TorusKnotBuilder {
  64332. /**
  64333. * Creates a torus knot mesh
  64334. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64335. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64336. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64337. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64339. * * 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
  64340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64341. * @param name defines the name of the mesh
  64342. * @param options defines the options used to create the mesh
  64343. * @param scene defines the hosting scene
  64344. * @returns the torus knot mesh
  64345. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64346. */
  64347. static CreateTorusKnot(name: string, options: {
  64348. radius?: number;
  64349. tube?: number;
  64350. radialSegments?: number;
  64351. tubularSegments?: number;
  64352. p?: number;
  64353. q?: number;
  64354. updatable?: boolean;
  64355. sideOrientation?: number;
  64356. frontUVs?: Vector4;
  64357. backUVs?: Vector4;
  64358. }, scene: any): Mesh;
  64359. }
  64360. }
  64361. declare module BABYLON {
  64362. /**
  64363. * Polygon
  64364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64365. */
  64366. export class Polygon {
  64367. /**
  64368. * Creates a rectangle
  64369. * @param xmin bottom X coord
  64370. * @param ymin bottom Y coord
  64371. * @param xmax top X coord
  64372. * @param ymax top Y coord
  64373. * @returns points that make the resulting rectation
  64374. */
  64375. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64376. /**
  64377. * Creates a circle
  64378. * @param radius radius of circle
  64379. * @param cx scale in x
  64380. * @param cy scale in y
  64381. * @param numberOfSides number of sides that make up the circle
  64382. * @returns points that make the resulting circle
  64383. */
  64384. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64385. /**
  64386. * Creates a polygon from input string
  64387. * @param input Input polygon data
  64388. * @returns the parsed points
  64389. */
  64390. static Parse(input: string): Vector2[];
  64391. /**
  64392. * Starts building a polygon from x and y coordinates
  64393. * @param x x coordinate
  64394. * @param y y coordinate
  64395. * @returns the started path2
  64396. */
  64397. static StartingAt(x: number, y: number): Path2;
  64398. }
  64399. /**
  64400. * Builds a polygon
  64401. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64402. */
  64403. export class PolygonMeshBuilder {
  64404. private _points;
  64405. private _outlinepoints;
  64406. private _holes;
  64407. private _name;
  64408. private _scene;
  64409. private _epoints;
  64410. private _eholes;
  64411. private _addToepoint;
  64412. /**
  64413. * Babylon reference to the earcut plugin.
  64414. */
  64415. bjsEarcut: any;
  64416. /**
  64417. * Creates a PolygonMeshBuilder
  64418. * @param name name of the builder
  64419. * @param contours Path of the polygon
  64420. * @param scene scene to add to when creating the mesh
  64421. * @param earcutInjection can be used to inject your own earcut reference
  64422. */
  64423. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64424. /**
  64425. * Adds a whole within the polygon
  64426. * @param hole Array of points defining the hole
  64427. * @returns this
  64428. */
  64429. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64430. /**
  64431. * Creates the polygon
  64432. * @param updatable If the mesh should be updatable
  64433. * @param depth The depth of the mesh created
  64434. * @returns the created mesh
  64435. */
  64436. build(updatable?: boolean, depth?: number): Mesh;
  64437. /**
  64438. * Creates the polygon
  64439. * @param depth The depth of the mesh created
  64440. * @returns the created VertexData
  64441. */
  64442. buildVertexData(depth?: number): VertexData;
  64443. /**
  64444. * Adds a side to the polygon
  64445. * @param positions points that make the polygon
  64446. * @param normals normals of the polygon
  64447. * @param uvs uvs of the polygon
  64448. * @param indices indices of the polygon
  64449. * @param bounds bounds of the polygon
  64450. * @param points points of the polygon
  64451. * @param depth depth of the polygon
  64452. * @param flip flip of the polygon
  64453. */
  64454. private addSide;
  64455. }
  64456. }
  64457. declare module BABYLON {
  64458. /**
  64459. * Class containing static functions to help procedurally build meshes
  64460. */
  64461. export class PolygonBuilder {
  64462. /**
  64463. * Creates a polygon mesh
  64464. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64465. * * 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
  64466. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64468. * * 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)
  64469. * * Remember you can only change the shape positions, not their number when updating a polygon
  64470. * @param name defines the name of the mesh
  64471. * @param options defines the options used to create the mesh
  64472. * @param scene defines the hosting scene
  64473. * @param earcutInjection can be used to inject your own earcut reference
  64474. * @returns the polygon mesh
  64475. */
  64476. static CreatePolygon(name: string, options: {
  64477. shape: Vector3[];
  64478. holes?: Vector3[][];
  64479. depth?: number;
  64480. faceUV?: Vector4[];
  64481. faceColors?: Color4[];
  64482. updatable?: boolean;
  64483. sideOrientation?: number;
  64484. frontUVs?: Vector4;
  64485. backUVs?: Vector4;
  64486. wrap?: boolean;
  64487. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64488. /**
  64489. * Creates an extruded polygon mesh, with depth in the Y direction.
  64490. * * 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)
  64491. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64492. * @param name defines the name of the mesh
  64493. * @param options defines the options used to create the mesh
  64494. * @param scene defines the hosting scene
  64495. * @param earcutInjection can be used to inject your own earcut reference
  64496. * @returns the polygon mesh
  64497. */
  64498. static ExtrudePolygon(name: string, options: {
  64499. shape: Vector3[];
  64500. holes?: Vector3[][];
  64501. depth?: number;
  64502. faceUV?: Vector4[];
  64503. faceColors?: Color4[];
  64504. updatable?: boolean;
  64505. sideOrientation?: number;
  64506. frontUVs?: Vector4;
  64507. backUVs?: Vector4;
  64508. wrap?: boolean;
  64509. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64510. }
  64511. }
  64512. declare module BABYLON {
  64513. /**
  64514. * Class containing static functions to help procedurally build meshes
  64515. */
  64516. export class LatheBuilder {
  64517. /**
  64518. * Creates lathe mesh.
  64519. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64520. * * 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
  64521. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64522. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64523. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64524. * * 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
  64525. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64526. * * 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
  64527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64528. * * 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
  64529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64531. * @param name defines the name of the mesh
  64532. * @param options defines the options used to create the mesh
  64533. * @param scene defines the hosting scene
  64534. * @returns the lathe mesh
  64535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64536. */
  64537. static CreateLathe(name: string, options: {
  64538. shape: Vector3[];
  64539. radius?: number;
  64540. tessellation?: number;
  64541. clip?: number;
  64542. arc?: number;
  64543. closed?: boolean;
  64544. updatable?: boolean;
  64545. sideOrientation?: number;
  64546. frontUVs?: Vector4;
  64547. backUVs?: Vector4;
  64548. cap?: number;
  64549. invertUV?: boolean;
  64550. }, scene?: Nullable<Scene>): Mesh;
  64551. }
  64552. }
  64553. declare module BABYLON {
  64554. /**
  64555. * Class containing static functions to help procedurally build meshes
  64556. */
  64557. export class TiledPlaneBuilder {
  64558. /**
  64559. * Creates a tiled plane mesh
  64560. * * The parameter `pattern` will, depending on value, do nothing or
  64561. * * * flip (reflect about central vertical) alternate tiles across and up
  64562. * * * flip every tile on alternate rows
  64563. * * * rotate (180 degs) alternate tiles across and up
  64564. * * * rotate every tile on alternate rows
  64565. * * * flip and rotate alternate tiles across and up
  64566. * * * flip and rotate every tile on alternate rows
  64567. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64568. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64569. * * 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
  64570. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64571. * * 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)
  64572. * * 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)
  64573. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64574. * @param name defines the name of the mesh
  64575. * @param options defines the options used to create the mesh
  64576. * @param scene defines the hosting scene
  64577. * @returns the box mesh
  64578. */
  64579. static CreateTiledPlane(name: string, options: {
  64580. pattern?: number;
  64581. tileSize?: number;
  64582. tileWidth?: number;
  64583. tileHeight?: number;
  64584. size?: number;
  64585. width?: number;
  64586. height?: number;
  64587. alignHorizontal?: number;
  64588. alignVertical?: number;
  64589. sideOrientation?: number;
  64590. frontUVs?: Vector4;
  64591. backUVs?: Vector4;
  64592. updatable?: boolean;
  64593. }, scene?: Nullable<Scene>): Mesh;
  64594. }
  64595. }
  64596. declare module BABYLON {
  64597. /**
  64598. * Class containing static functions to help procedurally build meshes
  64599. */
  64600. export class TubeBuilder {
  64601. /**
  64602. * Creates a tube mesh.
  64603. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64604. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64605. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64606. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64607. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64608. * * 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)
  64609. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64610. * * 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
  64611. * * 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
  64612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64613. * * 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
  64614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64616. * @param name defines the name of the mesh
  64617. * @param options defines the options used to create the mesh
  64618. * @param scene defines the hosting scene
  64619. * @returns the tube mesh
  64620. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64621. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64622. */
  64623. static CreateTube(name: string, options: {
  64624. path: Vector3[];
  64625. radius?: number;
  64626. tessellation?: number;
  64627. radiusFunction?: {
  64628. (i: number, distance: number): number;
  64629. };
  64630. cap?: number;
  64631. arc?: number;
  64632. updatable?: boolean;
  64633. sideOrientation?: number;
  64634. frontUVs?: Vector4;
  64635. backUVs?: Vector4;
  64636. instance?: Mesh;
  64637. invertUV?: boolean;
  64638. }, scene?: Nullable<Scene>): Mesh;
  64639. }
  64640. }
  64641. declare module BABYLON {
  64642. /**
  64643. * Class containing static functions to help procedurally build meshes
  64644. */
  64645. export class IcoSphereBuilder {
  64646. /**
  64647. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64648. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64649. * * 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`)
  64650. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64651. * * 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
  64652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64653. * * 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
  64654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64655. * @param name defines the name of the mesh
  64656. * @param options defines the options used to create the mesh
  64657. * @param scene defines the hosting scene
  64658. * @returns the icosahedron mesh
  64659. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64660. */
  64661. static CreateIcoSphere(name: string, options: {
  64662. radius?: number;
  64663. radiusX?: number;
  64664. radiusY?: number;
  64665. radiusZ?: number;
  64666. flat?: boolean;
  64667. subdivisions?: number;
  64668. sideOrientation?: number;
  64669. frontUVs?: Vector4;
  64670. backUVs?: Vector4;
  64671. updatable?: boolean;
  64672. }, scene?: Nullable<Scene>): Mesh;
  64673. }
  64674. }
  64675. declare module BABYLON {
  64676. /**
  64677. * Class containing static functions to help procedurally build meshes
  64678. */
  64679. export class DecalBuilder {
  64680. /**
  64681. * Creates a decal mesh.
  64682. * 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
  64683. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64684. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64685. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64686. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64687. * @param name defines the name of the mesh
  64688. * @param sourceMesh defines the mesh where the decal must be applied
  64689. * @param options defines the options used to create the mesh
  64690. * @param scene defines the hosting scene
  64691. * @returns the decal mesh
  64692. * @see https://doc.babylonjs.com/how_to/decals
  64693. */
  64694. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64695. position?: Vector3;
  64696. normal?: Vector3;
  64697. size?: Vector3;
  64698. angle?: number;
  64699. }): Mesh;
  64700. }
  64701. }
  64702. declare module BABYLON {
  64703. /**
  64704. * Class containing static functions to help procedurally build meshes
  64705. */
  64706. export class MeshBuilder {
  64707. /**
  64708. * Creates a box mesh
  64709. * * The parameter `size` sets the size (float) of each box side (default 1)
  64710. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64711. * * 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)
  64712. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64714. * * 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
  64715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64716. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64717. * @param name defines the name of the mesh
  64718. * @param options defines the options used to create the mesh
  64719. * @param scene defines the hosting scene
  64720. * @returns the box mesh
  64721. */
  64722. static CreateBox(name: string, options: {
  64723. size?: number;
  64724. width?: number;
  64725. height?: number;
  64726. depth?: number;
  64727. faceUV?: Vector4[];
  64728. faceColors?: Color4[];
  64729. sideOrientation?: number;
  64730. frontUVs?: Vector4;
  64731. backUVs?: Vector4;
  64732. wrap?: boolean;
  64733. topBaseAt?: number;
  64734. bottomBaseAt?: number;
  64735. updatable?: boolean;
  64736. }, scene?: Nullable<Scene>): Mesh;
  64737. /**
  64738. * Creates a tiled box mesh
  64739. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64741. * @param name defines the name of the mesh
  64742. * @param options defines the options used to create the mesh
  64743. * @param scene defines the hosting scene
  64744. * @returns the tiled box mesh
  64745. */
  64746. static CreateTiledBox(name: string, options: {
  64747. pattern?: number;
  64748. size?: number;
  64749. width?: number;
  64750. height?: number;
  64751. depth: number;
  64752. tileSize?: number;
  64753. tileWidth?: number;
  64754. tileHeight?: number;
  64755. faceUV?: Vector4[];
  64756. faceColors?: Color4[];
  64757. alignHorizontal?: number;
  64758. alignVertical?: number;
  64759. sideOrientation?: number;
  64760. updatable?: boolean;
  64761. }, scene?: Nullable<Scene>): Mesh;
  64762. /**
  64763. * Creates a sphere mesh
  64764. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64765. * * 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`)
  64766. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64767. * * 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
  64768. * * 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)
  64769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64770. * * 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
  64771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64772. * @param name defines the name of the mesh
  64773. * @param options defines the options used to create the mesh
  64774. * @param scene defines the hosting scene
  64775. * @returns the sphere mesh
  64776. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64777. */
  64778. static CreateSphere(name: string, options: {
  64779. segments?: number;
  64780. diameter?: number;
  64781. diameterX?: number;
  64782. diameterY?: number;
  64783. diameterZ?: number;
  64784. arc?: number;
  64785. slice?: number;
  64786. sideOrientation?: number;
  64787. frontUVs?: Vector4;
  64788. backUVs?: Vector4;
  64789. updatable?: boolean;
  64790. }, scene?: Nullable<Scene>): Mesh;
  64791. /**
  64792. * Creates a plane polygonal mesh. By default, this is a disc
  64793. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64794. * * 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
  64795. * * 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
  64796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64797. * * 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
  64798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64799. * @param name defines the name of the mesh
  64800. * @param options defines the options used to create the mesh
  64801. * @param scene defines the hosting scene
  64802. * @returns the plane polygonal mesh
  64803. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64804. */
  64805. static CreateDisc(name: string, options: {
  64806. radius?: number;
  64807. tessellation?: number;
  64808. arc?: number;
  64809. updatable?: boolean;
  64810. sideOrientation?: number;
  64811. frontUVs?: Vector4;
  64812. backUVs?: Vector4;
  64813. }, scene?: Nullable<Scene>): Mesh;
  64814. /**
  64815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64817. * * 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`)
  64818. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64819. * * 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
  64820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64821. * * 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
  64822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64823. * @param name defines the name of the mesh
  64824. * @param options defines the options used to create the mesh
  64825. * @param scene defines the hosting scene
  64826. * @returns the icosahedron mesh
  64827. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64828. */
  64829. static CreateIcoSphere(name: string, options: {
  64830. radius?: number;
  64831. radiusX?: number;
  64832. radiusY?: number;
  64833. radiusZ?: number;
  64834. flat?: boolean;
  64835. subdivisions?: number;
  64836. sideOrientation?: number;
  64837. frontUVs?: Vector4;
  64838. backUVs?: Vector4;
  64839. updatable?: boolean;
  64840. }, scene?: Nullable<Scene>): Mesh;
  64841. /**
  64842. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64843. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64844. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64845. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64846. * * 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
  64847. * * 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
  64848. * * 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
  64849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64850. * * 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
  64851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64852. * * 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
  64853. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64854. * * 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
  64855. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64857. * @param name defines the name of the mesh
  64858. * @param options defines the options used to create the mesh
  64859. * @param scene defines the hosting scene
  64860. * @returns the ribbon mesh
  64861. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64863. */
  64864. static CreateRibbon(name: string, options: {
  64865. pathArray: Vector3[][];
  64866. closeArray?: boolean;
  64867. closePath?: boolean;
  64868. offset?: number;
  64869. updatable?: boolean;
  64870. sideOrientation?: number;
  64871. frontUVs?: Vector4;
  64872. backUVs?: Vector4;
  64873. instance?: Mesh;
  64874. invertUV?: boolean;
  64875. uvs?: Vector2[];
  64876. colors?: Color4[];
  64877. }, scene?: Nullable<Scene>): Mesh;
  64878. /**
  64879. * Creates a cylinder or a cone mesh
  64880. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64881. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64882. * * 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.
  64883. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64884. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64885. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64886. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64887. * * 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).
  64888. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64889. * * 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).
  64890. * * 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
  64891. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64892. * * 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
  64893. * * 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.
  64894. * * If `enclose` is false, a ring surface is one element.
  64895. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64896. * * 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
  64897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64898. * * 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
  64899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64900. * @param name defines the name of the mesh
  64901. * @param options defines the options used to create the mesh
  64902. * @param scene defines the hosting scene
  64903. * @returns the cylinder mesh
  64904. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64905. */
  64906. static CreateCylinder(name: string, options: {
  64907. height?: number;
  64908. diameterTop?: number;
  64909. diameterBottom?: number;
  64910. diameter?: number;
  64911. tessellation?: number;
  64912. subdivisions?: number;
  64913. arc?: number;
  64914. faceColors?: Color4[];
  64915. faceUV?: Vector4[];
  64916. updatable?: boolean;
  64917. hasRings?: boolean;
  64918. enclose?: boolean;
  64919. cap?: number;
  64920. sideOrientation?: number;
  64921. frontUVs?: Vector4;
  64922. backUVs?: Vector4;
  64923. }, scene?: Nullable<Scene>): Mesh;
  64924. /**
  64925. * Creates a torus mesh
  64926. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64927. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64928. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64930. * * 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
  64931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64932. * @param name defines the name of the mesh
  64933. * @param options defines the options used to create the mesh
  64934. * @param scene defines the hosting scene
  64935. * @returns the torus mesh
  64936. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64937. */
  64938. static CreateTorus(name: string, options: {
  64939. diameter?: number;
  64940. thickness?: number;
  64941. tessellation?: number;
  64942. updatable?: boolean;
  64943. sideOrientation?: number;
  64944. frontUVs?: Vector4;
  64945. backUVs?: Vector4;
  64946. }, scene?: Nullable<Scene>): Mesh;
  64947. /**
  64948. * Creates a torus knot mesh
  64949. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64950. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64951. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64952. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64954. * * 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
  64955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64956. * @param name defines the name of the mesh
  64957. * @param options defines the options used to create the mesh
  64958. * @param scene defines the hosting scene
  64959. * @returns the torus knot mesh
  64960. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64961. */
  64962. static CreateTorusKnot(name: string, options: {
  64963. radius?: number;
  64964. tube?: number;
  64965. radialSegments?: number;
  64966. tubularSegments?: number;
  64967. p?: number;
  64968. q?: number;
  64969. updatable?: boolean;
  64970. sideOrientation?: number;
  64971. frontUVs?: Vector4;
  64972. backUVs?: Vector4;
  64973. }, scene?: Nullable<Scene>): Mesh;
  64974. /**
  64975. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64976. * * 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
  64977. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64978. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64979. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64980. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64981. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64982. * * 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
  64983. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64985. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64986. * @param name defines the name of the new line system
  64987. * @param options defines the options used to create the line system
  64988. * @param scene defines the hosting scene
  64989. * @returns a new line system mesh
  64990. */
  64991. static CreateLineSystem(name: string, options: {
  64992. lines: Vector3[][];
  64993. updatable?: boolean;
  64994. instance?: Nullable<LinesMesh>;
  64995. colors?: Nullable<Color4[][]>;
  64996. useVertexAlpha?: boolean;
  64997. }, scene: Nullable<Scene>): LinesMesh;
  64998. /**
  64999. * Creates a line mesh
  65000. * 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
  65001. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65002. * * The parameter `points` is an array successive Vector3
  65003. * * 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
  65004. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65005. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65006. * * When updating an instance, remember that only point positions can change, not the number of points
  65007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65009. * @param name defines the name of the new line system
  65010. * @param options defines the options used to create the line system
  65011. * @param scene defines the hosting scene
  65012. * @returns a new line mesh
  65013. */
  65014. static CreateLines(name: string, options: {
  65015. points: Vector3[];
  65016. updatable?: boolean;
  65017. instance?: Nullable<LinesMesh>;
  65018. colors?: Color4[];
  65019. useVertexAlpha?: boolean;
  65020. }, scene?: Nullable<Scene>): LinesMesh;
  65021. /**
  65022. * Creates a dashed line mesh
  65023. * * 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
  65024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65025. * * The parameter `points` is an array successive Vector3
  65026. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65027. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65028. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65029. * * 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
  65030. * * When updating an instance, remember that only point positions can change, not the number of points
  65031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65032. * @param name defines the name of the mesh
  65033. * @param options defines the options used to create the mesh
  65034. * @param scene defines the hosting scene
  65035. * @returns the dashed line mesh
  65036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65037. */
  65038. static CreateDashedLines(name: string, options: {
  65039. points: Vector3[];
  65040. dashSize?: number;
  65041. gapSize?: number;
  65042. dashNb?: number;
  65043. updatable?: boolean;
  65044. instance?: LinesMesh;
  65045. }, scene?: Nullable<Scene>): LinesMesh;
  65046. /**
  65047. * 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.
  65048. * * 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.
  65049. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65050. * * 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.
  65051. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65052. * * 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
  65053. * * 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
  65054. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65056. * * 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
  65057. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65059. * @param name defines the name of the mesh
  65060. * @param options defines the options used to create the mesh
  65061. * @param scene defines the hosting scene
  65062. * @returns the extruded shape mesh
  65063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65065. */
  65066. static ExtrudeShape(name: string, options: {
  65067. shape: Vector3[];
  65068. path: Vector3[];
  65069. scale?: number;
  65070. rotation?: number;
  65071. cap?: number;
  65072. updatable?: boolean;
  65073. sideOrientation?: number;
  65074. frontUVs?: Vector4;
  65075. backUVs?: Vector4;
  65076. instance?: Mesh;
  65077. invertUV?: boolean;
  65078. }, scene?: Nullable<Scene>): Mesh;
  65079. /**
  65080. * Creates an custom extruded shape mesh.
  65081. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65082. * * 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.
  65083. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65084. * * 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
  65085. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65086. * * 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
  65087. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65088. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65089. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65090. * * 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
  65091. * * 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
  65092. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65094. * * 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
  65095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65097. * @param name defines the name of the mesh
  65098. * @param options defines the options used to create the mesh
  65099. * @param scene defines the hosting scene
  65100. * @returns the custom extruded shape mesh
  65101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65104. */
  65105. static ExtrudeShapeCustom(name: string, options: {
  65106. shape: Vector3[];
  65107. path: Vector3[];
  65108. scaleFunction?: any;
  65109. rotationFunction?: any;
  65110. ribbonCloseArray?: boolean;
  65111. ribbonClosePath?: boolean;
  65112. cap?: number;
  65113. updatable?: boolean;
  65114. sideOrientation?: number;
  65115. frontUVs?: Vector4;
  65116. backUVs?: Vector4;
  65117. instance?: Mesh;
  65118. invertUV?: boolean;
  65119. }, scene?: Nullable<Scene>): Mesh;
  65120. /**
  65121. * Creates lathe mesh.
  65122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65123. * * 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
  65124. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65125. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65126. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65127. * * 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
  65128. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65129. * * 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
  65130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65131. * * 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
  65132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65134. * @param name defines the name of the mesh
  65135. * @param options defines the options used to create the mesh
  65136. * @param scene defines the hosting scene
  65137. * @returns the lathe mesh
  65138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65139. */
  65140. static CreateLathe(name: string, options: {
  65141. shape: Vector3[];
  65142. radius?: number;
  65143. tessellation?: number;
  65144. clip?: number;
  65145. arc?: number;
  65146. closed?: boolean;
  65147. updatable?: boolean;
  65148. sideOrientation?: number;
  65149. frontUVs?: Vector4;
  65150. backUVs?: Vector4;
  65151. cap?: number;
  65152. invertUV?: boolean;
  65153. }, scene?: Nullable<Scene>): Mesh;
  65154. /**
  65155. * Creates a tiled plane mesh
  65156. * * You can set a limited pattern arrangement with the tiles
  65157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65158. * * 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
  65159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65160. * @param name defines the name of the mesh
  65161. * @param options defines the options used to create the mesh
  65162. * @param scene defines the hosting scene
  65163. * @returns the plane mesh
  65164. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65165. */
  65166. static CreateTiledPlane(name: string, options: {
  65167. pattern?: number;
  65168. tileSize?: number;
  65169. tileWidth?: number;
  65170. tileHeight?: number;
  65171. size?: number;
  65172. width?: number;
  65173. height?: number;
  65174. alignHorizontal?: number;
  65175. alignVertical?: number;
  65176. sideOrientation?: number;
  65177. frontUVs?: Vector4;
  65178. backUVs?: Vector4;
  65179. updatable?: boolean;
  65180. }, scene?: Nullable<Scene>): Mesh;
  65181. /**
  65182. * Creates a plane mesh
  65183. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65184. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65185. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65187. * * 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
  65188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65189. * @param name defines the name of the mesh
  65190. * @param options defines the options used to create the mesh
  65191. * @param scene defines the hosting scene
  65192. * @returns the plane mesh
  65193. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65194. */
  65195. static CreatePlane(name: string, options: {
  65196. size?: number;
  65197. width?: number;
  65198. height?: number;
  65199. sideOrientation?: number;
  65200. frontUVs?: Vector4;
  65201. backUVs?: Vector4;
  65202. updatable?: boolean;
  65203. sourcePlane?: Plane;
  65204. }, scene?: Nullable<Scene>): Mesh;
  65205. /**
  65206. * Creates a ground mesh
  65207. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65208. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65210. * @param name defines the name of the mesh
  65211. * @param options defines the options used to create the mesh
  65212. * @param scene defines the hosting scene
  65213. * @returns the ground mesh
  65214. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65215. */
  65216. static CreateGround(name: string, options: {
  65217. width?: number;
  65218. height?: number;
  65219. subdivisions?: number;
  65220. subdivisionsX?: number;
  65221. subdivisionsY?: number;
  65222. updatable?: boolean;
  65223. }, scene?: Nullable<Scene>): Mesh;
  65224. /**
  65225. * Creates a tiled ground mesh
  65226. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65227. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65228. * * 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
  65229. * * 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
  65230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65231. * @param name defines the name of the mesh
  65232. * @param options defines the options used to create the mesh
  65233. * @param scene defines the hosting scene
  65234. * @returns the tiled ground mesh
  65235. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65236. */
  65237. static CreateTiledGround(name: string, options: {
  65238. xmin: number;
  65239. zmin: number;
  65240. xmax: number;
  65241. zmax: number;
  65242. subdivisions?: {
  65243. w: number;
  65244. h: number;
  65245. };
  65246. precision?: {
  65247. w: number;
  65248. h: number;
  65249. };
  65250. updatable?: boolean;
  65251. }, scene?: Nullable<Scene>): Mesh;
  65252. /**
  65253. * Creates a ground mesh from a height map
  65254. * * The parameter `url` sets the URL of the height map image resource.
  65255. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65256. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65257. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65258. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65259. * * 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.
  65260. * * 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).
  65261. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65263. * @param name defines the name of the mesh
  65264. * @param url defines the url to the height map
  65265. * @param options defines the options used to create the mesh
  65266. * @param scene defines the hosting scene
  65267. * @returns the ground mesh
  65268. * @see https://doc.babylonjs.com/babylon101/height_map
  65269. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65270. */
  65271. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65272. width?: number;
  65273. height?: number;
  65274. subdivisions?: number;
  65275. minHeight?: number;
  65276. maxHeight?: number;
  65277. colorFilter?: Color3;
  65278. alphaFilter?: number;
  65279. updatable?: boolean;
  65280. onReady?: (mesh: GroundMesh) => void;
  65281. }, scene?: Nullable<Scene>): GroundMesh;
  65282. /**
  65283. * Creates a polygon mesh
  65284. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65285. * * 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
  65286. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65288. * * 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)
  65289. * * Remember you can only change the shape positions, not their number when updating a polygon
  65290. * @param name defines the name of the mesh
  65291. * @param options defines the options used to create the mesh
  65292. * @param scene defines the hosting scene
  65293. * @param earcutInjection can be used to inject your own earcut reference
  65294. * @returns the polygon mesh
  65295. */
  65296. static CreatePolygon(name: string, options: {
  65297. shape: Vector3[];
  65298. holes?: Vector3[][];
  65299. depth?: number;
  65300. faceUV?: Vector4[];
  65301. faceColors?: Color4[];
  65302. updatable?: boolean;
  65303. sideOrientation?: number;
  65304. frontUVs?: Vector4;
  65305. backUVs?: Vector4;
  65306. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65307. /**
  65308. * Creates an extruded polygon mesh, with depth in the Y direction.
  65309. * * 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)
  65310. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65311. * @param name defines the name of the mesh
  65312. * @param options defines the options used to create the mesh
  65313. * @param scene defines the hosting scene
  65314. * @param earcutInjection can be used to inject your own earcut reference
  65315. * @returns the polygon mesh
  65316. */
  65317. static ExtrudePolygon(name: string, options: {
  65318. shape: Vector3[];
  65319. holes?: Vector3[][];
  65320. depth?: number;
  65321. faceUV?: Vector4[];
  65322. faceColors?: Color4[];
  65323. updatable?: boolean;
  65324. sideOrientation?: number;
  65325. frontUVs?: Vector4;
  65326. backUVs?: Vector4;
  65327. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65328. /**
  65329. * Creates a tube mesh.
  65330. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65331. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65332. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65333. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65334. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65335. * * 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)
  65336. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65337. * * 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
  65338. * * 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
  65339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65340. * * 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
  65341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65343. * @param name defines the name of the mesh
  65344. * @param options defines the options used to create the mesh
  65345. * @param scene defines the hosting scene
  65346. * @returns the tube mesh
  65347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65348. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65349. */
  65350. static CreateTube(name: string, options: {
  65351. path: Vector3[];
  65352. radius?: number;
  65353. tessellation?: number;
  65354. radiusFunction?: {
  65355. (i: number, distance: number): number;
  65356. };
  65357. cap?: number;
  65358. arc?: number;
  65359. updatable?: boolean;
  65360. sideOrientation?: number;
  65361. frontUVs?: Vector4;
  65362. backUVs?: Vector4;
  65363. instance?: Mesh;
  65364. invertUV?: boolean;
  65365. }, scene?: Nullable<Scene>): Mesh;
  65366. /**
  65367. * Creates a polyhedron mesh
  65368. * * 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
  65369. * * The parameter `size` (positive float, default 1) sets the polygon size
  65370. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65371. * * 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`
  65372. * * 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
  65373. * * 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)`)
  65374. * * 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
  65375. * * 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
  65376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65377. * * 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
  65378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65379. * @param name defines the name of the mesh
  65380. * @param options defines the options used to create the mesh
  65381. * @param scene defines the hosting scene
  65382. * @returns the polyhedron mesh
  65383. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65384. */
  65385. static CreatePolyhedron(name: string, options: {
  65386. type?: number;
  65387. size?: number;
  65388. sizeX?: number;
  65389. sizeY?: number;
  65390. sizeZ?: number;
  65391. custom?: any;
  65392. faceUV?: Vector4[];
  65393. faceColors?: Color4[];
  65394. flat?: boolean;
  65395. updatable?: boolean;
  65396. sideOrientation?: number;
  65397. frontUVs?: Vector4;
  65398. backUVs?: Vector4;
  65399. }, scene?: Nullable<Scene>): Mesh;
  65400. /**
  65401. * Creates a decal mesh.
  65402. * 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
  65403. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65404. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65405. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65406. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65407. * @param name defines the name of the mesh
  65408. * @param sourceMesh defines the mesh where the decal must be applied
  65409. * @param options defines the options used to create the mesh
  65410. * @param scene defines the hosting scene
  65411. * @returns the decal mesh
  65412. * @see https://doc.babylonjs.com/how_to/decals
  65413. */
  65414. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65415. position?: Vector3;
  65416. normal?: Vector3;
  65417. size?: Vector3;
  65418. angle?: number;
  65419. }): Mesh;
  65420. }
  65421. }
  65422. declare module BABYLON {
  65423. /**
  65424. * A simplifier interface for future simplification implementations
  65425. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65426. */
  65427. export interface ISimplifier {
  65428. /**
  65429. * Simplification of a given mesh according to the given settings.
  65430. * Since this requires computation, it is assumed that the function runs async.
  65431. * @param settings The settings of the simplification, including quality and distance
  65432. * @param successCallback A callback that will be called after the mesh was simplified.
  65433. * @param errorCallback in case of an error, this callback will be called. optional.
  65434. */
  65435. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65436. }
  65437. /**
  65438. * Expected simplification settings.
  65439. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65440. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65441. */
  65442. export interface ISimplificationSettings {
  65443. /**
  65444. * Gets or sets the expected quality
  65445. */
  65446. quality: number;
  65447. /**
  65448. * Gets or sets the distance when this optimized version should be used
  65449. */
  65450. distance: number;
  65451. /**
  65452. * Gets an already optimized mesh
  65453. */
  65454. optimizeMesh?: boolean;
  65455. }
  65456. /**
  65457. * Class used to specify simplification options
  65458. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65459. */
  65460. export class SimplificationSettings implements ISimplificationSettings {
  65461. /** expected quality */
  65462. quality: number;
  65463. /** distance when this optimized version should be used */
  65464. distance: number;
  65465. /** already optimized mesh */
  65466. optimizeMesh?: boolean | undefined;
  65467. /**
  65468. * Creates a SimplificationSettings
  65469. * @param quality expected quality
  65470. * @param distance distance when this optimized version should be used
  65471. * @param optimizeMesh already optimized mesh
  65472. */
  65473. constructor(
  65474. /** expected quality */
  65475. quality: number,
  65476. /** distance when this optimized version should be used */
  65477. distance: number,
  65478. /** already optimized mesh */
  65479. optimizeMesh?: boolean | undefined);
  65480. }
  65481. /**
  65482. * Interface used to define a simplification task
  65483. */
  65484. export interface ISimplificationTask {
  65485. /**
  65486. * Array of settings
  65487. */
  65488. settings: Array<ISimplificationSettings>;
  65489. /**
  65490. * Simplification type
  65491. */
  65492. simplificationType: SimplificationType;
  65493. /**
  65494. * Mesh to simplify
  65495. */
  65496. mesh: Mesh;
  65497. /**
  65498. * Callback called on success
  65499. */
  65500. successCallback?: () => void;
  65501. /**
  65502. * Defines if parallel processing can be used
  65503. */
  65504. parallelProcessing: boolean;
  65505. }
  65506. /**
  65507. * Queue used to order the simplification tasks
  65508. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65509. */
  65510. export class SimplificationQueue {
  65511. private _simplificationArray;
  65512. /**
  65513. * Gets a boolean indicating that the process is still running
  65514. */
  65515. running: boolean;
  65516. /**
  65517. * Creates a new queue
  65518. */
  65519. constructor();
  65520. /**
  65521. * Adds a new simplification task
  65522. * @param task defines a task to add
  65523. */
  65524. addTask(task: ISimplificationTask): void;
  65525. /**
  65526. * Execute next task
  65527. */
  65528. executeNext(): void;
  65529. /**
  65530. * Execute a simplification task
  65531. * @param task defines the task to run
  65532. */
  65533. runSimplification(task: ISimplificationTask): void;
  65534. private getSimplifier;
  65535. }
  65536. /**
  65537. * The implemented types of simplification
  65538. * At the moment only Quadratic Error Decimation is implemented
  65539. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65540. */
  65541. export enum SimplificationType {
  65542. /** Quadratic error decimation */
  65543. QUADRATIC = 0
  65544. }
  65545. /**
  65546. * An implementation of the Quadratic Error simplification algorithm.
  65547. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65548. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65549. * @author RaananW
  65550. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65551. */
  65552. export class QuadraticErrorSimplification implements ISimplifier {
  65553. private _mesh;
  65554. private triangles;
  65555. private vertices;
  65556. private references;
  65557. private _reconstructedMesh;
  65558. /** Gets or sets the number pf sync interations */
  65559. syncIterations: number;
  65560. /** Gets or sets the aggressiveness of the simplifier */
  65561. aggressiveness: number;
  65562. /** Gets or sets the number of allowed iterations for decimation */
  65563. decimationIterations: number;
  65564. /** Gets or sets the espilon to use for bounding box computation */
  65565. boundingBoxEpsilon: number;
  65566. /**
  65567. * Creates a new QuadraticErrorSimplification
  65568. * @param _mesh defines the target mesh
  65569. */
  65570. constructor(_mesh: Mesh);
  65571. /**
  65572. * Simplification of a given mesh according to the given settings.
  65573. * Since this requires computation, it is assumed that the function runs async.
  65574. * @param settings The settings of the simplification, including quality and distance
  65575. * @param successCallback A callback that will be called after the mesh was simplified.
  65576. */
  65577. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65578. private runDecimation;
  65579. private initWithMesh;
  65580. private init;
  65581. private reconstructMesh;
  65582. private initDecimatedMesh;
  65583. private isFlipped;
  65584. private updateTriangles;
  65585. private identifyBorder;
  65586. private updateMesh;
  65587. private vertexError;
  65588. private calculateError;
  65589. }
  65590. }
  65591. declare module BABYLON {
  65592. interface Scene {
  65593. /** @hidden (Backing field) */
  65594. _simplificationQueue: SimplificationQueue;
  65595. /**
  65596. * Gets or sets the simplification queue attached to the scene
  65597. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65598. */
  65599. simplificationQueue: SimplificationQueue;
  65600. }
  65601. interface Mesh {
  65602. /**
  65603. * Simplify the mesh according to the given array of settings.
  65604. * Function will return immediately and will simplify async
  65605. * @param settings a collection of simplification settings
  65606. * @param parallelProcessing should all levels calculate parallel or one after the other
  65607. * @param simplificationType the type of simplification to run
  65608. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65609. * @returns the current mesh
  65610. */
  65611. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65612. }
  65613. /**
  65614. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65615. * created in a scene
  65616. */
  65617. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65618. /**
  65619. * The component name helpfull to identify the component in the list of scene components.
  65620. */
  65621. readonly name: string;
  65622. /**
  65623. * The scene the component belongs to.
  65624. */
  65625. scene: Scene;
  65626. /**
  65627. * Creates a new instance of the component for the given scene
  65628. * @param scene Defines the scene to register the component in
  65629. */
  65630. constructor(scene: Scene);
  65631. /**
  65632. * Registers the component in a given scene
  65633. */
  65634. register(): void;
  65635. /**
  65636. * Rebuilds the elements related to this component in case of
  65637. * context lost for instance.
  65638. */
  65639. rebuild(): void;
  65640. /**
  65641. * Disposes the component and the associated ressources
  65642. */
  65643. dispose(): void;
  65644. private _beforeCameraUpdate;
  65645. }
  65646. }
  65647. declare module BABYLON {
  65648. interface Mesh {
  65649. /**
  65650. * Creates a new thin instance
  65651. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65652. * @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
  65653. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65654. */
  65655. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65656. /**
  65657. * Adds the transformation (matrix) of the current mesh as a thin instance
  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
  65660. */
  65661. thinInstanceAddSelf(refresh: boolean): number;
  65662. /**
  65663. * Registers a custom attribute to be used with thin instances
  65664. * @param kind name of the attribute
  65665. * @param stride size in floats of the attribute
  65666. */
  65667. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65668. /**
  65669. * Sets the matrix of a thin instance
  65670. * @param index index of the thin instance
  65671. * @param matrix matrix to set
  65672. * @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
  65673. */
  65674. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65675. /**
  65676. * Sets the value of a custom attribute for a thin instance
  65677. * @param kind name of the attribute
  65678. * @param index index of the thin instance
  65679. * @param value value to set
  65680. * @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
  65681. */
  65682. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65683. /**
  65684. * 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.
  65685. */
  65686. thinInstanceCount: number;
  65687. /**
  65688. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65689. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65690. * @param buffer buffer to set
  65691. * @param stride size in floats of each value of the buffer
  65692. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65693. */
  65694. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65695. /**
  65696. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65697. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65698. */
  65699. thinInstanceBufferUpdated(kind: string): void;
  65700. /**
  65701. * Refreshes the bounding info, taking into account all the thin instances defined
  65702. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65703. */
  65704. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65705. /** @hidden */
  65706. _thinInstanceInitializeUserStorage(): void;
  65707. /** @hidden */
  65708. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65709. /** @hidden */
  65710. _userThinInstanceBuffersStorage: {
  65711. data: {
  65712. [key: string]: Float32Array;
  65713. };
  65714. sizes: {
  65715. [key: string]: number;
  65716. };
  65717. vertexBuffers: {
  65718. [key: string]: Nullable<VertexBuffer>;
  65719. };
  65720. strides: {
  65721. [key: string]: number;
  65722. };
  65723. };
  65724. }
  65725. }
  65726. declare module BABYLON {
  65727. /**
  65728. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65729. */
  65730. export interface INavigationEnginePlugin {
  65731. /**
  65732. * plugin name
  65733. */
  65734. name: string;
  65735. /**
  65736. * Creates a navigation mesh
  65737. * @param meshes array of all the geometry used to compute the navigatio mesh
  65738. * @param parameters bunch of parameters used to filter geometry
  65739. */
  65740. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65741. /**
  65742. * Create a navigation mesh debug mesh
  65743. * @param scene is where the mesh will be added
  65744. * @returns debug display mesh
  65745. */
  65746. createDebugNavMesh(scene: Scene): Mesh;
  65747. /**
  65748. * Get a navigation mesh constrained position, closest to the parameter position
  65749. * @param position world position
  65750. * @returns the closest point to position constrained by the navigation mesh
  65751. */
  65752. getClosestPoint(position: Vector3): Vector3;
  65753. /**
  65754. * Get a navigation mesh constrained position, closest to the parameter position
  65755. * @param position world position
  65756. * @param result output the closest point to position constrained by the navigation mesh
  65757. */
  65758. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65759. /**
  65760. * Get a navigation mesh constrained position, within a particular radius
  65761. * @param position world position
  65762. * @param maxRadius the maximum distance to the constrained world position
  65763. * @returns the closest point to position constrained by the navigation mesh
  65764. */
  65765. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65766. /**
  65767. * Get a navigation mesh constrained position, within a particular radius
  65768. * @param position world position
  65769. * @param maxRadius the maximum distance to the constrained world position
  65770. * @param result output the closest point to position constrained by the navigation mesh
  65771. */
  65772. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65773. /**
  65774. * Compute the final position from a segment made of destination-position
  65775. * @param position world position
  65776. * @param destination world position
  65777. * @returns the resulting point along the navmesh
  65778. */
  65779. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65780. /**
  65781. * Compute the final position from a segment made of destination-position
  65782. * @param position world position
  65783. * @param destination world position
  65784. * @param result output the resulting point along the navmesh
  65785. */
  65786. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65787. /**
  65788. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65789. * @param start world position
  65790. * @param end world position
  65791. * @returns array containing world position composing the path
  65792. */
  65793. computePath(start: Vector3, end: Vector3): Vector3[];
  65794. /**
  65795. * If this plugin is supported
  65796. * @returns true if plugin is supported
  65797. */
  65798. isSupported(): boolean;
  65799. /**
  65800. * Create a new Crowd so you can add agents
  65801. * @param maxAgents the maximum agent count in the crowd
  65802. * @param maxAgentRadius the maximum radius an agent can have
  65803. * @param scene to attach the crowd to
  65804. * @returns the crowd you can add agents to
  65805. */
  65806. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65807. /**
  65808. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65809. * The queries will try to find a solution within those bounds
  65810. * default is (1,1,1)
  65811. * @param extent x,y,z value that define the extent around the queries point of reference
  65812. */
  65813. setDefaultQueryExtent(extent: Vector3): void;
  65814. /**
  65815. * Get the Bounding box extent specified by setDefaultQueryExtent
  65816. * @returns the box extent values
  65817. */
  65818. getDefaultQueryExtent(): Vector3;
  65819. /**
  65820. * build the navmesh from a previously saved state using getNavmeshData
  65821. * @param data the Uint8Array returned by getNavmeshData
  65822. */
  65823. buildFromNavmeshData(data: Uint8Array): void;
  65824. /**
  65825. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65826. * @returns data the Uint8Array that can be saved and reused
  65827. */
  65828. getNavmeshData(): Uint8Array;
  65829. /**
  65830. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65831. * @param result output the box extent values
  65832. */
  65833. getDefaultQueryExtentToRef(result: Vector3): void;
  65834. /**
  65835. * Release all resources
  65836. */
  65837. dispose(): void;
  65838. }
  65839. /**
  65840. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65841. */
  65842. export interface ICrowd {
  65843. /**
  65844. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65845. * You can attach anything to that node. The node position is updated in the scene update tick.
  65846. * @param pos world position that will be constrained by the navigation mesh
  65847. * @param parameters agent parameters
  65848. * @param transform hooked to the agent that will be update by the scene
  65849. * @returns agent index
  65850. */
  65851. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65852. /**
  65853. * Returns the agent position in world space
  65854. * @param index agent index returned by addAgent
  65855. * @returns world space position
  65856. */
  65857. getAgentPosition(index: number): Vector3;
  65858. /**
  65859. * Gets the agent position result in world space
  65860. * @param index agent index returned by addAgent
  65861. * @param result output world space position
  65862. */
  65863. getAgentPositionToRef(index: number, result: Vector3): void;
  65864. /**
  65865. * Gets the agent velocity in world space
  65866. * @param index agent index returned by addAgent
  65867. * @returns world space velocity
  65868. */
  65869. getAgentVelocity(index: number): Vector3;
  65870. /**
  65871. * Gets the agent velocity result in world space
  65872. * @param index agent index returned by addAgent
  65873. * @param result output world space velocity
  65874. */
  65875. getAgentVelocityToRef(index: number, result: Vector3): void;
  65876. /**
  65877. * remove a particular agent previously created
  65878. * @param index agent index returned by addAgent
  65879. */
  65880. removeAgent(index: number): void;
  65881. /**
  65882. * get the list of all agents attached to this crowd
  65883. * @returns list of agent indices
  65884. */
  65885. getAgents(): number[];
  65886. /**
  65887. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65888. * @param deltaTime in seconds
  65889. */
  65890. update(deltaTime: number): void;
  65891. /**
  65892. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65893. * @param index agent index returned by addAgent
  65894. * @param destination targeted world position
  65895. */
  65896. agentGoto(index: number, destination: Vector3): void;
  65897. /**
  65898. * Teleport the agent to a new position
  65899. * @param index agent index returned by addAgent
  65900. * @param destination targeted world position
  65901. */
  65902. agentTeleport(index: number, destination: Vector3): void;
  65903. /**
  65904. * Update agent parameters
  65905. * @param index agent index returned by addAgent
  65906. * @param parameters agent parameters
  65907. */
  65908. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65909. /**
  65910. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65911. * The queries will try to find a solution within those bounds
  65912. * default is (1,1,1)
  65913. * @param extent x,y,z value that define the extent around the queries point of reference
  65914. */
  65915. setDefaultQueryExtent(extent: Vector3): void;
  65916. /**
  65917. * Get the Bounding box extent specified by setDefaultQueryExtent
  65918. * @returns the box extent values
  65919. */
  65920. getDefaultQueryExtent(): Vector3;
  65921. /**
  65922. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65923. * @param result output the box extent values
  65924. */
  65925. getDefaultQueryExtentToRef(result: Vector3): void;
  65926. /**
  65927. * Release all resources
  65928. */
  65929. dispose(): void;
  65930. }
  65931. /**
  65932. * Configures an agent
  65933. */
  65934. export interface IAgentParameters {
  65935. /**
  65936. * Agent radius. [Limit: >= 0]
  65937. */
  65938. radius: number;
  65939. /**
  65940. * Agent height. [Limit: > 0]
  65941. */
  65942. height: number;
  65943. /**
  65944. * Maximum allowed acceleration. [Limit: >= 0]
  65945. */
  65946. maxAcceleration: number;
  65947. /**
  65948. * Maximum allowed speed. [Limit: >= 0]
  65949. */
  65950. maxSpeed: number;
  65951. /**
  65952. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65953. */
  65954. collisionQueryRange: number;
  65955. /**
  65956. * The path visibility optimization range. [Limit: > 0]
  65957. */
  65958. pathOptimizationRange: number;
  65959. /**
  65960. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65961. */
  65962. separationWeight: number;
  65963. }
  65964. /**
  65965. * Configures the navigation mesh creation
  65966. */
  65967. export interface INavMeshParameters {
  65968. /**
  65969. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65970. */
  65971. cs: number;
  65972. /**
  65973. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65974. */
  65975. ch: number;
  65976. /**
  65977. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65978. */
  65979. walkableSlopeAngle: number;
  65980. /**
  65981. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65982. * be considered walkable. [Limit: >= 3] [Units: vx]
  65983. */
  65984. walkableHeight: number;
  65985. /**
  65986. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65987. */
  65988. walkableClimb: number;
  65989. /**
  65990. * The distance to erode/shrink the walkable area of the heightfield away from
  65991. * obstructions. [Limit: >=0] [Units: vx]
  65992. */
  65993. walkableRadius: number;
  65994. /**
  65995. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65996. */
  65997. maxEdgeLen: number;
  65998. /**
  65999. * The maximum distance a simplfied contour's border edges should deviate
  66000. * the original raw contour. [Limit: >=0] [Units: vx]
  66001. */
  66002. maxSimplificationError: number;
  66003. /**
  66004. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66005. */
  66006. minRegionArea: number;
  66007. /**
  66008. * Any regions with a span count smaller than this value will, if possible,
  66009. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66010. */
  66011. mergeRegionArea: number;
  66012. /**
  66013. * The maximum number of vertices allowed for polygons generated during the
  66014. * contour to polygon conversion process. [Limit: >= 3]
  66015. */
  66016. maxVertsPerPoly: number;
  66017. /**
  66018. * Sets the sampling distance to use when generating the detail mesh.
  66019. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66020. */
  66021. detailSampleDist: number;
  66022. /**
  66023. * The maximum distance the detail mesh surface should deviate from heightfield
  66024. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66025. */
  66026. detailSampleMaxError: number;
  66027. }
  66028. }
  66029. declare module BABYLON {
  66030. /**
  66031. * RecastJS navigation plugin
  66032. */
  66033. export class RecastJSPlugin implements INavigationEnginePlugin {
  66034. /**
  66035. * Reference to the Recast library
  66036. */
  66037. bjsRECAST: any;
  66038. /**
  66039. * plugin name
  66040. */
  66041. name: string;
  66042. /**
  66043. * the first navmesh created. We might extend this to support multiple navmeshes
  66044. */
  66045. navMesh: any;
  66046. /**
  66047. * Initializes the recastJS plugin
  66048. * @param recastInjection can be used to inject your own recast reference
  66049. */
  66050. constructor(recastInjection?: any);
  66051. /**
  66052. * Creates a navigation mesh
  66053. * @param meshes array of all the geometry used to compute the navigatio mesh
  66054. * @param parameters bunch of parameters used to filter geometry
  66055. */
  66056. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66057. /**
  66058. * Create a navigation mesh debug mesh
  66059. * @param scene is where the mesh will be added
  66060. * @returns debug display mesh
  66061. */
  66062. createDebugNavMesh(scene: Scene): Mesh;
  66063. /**
  66064. * Get a navigation mesh constrained position, closest to the parameter position
  66065. * @param position world position
  66066. * @returns the closest point to position constrained by the navigation mesh
  66067. */
  66068. getClosestPoint(position: Vector3): Vector3;
  66069. /**
  66070. * Get a navigation mesh constrained position, closest to the parameter position
  66071. * @param position world position
  66072. * @param result output the closest point to position constrained by the navigation mesh
  66073. */
  66074. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66075. /**
  66076. * Get a navigation mesh constrained position, within a particular radius
  66077. * @param position world position
  66078. * @param maxRadius the maximum distance to the constrained world position
  66079. * @returns the closest point to position constrained by the navigation mesh
  66080. */
  66081. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66082. /**
  66083. * Get a navigation mesh constrained position, within a particular radius
  66084. * @param position world position
  66085. * @param maxRadius the maximum distance to the constrained world position
  66086. * @param result output the closest point to position constrained by the navigation mesh
  66087. */
  66088. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66089. /**
  66090. * Compute the final position from a segment made of destination-position
  66091. * @param position world position
  66092. * @param destination world position
  66093. * @returns the resulting point along the navmesh
  66094. */
  66095. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66096. /**
  66097. * Compute the final position from a segment made of destination-position
  66098. * @param position world position
  66099. * @param destination world position
  66100. * @param result output the resulting point along the navmesh
  66101. */
  66102. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66103. /**
  66104. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66105. * @param start world position
  66106. * @param end world position
  66107. * @returns array containing world position composing the path
  66108. */
  66109. computePath(start: Vector3, end: Vector3): Vector3[];
  66110. /**
  66111. * Create a new Crowd so you can add agents
  66112. * @param maxAgents the maximum agent count in the crowd
  66113. * @param maxAgentRadius the maximum radius an agent can have
  66114. * @param scene to attach the crowd to
  66115. * @returns the crowd you can add agents to
  66116. */
  66117. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66118. /**
  66119. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66120. * The queries will try to find a solution within those bounds
  66121. * default is (1,1,1)
  66122. * @param extent x,y,z value that define the extent around the queries point of reference
  66123. */
  66124. setDefaultQueryExtent(extent: Vector3): void;
  66125. /**
  66126. * Get the Bounding box extent specified by setDefaultQueryExtent
  66127. * @returns the box extent values
  66128. */
  66129. getDefaultQueryExtent(): Vector3;
  66130. /**
  66131. * build the navmesh from a previously saved state using getNavmeshData
  66132. * @param data the Uint8Array returned by getNavmeshData
  66133. */
  66134. buildFromNavmeshData(data: Uint8Array): void;
  66135. /**
  66136. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66137. * @returns data the Uint8Array that can be saved and reused
  66138. */
  66139. getNavmeshData(): Uint8Array;
  66140. /**
  66141. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66142. * @param result output the box extent values
  66143. */
  66144. getDefaultQueryExtentToRef(result: Vector3): void;
  66145. /**
  66146. * Disposes
  66147. */
  66148. dispose(): void;
  66149. /**
  66150. * If this plugin is supported
  66151. * @returns true if plugin is supported
  66152. */
  66153. isSupported(): boolean;
  66154. }
  66155. /**
  66156. * Recast detour crowd implementation
  66157. */
  66158. export class RecastJSCrowd implements ICrowd {
  66159. /**
  66160. * Recast/detour plugin
  66161. */
  66162. bjsRECASTPlugin: RecastJSPlugin;
  66163. /**
  66164. * Link to the detour crowd
  66165. */
  66166. recastCrowd: any;
  66167. /**
  66168. * One transform per agent
  66169. */
  66170. transforms: TransformNode[];
  66171. /**
  66172. * All agents created
  66173. */
  66174. agents: number[];
  66175. /**
  66176. * Link to the scene is kept to unregister the crowd from the scene
  66177. */
  66178. private _scene;
  66179. /**
  66180. * Observer for crowd updates
  66181. */
  66182. private _onBeforeAnimationsObserver;
  66183. /**
  66184. * Constructor
  66185. * @param plugin recastJS plugin
  66186. * @param maxAgents the maximum agent count in the crowd
  66187. * @param maxAgentRadius the maximum radius an agent can have
  66188. * @param scene to attach the crowd to
  66189. * @returns the crowd you can add agents to
  66190. */
  66191. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66192. /**
  66193. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66194. * You can attach anything to that node. The node position is updated in the scene update tick.
  66195. * @param pos world position that will be constrained by the navigation mesh
  66196. * @param parameters agent parameters
  66197. * @param transform hooked to the agent that will be update by the scene
  66198. * @returns agent index
  66199. */
  66200. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66201. /**
  66202. * Returns the agent position in world space
  66203. * @param index agent index returned by addAgent
  66204. * @returns world space position
  66205. */
  66206. getAgentPosition(index: number): Vector3;
  66207. /**
  66208. * Returns the agent position result in world space
  66209. * @param index agent index returned by addAgent
  66210. * @param result output world space position
  66211. */
  66212. getAgentPositionToRef(index: number, result: Vector3): void;
  66213. /**
  66214. * Returns the agent velocity in world space
  66215. * @param index agent index returned by addAgent
  66216. * @returns world space velocity
  66217. */
  66218. getAgentVelocity(index: number): Vector3;
  66219. /**
  66220. * Returns the agent velocity result in world space
  66221. * @param index agent index returned by addAgent
  66222. * @param result output world space velocity
  66223. */
  66224. getAgentVelocityToRef(index: number, result: Vector3): void;
  66225. /**
  66226. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66227. * @param index agent index returned by addAgent
  66228. * @param destination targeted world position
  66229. */
  66230. agentGoto(index: number, destination: Vector3): void;
  66231. /**
  66232. * Teleport the agent to a new position
  66233. * @param index agent index returned by addAgent
  66234. * @param destination targeted world position
  66235. */
  66236. agentTeleport(index: number, destination: Vector3): void;
  66237. /**
  66238. * Update agent parameters
  66239. * @param index agent index returned by addAgent
  66240. * @param parameters agent parameters
  66241. */
  66242. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66243. /**
  66244. * remove a particular agent previously created
  66245. * @param index agent index returned by addAgent
  66246. */
  66247. removeAgent(index: number): void;
  66248. /**
  66249. * get the list of all agents attached to this crowd
  66250. * @returns list of agent indices
  66251. */
  66252. getAgents(): number[];
  66253. /**
  66254. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66255. * @param deltaTime in seconds
  66256. */
  66257. update(deltaTime: number): void;
  66258. /**
  66259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66260. * The queries will try to find a solution within those bounds
  66261. * default is (1,1,1)
  66262. * @param extent x,y,z value that define the extent around the queries point of reference
  66263. */
  66264. setDefaultQueryExtent(extent: Vector3): void;
  66265. /**
  66266. * Get the Bounding box extent specified by setDefaultQueryExtent
  66267. * @returns the box extent values
  66268. */
  66269. getDefaultQueryExtent(): Vector3;
  66270. /**
  66271. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66272. * @param result output the box extent values
  66273. */
  66274. getDefaultQueryExtentToRef(result: Vector3): void;
  66275. /**
  66276. * Release all resources
  66277. */
  66278. dispose(): void;
  66279. }
  66280. }
  66281. declare module BABYLON {
  66282. /**
  66283. * Class used to enable access to IndexedDB
  66284. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66285. */
  66286. export class Database implements IOfflineProvider {
  66287. private _callbackManifestChecked;
  66288. private _currentSceneUrl;
  66289. private _db;
  66290. private _enableSceneOffline;
  66291. private _enableTexturesOffline;
  66292. private _manifestVersionFound;
  66293. private _mustUpdateRessources;
  66294. private _hasReachedQuota;
  66295. private _isSupported;
  66296. private _idbFactory;
  66297. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66298. private static IsUASupportingBlobStorage;
  66299. /**
  66300. * Gets a boolean indicating if Database storate is enabled (off by default)
  66301. */
  66302. static IDBStorageEnabled: boolean;
  66303. /**
  66304. * Gets a boolean indicating if scene must be saved in the database
  66305. */
  66306. get enableSceneOffline(): boolean;
  66307. /**
  66308. * Gets a boolean indicating if textures must be saved in the database
  66309. */
  66310. get enableTexturesOffline(): boolean;
  66311. /**
  66312. * Creates a new Database
  66313. * @param urlToScene defines the url to load the scene
  66314. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66315. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66316. */
  66317. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66318. private static _ParseURL;
  66319. private static _ReturnFullUrlLocation;
  66320. private _checkManifestFile;
  66321. /**
  66322. * Open the database and make it available
  66323. * @param successCallback defines the callback to call on success
  66324. * @param errorCallback defines the callback to call on error
  66325. */
  66326. open(successCallback: () => void, errorCallback: () => void): void;
  66327. /**
  66328. * Loads an image from the database
  66329. * @param url defines the url to load from
  66330. * @param image defines the target DOM image
  66331. */
  66332. loadImage(url: string, image: HTMLImageElement): void;
  66333. private _loadImageFromDBAsync;
  66334. private _saveImageIntoDBAsync;
  66335. private _checkVersionFromDB;
  66336. private _loadVersionFromDBAsync;
  66337. private _saveVersionIntoDBAsync;
  66338. /**
  66339. * Loads a file from database
  66340. * @param url defines the URL to load from
  66341. * @param sceneLoaded defines a callback to call on success
  66342. * @param progressCallBack defines a callback to call when progress changed
  66343. * @param errorCallback defines a callback to call on error
  66344. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66345. */
  66346. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66347. private _loadFileAsync;
  66348. private _saveFileAsync;
  66349. /**
  66350. * Validates if xhr data is correct
  66351. * @param xhr defines the request to validate
  66352. * @param dataType defines the expected data type
  66353. * @returns true if data is correct
  66354. */
  66355. private static _ValidateXHRData;
  66356. }
  66357. }
  66358. declare module BABYLON {
  66359. /** @hidden */
  66360. export var gpuUpdateParticlesPixelShader: {
  66361. name: string;
  66362. shader: string;
  66363. };
  66364. }
  66365. declare module BABYLON {
  66366. /** @hidden */
  66367. export var gpuUpdateParticlesVertexShader: {
  66368. name: string;
  66369. shader: string;
  66370. };
  66371. }
  66372. declare module BABYLON {
  66373. /** @hidden */
  66374. export var clipPlaneFragmentDeclaration2: {
  66375. name: string;
  66376. shader: string;
  66377. };
  66378. }
  66379. declare module BABYLON {
  66380. /** @hidden */
  66381. export var gpuRenderParticlesPixelShader: {
  66382. name: string;
  66383. shader: string;
  66384. };
  66385. }
  66386. declare module BABYLON {
  66387. /** @hidden */
  66388. export var clipPlaneVertexDeclaration2: {
  66389. name: string;
  66390. shader: string;
  66391. };
  66392. }
  66393. declare module BABYLON {
  66394. /** @hidden */
  66395. export var gpuRenderParticlesVertexShader: {
  66396. name: string;
  66397. shader: string;
  66398. };
  66399. }
  66400. declare module BABYLON {
  66401. /**
  66402. * This represents a GPU particle system in Babylon
  66403. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66404. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66405. */
  66406. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66407. /**
  66408. * The layer mask we are rendering the particles through.
  66409. */
  66410. layerMask: number;
  66411. private _capacity;
  66412. private _activeCount;
  66413. private _currentActiveCount;
  66414. private _accumulatedCount;
  66415. private _renderEffect;
  66416. private _updateEffect;
  66417. private _buffer0;
  66418. private _buffer1;
  66419. private _spriteBuffer;
  66420. private _updateVAO;
  66421. private _renderVAO;
  66422. private _targetIndex;
  66423. private _sourceBuffer;
  66424. private _targetBuffer;
  66425. private _engine;
  66426. private _currentRenderId;
  66427. private _started;
  66428. private _stopped;
  66429. private _timeDelta;
  66430. private _randomTexture;
  66431. private _randomTexture2;
  66432. private _attributesStrideSize;
  66433. private _updateEffectOptions;
  66434. private _randomTextureSize;
  66435. private _actualFrame;
  66436. private _customEffect;
  66437. private readonly _rawTextureWidth;
  66438. /**
  66439. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66440. */
  66441. static get IsSupported(): boolean;
  66442. /**
  66443. * An event triggered when the system is disposed.
  66444. */
  66445. onDisposeObservable: Observable<IParticleSystem>;
  66446. /**
  66447. * Gets the maximum number of particles active at the same time.
  66448. * @returns The max number of active particles.
  66449. */
  66450. getCapacity(): number;
  66451. /**
  66452. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66453. * to override the particles.
  66454. */
  66455. forceDepthWrite: boolean;
  66456. /**
  66457. * Gets or set the number of active particles
  66458. */
  66459. get activeParticleCount(): number;
  66460. set activeParticleCount(value: number);
  66461. private _preWarmDone;
  66462. /**
  66463. * Specifies if the particles are updated in emitter local space or world space.
  66464. */
  66465. isLocal: boolean;
  66466. /**
  66467. * Is this system ready to be used/rendered
  66468. * @return true if the system is ready
  66469. */
  66470. isReady(): boolean;
  66471. /**
  66472. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66473. * @returns True if it has been started, otherwise false.
  66474. */
  66475. isStarted(): boolean;
  66476. /**
  66477. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66478. * @returns True if it has been stopped, otherwise false.
  66479. */
  66480. isStopped(): boolean;
  66481. /**
  66482. * Gets a boolean indicating that the system is stopping
  66483. * @returns true if the system is currently stopping
  66484. */
  66485. isStopping(): boolean;
  66486. /**
  66487. * Gets the number of particles active at the same time.
  66488. * @returns The number of active particles.
  66489. */
  66490. getActiveCount(): number;
  66491. /**
  66492. * Starts the particle system and begins to emit
  66493. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66494. */
  66495. start(delay?: number): void;
  66496. /**
  66497. * Stops the particle system.
  66498. */
  66499. stop(): void;
  66500. /**
  66501. * Remove all active particles
  66502. */
  66503. reset(): void;
  66504. /**
  66505. * Returns the string "GPUParticleSystem"
  66506. * @returns a string containing the class name
  66507. */
  66508. getClassName(): string;
  66509. /**
  66510. * Gets the custom effect used to render the particles
  66511. * @param blendMode Blend mode for which the effect should be retrieved
  66512. * @returns The effect
  66513. */
  66514. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66515. /**
  66516. * Sets the custom effect used to render the particles
  66517. * @param effect The effect to set
  66518. * @param blendMode Blend mode for which the effect should be set
  66519. */
  66520. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66521. /** @hidden */
  66522. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66523. /**
  66524. * Observable that will be called just before the particles are drawn
  66525. */
  66526. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66527. /**
  66528. * Gets the name of the particle vertex shader
  66529. */
  66530. get vertexShaderName(): string;
  66531. private _colorGradientsTexture;
  66532. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66533. /**
  66534. * Adds a new color gradient
  66535. * @param gradient defines the gradient to use (between 0 and 1)
  66536. * @param color1 defines the color to affect to the specified gradient
  66537. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66538. * @returns the current particle system
  66539. */
  66540. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66541. private _refreshColorGradient;
  66542. /** Force the system to rebuild all gradients that need to be resync */
  66543. forceRefreshGradients(): void;
  66544. /**
  66545. * Remove a specific color gradient
  66546. * @param gradient defines the gradient to remove
  66547. * @returns the current particle system
  66548. */
  66549. removeColorGradient(gradient: number): GPUParticleSystem;
  66550. private _angularSpeedGradientsTexture;
  66551. private _sizeGradientsTexture;
  66552. private _velocityGradientsTexture;
  66553. private _limitVelocityGradientsTexture;
  66554. private _dragGradientsTexture;
  66555. private _addFactorGradient;
  66556. /**
  66557. * Adds a new size gradient
  66558. * @param gradient defines the gradient to use (between 0 and 1)
  66559. * @param factor defines the size factor to affect to the specified gradient
  66560. * @returns the current particle system
  66561. */
  66562. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66563. /**
  66564. * Remove a specific size gradient
  66565. * @param gradient defines the gradient to remove
  66566. * @returns the current particle system
  66567. */
  66568. removeSizeGradient(gradient: number): GPUParticleSystem;
  66569. private _refreshFactorGradient;
  66570. /**
  66571. * Adds a new angular speed gradient
  66572. * @param gradient defines the gradient to use (between 0 and 1)
  66573. * @param factor defines the angular speed to affect to the specified gradient
  66574. * @returns the current particle system
  66575. */
  66576. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66577. /**
  66578. * Remove a specific angular speed gradient
  66579. * @param gradient defines the gradient to remove
  66580. * @returns the current particle system
  66581. */
  66582. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66583. /**
  66584. * Adds a new velocity gradient
  66585. * @param gradient defines the gradient to use (between 0 and 1)
  66586. * @param factor defines the velocity to affect to the specified gradient
  66587. * @returns the current particle system
  66588. */
  66589. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66590. /**
  66591. * Remove a specific velocity gradient
  66592. * @param gradient defines the gradient to remove
  66593. * @returns the current particle system
  66594. */
  66595. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66596. /**
  66597. * Adds a new limit velocity gradient
  66598. * @param gradient defines the gradient to use (between 0 and 1)
  66599. * @param factor defines the limit velocity value to affect to the specified gradient
  66600. * @returns the current particle system
  66601. */
  66602. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66603. /**
  66604. * Remove a specific limit velocity gradient
  66605. * @param gradient defines the gradient to remove
  66606. * @returns the current particle system
  66607. */
  66608. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66609. /**
  66610. * Adds a new drag gradient
  66611. * @param gradient defines the gradient to use (between 0 and 1)
  66612. * @param factor defines the drag value to affect to the specified gradient
  66613. * @returns the current particle system
  66614. */
  66615. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66616. /**
  66617. * Remove a specific drag gradient
  66618. * @param gradient defines the gradient to remove
  66619. * @returns the current particle system
  66620. */
  66621. removeDragGradient(gradient: number): GPUParticleSystem;
  66622. /**
  66623. * Not supported by GPUParticleSystem
  66624. * @param gradient defines the gradient to use (between 0 and 1)
  66625. * @param factor defines the emit rate value to affect to the specified gradient
  66626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66627. * @returns the current particle system
  66628. */
  66629. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66630. /**
  66631. * Not supported by GPUParticleSystem
  66632. * @param gradient defines the gradient to remove
  66633. * @returns the current particle system
  66634. */
  66635. removeEmitRateGradient(gradient: number): IParticleSystem;
  66636. /**
  66637. * Not supported by GPUParticleSystem
  66638. * @param gradient defines the gradient to use (between 0 and 1)
  66639. * @param factor defines the start size value to affect to the specified gradient
  66640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66641. * @returns the current particle system
  66642. */
  66643. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66644. /**
  66645. * Not supported by GPUParticleSystem
  66646. * @param gradient defines the gradient to remove
  66647. * @returns the current particle system
  66648. */
  66649. removeStartSizeGradient(gradient: number): IParticleSystem;
  66650. /**
  66651. * Not supported by GPUParticleSystem
  66652. * @param gradient defines the gradient to use (between 0 and 1)
  66653. * @param min defines the color remap minimal range
  66654. * @param max defines the color remap maximal range
  66655. * @returns the current particle system
  66656. */
  66657. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66658. /**
  66659. * Not supported by GPUParticleSystem
  66660. * @param gradient defines the gradient to remove
  66661. * @returns the current particle system
  66662. */
  66663. removeColorRemapGradient(): IParticleSystem;
  66664. /**
  66665. * Not supported by GPUParticleSystem
  66666. * @param gradient defines the gradient to use (between 0 and 1)
  66667. * @param min defines the alpha remap minimal range
  66668. * @param max defines the alpha remap maximal range
  66669. * @returns the current particle system
  66670. */
  66671. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66672. /**
  66673. * Not supported by GPUParticleSystem
  66674. * @param gradient defines the gradient to remove
  66675. * @returns the current particle system
  66676. */
  66677. removeAlphaRemapGradient(): IParticleSystem;
  66678. /**
  66679. * Not supported by GPUParticleSystem
  66680. * @param gradient defines the gradient to use (between 0 and 1)
  66681. * @param color defines the color to affect to the specified gradient
  66682. * @returns the current particle system
  66683. */
  66684. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66685. /**
  66686. * Not supported by GPUParticleSystem
  66687. * @param gradient defines the gradient to remove
  66688. * @returns the current particle system
  66689. */
  66690. removeRampGradient(): IParticleSystem;
  66691. /**
  66692. * Not supported by GPUParticleSystem
  66693. * @returns the list of ramp gradients
  66694. */
  66695. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66696. /**
  66697. * Not supported by GPUParticleSystem
  66698. * Gets or sets a boolean indicating that ramp gradients must be used
  66699. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66700. */
  66701. get useRampGradients(): boolean;
  66702. set useRampGradients(value: boolean);
  66703. /**
  66704. * Not supported by GPUParticleSystem
  66705. * @param gradient defines the gradient to use (between 0 and 1)
  66706. * @param factor defines the life time factor to affect to the specified gradient
  66707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66708. * @returns the current particle system
  66709. */
  66710. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66711. /**
  66712. * Not supported by GPUParticleSystem
  66713. * @param gradient defines the gradient to remove
  66714. * @returns the current particle system
  66715. */
  66716. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66717. /**
  66718. * Instantiates a GPU particle system.
  66719. * 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.
  66720. * @param name The name of the particle system
  66721. * @param options The options used to create the system
  66722. * @param scene The scene the particle system belongs to
  66723. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66724. * @param customEffect a custom effect used to change the way particles are rendered by default
  66725. */
  66726. constructor(name: string, options: Partial<{
  66727. capacity: number;
  66728. randomTextureSize: number;
  66729. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66730. protected _reset(): void;
  66731. private _createUpdateVAO;
  66732. private _createRenderVAO;
  66733. private _initialize;
  66734. /** @hidden */
  66735. _recreateUpdateEffect(): void;
  66736. private _getEffect;
  66737. /**
  66738. * Fill the defines array according to the current settings of the particle system
  66739. * @param defines Array to be updated
  66740. * @param blendMode blend mode to take into account when updating the array
  66741. */
  66742. fillDefines(defines: Array<string>, blendMode?: number): void;
  66743. /**
  66744. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66745. * @param uniforms Uniforms array to fill
  66746. * @param attributes Attributes array to fill
  66747. * @param samplers Samplers array to fill
  66748. */
  66749. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66750. /** @hidden */
  66751. _recreateRenderEffect(): Effect;
  66752. /**
  66753. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66754. * @param preWarm defines if we are in the pre-warmimg phase
  66755. */
  66756. animate(preWarm?: boolean): void;
  66757. private _createFactorGradientTexture;
  66758. private _createSizeGradientTexture;
  66759. private _createAngularSpeedGradientTexture;
  66760. private _createVelocityGradientTexture;
  66761. private _createLimitVelocityGradientTexture;
  66762. private _createDragGradientTexture;
  66763. private _createColorGradientTexture;
  66764. /**
  66765. * Renders the particle system in its current state
  66766. * @param preWarm defines if the system should only update the particles but not render them
  66767. * @returns the current number of particles
  66768. */
  66769. render(preWarm?: boolean): number;
  66770. /**
  66771. * Rebuilds the particle system
  66772. */
  66773. rebuild(): void;
  66774. private _releaseBuffers;
  66775. private _releaseVAOs;
  66776. /**
  66777. * Disposes the particle system and free the associated resources
  66778. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66779. */
  66780. dispose(disposeTexture?: boolean): void;
  66781. /**
  66782. * Clones the particle system.
  66783. * @param name The name of the cloned object
  66784. * @param newEmitter The new emitter to use
  66785. * @returns the cloned particle system
  66786. */
  66787. clone(name: string, newEmitter: any): GPUParticleSystem;
  66788. /**
  66789. * Serializes the particle system to a JSON object
  66790. * @param serializeTexture defines if the texture must be serialized as well
  66791. * @returns the JSON object
  66792. */
  66793. serialize(serializeTexture?: boolean): any;
  66794. /**
  66795. * Parses a JSON object to create a GPU particle system.
  66796. * @param parsedParticleSystem The JSON object to parse
  66797. * @param scene The scene to create the particle system in
  66798. * @param rootUrl The root url to use to load external dependencies like texture
  66799. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66800. * @returns the parsed GPU particle system
  66801. */
  66802. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66803. }
  66804. }
  66805. declare module BABYLON {
  66806. /**
  66807. * Represents a set of particle systems working together to create a specific effect
  66808. */
  66809. export class ParticleSystemSet implements IDisposable {
  66810. /**
  66811. * Gets or sets base Assets URL
  66812. */
  66813. static BaseAssetsUrl: string;
  66814. private _emitterCreationOptions;
  66815. private _emitterNode;
  66816. /**
  66817. * Gets the particle system list
  66818. */
  66819. systems: IParticleSystem[];
  66820. /**
  66821. * Gets the emitter node used with this set
  66822. */
  66823. get emitterNode(): Nullable<TransformNode>;
  66824. /**
  66825. * Creates a new emitter mesh as a sphere
  66826. * @param options defines the options used to create the sphere
  66827. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66828. * @param scene defines the hosting scene
  66829. */
  66830. setEmitterAsSphere(options: {
  66831. diameter: number;
  66832. segments: number;
  66833. color: Color3;
  66834. }, renderingGroupId: number, scene: Scene): void;
  66835. /**
  66836. * Starts all particle systems of the set
  66837. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66838. */
  66839. start(emitter?: AbstractMesh): void;
  66840. /**
  66841. * Release all associated resources
  66842. */
  66843. dispose(): void;
  66844. /**
  66845. * Serialize the set into a JSON compatible object
  66846. * @param serializeTexture defines if the texture must be serialized as well
  66847. * @returns a JSON compatible representation of the set
  66848. */
  66849. serialize(serializeTexture?: boolean): any;
  66850. /**
  66851. * Parse a new ParticleSystemSet from a serialized source
  66852. * @param data defines a JSON compatible representation of the set
  66853. * @param scene defines the hosting scene
  66854. * @param gpu defines if we want GPU particles or CPU particles
  66855. * @returns a new ParticleSystemSet
  66856. */
  66857. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66858. }
  66859. }
  66860. declare module BABYLON {
  66861. /**
  66862. * This class is made for on one-liner static method to help creating particle system set.
  66863. */
  66864. export class ParticleHelper {
  66865. /**
  66866. * Gets or sets base Assets URL
  66867. */
  66868. static BaseAssetsUrl: string;
  66869. /** Define the Url to load snippets */
  66870. static SnippetUrl: string;
  66871. /**
  66872. * Create a default particle system that you can tweak
  66873. * @param emitter defines the emitter to use
  66874. * @param capacity defines the system capacity (default is 500 particles)
  66875. * @param scene defines the hosting scene
  66876. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66877. * @returns the new Particle system
  66878. */
  66879. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66880. /**
  66881. * This is the main static method (one-liner) of this helper to create different particle systems
  66882. * @param type This string represents the type to the particle system to create
  66883. * @param scene The scene where the particle system should live
  66884. * @param gpu If the system will use gpu
  66885. * @returns the ParticleSystemSet created
  66886. */
  66887. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66888. /**
  66889. * Static function used to export a particle system to a ParticleSystemSet variable.
  66890. * Please note that the emitter shape is not exported
  66891. * @param systems defines the particle systems to export
  66892. * @returns the created particle system set
  66893. */
  66894. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66895. /**
  66896. * Creates a particle system from a snippet saved in a remote file
  66897. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66898. * @param url defines the url to load from
  66899. * @param scene defines the hosting scene
  66900. * @param gpu If the system will use gpu
  66901. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66902. * @returns a promise that will resolve to the new particle system
  66903. */
  66904. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66905. /**
  66906. * Creates a particle system from a snippet saved by the particle system editor
  66907. * @param snippetId defines the snippet to load
  66908. * @param scene defines the hosting scene
  66909. * @param gpu If the system will use gpu
  66910. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66911. * @returns a promise that will resolve to the new particle system
  66912. */
  66913. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66914. }
  66915. }
  66916. declare module BABYLON {
  66917. interface Engine {
  66918. /**
  66919. * Create an effect to use with particle systems.
  66920. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66921. * the particle system for which you want to create a custom effect in the last parameter
  66922. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66923. * @param uniformsNames defines a list of attribute names
  66924. * @param samplers defines an array of string used to represent textures
  66925. * @param defines defines the string containing the defines to use to compile the shaders
  66926. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66927. * @param onCompiled defines a function to call when the effect creation is successful
  66928. * @param onError defines a function to call when the effect creation has failed
  66929. * @param particleSystem the particle system you want to create the effect for
  66930. * @returns the new Effect
  66931. */
  66932. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66933. }
  66934. interface Mesh {
  66935. /**
  66936. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66937. * @returns an array of IParticleSystem
  66938. */
  66939. getEmittedParticleSystems(): IParticleSystem[];
  66940. /**
  66941. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66942. * @returns an array of IParticleSystem
  66943. */
  66944. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66945. }
  66946. }
  66947. declare module BABYLON {
  66948. /** Defines the 4 color options */
  66949. export enum PointColor {
  66950. /** color value */
  66951. Color = 2,
  66952. /** uv value */
  66953. UV = 1,
  66954. /** random value */
  66955. Random = 0,
  66956. /** stated value */
  66957. Stated = 3
  66958. }
  66959. /**
  66960. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66961. * 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.
  66962. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66963. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66964. *
  66965. * Full documentation here : TO BE ENTERED
  66966. */
  66967. export class PointsCloudSystem implements IDisposable {
  66968. /**
  66969. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66970. * Example : var p = SPS.particles[i];
  66971. */
  66972. particles: CloudPoint[];
  66973. /**
  66974. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66975. */
  66976. nbParticles: number;
  66977. /**
  66978. * This a counter for your own usage. It's not set by any SPS functions.
  66979. */
  66980. counter: number;
  66981. /**
  66982. * The PCS name. This name is also given to the underlying mesh.
  66983. */
  66984. name: string;
  66985. /**
  66986. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66987. */
  66988. mesh: Mesh;
  66989. /**
  66990. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66991. * Please read :
  66992. */
  66993. vars: any;
  66994. /**
  66995. * @hidden
  66996. */
  66997. _size: number;
  66998. private _scene;
  66999. private _promises;
  67000. private _positions;
  67001. private _indices;
  67002. private _normals;
  67003. private _colors;
  67004. private _uvs;
  67005. private _indices32;
  67006. private _positions32;
  67007. private _colors32;
  67008. private _uvs32;
  67009. private _updatable;
  67010. private _isVisibilityBoxLocked;
  67011. private _alwaysVisible;
  67012. private _groups;
  67013. private _groupCounter;
  67014. private _computeParticleColor;
  67015. private _computeParticleTexture;
  67016. private _computeParticleRotation;
  67017. private _computeBoundingBox;
  67018. private _isReady;
  67019. /**
  67020. * Creates a PCS (Points Cloud System) object
  67021. * @param name (String) is the PCS name, this will be the underlying mesh name
  67022. * @param pointSize (number) is the size for each point
  67023. * @param scene (Scene) is the scene in which the PCS is added
  67024. * @param options defines the options of the PCS e.g.
  67025. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67026. */
  67027. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67028. updatable?: boolean;
  67029. });
  67030. /**
  67031. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67032. * If no points were added to the PCS, the returned mesh is just a single point.
  67033. * @returns a promise for the created mesh
  67034. */
  67035. buildMeshAsync(): Promise<Mesh>;
  67036. /**
  67037. * @hidden
  67038. */
  67039. private _buildMesh;
  67040. private _addParticle;
  67041. private _randomUnitVector;
  67042. private _getColorIndicesForCoord;
  67043. private _setPointsColorOrUV;
  67044. private _colorFromTexture;
  67045. private _calculateDensity;
  67046. /**
  67047. * Adds points to the PCS in random positions within a unit sphere
  67048. * @param nb (positive integer) the number of particles to be created from this model
  67049. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67050. * @returns the number of groups in the system
  67051. */
  67052. addPoints(nb: number, pointFunction?: any): number;
  67053. /**
  67054. * Adds points to the PCS from the surface of the model shape
  67055. * @param mesh is any Mesh object that will be used as a surface model for the points
  67056. * @param nb (positive integer) the number of particles to be created from this model
  67057. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67058. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67059. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67060. * @returns the number of groups in the system
  67061. */
  67062. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67063. /**
  67064. * Adds points to the PCS inside the model shape
  67065. * @param mesh is any Mesh object that will be used as a surface model for the points
  67066. * @param nb (positive integer) the number of particles to be created from this model
  67067. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67068. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67069. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67070. * @returns the number of groups in the system
  67071. */
  67072. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67073. /**
  67074. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67075. * This method calls `updateParticle()` for each particle of the SPS.
  67076. * For an animated SPS, it is usually called within the render loop.
  67077. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67078. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67079. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67080. * @returns the PCS.
  67081. */
  67082. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67083. /**
  67084. * Disposes the PCS.
  67085. */
  67086. dispose(): void;
  67087. /**
  67088. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67089. * doc :
  67090. * @returns the PCS.
  67091. */
  67092. refreshVisibleSize(): PointsCloudSystem;
  67093. /**
  67094. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67095. * @param size the size (float) of the visibility box
  67096. * note : this doesn't lock the PCS mesh bounding box.
  67097. * doc :
  67098. */
  67099. setVisibilityBox(size: number): void;
  67100. /**
  67101. * Gets whether the PCS is always visible or not
  67102. * doc :
  67103. */
  67104. get isAlwaysVisible(): boolean;
  67105. /**
  67106. * Sets the PCS as always visible or not
  67107. * doc :
  67108. */
  67109. set isAlwaysVisible(val: boolean);
  67110. /**
  67111. * Tells to `setParticles()` to compute the particle rotations or not
  67112. * Default value : false. The PCS is faster when it's set to false
  67113. * Note : particle rotations are only applied to parent particles
  67114. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67115. */
  67116. set computeParticleRotation(val: boolean);
  67117. /**
  67118. * Tells to `setParticles()` to compute the particle colors or not.
  67119. * Default value : true. The PCS is faster when it's set to false.
  67120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67121. */
  67122. set computeParticleColor(val: boolean);
  67123. set computeParticleTexture(val: boolean);
  67124. /**
  67125. * Gets if `setParticles()` computes the particle colors or not.
  67126. * Default value : false. The PCS is faster when it's set to false.
  67127. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67128. */
  67129. get computeParticleColor(): boolean;
  67130. /**
  67131. * Gets if `setParticles()` computes the particle textures or not.
  67132. * Default value : false. The PCS is faster when it's set to false.
  67133. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67134. */
  67135. get computeParticleTexture(): boolean;
  67136. /**
  67137. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67138. */
  67139. set computeBoundingBox(val: boolean);
  67140. /**
  67141. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67142. */
  67143. get computeBoundingBox(): boolean;
  67144. /**
  67145. * This function does nothing. It may be overwritten to set all the particle first values.
  67146. * The PCS doesn't call this function, you may have to call it by your own.
  67147. * doc :
  67148. */
  67149. initParticles(): void;
  67150. /**
  67151. * This function does nothing. It may be overwritten to recycle a particle
  67152. * The PCS doesn't call this function, you can to call it
  67153. * doc :
  67154. * @param particle The particle to recycle
  67155. * @returns the recycled particle
  67156. */
  67157. recycleParticle(particle: CloudPoint): CloudPoint;
  67158. /**
  67159. * Updates a particle : this function should be overwritten by the user.
  67160. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67161. * doc :
  67162. * @example : just set a particle position or velocity and recycle conditions
  67163. * @param particle The particle to update
  67164. * @returns the updated particle
  67165. */
  67166. updateParticle(particle: CloudPoint): CloudPoint;
  67167. /**
  67168. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67169. * This does nothing and may be overwritten by the user.
  67170. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67171. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67172. * @param update the boolean update value actually passed to setParticles()
  67173. */
  67174. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67175. /**
  67176. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67177. * This will be passed three parameters.
  67178. * This does nothing and may be overwritten by the user.
  67179. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67180. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67181. * @param update the boolean update value actually passed to setParticles()
  67182. */
  67183. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67184. }
  67185. }
  67186. declare module BABYLON {
  67187. /**
  67188. * Represents one particle of a points cloud system.
  67189. */
  67190. export class CloudPoint {
  67191. /**
  67192. * particle global index
  67193. */
  67194. idx: number;
  67195. /**
  67196. * The color of the particle
  67197. */
  67198. color: Nullable<Color4>;
  67199. /**
  67200. * The world space position of the particle.
  67201. */
  67202. position: Vector3;
  67203. /**
  67204. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67205. */
  67206. rotation: Vector3;
  67207. /**
  67208. * The world space rotation quaternion of the particle.
  67209. */
  67210. rotationQuaternion: Nullable<Quaternion>;
  67211. /**
  67212. * The uv of the particle.
  67213. */
  67214. uv: Nullable<Vector2>;
  67215. /**
  67216. * The current speed of the particle.
  67217. */
  67218. velocity: Vector3;
  67219. /**
  67220. * The pivot point in the particle local space.
  67221. */
  67222. pivot: Vector3;
  67223. /**
  67224. * Must the particle be translated from its pivot point in its local space ?
  67225. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67226. * Default : false
  67227. */
  67228. translateFromPivot: boolean;
  67229. /**
  67230. * Index of this particle in the global "positions" array (Internal use)
  67231. * @hidden
  67232. */
  67233. _pos: number;
  67234. /**
  67235. * @hidden Index of this particle in the global "indices" array (Internal use)
  67236. */
  67237. _ind: number;
  67238. /**
  67239. * Group this particle belongs to
  67240. */
  67241. _group: PointsGroup;
  67242. /**
  67243. * Group id of this particle
  67244. */
  67245. groupId: number;
  67246. /**
  67247. * Index of the particle in its group id (Internal use)
  67248. */
  67249. idxInGroup: number;
  67250. /**
  67251. * @hidden Particle BoundingInfo object (Internal use)
  67252. */
  67253. _boundingInfo: BoundingInfo;
  67254. /**
  67255. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67256. */
  67257. _pcs: PointsCloudSystem;
  67258. /**
  67259. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67260. */
  67261. _stillInvisible: boolean;
  67262. /**
  67263. * @hidden Last computed particle rotation matrix
  67264. */
  67265. _rotationMatrix: number[];
  67266. /**
  67267. * Parent particle Id, if any.
  67268. * Default null.
  67269. */
  67270. parentId: Nullable<number>;
  67271. /**
  67272. * @hidden Internal global position in the PCS.
  67273. */
  67274. _globalPosition: Vector3;
  67275. /**
  67276. * Creates a Point Cloud object.
  67277. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67278. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67279. * @param group (PointsGroup) is the group the particle belongs to
  67280. * @param groupId (integer) is the group identifier in the PCS.
  67281. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67282. * @param pcs defines the PCS it is associated to
  67283. */
  67284. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67285. /**
  67286. * get point size
  67287. */
  67288. get size(): Vector3;
  67289. /**
  67290. * Set point size
  67291. */
  67292. set size(scale: Vector3);
  67293. /**
  67294. * Legacy support, changed quaternion to rotationQuaternion
  67295. */
  67296. get quaternion(): Nullable<Quaternion>;
  67297. /**
  67298. * Legacy support, changed quaternion to rotationQuaternion
  67299. */
  67300. set quaternion(q: Nullable<Quaternion>);
  67301. /**
  67302. * Returns a boolean. True if the particle intersects a mesh, else false
  67303. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67304. * @param target is the object (point or mesh) what the intersection is computed against
  67305. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67306. * @returns true if it intersects
  67307. */
  67308. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67309. /**
  67310. * get the rotation matrix of the particle
  67311. * @hidden
  67312. */
  67313. getRotationMatrix(m: Matrix): void;
  67314. }
  67315. /**
  67316. * Represents a group of points in a points cloud system
  67317. * * PCS internal tool, don't use it manually.
  67318. */
  67319. export class PointsGroup {
  67320. /**
  67321. * The group id
  67322. * @hidden
  67323. */
  67324. groupID: number;
  67325. /**
  67326. * image data for group (internal use)
  67327. * @hidden
  67328. */
  67329. _groupImageData: Nullable<ArrayBufferView>;
  67330. /**
  67331. * Image Width (internal use)
  67332. * @hidden
  67333. */
  67334. _groupImgWidth: number;
  67335. /**
  67336. * Image Height (internal use)
  67337. * @hidden
  67338. */
  67339. _groupImgHeight: number;
  67340. /**
  67341. * Custom position function (internal use)
  67342. * @hidden
  67343. */
  67344. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67345. /**
  67346. * density per facet for surface points
  67347. * @hidden
  67348. */
  67349. _groupDensity: number[];
  67350. /**
  67351. * Only when points are colored by texture carries pointer to texture list array
  67352. * @hidden
  67353. */
  67354. _textureNb: number;
  67355. /**
  67356. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67357. * PCS internal tool, don't use it manually.
  67358. * @hidden
  67359. */
  67360. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67361. }
  67362. }
  67363. declare module BABYLON {
  67364. interface Scene {
  67365. /** @hidden (Backing field) */
  67366. _physicsEngine: Nullable<IPhysicsEngine>;
  67367. /** @hidden */
  67368. _physicsTimeAccumulator: number;
  67369. /**
  67370. * Gets the current physics engine
  67371. * @returns a IPhysicsEngine or null if none attached
  67372. */
  67373. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67374. /**
  67375. * Enables physics to the current scene
  67376. * @param gravity defines the scene's gravity for the physics engine
  67377. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67378. * @return a boolean indicating if the physics engine was initialized
  67379. */
  67380. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67381. /**
  67382. * Disables and disposes the physics engine associated with the scene
  67383. */
  67384. disablePhysicsEngine(): void;
  67385. /**
  67386. * Gets a boolean indicating if there is an active physics engine
  67387. * @returns a boolean indicating if there is an active physics engine
  67388. */
  67389. isPhysicsEnabled(): boolean;
  67390. /**
  67391. * Deletes a physics compound impostor
  67392. * @param compound defines the compound to delete
  67393. */
  67394. deleteCompoundImpostor(compound: any): void;
  67395. /**
  67396. * An event triggered when physic simulation is about to be run
  67397. */
  67398. onBeforePhysicsObservable: Observable<Scene>;
  67399. /**
  67400. * An event triggered when physic simulation has been done
  67401. */
  67402. onAfterPhysicsObservable: Observable<Scene>;
  67403. }
  67404. interface AbstractMesh {
  67405. /** @hidden */
  67406. _physicsImpostor: Nullable<PhysicsImpostor>;
  67407. /**
  67408. * Gets or sets impostor used for physic simulation
  67409. * @see https://doc.babylonjs.com/features/physics_engine
  67410. */
  67411. physicsImpostor: Nullable<PhysicsImpostor>;
  67412. /**
  67413. * Gets the current physics impostor
  67414. * @see https://doc.babylonjs.com/features/physics_engine
  67415. * @returns a physics impostor or null
  67416. */
  67417. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67418. /** Apply a physic impulse to the mesh
  67419. * @param force defines the force to apply
  67420. * @param contactPoint defines where to apply the force
  67421. * @returns the current mesh
  67422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67423. */
  67424. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67425. /**
  67426. * Creates a physic joint between two meshes
  67427. * @param otherMesh defines the other mesh to use
  67428. * @param pivot1 defines the pivot to use on this mesh
  67429. * @param pivot2 defines the pivot to use on the other mesh
  67430. * @param options defines additional options (can be plugin dependent)
  67431. * @returns the current mesh
  67432. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67433. */
  67434. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67435. /** @hidden */
  67436. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67437. }
  67438. /**
  67439. * Defines the physics engine scene component responsible to manage a physics engine
  67440. */
  67441. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67442. /**
  67443. * The component name helpful to identify the component in the list of scene components.
  67444. */
  67445. readonly name: string;
  67446. /**
  67447. * The scene the component belongs to.
  67448. */
  67449. scene: Scene;
  67450. /**
  67451. * Creates a new instance of the component for the given scene
  67452. * @param scene Defines the scene to register the component in
  67453. */
  67454. constructor(scene: Scene);
  67455. /**
  67456. * Registers the component in a given scene
  67457. */
  67458. register(): void;
  67459. /**
  67460. * Rebuilds the elements related to this component in case of
  67461. * context lost for instance.
  67462. */
  67463. rebuild(): void;
  67464. /**
  67465. * Disposes the component and the associated ressources
  67466. */
  67467. dispose(): void;
  67468. }
  67469. }
  67470. declare module BABYLON {
  67471. /**
  67472. * A helper for physics simulations
  67473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67474. */
  67475. export class PhysicsHelper {
  67476. private _scene;
  67477. private _physicsEngine;
  67478. /**
  67479. * Initializes the Physics helper
  67480. * @param scene Babylon.js scene
  67481. */
  67482. constructor(scene: Scene);
  67483. /**
  67484. * Applies a radial explosion impulse
  67485. * @param origin the origin of the explosion
  67486. * @param radiusOrEventOptions the radius or the options of radial explosion
  67487. * @param strength the explosion strength
  67488. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67489. * @returns A physics radial explosion event, or null
  67490. */
  67491. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67492. /**
  67493. * Applies a radial explosion force
  67494. * @param origin the origin of the explosion
  67495. * @param radiusOrEventOptions the radius or the options of radial explosion
  67496. * @param strength the explosion strength
  67497. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67498. * @returns A physics radial explosion event, or null
  67499. */
  67500. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67501. /**
  67502. * Creates a gravitational field
  67503. * @param origin the origin of the explosion
  67504. * @param radiusOrEventOptions the radius or the options of radial explosion
  67505. * @param strength the explosion strength
  67506. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67507. * @returns A physics gravitational field event, or null
  67508. */
  67509. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67510. /**
  67511. * Creates a physics updraft event
  67512. * @param origin the origin of the updraft
  67513. * @param radiusOrEventOptions the radius or the options of the updraft
  67514. * @param strength the strength of the updraft
  67515. * @param height the height of the updraft
  67516. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67517. * @returns A physics updraft event, or null
  67518. */
  67519. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67520. /**
  67521. * Creates a physics vortex event
  67522. * @param origin the of the vortex
  67523. * @param radiusOrEventOptions the radius or the options of the vortex
  67524. * @param strength the strength of the vortex
  67525. * @param height the height of the vortex
  67526. * @returns a Physics vortex event, or null
  67527. * A physics vortex event or null
  67528. */
  67529. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67530. }
  67531. /**
  67532. * Represents a physics radial explosion event
  67533. */
  67534. class PhysicsRadialExplosionEvent {
  67535. private _scene;
  67536. private _options;
  67537. private _sphere;
  67538. private _dataFetched;
  67539. /**
  67540. * Initializes a radial explosioin event
  67541. * @param _scene BabylonJS scene
  67542. * @param _options The options for the vortex event
  67543. */
  67544. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67545. /**
  67546. * Returns the data related to the radial explosion event (sphere).
  67547. * @returns The radial explosion event data
  67548. */
  67549. getData(): PhysicsRadialExplosionEventData;
  67550. /**
  67551. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67552. * @param impostor A physics imposter
  67553. * @param origin the origin of the explosion
  67554. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67555. */
  67556. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67557. /**
  67558. * Triggers affecterd impostors callbacks
  67559. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67560. */
  67561. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67562. /**
  67563. * Disposes the sphere.
  67564. * @param force Specifies if the sphere should be disposed by force
  67565. */
  67566. dispose(force?: boolean): void;
  67567. /*** Helpers ***/
  67568. private _prepareSphere;
  67569. private _intersectsWithSphere;
  67570. }
  67571. /**
  67572. * Represents a gravitational field event
  67573. */
  67574. class PhysicsGravitationalFieldEvent {
  67575. private _physicsHelper;
  67576. private _scene;
  67577. private _origin;
  67578. private _options;
  67579. private _tickCallback;
  67580. private _sphere;
  67581. private _dataFetched;
  67582. /**
  67583. * Initializes the physics gravitational field event
  67584. * @param _physicsHelper A physics helper
  67585. * @param _scene BabylonJS scene
  67586. * @param _origin The origin position of the gravitational field event
  67587. * @param _options The options for the vortex event
  67588. */
  67589. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67590. /**
  67591. * Returns the data related to the gravitational field event (sphere).
  67592. * @returns A gravitational field event
  67593. */
  67594. getData(): PhysicsGravitationalFieldEventData;
  67595. /**
  67596. * Enables the gravitational field.
  67597. */
  67598. enable(): void;
  67599. /**
  67600. * Disables the gravitational field.
  67601. */
  67602. disable(): void;
  67603. /**
  67604. * Disposes the sphere.
  67605. * @param force The force to dispose from the gravitational field event
  67606. */
  67607. dispose(force?: boolean): void;
  67608. private _tick;
  67609. }
  67610. /**
  67611. * Represents a physics updraft event
  67612. */
  67613. class PhysicsUpdraftEvent {
  67614. private _scene;
  67615. private _origin;
  67616. private _options;
  67617. private _physicsEngine;
  67618. private _originTop;
  67619. private _originDirection;
  67620. private _tickCallback;
  67621. private _cylinder;
  67622. private _cylinderPosition;
  67623. private _dataFetched;
  67624. /**
  67625. * Initializes the physics updraft event
  67626. * @param _scene BabylonJS scene
  67627. * @param _origin The origin position of the updraft
  67628. * @param _options The options for the updraft event
  67629. */
  67630. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67631. /**
  67632. * Returns the data related to the updraft event (cylinder).
  67633. * @returns A physics updraft event
  67634. */
  67635. getData(): PhysicsUpdraftEventData;
  67636. /**
  67637. * Enables the updraft.
  67638. */
  67639. enable(): void;
  67640. /**
  67641. * Disables the updraft.
  67642. */
  67643. disable(): void;
  67644. /**
  67645. * Disposes the cylinder.
  67646. * @param force Specifies if the updraft should be disposed by force
  67647. */
  67648. dispose(force?: boolean): void;
  67649. private getImpostorHitData;
  67650. private _tick;
  67651. /*** Helpers ***/
  67652. private _prepareCylinder;
  67653. private _intersectsWithCylinder;
  67654. }
  67655. /**
  67656. * Represents a physics vortex event
  67657. */
  67658. class PhysicsVortexEvent {
  67659. private _scene;
  67660. private _origin;
  67661. private _options;
  67662. private _physicsEngine;
  67663. private _originTop;
  67664. private _tickCallback;
  67665. private _cylinder;
  67666. private _cylinderPosition;
  67667. private _dataFetched;
  67668. /**
  67669. * Initializes the physics vortex event
  67670. * @param _scene The BabylonJS scene
  67671. * @param _origin The origin position of the vortex
  67672. * @param _options The options for the vortex event
  67673. */
  67674. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67675. /**
  67676. * Returns the data related to the vortex event (cylinder).
  67677. * @returns The physics vortex event data
  67678. */
  67679. getData(): PhysicsVortexEventData;
  67680. /**
  67681. * Enables the vortex.
  67682. */
  67683. enable(): void;
  67684. /**
  67685. * Disables the cortex.
  67686. */
  67687. disable(): void;
  67688. /**
  67689. * Disposes the sphere.
  67690. * @param force
  67691. */
  67692. dispose(force?: boolean): void;
  67693. private getImpostorHitData;
  67694. private _tick;
  67695. /*** Helpers ***/
  67696. private _prepareCylinder;
  67697. private _intersectsWithCylinder;
  67698. }
  67699. /**
  67700. * Options fot the radial explosion event
  67701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67702. */
  67703. export class PhysicsRadialExplosionEventOptions {
  67704. /**
  67705. * The radius of the sphere for the radial explosion.
  67706. */
  67707. radius: number;
  67708. /**
  67709. * The strenth of the explosion.
  67710. */
  67711. strength: number;
  67712. /**
  67713. * The strenght of the force in correspondence to the distance of the affected object
  67714. */
  67715. falloff: PhysicsRadialImpulseFalloff;
  67716. /**
  67717. * Sphere options for the radial explosion.
  67718. */
  67719. sphere: {
  67720. segments: number;
  67721. diameter: number;
  67722. };
  67723. /**
  67724. * Sphere options for the radial explosion.
  67725. */
  67726. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67727. }
  67728. /**
  67729. * Options fot the updraft event
  67730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67731. */
  67732. export class PhysicsUpdraftEventOptions {
  67733. /**
  67734. * The radius of the cylinder for the vortex
  67735. */
  67736. radius: number;
  67737. /**
  67738. * The strenth of the updraft.
  67739. */
  67740. strength: number;
  67741. /**
  67742. * The height of the cylinder for the updraft.
  67743. */
  67744. height: number;
  67745. /**
  67746. * The mode for the the updraft.
  67747. */
  67748. updraftMode: PhysicsUpdraftMode;
  67749. }
  67750. /**
  67751. * Options fot the vortex event
  67752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67753. */
  67754. export class PhysicsVortexEventOptions {
  67755. /**
  67756. * The radius of the cylinder for the vortex
  67757. */
  67758. radius: number;
  67759. /**
  67760. * The strenth of the vortex.
  67761. */
  67762. strength: number;
  67763. /**
  67764. * The height of the cylinder for the vortex.
  67765. */
  67766. height: number;
  67767. /**
  67768. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67769. */
  67770. centripetalForceThreshold: number;
  67771. /**
  67772. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67773. */
  67774. centripetalForceMultiplier: number;
  67775. /**
  67776. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67777. */
  67778. centrifugalForceMultiplier: number;
  67779. /**
  67780. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67781. */
  67782. updraftForceMultiplier: number;
  67783. }
  67784. /**
  67785. * The strenght of the force in correspondence to the distance of the affected object
  67786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67787. */
  67788. export enum PhysicsRadialImpulseFalloff {
  67789. /** Defines that impulse is constant in strength across it's whole radius */
  67790. Constant = 0,
  67791. /** Defines that impulse gets weaker if it's further from the origin */
  67792. Linear = 1
  67793. }
  67794. /**
  67795. * The strength of the force in correspondence to the distance of the affected object
  67796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67797. */
  67798. export enum PhysicsUpdraftMode {
  67799. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67800. Center = 0,
  67801. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67802. Perpendicular = 1
  67803. }
  67804. /**
  67805. * Interface for a physics hit data
  67806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67807. */
  67808. export interface PhysicsHitData {
  67809. /**
  67810. * The force applied at the contact point
  67811. */
  67812. force: Vector3;
  67813. /**
  67814. * The contact point
  67815. */
  67816. contactPoint: Vector3;
  67817. /**
  67818. * The distance from the origin to the contact point
  67819. */
  67820. distanceFromOrigin: number;
  67821. }
  67822. /**
  67823. * Interface for radial explosion event data
  67824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67825. */
  67826. export interface PhysicsRadialExplosionEventData {
  67827. /**
  67828. * A sphere used for the radial explosion event
  67829. */
  67830. sphere: Mesh;
  67831. }
  67832. /**
  67833. * Interface for gravitational field event data
  67834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67835. */
  67836. export interface PhysicsGravitationalFieldEventData {
  67837. /**
  67838. * A sphere mesh used for the gravitational field event
  67839. */
  67840. sphere: Mesh;
  67841. }
  67842. /**
  67843. * Interface for updraft event data
  67844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67845. */
  67846. export interface PhysicsUpdraftEventData {
  67847. /**
  67848. * A cylinder used for the updraft event
  67849. */
  67850. cylinder: Mesh;
  67851. }
  67852. /**
  67853. * Interface for vortex event data
  67854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67855. */
  67856. export interface PhysicsVortexEventData {
  67857. /**
  67858. * A cylinder used for the vortex event
  67859. */
  67860. cylinder: Mesh;
  67861. }
  67862. /**
  67863. * Interface for an affected physics impostor
  67864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67865. */
  67866. export interface PhysicsAffectedImpostorWithData {
  67867. /**
  67868. * The impostor affected by the effect
  67869. */
  67870. impostor: PhysicsImpostor;
  67871. /**
  67872. * The data about the hit/horce from the explosion
  67873. */
  67874. hitData: PhysicsHitData;
  67875. }
  67876. }
  67877. declare module BABYLON {
  67878. /** @hidden */
  67879. export var blackAndWhitePixelShader: {
  67880. name: string;
  67881. shader: string;
  67882. };
  67883. }
  67884. declare module BABYLON {
  67885. /**
  67886. * Post process used to render in black and white
  67887. */
  67888. export class BlackAndWhitePostProcess extends PostProcess {
  67889. /**
  67890. * Linear about to convert he result to black and white (default: 1)
  67891. */
  67892. degree: number;
  67893. /**
  67894. * Creates a black and white post process
  67895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67896. * @param name The name of the effect.
  67897. * @param options The required width/height ratio to downsize to before computing the render pass.
  67898. * @param camera The camera to apply the render pass to.
  67899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67900. * @param engine The engine which the post process will be applied. (default: current engine)
  67901. * @param reusable If the post process can be reused on the same frame. (default: false)
  67902. */
  67903. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67904. }
  67905. }
  67906. declare module BABYLON {
  67907. /**
  67908. * This represents a set of one or more post processes in Babylon.
  67909. * A post process can be used to apply a shader to a texture after it is rendered.
  67910. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67911. */
  67912. export class PostProcessRenderEffect {
  67913. private _postProcesses;
  67914. private _getPostProcesses;
  67915. private _singleInstance;
  67916. private _cameras;
  67917. private _indicesForCamera;
  67918. /**
  67919. * Name of the effect
  67920. * @hidden
  67921. */
  67922. _name: string;
  67923. /**
  67924. * Instantiates a post process render effect.
  67925. * A post process can be used to apply a shader to a texture after it is rendered.
  67926. * @param engine The engine the effect is tied to
  67927. * @param name The name of the effect
  67928. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67929. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67930. */
  67931. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67932. /**
  67933. * Checks if all the post processes in the effect are supported.
  67934. */
  67935. get isSupported(): boolean;
  67936. /**
  67937. * Updates the current state of the effect
  67938. * @hidden
  67939. */
  67940. _update(): void;
  67941. /**
  67942. * Attaches the effect on cameras
  67943. * @param cameras The camera to attach to.
  67944. * @hidden
  67945. */
  67946. _attachCameras(cameras: Camera): 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. * Detaches the effect on cameras
  67955. * @param cameras The camera to detatch from.
  67956. * @hidden
  67957. */
  67958. _detachCameras(cameras: Camera): void;
  67959. /**
  67960. * Detatches the effect on cameras
  67961. * @param cameras The camera to detatch from.
  67962. * @hidden
  67963. */
  67964. _detachCameras(cameras: Camera[]): void;
  67965. /**
  67966. * Enables the effect on given cameras
  67967. * @param cameras The camera to enable.
  67968. * @hidden
  67969. */
  67970. _enable(cameras: Camera): void;
  67971. /**
  67972. * Enables the effect on given cameras
  67973. * @param cameras The camera to enable.
  67974. * @hidden
  67975. */
  67976. _enable(cameras: Nullable<Camera[]>): void;
  67977. /**
  67978. * Disables the effect on the given cameras
  67979. * @param cameras The camera to disable.
  67980. * @hidden
  67981. */
  67982. _disable(cameras: Camera): void;
  67983. /**
  67984. * Disables the effect on the given cameras
  67985. * @param cameras The camera to disable.
  67986. * @hidden
  67987. */
  67988. _disable(cameras: Nullable<Camera[]>): void;
  67989. /**
  67990. * Gets a list of the post processes contained in the effect.
  67991. * @param camera The camera to get the post processes on.
  67992. * @returns The list of the post processes in the effect.
  67993. */
  67994. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67995. }
  67996. }
  67997. declare module BABYLON {
  67998. /** @hidden */
  67999. export var extractHighlightsPixelShader: {
  68000. name: string;
  68001. shader: string;
  68002. };
  68003. }
  68004. declare module BABYLON {
  68005. /**
  68006. * 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.
  68007. */
  68008. export class ExtractHighlightsPostProcess extends PostProcess {
  68009. /**
  68010. * The luminance threshold, pixels below this value will be set to black.
  68011. */
  68012. threshold: number;
  68013. /** @hidden */
  68014. _exposure: number;
  68015. /**
  68016. * Post process which has the input texture to be used when performing highlight extraction
  68017. * @hidden
  68018. */
  68019. _inputPostProcess: Nullable<PostProcess>;
  68020. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68021. }
  68022. }
  68023. declare module BABYLON {
  68024. /** @hidden */
  68025. export var bloomMergePixelShader: {
  68026. name: string;
  68027. shader: string;
  68028. };
  68029. }
  68030. declare module BABYLON {
  68031. /**
  68032. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68033. */
  68034. export class BloomMergePostProcess extends PostProcess {
  68035. /** Weight of the bloom to be added to the original input. */
  68036. weight: number;
  68037. /**
  68038. * Creates a new instance of @see BloomMergePostProcess
  68039. * @param name The name of the effect.
  68040. * @param originalFromInput Post process which's input will be used for the merge.
  68041. * @param blurred Blurred highlights post process which's output will be used.
  68042. * @param weight Weight of the bloom to be added to the original input.
  68043. * @param options The required width/height ratio to downsize to before computing the render pass.
  68044. * @param camera The camera to apply the render pass to.
  68045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68046. * @param engine The engine which the post process will be applied. (default: current engine)
  68047. * @param reusable If the post process can be reused on the same frame. (default: false)
  68048. * @param textureType Type of textures used when performing the post process. (default: 0)
  68049. * @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)
  68050. */
  68051. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68052. /** Weight of the bloom to be added to the original input. */
  68053. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68054. }
  68055. }
  68056. declare module BABYLON {
  68057. /**
  68058. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68059. */
  68060. export class BloomEffect extends PostProcessRenderEffect {
  68061. private bloomScale;
  68062. /**
  68063. * @hidden Internal
  68064. */
  68065. _effects: Array<PostProcess>;
  68066. /**
  68067. * @hidden Internal
  68068. */
  68069. _downscale: ExtractHighlightsPostProcess;
  68070. private _blurX;
  68071. private _blurY;
  68072. private _merge;
  68073. /**
  68074. * The luminance threshold to find bright areas of the image to bloom.
  68075. */
  68076. get threshold(): number;
  68077. set threshold(value: number);
  68078. /**
  68079. * The strength of the bloom.
  68080. */
  68081. get weight(): number;
  68082. set weight(value: number);
  68083. /**
  68084. * Specifies the size of the bloom blur kernel, relative to the final output size
  68085. */
  68086. get kernel(): number;
  68087. set kernel(value: number);
  68088. /**
  68089. * Creates a new instance of @see BloomEffect
  68090. * @param scene The scene the effect belongs to.
  68091. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68092. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68093. * @param bloomWeight The the strength of bloom.
  68094. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68095. * @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)
  68096. */
  68097. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68098. /**
  68099. * Disposes each of the internal effects for a given camera.
  68100. * @param camera The camera to dispose the effect on.
  68101. */
  68102. disposeEffects(camera: Camera): void;
  68103. /**
  68104. * @hidden Internal
  68105. */
  68106. _updateEffects(): void;
  68107. /**
  68108. * Internal
  68109. * @returns if all the contained post processes are ready.
  68110. * @hidden
  68111. */
  68112. _isReady(): boolean;
  68113. }
  68114. }
  68115. declare module BABYLON {
  68116. /** @hidden */
  68117. export var chromaticAberrationPixelShader: {
  68118. name: string;
  68119. shader: string;
  68120. };
  68121. }
  68122. declare module BABYLON {
  68123. /**
  68124. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68125. */
  68126. export class ChromaticAberrationPostProcess extends PostProcess {
  68127. /**
  68128. * The amount of seperation of rgb channels (default: 30)
  68129. */
  68130. aberrationAmount: number;
  68131. /**
  68132. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68133. */
  68134. radialIntensity: number;
  68135. /**
  68136. * 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))
  68137. */
  68138. direction: Vector2;
  68139. /**
  68140. * 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))
  68141. */
  68142. centerPosition: Vector2;
  68143. /**
  68144. * Creates a new instance ChromaticAberrationPostProcess
  68145. * @param name The name of the effect.
  68146. * @param screenWidth The width of the screen to apply the effect on.
  68147. * @param screenHeight The height of the screen to apply the effect on.
  68148. * @param options The required width/height ratio to downsize to before computing the render pass.
  68149. * @param camera The camera to apply the render pass to.
  68150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68151. * @param engine The engine which the post process will be applied. (default: current engine)
  68152. * @param reusable If the post process can be reused on the same frame. (default: false)
  68153. * @param textureType Type of textures used when performing the post process. (default: 0)
  68154. * @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)
  68155. */
  68156. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68157. }
  68158. }
  68159. declare module BABYLON {
  68160. /** @hidden */
  68161. export var circleOfConfusionPixelShader: {
  68162. name: string;
  68163. shader: string;
  68164. };
  68165. }
  68166. declare module BABYLON {
  68167. /**
  68168. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68169. */
  68170. export class CircleOfConfusionPostProcess extends PostProcess {
  68171. /**
  68172. * 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.
  68173. */
  68174. lensSize: number;
  68175. /**
  68176. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68177. */
  68178. fStop: number;
  68179. /**
  68180. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68181. */
  68182. focusDistance: number;
  68183. /**
  68184. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68185. */
  68186. focalLength: number;
  68187. private _depthTexture;
  68188. /**
  68189. * Creates a new instance CircleOfConfusionPostProcess
  68190. * @param name The name of the effect.
  68191. * @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.
  68192. * @param options The required width/height ratio to downsize to before computing the render pass.
  68193. * @param camera The camera to apply the render pass to.
  68194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68195. * @param engine The engine which the post process will be applied. (default: current engine)
  68196. * @param reusable If the post process can be reused on the same frame. (default: false)
  68197. * @param textureType Type of textures used when performing the post process. (default: 0)
  68198. * @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)
  68199. */
  68200. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68201. /**
  68202. * 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.
  68203. */
  68204. set depthTexture(value: RenderTargetTexture);
  68205. }
  68206. }
  68207. declare module BABYLON {
  68208. /** @hidden */
  68209. export var colorCorrectionPixelShader: {
  68210. name: string;
  68211. shader: string;
  68212. };
  68213. }
  68214. declare module BABYLON {
  68215. /**
  68216. *
  68217. * This post-process allows the modification of rendered colors by using
  68218. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68219. *
  68220. * The object needs to be provided an url to a texture containing the color
  68221. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68222. * Use an image editing software to tweak the LUT to match your needs.
  68223. *
  68224. * For an example of a color LUT, see here:
  68225. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68226. * For explanations on color grading, see here:
  68227. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68228. *
  68229. */
  68230. export class ColorCorrectionPostProcess extends PostProcess {
  68231. private _colorTableTexture;
  68232. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68233. }
  68234. }
  68235. declare module BABYLON {
  68236. /** @hidden */
  68237. export var convolutionPixelShader: {
  68238. name: string;
  68239. shader: string;
  68240. };
  68241. }
  68242. declare module BABYLON {
  68243. /**
  68244. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68245. * input texture to perform effects such as edge detection or sharpening
  68246. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68247. */
  68248. export class ConvolutionPostProcess extends PostProcess {
  68249. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68250. kernel: number[];
  68251. /**
  68252. * Creates a new instance ConvolutionPostProcess
  68253. * @param name The name of the effect.
  68254. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68255. * @param options The required width/height ratio to downsize to before computing the render pass.
  68256. * @param camera The camera to apply the render pass to.
  68257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68258. * @param engine The engine which the post process will be applied. (default: current engine)
  68259. * @param reusable If the post process can be reused on the same frame. (default: false)
  68260. * @param textureType Type of textures used when performing the post process. (default: 0)
  68261. */
  68262. constructor(name: string,
  68263. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68264. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68265. /**
  68266. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68267. */
  68268. static EdgeDetect0Kernel: number[];
  68269. /**
  68270. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68271. */
  68272. static EdgeDetect1Kernel: number[];
  68273. /**
  68274. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68275. */
  68276. static EdgeDetect2Kernel: number[];
  68277. /**
  68278. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68279. */
  68280. static SharpenKernel: number[];
  68281. /**
  68282. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68283. */
  68284. static EmbossKernel: number[];
  68285. /**
  68286. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68287. */
  68288. static GaussianKernel: number[];
  68289. }
  68290. }
  68291. declare module BABYLON {
  68292. /**
  68293. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68294. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68295. * based on samples that have a large difference in distance than the center pixel.
  68296. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68297. */
  68298. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68299. direction: Vector2;
  68300. /**
  68301. * Creates a new instance CircleOfConfusionPostProcess
  68302. * @param name The name of the effect.
  68303. * @param scene The scene the effect belongs to.
  68304. * @param direction The direction the blur should be applied.
  68305. * @param kernel The size of the kernel used to blur.
  68306. * @param options The required width/height ratio to downsize to before computing the render pass.
  68307. * @param camera The camera to apply the render pass to.
  68308. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68309. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68311. * @param engine The engine which the post process will be applied. (default: current engine)
  68312. * @param reusable If the post process can be reused on the same frame. (default: false)
  68313. * @param textureType Type of textures used when performing the post process. (default: 0)
  68314. * @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)
  68315. */
  68316. 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);
  68317. }
  68318. }
  68319. declare module BABYLON {
  68320. /** @hidden */
  68321. export var depthOfFieldMergePixelShader: {
  68322. name: string;
  68323. shader: string;
  68324. };
  68325. }
  68326. declare module BABYLON {
  68327. /**
  68328. * Options to be set when merging outputs from the default pipeline.
  68329. */
  68330. export class DepthOfFieldMergePostProcessOptions {
  68331. /**
  68332. * The original image to merge on top of
  68333. */
  68334. originalFromInput: PostProcess;
  68335. /**
  68336. * Parameters to perform the merge of the depth of field effect
  68337. */
  68338. depthOfField?: {
  68339. circleOfConfusion: PostProcess;
  68340. blurSteps: Array<PostProcess>;
  68341. };
  68342. /**
  68343. * Parameters to perform the merge of bloom effect
  68344. */
  68345. bloom?: {
  68346. blurred: PostProcess;
  68347. weight: number;
  68348. };
  68349. }
  68350. /**
  68351. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68352. */
  68353. export class DepthOfFieldMergePostProcess extends PostProcess {
  68354. private blurSteps;
  68355. /**
  68356. * Creates a new instance of DepthOfFieldMergePostProcess
  68357. * @param name The name of the effect.
  68358. * @param originalFromInput Post process which's input will be used for the merge.
  68359. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68360. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68361. * @param options The required width/height ratio to downsize to before computing the render pass.
  68362. * @param camera The camera to apply the render pass to.
  68363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68364. * @param engine The engine which the post process will be applied. (default: current engine)
  68365. * @param reusable If the post process can be reused on the same frame. (default: false)
  68366. * @param textureType Type of textures used when performing the post process. (default: 0)
  68367. * @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)
  68368. */
  68369. 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);
  68370. /**
  68371. * Updates the effect with the current post process compile time values and recompiles the shader.
  68372. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68373. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68374. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68375. * @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
  68376. * @param onCompiled Called when the shader has been compiled.
  68377. * @param onError Called if there is an error when compiling a shader.
  68378. */
  68379. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68380. }
  68381. }
  68382. declare module BABYLON {
  68383. /**
  68384. * Specifies the level of max blur that should be applied when using the depth of field effect
  68385. */
  68386. export enum DepthOfFieldEffectBlurLevel {
  68387. /**
  68388. * Subtle blur
  68389. */
  68390. Low = 0,
  68391. /**
  68392. * Medium blur
  68393. */
  68394. Medium = 1,
  68395. /**
  68396. * Large blur
  68397. */
  68398. High = 2
  68399. }
  68400. /**
  68401. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68402. */
  68403. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68404. private _circleOfConfusion;
  68405. /**
  68406. * @hidden Internal, blurs from high to low
  68407. */
  68408. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68409. private _depthOfFieldBlurY;
  68410. private _dofMerge;
  68411. /**
  68412. * @hidden Internal post processes in depth of field effect
  68413. */
  68414. _effects: Array<PostProcess>;
  68415. /**
  68416. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68417. */
  68418. set focalLength(value: number);
  68419. get focalLength(): number;
  68420. /**
  68421. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68422. */
  68423. set fStop(value: number);
  68424. get fStop(): number;
  68425. /**
  68426. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68427. */
  68428. set focusDistance(value: number);
  68429. get focusDistance(): number;
  68430. /**
  68431. * 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.
  68432. */
  68433. set lensSize(value: number);
  68434. get lensSize(): number;
  68435. /**
  68436. * Creates a new instance DepthOfFieldEffect
  68437. * @param scene The scene the effect belongs to.
  68438. * @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.
  68439. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68440. * @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)
  68441. */
  68442. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68443. /**
  68444. * Get the current class name of the current effet
  68445. * @returns "DepthOfFieldEffect"
  68446. */
  68447. getClassName(): string;
  68448. /**
  68449. * 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.
  68450. */
  68451. set depthTexture(value: RenderTargetTexture);
  68452. /**
  68453. * Disposes each of the internal effects for a given camera.
  68454. * @param camera The camera to dispose the effect on.
  68455. */
  68456. disposeEffects(camera: Camera): void;
  68457. /**
  68458. * @hidden Internal
  68459. */
  68460. _updateEffects(): void;
  68461. /**
  68462. * Internal
  68463. * @returns if all the contained post processes are ready.
  68464. * @hidden
  68465. */
  68466. _isReady(): boolean;
  68467. }
  68468. }
  68469. declare module BABYLON {
  68470. /** @hidden */
  68471. export var displayPassPixelShader: {
  68472. name: string;
  68473. shader: string;
  68474. };
  68475. }
  68476. declare module BABYLON {
  68477. /**
  68478. * DisplayPassPostProcess which produces an output the same as it's input
  68479. */
  68480. export class DisplayPassPostProcess extends PostProcess {
  68481. /**
  68482. * Creates the DisplayPassPostProcess
  68483. * @param name The name of the effect.
  68484. * @param options The required width/height ratio to downsize to before computing the render pass.
  68485. * @param camera The camera to apply the render pass to.
  68486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68487. * @param engine The engine which the post process will be applied. (default: current engine)
  68488. * @param reusable If the post process can be reused on the same frame. (default: false)
  68489. */
  68490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68491. }
  68492. }
  68493. declare module BABYLON {
  68494. /** @hidden */
  68495. export var filterPixelShader: {
  68496. name: string;
  68497. shader: string;
  68498. };
  68499. }
  68500. declare module BABYLON {
  68501. /**
  68502. * Applies a kernel filter to the image
  68503. */
  68504. export class FilterPostProcess extends PostProcess {
  68505. /** The matrix to be applied to the image */
  68506. kernelMatrix: Matrix;
  68507. /**
  68508. *
  68509. * @param name The name of the effect.
  68510. * @param kernelMatrix The matrix to be applied to the image
  68511. * @param options The required width/height ratio to downsize to before computing the render pass.
  68512. * @param camera The camera to apply the render pass to.
  68513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68514. * @param engine The engine which the post process will be applied. (default: current engine)
  68515. * @param reusable If the post process can be reused on the same frame. (default: false)
  68516. */
  68517. constructor(name: string,
  68518. /** The matrix to be applied to the image */
  68519. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68520. }
  68521. }
  68522. declare module BABYLON {
  68523. /** @hidden */
  68524. export var fxaaPixelShader: {
  68525. name: string;
  68526. shader: string;
  68527. };
  68528. }
  68529. declare module BABYLON {
  68530. /** @hidden */
  68531. export var fxaaVertexShader: {
  68532. name: string;
  68533. shader: string;
  68534. };
  68535. }
  68536. declare module BABYLON {
  68537. /**
  68538. * Fxaa post process
  68539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68540. */
  68541. export class FxaaPostProcess extends PostProcess {
  68542. /** @hidden */
  68543. texelWidth: number;
  68544. /** @hidden */
  68545. texelHeight: number;
  68546. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68547. private _getDefines;
  68548. }
  68549. }
  68550. declare module BABYLON {
  68551. /** @hidden */
  68552. export var grainPixelShader: {
  68553. name: string;
  68554. shader: string;
  68555. };
  68556. }
  68557. declare module BABYLON {
  68558. /**
  68559. * The GrainPostProcess adds noise to the image at mid luminance levels
  68560. */
  68561. export class GrainPostProcess extends PostProcess {
  68562. /**
  68563. * The intensity of the grain added (default: 30)
  68564. */
  68565. intensity: number;
  68566. /**
  68567. * If the grain should be randomized on every frame
  68568. */
  68569. animated: boolean;
  68570. /**
  68571. * Creates a new instance of @see GrainPostProcess
  68572. * @param name The name of the effect.
  68573. * @param options The required width/height ratio to downsize to before computing the render pass.
  68574. * @param camera The camera to apply the render pass to.
  68575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68576. * @param engine The engine which the post process will be applied. (default: current engine)
  68577. * @param reusable If the post process can be reused on the same frame. (default: false)
  68578. * @param textureType Type of textures used when performing the post process. (default: 0)
  68579. * @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)
  68580. */
  68581. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68582. }
  68583. }
  68584. declare module BABYLON {
  68585. /** @hidden */
  68586. export var highlightsPixelShader: {
  68587. name: string;
  68588. shader: string;
  68589. };
  68590. }
  68591. declare module BABYLON {
  68592. /**
  68593. * Extracts highlights from the image
  68594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68595. */
  68596. export class HighlightsPostProcess extends PostProcess {
  68597. /**
  68598. * Extracts highlights from the image
  68599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68600. * @param name The name of the effect.
  68601. * @param options The required width/height ratio to downsize to before computing the render pass.
  68602. * @param camera The camera to apply the render pass to.
  68603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68604. * @param engine The engine which the post process will be applied. (default: current engine)
  68605. * @param reusable If the post process can be reused on the same frame. (default: false)
  68606. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68607. */
  68608. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68609. }
  68610. }
  68611. declare module BABYLON {
  68612. /** @hidden */
  68613. export var mrtFragmentDeclaration: {
  68614. name: string;
  68615. shader: string;
  68616. };
  68617. }
  68618. declare module BABYLON {
  68619. /** @hidden */
  68620. export var geometryPixelShader: {
  68621. name: string;
  68622. shader: string;
  68623. };
  68624. }
  68625. declare module BABYLON {
  68626. /** @hidden */
  68627. export var geometryVertexShader: {
  68628. name: string;
  68629. shader: string;
  68630. };
  68631. }
  68632. declare module BABYLON {
  68633. /** @hidden */
  68634. interface ISavedTransformationMatrix {
  68635. world: Matrix;
  68636. viewProjection: Matrix;
  68637. }
  68638. /**
  68639. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68640. */
  68641. export class GeometryBufferRenderer {
  68642. /**
  68643. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68644. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68645. */
  68646. static readonly POSITION_TEXTURE_TYPE: number;
  68647. /**
  68648. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68649. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68650. */
  68651. static readonly VELOCITY_TEXTURE_TYPE: number;
  68652. /**
  68653. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68654. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68655. */
  68656. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68657. /**
  68658. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68659. * in order to compute objects velocities when enableVelocity is set to "true"
  68660. * @hidden
  68661. */
  68662. _previousTransformationMatrices: {
  68663. [index: number]: ISavedTransformationMatrix;
  68664. };
  68665. /**
  68666. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68667. * in order to compute objects velocities when enableVelocity is set to "true"
  68668. * @hidden
  68669. */
  68670. _previousBonesTransformationMatrices: {
  68671. [index: number]: Float32Array;
  68672. };
  68673. /**
  68674. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68675. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68676. */
  68677. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68678. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68679. renderTransparentMeshes: boolean;
  68680. private _scene;
  68681. private _multiRenderTarget;
  68682. private _ratio;
  68683. private _enablePosition;
  68684. private _enableVelocity;
  68685. private _enableReflectivity;
  68686. private _positionIndex;
  68687. private _velocityIndex;
  68688. private _reflectivityIndex;
  68689. protected _effect: Effect;
  68690. protected _cachedDefines: string;
  68691. /**
  68692. * Set the render list (meshes to be rendered) used in the G buffer.
  68693. */
  68694. set renderList(meshes: Mesh[]);
  68695. /**
  68696. * Gets wether or not G buffer are supported by the running hardware.
  68697. * This requires draw buffer supports
  68698. */
  68699. get isSupported(): boolean;
  68700. /**
  68701. * Returns the index of the given texture type in the G-Buffer textures array
  68702. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68703. * @returns the index of the given texture type in the G-Buffer textures array
  68704. */
  68705. getTextureIndex(textureType: number): number;
  68706. /**
  68707. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68708. */
  68709. get enablePosition(): boolean;
  68710. /**
  68711. * Sets whether or not objects positions are enabled for the G buffer.
  68712. */
  68713. set enablePosition(enable: boolean);
  68714. /**
  68715. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68716. */
  68717. get enableVelocity(): boolean;
  68718. /**
  68719. * Sets wether or not objects velocities are enabled for the G buffer.
  68720. */
  68721. set enableVelocity(enable: boolean);
  68722. /**
  68723. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68724. */
  68725. get enableReflectivity(): boolean;
  68726. /**
  68727. * Sets wether or not objects roughness are enabled for the G buffer.
  68728. */
  68729. set enableReflectivity(enable: boolean);
  68730. /**
  68731. * Gets the scene associated with the buffer.
  68732. */
  68733. get scene(): Scene;
  68734. /**
  68735. * Gets the ratio used by the buffer during its creation.
  68736. * How big is the buffer related to the main canvas.
  68737. */
  68738. get ratio(): number;
  68739. /** @hidden */
  68740. static _SceneComponentInitialization: (scene: Scene) => void;
  68741. /**
  68742. * Creates a new G Buffer for the scene
  68743. * @param scene The scene the buffer belongs to
  68744. * @param ratio How big is the buffer related to the main canvas.
  68745. */
  68746. constructor(scene: Scene, ratio?: number);
  68747. /**
  68748. * Checks wether everything is ready to render a submesh to the G buffer.
  68749. * @param subMesh the submesh to check readiness for
  68750. * @param useInstances is the mesh drawn using instance or not
  68751. * @returns true if ready otherwise false
  68752. */
  68753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68754. /**
  68755. * Gets the current underlying G Buffer.
  68756. * @returns the buffer
  68757. */
  68758. getGBuffer(): MultiRenderTarget;
  68759. /**
  68760. * Gets the number of samples used to render the buffer (anti aliasing).
  68761. */
  68762. get samples(): number;
  68763. /**
  68764. * Sets the number of samples used to render the buffer (anti aliasing).
  68765. */
  68766. set samples(value: number);
  68767. /**
  68768. * Disposes the renderer and frees up associated resources.
  68769. */
  68770. dispose(): void;
  68771. protected _createRenderTargets(): void;
  68772. private _copyBonesTransformationMatrices;
  68773. }
  68774. }
  68775. declare module BABYLON {
  68776. interface Scene {
  68777. /** @hidden (Backing field) */
  68778. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68779. /**
  68780. * Gets or Sets the current geometry buffer associated to the scene.
  68781. */
  68782. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68783. /**
  68784. * Enables a GeometryBufferRender and associates it with the scene
  68785. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68786. * @returns the GeometryBufferRenderer
  68787. */
  68788. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68789. /**
  68790. * Disables the GeometryBufferRender associated with the scene
  68791. */
  68792. disableGeometryBufferRenderer(): void;
  68793. }
  68794. /**
  68795. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68796. * in several rendering techniques.
  68797. */
  68798. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68799. /**
  68800. * The component name helpful to identify the component in the list of scene components.
  68801. */
  68802. readonly name: string;
  68803. /**
  68804. * The scene the component belongs to.
  68805. */
  68806. scene: Scene;
  68807. /**
  68808. * Creates a new instance of the component for the given scene
  68809. * @param scene Defines the scene to register the component in
  68810. */
  68811. constructor(scene: Scene);
  68812. /**
  68813. * Registers the component in a given scene
  68814. */
  68815. register(): void;
  68816. /**
  68817. * Rebuilds the elements related to this component in case of
  68818. * context lost for instance.
  68819. */
  68820. rebuild(): void;
  68821. /**
  68822. * Disposes the component and the associated ressources
  68823. */
  68824. dispose(): void;
  68825. private _gatherRenderTargets;
  68826. }
  68827. }
  68828. declare module BABYLON {
  68829. /** @hidden */
  68830. export var motionBlurPixelShader: {
  68831. name: string;
  68832. shader: string;
  68833. };
  68834. }
  68835. declare module BABYLON {
  68836. /**
  68837. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68838. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68839. * As an example, all you have to do is to create the post-process:
  68840. * var mb = new BABYLON.MotionBlurPostProcess(
  68841. * 'mb', // The name of the effect.
  68842. * scene, // The scene containing the objects to blur according to their velocity.
  68843. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68844. * camera // The camera to apply the render pass to.
  68845. * );
  68846. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68847. */
  68848. export class MotionBlurPostProcess extends PostProcess {
  68849. /**
  68850. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68851. */
  68852. motionStrength: number;
  68853. /**
  68854. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68855. */
  68856. get motionBlurSamples(): number;
  68857. /**
  68858. * Sets the number of iterations to be used for motion blur quality
  68859. */
  68860. set motionBlurSamples(samples: number);
  68861. private _motionBlurSamples;
  68862. private _geometryBufferRenderer;
  68863. /**
  68864. * Creates a new instance MotionBlurPostProcess
  68865. * @param name The name of the effect.
  68866. * @param scene The scene containing the objects to blur according to their velocity.
  68867. * @param options The required width/height ratio to downsize to before computing the render pass.
  68868. * @param camera The camera to apply the render pass to.
  68869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68870. * @param engine The engine which the post process will be applied. (default: current engine)
  68871. * @param reusable If the post process can be reused on the same frame. (default: false)
  68872. * @param textureType Type of textures used when performing the post process. (default: 0)
  68873. * @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)
  68874. */
  68875. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68876. /**
  68877. * Excludes the given skinned mesh from computing bones velocities.
  68878. * 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.
  68879. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68880. */
  68881. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68882. /**
  68883. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68884. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68885. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68886. */
  68887. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68888. /**
  68889. * Disposes the post process.
  68890. * @param camera The camera to dispose the post process on.
  68891. */
  68892. dispose(camera?: Camera): void;
  68893. }
  68894. }
  68895. declare module BABYLON {
  68896. /** @hidden */
  68897. export var refractionPixelShader: {
  68898. name: string;
  68899. shader: string;
  68900. };
  68901. }
  68902. declare module BABYLON {
  68903. /**
  68904. * Post process which applies a refractin texture
  68905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68906. */
  68907. export class RefractionPostProcess extends PostProcess {
  68908. /** the base color of the refraction (used to taint the rendering) */
  68909. color: Color3;
  68910. /** simulated refraction depth */
  68911. depth: number;
  68912. /** the coefficient of the base color (0 to remove base color tainting) */
  68913. colorLevel: number;
  68914. private _refTexture;
  68915. private _ownRefractionTexture;
  68916. /**
  68917. * Gets or sets the refraction texture
  68918. * Please note that you are responsible for disposing the texture if you set it manually
  68919. */
  68920. get refractionTexture(): Texture;
  68921. set refractionTexture(value: Texture);
  68922. /**
  68923. * Initializes the RefractionPostProcess
  68924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68925. * @param name The name of the effect.
  68926. * @param refractionTextureUrl Url of the refraction texture to use
  68927. * @param color the base color of the refraction (used to taint the rendering)
  68928. * @param depth simulated refraction depth
  68929. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68930. * @param camera The camera to apply the render pass to.
  68931. * @param options The required width/height ratio to downsize to before computing the render pass.
  68932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68933. * @param engine The engine which the post process will be applied. (default: current engine)
  68934. * @param reusable If the post process can be reused on the same frame. (default: false)
  68935. */
  68936. constructor(name: string, refractionTextureUrl: string,
  68937. /** the base color of the refraction (used to taint the rendering) */
  68938. color: Color3,
  68939. /** simulated refraction depth */
  68940. depth: number,
  68941. /** the coefficient of the base color (0 to remove base color tainting) */
  68942. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68943. /**
  68944. * Disposes of the post process
  68945. * @param camera Camera to dispose post process on
  68946. */
  68947. dispose(camera: Camera): void;
  68948. }
  68949. }
  68950. declare module BABYLON {
  68951. /** @hidden */
  68952. export var sharpenPixelShader: {
  68953. name: string;
  68954. shader: string;
  68955. };
  68956. }
  68957. declare module BABYLON {
  68958. /**
  68959. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68960. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68961. */
  68962. export class SharpenPostProcess extends PostProcess {
  68963. /**
  68964. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68965. */
  68966. colorAmount: number;
  68967. /**
  68968. * How much sharpness should be applied (default: 0.3)
  68969. */
  68970. edgeAmount: number;
  68971. /**
  68972. * Creates a new instance ConvolutionPostProcess
  68973. * @param name The name of the effect.
  68974. * @param options The required width/height ratio to downsize to before computing the render pass.
  68975. * @param camera The camera to apply the render pass to.
  68976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68977. * @param engine The engine which the post process will be applied. (default: current engine)
  68978. * @param reusable If the post process can be reused on the same frame. (default: false)
  68979. * @param textureType Type of textures used when performing the post process. (default: 0)
  68980. * @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)
  68981. */
  68982. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68983. }
  68984. }
  68985. declare module BABYLON {
  68986. /**
  68987. * PostProcessRenderPipeline
  68988. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68989. */
  68990. export class PostProcessRenderPipeline {
  68991. private engine;
  68992. private _renderEffects;
  68993. private _renderEffectsForIsolatedPass;
  68994. /**
  68995. * List of inspectable custom properties (used by the Inspector)
  68996. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68997. */
  68998. inspectableCustomProperties: IInspectable[];
  68999. /**
  69000. * @hidden
  69001. */
  69002. protected _cameras: Camera[];
  69003. /** @hidden */
  69004. _name: string;
  69005. /**
  69006. * Gets pipeline name
  69007. */
  69008. get name(): string;
  69009. /** Gets the list of attached cameras */
  69010. get cameras(): Camera[];
  69011. /**
  69012. * Initializes a PostProcessRenderPipeline
  69013. * @param engine engine to add the pipeline to
  69014. * @param name name of the pipeline
  69015. */
  69016. constructor(engine: Engine, name: string);
  69017. /**
  69018. * Gets the class name
  69019. * @returns "PostProcessRenderPipeline"
  69020. */
  69021. getClassName(): string;
  69022. /**
  69023. * If all the render effects in the pipeline are supported
  69024. */
  69025. get isSupported(): boolean;
  69026. /**
  69027. * Adds an effect to the pipeline
  69028. * @param renderEffect the effect to add
  69029. */
  69030. addEffect(renderEffect: PostProcessRenderEffect): void;
  69031. /** @hidden */
  69032. _rebuild(): void;
  69033. /** @hidden */
  69034. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69035. /** @hidden */
  69036. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69037. /** @hidden */
  69038. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69039. /** @hidden */
  69040. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69041. /** @hidden */
  69042. _attachCameras(cameras: Camera, unique: boolean): void;
  69043. /** @hidden */
  69044. _attachCameras(cameras: Camera[], unique: boolean): void;
  69045. /** @hidden */
  69046. _detachCameras(cameras: Camera): void;
  69047. /** @hidden */
  69048. _detachCameras(cameras: Nullable<Camera[]>): void;
  69049. /** @hidden */
  69050. _update(): void;
  69051. /** @hidden */
  69052. _reset(): void;
  69053. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69054. /**
  69055. * Disposes of the pipeline
  69056. */
  69057. dispose(): void;
  69058. }
  69059. }
  69060. declare module BABYLON {
  69061. /**
  69062. * PostProcessRenderPipelineManager class
  69063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69064. */
  69065. export class PostProcessRenderPipelineManager {
  69066. private _renderPipelines;
  69067. /**
  69068. * Initializes a PostProcessRenderPipelineManager
  69069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69070. */
  69071. constructor();
  69072. /**
  69073. * Gets the list of supported render pipelines
  69074. */
  69075. get supportedPipelines(): PostProcessRenderPipeline[];
  69076. /**
  69077. * Adds a pipeline to the manager
  69078. * @param renderPipeline The pipeline to add
  69079. */
  69080. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69081. /**
  69082. * Attaches a camera to the pipeline
  69083. * @param renderPipelineName The name of the pipeline to attach to
  69084. * @param cameras the camera to attach
  69085. * @param unique if the camera can be attached multiple times to the pipeline
  69086. */
  69087. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69088. /**
  69089. * Detaches a camera from the pipeline
  69090. * @param renderPipelineName The name of the pipeline to detach from
  69091. * @param cameras the camera to detach
  69092. */
  69093. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69094. /**
  69095. * Enables an effect by name on a pipeline
  69096. * @param renderPipelineName the name of the pipeline to enable the effect in
  69097. * @param renderEffectName the name of the effect to enable
  69098. * @param cameras the cameras that the effect should be enabled on
  69099. */
  69100. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69101. /**
  69102. * Disables an effect by name on a pipeline
  69103. * @param renderPipelineName the name of the pipeline to disable the effect in
  69104. * @param renderEffectName the name of the effect to disable
  69105. * @param cameras the cameras that the effect should be disabled on
  69106. */
  69107. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69108. /**
  69109. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69110. */
  69111. update(): void;
  69112. /** @hidden */
  69113. _rebuild(): void;
  69114. /**
  69115. * Disposes of the manager and pipelines
  69116. */
  69117. dispose(): void;
  69118. }
  69119. }
  69120. declare module BABYLON {
  69121. interface Scene {
  69122. /** @hidden (Backing field) */
  69123. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69124. /**
  69125. * Gets the postprocess render pipeline manager
  69126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69127. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69128. */
  69129. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69130. }
  69131. /**
  69132. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69133. */
  69134. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69135. /**
  69136. * The component name helpfull to identify the component in the list of scene components.
  69137. */
  69138. readonly name: string;
  69139. /**
  69140. * The scene the component belongs to.
  69141. */
  69142. scene: Scene;
  69143. /**
  69144. * Creates a new instance of the component for the given scene
  69145. * @param scene Defines the scene to register the component in
  69146. */
  69147. constructor(scene: Scene);
  69148. /**
  69149. * Registers the component in a given scene
  69150. */
  69151. register(): void;
  69152. /**
  69153. * Rebuilds the elements related to this component in case of
  69154. * context lost for instance.
  69155. */
  69156. rebuild(): void;
  69157. /**
  69158. * Disposes the component and the associated ressources
  69159. */
  69160. dispose(): void;
  69161. private _gatherRenderTargets;
  69162. }
  69163. }
  69164. declare module BABYLON {
  69165. /**
  69166. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69167. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69168. */
  69169. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69170. private _scene;
  69171. private _camerasToBeAttached;
  69172. /**
  69173. * ID of the sharpen post process,
  69174. */
  69175. private readonly SharpenPostProcessId;
  69176. /**
  69177. * @ignore
  69178. * ID of the image processing post process;
  69179. */
  69180. readonly ImageProcessingPostProcessId: string;
  69181. /**
  69182. * @ignore
  69183. * ID of the Fast Approximate Anti-Aliasing post process;
  69184. */
  69185. readonly FxaaPostProcessId: string;
  69186. /**
  69187. * ID of the chromatic aberration post process,
  69188. */
  69189. private readonly ChromaticAberrationPostProcessId;
  69190. /**
  69191. * ID of the grain post process
  69192. */
  69193. private readonly GrainPostProcessId;
  69194. /**
  69195. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69196. */
  69197. sharpen: SharpenPostProcess;
  69198. private _sharpenEffect;
  69199. private bloom;
  69200. /**
  69201. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69202. */
  69203. depthOfField: DepthOfFieldEffect;
  69204. /**
  69205. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69206. */
  69207. fxaa: FxaaPostProcess;
  69208. /**
  69209. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69210. */
  69211. imageProcessing: ImageProcessingPostProcess;
  69212. /**
  69213. * Chromatic aberration post process which will shift rgb colors in the image
  69214. */
  69215. chromaticAberration: ChromaticAberrationPostProcess;
  69216. private _chromaticAberrationEffect;
  69217. /**
  69218. * Grain post process which add noise to the image
  69219. */
  69220. grain: GrainPostProcess;
  69221. private _grainEffect;
  69222. /**
  69223. * Glow post process which adds a glow to emissive areas of the image
  69224. */
  69225. private _glowLayer;
  69226. /**
  69227. * Animations which can be used to tweak settings over a period of time
  69228. */
  69229. animations: Animation[];
  69230. private _imageProcessingConfigurationObserver;
  69231. private _sharpenEnabled;
  69232. private _bloomEnabled;
  69233. private _depthOfFieldEnabled;
  69234. private _depthOfFieldBlurLevel;
  69235. private _fxaaEnabled;
  69236. private _imageProcessingEnabled;
  69237. private _defaultPipelineTextureType;
  69238. private _bloomScale;
  69239. private _chromaticAberrationEnabled;
  69240. private _grainEnabled;
  69241. private _buildAllowed;
  69242. /**
  69243. * Gets active scene
  69244. */
  69245. get scene(): Scene;
  69246. /**
  69247. * Enable or disable the sharpen process from the pipeline
  69248. */
  69249. set sharpenEnabled(enabled: boolean);
  69250. get sharpenEnabled(): boolean;
  69251. private _resizeObserver;
  69252. private _hardwareScaleLevel;
  69253. private _bloomKernel;
  69254. /**
  69255. * Specifies the size of the bloom blur kernel, relative to the final output size
  69256. */
  69257. get bloomKernel(): number;
  69258. set bloomKernel(value: number);
  69259. /**
  69260. * Specifies the weight of the bloom in the final rendering
  69261. */
  69262. private _bloomWeight;
  69263. /**
  69264. * Specifies the luma threshold for the area that will be blurred by the bloom
  69265. */
  69266. private _bloomThreshold;
  69267. private _hdr;
  69268. /**
  69269. * The strength of the bloom.
  69270. */
  69271. set bloomWeight(value: number);
  69272. get bloomWeight(): number;
  69273. /**
  69274. * The strength of the bloom.
  69275. */
  69276. set bloomThreshold(value: number);
  69277. get bloomThreshold(): number;
  69278. /**
  69279. * The scale of the bloom, lower value will provide better performance.
  69280. */
  69281. set bloomScale(value: number);
  69282. get bloomScale(): number;
  69283. /**
  69284. * Enable or disable the bloom from the pipeline
  69285. */
  69286. set bloomEnabled(enabled: boolean);
  69287. get bloomEnabled(): boolean;
  69288. private _rebuildBloom;
  69289. /**
  69290. * If the depth of field is enabled.
  69291. */
  69292. get depthOfFieldEnabled(): boolean;
  69293. set depthOfFieldEnabled(enabled: boolean);
  69294. /**
  69295. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69296. */
  69297. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69298. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69299. /**
  69300. * If the anti aliasing is enabled.
  69301. */
  69302. set fxaaEnabled(enabled: boolean);
  69303. get fxaaEnabled(): boolean;
  69304. private _samples;
  69305. /**
  69306. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69307. */
  69308. set samples(sampleCount: number);
  69309. get samples(): number;
  69310. /**
  69311. * If image processing is enabled.
  69312. */
  69313. set imageProcessingEnabled(enabled: boolean);
  69314. get imageProcessingEnabled(): boolean;
  69315. /**
  69316. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69317. */
  69318. set glowLayerEnabled(enabled: boolean);
  69319. get glowLayerEnabled(): boolean;
  69320. /**
  69321. * Gets the glow layer (or null if not defined)
  69322. */
  69323. get glowLayer(): Nullable<GlowLayer>;
  69324. /**
  69325. * Enable or disable the chromaticAberration process from the pipeline
  69326. */
  69327. set chromaticAberrationEnabled(enabled: boolean);
  69328. get chromaticAberrationEnabled(): boolean;
  69329. /**
  69330. * Enable or disable the grain process from the pipeline
  69331. */
  69332. set grainEnabled(enabled: boolean);
  69333. get grainEnabled(): boolean;
  69334. /**
  69335. * @constructor
  69336. * @param name - The rendering pipeline name (default: "")
  69337. * @param hdr - If high dynamic range textures should be used (default: true)
  69338. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69339. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69340. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69341. */
  69342. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69343. /**
  69344. * Get the class name
  69345. * @returns "DefaultRenderingPipeline"
  69346. */
  69347. getClassName(): string;
  69348. /**
  69349. * Force the compilation of the entire pipeline.
  69350. */
  69351. prepare(): void;
  69352. private _hasCleared;
  69353. private _prevPostProcess;
  69354. private _prevPrevPostProcess;
  69355. private _setAutoClearAndTextureSharing;
  69356. private _depthOfFieldSceneObserver;
  69357. private _buildPipeline;
  69358. private _disposePostProcesses;
  69359. /**
  69360. * Adds a camera to the pipeline
  69361. * @param camera the camera to be added
  69362. */
  69363. addCamera(camera: Camera): void;
  69364. /**
  69365. * Removes a camera from the pipeline
  69366. * @param camera the camera to remove
  69367. */
  69368. removeCamera(camera: Camera): void;
  69369. /**
  69370. * Dispose of the pipeline and stop all post processes
  69371. */
  69372. dispose(): void;
  69373. /**
  69374. * Serialize the rendering pipeline (Used when exporting)
  69375. * @returns the serialized object
  69376. */
  69377. serialize(): any;
  69378. /**
  69379. * Parse the serialized pipeline
  69380. * @param source Source pipeline.
  69381. * @param scene The scene to load the pipeline to.
  69382. * @param rootUrl The URL of the serialized pipeline.
  69383. * @returns An instantiated pipeline from the serialized object.
  69384. */
  69385. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69386. }
  69387. }
  69388. declare module BABYLON {
  69389. /** @hidden */
  69390. export var lensHighlightsPixelShader: {
  69391. name: string;
  69392. shader: string;
  69393. };
  69394. }
  69395. declare module BABYLON {
  69396. /** @hidden */
  69397. export var depthOfFieldPixelShader: {
  69398. name: string;
  69399. shader: string;
  69400. };
  69401. }
  69402. declare module BABYLON {
  69403. /**
  69404. * BABYLON.JS Chromatic Aberration GLSL Shader
  69405. * Author: Olivier Guyot
  69406. * Separates very slightly R, G and B colors on the edges of the screen
  69407. * Inspired by Francois Tarlier & Martins Upitis
  69408. */
  69409. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69410. /**
  69411. * @ignore
  69412. * The chromatic aberration PostProcess id in the pipeline
  69413. */
  69414. LensChromaticAberrationEffect: string;
  69415. /**
  69416. * @ignore
  69417. * The highlights enhancing PostProcess id in the pipeline
  69418. */
  69419. HighlightsEnhancingEffect: string;
  69420. /**
  69421. * @ignore
  69422. * The depth-of-field PostProcess id in the pipeline
  69423. */
  69424. LensDepthOfFieldEffect: string;
  69425. private _scene;
  69426. private _depthTexture;
  69427. private _grainTexture;
  69428. private _chromaticAberrationPostProcess;
  69429. private _highlightsPostProcess;
  69430. private _depthOfFieldPostProcess;
  69431. private _edgeBlur;
  69432. private _grainAmount;
  69433. private _chromaticAberration;
  69434. private _distortion;
  69435. private _highlightsGain;
  69436. private _highlightsThreshold;
  69437. private _dofDistance;
  69438. private _dofAperture;
  69439. private _dofDarken;
  69440. private _dofPentagon;
  69441. private _blurNoise;
  69442. /**
  69443. * @constructor
  69444. *
  69445. * Effect parameters are as follow:
  69446. * {
  69447. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69448. * edge_blur: number; // from 0 to x (1 for realism)
  69449. * distortion: number; // from 0 to x (1 for realism)
  69450. * grain_amount: number; // from 0 to 1
  69451. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69452. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69453. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69454. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69455. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69456. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69457. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69458. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69459. * }
  69460. * Note: if an effect parameter is unset, effect is disabled
  69461. *
  69462. * @param name The rendering pipeline name
  69463. * @param parameters - An object containing all parameters (see above)
  69464. * @param scene The scene linked to this pipeline
  69465. * @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)
  69466. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69467. */
  69468. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69469. /**
  69470. * Get the class name
  69471. * @returns "LensRenderingPipeline"
  69472. */
  69473. getClassName(): string;
  69474. /**
  69475. * Gets associated scene
  69476. */
  69477. get scene(): Scene;
  69478. /**
  69479. * Gets or sets the edge blur
  69480. */
  69481. get edgeBlur(): number;
  69482. set edgeBlur(value: number);
  69483. /**
  69484. * Gets or sets the grain amount
  69485. */
  69486. get grainAmount(): number;
  69487. set grainAmount(value: number);
  69488. /**
  69489. * Gets or sets the chromatic aberration amount
  69490. */
  69491. get chromaticAberration(): number;
  69492. set chromaticAberration(value: number);
  69493. /**
  69494. * Gets or sets the depth of field aperture
  69495. */
  69496. get dofAperture(): number;
  69497. set dofAperture(value: number);
  69498. /**
  69499. * Gets or sets the edge distortion
  69500. */
  69501. get edgeDistortion(): number;
  69502. set edgeDistortion(value: number);
  69503. /**
  69504. * Gets or sets the depth of field distortion
  69505. */
  69506. get dofDistortion(): number;
  69507. set dofDistortion(value: number);
  69508. /**
  69509. * Gets or sets the darken out of focus amount
  69510. */
  69511. get darkenOutOfFocus(): number;
  69512. set darkenOutOfFocus(value: number);
  69513. /**
  69514. * Gets or sets a boolean indicating if blur noise is enabled
  69515. */
  69516. get blurNoise(): boolean;
  69517. set blurNoise(value: boolean);
  69518. /**
  69519. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69520. */
  69521. get pentagonBokeh(): boolean;
  69522. set pentagonBokeh(value: boolean);
  69523. /**
  69524. * Gets or sets the highlight grain amount
  69525. */
  69526. get highlightsGain(): number;
  69527. set highlightsGain(value: number);
  69528. /**
  69529. * Gets or sets the highlight threshold
  69530. */
  69531. get highlightsThreshold(): number;
  69532. set highlightsThreshold(value: number);
  69533. /**
  69534. * Sets the amount of blur at the edges
  69535. * @param amount blur amount
  69536. */
  69537. setEdgeBlur(amount: number): void;
  69538. /**
  69539. * Sets edge blur to 0
  69540. */
  69541. disableEdgeBlur(): void;
  69542. /**
  69543. * Sets the amout of grain
  69544. * @param amount Amount of grain
  69545. */
  69546. setGrainAmount(amount: number): void;
  69547. /**
  69548. * Set grain amount to 0
  69549. */
  69550. disableGrain(): void;
  69551. /**
  69552. * Sets the chromatic aberration amount
  69553. * @param amount amount of chromatic aberration
  69554. */
  69555. setChromaticAberration(amount: number): void;
  69556. /**
  69557. * Sets chromatic aberration amount to 0
  69558. */
  69559. disableChromaticAberration(): void;
  69560. /**
  69561. * Sets the EdgeDistortion amount
  69562. * @param amount amount of EdgeDistortion
  69563. */
  69564. setEdgeDistortion(amount: number): void;
  69565. /**
  69566. * Sets edge distortion to 0
  69567. */
  69568. disableEdgeDistortion(): void;
  69569. /**
  69570. * Sets the FocusDistance amount
  69571. * @param amount amount of FocusDistance
  69572. */
  69573. setFocusDistance(amount: number): void;
  69574. /**
  69575. * Disables depth of field
  69576. */
  69577. disableDepthOfField(): void;
  69578. /**
  69579. * Sets the Aperture amount
  69580. * @param amount amount of Aperture
  69581. */
  69582. setAperture(amount: number): void;
  69583. /**
  69584. * Sets the DarkenOutOfFocus amount
  69585. * @param amount amount of DarkenOutOfFocus
  69586. */
  69587. setDarkenOutOfFocus(amount: number): void;
  69588. private _pentagonBokehIsEnabled;
  69589. /**
  69590. * Creates a pentagon bokeh effect
  69591. */
  69592. enablePentagonBokeh(): void;
  69593. /**
  69594. * Disables the pentagon bokeh effect
  69595. */
  69596. disablePentagonBokeh(): void;
  69597. /**
  69598. * Enables noise blur
  69599. */
  69600. enableNoiseBlur(): void;
  69601. /**
  69602. * Disables noise blur
  69603. */
  69604. disableNoiseBlur(): void;
  69605. /**
  69606. * Sets the HighlightsGain amount
  69607. * @param amount amount of HighlightsGain
  69608. */
  69609. setHighlightsGain(amount: number): void;
  69610. /**
  69611. * Sets the HighlightsThreshold amount
  69612. * @param amount amount of HighlightsThreshold
  69613. */
  69614. setHighlightsThreshold(amount: number): void;
  69615. /**
  69616. * Disables highlights
  69617. */
  69618. disableHighlights(): void;
  69619. /**
  69620. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69621. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69622. */
  69623. dispose(disableDepthRender?: boolean): void;
  69624. private _createChromaticAberrationPostProcess;
  69625. private _createHighlightsPostProcess;
  69626. private _createDepthOfFieldPostProcess;
  69627. private _createGrainTexture;
  69628. }
  69629. }
  69630. declare module BABYLON {
  69631. /** @hidden */
  69632. export var ssao2PixelShader: {
  69633. name: string;
  69634. shader: string;
  69635. };
  69636. }
  69637. declare module BABYLON {
  69638. /** @hidden */
  69639. export var ssaoCombinePixelShader: {
  69640. name: string;
  69641. shader: string;
  69642. };
  69643. }
  69644. declare module BABYLON {
  69645. /**
  69646. * Render pipeline to produce ssao effect
  69647. */
  69648. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69649. /**
  69650. * @ignore
  69651. * The PassPostProcess id in the pipeline that contains the original scene color
  69652. */
  69653. SSAOOriginalSceneColorEffect: string;
  69654. /**
  69655. * @ignore
  69656. * The SSAO PostProcess id in the pipeline
  69657. */
  69658. SSAORenderEffect: string;
  69659. /**
  69660. * @ignore
  69661. * The horizontal blur PostProcess id in the pipeline
  69662. */
  69663. SSAOBlurHRenderEffect: string;
  69664. /**
  69665. * @ignore
  69666. * The vertical blur PostProcess id in the pipeline
  69667. */
  69668. SSAOBlurVRenderEffect: string;
  69669. /**
  69670. * @ignore
  69671. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69672. */
  69673. SSAOCombineRenderEffect: string;
  69674. /**
  69675. * The output strength of the SSAO post-process. Default value is 1.0.
  69676. */
  69677. totalStrength: number;
  69678. /**
  69679. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69680. */
  69681. maxZ: number;
  69682. /**
  69683. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69684. */
  69685. minZAspect: number;
  69686. private _samples;
  69687. /**
  69688. * Number of samples used for the SSAO calculations. Default value is 8
  69689. */
  69690. set samples(n: number);
  69691. get samples(): number;
  69692. private _textureSamples;
  69693. /**
  69694. * Number of samples to use for antialiasing
  69695. */
  69696. set textureSamples(n: number);
  69697. get textureSamples(): number;
  69698. /**
  69699. * Ratio object used for SSAO ratio and blur ratio
  69700. */
  69701. private _ratio;
  69702. /**
  69703. * Dynamically generated sphere sampler.
  69704. */
  69705. private _sampleSphere;
  69706. /**
  69707. * Blur filter offsets
  69708. */
  69709. private _samplerOffsets;
  69710. private _expensiveBlur;
  69711. /**
  69712. * If bilateral blur should be used
  69713. */
  69714. set expensiveBlur(b: boolean);
  69715. get expensiveBlur(): boolean;
  69716. /**
  69717. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69718. */
  69719. radius: number;
  69720. /**
  69721. * The base color of the SSAO post-process
  69722. * The final result is "base + ssao" between [0, 1]
  69723. */
  69724. base: number;
  69725. /**
  69726. * Support test.
  69727. */
  69728. static get IsSupported(): boolean;
  69729. private _scene;
  69730. private _depthTexture;
  69731. private _normalTexture;
  69732. private _randomTexture;
  69733. private _originalColorPostProcess;
  69734. private _ssaoPostProcess;
  69735. private _blurHPostProcess;
  69736. private _blurVPostProcess;
  69737. private _ssaoCombinePostProcess;
  69738. /**
  69739. * Gets active scene
  69740. */
  69741. get scene(): Scene;
  69742. /**
  69743. * @constructor
  69744. * @param name The rendering pipeline name
  69745. * @param scene The scene linked to this pipeline
  69746. * @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 }
  69747. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69748. */
  69749. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69750. /**
  69751. * Get the class name
  69752. * @returns "SSAO2RenderingPipeline"
  69753. */
  69754. getClassName(): string;
  69755. /**
  69756. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69757. */
  69758. dispose(disableGeometryBufferRenderer?: boolean): void;
  69759. private _createBlurPostProcess;
  69760. /** @hidden */
  69761. _rebuild(): void;
  69762. private _bits;
  69763. private _radicalInverse_VdC;
  69764. private _hammersley;
  69765. private _hemisphereSample_uniform;
  69766. private _generateHemisphere;
  69767. private _createSSAOPostProcess;
  69768. private _createSSAOCombinePostProcess;
  69769. private _createRandomTexture;
  69770. /**
  69771. * Serialize the rendering pipeline (Used when exporting)
  69772. * @returns the serialized object
  69773. */
  69774. serialize(): any;
  69775. /**
  69776. * Parse the serialized pipeline
  69777. * @param source Source pipeline.
  69778. * @param scene The scene to load the pipeline to.
  69779. * @param rootUrl The URL of the serialized pipeline.
  69780. * @returns An instantiated pipeline from the serialized object.
  69781. */
  69782. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69783. }
  69784. }
  69785. declare module BABYLON {
  69786. /** @hidden */
  69787. export var ssaoPixelShader: {
  69788. name: string;
  69789. shader: string;
  69790. };
  69791. }
  69792. declare module BABYLON {
  69793. /**
  69794. * Render pipeline to produce ssao effect
  69795. */
  69796. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69797. /**
  69798. * @ignore
  69799. * The PassPostProcess id in the pipeline that contains the original scene color
  69800. */
  69801. SSAOOriginalSceneColorEffect: string;
  69802. /**
  69803. * @ignore
  69804. * The SSAO PostProcess id in the pipeline
  69805. */
  69806. SSAORenderEffect: string;
  69807. /**
  69808. * @ignore
  69809. * The horizontal blur PostProcess id in the pipeline
  69810. */
  69811. SSAOBlurHRenderEffect: string;
  69812. /**
  69813. * @ignore
  69814. * The vertical blur PostProcess id in the pipeline
  69815. */
  69816. SSAOBlurVRenderEffect: string;
  69817. /**
  69818. * @ignore
  69819. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69820. */
  69821. SSAOCombineRenderEffect: string;
  69822. /**
  69823. * The output strength of the SSAO post-process. Default value is 1.0.
  69824. */
  69825. totalStrength: number;
  69826. /**
  69827. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69828. */
  69829. radius: number;
  69830. /**
  69831. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69832. * Must not be equal to fallOff and superior to fallOff.
  69833. * Default value is 0.0075
  69834. */
  69835. area: number;
  69836. /**
  69837. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69838. * Must not be equal to area and inferior to area.
  69839. * Default value is 0.000001
  69840. */
  69841. fallOff: number;
  69842. /**
  69843. * The base color of the SSAO post-process
  69844. * The final result is "base + ssao" between [0, 1]
  69845. */
  69846. base: number;
  69847. private _scene;
  69848. private _depthTexture;
  69849. private _randomTexture;
  69850. private _originalColorPostProcess;
  69851. private _ssaoPostProcess;
  69852. private _blurHPostProcess;
  69853. private _blurVPostProcess;
  69854. private _ssaoCombinePostProcess;
  69855. private _firstUpdate;
  69856. /**
  69857. * Gets active scene
  69858. */
  69859. get scene(): Scene;
  69860. /**
  69861. * @constructor
  69862. * @param name - The rendering pipeline name
  69863. * @param scene - The scene linked to this pipeline
  69864. * @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 }
  69865. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69866. */
  69867. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69868. /**
  69869. * Get the class name
  69870. * @returns "SSAORenderingPipeline"
  69871. */
  69872. getClassName(): string;
  69873. /**
  69874. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69875. */
  69876. dispose(disableDepthRender?: boolean): void;
  69877. private _createBlurPostProcess;
  69878. /** @hidden */
  69879. _rebuild(): void;
  69880. private _createSSAOPostProcess;
  69881. private _createSSAOCombinePostProcess;
  69882. private _createRandomTexture;
  69883. }
  69884. }
  69885. declare module BABYLON {
  69886. /** @hidden */
  69887. export var screenSpaceReflectionPixelShader: {
  69888. name: string;
  69889. shader: string;
  69890. };
  69891. }
  69892. declare module BABYLON {
  69893. /**
  69894. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69895. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69896. */
  69897. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69898. /**
  69899. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69900. */
  69901. threshold: number;
  69902. /**
  69903. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69904. */
  69905. strength: number;
  69906. /**
  69907. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69908. */
  69909. reflectionSpecularFalloffExponent: number;
  69910. /**
  69911. * 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]
  69912. */
  69913. step: number;
  69914. /**
  69915. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69916. */
  69917. roughnessFactor: number;
  69918. private _geometryBufferRenderer;
  69919. private _enableSmoothReflections;
  69920. private _reflectionSamples;
  69921. private _smoothSteps;
  69922. /**
  69923. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69924. * @param name The name of the effect.
  69925. * @param scene The scene containing the objects to calculate reflections.
  69926. * @param options The required width/height ratio to downsize to before computing the render pass.
  69927. * @param camera The camera to apply the render pass to.
  69928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69929. * @param engine The engine which the post process will be applied. (default: current engine)
  69930. * @param reusable If the post process can be reused on the same frame. (default: false)
  69931. * @param textureType Type of textures used when performing the post process. (default: 0)
  69932. * @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)
  69933. */
  69934. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69935. /**
  69936. * Gets wether or not smoothing reflections is enabled.
  69937. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69938. */
  69939. get enableSmoothReflections(): boolean;
  69940. /**
  69941. * Sets wether or not smoothing reflections is enabled.
  69942. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69943. */
  69944. set enableSmoothReflections(enabled: boolean);
  69945. /**
  69946. * Gets the number of samples taken while computing reflections. More samples count is high,
  69947. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69948. */
  69949. get reflectionSamples(): number;
  69950. /**
  69951. * Sets the number of samples taken while computing reflections. More samples count is high,
  69952. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69953. */
  69954. set reflectionSamples(samples: number);
  69955. /**
  69956. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69957. * more the post-process will require GPU power and can generate a drop in FPS.
  69958. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69959. */
  69960. get smoothSteps(): number;
  69961. set smoothSteps(steps: number);
  69962. private _updateEffectDefines;
  69963. }
  69964. }
  69965. declare module BABYLON {
  69966. /** @hidden */
  69967. export var standardPixelShader: {
  69968. name: string;
  69969. shader: string;
  69970. };
  69971. }
  69972. declare module BABYLON {
  69973. /**
  69974. * Standard rendering pipeline
  69975. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69976. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69977. */
  69978. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69979. /**
  69980. * Public members
  69981. */
  69982. /**
  69983. * Post-process which contains the original scene color before the pipeline applies all the effects
  69984. */
  69985. originalPostProcess: Nullable<PostProcess>;
  69986. /**
  69987. * Post-process used to down scale an image x4
  69988. */
  69989. downSampleX4PostProcess: Nullable<PostProcess>;
  69990. /**
  69991. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69992. */
  69993. brightPassPostProcess: Nullable<PostProcess>;
  69994. /**
  69995. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69996. */
  69997. blurHPostProcesses: PostProcess[];
  69998. /**
  69999. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70000. */
  70001. blurVPostProcesses: PostProcess[];
  70002. /**
  70003. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70004. */
  70005. textureAdderPostProcess: Nullable<PostProcess>;
  70006. /**
  70007. * Post-process used to create volumetric lighting effect
  70008. */
  70009. volumetricLightPostProcess: Nullable<PostProcess>;
  70010. /**
  70011. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70012. */
  70013. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70014. /**
  70015. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70016. */
  70017. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70018. /**
  70019. * Post-process used to merge the volumetric light effect and the real scene color
  70020. */
  70021. volumetricLightMergePostProces: Nullable<PostProcess>;
  70022. /**
  70023. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70024. */
  70025. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70026. /**
  70027. * Base post-process used to calculate the average luminance of the final image for HDR
  70028. */
  70029. luminancePostProcess: Nullable<PostProcess>;
  70030. /**
  70031. * Post-processes used to create down sample post-processes in order to get
  70032. * the average luminance of the final image for HDR
  70033. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70034. */
  70035. luminanceDownSamplePostProcesses: PostProcess[];
  70036. /**
  70037. * Post-process used to create a HDR effect (light adaptation)
  70038. */
  70039. hdrPostProcess: Nullable<PostProcess>;
  70040. /**
  70041. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70042. */
  70043. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70044. /**
  70045. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70046. */
  70047. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70048. /**
  70049. * Post-process used to merge the final HDR post-process and the real scene color
  70050. */
  70051. hdrFinalPostProcess: Nullable<PostProcess>;
  70052. /**
  70053. * Post-process used to create a lens flare effect
  70054. */
  70055. lensFlarePostProcess: Nullable<PostProcess>;
  70056. /**
  70057. * Post-process that merges the result of the lens flare post-process and the real scene color
  70058. */
  70059. lensFlareComposePostProcess: Nullable<PostProcess>;
  70060. /**
  70061. * Post-process used to create a motion blur effect
  70062. */
  70063. motionBlurPostProcess: Nullable<PostProcess>;
  70064. /**
  70065. * Post-process used to create a depth of field effect
  70066. */
  70067. depthOfFieldPostProcess: Nullable<PostProcess>;
  70068. /**
  70069. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70070. */
  70071. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70072. /**
  70073. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70074. */
  70075. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70076. /**
  70077. * Represents the brightness threshold in order to configure the illuminated surfaces
  70078. */
  70079. brightThreshold: number;
  70080. /**
  70081. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70082. */
  70083. blurWidth: number;
  70084. /**
  70085. * Sets if the blur for highlighted surfaces must be only horizontal
  70086. */
  70087. horizontalBlur: boolean;
  70088. /**
  70089. * Gets the overall exposure used by the pipeline
  70090. */
  70091. get exposure(): number;
  70092. /**
  70093. * Sets the overall exposure used by the pipeline
  70094. */
  70095. set exposure(value: number);
  70096. /**
  70097. * Texture used typically to simulate "dirty" on camera lens
  70098. */
  70099. lensTexture: Nullable<Texture>;
  70100. /**
  70101. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70102. */
  70103. volumetricLightCoefficient: number;
  70104. /**
  70105. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70106. */
  70107. volumetricLightPower: number;
  70108. /**
  70109. * Used the set the blur intensity to smooth the volumetric lights
  70110. */
  70111. volumetricLightBlurScale: number;
  70112. /**
  70113. * Light (spot or directional) used to generate the volumetric lights rays
  70114. * The source light must have a shadow generate so the pipeline can get its
  70115. * depth map
  70116. */
  70117. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70118. /**
  70119. * For eye adaptation, represents the minimum luminance the eye can see
  70120. */
  70121. hdrMinimumLuminance: number;
  70122. /**
  70123. * For eye adaptation, represents the decrease luminance speed
  70124. */
  70125. hdrDecreaseRate: number;
  70126. /**
  70127. * For eye adaptation, represents the increase luminance speed
  70128. */
  70129. hdrIncreaseRate: number;
  70130. /**
  70131. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70132. */
  70133. get hdrAutoExposure(): boolean;
  70134. /**
  70135. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70136. */
  70137. set hdrAutoExposure(value: boolean);
  70138. /**
  70139. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70140. */
  70141. lensColorTexture: Nullable<Texture>;
  70142. /**
  70143. * The overall strengh for the lens flare effect
  70144. */
  70145. lensFlareStrength: number;
  70146. /**
  70147. * Dispersion coefficient for lens flare ghosts
  70148. */
  70149. lensFlareGhostDispersal: number;
  70150. /**
  70151. * Main lens flare halo width
  70152. */
  70153. lensFlareHaloWidth: number;
  70154. /**
  70155. * Based on the lens distortion effect, defines how much the lens flare result
  70156. * is distorted
  70157. */
  70158. lensFlareDistortionStrength: number;
  70159. /**
  70160. * Configures the blur intensity used for for lens flare (halo)
  70161. */
  70162. lensFlareBlurWidth: number;
  70163. /**
  70164. * Lens star texture must be used to simulate rays on the flares and is available
  70165. * in the documentation
  70166. */
  70167. lensStarTexture: Nullable<Texture>;
  70168. /**
  70169. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70170. * flare effect by taking account of the dirt texture
  70171. */
  70172. lensFlareDirtTexture: Nullable<Texture>;
  70173. /**
  70174. * Represents the focal length for the depth of field effect
  70175. */
  70176. depthOfFieldDistance: number;
  70177. /**
  70178. * Represents the blur intensity for the blurred part of the depth of field effect
  70179. */
  70180. depthOfFieldBlurWidth: number;
  70181. /**
  70182. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70183. */
  70184. get motionStrength(): number;
  70185. /**
  70186. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70187. */
  70188. set motionStrength(strength: number);
  70189. /**
  70190. * Gets wether or not the motion blur post-process is object based or screen based.
  70191. */
  70192. get objectBasedMotionBlur(): boolean;
  70193. /**
  70194. * Sets wether or not the motion blur post-process should be object based or screen based
  70195. */
  70196. set objectBasedMotionBlur(value: boolean);
  70197. /**
  70198. * List of animations for the pipeline (IAnimatable implementation)
  70199. */
  70200. animations: Animation[];
  70201. /**
  70202. * Private members
  70203. */
  70204. private _scene;
  70205. private _currentDepthOfFieldSource;
  70206. private _basePostProcess;
  70207. private _fixedExposure;
  70208. private _currentExposure;
  70209. private _hdrAutoExposure;
  70210. private _hdrCurrentLuminance;
  70211. private _motionStrength;
  70212. private _isObjectBasedMotionBlur;
  70213. private _floatTextureType;
  70214. private _camerasToBeAttached;
  70215. private _ratio;
  70216. private _bloomEnabled;
  70217. private _depthOfFieldEnabled;
  70218. private _vlsEnabled;
  70219. private _lensFlareEnabled;
  70220. private _hdrEnabled;
  70221. private _motionBlurEnabled;
  70222. private _fxaaEnabled;
  70223. private _screenSpaceReflectionsEnabled;
  70224. private _motionBlurSamples;
  70225. private _volumetricLightStepsCount;
  70226. private _samples;
  70227. /**
  70228. * @ignore
  70229. * Specifies if the bloom pipeline is enabled
  70230. */
  70231. get BloomEnabled(): boolean;
  70232. set BloomEnabled(enabled: boolean);
  70233. /**
  70234. * @ignore
  70235. * Specifies if the depth of field pipeline is enabed
  70236. */
  70237. get DepthOfFieldEnabled(): boolean;
  70238. set DepthOfFieldEnabled(enabled: boolean);
  70239. /**
  70240. * @ignore
  70241. * Specifies if the lens flare pipeline is enabed
  70242. */
  70243. get LensFlareEnabled(): boolean;
  70244. set LensFlareEnabled(enabled: boolean);
  70245. /**
  70246. * @ignore
  70247. * Specifies if the HDR pipeline is enabled
  70248. */
  70249. get HDREnabled(): boolean;
  70250. set HDREnabled(enabled: boolean);
  70251. /**
  70252. * @ignore
  70253. * Specifies if the volumetric lights scattering effect is enabled
  70254. */
  70255. get VLSEnabled(): boolean;
  70256. set VLSEnabled(enabled: boolean);
  70257. /**
  70258. * @ignore
  70259. * Specifies if the motion blur effect is enabled
  70260. */
  70261. get MotionBlurEnabled(): boolean;
  70262. set MotionBlurEnabled(enabled: boolean);
  70263. /**
  70264. * Specifies if anti-aliasing is enabled
  70265. */
  70266. get fxaaEnabled(): boolean;
  70267. set fxaaEnabled(enabled: boolean);
  70268. /**
  70269. * Specifies if screen space reflections are enabled.
  70270. */
  70271. get screenSpaceReflectionsEnabled(): boolean;
  70272. set screenSpaceReflectionsEnabled(enabled: boolean);
  70273. /**
  70274. * Specifies the number of steps used to calculate the volumetric lights
  70275. * Typically in interval [50, 200]
  70276. */
  70277. get volumetricLightStepsCount(): number;
  70278. set volumetricLightStepsCount(count: number);
  70279. /**
  70280. * Specifies the number of samples used for the motion blur effect
  70281. * Typically in interval [16, 64]
  70282. */
  70283. get motionBlurSamples(): number;
  70284. set motionBlurSamples(samples: number);
  70285. /**
  70286. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70287. */
  70288. get samples(): number;
  70289. set samples(sampleCount: number);
  70290. /**
  70291. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70292. * @constructor
  70293. * @param name The rendering pipeline name
  70294. * @param scene The scene linked to this pipeline
  70295. * @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)
  70296. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70297. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70298. */
  70299. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70300. private _buildPipeline;
  70301. private _createDownSampleX4PostProcess;
  70302. private _createBrightPassPostProcess;
  70303. private _createBlurPostProcesses;
  70304. private _createTextureAdderPostProcess;
  70305. private _createVolumetricLightPostProcess;
  70306. private _createLuminancePostProcesses;
  70307. private _createHdrPostProcess;
  70308. private _createLensFlarePostProcess;
  70309. private _createDepthOfFieldPostProcess;
  70310. private _createMotionBlurPostProcess;
  70311. private _getDepthTexture;
  70312. private _disposePostProcesses;
  70313. /**
  70314. * Dispose of the pipeline and stop all post processes
  70315. */
  70316. dispose(): void;
  70317. /**
  70318. * Serialize the rendering pipeline (Used when exporting)
  70319. * @returns the serialized object
  70320. */
  70321. serialize(): any;
  70322. /**
  70323. * Parse the serialized pipeline
  70324. * @param source Source pipeline.
  70325. * @param scene The scene to load the pipeline to.
  70326. * @param rootUrl The URL of the serialized pipeline.
  70327. * @returns An instantiated pipeline from the serialized object.
  70328. */
  70329. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70330. /**
  70331. * Luminance steps
  70332. */
  70333. static LuminanceSteps: number;
  70334. }
  70335. }
  70336. declare module BABYLON {
  70337. /** @hidden */
  70338. export var stereoscopicInterlacePixelShader: {
  70339. name: string;
  70340. shader: string;
  70341. };
  70342. }
  70343. declare module BABYLON {
  70344. /**
  70345. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70346. */
  70347. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70348. private _stepSize;
  70349. private _passedProcess;
  70350. /**
  70351. * Initializes a StereoscopicInterlacePostProcessI
  70352. * @param name The name of the effect.
  70353. * @param rigCameras The rig cameras to be appled to the post process
  70354. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70355. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70357. * @param engine The engine which the post process will be applied. (default: current engine)
  70358. * @param reusable If the post process can be reused on the same frame. (default: false)
  70359. */
  70360. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70361. }
  70362. /**
  70363. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70364. */
  70365. export class StereoscopicInterlacePostProcess extends PostProcess {
  70366. private _stepSize;
  70367. private _passedProcess;
  70368. /**
  70369. * Initializes a StereoscopicInterlacePostProcess
  70370. * @param name The name of the effect.
  70371. * @param rigCameras The rig cameras to be appled to the post process
  70372. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70374. * @param engine The engine which the post process will be applied. (default: current engine)
  70375. * @param reusable If the post process can be reused on the same frame. (default: false)
  70376. */
  70377. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70378. }
  70379. }
  70380. declare module BABYLON {
  70381. /** @hidden */
  70382. export var tonemapPixelShader: {
  70383. name: string;
  70384. shader: string;
  70385. };
  70386. }
  70387. declare module BABYLON {
  70388. /** Defines operator used for tonemapping */
  70389. export enum TonemappingOperator {
  70390. /** Hable */
  70391. Hable = 0,
  70392. /** Reinhard */
  70393. Reinhard = 1,
  70394. /** HejiDawson */
  70395. HejiDawson = 2,
  70396. /** Photographic */
  70397. Photographic = 3
  70398. }
  70399. /**
  70400. * Defines a post process to apply tone mapping
  70401. */
  70402. export class TonemapPostProcess extends PostProcess {
  70403. private _operator;
  70404. /** Defines the required exposure adjustement */
  70405. exposureAdjustment: number;
  70406. /**
  70407. * Creates a new TonemapPostProcess
  70408. * @param name defines the name of the postprocess
  70409. * @param _operator defines the operator to use
  70410. * @param exposureAdjustment defines the required exposure adjustement
  70411. * @param camera defines the camera to use (can be null)
  70412. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70413. * @param engine defines the hosting engine (can be ignore if camera is set)
  70414. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70415. */
  70416. constructor(name: string, _operator: TonemappingOperator,
  70417. /** Defines the required exposure adjustement */
  70418. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70419. }
  70420. }
  70421. declare module BABYLON {
  70422. /** @hidden */
  70423. export var volumetricLightScatteringPixelShader: {
  70424. name: string;
  70425. shader: string;
  70426. };
  70427. }
  70428. declare module BABYLON {
  70429. /** @hidden */
  70430. export var volumetricLightScatteringPassVertexShader: {
  70431. name: string;
  70432. shader: string;
  70433. };
  70434. }
  70435. declare module BABYLON {
  70436. /** @hidden */
  70437. export var volumetricLightScatteringPassPixelShader: {
  70438. name: string;
  70439. shader: string;
  70440. };
  70441. }
  70442. declare module BABYLON {
  70443. /**
  70444. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70445. */
  70446. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70447. private _volumetricLightScatteringPass;
  70448. private _volumetricLightScatteringRTT;
  70449. private _viewPort;
  70450. private _screenCoordinates;
  70451. private _cachedDefines;
  70452. /**
  70453. * If not undefined, the mesh position is computed from the attached node position
  70454. */
  70455. attachedNode: {
  70456. position: Vector3;
  70457. };
  70458. /**
  70459. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70460. */
  70461. customMeshPosition: Vector3;
  70462. /**
  70463. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70464. */
  70465. useCustomMeshPosition: boolean;
  70466. /**
  70467. * If the post-process should inverse the light scattering direction
  70468. */
  70469. invert: boolean;
  70470. /**
  70471. * The internal mesh used by the post-process
  70472. */
  70473. mesh: Mesh;
  70474. /**
  70475. * @hidden
  70476. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70477. */
  70478. get useDiffuseColor(): boolean;
  70479. set useDiffuseColor(useDiffuseColor: boolean);
  70480. /**
  70481. * Array containing the excluded meshes not rendered in the internal pass
  70482. */
  70483. excludedMeshes: AbstractMesh[];
  70484. /**
  70485. * Controls the overall intensity of the post-process
  70486. */
  70487. exposure: number;
  70488. /**
  70489. * Dissipates each sample's contribution in range [0, 1]
  70490. */
  70491. decay: number;
  70492. /**
  70493. * Controls the overall intensity of each sample
  70494. */
  70495. weight: number;
  70496. /**
  70497. * Controls the density of each sample
  70498. */
  70499. density: number;
  70500. /**
  70501. * @constructor
  70502. * @param name The post-process name
  70503. * @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)
  70504. * @param camera The camera that the post-process will be attached to
  70505. * @param mesh The mesh used to create the light scattering
  70506. * @param samples The post-process quality, default 100
  70507. * @param samplingModeThe post-process filtering mode
  70508. * @param engine The babylon engine
  70509. * @param reusable If the post-process is reusable
  70510. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70511. */
  70512. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70513. /**
  70514. * Returns the string "VolumetricLightScatteringPostProcess"
  70515. * @returns "VolumetricLightScatteringPostProcess"
  70516. */
  70517. getClassName(): string;
  70518. private _isReady;
  70519. /**
  70520. * Sets the new light position for light scattering effect
  70521. * @param position The new custom light position
  70522. */
  70523. setCustomMeshPosition(position: Vector3): void;
  70524. /**
  70525. * Returns the light position for light scattering effect
  70526. * @return Vector3 The custom light position
  70527. */
  70528. getCustomMeshPosition(): Vector3;
  70529. /**
  70530. * Disposes the internal assets and detaches the post-process from the camera
  70531. */
  70532. dispose(camera: Camera): void;
  70533. /**
  70534. * Returns the render target texture used by the post-process
  70535. * @return the render target texture used by the post-process
  70536. */
  70537. getPass(): RenderTargetTexture;
  70538. private _meshExcluded;
  70539. private _createPass;
  70540. private _updateMeshScreenCoordinates;
  70541. /**
  70542. * Creates a default mesh for the Volumeric Light Scattering post-process
  70543. * @param name The mesh name
  70544. * @param scene The scene where to create the mesh
  70545. * @return the default mesh
  70546. */
  70547. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70548. }
  70549. }
  70550. declare module BABYLON {
  70551. interface Scene {
  70552. /** @hidden (Backing field) */
  70553. _boundingBoxRenderer: BoundingBoxRenderer;
  70554. /** @hidden (Backing field) */
  70555. _forceShowBoundingBoxes: boolean;
  70556. /**
  70557. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70558. */
  70559. forceShowBoundingBoxes: boolean;
  70560. /**
  70561. * Gets the bounding box renderer associated with the scene
  70562. * @returns a BoundingBoxRenderer
  70563. */
  70564. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70565. }
  70566. interface AbstractMesh {
  70567. /** @hidden (Backing field) */
  70568. _showBoundingBox: boolean;
  70569. /**
  70570. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70571. */
  70572. showBoundingBox: boolean;
  70573. }
  70574. /**
  70575. * Component responsible of rendering the bounding box of the meshes in a scene.
  70576. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70577. */
  70578. export class BoundingBoxRenderer implements ISceneComponent {
  70579. /**
  70580. * The component name helpfull to identify the component in the list of scene components.
  70581. */
  70582. readonly name: string;
  70583. /**
  70584. * The scene the component belongs to.
  70585. */
  70586. scene: Scene;
  70587. /**
  70588. * Color of the bounding box lines placed in front of an object
  70589. */
  70590. frontColor: Color3;
  70591. /**
  70592. * Color of the bounding box lines placed behind an object
  70593. */
  70594. backColor: Color3;
  70595. /**
  70596. * Defines if the renderer should show the back lines or not
  70597. */
  70598. showBackLines: boolean;
  70599. /**
  70600. * Observable raised before rendering a bounding box
  70601. */
  70602. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70603. /**
  70604. * Observable raised after rendering a bounding box
  70605. */
  70606. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70607. /**
  70608. * @hidden
  70609. */
  70610. renderList: SmartArray<BoundingBox>;
  70611. private _colorShader;
  70612. private _vertexBuffers;
  70613. private _indexBuffer;
  70614. private _fillIndexBuffer;
  70615. private _fillIndexData;
  70616. /**
  70617. * Instantiates a new bounding box renderer in a scene.
  70618. * @param scene the scene the renderer renders in
  70619. */
  70620. constructor(scene: Scene);
  70621. /**
  70622. * Registers the component in a given scene
  70623. */
  70624. register(): void;
  70625. private _evaluateSubMesh;
  70626. private _activeMesh;
  70627. private _prepareRessources;
  70628. private _createIndexBuffer;
  70629. /**
  70630. * Rebuilds the elements related to this component in case of
  70631. * context lost for instance.
  70632. */
  70633. rebuild(): void;
  70634. /**
  70635. * @hidden
  70636. */
  70637. reset(): void;
  70638. /**
  70639. * Render the bounding boxes of a specific rendering group
  70640. * @param renderingGroupId defines the rendering group to render
  70641. */
  70642. render(renderingGroupId: number): void;
  70643. /**
  70644. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70645. * @param mesh Define the mesh to render the occlusion bounding box for
  70646. */
  70647. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70648. /**
  70649. * Dispose and release the resources attached to this renderer.
  70650. */
  70651. dispose(): void;
  70652. }
  70653. }
  70654. declare module BABYLON {
  70655. interface Scene {
  70656. /** @hidden (Backing field) */
  70657. _depthRenderer: {
  70658. [id: string]: DepthRenderer;
  70659. };
  70660. /**
  70661. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70662. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70663. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70664. * @returns the created depth renderer
  70665. */
  70666. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70667. /**
  70668. * Disables a depth renderer for a given camera
  70669. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70670. */
  70671. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70672. }
  70673. /**
  70674. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70675. * in several rendering techniques.
  70676. */
  70677. export class DepthRendererSceneComponent implements ISceneComponent {
  70678. /**
  70679. * The component name helpfull to identify the component in the list of scene components.
  70680. */
  70681. readonly name: string;
  70682. /**
  70683. * The scene the component belongs to.
  70684. */
  70685. scene: Scene;
  70686. /**
  70687. * Creates a new instance of the component for the given scene
  70688. * @param scene Defines the scene to register the component in
  70689. */
  70690. constructor(scene: Scene);
  70691. /**
  70692. * Registers the component in a given scene
  70693. */
  70694. register(): void;
  70695. /**
  70696. * Rebuilds the elements related to this component in case of
  70697. * context lost for instance.
  70698. */
  70699. rebuild(): void;
  70700. /**
  70701. * Disposes the component and the associated ressources
  70702. */
  70703. dispose(): void;
  70704. private _gatherRenderTargets;
  70705. private _gatherActiveCameraRenderTargets;
  70706. }
  70707. }
  70708. declare module BABYLON {
  70709. /** @hidden */
  70710. export var fibonacci: {
  70711. name: string;
  70712. shader: string;
  70713. };
  70714. }
  70715. declare module BABYLON {
  70716. /** @hidden */
  70717. export var diffusionProfile: {
  70718. name: string;
  70719. shader: string;
  70720. };
  70721. }
  70722. declare module BABYLON {
  70723. /** @hidden */
  70724. export var subSurfaceScatteringPixelShader: {
  70725. name: string;
  70726. shader: string;
  70727. };
  70728. }
  70729. declare module BABYLON {
  70730. /**
  70731. * Sub surface scattering post process
  70732. */
  70733. export class SubSurfaceScatteringPostProcess extends PostProcess {
  70734. /** @hidden */
  70735. texelWidth: number;
  70736. /** @hidden */
  70737. texelHeight: number;
  70738. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70739. }
  70740. }
  70741. declare module BABYLON {
  70742. /**
  70743. * Contains all parameters needed for the prepass to perform
  70744. * screen space subsurface scattering
  70745. */
  70746. export class SubSurfaceConfiguration {
  70747. private _ssDiffusionS;
  70748. private _ssFilterRadii;
  70749. private _ssDiffusionD;
  70750. /**
  70751. * Diffusion profile color for subsurface scattering
  70752. */
  70753. get ssDiffusionS(): number[];
  70754. /**
  70755. * Diffusion profile max color channel value for subsurface scattering
  70756. */
  70757. get ssDiffusionD(): number[];
  70758. /**
  70759. * Diffusion profile filter radius for subsurface scattering
  70760. */
  70761. get ssFilterRadii(): number[];
  70762. /**
  70763. * Diffusion profile colors for subsurface scattering
  70764. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  70765. * See ...
  70766. * Note that you can only store up to 5 of them
  70767. */
  70768. ssDiffusionProfileColors: Color3[];
  70769. /**
  70770. * Defines the ratio real world => scene units.
  70771. * Used for subsurface scattering
  70772. */
  70773. metersPerUnit: number;
  70774. /**
  70775. * Builds a subsurface configuration object
  70776. * @param scene The scene
  70777. */
  70778. constructor();
  70779. /**
  70780. * Adds a new diffusion profile.
  70781. * Useful for more realistic subsurface scattering on diverse materials.
  70782. * @param color The color of the diffusion profile. Should be the average color of the material.
  70783. * @return The index of the diffusion profile for the material subsurface configuration
  70784. */
  70785. addDiffusionProfile(color: Color3): number;
  70786. /**
  70787. * Deletes all diffusion profiles.
  70788. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  70789. */
  70790. clearAllDiffusionProfiles(): void;
  70791. /**
  70792. * Disposes this object
  70793. */
  70794. dispose(): void;
  70795. /**
  70796. * @hidden
  70797. * https://zero-radiance.github.io/post/sampling-diffusion/
  70798. *
  70799. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  70800. * ------------------------------------------------------------------------------------
  70801. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  70802. * PDF[r, phi, s] = r * R[r, phi, s]
  70803. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  70804. * ------------------------------------------------------------------------------------
  70805. * We importance sample the color channel with the widest scattering distance.
  70806. */
  70807. getDiffusionProfileParameters(color: Color3): number;
  70808. /**
  70809. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  70810. * 'u' is the random number (the value of the CDF): [0, 1).
  70811. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  70812. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  70813. */
  70814. private _sampleBurleyDiffusionProfile;
  70815. }
  70816. }
  70817. declare module BABYLON {
  70818. /**
  70819. * Renders a pre pass of the scene
  70820. * This means every mesh in the scene will be rendered to a render target texture
  70821. * And then this texture will be composited to the rendering canvas with post processes
  70822. * It is necessary for effects like subsurface scattering or deferred shading
  70823. */
  70824. export class PrePassRenderer {
  70825. /** @hidden */
  70826. static _SceneComponentInitialization: (scene: Scene) => void;
  70827. private _scene;
  70828. private _engine;
  70829. private _isDirty;
  70830. /**
  70831. * Number of textures in the multi render target texture where the scene is directly rendered
  70832. */
  70833. readonly mrtCount: number;
  70834. /**
  70835. * The render target where the scene is directly rendered
  70836. */
  70837. prePassRT: MultiRenderTarget;
  70838. private _mrtTypes;
  70839. private _multiRenderAttachments;
  70840. private _defaultAttachments;
  70841. private _clearAttachments;
  70842. private readonly _clearColor;
  70843. /**
  70844. * Image processing post process for composition
  70845. */
  70846. imageProcessingPostProcess: ImageProcessingPostProcess;
  70847. /**
  70848. * Post process for subsurface scattering
  70849. */
  70850. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  70851. /**
  70852. * Configuration for sub surface scattering post process
  70853. */
  70854. subSurfaceConfiguration: SubSurfaceConfiguration;
  70855. private _enabled;
  70856. /**
  70857. * Indicates if the prepass is enabled
  70858. */
  70859. get enabled(): boolean;
  70860. /**
  70861. * How many samples are used for MSAA of the scene render target
  70862. */
  70863. get samples(): number;
  70864. set samples(n: number);
  70865. /**
  70866. * Instanciates a prepass renderer
  70867. * @param scene The scene
  70868. */
  70869. constructor(scene: Scene);
  70870. private _initializeAttachments;
  70871. private _createEffects;
  70872. /**
  70873. * Indicates if rendering a prepass is supported
  70874. */
  70875. get isSupported(): boolean;
  70876. /**
  70877. * Sets the proper output textures to draw in the engine.
  70878. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  70879. */
  70880. bindAttachmentsForEffect(effect: Effect): void;
  70881. /**
  70882. * @hidden
  70883. */
  70884. _beforeCameraDraw(): void;
  70885. /**
  70886. * @hidden
  70887. */
  70888. _afterCameraDraw(): void;
  70889. private _checkRTSize;
  70890. private _bindFrameBuffer;
  70891. /**
  70892. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  70893. */
  70894. clear(): void;
  70895. private _setState;
  70896. private _enable;
  70897. private _disable;
  70898. /**
  70899. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  70900. */
  70901. markAsDirty(): void;
  70902. private _update;
  70903. /**
  70904. * Disposes the prepass renderer.
  70905. */
  70906. dispose(): void;
  70907. }
  70908. }
  70909. declare module BABYLON {
  70910. interface AbstractScene {
  70911. /** @hidden (Backing field) */
  70912. _prePassRenderer: Nullable<PrePassRenderer>;
  70913. /**
  70914. * Gets or Sets the current prepass renderer associated to the scene.
  70915. */
  70916. prePassRenderer: Nullable<PrePassRenderer>;
  70917. /**
  70918. * Enables the prepass and associates it with the scene
  70919. * @returns the PrePassRenderer
  70920. */
  70921. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  70922. /**
  70923. * Disables the prepass associated with the scene
  70924. */
  70925. disablePrePassRenderer(): void;
  70926. }
  70927. /**
  70928. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70929. * in several rendering techniques.
  70930. */
  70931. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  70932. /**
  70933. * The component name helpful to identify the component in the list of scene components.
  70934. */
  70935. readonly name: string;
  70936. /**
  70937. * The scene the component belongs to.
  70938. */
  70939. scene: Scene;
  70940. /**
  70941. * Creates a new instance of the component for the given scene
  70942. * @param scene Defines the scene to register the component in
  70943. */
  70944. constructor(scene: Scene);
  70945. /**
  70946. * Registers the component in a given scene
  70947. */
  70948. register(): void;
  70949. private _beforeCameraDraw;
  70950. private _afterCameraDraw;
  70951. private _beforeClearStage;
  70952. /**
  70953. * Serializes the component data to the specified json object
  70954. * @param serializationObject The object to serialize to
  70955. */
  70956. serialize(serializationObject: any): void;
  70957. /**
  70958. * Adds all the elements from the container to the scene
  70959. * @param container the container holding the elements
  70960. */
  70961. addFromContainer(container: AbstractScene): void;
  70962. /**
  70963. * Removes all the elements in the container from the scene
  70964. * @param container contains the elements to remove
  70965. * @param dispose if the removed element should be disposed (default: false)
  70966. */
  70967. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70968. /**
  70969. * Rebuilds the elements related to this component in case of
  70970. * context lost for instance.
  70971. */
  70972. rebuild(): void;
  70973. /**
  70974. * Disposes the component and the associated ressources
  70975. */
  70976. dispose(): void;
  70977. }
  70978. }
  70979. declare module BABYLON {
  70980. /** @hidden */
  70981. export var outlinePixelShader: {
  70982. name: string;
  70983. shader: string;
  70984. };
  70985. }
  70986. declare module BABYLON {
  70987. /** @hidden */
  70988. export var outlineVertexShader: {
  70989. name: string;
  70990. shader: string;
  70991. };
  70992. }
  70993. declare module BABYLON {
  70994. interface Scene {
  70995. /** @hidden */
  70996. _outlineRenderer: OutlineRenderer;
  70997. /**
  70998. * Gets the outline renderer associated with the scene
  70999. * @returns a OutlineRenderer
  71000. */
  71001. getOutlineRenderer(): OutlineRenderer;
  71002. }
  71003. interface AbstractMesh {
  71004. /** @hidden (Backing field) */
  71005. _renderOutline: boolean;
  71006. /**
  71007. * Gets or sets a boolean indicating if the outline must be rendered as well
  71008. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71009. */
  71010. renderOutline: boolean;
  71011. /** @hidden (Backing field) */
  71012. _renderOverlay: boolean;
  71013. /**
  71014. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71015. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71016. */
  71017. renderOverlay: boolean;
  71018. }
  71019. /**
  71020. * This class is responsible to draw bothe outline/overlay of meshes.
  71021. * It should not be used directly but through the available method on mesh.
  71022. */
  71023. export class OutlineRenderer implements ISceneComponent {
  71024. /**
  71025. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71026. */
  71027. private static _StencilReference;
  71028. /**
  71029. * The name of the component. Each component must have a unique name.
  71030. */
  71031. name: string;
  71032. /**
  71033. * The scene the component belongs to.
  71034. */
  71035. scene: Scene;
  71036. /**
  71037. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71038. */
  71039. zOffset: number;
  71040. private _engine;
  71041. private _effect;
  71042. private _cachedDefines;
  71043. private _savedDepthWrite;
  71044. /**
  71045. * Instantiates a new outline renderer. (There could be only one per scene).
  71046. * @param scene Defines the scene it belongs to
  71047. */
  71048. constructor(scene: Scene);
  71049. /**
  71050. * Register the component to one instance of a scene.
  71051. */
  71052. register(): void;
  71053. /**
  71054. * Rebuilds the elements related to this component in case of
  71055. * context lost for instance.
  71056. */
  71057. rebuild(): void;
  71058. /**
  71059. * Disposes the component and the associated ressources.
  71060. */
  71061. dispose(): void;
  71062. /**
  71063. * Renders the outline in the canvas.
  71064. * @param subMesh Defines the sumesh to render
  71065. * @param batch Defines the batch of meshes in case of instances
  71066. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71067. */
  71068. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71069. /**
  71070. * Returns whether or not the outline renderer is ready for a given submesh.
  71071. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71072. * @param subMesh Defines the submesh to check readyness for
  71073. * @param useInstances Defines wheter wee are trying to render instances or not
  71074. * @returns true if ready otherwise false
  71075. */
  71076. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71077. private _beforeRenderingMesh;
  71078. private _afterRenderingMesh;
  71079. }
  71080. }
  71081. declare module BABYLON {
  71082. /**
  71083. * Defines the basic options interface of a Sprite Frame Source Size.
  71084. */
  71085. export interface ISpriteJSONSpriteSourceSize {
  71086. /**
  71087. * number of the original width of the Frame
  71088. */
  71089. w: number;
  71090. /**
  71091. * number of the original height of the Frame
  71092. */
  71093. h: number;
  71094. }
  71095. /**
  71096. * Defines the basic options interface of a Sprite Frame Data.
  71097. */
  71098. export interface ISpriteJSONSpriteFrameData {
  71099. /**
  71100. * number of the x offset of the Frame
  71101. */
  71102. x: number;
  71103. /**
  71104. * number of the y offset of the Frame
  71105. */
  71106. y: number;
  71107. /**
  71108. * number of the width of the Frame
  71109. */
  71110. w: number;
  71111. /**
  71112. * number of the height of the Frame
  71113. */
  71114. h: number;
  71115. }
  71116. /**
  71117. * Defines the basic options interface of a JSON Sprite.
  71118. */
  71119. export interface ISpriteJSONSprite {
  71120. /**
  71121. * string name of the Frame
  71122. */
  71123. filename: string;
  71124. /**
  71125. * ISpriteJSONSpriteFrame basic object of the frame data
  71126. */
  71127. frame: ISpriteJSONSpriteFrameData;
  71128. /**
  71129. * boolean to flag is the frame was rotated.
  71130. */
  71131. rotated: boolean;
  71132. /**
  71133. * boolean to flag is the frame was trimmed.
  71134. */
  71135. trimmed: boolean;
  71136. /**
  71137. * ISpriteJSONSpriteFrame basic object of the source data
  71138. */
  71139. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71140. /**
  71141. * ISpriteJSONSpriteFrame basic object of the source data
  71142. */
  71143. sourceSize: ISpriteJSONSpriteSourceSize;
  71144. }
  71145. /**
  71146. * Defines the basic options interface of a JSON atlas.
  71147. */
  71148. export interface ISpriteJSONAtlas {
  71149. /**
  71150. * Array of objects that contain the frame data.
  71151. */
  71152. frames: Array<ISpriteJSONSprite>;
  71153. /**
  71154. * object basic object containing the sprite meta data.
  71155. */
  71156. meta?: object;
  71157. }
  71158. }
  71159. declare module BABYLON {
  71160. /** @hidden */
  71161. export var spriteMapPixelShader: {
  71162. name: string;
  71163. shader: string;
  71164. };
  71165. }
  71166. declare module BABYLON {
  71167. /** @hidden */
  71168. export var spriteMapVertexShader: {
  71169. name: string;
  71170. shader: string;
  71171. };
  71172. }
  71173. declare module BABYLON {
  71174. /**
  71175. * Defines the basic options interface of a SpriteMap
  71176. */
  71177. export interface ISpriteMapOptions {
  71178. /**
  71179. * Vector2 of the number of cells in the grid.
  71180. */
  71181. stageSize?: Vector2;
  71182. /**
  71183. * Vector2 of the size of the output plane in World Units.
  71184. */
  71185. outputSize?: Vector2;
  71186. /**
  71187. * Vector3 of the position of the output plane in World Units.
  71188. */
  71189. outputPosition?: Vector3;
  71190. /**
  71191. * Vector3 of the rotation of the output plane.
  71192. */
  71193. outputRotation?: Vector3;
  71194. /**
  71195. * number of layers that the system will reserve in resources.
  71196. */
  71197. layerCount?: number;
  71198. /**
  71199. * number of max animation frames a single cell will reserve in resources.
  71200. */
  71201. maxAnimationFrames?: number;
  71202. /**
  71203. * number cell index of the base tile when the system compiles.
  71204. */
  71205. baseTile?: number;
  71206. /**
  71207. * boolean flip the sprite after its been repositioned by the framing data.
  71208. */
  71209. flipU?: boolean;
  71210. /**
  71211. * Vector3 scalar of the global RGB values of the SpriteMap.
  71212. */
  71213. colorMultiply?: Vector3;
  71214. }
  71215. /**
  71216. * Defines the IDisposable interface in order to be cleanable from resources.
  71217. */
  71218. export interface ISpriteMap extends IDisposable {
  71219. /**
  71220. * String name of the SpriteMap.
  71221. */
  71222. name: string;
  71223. /**
  71224. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71225. */
  71226. atlasJSON: ISpriteJSONAtlas;
  71227. /**
  71228. * Texture of the SpriteMap.
  71229. */
  71230. spriteSheet: Texture;
  71231. /**
  71232. * The parameters to initialize the SpriteMap with.
  71233. */
  71234. options: ISpriteMapOptions;
  71235. }
  71236. /**
  71237. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71238. */
  71239. export class SpriteMap implements ISpriteMap {
  71240. /** The Name of the spriteMap */
  71241. name: string;
  71242. /** The JSON file with the frame and meta data */
  71243. atlasJSON: ISpriteJSONAtlas;
  71244. /** The systems Sprite Sheet Texture */
  71245. spriteSheet: Texture;
  71246. /** Arguments passed with the Constructor */
  71247. options: ISpriteMapOptions;
  71248. /** Public Sprite Storage array, parsed from atlasJSON */
  71249. sprites: Array<ISpriteJSONSprite>;
  71250. /** Returns the Number of Sprites in the System */
  71251. get spriteCount(): number;
  71252. /** Returns the Position of Output Plane*/
  71253. get position(): Vector3;
  71254. /** Returns the Position of Output Plane*/
  71255. set position(v: Vector3);
  71256. /** Returns the Rotation of Output Plane*/
  71257. get rotation(): Vector3;
  71258. /** Returns the Rotation of Output Plane*/
  71259. set rotation(v: Vector3);
  71260. /** Sets the AnimationMap*/
  71261. get animationMap(): RawTexture;
  71262. /** Sets the AnimationMap*/
  71263. set animationMap(v: RawTexture);
  71264. /** Scene that the SpriteMap was created in */
  71265. private _scene;
  71266. /** Texture Buffer of Float32 that holds tile frame data*/
  71267. private _frameMap;
  71268. /** Texture Buffers of Float32 that holds tileMap data*/
  71269. private _tileMaps;
  71270. /** Texture Buffer of Float32 that holds Animation Data*/
  71271. private _animationMap;
  71272. /** Custom ShaderMaterial Central to the System*/
  71273. private _material;
  71274. /** Custom ShaderMaterial Central to the System*/
  71275. private _output;
  71276. /** Systems Time Ticker*/
  71277. private _time;
  71278. /**
  71279. * Creates a new SpriteMap
  71280. * @param name defines the SpriteMaps Name
  71281. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71282. * @param spriteSheet is the Texture that the Sprites are on.
  71283. * @param options a basic deployment configuration
  71284. * @param scene The Scene that the map is deployed on
  71285. */
  71286. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71287. /**
  71288. * Returns tileID location
  71289. * @returns Vector2 the cell position ID
  71290. */
  71291. getTileID(): Vector2;
  71292. /**
  71293. * Gets the UV location of the mouse over the SpriteMap.
  71294. * @returns Vector2 the UV position of the mouse interaction
  71295. */
  71296. getMousePosition(): Vector2;
  71297. /**
  71298. * Creates the "frame" texture Buffer
  71299. * -------------------------------------
  71300. * Structure of frames
  71301. * "filename": "Falling-Water-2.png",
  71302. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71303. * "rotated": true,
  71304. * "trimmed": true,
  71305. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71306. * "sourceSize": {"w":32,"h":32}
  71307. * @returns RawTexture of the frameMap
  71308. */
  71309. private _createFrameBuffer;
  71310. /**
  71311. * Creates the tileMap texture Buffer
  71312. * @param buffer normally and array of numbers, or a false to generate from scratch
  71313. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71314. * @returns RawTexture of the tileMap
  71315. */
  71316. private _createTileBuffer;
  71317. /**
  71318. * Modifies the data of the tileMaps
  71319. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71320. * @param pos is the iVector2 Coordinates of the Tile
  71321. * @param tile The SpriteIndex of the new Tile
  71322. */
  71323. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71324. /**
  71325. * Creates the animationMap texture Buffer
  71326. * @param buffer normally and array of numbers, or a false to generate from scratch
  71327. * @returns RawTexture of the animationMap
  71328. */
  71329. private _createTileAnimationBuffer;
  71330. /**
  71331. * Modifies the data of the animationMap
  71332. * @param cellID is the Index of the Sprite
  71333. * @param _frame is the target Animation frame
  71334. * @param toCell is the Target Index of the next frame of the animation
  71335. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71336. * @param speed is a global scalar of the time variable on the map.
  71337. */
  71338. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71339. /**
  71340. * Exports the .tilemaps file
  71341. */
  71342. saveTileMaps(): void;
  71343. /**
  71344. * Imports the .tilemaps file
  71345. * @param url of the .tilemaps file
  71346. */
  71347. loadTileMaps(url: string): void;
  71348. /**
  71349. * Release associated resources
  71350. */
  71351. dispose(): void;
  71352. }
  71353. }
  71354. declare module BABYLON {
  71355. /**
  71356. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71357. * @see https://doc.babylonjs.com/babylon101/sprites
  71358. */
  71359. export class SpritePackedManager extends SpriteManager {
  71360. /** defines the packed manager's name */
  71361. name: string;
  71362. /**
  71363. * Creates a new sprite manager from a packed sprite sheet
  71364. * @param name defines the manager's name
  71365. * @param imgUrl defines the sprite sheet url
  71366. * @param capacity defines the maximum allowed number of sprites
  71367. * @param scene defines the hosting scene
  71368. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71369. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71370. * @param samplingMode defines the smapling mode to use with spritesheet
  71371. * @param fromPacked set to true; do not alter
  71372. */
  71373. constructor(
  71374. /** defines the packed manager's name */
  71375. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71376. }
  71377. }
  71378. declare module BABYLON {
  71379. /**
  71380. * Defines the list of states available for a task inside a AssetsManager
  71381. */
  71382. export enum AssetTaskState {
  71383. /**
  71384. * Initialization
  71385. */
  71386. INIT = 0,
  71387. /**
  71388. * Running
  71389. */
  71390. RUNNING = 1,
  71391. /**
  71392. * Done
  71393. */
  71394. DONE = 2,
  71395. /**
  71396. * Error
  71397. */
  71398. ERROR = 3
  71399. }
  71400. /**
  71401. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71402. */
  71403. export abstract class AbstractAssetTask {
  71404. /**
  71405. * Task name
  71406. */ name: string;
  71407. /**
  71408. * Callback called when the task is successful
  71409. */
  71410. onSuccess: (task: any) => void;
  71411. /**
  71412. * Callback called when the task is not successful
  71413. */
  71414. onError: (task: any, message?: string, exception?: any) => void;
  71415. /**
  71416. * Creates a new AssetsManager
  71417. * @param name defines the name of the task
  71418. */
  71419. constructor(
  71420. /**
  71421. * Task name
  71422. */ name: string);
  71423. private _isCompleted;
  71424. private _taskState;
  71425. private _errorObject;
  71426. /**
  71427. * Get if the task is completed
  71428. */
  71429. get isCompleted(): boolean;
  71430. /**
  71431. * Gets the current state of the task
  71432. */
  71433. get taskState(): AssetTaskState;
  71434. /**
  71435. * Gets the current error object (if task is in error)
  71436. */
  71437. get errorObject(): {
  71438. message?: string;
  71439. exception?: any;
  71440. };
  71441. /**
  71442. * Internal only
  71443. * @hidden
  71444. */
  71445. _setErrorObject(message?: string, exception?: any): void;
  71446. /**
  71447. * Execute the current task
  71448. * @param scene defines the scene where you want your assets to be loaded
  71449. * @param onSuccess is a callback called when the task is successfully executed
  71450. * @param onError is a callback called if an error occurs
  71451. */
  71452. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71453. /**
  71454. * Execute the current task
  71455. * @param scene defines the scene where you want your assets to be loaded
  71456. * @param onSuccess is a callback called when the task is successfully executed
  71457. * @param onError is a callback called if an error occurs
  71458. */
  71459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71460. /**
  71461. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71462. * This can be used with failed tasks that have the reason for failure fixed.
  71463. */
  71464. reset(): void;
  71465. private onErrorCallback;
  71466. private onDoneCallback;
  71467. }
  71468. /**
  71469. * Define the interface used by progress events raised during assets loading
  71470. */
  71471. export interface IAssetsProgressEvent {
  71472. /**
  71473. * Defines the number of remaining tasks to process
  71474. */
  71475. remainingCount: number;
  71476. /**
  71477. * Defines the total number of tasks
  71478. */
  71479. totalCount: number;
  71480. /**
  71481. * Defines the task that was just processed
  71482. */
  71483. task: AbstractAssetTask;
  71484. }
  71485. /**
  71486. * Class used to share progress information about assets loading
  71487. */
  71488. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71489. /**
  71490. * Defines the number of remaining tasks to process
  71491. */
  71492. remainingCount: number;
  71493. /**
  71494. * Defines the total number of tasks
  71495. */
  71496. totalCount: number;
  71497. /**
  71498. * Defines the task that was just processed
  71499. */
  71500. task: AbstractAssetTask;
  71501. /**
  71502. * Creates a AssetsProgressEvent
  71503. * @param remainingCount defines the number of remaining tasks to process
  71504. * @param totalCount defines the total number of tasks
  71505. * @param task defines the task that was just processed
  71506. */
  71507. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71508. }
  71509. /**
  71510. * Define a task used by AssetsManager to load meshes
  71511. */
  71512. export class MeshAssetTask extends AbstractAssetTask {
  71513. /**
  71514. * Defines the name of the task
  71515. */
  71516. name: string;
  71517. /**
  71518. * Defines the list of mesh's names you want to load
  71519. */
  71520. meshesNames: any;
  71521. /**
  71522. * Defines the root url to use as a base to load your meshes and associated resources
  71523. */
  71524. rootUrl: string;
  71525. /**
  71526. * Defines the filename or File of the scene to load from
  71527. */
  71528. sceneFilename: string | File;
  71529. /**
  71530. * Gets the list of loaded meshes
  71531. */
  71532. loadedMeshes: Array<AbstractMesh>;
  71533. /**
  71534. * Gets the list of loaded particle systems
  71535. */
  71536. loadedParticleSystems: Array<IParticleSystem>;
  71537. /**
  71538. * Gets the list of loaded skeletons
  71539. */
  71540. loadedSkeletons: Array<Skeleton>;
  71541. /**
  71542. * Gets the list of loaded animation groups
  71543. */
  71544. loadedAnimationGroups: Array<AnimationGroup>;
  71545. /**
  71546. * Callback called when the task is successful
  71547. */
  71548. onSuccess: (task: MeshAssetTask) => void;
  71549. /**
  71550. * Callback called when the task is successful
  71551. */
  71552. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71553. /**
  71554. * Creates a new MeshAssetTask
  71555. * @param name defines the name of the task
  71556. * @param meshesNames defines the list of mesh's names you want to load
  71557. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71558. * @param sceneFilename defines the filename or File of the scene to load from
  71559. */
  71560. constructor(
  71561. /**
  71562. * Defines the name of the task
  71563. */
  71564. name: string,
  71565. /**
  71566. * Defines the list of mesh's names you want to load
  71567. */
  71568. meshesNames: any,
  71569. /**
  71570. * Defines the root url to use as a base to load your meshes and associated resources
  71571. */
  71572. rootUrl: string,
  71573. /**
  71574. * Defines the filename or File of the scene to load from
  71575. */
  71576. sceneFilename: string | File);
  71577. /**
  71578. * Execute the current task
  71579. * @param scene defines the scene where you want your assets to be loaded
  71580. * @param onSuccess is a callback called when the task is successfully executed
  71581. * @param onError is a callback called if an error occurs
  71582. */
  71583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71584. }
  71585. /**
  71586. * Define a task used by AssetsManager to load text content
  71587. */
  71588. export class TextFileAssetTask extends AbstractAssetTask {
  71589. /**
  71590. * Defines the name of the task
  71591. */
  71592. name: string;
  71593. /**
  71594. * Defines the location of the file to load
  71595. */
  71596. url: string;
  71597. /**
  71598. * Gets the loaded text string
  71599. */
  71600. text: string;
  71601. /**
  71602. * Callback called when the task is successful
  71603. */
  71604. onSuccess: (task: TextFileAssetTask) => void;
  71605. /**
  71606. * Callback called when the task is successful
  71607. */
  71608. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71609. /**
  71610. * Creates a new TextFileAssetTask object
  71611. * @param name defines the name of the task
  71612. * @param url defines the location of the file to load
  71613. */
  71614. constructor(
  71615. /**
  71616. * Defines the name of the task
  71617. */
  71618. name: string,
  71619. /**
  71620. * Defines the location of the file to load
  71621. */
  71622. url: string);
  71623. /**
  71624. * Execute the current task
  71625. * @param scene defines the scene where you want your assets to be loaded
  71626. * @param onSuccess is a callback called when the task is successfully executed
  71627. * @param onError is a callback called if an error occurs
  71628. */
  71629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71630. }
  71631. /**
  71632. * Define a task used by AssetsManager to load binary data
  71633. */
  71634. export class BinaryFileAssetTask extends AbstractAssetTask {
  71635. /**
  71636. * Defines the name of the task
  71637. */
  71638. name: string;
  71639. /**
  71640. * Defines the location of the file to load
  71641. */
  71642. url: string;
  71643. /**
  71644. * Gets the lodaded data (as an array buffer)
  71645. */
  71646. data: ArrayBuffer;
  71647. /**
  71648. * Callback called when the task is successful
  71649. */
  71650. onSuccess: (task: BinaryFileAssetTask) => void;
  71651. /**
  71652. * Callback called when the task is successful
  71653. */
  71654. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71655. /**
  71656. * Creates a new BinaryFileAssetTask object
  71657. * @param name defines the name of the new task
  71658. * @param url defines the location of the file to load
  71659. */
  71660. constructor(
  71661. /**
  71662. * Defines the name of the task
  71663. */
  71664. name: string,
  71665. /**
  71666. * Defines the location of the file to load
  71667. */
  71668. url: string);
  71669. /**
  71670. * Execute the current task
  71671. * @param scene defines the scene where you want your assets to be loaded
  71672. * @param onSuccess is a callback called when the task is successfully executed
  71673. * @param onError is a callback called if an error occurs
  71674. */
  71675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71676. }
  71677. /**
  71678. * Define a task used by AssetsManager to load images
  71679. */
  71680. export class ImageAssetTask extends AbstractAssetTask {
  71681. /**
  71682. * Defines the name of the task
  71683. */
  71684. name: string;
  71685. /**
  71686. * Defines the location of the image to load
  71687. */
  71688. url: string;
  71689. /**
  71690. * Gets the loaded images
  71691. */
  71692. image: HTMLImageElement;
  71693. /**
  71694. * Callback called when the task is successful
  71695. */
  71696. onSuccess: (task: ImageAssetTask) => void;
  71697. /**
  71698. * Callback called when the task is successful
  71699. */
  71700. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71701. /**
  71702. * Creates a new ImageAssetTask
  71703. * @param name defines the name of the task
  71704. * @param url defines the location of the image to load
  71705. */
  71706. constructor(
  71707. /**
  71708. * Defines the name of the task
  71709. */
  71710. name: string,
  71711. /**
  71712. * Defines the location of the image to load
  71713. */
  71714. url: string);
  71715. /**
  71716. * Execute the current task
  71717. * @param scene defines the scene where you want your assets to be loaded
  71718. * @param onSuccess is a callback called when the task is successfully executed
  71719. * @param onError is a callback called if an error occurs
  71720. */
  71721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71722. }
  71723. /**
  71724. * Defines the interface used by texture loading tasks
  71725. */
  71726. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71727. /**
  71728. * Gets the loaded texture
  71729. */
  71730. texture: TEX;
  71731. }
  71732. /**
  71733. * Define a task used by AssetsManager to load 2D textures
  71734. */
  71735. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71736. /**
  71737. * Defines the name of the task
  71738. */
  71739. name: string;
  71740. /**
  71741. * Defines the location of the file to load
  71742. */
  71743. url: string;
  71744. /**
  71745. * Defines if mipmap should not be generated (default is false)
  71746. */
  71747. noMipmap?: boolean | undefined;
  71748. /**
  71749. * Defines if texture must be inverted on Y axis (default is true)
  71750. */
  71751. invertY: boolean;
  71752. /**
  71753. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71754. */
  71755. samplingMode: number;
  71756. /**
  71757. * Gets the loaded texture
  71758. */
  71759. texture: Texture;
  71760. /**
  71761. * Callback called when the task is successful
  71762. */
  71763. onSuccess: (task: TextureAssetTask) => void;
  71764. /**
  71765. * Callback called when the task is successful
  71766. */
  71767. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71768. /**
  71769. * Creates a new TextureAssetTask object
  71770. * @param name defines the name of the task
  71771. * @param url defines the location of the file to load
  71772. * @param noMipmap defines if mipmap should not be generated (default is false)
  71773. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71774. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71775. */
  71776. constructor(
  71777. /**
  71778. * Defines the name of the task
  71779. */
  71780. name: string,
  71781. /**
  71782. * Defines the location of the file to load
  71783. */
  71784. url: string,
  71785. /**
  71786. * Defines if mipmap should not be generated (default is false)
  71787. */
  71788. noMipmap?: boolean | undefined,
  71789. /**
  71790. * Defines if texture must be inverted on Y axis (default is true)
  71791. */
  71792. invertY?: boolean,
  71793. /**
  71794. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71795. */
  71796. samplingMode?: number);
  71797. /**
  71798. * Execute the current task
  71799. * @param scene defines the scene where you want your assets to be loaded
  71800. * @param onSuccess is a callback called when the task is successfully executed
  71801. * @param onError is a callback called if an error occurs
  71802. */
  71803. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71804. }
  71805. /**
  71806. * Define a task used by AssetsManager to load cube textures
  71807. */
  71808. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71809. /**
  71810. * Defines the name of the task
  71811. */
  71812. name: string;
  71813. /**
  71814. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71815. */
  71816. url: string;
  71817. /**
  71818. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71819. */
  71820. extensions?: string[] | undefined;
  71821. /**
  71822. * Defines if mipmaps should not be generated (default is false)
  71823. */
  71824. noMipmap?: boolean | undefined;
  71825. /**
  71826. * Defines the explicit list of files (undefined by default)
  71827. */
  71828. files?: string[] | undefined;
  71829. /**
  71830. * Gets the loaded texture
  71831. */
  71832. texture: CubeTexture;
  71833. /**
  71834. * Callback called when the task is successful
  71835. */
  71836. onSuccess: (task: CubeTextureAssetTask) => void;
  71837. /**
  71838. * Callback called when the task is successful
  71839. */
  71840. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71841. /**
  71842. * Creates a new CubeTextureAssetTask
  71843. * @param name defines the name of the task
  71844. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71845. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71846. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71847. * @param files defines the explicit list of files (undefined by default)
  71848. */
  71849. constructor(
  71850. /**
  71851. * Defines the name of the task
  71852. */
  71853. name: string,
  71854. /**
  71855. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71856. */
  71857. url: string,
  71858. /**
  71859. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71860. */
  71861. extensions?: string[] | undefined,
  71862. /**
  71863. * Defines if mipmaps should not be generated (default is false)
  71864. */
  71865. noMipmap?: boolean | undefined,
  71866. /**
  71867. * Defines the explicit list of files (undefined by default)
  71868. */
  71869. files?: string[] | undefined);
  71870. /**
  71871. * Execute the current task
  71872. * @param scene defines the scene where you want your assets to be loaded
  71873. * @param onSuccess is a callback called when the task is successfully executed
  71874. * @param onError is a callback called if an error occurs
  71875. */
  71876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71877. }
  71878. /**
  71879. * Define a task used by AssetsManager to load HDR cube textures
  71880. */
  71881. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71882. /**
  71883. * Defines the name of the task
  71884. */
  71885. name: string;
  71886. /**
  71887. * Defines the location of the file to load
  71888. */
  71889. url: string;
  71890. /**
  71891. * Defines the desired size (the more it increases the longer the generation will be)
  71892. */
  71893. size: number;
  71894. /**
  71895. * Defines if mipmaps should not be generated (default is false)
  71896. */
  71897. noMipmap: boolean;
  71898. /**
  71899. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71900. */
  71901. generateHarmonics: boolean;
  71902. /**
  71903. * 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)
  71904. */
  71905. gammaSpace: boolean;
  71906. /**
  71907. * Internal Use Only
  71908. */
  71909. reserved: boolean;
  71910. /**
  71911. * Gets the loaded texture
  71912. */
  71913. texture: HDRCubeTexture;
  71914. /**
  71915. * Callback called when the task is successful
  71916. */
  71917. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71918. /**
  71919. * Callback called when the task is successful
  71920. */
  71921. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71922. /**
  71923. * Creates a new HDRCubeTextureAssetTask object
  71924. * @param name defines the name of the task
  71925. * @param url defines the location of the file to load
  71926. * @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.
  71927. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71928. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71929. * @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)
  71930. * @param reserved Internal use only
  71931. */
  71932. constructor(
  71933. /**
  71934. * Defines the name of the task
  71935. */
  71936. name: string,
  71937. /**
  71938. * Defines the location of the file to load
  71939. */
  71940. url: string,
  71941. /**
  71942. * Defines the desired size (the more it increases the longer the generation will be)
  71943. */
  71944. size: number,
  71945. /**
  71946. * Defines if mipmaps should not be generated (default is false)
  71947. */
  71948. noMipmap?: boolean,
  71949. /**
  71950. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71951. */
  71952. generateHarmonics?: boolean,
  71953. /**
  71954. * 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)
  71955. */
  71956. gammaSpace?: boolean,
  71957. /**
  71958. * Internal Use Only
  71959. */
  71960. reserved?: boolean);
  71961. /**
  71962. * Execute the current task
  71963. * @param scene defines the scene where you want your assets to be loaded
  71964. * @param onSuccess is a callback called when the task is successfully executed
  71965. * @param onError is a callback called if an error occurs
  71966. */
  71967. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71968. }
  71969. /**
  71970. * Define a task used by AssetsManager to load Equirectangular cube textures
  71971. */
  71972. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71973. /**
  71974. * Defines the name of the task
  71975. */
  71976. name: string;
  71977. /**
  71978. * Defines the location of the file to load
  71979. */
  71980. url: string;
  71981. /**
  71982. * Defines the desired size (the more it increases the longer the generation will be)
  71983. */
  71984. size: number;
  71985. /**
  71986. * Defines if mipmaps should not be generated (default is false)
  71987. */
  71988. noMipmap: boolean;
  71989. /**
  71990. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71991. * but the standard material would require them in Gamma space) (default is true)
  71992. */
  71993. gammaSpace: boolean;
  71994. /**
  71995. * Gets the loaded texture
  71996. */
  71997. texture: EquiRectangularCubeTexture;
  71998. /**
  71999. * Callback called when the task is successful
  72000. */
  72001. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72002. /**
  72003. * Callback called when the task is successful
  72004. */
  72005. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72006. /**
  72007. * Creates a new EquiRectangularCubeTextureAssetTask object
  72008. * @param name defines the name of the task
  72009. * @param url defines the location of the file to load
  72010. * @param size defines the desired size (the more it increases the longer the generation will be)
  72011. * If the size is omitted this implies you are using a preprocessed cubemap.
  72012. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72013. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72014. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72015. * (default is true)
  72016. */
  72017. constructor(
  72018. /**
  72019. * Defines the name of the task
  72020. */
  72021. name: string,
  72022. /**
  72023. * Defines the location of the file to load
  72024. */
  72025. url: string,
  72026. /**
  72027. * Defines the desired size (the more it increases the longer the generation will be)
  72028. */
  72029. size: number,
  72030. /**
  72031. * Defines if mipmaps should not be generated (default is false)
  72032. */
  72033. noMipmap?: boolean,
  72034. /**
  72035. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72036. * but the standard material would require them in Gamma space) (default is true)
  72037. */
  72038. gammaSpace?: boolean);
  72039. /**
  72040. * Execute the current task
  72041. * @param scene defines the scene where you want your assets to be loaded
  72042. * @param onSuccess is a callback called when the task is successfully executed
  72043. * @param onError is a callback called if an error occurs
  72044. */
  72045. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72046. }
  72047. /**
  72048. * This class can be used to easily import assets into a scene
  72049. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72050. */
  72051. export class AssetsManager {
  72052. private _scene;
  72053. private _isLoading;
  72054. protected _tasks: AbstractAssetTask[];
  72055. protected _waitingTasksCount: number;
  72056. protected _totalTasksCount: number;
  72057. /**
  72058. * Callback called when all tasks are processed
  72059. */
  72060. onFinish: (tasks: AbstractAssetTask[]) => void;
  72061. /**
  72062. * Callback called when a task is successful
  72063. */
  72064. onTaskSuccess: (task: AbstractAssetTask) => void;
  72065. /**
  72066. * Callback called when a task had an error
  72067. */
  72068. onTaskError: (task: AbstractAssetTask) => void;
  72069. /**
  72070. * Callback called when a task is done (whatever the result is)
  72071. */
  72072. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72073. /**
  72074. * Observable called when all tasks are processed
  72075. */
  72076. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72077. /**
  72078. * Observable called when a task had an error
  72079. */
  72080. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72081. /**
  72082. * Observable called when all tasks were executed
  72083. */
  72084. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72085. /**
  72086. * Observable called when a task is done (whatever the result is)
  72087. */
  72088. onProgressObservable: Observable<IAssetsProgressEvent>;
  72089. /**
  72090. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72091. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72092. */
  72093. useDefaultLoadingScreen: boolean;
  72094. /**
  72095. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72096. * when all assets have been downloaded.
  72097. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72098. */
  72099. autoHideLoadingUI: boolean;
  72100. /**
  72101. * Creates a new AssetsManager
  72102. * @param scene defines the scene to work on
  72103. */
  72104. constructor(scene: Scene);
  72105. /**
  72106. * Add a MeshAssetTask to the list of active tasks
  72107. * @param taskName defines the name of the new task
  72108. * @param meshesNames defines the name of meshes to load
  72109. * @param rootUrl defines the root url to use to locate files
  72110. * @param sceneFilename defines the filename of the scene file
  72111. * @returns a new MeshAssetTask object
  72112. */
  72113. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72114. /**
  72115. * Add a TextFileAssetTask to the list of active tasks
  72116. * @param taskName defines the name of the new task
  72117. * @param url defines the url of the file to load
  72118. * @returns a new TextFileAssetTask object
  72119. */
  72120. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72121. /**
  72122. * Add a BinaryFileAssetTask to the list of active tasks
  72123. * @param taskName defines the name of the new task
  72124. * @param url defines the url of the file to load
  72125. * @returns a new BinaryFileAssetTask object
  72126. */
  72127. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72128. /**
  72129. * Add a ImageAssetTask to the list of active tasks
  72130. * @param taskName defines the name of the new task
  72131. * @param url defines the url of the file to load
  72132. * @returns a new ImageAssetTask object
  72133. */
  72134. addImageTask(taskName: string, url: string): ImageAssetTask;
  72135. /**
  72136. * Add a TextureAssetTask to the list of active tasks
  72137. * @param taskName defines the name of the new task
  72138. * @param url defines the url of the file to load
  72139. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72140. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72141. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72142. * @returns a new TextureAssetTask object
  72143. */
  72144. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72145. /**
  72146. * Add a CubeTextureAssetTask to the list of active tasks
  72147. * @param taskName defines the name of the new task
  72148. * @param url defines the url of the file to load
  72149. * @param extensions defines the extension to use to load the cube map (can be null)
  72150. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72151. * @param files defines the list of files to load (can be null)
  72152. * @returns a new CubeTextureAssetTask object
  72153. */
  72154. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72155. /**
  72156. *
  72157. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72158. * @param taskName defines the name of the new task
  72159. * @param url defines the url of the file to load
  72160. * @param size defines the size you want for the cubemap (can be null)
  72161. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72162. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72163. * @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)
  72164. * @param reserved Internal use only
  72165. * @returns a new HDRCubeTextureAssetTask object
  72166. */
  72167. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72168. /**
  72169. *
  72170. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72171. * @param taskName defines the name of the new task
  72172. * @param url defines the url of the file to load
  72173. * @param size defines the size you want for the cubemap (can be null)
  72174. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72175. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72176. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72177. * @returns a new EquiRectangularCubeTextureAssetTask object
  72178. */
  72179. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72180. /**
  72181. * Remove a task from the assets manager.
  72182. * @param task the task to remove
  72183. */
  72184. removeTask(task: AbstractAssetTask): void;
  72185. private _decreaseWaitingTasksCount;
  72186. private _runTask;
  72187. /**
  72188. * Reset the AssetsManager and remove all tasks
  72189. * @return the current instance of the AssetsManager
  72190. */
  72191. reset(): AssetsManager;
  72192. /**
  72193. * Start the loading process
  72194. * @return the current instance of the AssetsManager
  72195. */
  72196. load(): AssetsManager;
  72197. /**
  72198. * Start the loading process as an async operation
  72199. * @return a promise returning the list of failed tasks
  72200. */
  72201. loadAsync(): Promise<void>;
  72202. }
  72203. }
  72204. declare module BABYLON {
  72205. /**
  72206. * Wrapper class for promise with external resolve and reject.
  72207. */
  72208. export class Deferred<T> {
  72209. /**
  72210. * The promise associated with this deferred object.
  72211. */
  72212. readonly promise: Promise<T>;
  72213. private _resolve;
  72214. private _reject;
  72215. /**
  72216. * The resolve method of the promise associated with this deferred object.
  72217. */
  72218. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72219. /**
  72220. * The reject method of the promise associated with this deferred object.
  72221. */
  72222. get reject(): (reason?: any) => void;
  72223. /**
  72224. * Constructor for this deferred object.
  72225. */
  72226. constructor();
  72227. }
  72228. }
  72229. declare module BABYLON {
  72230. /**
  72231. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72232. */
  72233. export class MeshExploder {
  72234. private _centerMesh;
  72235. private _meshes;
  72236. private _meshesOrigins;
  72237. private _toCenterVectors;
  72238. private _scaledDirection;
  72239. private _newPosition;
  72240. private _centerPosition;
  72241. /**
  72242. * Explodes meshes from a center mesh.
  72243. * @param meshes The meshes to explode.
  72244. * @param centerMesh The mesh to be center of explosion.
  72245. */
  72246. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72247. private _setCenterMesh;
  72248. /**
  72249. * Get class name
  72250. * @returns "MeshExploder"
  72251. */
  72252. getClassName(): string;
  72253. /**
  72254. * "Exploded meshes"
  72255. * @returns Array of meshes with the centerMesh at index 0.
  72256. */
  72257. getMeshes(): Array<Mesh>;
  72258. /**
  72259. * Explodes meshes giving a specific direction
  72260. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72261. */
  72262. explode(direction?: number): void;
  72263. }
  72264. }
  72265. declare module BABYLON {
  72266. /**
  72267. * Class used to help managing file picking and drag'n'drop
  72268. */
  72269. export class FilesInput {
  72270. /**
  72271. * List of files ready to be loaded
  72272. */
  72273. static get FilesToLoad(): {
  72274. [key: string]: File;
  72275. };
  72276. /**
  72277. * Callback called when a file is processed
  72278. */
  72279. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72280. private _engine;
  72281. private _currentScene;
  72282. private _sceneLoadedCallback;
  72283. private _progressCallback;
  72284. private _additionalRenderLoopLogicCallback;
  72285. private _textureLoadingCallback;
  72286. private _startingProcessingFilesCallback;
  72287. private _onReloadCallback;
  72288. private _errorCallback;
  72289. private _elementToMonitor;
  72290. private _sceneFileToLoad;
  72291. private _filesToLoad;
  72292. /**
  72293. * Creates a new FilesInput
  72294. * @param engine defines the rendering engine
  72295. * @param scene defines the hosting scene
  72296. * @param sceneLoadedCallback callback called when scene is loaded
  72297. * @param progressCallback callback called to track progress
  72298. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72299. * @param textureLoadingCallback callback called when a texture is loading
  72300. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72301. * @param onReloadCallback callback called when a reload is requested
  72302. * @param errorCallback callback call if an error occurs
  72303. */
  72304. 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>);
  72305. private _dragEnterHandler;
  72306. private _dragOverHandler;
  72307. private _dropHandler;
  72308. /**
  72309. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72310. * @param elementToMonitor defines the DOM element to track
  72311. */
  72312. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72313. /** Gets the current list of files to load */
  72314. get filesToLoad(): File[];
  72315. /**
  72316. * Release all associated resources
  72317. */
  72318. dispose(): void;
  72319. private renderFunction;
  72320. private drag;
  72321. private drop;
  72322. private _traverseFolder;
  72323. private _processFiles;
  72324. /**
  72325. * Load files from a drop event
  72326. * @param event defines the drop event to use as source
  72327. */
  72328. loadFiles(event: any): void;
  72329. private _processReload;
  72330. /**
  72331. * Reload the current scene from the loaded files
  72332. */
  72333. reload(): void;
  72334. }
  72335. }
  72336. declare module BABYLON {
  72337. /**
  72338. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72339. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72340. */
  72341. export class SceneOptimization {
  72342. /**
  72343. * Defines the priority of this optimization (0 by default which means first in the list)
  72344. */
  72345. priority: number;
  72346. /**
  72347. * Gets a string describing the action executed by the current optimization
  72348. * @returns description string
  72349. */
  72350. getDescription(): string;
  72351. /**
  72352. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72353. * @param scene defines the current scene where to apply this optimization
  72354. * @param optimizer defines the current optimizer
  72355. * @returns true if everything that can be done was applied
  72356. */
  72357. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72358. /**
  72359. * Creates the SceneOptimization object
  72360. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72361. * @param desc defines the description associated with the optimization
  72362. */
  72363. constructor(
  72364. /**
  72365. * Defines the priority of this optimization (0 by default which means first in the list)
  72366. */
  72367. priority?: number);
  72368. }
  72369. /**
  72370. * Defines an optimization used to reduce the size of render target textures
  72371. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72372. */
  72373. export class TextureOptimization extends SceneOptimization {
  72374. /**
  72375. * Defines the priority of this optimization (0 by default which means first in the list)
  72376. */
  72377. priority: number;
  72378. /**
  72379. * 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
  72380. */
  72381. maximumSize: number;
  72382. /**
  72383. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72384. */
  72385. step: number;
  72386. /**
  72387. * Gets a string describing the action executed by the current optimization
  72388. * @returns description string
  72389. */
  72390. getDescription(): string;
  72391. /**
  72392. * Creates the TextureOptimization object
  72393. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72394. * @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
  72395. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72396. */
  72397. constructor(
  72398. /**
  72399. * Defines the priority of this optimization (0 by default which means first in the list)
  72400. */
  72401. priority?: number,
  72402. /**
  72403. * 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
  72404. */
  72405. maximumSize?: number,
  72406. /**
  72407. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72408. */
  72409. step?: number);
  72410. /**
  72411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72412. * @param scene defines the current scene where to apply this optimization
  72413. * @param optimizer defines the current optimizer
  72414. * @returns true if everything that can be done was applied
  72415. */
  72416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72417. }
  72418. /**
  72419. * Defines an optimization used to increase or decrease the rendering resolution
  72420. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72421. */
  72422. export class HardwareScalingOptimization extends SceneOptimization {
  72423. /**
  72424. * Defines the priority of this optimization (0 by default which means first in the list)
  72425. */
  72426. priority: number;
  72427. /**
  72428. * Defines the maximum scale to use (2 by default)
  72429. */
  72430. maximumScale: number;
  72431. /**
  72432. * Defines the step to use between two passes (0.5 by default)
  72433. */
  72434. step: number;
  72435. private _currentScale;
  72436. private _directionOffset;
  72437. /**
  72438. * Gets a string describing the action executed by the current optimization
  72439. * @return description string
  72440. */
  72441. getDescription(): string;
  72442. /**
  72443. * Creates the HardwareScalingOptimization object
  72444. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72445. * @param maximumScale defines the maximum scale to use (2 by default)
  72446. * @param step defines the step to use between two passes (0.5 by default)
  72447. */
  72448. constructor(
  72449. /**
  72450. * Defines the priority of this optimization (0 by default which means first in the list)
  72451. */
  72452. priority?: number,
  72453. /**
  72454. * Defines the maximum scale to use (2 by default)
  72455. */
  72456. maximumScale?: number,
  72457. /**
  72458. * Defines the step to use between two passes (0.5 by default)
  72459. */
  72460. step?: number);
  72461. /**
  72462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72463. * @param scene defines the current scene where to apply this optimization
  72464. * @param optimizer defines the current optimizer
  72465. * @returns true if everything that can be done was applied
  72466. */
  72467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72468. }
  72469. /**
  72470. * Defines an optimization used to remove shadows
  72471. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72472. */
  72473. export class ShadowsOptimization extends SceneOptimization {
  72474. /**
  72475. * Gets a string describing the action executed by the current optimization
  72476. * @return description string
  72477. */
  72478. getDescription(): string;
  72479. /**
  72480. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72481. * @param scene defines the current scene where to apply this optimization
  72482. * @param optimizer defines the current optimizer
  72483. * @returns true if everything that can be done was applied
  72484. */
  72485. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72486. }
  72487. /**
  72488. * Defines an optimization used to turn post-processes off
  72489. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72490. */
  72491. export class PostProcessesOptimization extends SceneOptimization {
  72492. /**
  72493. * Gets a string describing the action executed by the current optimization
  72494. * @return description string
  72495. */
  72496. getDescription(): string;
  72497. /**
  72498. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72499. * @param scene defines the current scene where to apply this optimization
  72500. * @param optimizer defines the current optimizer
  72501. * @returns true if everything that can be done was applied
  72502. */
  72503. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72504. }
  72505. /**
  72506. * Defines an optimization used to turn lens flares off
  72507. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72508. */
  72509. export class LensFlaresOptimization extends SceneOptimization {
  72510. /**
  72511. * Gets a string describing the action executed by the current optimization
  72512. * @return description string
  72513. */
  72514. getDescription(): string;
  72515. /**
  72516. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72517. * @param scene defines the current scene where to apply this optimization
  72518. * @param optimizer defines the current optimizer
  72519. * @returns true if everything that can be done was applied
  72520. */
  72521. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72522. }
  72523. /**
  72524. * Defines an optimization based on user defined callback.
  72525. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72526. */
  72527. export class CustomOptimization extends SceneOptimization {
  72528. /**
  72529. * Callback called to apply the custom optimization.
  72530. */
  72531. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72532. /**
  72533. * Callback called to get custom description
  72534. */
  72535. onGetDescription: () => string;
  72536. /**
  72537. * Gets a string describing the action executed by the current optimization
  72538. * @returns description string
  72539. */
  72540. getDescription(): string;
  72541. /**
  72542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72543. * @param scene defines the current scene where to apply this optimization
  72544. * @param optimizer defines the current optimizer
  72545. * @returns true if everything that can be done was applied
  72546. */
  72547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72548. }
  72549. /**
  72550. * Defines an optimization used to turn particles off
  72551. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72552. */
  72553. export class ParticlesOptimization extends SceneOptimization {
  72554. /**
  72555. * Gets a string describing the action executed by the current optimization
  72556. * @return description string
  72557. */
  72558. getDescription(): string;
  72559. /**
  72560. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72561. * @param scene defines the current scene where to apply this optimization
  72562. * @param optimizer defines the current optimizer
  72563. * @returns true if everything that can be done was applied
  72564. */
  72565. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72566. }
  72567. /**
  72568. * Defines an optimization used to turn render targets off
  72569. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72570. */
  72571. export class RenderTargetsOptimization extends SceneOptimization {
  72572. /**
  72573. * Gets a string describing the action executed by the current optimization
  72574. * @return description string
  72575. */
  72576. getDescription(): string;
  72577. /**
  72578. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72579. * @param scene defines the current scene where to apply this optimization
  72580. * @param optimizer defines the current optimizer
  72581. * @returns true if everything that can be done was applied
  72582. */
  72583. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72584. }
  72585. /**
  72586. * Defines an optimization used to merge meshes with compatible materials
  72587. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72588. */
  72589. export class MergeMeshesOptimization extends SceneOptimization {
  72590. private static _UpdateSelectionTree;
  72591. /**
  72592. * Gets or sets a boolean which defines if optimization octree has to be updated
  72593. */
  72594. static get UpdateSelectionTree(): boolean;
  72595. /**
  72596. * Gets or sets a boolean which defines if optimization octree has to be updated
  72597. */
  72598. static set UpdateSelectionTree(value: boolean);
  72599. /**
  72600. * Gets a string describing the action executed by the current optimization
  72601. * @return description string
  72602. */
  72603. getDescription(): string;
  72604. private _canBeMerged;
  72605. /**
  72606. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72607. * @param scene defines the current scene where to apply this optimization
  72608. * @param optimizer defines the current optimizer
  72609. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72610. * @returns true if everything that can be done was applied
  72611. */
  72612. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72613. }
  72614. /**
  72615. * Defines a list of options used by SceneOptimizer
  72616. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72617. */
  72618. export class SceneOptimizerOptions {
  72619. /**
  72620. * Defines the target frame rate to reach (60 by default)
  72621. */
  72622. targetFrameRate: number;
  72623. /**
  72624. * Defines the interval between two checkes (2000ms by default)
  72625. */
  72626. trackerDuration: number;
  72627. /**
  72628. * Gets the list of optimizations to apply
  72629. */
  72630. optimizations: SceneOptimization[];
  72631. /**
  72632. * Creates a new list of options used by SceneOptimizer
  72633. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72634. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72635. */
  72636. constructor(
  72637. /**
  72638. * Defines the target frame rate to reach (60 by default)
  72639. */
  72640. targetFrameRate?: number,
  72641. /**
  72642. * Defines the interval between two checkes (2000ms by default)
  72643. */
  72644. trackerDuration?: number);
  72645. /**
  72646. * Add a new optimization
  72647. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72648. * @returns the current SceneOptimizerOptions
  72649. */
  72650. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72651. /**
  72652. * Add a new custom optimization
  72653. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72654. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72655. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72656. * @returns the current SceneOptimizerOptions
  72657. */
  72658. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72659. /**
  72660. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72661. * @param targetFrameRate defines the target frame rate (60 by default)
  72662. * @returns a SceneOptimizerOptions object
  72663. */
  72664. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72665. /**
  72666. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72667. * @param targetFrameRate defines the target frame rate (60 by default)
  72668. * @returns a SceneOptimizerOptions object
  72669. */
  72670. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72671. /**
  72672. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72673. * @param targetFrameRate defines the target frame rate (60 by default)
  72674. * @returns a SceneOptimizerOptions object
  72675. */
  72676. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72677. }
  72678. /**
  72679. * Class used to run optimizations in order to reach a target frame rate
  72680. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72681. */
  72682. export class SceneOptimizer implements IDisposable {
  72683. private _isRunning;
  72684. private _options;
  72685. private _scene;
  72686. private _currentPriorityLevel;
  72687. private _targetFrameRate;
  72688. private _trackerDuration;
  72689. private _currentFrameRate;
  72690. private _sceneDisposeObserver;
  72691. private _improvementMode;
  72692. /**
  72693. * Defines an observable called when the optimizer reaches the target frame rate
  72694. */
  72695. onSuccessObservable: Observable<SceneOptimizer>;
  72696. /**
  72697. * Defines an observable called when the optimizer enables an optimization
  72698. */
  72699. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72700. /**
  72701. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72702. */
  72703. onFailureObservable: Observable<SceneOptimizer>;
  72704. /**
  72705. * Gets a boolean indicating if the optimizer is in improvement mode
  72706. */
  72707. get isInImprovementMode(): boolean;
  72708. /**
  72709. * Gets the current priority level (0 at start)
  72710. */
  72711. get currentPriorityLevel(): number;
  72712. /**
  72713. * Gets the current frame rate checked by the SceneOptimizer
  72714. */
  72715. get currentFrameRate(): number;
  72716. /**
  72717. * Gets or sets the current target frame rate (60 by default)
  72718. */
  72719. get targetFrameRate(): number;
  72720. /**
  72721. * Gets or sets the current target frame rate (60 by default)
  72722. */
  72723. set targetFrameRate(value: number);
  72724. /**
  72725. * Gets or sets the current interval between two checks (every 2000ms by default)
  72726. */
  72727. get trackerDuration(): number;
  72728. /**
  72729. * Gets or sets the current interval between two checks (every 2000ms by default)
  72730. */
  72731. set trackerDuration(value: number);
  72732. /**
  72733. * Gets the list of active optimizations
  72734. */
  72735. get optimizations(): SceneOptimization[];
  72736. /**
  72737. * Creates a new SceneOptimizer
  72738. * @param scene defines the scene to work on
  72739. * @param options defines the options to use with the SceneOptimizer
  72740. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72741. * @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)
  72742. */
  72743. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72744. /**
  72745. * Stops the current optimizer
  72746. */
  72747. stop(): void;
  72748. /**
  72749. * Reset the optimizer to initial step (current priority level = 0)
  72750. */
  72751. reset(): void;
  72752. /**
  72753. * Start the optimizer. By default it will try to reach a specific framerate
  72754. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72755. */
  72756. start(): void;
  72757. private _checkCurrentState;
  72758. /**
  72759. * Release all resources
  72760. */
  72761. dispose(): void;
  72762. /**
  72763. * Helper function to create a SceneOptimizer with one single line of code
  72764. * @param scene defines the scene to work on
  72765. * @param options defines the options to use with the SceneOptimizer
  72766. * @param onSuccess defines a callback to call on success
  72767. * @param onFailure defines a callback to call on failure
  72768. * @returns the new SceneOptimizer object
  72769. */
  72770. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72771. }
  72772. }
  72773. declare module BABYLON {
  72774. /**
  72775. * Class used to serialize a scene into a string
  72776. */
  72777. export class SceneSerializer {
  72778. /**
  72779. * Clear cache used by a previous serialization
  72780. */
  72781. static ClearCache(): void;
  72782. /**
  72783. * Serialize a scene into a JSON compatible object
  72784. * @param scene defines the scene to serialize
  72785. * @returns a JSON compatible object
  72786. */
  72787. static Serialize(scene: Scene): any;
  72788. /**
  72789. * Serialize a mesh into a JSON compatible object
  72790. * @param toSerialize defines the mesh to serialize
  72791. * @param withParents defines if parents must be serialized as well
  72792. * @param withChildren defines if children must be serialized as well
  72793. * @returns a JSON compatible object
  72794. */
  72795. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72796. }
  72797. }
  72798. declare module BABYLON {
  72799. /**
  72800. * Class used to host texture specific utilities
  72801. */
  72802. export class TextureTools {
  72803. /**
  72804. * Uses the GPU to create a copy texture rescaled at a given size
  72805. * @param texture Texture to copy from
  72806. * @param width defines the desired width
  72807. * @param height defines the desired height
  72808. * @param useBilinearMode defines if bilinear mode has to be used
  72809. * @return the generated texture
  72810. */
  72811. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72812. }
  72813. }
  72814. declare module BABYLON {
  72815. /**
  72816. * This represents the different options available for the video capture.
  72817. */
  72818. export interface VideoRecorderOptions {
  72819. /** Defines the mime type of the video. */
  72820. mimeType: string;
  72821. /** Defines the FPS the video should be recorded at. */
  72822. fps: number;
  72823. /** Defines the chunk size for the recording data. */
  72824. recordChunckSize: number;
  72825. /** The audio tracks to attach to the recording. */
  72826. audioTracks?: MediaStreamTrack[];
  72827. }
  72828. /**
  72829. * This can help with recording videos from BabylonJS.
  72830. * This is based on the available WebRTC functionalities of the browser.
  72831. *
  72832. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  72833. */
  72834. export class VideoRecorder {
  72835. private static readonly _defaultOptions;
  72836. /**
  72837. * Returns whether or not the VideoRecorder is available in your browser.
  72838. * @param engine Defines the Babylon Engine.
  72839. * @returns true if supported otherwise false.
  72840. */
  72841. static IsSupported(engine: Engine): boolean;
  72842. private readonly _options;
  72843. private _canvas;
  72844. private _mediaRecorder;
  72845. private _recordedChunks;
  72846. private _fileName;
  72847. private _resolve;
  72848. private _reject;
  72849. /**
  72850. * True when a recording is already in progress.
  72851. */
  72852. get isRecording(): boolean;
  72853. /**
  72854. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72855. * @param engine Defines the BabylonJS Engine you wish to record.
  72856. * @param options Defines options that can be used to customize the capture.
  72857. */
  72858. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72859. /**
  72860. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72861. */
  72862. stopRecording(): void;
  72863. /**
  72864. * Starts recording the canvas for a max duration specified in parameters.
  72865. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72866. * If null no automatic download will start and you can rely on the promise to get the data back.
  72867. * @param maxDuration Defines the maximum recording time in seconds.
  72868. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72869. * @return A promise callback at the end of the recording with the video data in Blob.
  72870. */
  72871. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72872. /**
  72873. * Releases internal resources used during the recording.
  72874. */
  72875. dispose(): void;
  72876. private _handleDataAvailable;
  72877. private _handleError;
  72878. private _handleStop;
  72879. }
  72880. }
  72881. declare module BABYLON {
  72882. /**
  72883. * Class containing a set of static utilities functions for screenshots
  72884. */
  72885. export class ScreenshotTools {
  72886. /**
  72887. * Captures a screenshot of the current rendering
  72888. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72889. * @param engine defines the rendering engine
  72890. * @param camera defines the source camera
  72891. * @param size This parameter can be set to a single number or to an object with the
  72892. * following (optional) properties: precision, width, height. If a single number is passed,
  72893. * it will be used for both width and height. If an object is passed, the screenshot size
  72894. * will be derived from the parameters. The precision property is a multiplier allowing
  72895. * rendering at a higher or lower resolution
  72896. * @param successCallback defines the callback receives a single parameter which contains the
  72897. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72898. * src parameter of an <img> to display it
  72899. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72900. * Check your browser for supported MIME types
  72901. */
  72902. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72903. /**
  72904. * Captures a screenshot of the current rendering
  72905. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72906. * @param engine defines the rendering engine
  72907. * @param camera defines the source camera
  72908. * @param size This parameter can be set to a single number or to an object with the
  72909. * following (optional) properties: precision, width, height. If a single number is passed,
  72910. * it will be used for both width and height. If an object is passed, the screenshot size
  72911. * will be derived from the parameters. The precision property is a multiplier allowing
  72912. * rendering at a higher or lower resolution
  72913. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72914. * Check your browser for supported MIME types
  72915. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72916. * to the src parameter of an <img> to display it
  72917. */
  72918. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72919. /**
  72920. * Generates an image screenshot from the specified camera.
  72921. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72922. * @param engine The engine to use for rendering
  72923. * @param camera The camera to use for rendering
  72924. * @param size This parameter can be set to a single number or to an object with the
  72925. * following (optional) properties: precision, width, height. If a single number is passed,
  72926. * it will be used for both width and height. If an object is passed, the screenshot size
  72927. * will be derived from the parameters. The precision property is a multiplier allowing
  72928. * rendering at a higher or lower resolution
  72929. * @param successCallback The callback receives a single parameter which contains the
  72930. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72931. * src parameter of an <img> to display it
  72932. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72933. * Check your browser for supported MIME types
  72934. * @param samples Texture samples (default: 1)
  72935. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72936. * @param fileName A name for for the downloaded file.
  72937. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72938. */
  72939. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72940. /**
  72941. * Generates an image screenshot from the specified camera.
  72942. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72943. * @param engine The engine to use for rendering
  72944. * @param camera The camera to use for rendering
  72945. * @param size This parameter can be set to a single number or to an object with the
  72946. * following (optional) properties: precision, width, height. If a single number is passed,
  72947. * it will be used for both width and height. If an object is passed, the screenshot size
  72948. * will be derived from the parameters. The precision property is a multiplier allowing
  72949. * rendering at a higher or lower resolution
  72950. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72951. * Check your browser for supported MIME types
  72952. * @param samples Texture samples (default: 1)
  72953. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72954. * @param fileName A name for for the downloaded file.
  72955. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72956. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72957. * to the src parameter of an <img> to display it
  72958. */
  72959. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72960. /**
  72961. * Gets height and width for screenshot size
  72962. * @private
  72963. */
  72964. private static _getScreenshotSize;
  72965. }
  72966. }
  72967. declare module BABYLON {
  72968. /**
  72969. * Interface for a data buffer
  72970. */
  72971. export interface IDataBuffer {
  72972. /**
  72973. * Reads bytes from the data buffer.
  72974. * @param byteOffset The byte offset to read
  72975. * @param byteLength The byte length to read
  72976. * @returns A promise that resolves when the bytes are read
  72977. */
  72978. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72979. /**
  72980. * The byte length of the buffer.
  72981. */
  72982. readonly byteLength: number;
  72983. }
  72984. /**
  72985. * Utility class for reading from a data buffer
  72986. */
  72987. export class DataReader {
  72988. /**
  72989. * The data buffer associated with this data reader.
  72990. */
  72991. readonly buffer: IDataBuffer;
  72992. /**
  72993. * The current byte offset from the beginning of the data buffer.
  72994. */
  72995. byteOffset: number;
  72996. private _dataView;
  72997. private _dataByteOffset;
  72998. /**
  72999. * Constructor
  73000. * @param buffer The buffer to read
  73001. */
  73002. constructor(buffer: IDataBuffer);
  73003. /**
  73004. * Loads the given byte length.
  73005. * @param byteLength The byte length to load
  73006. * @returns A promise that resolves when the load is complete
  73007. */
  73008. loadAsync(byteLength: number): Promise<void>;
  73009. /**
  73010. * Read a unsigned 32-bit integer from the currently loaded data range.
  73011. * @returns The 32-bit integer read
  73012. */
  73013. readUint32(): number;
  73014. /**
  73015. * Read a byte array from the currently loaded data range.
  73016. * @param byteLength The byte length to read
  73017. * @returns The byte array read
  73018. */
  73019. readUint8Array(byteLength: number): Uint8Array;
  73020. /**
  73021. * Read a string from the currently loaded data range.
  73022. * @param byteLength The byte length to read
  73023. * @returns The string read
  73024. */
  73025. readString(byteLength: number): string;
  73026. /**
  73027. * Skips the given byte length the currently loaded data range.
  73028. * @param byteLength The byte length to skip
  73029. */
  73030. skipBytes(byteLength: number): void;
  73031. }
  73032. }
  73033. declare module BABYLON {
  73034. /**
  73035. * Class for storing data to local storage if available or in-memory storage otherwise
  73036. */
  73037. export class DataStorage {
  73038. private static _Storage;
  73039. private static _GetStorage;
  73040. /**
  73041. * Reads a string from the data storage
  73042. * @param key The key to read
  73043. * @param defaultValue The value if the key doesn't exist
  73044. * @returns The string value
  73045. */
  73046. static ReadString(key: string, defaultValue: string): string;
  73047. /**
  73048. * Writes a string to the data storage
  73049. * @param key The key to write
  73050. * @param value The value to write
  73051. */
  73052. static WriteString(key: string, value: string): void;
  73053. /**
  73054. * Reads a boolean from the data storage
  73055. * @param key The key to read
  73056. * @param defaultValue The value if the key doesn't exist
  73057. * @returns The boolean value
  73058. */
  73059. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73060. /**
  73061. * Writes a boolean to the data storage
  73062. * @param key The key to write
  73063. * @param value The value to write
  73064. */
  73065. static WriteBoolean(key: string, value: boolean): void;
  73066. /**
  73067. * Reads a number from the data storage
  73068. * @param key The key to read
  73069. * @param defaultValue The value if the key doesn't exist
  73070. * @returns The number value
  73071. */
  73072. static ReadNumber(key: string, defaultValue: number): number;
  73073. /**
  73074. * Writes a number to the data storage
  73075. * @param key The key to write
  73076. * @param value The value to write
  73077. */
  73078. static WriteNumber(key: string, value: number): void;
  73079. }
  73080. }
  73081. declare module BABYLON {
  73082. /**
  73083. * An interface for all Hit test features
  73084. */
  73085. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73086. /**
  73087. * Triggered when new babylon (transformed) hit test results are available
  73088. */
  73089. onHitTestResultObservable: Observable<T[]>;
  73090. }
  73091. /**
  73092. * Options used for hit testing
  73093. */
  73094. export interface IWebXRLegacyHitTestOptions {
  73095. /**
  73096. * Only test when user interacted with the scene. Default - hit test every frame
  73097. */
  73098. testOnPointerDownOnly?: boolean;
  73099. /**
  73100. * The node to use to transform the local results to world coordinates
  73101. */
  73102. worldParentNode?: TransformNode;
  73103. }
  73104. /**
  73105. * Interface defining the babylon result of raycasting/hit-test
  73106. */
  73107. export interface IWebXRLegacyHitResult {
  73108. /**
  73109. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73110. */
  73111. transformationMatrix: Matrix;
  73112. /**
  73113. * The native hit test result
  73114. */
  73115. xrHitResult: XRHitResult | XRHitTestResult;
  73116. }
  73117. /**
  73118. * The currently-working hit-test module.
  73119. * Hit test (or Ray-casting) is used to interact with the real world.
  73120. * For further information read here - https://github.com/immersive-web/hit-test
  73121. */
  73122. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73123. /**
  73124. * options to use when constructing this feature
  73125. */
  73126. readonly options: IWebXRLegacyHitTestOptions;
  73127. private _direction;
  73128. private _mat;
  73129. private _onSelectEnabled;
  73130. private _origin;
  73131. /**
  73132. * The module's name
  73133. */
  73134. static readonly Name: string;
  73135. /**
  73136. * The (Babylon) version of this module.
  73137. * This is an integer representing the implementation version.
  73138. * This number does not correspond to the WebXR specs version
  73139. */
  73140. static readonly Version: number;
  73141. /**
  73142. * Populated with the last native XR Hit Results
  73143. */
  73144. lastNativeXRHitResults: XRHitResult[];
  73145. /**
  73146. * Triggered when new babylon (transformed) hit test results are available
  73147. */
  73148. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73149. /**
  73150. * Creates a new instance of the (legacy version) hit test feature
  73151. * @param _xrSessionManager an instance of WebXRSessionManager
  73152. * @param options options to use when constructing this feature
  73153. */
  73154. constructor(_xrSessionManager: WebXRSessionManager,
  73155. /**
  73156. * options to use when constructing this feature
  73157. */
  73158. options?: IWebXRLegacyHitTestOptions);
  73159. /**
  73160. * execute a hit test with an XR Ray
  73161. *
  73162. * @param xrSession a native xrSession that will execute this hit test
  73163. * @param xrRay the ray (position and direction) to use for ray-casting
  73164. * @param referenceSpace native XR reference space to use for the hit-test
  73165. * @param filter filter function that will filter the results
  73166. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73167. */
  73168. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73169. /**
  73170. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73171. * @param event the (select) event to use to select with
  73172. * @param referenceSpace the reference space to use for this hit test
  73173. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73174. */
  73175. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73176. /**
  73177. * attach this feature
  73178. * Will usually be called by the features manager
  73179. *
  73180. * @returns true if successful.
  73181. */
  73182. attach(): boolean;
  73183. /**
  73184. * detach this feature.
  73185. * Will usually be called by the features manager
  73186. *
  73187. * @returns true if successful.
  73188. */
  73189. detach(): boolean;
  73190. /**
  73191. * Dispose this feature and all of the resources attached
  73192. */
  73193. dispose(): void;
  73194. protected _onXRFrame(frame: XRFrame): void;
  73195. private _onHitTestResults;
  73196. private _onSelect;
  73197. }
  73198. }
  73199. declare module BABYLON {
  73200. /**
  73201. * Options used for hit testing (version 2)
  73202. */
  73203. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73204. /**
  73205. * Do not create a permanent hit test. Will usually be used when only
  73206. * transient inputs are needed.
  73207. */
  73208. disablePermanentHitTest?: boolean;
  73209. /**
  73210. * Enable transient (for example touch-based) hit test inspections
  73211. */
  73212. enableTransientHitTest?: boolean;
  73213. /**
  73214. * Offset ray for the permanent hit test
  73215. */
  73216. offsetRay?: Vector3;
  73217. /**
  73218. * Offset ray for the transient hit test
  73219. */
  73220. transientOffsetRay?: Vector3;
  73221. /**
  73222. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73223. */
  73224. useReferenceSpace?: boolean;
  73225. }
  73226. /**
  73227. * Interface defining the babylon result of hit-test
  73228. */
  73229. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73230. /**
  73231. * The input source that generated this hit test (if transient)
  73232. */
  73233. inputSource?: XRInputSource;
  73234. /**
  73235. * Is this a transient hit test
  73236. */
  73237. isTransient?: boolean;
  73238. /**
  73239. * Position of the hit test result
  73240. */
  73241. position: Vector3;
  73242. /**
  73243. * Rotation of the hit test result
  73244. */
  73245. rotationQuaternion: Quaternion;
  73246. /**
  73247. * The native hit test result
  73248. */
  73249. xrHitResult: XRHitTestResult;
  73250. }
  73251. /**
  73252. * The currently-working hit-test module.
  73253. * Hit test (or Ray-casting) is used to interact with the real world.
  73254. * For further information read here - https://github.com/immersive-web/hit-test
  73255. *
  73256. * Tested on chrome (mobile) 80.
  73257. */
  73258. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73259. /**
  73260. * options to use when constructing this feature
  73261. */
  73262. readonly options: IWebXRHitTestOptions;
  73263. private _tmpMat;
  73264. private _tmpPos;
  73265. private _tmpQuat;
  73266. private _transientXrHitTestSource;
  73267. private _xrHitTestSource;
  73268. private initHitTestSource;
  73269. /**
  73270. * The module's name
  73271. */
  73272. static readonly Name: string;
  73273. /**
  73274. * The (Babylon) version of this module.
  73275. * This is an integer representing the implementation version.
  73276. * This number does not correspond to the WebXR specs version
  73277. */
  73278. static readonly Version: number;
  73279. /**
  73280. * When set to true, each hit test will have its own position/rotation objects
  73281. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73282. * the developers will clone them or copy them as they see fit.
  73283. */
  73284. autoCloneTransformation: boolean;
  73285. /**
  73286. * Triggered when new babylon (transformed) hit test results are available
  73287. */
  73288. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73289. /**
  73290. * Use this to temporarily pause hit test checks.
  73291. */
  73292. paused: boolean;
  73293. /**
  73294. * Creates a new instance of the hit test feature
  73295. * @param _xrSessionManager an instance of WebXRSessionManager
  73296. * @param options options to use when constructing this feature
  73297. */
  73298. constructor(_xrSessionManager: WebXRSessionManager,
  73299. /**
  73300. * options to use when constructing this feature
  73301. */
  73302. options?: IWebXRHitTestOptions);
  73303. /**
  73304. * attach this feature
  73305. * Will usually be called by the features manager
  73306. *
  73307. * @returns true if successful.
  73308. */
  73309. attach(): boolean;
  73310. /**
  73311. * detach this feature.
  73312. * Will usually be called by the features manager
  73313. *
  73314. * @returns true if successful.
  73315. */
  73316. detach(): boolean;
  73317. /**
  73318. * Dispose this feature and all of the resources attached
  73319. */
  73320. dispose(): void;
  73321. protected _onXRFrame(frame: XRFrame): void;
  73322. private _processWebXRHitTestResult;
  73323. }
  73324. }
  73325. declare module BABYLON {
  73326. /**
  73327. * Configuration options of the anchor system
  73328. */
  73329. export interface IWebXRAnchorSystemOptions {
  73330. /**
  73331. * a node that will be used to convert local to world coordinates
  73332. */
  73333. worldParentNode?: TransformNode;
  73334. /**
  73335. * If set to true a reference of the created anchors will be kept until the next session starts
  73336. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73337. */
  73338. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73339. }
  73340. /**
  73341. * A babylon container for an XR Anchor
  73342. */
  73343. export interface IWebXRAnchor {
  73344. /**
  73345. * A babylon-assigned ID for this anchor
  73346. */
  73347. id: number;
  73348. /**
  73349. * Transformation matrix to apply to an object attached to this anchor
  73350. */
  73351. transformationMatrix: Matrix;
  73352. /**
  73353. * The native anchor object
  73354. */
  73355. xrAnchor: XRAnchor;
  73356. /**
  73357. * if defined, this object will be constantly updated by the anchor's position and rotation
  73358. */
  73359. attachedNode?: TransformNode;
  73360. }
  73361. /**
  73362. * An implementation of the anchor system for WebXR.
  73363. * For further information see https://github.com/immersive-web/anchors/
  73364. */
  73365. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73366. private _options;
  73367. private _lastFrameDetected;
  73368. private _trackedAnchors;
  73369. private _referenceSpaceForFrameAnchors;
  73370. private _futureAnchors;
  73371. /**
  73372. * The module's name
  73373. */
  73374. static readonly Name: string;
  73375. /**
  73376. * The (Babylon) version of this module.
  73377. * This is an integer representing the implementation version.
  73378. * This number does not correspond to the WebXR specs version
  73379. */
  73380. static readonly Version: number;
  73381. /**
  73382. * Observers registered here will be executed when a new anchor was added to the session
  73383. */
  73384. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73385. /**
  73386. * Observers registered here will be executed when an anchor was removed from the session
  73387. */
  73388. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73389. /**
  73390. * Observers registered here will be executed when an existing anchor updates
  73391. * This can execute N times every frame
  73392. */
  73393. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73394. /**
  73395. * Set the reference space to use for anchor creation, when not using a hit test.
  73396. * Will default to the session's reference space if not defined
  73397. */
  73398. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73399. /**
  73400. * constructs a new anchor system
  73401. * @param _xrSessionManager an instance of WebXRSessionManager
  73402. * @param _options configuration object for this feature
  73403. */
  73404. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73405. private _tmpVector;
  73406. private _tmpQuaternion;
  73407. private _populateTmpTransformation;
  73408. /**
  73409. * Create a new anchor point using a hit test result at a specific point in the scene
  73410. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73411. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73412. *
  73413. * @param hitTestResult The hit test result to use for this anchor creation
  73414. * @param position an optional position offset for this anchor
  73415. * @param rotationQuaternion an optional rotation offset for this anchor
  73416. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73417. */
  73418. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73419. /**
  73420. * Add a new anchor at a specific position and rotation
  73421. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73422. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73423. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73424. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73425. *
  73426. * @param position the position in which to add an anchor
  73427. * @param rotationQuaternion an optional rotation for the anchor transformation
  73428. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73429. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73430. */
  73431. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73432. /**
  73433. * detach this feature.
  73434. * Will usually be called by the features manager
  73435. *
  73436. * @returns true if successful.
  73437. */
  73438. detach(): boolean;
  73439. /**
  73440. * Dispose this feature and all of the resources attached
  73441. */
  73442. dispose(): void;
  73443. protected _onXRFrame(frame: XRFrame): void;
  73444. /**
  73445. * avoiding using Array.find for global support.
  73446. * @param xrAnchor the plane to find in the array
  73447. */
  73448. private _findIndexInAnchorArray;
  73449. private _updateAnchorWithXRFrame;
  73450. private _createAnchorAtTransformation;
  73451. }
  73452. }
  73453. declare module BABYLON {
  73454. /**
  73455. * Options used in the plane detector module
  73456. */
  73457. export interface IWebXRPlaneDetectorOptions {
  73458. /**
  73459. * The node to use to transform the local results to world coordinates
  73460. */
  73461. worldParentNode?: TransformNode;
  73462. /**
  73463. * If set to true a reference of the created planes will be kept until the next session starts
  73464. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73465. */
  73466. doNotRemovePlanesOnSessionEnded?: boolean;
  73467. }
  73468. /**
  73469. * A babylon interface for a WebXR plane.
  73470. * A Plane is actually a polygon, built from N points in space
  73471. *
  73472. * Supported in chrome 79, not supported in canary 81 ATM
  73473. */
  73474. export interface IWebXRPlane {
  73475. /**
  73476. * a babylon-assigned ID for this polygon
  73477. */
  73478. id: number;
  73479. /**
  73480. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73481. */
  73482. polygonDefinition: Array<Vector3>;
  73483. /**
  73484. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73485. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73486. */
  73487. transformationMatrix: Matrix;
  73488. /**
  73489. * the native xr-plane object
  73490. */
  73491. xrPlane: XRPlane;
  73492. }
  73493. /**
  73494. * The plane detector is used to detect planes in the real world when in AR
  73495. * For more information see https://github.com/immersive-web/real-world-geometry/
  73496. */
  73497. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73498. private _options;
  73499. private _detectedPlanes;
  73500. private _enabled;
  73501. private _lastFrameDetected;
  73502. /**
  73503. * The module's name
  73504. */
  73505. static readonly Name: string;
  73506. /**
  73507. * The (Babylon) version of this module.
  73508. * This is an integer representing the implementation version.
  73509. * This number does not correspond to the WebXR specs version
  73510. */
  73511. static readonly Version: number;
  73512. /**
  73513. * Observers registered here will be executed when a new plane was added to the session
  73514. */
  73515. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73516. /**
  73517. * Observers registered here will be executed when a plane is no longer detected in the session
  73518. */
  73519. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73520. /**
  73521. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73522. * This can execute N times every frame
  73523. */
  73524. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73525. /**
  73526. * construct a new Plane Detector
  73527. * @param _xrSessionManager an instance of xr Session manager
  73528. * @param _options configuration to use when constructing this feature
  73529. */
  73530. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73531. /**
  73532. * detach this feature.
  73533. * Will usually be called by the features manager
  73534. *
  73535. * @returns true if successful.
  73536. */
  73537. detach(): boolean;
  73538. /**
  73539. * Dispose this feature and all of the resources attached
  73540. */
  73541. dispose(): void;
  73542. protected _onXRFrame(frame: XRFrame): void;
  73543. private _init;
  73544. private _updatePlaneWithXRPlane;
  73545. /**
  73546. * avoiding using Array.find for global support.
  73547. * @param xrPlane the plane to find in the array
  73548. */
  73549. private findIndexInPlaneArray;
  73550. }
  73551. }
  73552. declare module BABYLON {
  73553. /**
  73554. * Options interface for the background remover plugin
  73555. */
  73556. export interface IWebXRBackgroundRemoverOptions {
  73557. /**
  73558. * Further background meshes to disable when entering AR
  73559. */
  73560. backgroundMeshes?: AbstractMesh[];
  73561. /**
  73562. * flags to configure the removal of the environment helper.
  73563. * If not set, the entire background will be removed. If set, flags should be set as well.
  73564. */
  73565. environmentHelperRemovalFlags?: {
  73566. /**
  73567. * Should the skybox be removed (default false)
  73568. */
  73569. skyBox?: boolean;
  73570. /**
  73571. * Should the ground be removed (default false)
  73572. */
  73573. ground?: boolean;
  73574. };
  73575. /**
  73576. * don't disable the environment helper
  73577. */
  73578. ignoreEnvironmentHelper?: boolean;
  73579. }
  73580. /**
  73581. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73582. */
  73583. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73584. /**
  73585. * read-only options to be used in this module
  73586. */
  73587. readonly options: IWebXRBackgroundRemoverOptions;
  73588. /**
  73589. * The module's name
  73590. */
  73591. static readonly Name: string;
  73592. /**
  73593. * The (Babylon) version of this module.
  73594. * This is an integer representing the implementation version.
  73595. * This number does not correspond to the WebXR specs version
  73596. */
  73597. static readonly Version: number;
  73598. /**
  73599. * registered observers will be triggered when the background state changes
  73600. */
  73601. onBackgroundStateChangedObservable: Observable<boolean>;
  73602. /**
  73603. * constructs a new background remover module
  73604. * @param _xrSessionManager the session manager for this module
  73605. * @param options read-only options to be used in this module
  73606. */
  73607. constructor(_xrSessionManager: WebXRSessionManager,
  73608. /**
  73609. * read-only options to be used in this module
  73610. */
  73611. options?: IWebXRBackgroundRemoverOptions);
  73612. /**
  73613. * attach this feature
  73614. * Will usually be called by the features manager
  73615. *
  73616. * @returns true if successful.
  73617. */
  73618. attach(): boolean;
  73619. /**
  73620. * detach this feature.
  73621. * Will usually be called by the features manager
  73622. *
  73623. * @returns true if successful.
  73624. */
  73625. detach(): boolean;
  73626. /**
  73627. * Dispose this feature and all of the resources attached
  73628. */
  73629. dispose(): void;
  73630. protected _onXRFrame(_xrFrame: XRFrame): void;
  73631. private _setBackgroundState;
  73632. }
  73633. }
  73634. declare module BABYLON {
  73635. /**
  73636. * Options for the controller physics feature
  73637. */
  73638. export class IWebXRControllerPhysicsOptions {
  73639. /**
  73640. * Should the headset get its own impostor
  73641. */
  73642. enableHeadsetImpostor?: boolean;
  73643. /**
  73644. * Optional parameters for the headset impostor
  73645. */
  73646. headsetImpostorParams?: {
  73647. /**
  73648. * The type of impostor to create. Default is sphere
  73649. */
  73650. impostorType: number;
  73651. /**
  73652. * the size of the impostor. Defaults to 10cm
  73653. */
  73654. impostorSize?: number | {
  73655. width: number;
  73656. height: number;
  73657. depth: number;
  73658. };
  73659. /**
  73660. * Friction definitions
  73661. */
  73662. friction?: number;
  73663. /**
  73664. * Restitution
  73665. */
  73666. restitution?: number;
  73667. };
  73668. /**
  73669. * The physics properties of the future impostors
  73670. */
  73671. physicsProperties?: {
  73672. /**
  73673. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73674. * Note that this requires a physics engine that supports mesh impostors!
  73675. */
  73676. useControllerMesh?: boolean;
  73677. /**
  73678. * The type of impostor to create. Default is sphere
  73679. */
  73680. impostorType?: number;
  73681. /**
  73682. * the size of the impostor. Defaults to 10cm
  73683. */
  73684. impostorSize?: number | {
  73685. width: number;
  73686. height: number;
  73687. depth: number;
  73688. };
  73689. /**
  73690. * Friction definitions
  73691. */
  73692. friction?: number;
  73693. /**
  73694. * Restitution
  73695. */
  73696. restitution?: number;
  73697. };
  73698. /**
  73699. * the xr input to use with this pointer selection
  73700. */
  73701. xrInput: WebXRInput;
  73702. }
  73703. /**
  73704. * Add physics impostor to your webxr controllers,
  73705. * including naive calculation of their linear and angular velocity
  73706. */
  73707. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73708. private readonly _options;
  73709. private _attachController;
  73710. private _controllers;
  73711. private _debugMode;
  73712. private _delta;
  73713. private _headsetImpostor?;
  73714. private _headsetMesh?;
  73715. private _lastTimestamp;
  73716. private _tmpQuaternion;
  73717. private _tmpVector;
  73718. /**
  73719. * The module's name
  73720. */
  73721. static readonly Name: string;
  73722. /**
  73723. * The (Babylon) version of this module.
  73724. * This is an integer representing the implementation version.
  73725. * This number does not correspond to the webxr specs version
  73726. */
  73727. static readonly Version: number;
  73728. /**
  73729. * Construct a new Controller Physics Feature
  73730. * @param _xrSessionManager the corresponding xr session manager
  73731. * @param _options options to create this feature with
  73732. */
  73733. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73734. /**
  73735. * @hidden
  73736. * enable debugging - will show console outputs and the impostor mesh
  73737. */
  73738. _enablePhysicsDebug(): void;
  73739. /**
  73740. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73741. * @param xrController the controller to add
  73742. */
  73743. addController(xrController: WebXRInputSource): void;
  73744. /**
  73745. * attach this feature
  73746. * Will usually be called by the features manager
  73747. *
  73748. * @returns true if successful.
  73749. */
  73750. attach(): boolean;
  73751. /**
  73752. * detach this feature.
  73753. * Will usually be called by the features manager
  73754. *
  73755. * @returns true if successful.
  73756. */
  73757. detach(): boolean;
  73758. /**
  73759. * Get the headset impostor, if enabled
  73760. * @returns the impostor
  73761. */
  73762. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73763. /**
  73764. * Get the physics impostor of a specific controller.
  73765. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73766. * @param controller the controller or the controller id of which to get the impostor
  73767. * @returns the impostor or null
  73768. */
  73769. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73770. /**
  73771. * Update the physics properties provided in the constructor
  73772. * @param newProperties the new properties object
  73773. */
  73774. setPhysicsProperties(newProperties: {
  73775. impostorType?: number;
  73776. impostorSize?: number | {
  73777. width: number;
  73778. height: number;
  73779. depth: number;
  73780. };
  73781. friction?: number;
  73782. restitution?: number;
  73783. }): void;
  73784. protected _onXRFrame(_xrFrame: any): void;
  73785. private _detachController;
  73786. }
  73787. }
  73788. declare module BABYLON {
  73789. /**
  73790. * The motion controller class for all microsoft mixed reality controllers
  73791. */
  73792. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73793. protected readonly _mapping: {
  73794. defaultButton: {
  73795. valueNodeName: string;
  73796. unpressedNodeName: string;
  73797. pressedNodeName: string;
  73798. };
  73799. defaultAxis: {
  73800. valueNodeName: string;
  73801. minNodeName: string;
  73802. maxNodeName: string;
  73803. };
  73804. buttons: {
  73805. "xr-standard-trigger": {
  73806. rootNodeName: string;
  73807. componentProperty: string;
  73808. states: string[];
  73809. };
  73810. "xr-standard-squeeze": {
  73811. rootNodeName: string;
  73812. componentProperty: string;
  73813. states: string[];
  73814. };
  73815. "xr-standard-touchpad": {
  73816. rootNodeName: string;
  73817. labelAnchorNodeName: string;
  73818. touchPointNodeName: string;
  73819. };
  73820. "xr-standard-thumbstick": {
  73821. rootNodeName: string;
  73822. componentProperty: string;
  73823. states: string[];
  73824. };
  73825. };
  73826. axes: {
  73827. "xr-standard-touchpad": {
  73828. "x-axis": {
  73829. rootNodeName: string;
  73830. };
  73831. "y-axis": {
  73832. rootNodeName: string;
  73833. };
  73834. };
  73835. "xr-standard-thumbstick": {
  73836. "x-axis": {
  73837. rootNodeName: string;
  73838. };
  73839. "y-axis": {
  73840. rootNodeName: string;
  73841. };
  73842. };
  73843. };
  73844. };
  73845. /**
  73846. * The base url used to load the left and right controller models
  73847. */
  73848. static MODEL_BASE_URL: string;
  73849. /**
  73850. * The name of the left controller model file
  73851. */
  73852. static MODEL_LEFT_FILENAME: string;
  73853. /**
  73854. * The name of the right controller model file
  73855. */
  73856. static MODEL_RIGHT_FILENAME: string;
  73857. profileId: string;
  73858. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73859. protected _getFilenameAndPath(): {
  73860. filename: string;
  73861. path: string;
  73862. };
  73863. protected _getModelLoadingConstraints(): boolean;
  73864. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73865. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73866. protected _updateModel(): void;
  73867. }
  73868. }
  73869. declare module BABYLON {
  73870. /**
  73871. * The motion controller class for oculus touch (quest, rift).
  73872. * This class supports legacy mapping as well the standard xr mapping
  73873. */
  73874. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73875. private _forceLegacyControllers;
  73876. private _modelRootNode;
  73877. /**
  73878. * The base url used to load the left and right controller models
  73879. */
  73880. static MODEL_BASE_URL: string;
  73881. /**
  73882. * The name of the left controller model file
  73883. */
  73884. static MODEL_LEFT_FILENAME: string;
  73885. /**
  73886. * The name of the right controller model file
  73887. */
  73888. static MODEL_RIGHT_FILENAME: string;
  73889. /**
  73890. * Base Url for the Quest controller model.
  73891. */
  73892. static QUEST_MODEL_BASE_URL: string;
  73893. profileId: string;
  73894. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73895. protected _getFilenameAndPath(): {
  73896. filename: string;
  73897. path: string;
  73898. };
  73899. protected _getModelLoadingConstraints(): boolean;
  73900. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73901. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73902. protected _updateModel(): void;
  73903. /**
  73904. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73905. * between the touch and touch 2.
  73906. */
  73907. private _isQuest;
  73908. }
  73909. }
  73910. declare module BABYLON {
  73911. /**
  73912. * The motion controller class for the standard HTC-Vive controllers
  73913. */
  73914. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73915. private _modelRootNode;
  73916. /**
  73917. * The base url used to load the left and right controller models
  73918. */
  73919. static MODEL_BASE_URL: string;
  73920. /**
  73921. * File name for the controller model.
  73922. */
  73923. static MODEL_FILENAME: string;
  73924. profileId: string;
  73925. /**
  73926. * Create a new Vive motion controller object
  73927. * @param scene the scene to use to create this controller
  73928. * @param gamepadObject the corresponding gamepad object
  73929. * @param handedness the handedness of the controller
  73930. */
  73931. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73932. protected _getFilenameAndPath(): {
  73933. filename: string;
  73934. path: string;
  73935. };
  73936. protected _getModelLoadingConstraints(): boolean;
  73937. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73938. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73939. protected _updateModel(): void;
  73940. }
  73941. }
  73942. declare module BABYLON {
  73943. /**
  73944. * A cursor which tracks a point on a path
  73945. */
  73946. export class PathCursor {
  73947. private path;
  73948. /**
  73949. * Stores path cursor callbacks for when an onchange event is triggered
  73950. */
  73951. private _onchange;
  73952. /**
  73953. * The value of the path cursor
  73954. */
  73955. value: number;
  73956. /**
  73957. * The animation array of the path cursor
  73958. */
  73959. animations: Animation[];
  73960. /**
  73961. * Initializes the path cursor
  73962. * @param path The path to track
  73963. */
  73964. constructor(path: Path2);
  73965. /**
  73966. * Gets the cursor point on the path
  73967. * @returns A point on the path cursor at the cursor location
  73968. */
  73969. getPoint(): Vector3;
  73970. /**
  73971. * Moves the cursor ahead by the step amount
  73972. * @param step The amount to move the cursor forward
  73973. * @returns This path cursor
  73974. */
  73975. moveAhead(step?: number): PathCursor;
  73976. /**
  73977. * Moves the cursor behind by the step amount
  73978. * @param step The amount to move the cursor back
  73979. * @returns This path cursor
  73980. */
  73981. moveBack(step?: number): PathCursor;
  73982. /**
  73983. * Moves the cursor by the step amount
  73984. * If the step amount is greater than one, an exception is thrown
  73985. * @param step The amount to move the cursor
  73986. * @returns This path cursor
  73987. */
  73988. move(step: number): PathCursor;
  73989. /**
  73990. * Ensures that the value is limited between zero and one
  73991. * @returns This path cursor
  73992. */
  73993. private ensureLimits;
  73994. /**
  73995. * Runs onchange callbacks on change (used by the animation engine)
  73996. * @returns This path cursor
  73997. */
  73998. private raiseOnChange;
  73999. /**
  74000. * Executes a function on change
  74001. * @param f A path cursor onchange callback
  74002. * @returns This path cursor
  74003. */
  74004. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74005. }
  74006. }
  74007. declare module BABYLON {
  74008. /** @hidden */
  74009. export var blurPixelShader: {
  74010. name: string;
  74011. shader: string;
  74012. };
  74013. }
  74014. declare module BABYLON {
  74015. /** @hidden */
  74016. export var pointCloudVertexDeclaration: {
  74017. name: string;
  74018. shader: string;
  74019. };
  74020. }
  74021. // Mixins
  74022. interface Window {
  74023. mozIndexedDB: IDBFactory;
  74024. webkitIndexedDB: IDBFactory;
  74025. msIndexedDB: IDBFactory;
  74026. webkitURL: typeof URL;
  74027. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74028. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74029. WebGLRenderingContext: WebGLRenderingContext;
  74030. MSGesture: MSGesture;
  74031. CANNON: any;
  74032. AudioContext: AudioContext;
  74033. webkitAudioContext: AudioContext;
  74034. PointerEvent: any;
  74035. Math: Math;
  74036. Uint8Array: Uint8ArrayConstructor;
  74037. Float32Array: Float32ArrayConstructor;
  74038. mozURL: typeof URL;
  74039. msURL: typeof URL;
  74040. VRFrameData: any; // WebVR, from specs 1.1
  74041. DracoDecoderModule: any;
  74042. setImmediate(handler: (...args: any[]) => void): number;
  74043. }
  74044. interface HTMLCanvasElement {
  74045. requestPointerLock(): void;
  74046. msRequestPointerLock?(): void;
  74047. mozRequestPointerLock?(): void;
  74048. webkitRequestPointerLock?(): void;
  74049. /** Track wether a record is in progress */
  74050. isRecording: boolean;
  74051. /** Capture Stream method defined by some browsers */
  74052. captureStream(fps?: number): MediaStream;
  74053. }
  74054. interface CanvasRenderingContext2D {
  74055. msImageSmoothingEnabled: boolean;
  74056. }
  74057. interface MouseEvent {
  74058. mozMovementX: number;
  74059. mozMovementY: number;
  74060. webkitMovementX: number;
  74061. webkitMovementY: number;
  74062. msMovementX: number;
  74063. msMovementY: number;
  74064. }
  74065. interface Navigator {
  74066. mozGetVRDevices: (any: any) => any;
  74067. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74068. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74069. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74070. webkitGetGamepads(): Gamepad[];
  74071. msGetGamepads(): Gamepad[];
  74072. webkitGamepads(): Gamepad[];
  74073. }
  74074. interface HTMLVideoElement {
  74075. mozSrcObject: any;
  74076. }
  74077. interface Math {
  74078. fround(x: number): number;
  74079. imul(a: number, b: number): number;
  74080. }
  74081. interface WebGLRenderingContext {
  74082. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74083. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74084. vertexAttribDivisor(index: number, divisor: number): void;
  74085. createVertexArray(): any;
  74086. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74087. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74088. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74089. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74090. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74091. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74092. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74093. // Queries
  74094. createQuery(): WebGLQuery;
  74095. deleteQuery(query: WebGLQuery): void;
  74096. beginQuery(target: number, query: WebGLQuery): void;
  74097. endQuery(target: number): void;
  74098. getQueryParameter(query: WebGLQuery, pname: number): any;
  74099. getQuery(target: number, pname: number): any;
  74100. MAX_SAMPLES: number;
  74101. RGBA8: number;
  74102. READ_FRAMEBUFFER: number;
  74103. DRAW_FRAMEBUFFER: number;
  74104. UNIFORM_BUFFER: number;
  74105. HALF_FLOAT_OES: number;
  74106. RGBA16F: number;
  74107. RGBA32F: number;
  74108. R32F: number;
  74109. RG32F: number;
  74110. RGB32F: number;
  74111. R16F: number;
  74112. RG16F: number;
  74113. RGB16F: number;
  74114. RED: number;
  74115. RG: number;
  74116. R8: number;
  74117. RG8: number;
  74118. UNSIGNED_INT_24_8: number;
  74119. DEPTH24_STENCIL8: number;
  74120. MIN: number;
  74121. MAX: number;
  74122. /* Multiple Render Targets */
  74123. drawBuffers(buffers: number[]): void;
  74124. readBuffer(src: number): void;
  74125. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74126. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74127. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74128. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74129. // Occlusion Query
  74130. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74131. ANY_SAMPLES_PASSED: number;
  74132. QUERY_RESULT_AVAILABLE: number;
  74133. QUERY_RESULT: number;
  74134. }
  74135. interface WebGLProgram {
  74136. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74137. }
  74138. interface EXT_disjoint_timer_query {
  74139. QUERY_COUNTER_BITS_EXT: number;
  74140. TIME_ELAPSED_EXT: number;
  74141. TIMESTAMP_EXT: number;
  74142. GPU_DISJOINT_EXT: number;
  74143. QUERY_RESULT_EXT: number;
  74144. QUERY_RESULT_AVAILABLE_EXT: number;
  74145. queryCounterEXT(query: WebGLQuery, target: number): void;
  74146. createQueryEXT(): WebGLQuery;
  74147. beginQueryEXT(target: number, query: WebGLQuery): void;
  74148. endQueryEXT(target: number): void;
  74149. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74150. deleteQueryEXT(query: WebGLQuery): void;
  74151. }
  74152. interface WebGLUniformLocation {
  74153. _currentState: any;
  74154. }
  74155. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74156. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74157. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74158. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74159. interface WebGLRenderingContext {
  74160. readonly RASTERIZER_DISCARD: number;
  74161. readonly DEPTH_COMPONENT24: number;
  74162. readonly TEXTURE_3D: number;
  74163. readonly TEXTURE_2D_ARRAY: number;
  74164. readonly TEXTURE_COMPARE_FUNC: number;
  74165. readonly TEXTURE_COMPARE_MODE: number;
  74166. readonly COMPARE_REF_TO_TEXTURE: number;
  74167. readonly TEXTURE_WRAP_R: number;
  74168. readonly HALF_FLOAT: number;
  74169. readonly RGB8: number;
  74170. readonly RED_INTEGER: number;
  74171. readonly RG_INTEGER: number;
  74172. readonly RGB_INTEGER: number;
  74173. readonly RGBA_INTEGER: number;
  74174. readonly R8_SNORM: number;
  74175. readonly RG8_SNORM: number;
  74176. readonly RGB8_SNORM: number;
  74177. readonly RGBA8_SNORM: number;
  74178. readonly R8I: number;
  74179. readonly RG8I: number;
  74180. readonly RGB8I: number;
  74181. readonly RGBA8I: number;
  74182. readonly R8UI: number;
  74183. readonly RG8UI: number;
  74184. readonly RGB8UI: number;
  74185. readonly RGBA8UI: number;
  74186. readonly R16I: number;
  74187. readonly RG16I: number;
  74188. readonly RGB16I: number;
  74189. readonly RGBA16I: number;
  74190. readonly R16UI: number;
  74191. readonly RG16UI: number;
  74192. readonly RGB16UI: number;
  74193. readonly RGBA16UI: number;
  74194. readonly R32I: number;
  74195. readonly RG32I: number;
  74196. readonly RGB32I: number;
  74197. readonly RGBA32I: number;
  74198. readonly R32UI: number;
  74199. readonly RG32UI: number;
  74200. readonly RGB32UI: number;
  74201. readonly RGBA32UI: number;
  74202. readonly RGB10_A2UI: number;
  74203. readonly R11F_G11F_B10F: number;
  74204. readonly RGB9_E5: number;
  74205. readonly RGB10_A2: number;
  74206. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74207. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74208. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74209. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74210. readonly DEPTH_COMPONENT32F: number;
  74211. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74212. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74213. 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;
  74214. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74215. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74216. readonly TRANSFORM_FEEDBACK: number;
  74217. readonly INTERLEAVED_ATTRIBS: number;
  74218. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74219. createTransformFeedback(): WebGLTransformFeedback;
  74220. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74221. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74222. beginTransformFeedback(primitiveMode: number): void;
  74223. endTransformFeedback(): void;
  74224. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74225. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74226. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74227. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74228. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74229. }
  74230. interface ImageBitmap {
  74231. readonly width: number;
  74232. readonly height: number;
  74233. close(): void;
  74234. }
  74235. interface WebGLQuery extends WebGLObject {
  74236. }
  74237. declare var WebGLQuery: {
  74238. prototype: WebGLQuery;
  74239. new(): WebGLQuery;
  74240. };
  74241. interface WebGLSampler extends WebGLObject {
  74242. }
  74243. declare var WebGLSampler: {
  74244. prototype: WebGLSampler;
  74245. new(): WebGLSampler;
  74246. };
  74247. interface WebGLSync extends WebGLObject {
  74248. }
  74249. declare var WebGLSync: {
  74250. prototype: WebGLSync;
  74251. new(): WebGLSync;
  74252. };
  74253. interface WebGLTransformFeedback extends WebGLObject {
  74254. }
  74255. declare var WebGLTransformFeedback: {
  74256. prototype: WebGLTransformFeedback;
  74257. new(): WebGLTransformFeedback;
  74258. };
  74259. interface WebGLVertexArrayObject extends WebGLObject {
  74260. }
  74261. declare var WebGLVertexArrayObject: {
  74262. prototype: WebGLVertexArrayObject;
  74263. new(): WebGLVertexArrayObject;
  74264. };
  74265. // Type definitions for WebVR API
  74266. // Project: https://w3c.github.io/webvr/
  74267. // Definitions by: six a <https://github.com/lostfictions>
  74268. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74269. interface VRDisplay extends EventTarget {
  74270. /**
  74271. * Dictionary of capabilities describing the VRDisplay.
  74272. */
  74273. readonly capabilities: VRDisplayCapabilities;
  74274. /**
  74275. * z-depth defining the far plane of the eye view frustum
  74276. * enables mapping of values in the render target depth
  74277. * attachment to scene coordinates. Initially set to 10000.0.
  74278. */
  74279. depthFar: number;
  74280. /**
  74281. * z-depth defining the near plane of the eye view frustum
  74282. * enables mapping of values in the render target depth
  74283. * attachment to scene coordinates. Initially set to 0.01.
  74284. */
  74285. depthNear: number;
  74286. /**
  74287. * An identifier for this distinct VRDisplay. Used as an
  74288. * association point in the Gamepad API.
  74289. */
  74290. readonly displayId: number;
  74291. /**
  74292. * A display name, a user-readable name identifying it.
  74293. */
  74294. readonly displayName: string;
  74295. readonly isConnected: boolean;
  74296. readonly isPresenting: boolean;
  74297. /**
  74298. * If this VRDisplay supports room-scale experiences, the optional
  74299. * stage attribute contains details on the room-scale parameters.
  74300. */
  74301. readonly stageParameters: VRStageParameters | null;
  74302. /**
  74303. * Passing the value returned by `requestAnimationFrame` to
  74304. * `cancelAnimationFrame` will unregister the callback.
  74305. * @param handle Define the hanle of the request to cancel
  74306. */
  74307. cancelAnimationFrame(handle: number): void;
  74308. /**
  74309. * Stops presenting to the VRDisplay.
  74310. * @returns a promise to know when it stopped
  74311. */
  74312. exitPresent(): Promise<void>;
  74313. /**
  74314. * Return the current VREyeParameters for the given eye.
  74315. * @param whichEye Define the eye we want the parameter for
  74316. * @returns the eye parameters
  74317. */
  74318. getEyeParameters(whichEye: string): VREyeParameters;
  74319. /**
  74320. * Populates the passed VRFrameData with the information required to render
  74321. * the current frame.
  74322. * @param frameData Define the data structure to populate
  74323. * @returns true if ok otherwise false
  74324. */
  74325. getFrameData(frameData: VRFrameData): boolean;
  74326. /**
  74327. * Get the layers currently being presented.
  74328. * @returns the list of VR layers
  74329. */
  74330. getLayers(): VRLayer[];
  74331. /**
  74332. * Return a VRPose containing the future predicted pose of the VRDisplay
  74333. * when the current frame will be presented. The value returned will not
  74334. * change until JavaScript has returned control to the browser.
  74335. *
  74336. * The VRPose will contain the position, orientation, velocity,
  74337. * and acceleration of each of these properties.
  74338. * @returns the pose object
  74339. */
  74340. getPose(): VRPose;
  74341. /**
  74342. * Return the current instantaneous pose of the VRDisplay, with no
  74343. * prediction applied.
  74344. * @returns the current instantaneous pose
  74345. */
  74346. getImmediatePose(): VRPose;
  74347. /**
  74348. * The callback passed to `requestAnimationFrame` will be called
  74349. * any time a new frame should be rendered. When the VRDisplay is
  74350. * presenting the callback will be called at the native refresh
  74351. * rate of the HMD. When not presenting this function acts
  74352. * identically to how window.requestAnimationFrame acts. Content should
  74353. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74354. * asynchronously from other displays and at differing refresh rates.
  74355. * @param callback Define the eaction to run next frame
  74356. * @returns the request handle it
  74357. */
  74358. requestAnimationFrame(callback: FrameRequestCallback): number;
  74359. /**
  74360. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74361. * Repeat calls while already presenting will update the VRLayers being displayed.
  74362. * @param layers Define the list of layer to present
  74363. * @returns a promise to know when the request has been fulfilled
  74364. */
  74365. requestPresent(layers: VRLayer[]): Promise<void>;
  74366. /**
  74367. * Reset the pose for this display, treating its current position and
  74368. * orientation as the "origin/zero" values. VRPose.position,
  74369. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74370. * updated when calling resetPose(). This should be called in only
  74371. * sitting-space experiences.
  74372. */
  74373. resetPose(): void;
  74374. /**
  74375. * The VRLayer provided to the VRDisplay will be captured and presented
  74376. * in the HMD. Calling this function has the same effect on the source
  74377. * canvas as any other operation that uses its source image, and canvases
  74378. * created without preserveDrawingBuffer set to true will be cleared.
  74379. * @param pose Define the pose to submit
  74380. */
  74381. submitFrame(pose?: VRPose): void;
  74382. }
  74383. declare var VRDisplay: {
  74384. prototype: VRDisplay;
  74385. new(): VRDisplay;
  74386. };
  74387. interface VRLayer {
  74388. leftBounds?: number[] | Float32Array | null;
  74389. rightBounds?: number[] | Float32Array | null;
  74390. source?: HTMLCanvasElement | null;
  74391. }
  74392. interface VRDisplayCapabilities {
  74393. readonly canPresent: boolean;
  74394. readonly hasExternalDisplay: boolean;
  74395. readonly hasOrientation: boolean;
  74396. readonly hasPosition: boolean;
  74397. readonly maxLayers: number;
  74398. }
  74399. interface VREyeParameters {
  74400. /** @deprecated */
  74401. readonly fieldOfView: VRFieldOfView;
  74402. readonly offset: Float32Array;
  74403. readonly renderHeight: number;
  74404. readonly renderWidth: number;
  74405. }
  74406. interface VRFieldOfView {
  74407. readonly downDegrees: number;
  74408. readonly leftDegrees: number;
  74409. readonly rightDegrees: number;
  74410. readonly upDegrees: number;
  74411. }
  74412. interface VRFrameData {
  74413. readonly leftProjectionMatrix: Float32Array;
  74414. readonly leftViewMatrix: Float32Array;
  74415. readonly pose: VRPose;
  74416. readonly rightProjectionMatrix: Float32Array;
  74417. readonly rightViewMatrix: Float32Array;
  74418. readonly timestamp: number;
  74419. }
  74420. interface VRPose {
  74421. readonly angularAcceleration: Float32Array | null;
  74422. readonly angularVelocity: Float32Array | null;
  74423. readonly linearAcceleration: Float32Array | null;
  74424. readonly linearVelocity: Float32Array | null;
  74425. readonly orientation: Float32Array | null;
  74426. readonly position: Float32Array | null;
  74427. readonly timestamp: number;
  74428. }
  74429. interface VRStageParameters {
  74430. sittingToStandingTransform?: Float32Array;
  74431. sizeX?: number;
  74432. sizeY?: number;
  74433. }
  74434. interface Navigator {
  74435. getVRDisplays(): Promise<VRDisplay[]>;
  74436. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74437. }
  74438. interface Window {
  74439. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74440. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74441. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74442. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74443. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74444. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74445. }
  74446. interface Gamepad {
  74447. readonly displayId: number;
  74448. }
  74449. type XRSessionMode =
  74450. | "inline"
  74451. | "immersive-vr"
  74452. | "immersive-ar";
  74453. type XRReferenceSpaceType =
  74454. | "viewer"
  74455. | "local"
  74456. | "local-floor"
  74457. | "bounded-floor"
  74458. | "unbounded";
  74459. type XREnvironmentBlendMode =
  74460. | "opaque"
  74461. | "additive"
  74462. | "alpha-blend";
  74463. type XRVisibilityState =
  74464. | "visible"
  74465. | "visible-blurred"
  74466. | "hidden";
  74467. type XRHandedness =
  74468. | "none"
  74469. | "left"
  74470. | "right";
  74471. type XRTargetRayMode =
  74472. | "gaze"
  74473. | "tracked-pointer"
  74474. | "screen";
  74475. type XREye =
  74476. | "none"
  74477. | "left"
  74478. | "right";
  74479. type XREventType =
  74480. | "devicechange"
  74481. | "visibilitychange"
  74482. | "end"
  74483. | "inputsourceschange"
  74484. | "select"
  74485. | "selectstart"
  74486. | "selectend"
  74487. | "squeeze"
  74488. | "squeezestart"
  74489. | "squeezeend"
  74490. | "reset";
  74491. interface XRSpace extends EventTarget {
  74492. }
  74493. interface XRRenderState {
  74494. depthNear?: number;
  74495. depthFar?: number;
  74496. inlineVerticalFieldOfView?: number;
  74497. baseLayer?: XRWebGLLayer;
  74498. }
  74499. interface XRInputSource {
  74500. handedness: XRHandedness;
  74501. targetRayMode: XRTargetRayMode;
  74502. targetRaySpace: XRSpace;
  74503. gripSpace: XRSpace | undefined;
  74504. gamepad: Gamepad | undefined;
  74505. profiles: Array<string>;
  74506. }
  74507. interface XRSessionInit {
  74508. optionalFeatures?: string[];
  74509. requiredFeatures?: string[];
  74510. }
  74511. interface XRSession {
  74512. addEventListener: Function;
  74513. removeEventListener: Function;
  74514. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74515. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74516. requestAnimationFrame: Function;
  74517. end(): Promise<void>;
  74518. renderState: XRRenderState;
  74519. inputSources: Array<XRInputSource>;
  74520. // hit test
  74521. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74522. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74523. // legacy AR hit test
  74524. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74525. // legacy plane detection
  74526. updateWorldTrackingState(options: {
  74527. planeDetectionState?: { enabled: boolean; }
  74528. }): void;
  74529. }
  74530. interface XRReferenceSpace extends XRSpace {
  74531. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74532. onreset: any;
  74533. }
  74534. type XRPlaneSet = Set<XRPlane>;
  74535. type XRAnchorSet = Set<XRAnchor>;
  74536. interface XRFrame {
  74537. session: XRSession;
  74538. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74539. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74540. // AR
  74541. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74542. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74543. // Anchors
  74544. trackedAnchors?: XRAnchorSet;
  74545. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74546. // Planes
  74547. worldInformation: {
  74548. detectedPlanes?: XRPlaneSet;
  74549. };
  74550. }
  74551. interface XRViewerPose extends XRPose {
  74552. views: Array<XRView>;
  74553. }
  74554. interface XRPose {
  74555. transform: XRRigidTransform;
  74556. emulatedPosition: boolean;
  74557. }
  74558. interface XRWebGLLayerOptions {
  74559. antialias?: boolean;
  74560. depth?: boolean;
  74561. stencil?: boolean;
  74562. alpha?: boolean;
  74563. multiview?: boolean;
  74564. framebufferScaleFactor?: number;
  74565. }
  74566. declare var XRWebGLLayer: {
  74567. prototype: XRWebGLLayer;
  74568. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74569. };
  74570. interface XRWebGLLayer {
  74571. framebuffer: WebGLFramebuffer;
  74572. framebufferWidth: number;
  74573. framebufferHeight: number;
  74574. getViewport: Function;
  74575. }
  74576. declare class XRRigidTransform {
  74577. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74578. position: DOMPointReadOnly;
  74579. orientation: DOMPointReadOnly;
  74580. matrix: Float32Array;
  74581. inverse: XRRigidTransform;
  74582. }
  74583. interface XRView {
  74584. eye: XREye;
  74585. projectionMatrix: Float32Array;
  74586. transform: XRRigidTransform;
  74587. }
  74588. interface XRInputSourceChangeEvent {
  74589. session: XRSession;
  74590. removed: Array<XRInputSource>;
  74591. added: Array<XRInputSource>;
  74592. }
  74593. interface XRInputSourceEvent extends Event {
  74594. readonly frame: XRFrame;
  74595. readonly inputSource: XRInputSource;
  74596. }
  74597. // Experimental(er) features
  74598. declare class XRRay {
  74599. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74600. origin: DOMPointReadOnly;
  74601. direction: DOMPointReadOnly;
  74602. matrix: Float32Array;
  74603. }
  74604. declare enum XRHitTestTrackableType {
  74605. "point",
  74606. "plane"
  74607. }
  74608. interface XRHitResult {
  74609. hitMatrix: Float32Array;
  74610. }
  74611. interface XRTransientInputHitTestResult {
  74612. readonly inputSource: XRInputSource;
  74613. readonly results: Array<XRHitTestResult>;
  74614. }
  74615. interface XRHitTestResult {
  74616. getPose(baseSpace: XRSpace): XRPose | undefined;
  74617. // When anchor system is enabled
  74618. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74619. }
  74620. interface XRHitTestSource {
  74621. cancel(): void;
  74622. }
  74623. interface XRTransientInputHitTestSource {
  74624. cancel(): void;
  74625. }
  74626. interface XRHitTestOptionsInit {
  74627. space: XRSpace;
  74628. entityTypes?: Array<XRHitTestTrackableType>;
  74629. offsetRay?: XRRay;
  74630. }
  74631. interface XRTransientInputHitTestOptionsInit {
  74632. profile: string;
  74633. entityTypes?: Array<XRHitTestTrackableType>;
  74634. offsetRay?: XRRay;
  74635. }
  74636. interface XRAnchor {
  74637. anchorSpace: XRSpace;
  74638. delete(): void;
  74639. }
  74640. interface XRPlane {
  74641. orientation: "Horizontal" | "Vertical";
  74642. planeSpace: XRSpace;
  74643. polygon: Array<DOMPointReadOnly>;
  74644. lastChangedTime: number;
  74645. }
  74646. /**
  74647. * @ignore
  74648. */
  74649. declare module BABYLON.GLTF2.Exporter {
  74650. }
  74651. /**
  74652. * @ignore
  74653. */
  74654. declare module BABYLON.GLTF1 {
  74655. }
  74656. declare module BABYLON.GUI {
  74657. /**
  74658. * Class used to specific a value and its associated unit
  74659. */
  74660. export class ValueAndUnit {
  74661. /** defines the unit to store */
  74662. unit: number;
  74663. /** defines a boolean indicating if the value can be negative */
  74664. negativeValueAllowed: boolean;
  74665. private _value;
  74666. private _originalUnit;
  74667. /**
  74668. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74669. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74670. */
  74671. ignoreAdaptiveScaling: boolean;
  74672. /**
  74673. * Creates a new ValueAndUnit
  74674. * @param value defines the value to store
  74675. * @param unit defines the unit to store
  74676. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74677. */
  74678. constructor(value: number,
  74679. /** defines the unit to store */
  74680. unit?: number,
  74681. /** defines a boolean indicating if the value can be negative */
  74682. negativeValueAllowed?: boolean);
  74683. /** Gets a boolean indicating if the value is a percentage */
  74684. get isPercentage(): boolean;
  74685. /** Gets a boolean indicating if the value is store as pixel */
  74686. get isPixel(): boolean;
  74687. /** Gets direct internal value */
  74688. get internalValue(): number;
  74689. /**
  74690. * Gets value as pixel
  74691. * @param host defines the root host
  74692. * @param refValue defines the reference value for percentages
  74693. * @returns the value as pixel
  74694. */
  74695. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74696. /**
  74697. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74698. * @param value defines the value to store
  74699. * @param unit defines the unit to store
  74700. * @returns the current ValueAndUnit
  74701. */
  74702. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74703. /**
  74704. * Gets the value accordingly to its unit
  74705. * @param host defines the root host
  74706. * @returns the value
  74707. */
  74708. getValue(host: AdvancedDynamicTexture): number;
  74709. /**
  74710. * Gets a string representation of the value
  74711. * @param host defines the root host
  74712. * @param decimals defines an optional number of decimals to display
  74713. * @returns a string
  74714. */
  74715. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74716. /**
  74717. * Store a value parsed from a string
  74718. * @param source defines the source string
  74719. * @returns true if the value was successfully parsed
  74720. */
  74721. fromString(source: string | number): boolean;
  74722. private static _Regex;
  74723. private static _UNITMODE_PERCENTAGE;
  74724. private static _UNITMODE_PIXEL;
  74725. /** UNITMODE_PERCENTAGE */
  74726. static get UNITMODE_PERCENTAGE(): number;
  74727. /** UNITMODE_PIXEL */
  74728. static get UNITMODE_PIXEL(): number;
  74729. }
  74730. }
  74731. declare module BABYLON.GUI {
  74732. /**
  74733. * Define a style used by control to automatically setup properties based on a template.
  74734. * Only support font related properties so far
  74735. */
  74736. export class Style implements BABYLON.IDisposable {
  74737. private _fontFamily;
  74738. private _fontStyle;
  74739. private _fontWeight;
  74740. /** @hidden */
  74741. _host: AdvancedDynamicTexture;
  74742. /** @hidden */
  74743. _fontSize: ValueAndUnit;
  74744. /**
  74745. * BABYLON.Observable raised when the style values are changed
  74746. */
  74747. onChangedObservable: BABYLON.Observable<Style>;
  74748. /**
  74749. * Creates a new style object
  74750. * @param host defines the AdvancedDynamicTexture which hosts this style
  74751. */
  74752. constructor(host: AdvancedDynamicTexture);
  74753. /**
  74754. * Gets or sets the font size
  74755. */
  74756. get fontSize(): string | number;
  74757. set fontSize(value: string | number);
  74758. /**
  74759. * Gets or sets the font family
  74760. */
  74761. get fontFamily(): string;
  74762. set fontFamily(value: string);
  74763. /**
  74764. * Gets or sets the font style
  74765. */
  74766. get fontStyle(): string;
  74767. set fontStyle(value: string);
  74768. /** Gets or sets font weight */
  74769. get fontWeight(): string;
  74770. set fontWeight(value: string);
  74771. /** Dispose all associated resources */
  74772. dispose(): void;
  74773. }
  74774. }
  74775. declare module BABYLON.GUI {
  74776. /**
  74777. * Class used to transport BABYLON.Vector2 information for pointer events
  74778. */
  74779. export class Vector2WithInfo extends BABYLON.Vector2 {
  74780. /** defines the current mouse button index */
  74781. buttonIndex: number;
  74782. /**
  74783. * Creates a new Vector2WithInfo
  74784. * @param source defines the vector2 data to transport
  74785. * @param buttonIndex defines the current mouse button index
  74786. */
  74787. constructor(source: BABYLON.Vector2,
  74788. /** defines the current mouse button index */
  74789. buttonIndex?: number);
  74790. }
  74791. /** Class used to provide 2D matrix features */
  74792. export class Matrix2D {
  74793. /** Gets the internal array of 6 floats used to store matrix data */
  74794. m: Float32Array;
  74795. /**
  74796. * Creates a new matrix
  74797. * @param m00 defines value for (0, 0)
  74798. * @param m01 defines value for (0, 1)
  74799. * @param m10 defines value for (1, 0)
  74800. * @param m11 defines value for (1, 1)
  74801. * @param m20 defines value for (2, 0)
  74802. * @param m21 defines value for (2, 1)
  74803. */
  74804. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74805. /**
  74806. * Fills the matrix from direct values
  74807. * @param m00 defines value for (0, 0)
  74808. * @param m01 defines value for (0, 1)
  74809. * @param m10 defines value for (1, 0)
  74810. * @param m11 defines value for (1, 1)
  74811. * @param m20 defines value for (2, 0)
  74812. * @param m21 defines value for (2, 1)
  74813. * @returns the current modified matrix
  74814. */
  74815. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74816. /**
  74817. * Gets matrix determinant
  74818. * @returns the determinant
  74819. */
  74820. determinant(): number;
  74821. /**
  74822. * Inverses the matrix and stores it in a target matrix
  74823. * @param result defines the target matrix
  74824. * @returns the current matrix
  74825. */
  74826. invertToRef(result: Matrix2D): Matrix2D;
  74827. /**
  74828. * Multiplies the current matrix with another one
  74829. * @param other defines the second operand
  74830. * @param result defines the target matrix
  74831. * @returns the current matrix
  74832. */
  74833. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74834. /**
  74835. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74836. * @param x defines the x coordinate to transform
  74837. * @param y defines the x coordinate to transform
  74838. * @param result defines the target vector2
  74839. * @returns the current matrix
  74840. */
  74841. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74842. /**
  74843. * Creates an identity matrix
  74844. * @returns a new matrix
  74845. */
  74846. static Identity(): Matrix2D;
  74847. /**
  74848. * Creates a translation matrix and stores it in a target matrix
  74849. * @param x defines the x coordinate of the translation
  74850. * @param y defines the y coordinate of the translation
  74851. * @param result defines the target matrix
  74852. */
  74853. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74854. /**
  74855. * Creates a scaling matrix and stores it in a target matrix
  74856. * @param x defines the x coordinate of the scaling
  74857. * @param y defines the y coordinate of the scaling
  74858. * @param result defines the target matrix
  74859. */
  74860. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74861. /**
  74862. * Creates a rotation matrix and stores it in a target matrix
  74863. * @param angle defines the rotation angle
  74864. * @param result defines the target matrix
  74865. */
  74866. static RotationToRef(angle: number, result: Matrix2D): void;
  74867. private static _TempPreTranslationMatrix;
  74868. private static _TempPostTranslationMatrix;
  74869. private static _TempRotationMatrix;
  74870. private static _TempScalingMatrix;
  74871. private static _TempCompose0;
  74872. private static _TempCompose1;
  74873. private static _TempCompose2;
  74874. /**
  74875. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74876. * @param tx defines the x coordinate of the translation
  74877. * @param ty defines the y coordinate of the translation
  74878. * @param angle defines the rotation angle
  74879. * @param scaleX defines the x coordinate of the scaling
  74880. * @param scaleY defines the y coordinate of the scaling
  74881. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74882. * @param result defines the target matrix
  74883. */
  74884. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74885. }
  74886. }
  74887. declare module BABYLON.GUI {
  74888. /**
  74889. * Class used to store 2D control sizes
  74890. */
  74891. export class Measure {
  74892. /** defines left coordinate */
  74893. left: number;
  74894. /** defines top coordinate */
  74895. top: number;
  74896. /** defines width dimension */
  74897. width: number;
  74898. /** defines height dimension */
  74899. height: number;
  74900. /**
  74901. * Creates a new measure
  74902. * @param left defines left coordinate
  74903. * @param top defines top coordinate
  74904. * @param width defines width dimension
  74905. * @param height defines height dimension
  74906. */
  74907. constructor(
  74908. /** defines left coordinate */
  74909. left: number,
  74910. /** defines top coordinate */
  74911. top: number,
  74912. /** defines width dimension */
  74913. width: number,
  74914. /** defines height dimension */
  74915. height: number);
  74916. /**
  74917. * Copy from another measure
  74918. * @param other defines the other measure to copy from
  74919. */
  74920. copyFrom(other: Measure): void;
  74921. /**
  74922. * Copy from a group of 4 floats
  74923. * @param left defines left coordinate
  74924. * @param top defines top coordinate
  74925. * @param width defines width dimension
  74926. * @param height defines height dimension
  74927. */
  74928. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74929. /**
  74930. * Computes the axis aligned bounding box measure for two given measures
  74931. * @param a Input measure
  74932. * @param b Input measure
  74933. * @param result the resulting bounding measure
  74934. */
  74935. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74936. /**
  74937. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74938. * @param transform the matrix to transform the measure before computing the AABB
  74939. * @param result the resulting AABB
  74940. */
  74941. transformToRef(transform: Matrix2D, result: Measure): void;
  74942. /**
  74943. * Check equality between this measure and another one
  74944. * @param other defines the other measures
  74945. * @returns true if both measures are equals
  74946. */
  74947. isEqualsTo(other: Measure): boolean;
  74948. /**
  74949. * Creates an empty measure
  74950. * @returns a new measure
  74951. */
  74952. static Empty(): Measure;
  74953. }
  74954. }
  74955. declare module BABYLON.GUI {
  74956. /**
  74957. * Interface used to define a control that can receive focus
  74958. */
  74959. export interface IFocusableControl {
  74960. /**
  74961. * Function called when the control receives the focus
  74962. */
  74963. onFocus(): void;
  74964. /**
  74965. * Function called when the control loses the focus
  74966. */
  74967. onBlur(): void;
  74968. /**
  74969. * Function called to let the control handle keyboard events
  74970. * @param evt defines the current keyboard event
  74971. */
  74972. processKeyboard(evt: KeyboardEvent): void;
  74973. /**
  74974. * Function called to get the list of controls that should not steal the focus from this control
  74975. * @returns an array of controls
  74976. */
  74977. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74978. }
  74979. /**
  74980. * Class used to create texture to support 2D GUI elements
  74981. * @see https://doc.babylonjs.com/how_to/gui
  74982. */
  74983. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74984. private _isDirty;
  74985. private _renderObserver;
  74986. private _resizeObserver;
  74987. private _preKeyboardObserver;
  74988. private _pointerMoveObserver;
  74989. private _pointerObserver;
  74990. private _canvasPointerOutObserver;
  74991. private _background;
  74992. /** @hidden */
  74993. _rootContainer: Container;
  74994. /** @hidden */
  74995. _lastPickedControl: Control;
  74996. /** @hidden */
  74997. _lastControlOver: {
  74998. [pointerId: number]: Control;
  74999. };
  75000. /** @hidden */
  75001. _lastControlDown: {
  75002. [pointerId: number]: Control;
  75003. };
  75004. /** @hidden */
  75005. _capturingControl: {
  75006. [pointerId: number]: Control;
  75007. };
  75008. /** @hidden */
  75009. _shouldBlockPointer: boolean;
  75010. /** @hidden */
  75011. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75012. /** @hidden */
  75013. _linkedControls: Control[];
  75014. private _isFullscreen;
  75015. private _fullscreenViewport;
  75016. private _idealWidth;
  75017. private _idealHeight;
  75018. private _useSmallestIdeal;
  75019. private _renderAtIdealSize;
  75020. private _focusedControl;
  75021. private _blockNextFocusCheck;
  75022. private _renderScale;
  75023. private _rootElement;
  75024. private _cursorChanged;
  75025. private _defaultMousePointerId;
  75026. /** @hidden */
  75027. _numLayoutCalls: number;
  75028. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75029. get numLayoutCalls(): number;
  75030. /** @hidden */
  75031. _numRenderCalls: number;
  75032. /** Gets the number of render calls made the last time the ADT has been rendered */
  75033. get numRenderCalls(): number;
  75034. /**
  75035. * Define type to string to ensure compatibility across browsers
  75036. * Safari doesn't support DataTransfer constructor
  75037. */
  75038. private _clipboardData;
  75039. /**
  75040. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75041. */
  75042. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75043. /**
  75044. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75045. */
  75046. onControlPickedObservable: BABYLON.Observable<Control>;
  75047. /**
  75048. * BABYLON.Observable event triggered before layout is evaluated
  75049. */
  75050. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75051. /**
  75052. * BABYLON.Observable event triggered after the layout was evaluated
  75053. */
  75054. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75055. /**
  75056. * BABYLON.Observable event triggered before the texture is rendered
  75057. */
  75058. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75059. /**
  75060. * BABYLON.Observable event triggered after the texture was rendered
  75061. */
  75062. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75063. /**
  75064. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75065. */
  75066. premulAlpha: boolean;
  75067. /**
  75068. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75069. * Useful when you want more antialiasing
  75070. */
  75071. get renderScale(): number;
  75072. set renderScale(value: number);
  75073. /** Gets or sets the background color */
  75074. get background(): string;
  75075. set background(value: string);
  75076. /**
  75077. * Gets or sets the ideal width used to design controls.
  75078. * The GUI will then rescale everything accordingly
  75079. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75080. */
  75081. get idealWidth(): number;
  75082. set idealWidth(value: number);
  75083. /**
  75084. * Gets or sets the ideal height used to design controls.
  75085. * The GUI will then rescale everything accordingly
  75086. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75087. */
  75088. get idealHeight(): number;
  75089. set idealHeight(value: number);
  75090. /**
  75091. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75092. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75093. */
  75094. get useSmallestIdeal(): boolean;
  75095. set useSmallestIdeal(value: boolean);
  75096. /**
  75097. * Gets or sets a boolean indicating if adaptive scaling must be used
  75098. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75099. */
  75100. get renderAtIdealSize(): boolean;
  75101. set renderAtIdealSize(value: boolean);
  75102. /**
  75103. * Gets the ratio used when in "ideal mode"
  75104. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75105. * */
  75106. get idealRatio(): number;
  75107. /**
  75108. * Gets the underlying layer used to render the texture when in fullscreen mode
  75109. */
  75110. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75111. /**
  75112. * Gets the root container control
  75113. */
  75114. get rootContainer(): Container;
  75115. /**
  75116. * Returns an array containing the root container.
  75117. * This is mostly used to let the Inspector introspects the ADT
  75118. * @returns an array containing the rootContainer
  75119. */
  75120. getChildren(): Array<Container>;
  75121. /**
  75122. * Will return all controls that are inside this texture
  75123. * @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
  75124. * @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
  75125. * @return all child controls
  75126. */
  75127. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75128. /**
  75129. * Gets or sets the current focused control
  75130. */
  75131. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75132. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75133. /**
  75134. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75135. */
  75136. get isForeground(): boolean;
  75137. set isForeground(value: boolean);
  75138. /**
  75139. * Gets or set information about clipboardData
  75140. */
  75141. get clipboardData(): string;
  75142. set clipboardData(value: string);
  75143. /**
  75144. * Creates a new AdvancedDynamicTexture
  75145. * @param name defines the name of the texture
  75146. * @param width defines the width of the texture
  75147. * @param height defines the height of the texture
  75148. * @param scene defines the hosting scene
  75149. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75150. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75151. */
  75152. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75153. /**
  75154. * Get the current class name of the texture useful for serialization or dynamic coding.
  75155. * @returns "AdvancedDynamicTexture"
  75156. */
  75157. getClassName(): string;
  75158. /**
  75159. * Function used to execute a function on all controls
  75160. * @param func defines the function to execute
  75161. * @param container defines the container where controls belong. If null the root container will be used
  75162. */
  75163. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75164. private _useInvalidateRectOptimization;
  75165. /**
  75166. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75167. */
  75168. get useInvalidateRectOptimization(): boolean;
  75169. set useInvalidateRectOptimization(value: boolean);
  75170. private _invalidatedRectangle;
  75171. /**
  75172. * Invalidates a rectangle area on the gui texture
  75173. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75174. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75175. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75176. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75177. */
  75178. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75179. /**
  75180. * Marks the texture as dirty forcing a complete update
  75181. */
  75182. markAsDirty(): void;
  75183. /**
  75184. * Helper function used to create a new style
  75185. * @returns a new style
  75186. * @see https://doc.babylonjs.com/how_to/gui#styles
  75187. */
  75188. createStyle(): Style;
  75189. /**
  75190. * Adds a new control to the root container
  75191. * @param control defines the control to add
  75192. * @returns the current texture
  75193. */
  75194. addControl(control: Control): AdvancedDynamicTexture;
  75195. /**
  75196. * Removes a control from the root container
  75197. * @param control defines the control to remove
  75198. * @returns the current texture
  75199. */
  75200. removeControl(control: Control): AdvancedDynamicTexture;
  75201. /**
  75202. * Release all resources
  75203. */
  75204. dispose(): void;
  75205. private _onResize;
  75206. /** @hidden */
  75207. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75208. /**
  75209. * Get screen coordinates for a vector3
  75210. * @param position defines the position to project
  75211. * @param worldMatrix defines the world matrix to use
  75212. * @returns the projected position
  75213. */
  75214. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75215. private _checkUpdate;
  75216. private _clearMeasure;
  75217. private _render;
  75218. /** @hidden */
  75219. _changeCursor(cursor: string): void;
  75220. /** @hidden */
  75221. _registerLastControlDown(control: Control, pointerId: number): void;
  75222. private _doPicking;
  75223. /** @hidden */
  75224. _cleanControlAfterRemovalFromList(list: {
  75225. [pointerId: number]: Control;
  75226. }, control: Control): void;
  75227. /** @hidden */
  75228. _cleanControlAfterRemoval(control: Control): void;
  75229. /** Attach to all scene events required to support pointer events */
  75230. attach(): void;
  75231. /** @hidden */
  75232. private onClipboardCopy;
  75233. /** @hidden */
  75234. private onClipboardCut;
  75235. /** @hidden */
  75236. private onClipboardPaste;
  75237. /**
  75238. * Register the clipboard Events onto the canvas
  75239. */
  75240. registerClipboardEvents(): void;
  75241. /**
  75242. * Unregister the clipboard Events from the canvas
  75243. */
  75244. unRegisterClipboardEvents(): void;
  75245. /**
  75246. * Connect the texture to a hosting mesh to enable interactions
  75247. * @param mesh defines the mesh to attach to
  75248. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75249. */
  75250. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75251. /**
  75252. * Move the focus to a specific control
  75253. * @param control defines the control which will receive the focus
  75254. */
  75255. moveFocusToControl(control: IFocusableControl): void;
  75256. private _manageFocus;
  75257. private _attachToOnPointerOut;
  75258. /**
  75259. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75260. * @param mesh defines the mesh which will receive the texture
  75261. * @param width defines the texture width (1024 by default)
  75262. * @param height defines the texture height (1024 by default)
  75263. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75264. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75265. * @returns a new AdvancedDynamicTexture
  75266. */
  75267. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75268. /**
  75269. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75270. * In this mode the texture will rely on a layer for its rendering.
  75271. * This allows it to be treated like any other layer.
  75272. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75273. * LayerMask is set through advancedTexture.layer.layerMask
  75274. * @param name defines name for the texture
  75275. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75276. * @param scene defines the hsoting scene
  75277. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75278. * @returns a new AdvancedDynamicTexture
  75279. */
  75280. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75281. }
  75282. }
  75283. declare module BABYLON.GUI {
  75284. /**
  75285. * Root class used for all 2D controls
  75286. * @see https://doc.babylonjs.com/how_to/gui#controls
  75287. */
  75288. export class Control {
  75289. /** defines the name of the control */
  75290. name?: string | undefined;
  75291. /**
  75292. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75293. */
  75294. static AllowAlphaInheritance: boolean;
  75295. private _alpha;
  75296. private _alphaSet;
  75297. private _zIndex;
  75298. /** @hidden */
  75299. _host: AdvancedDynamicTexture;
  75300. /** Gets or sets the control parent */
  75301. parent: BABYLON.Nullable<Container>;
  75302. /** @hidden */
  75303. _currentMeasure: Measure;
  75304. private _fontFamily;
  75305. private _fontStyle;
  75306. private _fontWeight;
  75307. private _fontSize;
  75308. private _font;
  75309. /** @hidden */
  75310. _width: ValueAndUnit;
  75311. /** @hidden */
  75312. _height: ValueAndUnit;
  75313. /** @hidden */
  75314. protected _fontOffset: {
  75315. ascent: number;
  75316. height: number;
  75317. descent: number;
  75318. };
  75319. private _color;
  75320. private _style;
  75321. private _styleObserver;
  75322. /** @hidden */
  75323. protected _horizontalAlignment: number;
  75324. /** @hidden */
  75325. protected _verticalAlignment: number;
  75326. /** @hidden */
  75327. protected _isDirty: boolean;
  75328. /** @hidden */
  75329. protected _wasDirty: boolean;
  75330. /** @hidden */
  75331. _tempParentMeasure: Measure;
  75332. /** @hidden */
  75333. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75334. /** @hidden */
  75335. protected _cachedParentMeasure: Measure;
  75336. private _paddingLeft;
  75337. private _paddingRight;
  75338. private _paddingTop;
  75339. private _paddingBottom;
  75340. /** @hidden */
  75341. _left: ValueAndUnit;
  75342. /** @hidden */
  75343. _top: ValueAndUnit;
  75344. private _scaleX;
  75345. private _scaleY;
  75346. private _rotation;
  75347. private _transformCenterX;
  75348. private _transformCenterY;
  75349. /** @hidden */
  75350. _transformMatrix: Matrix2D;
  75351. /** @hidden */
  75352. protected _invertTransformMatrix: Matrix2D;
  75353. /** @hidden */
  75354. protected _transformedPosition: BABYLON.Vector2;
  75355. private _isMatrixDirty;
  75356. private _cachedOffsetX;
  75357. private _cachedOffsetY;
  75358. private _isVisible;
  75359. private _isHighlighted;
  75360. /** @hidden */
  75361. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75362. private _fontSet;
  75363. private _dummyVector2;
  75364. private _downCount;
  75365. private _enterCount;
  75366. private _doNotRender;
  75367. private _downPointerIds;
  75368. protected _isEnabled: boolean;
  75369. protected _disabledColor: string;
  75370. protected _disabledColorItem: string;
  75371. /** @hidden */
  75372. protected _rebuildLayout: boolean;
  75373. /** @hidden */
  75374. _customData: any;
  75375. /** @hidden */
  75376. _isClipped: boolean;
  75377. /** @hidden */
  75378. _automaticSize: boolean;
  75379. /** @hidden */
  75380. _tag: any;
  75381. /**
  75382. * 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
  75383. */
  75384. uniqueId: number;
  75385. /**
  75386. * Gets or sets an object used to store user defined information for the node
  75387. */
  75388. metadata: any;
  75389. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75390. isHitTestVisible: boolean;
  75391. /** Gets or sets a boolean indicating if the control can block pointer events */
  75392. isPointerBlocker: boolean;
  75393. /** Gets or sets a boolean indicating if the control can be focusable */
  75394. isFocusInvisible: boolean;
  75395. /**
  75396. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75397. * 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
  75398. */
  75399. clipChildren: boolean;
  75400. /**
  75401. * Gets or sets a boolean indicating that control content must be clipped
  75402. * 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
  75403. */
  75404. clipContent: boolean;
  75405. /**
  75406. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75407. */
  75408. useBitmapCache: boolean;
  75409. private _cacheData;
  75410. private _shadowOffsetX;
  75411. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75412. get shadowOffsetX(): number;
  75413. set shadowOffsetX(value: number);
  75414. private _shadowOffsetY;
  75415. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75416. get shadowOffsetY(): number;
  75417. set shadowOffsetY(value: number);
  75418. private _shadowBlur;
  75419. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75420. get shadowBlur(): number;
  75421. set shadowBlur(value: number);
  75422. private _shadowColor;
  75423. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75424. get shadowColor(): string;
  75425. set shadowColor(value: string);
  75426. /** Gets or sets the cursor to use when the control is hovered */
  75427. hoverCursor: string;
  75428. /** @hidden */
  75429. protected _linkOffsetX: ValueAndUnit;
  75430. /** @hidden */
  75431. protected _linkOffsetY: ValueAndUnit;
  75432. /** Gets the control type name */
  75433. get typeName(): string;
  75434. /**
  75435. * Get the current class name of the control.
  75436. * @returns current class name
  75437. */
  75438. getClassName(): string;
  75439. /**
  75440. * An event triggered when pointer wheel is scrolled
  75441. */
  75442. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75443. /**
  75444. * An event triggered when the pointer move over the control.
  75445. */
  75446. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75447. /**
  75448. * An event triggered when the pointer move out of the control.
  75449. */
  75450. onPointerOutObservable: BABYLON.Observable<Control>;
  75451. /**
  75452. * An event triggered when the pointer taps the control
  75453. */
  75454. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75455. /**
  75456. * An event triggered when pointer up
  75457. */
  75458. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75459. /**
  75460. * An event triggered when a control is clicked on
  75461. */
  75462. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75463. /**
  75464. * An event triggered when pointer enters the control
  75465. */
  75466. onPointerEnterObservable: BABYLON.Observable<Control>;
  75467. /**
  75468. * An event triggered when the control is marked as dirty
  75469. */
  75470. onDirtyObservable: BABYLON.Observable<Control>;
  75471. /**
  75472. * An event triggered before drawing the control
  75473. */
  75474. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75475. /**
  75476. * An event triggered after the control was drawn
  75477. */
  75478. onAfterDrawObservable: BABYLON.Observable<Control>;
  75479. /**
  75480. * An event triggered when the control has been disposed
  75481. */
  75482. onDisposeObservable: BABYLON.Observable<Control>;
  75483. /**
  75484. * Get the hosting AdvancedDynamicTexture
  75485. */
  75486. get host(): AdvancedDynamicTexture;
  75487. /** Gets or set information about font offsets (used to render and align text) */
  75488. get fontOffset(): {
  75489. ascent: number;
  75490. height: number;
  75491. descent: number;
  75492. };
  75493. set fontOffset(offset: {
  75494. ascent: number;
  75495. height: number;
  75496. descent: number;
  75497. });
  75498. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75499. get alpha(): number;
  75500. set alpha(value: number);
  75501. /**
  75502. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75503. */
  75504. get isHighlighted(): boolean;
  75505. set isHighlighted(value: boolean);
  75506. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75507. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75508. */
  75509. get scaleX(): number;
  75510. set scaleX(value: number);
  75511. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75512. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75513. */
  75514. get scaleY(): number;
  75515. set scaleY(value: number);
  75516. /** Gets or sets the rotation angle (0 by default)
  75517. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75518. */
  75519. get rotation(): number;
  75520. set rotation(value: number);
  75521. /** Gets or sets the transformation center on Y axis (0 by default)
  75522. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75523. */
  75524. get transformCenterY(): number;
  75525. set transformCenterY(value: number);
  75526. /** Gets or sets the transformation center on X axis (0 by default)
  75527. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75528. */
  75529. get transformCenterX(): number;
  75530. set transformCenterX(value: number);
  75531. /**
  75532. * Gets or sets the horizontal alignment
  75533. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75534. */
  75535. get horizontalAlignment(): number;
  75536. set horizontalAlignment(value: number);
  75537. /**
  75538. * Gets or sets the vertical alignment
  75539. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75540. */
  75541. get verticalAlignment(): number;
  75542. set verticalAlignment(value: number);
  75543. /**
  75544. * Gets or sets control width
  75545. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75546. */
  75547. get width(): string | number;
  75548. set width(value: string | number);
  75549. /**
  75550. * Gets or sets the control width in pixel
  75551. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75552. */
  75553. get widthInPixels(): number;
  75554. set widthInPixels(value: number);
  75555. /**
  75556. * Gets or sets control height
  75557. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75558. */
  75559. get height(): string | number;
  75560. set height(value: string | number);
  75561. /**
  75562. * Gets or sets control height in pixel
  75563. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75564. */
  75565. get heightInPixels(): number;
  75566. set heightInPixels(value: number);
  75567. /** Gets or set font family */
  75568. get fontFamily(): string;
  75569. set fontFamily(value: string);
  75570. /** Gets or sets font style */
  75571. get fontStyle(): string;
  75572. set fontStyle(value: string);
  75573. /** Gets or sets font weight */
  75574. get fontWeight(): string;
  75575. set fontWeight(value: string);
  75576. /**
  75577. * Gets or sets style
  75578. * @see https://doc.babylonjs.com/how_to/gui#styles
  75579. */
  75580. get style(): BABYLON.Nullable<Style>;
  75581. set style(value: BABYLON.Nullable<Style>);
  75582. /** @hidden */
  75583. get _isFontSizeInPercentage(): boolean;
  75584. /** Gets or sets font size in pixels */
  75585. get fontSizeInPixels(): number;
  75586. set fontSizeInPixels(value: number);
  75587. /** Gets or sets font size */
  75588. get fontSize(): string | number;
  75589. set fontSize(value: string | number);
  75590. /** Gets or sets foreground color */
  75591. get color(): string;
  75592. set color(value: string);
  75593. /** Gets or sets z index which is used to reorder controls on the z axis */
  75594. get zIndex(): number;
  75595. set zIndex(value: number);
  75596. /** Gets or sets a boolean indicating if the control can be rendered */
  75597. get notRenderable(): boolean;
  75598. set notRenderable(value: boolean);
  75599. /** Gets or sets a boolean indicating if the control is visible */
  75600. get isVisible(): boolean;
  75601. set isVisible(value: boolean);
  75602. /** Gets a boolean indicating that the control needs to update its rendering */
  75603. get isDirty(): boolean;
  75604. /**
  75605. * Gets the current linked mesh (or null if none)
  75606. */
  75607. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75608. /**
  75609. * Gets or sets a value indicating the padding to use on the left of the control
  75610. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75611. */
  75612. get paddingLeft(): string | number;
  75613. set paddingLeft(value: string | number);
  75614. /**
  75615. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75616. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75617. */
  75618. get paddingLeftInPixels(): number;
  75619. set paddingLeftInPixels(value: number);
  75620. /**
  75621. * Gets or sets a value indicating the padding to use on the right of the control
  75622. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75623. */
  75624. get paddingRight(): string | number;
  75625. set paddingRight(value: string | number);
  75626. /**
  75627. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75628. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75629. */
  75630. get paddingRightInPixels(): number;
  75631. set paddingRightInPixels(value: number);
  75632. /**
  75633. * Gets or sets a value indicating the padding to use on the top of the control
  75634. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75635. */
  75636. get paddingTop(): string | number;
  75637. set paddingTop(value: string | number);
  75638. /**
  75639. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75640. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75641. */
  75642. get paddingTopInPixels(): number;
  75643. set paddingTopInPixels(value: number);
  75644. /**
  75645. * Gets or sets a value indicating the padding to use on the bottom of the control
  75646. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75647. */
  75648. get paddingBottom(): string | number;
  75649. set paddingBottom(value: string | number);
  75650. /**
  75651. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75652. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75653. */
  75654. get paddingBottomInPixels(): number;
  75655. set paddingBottomInPixels(value: number);
  75656. /**
  75657. * Gets or sets a value indicating the left coordinate of the control
  75658. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75659. */
  75660. get left(): string | number;
  75661. set left(value: string | number);
  75662. /**
  75663. * Gets or sets a value indicating the left coordinate in pixels of the control
  75664. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75665. */
  75666. get leftInPixels(): number;
  75667. set leftInPixels(value: number);
  75668. /**
  75669. * Gets or sets a value indicating the top coordinate of the control
  75670. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75671. */
  75672. get top(): string | number;
  75673. set top(value: string | number);
  75674. /**
  75675. * Gets or sets a value indicating the top coordinate in pixels of the control
  75676. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75677. */
  75678. get topInPixels(): number;
  75679. set topInPixels(value: number);
  75680. /**
  75681. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75682. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75683. */
  75684. get linkOffsetX(): string | number;
  75685. set linkOffsetX(value: string | number);
  75686. /**
  75687. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75688. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75689. */
  75690. get linkOffsetXInPixels(): number;
  75691. set linkOffsetXInPixels(value: number);
  75692. /**
  75693. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75694. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75695. */
  75696. get linkOffsetY(): string | number;
  75697. set linkOffsetY(value: string | number);
  75698. /**
  75699. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75700. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75701. */
  75702. get linkOffsetYInPixels(): number;
  75703. set linkOffsetYInPixels(value: number);
  75704. /** Gets the center coordinate on X axis */
  75705. get centerX(): number;
  75706. /** Gets the center coordinate on Y axis */
  75707. get centerY(): number;
  75708. /** Gets or sets if control is Enabled*/
  75709. get isEnabled(): boolean;
  75710. set isEnabled(value: boolean);
  75711. /** Gets or sets background color of control if it's disabled*/
  75712. get disabledColor(): string;
  75713. set disabledColor(value: string);
  75714. /** Gets or sets front color of control if it's disabled*/
  75715. get disabledColorItem(): string;
  75716. set disabledColorItem(value: string);
  75717. /**
  75718. * Creates a new control
  75719. * @param name defines the name of the control
  75720. */
  75721. constructor(
  75722. /** defines the name of the control */
  75723. name?: string | undefined);
  75724. /** @hidden */
  75725. protected _getTypeName(): string;
  75726. /**
  75727. * Gets the first ascendant in the hierarchy of the given type
  75728. * @param className defines the required type
  75729. * @returns the ascendant or null if not found
  75730. */
  75731. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75732. /** @hidden */
  75733. _resetFontCache(): void;
  75734. /**
  75735. * Determines if a container is an ascendant of the current control
  75736. * @param container defines the container to look for
  75737. * @returns true if the container is one of the ascendant of the control
  75738. */
  75739. isAscendant(container: Control): boolean;
  75740. /**
  75741. * Gets coordinates in local control space
  75742. * @param globalCoordinates defines the coordinates to transform
  75743. * @returns the new coordinates in local space
  75744. */
  75745. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75746. /**
  75747. * Gets coordinates in local control space
  75748. * @param globalCoordinates defines the coordinates to transform
  75749. * @param result defines the target vector2 where to store the result
  75750. * @returns the current control
  75751. */
  75752. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75753. /**
  75754. * Gets coordinates in parent local control space
  75755. * @param globalCoordinates defines the coordinates to transform
  75756. * @returns the new coordinates in parent local space
  75757. */
  75758. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75759. /**
  75760. * Move the current control to a vector3 position projected onto the screen.
  75761. * @param position defines the target position
  75762. * @param scene defines the hosting scene
  75763. */
  75764. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75765. /**
  75766. * Will store all controls that have this control as ascendant in a given array
  75767. * @param results defines the array where to store the descendants
  75768. * @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
  75769. * @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
  75770. */
  75771. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75772. /**
  75773. * Will return all controls that have this control as ascendant
  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. * @return all child controls
  75777. */
  75778. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75779. /**
  75780. * Link current control with a target mesh
  75781. * @param mesh defines the mesh to link with
  75782. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75783. */
  75784. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75785. /** @hidden */
  75786. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75787. /** @hidden */
  75788. _offsetLeft(offset: number): void;
  75789. /** @hidden */
  75790. _offsetTop(offset: number): void;
  75791. /** @hidden */
  75792. _markMatrixAsDirty(): void;
  75793. /** @hidden */
  75794. _flagDescendantsAsMatrixDirty(): void;
  75795. /** @hidden */
  75796. _intersectsRect(rect: Measure): boolean;
  75797. /** @hidden */
  75798. protected invalidateRect(): void;
  75799. /** @hidden */
  75800. _markAsDirty(force?: boolean): void;
  75801. /** @hidden */
  75802. _markAllAsDirty(): void;
  75803. /** @hidden */
  75804. _link(host: AdvancedDynamicTexture): void;
  75805. /** @hidden */
  75806. protected _transform(context?: CanvasRenderingContext2D): void;
  75807. /** @hidden */
  75808. _renderHighlight(context: CanvasRenderingContext2D): void;
  75809. /** @hidden */
  75810. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75811. /** @hidden */
  75812. protected _applyStates(context: CanvasRenderingContext2D): void;
  75813. /** @hidden */
  75814. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75815. /** @hidden */
  75816. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75817. protected _evaluateClippingState(parentMeasure: Measure): void;
  75818. /** @hidden */
  75819. _measure(): void;
  75820. /** @hidden */
  75821. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75822. /** @hidden */
  75823. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75824. /** @hidden */
  75825. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75826. /** @hidden */
  75827. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75828. private static _ClipMeasure;
  75829. private _tmpMeasureA;
  75830. private _clip;
  75831. /** @hidden */
  75832. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75833. /** @hidden */
  75834. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75835. /**
  75836. * Tests if a given coordinates belong to the current control
  75837. * @param x defines x coordinate to test
  75838. * @param y defines y coordinate to test
  75839. * @returns true if the coordinates are inside the control
  75840. */
  75841. contains(x: number, y: number): boolean;
  75842. /** @hidden */
  75843. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75844. /** @hidden */
  75845. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75846. /** @hidden */
  75847. _onPointerEnter(target: Control): boolean;
  75848. /** @hidden */
  75849. _onPointerOut(target: Control, force?: boolean): void;
  75850. /** @hidden */
  75851. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75852. /** @hidden */
  75853. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75854. /** @hidden */
  75855. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75856. /** @hidden */
  75857. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75858. /** @hidden */
  75859. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75860. private _prepareFont;
  75861. /** Releases associated resources */
  75862. dispose(): void;
  75863. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75864. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75865. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75866. private static _VERTICAL_ALIGNMENT_TOP;
  75867. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75868. private static _VERTICAL_ALIGNMENT_CENTER;
  75869. /** HORIZONTAL_ALIGNMENT_LEFT */
  75870. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75871. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75872. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75873. /** HORIZONTAL_ALIGNMENT_CENTER */
  75874. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75875. /** VERTICAL_ALIGNMENT_TOP */
  75876. static get VERTICAL_ALIGNMENT_TOP(): number;
  75877. /** VERTICAL_ALIGNMENT_BOTTOM */
  75878. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75879. /** VERTICAL_ALIGNMENT_CENTER */
  75880. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75881. private static _FontHeightSizes;
  75882. /** @hidden */
  75883. static _GetFontOffset(font: string): {
  75884. ascent: number;
  75885. height: number;
  75886. descent: number;
  75887. };
  75888. /**
  75889. * Creates a stack panel that can be used to render headers
  75890. * @param control defines the control to associate with the header
  75891. * @param text defines the text of the header
  75892. * @param size defines the size of the header
  75893. * @param options defines options used to configure the header
  75894. * @returns a new StackPanel
  75895. * @ignore
  75896. * @hidden
  75897. */
  75898. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75899. isHorizontal: boolean;
  75900. controlFirst: boolean;
  75901. }) => any;
  75902. /** @hidden */
  75903. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75904. }
  75905. }
  75906. declare module BABYLON.GUI {
  75907. /**
  75908. * Root class for 2D containers
  75909. * @see https://doc.babylonjs.com/how_to/gui#containers
  75910. */
  75911. export class Container extends Control {
  75912. name?: string | undefined;
  75913. /** @hidden */
  75914. _children: Control[];
  75915. /** @hidden */
  75916. protected _measureForChildren: Measure;
  75917. /** @hidden */
  75918. protected _background: string;
  75919. /** @hidden */
  75920. protected _adaptWidthToChildren: boolean;
  75921. /** @hidden */
  75922. protected _adaptHeightToChildren: boolean;
  75923. /**
  75924. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75925. */
  75926. logLayoutCycleErrors: boolean;
  75927. /**
  75928. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75929. */
  75930. maxLayoutCycle: number;
  75931. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75932. get adaptHeightToChildren(): boolean;
  75933. set adaptHeightToChildren(value: boolean);
  75934. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75935. get adaptWidthToChildren(): boolean;
  75936. set adaptWidthToChildren(value: boolean);
  75937. /** Gets or sets background color */
  75938. get background(): string;
  75939. set background(value: string);
  75940. /** Gets the list of children */
  75941. get children(): Control[];
  75942. /**
  75943. * Creates a new Container
  75944. * @param name defines the name of the container
  75945. */
  75946. constructor(name?: string | undefined);
  75947. protected _getTypeName(): string;
  75948. _flagDescendantsAsMatrixDirty(): void;
  75949. /**
  75950. * Gets a child using its name
  75951. * @param name defines the child name to look for
  75952. * @returns the child control if found
  75953. */
  75954. getChildByName(name: string): BABYLON.Nullable<Control>;
  75955. /**
  75956. * Gets a child using its type and its name
  75957. * @param name defines the child name to look for
  75958. * @param type defines the child type to look for
  75959. * @returns the child control if found
  75960. */
  75961. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75962. /**
  75963. * Search for a specific control in children
  75964. * @param control defines the control to look for
  75965. * @returns true if the control is in child list
  75966. */
  75967. containsControl(control: Control): boolean;
  75968. /**
  75969. * Adds a new control to the current container
  75970. * @param control defines the control to add
  75971. * @returns the current container
  75972. */
  75973. addControl(control: BABYLON.Nullable<Control>): Container;
  75974. /**
  75975. * Removes all controls from the current container
  75976. * @returns the current container
  75977. */
  75978. clearControls(): Container;
  75979. /**
  75980. * Removes a control from the current container
  75981. * @param control defines the control to remove
  75982. * @returns the current container
  75983. */
  75984. removeControl(control: Control): Container;
  75985. /** @hidden */
  75986. _reOrderControl(control: Control): void;
  75987. /** @hidden */
  75988. _offsetLeft(offset: number): void;
  75989. /** @hidden */
  75990. _offsetTop(offset: number): void;
  75991. /** @hidden */
  75992. _markAllAsDirty(): void;
  75993. /** @hidden */
  75994. protected _localDraw(context: CanvasRenderingContext2D): void;
  75995. /** @hidden */
  75996. _link(host: AdvancedDynamicTexture): void;
  75997. /** @hidden */
  75998. protected _beforeLayout(): void;
  75999. /** @hidden */
  76000. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76001. /** @hidden */
  76002. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76003. protected _postMeasure(): void;
  76004. /** @hidden */
  76005. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76006. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76007. /** @hidden */
  76008. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76009. /** @hidden */
  76010. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76011. /** Releases associated resources */
  76012. dispose(): void;
  76013. }
  76014. }
  76015. declare module BABYLON.GUI {
  76016. /** Class used to create rectangle container */
  76017. export class Rectangle extends Container {
  76018. name?: string | undefined;
  76019. private _thickness;
  76020. private _cornerRadius;
  76021. /** Gets or sets border thickness */
  76022. get thickness(): number;
  76023. set thickness(value: number);
  76024. /** Gets or sets the corner radius angle */
  76025. get cornerRadius(): number;
  76026. set cornerRadius(value: number);
  76027. /**
  76028. * Creates a new Rectangle
  76029. * @param name defines the control name
  76030. */
  76031. constructor(name?: string | undefined);
  76032. protected _getTypeName(): string;
  76033. protected _localDraw(context: CanvasRenderingContext2D): void;
  76034. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76035. private _drawRoundedRect;
  76036. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76037. }
  76038. }
  76039. declare module BABYLON.GUI {
  76040. /**
  76041. * Enum that determines the text-wrapping mode to use.
  76042. */
  76043. export enum TextWrapping {
  76044. /**
  76045. * Clip the text when it's larger than Control.width; this is the default mode.
  76046. */
  76047. Clip = 0,
  76048. /**
  76049. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76050. */
  76051. WordWrap = 1,
  76052. /**
  76053. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76054. */
  76055. Ellipsis = 2
  76056. }
  76057. /**
  76058. * Class used to create text block control
  76059. */
  76060. export class TextBlock extends Control {
  76061. /**
  76062. * Defines the name of the control
  76063. */
  76064. name?: string | undefined;
  76065. private _text;
  76066. private _textWrapping;
  76067. private _textHorizontalAlignment;
  76068. private _textVerticalAlignment;
  76069. private _lines;
  76070. private _resizeToFit;
  76071. private _lineSpacing;
  76072. private _outlineWidth;
  76073. private _outlineColor;
  76074. /**
  76075. * An event triggered after the text is changed
  76076. */
  76077. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76078. /**
  76079. * An event triggered after the text was broken up into lines
  76080. */
  76081. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76082. /**
  76083. * Function used to split a string into words. By default, a string is split at each space character found
  76084. */
  76085. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76086. /**
  76087. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76088. */
  76089. get lines(): any[];
  76090. /**
  76091. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76092. */
  76093. get resizeToFit(): boolean;
  76094. /**
  76095. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76096. */
  76097. set resizeToFit(value: boolean);
  76098. /**
  76099. * Gets or sets a boolean indicating if text must be wrapped
  76100. */
  76101. get textWrapping(): TextWrapping | boolean;
  76102. /**
  76103. * Gets or sets a boolean indicating if text must be wrapped
  76104. */
  76105. set textWrapping(value: TextWrapping | boolean);
  76106. /**
  76107. * Gets or sets text to display
  76108. */
  76109. get text(): string;
  76110. /**
  76111. * Gets or sets text to display
  76112. */
  76113. set text(value: string);
  76114. /**
  76115. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76116. */
  76117. get textHorizontalAlignment(): number;
  76118. /**
  76119. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76120. */
  76121. set textHorizontalAlignment(value: number);
  76122. /**
  76123. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76124. */
  76125. get textVerticalAlignment(): number;
  76126. /**
  76127. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76128. */
  76129. set textVerticalAlignment(value: number);
  76130. /**
  76131. * Gets or sets line spacing value
  76132. */
  76133. set lineSpacing(value: string | number);
  76134. /**
  76135. * Gets or sets line spacing value
  76136. */
  76137. get lineSpacing(): string | number;
  76138. /**
  76139. * Gets or sets outlineWidth of the text to display
  76140. */
  76141. get outlineWidth(): number;
  76142. /**
  76143. * Gets or sets outlineWidth of the text to display
  76144. */
  76145. set outlineWidth(value: number);
  76146. /**
  76147. * Gets or sets outlineColor of the text to display
  76148. */
  76149. get outlineColor(): string;
  76150. /**
  76151. * Gets or sets outlineColor of the text to display
  76152. */
  76153. set outlineColor(value: string);
  76154. /**
  76155. * Creates a new TextBlock object
  76156. * @param name defines the name of the control
  76157. * @param text defines the text to display (emptry string by default)
  76158. */
  76159. constructor(
  76160. /**
  76161. * Defines the name of the control
  76162. */
  76163. name?: string | undefined, text?: string);
  76164. protected _getTypeName(): string;
  76165. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76166. private _drawText;
  76167. /** @hidden */
  76168. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76169. protected _applyStates(context: CanvasRenderingContext2D): void;
  76170. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76171. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76172. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76173. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76174. protected _renderLines(context: CanvasRenderingContext2D): void;
  76175. /**
  76176. * Given a width constraint applied on the text block, find the expected height
  76177. * @returns expected height
  76178. */
  76179. computeExpectedHeight(): number;
  76180. dispose(): void;
  76181. }
  76182. }
  76183. declare module BABYLON.GUI {
  76184. /**
  76185. * Class used to create 2D images
  76186. */
  76187. export class Image extends Control {
  76188. name?: string | undefined;
  76189. private _workingCanvas;
  76190. private _domImage;
  76191. private _imageWidth;
  76192. private _imageHeight;
  76193. private _loaded;
  76194. private _stretch;
  76195. private _source;
  76196. private _autoScale;
  76197. private _sourceLeft;
  76198. private _sourceTop;
  76199. private _sourceWidth;
  76200. private _sourceHeight;
  76201. private _svgAttributesComputationCompleted;
  76202. private _isSVG;
  76203. private _cellWidth;
  76204. private _cellHeight;
  76205. private _cellId;
  76206. private _populateNinePatchSlicesFromImage;
  76207. private _sliceLeft;
  76208. private _sliceRight;
  76209. private _sliceTop;
  76210. private _sliceBottom;
  76211. private _detectPointerOnOpaqueOnly;
  76212. /**
  76213. * BABYLON.Observable notified when the content is loaded
  76214. */
  76215. onImageLoadedObservable: BABYLON.Observable<Image>;
  76216. /**
  76217. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76218. */
  76219. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76220. /**
  76221. * Gets a boolean indicating that the content is loaded
  76222. */
  76223. get isLoaded(): boolean;
  76224. /**
  76225. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76226. */
  76227. get populateNinePatchSlicesFromImage(): boolean;
  76228. set populateNinePatchSlicesFromImage(value: boolean);
  76229. /**
  76230. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76231. * Beware using this as this will comsume more memory as the image has to be stored twice
  76232. */
  76233. get detectPointerOnOpaqueOnly(): boolean;
  76234. set detectPointerOnOpaqueOnly(value: boolean);
  76235. /**
  76236. * Gets or sets the left value for slicing (9-patch)
  76237. */
  76238. get sliceLeft(): number;
  76239. set sliceLeft(value: number);
  76240. /**
  76241. * Gets or sets the right value for slicing (9-patch)
  76242. */
  76243. get sliceRight(): number;
  76244. set sliceRight(value: number);
  76245. /**
  76246. * Gets or sets the top value for slicing (9-patch)
  76247. */
  76248. get sliceTop(): number;
  76249. set sliceTop(value: number);
  76250. /**
  76251. * Gets or sets the bottom value for slicing (9-patch)
  76252. */
  76253. get sliceBottom(): number;
  76254. set sliceBottom(value: number);
  76255. /**
  76256. * Gets or sets the left coordinate in the source image
  76257. */
  76258. get sourceLeft(): number;
  76259. set sourceLeft(value: number);
  76260. /**
  76261. * Gets or sets the top coordinate in the source image
  76262. */
  76263. get sourceTop(): number;
  76264. set sourceTop(value: number);
  76265. /**
  76266. * Gets or sets the width to capture in the source image
  76267. */
  76268. get sourceWidth(): number;
  76269. set sourceWidth(value: number);
  76270. /**
  76271. * Gets or sets the height to capture in the source image
  76272. */
  76273. get sourceHeight(): number;
  76274. set sourceHeight(value: number);
  76275. /** Indicates if the format of the image is SVG */
  76276. get isSVG(): boolean;
  76277. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76278. get svgAttributesComputationCompleted(): boolean;
  76279. /**
  76280. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76281. * @see https://doc.babylonjs.com/how_to/gui#image
  76282. */
  76283. get autoScale(): boolean;
  76284. set autoScale(value: boolean);
  76285. /** Gets or sets the streching mode used by the image */
  76286. get stretch(): number;
  76287. set stretch(value: number);
  76288. /** @hidden */
  76289. _rotate90(n: number, preserveProperties?: boolean): Image;
  76290. private _handleRotationForSVGImage;
  76291. private _rotate90SourceProperties;
  76292. /**
  76293. * Gets or sets the internal DOM image used to render the control
  76294. */
  76295. set domImage(value: HTMLImageElement);
  76296. get domImage(): HTMLImageElement;
  76297. private _onImageLoaded;
  76298. private _extractNinePatchSliceDataFromImage;
  76299. /**
  76300. * Gets or sets image source url
  76301. */
  76302. set source(value: BABYLON.Nullable<string>);
  76303. /**
  76304. * Checks for svg document with icon id present
  76305. */
  76306. private _svgCheck;
  76307. /**
  76308. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76309. * given external svg file and icon id
  76310. */
  76311. private _getSVGAttribs;
  76312. /**
  76313. * Gets or sets the cell width to use when animation sheet is enabled
  76314. * @see https://doc.babylonjs.com/how_to/gui#image
  76315. */
  76316. get cellWidth(): number;
  76317. set cellWidth(value: number);
  76318. /**
  76319. * Gets or sets the cell height to use when animation sheet is enabled
  76320. * @see https://doc.babylonjs.com/how_to/gui#image
  76321. */
  76322. get cellHeight(): number;
  76323. set cellHeight(value: number);
  76324. /**
  76325. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76326. * @see https://doc.babylonjs.com/how_to/gui#image
  76327. */
  76328. get cellId(): number;
  76329. set cellId(value: number);
  76330. /**
  76331. * Creates a new Image
  76332. * @param name defines the control name
  76333. * @param url defines the image url
  76334. */
  76335. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76336. /**
  76337. * Tests if a given coordinates belong to the current control
  76338. * @param x defines x coordinate to test
  76339. * @param y defines y coordinate to test
  76340. * @returns true if the coordinates are inside the control
  76341. */
  76342. contains(x: number, y: number): boolean;
  76343. protected _getTypeName(): string;
  76344. /** Force the control to synchronize with its content */
  76345. synchronizeSizeWithContent(): void;
  76346. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76347. private _prepareWorkingCanvasForOpaqueDetection;
  76348. private _drawImage;
  76349. _draw(context: CanvasRenderingContext2D): void;
  76350. private _renderCornerPatch;
  76351. private _renderNinePatch;
  76352. dispose(): void;
  76353. /** STRETCH_NONE */
  76354. static readonly STRETCH_NONE: number;
  76355. /** STRETCH_FILL */
  76356. static readonly STRETCH_FILL: number;
  76357. /** STRETCH_UNIFORM */
  76358. static readonly STRETCH_UNIFORM: number;
  76359. /** STRETCH_EXTEND */
  76360. static readonly STRETCH_EXTEND: number;
  76361. /** NINE_PATCH */
  76362. static readonly STRETCH_NINE_PATCH: number;
  76363. }
  76364. }
  76365. declare module BABYLON.GUI {
  76366. /**
  76367. * Class used to create 2D buttons
  76368. */
  76369. export class Button extends Rectangle {
  76370. name?: string | undefined;
  76371. /**
  76372. * Function called to generate a pointer enter animation
  76373. */
  76374. pointerEnterAnimation: () => void;
  76375. /**
  76376. * Function called to generate a pointer out animation
  76377. */
  76378. pointerOutAnimation: () => void;
  76379. /**
  76380. * Function called to generate a pointer down animation
  76381. */
  76382. pointerDownAnimation: () => void;
  76383. /**
  76384. * Function called to generate a pointer up animation
  76385. */
  76386. pointerUpAnimation: () => void;
  76387. /**
  76388. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76389. */
  76390. delegatePickingToChildren: boolean;
  76391. private _image;
  76392. /**
  76393. * Returns the image part of the button (if any)
  76394. */
  76395. get image(): BABYLON.Nullable<Image>;
  76396. private _textBlock;
  76397. /**
  76398. * Returns the image part of the button (if any)
  76399. */
  76400. get textBlock(): BABYLON.Nullable<TextBlock>;
  76401. /**
  76402. * Creates a new Button
  76403. * @param name defines the name of the button
  76404. */
  76405. constructor(name?: string | undefined);
  76406. protected _getTypeName(): string;
  76407. /** @hidden */
  76408. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76409. /** @hidden */
  76410. _onPointerEnter(target: Control): boolean;
  76411. /** @hidden */
  76412. _onPointerOut(target: Control, force?: boolean): void;
  76413. /** @hidden */
  76414. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76415. /** @hidden */
  76416. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76417. /**
  76418. * Creates a new button made with an image and a text
  76419. * @param name defines the name of the button
  76420. * @param text defines the text of the button
  76421. * @param imageUrl defines the url of the image
  76422. * @returns a new Button
  76423. */
  76424. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76425. /**
  76426. * Creates a new button made with an image
  76427. * @param name defines the name of the button
  76428. * @param imageUrl defines the url of the image
  76429. * @returns a new Button
  76430. */
  76431. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76432. /**
  76433. * Creates a new button made with a text
  76434. * @param name defines the name of the button
  76435. * @param text defines the text of the button
  76436. * @returns a new Button
  76437. */
  76438. static CreateSimpleButton(name: string, text: string): Button;
  76439. /**
  76440. * Creates a new button made with an image and a centered text
  76441. * @param name defines the name of the button
  76442. * @param text defines the text of the button
  76443. * @param imageUrl defines the url of the image
  76444. * @returns a new Button
  76445. */
  76446. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76447. }
  76448. }
  76449. declare module BABYLON.GUI {
  76450. /**
  76451. * Class used to create a 2D stack panel container
  76452. */
  76453. export class StackPanel extends Container {
  76454. name?: string | undefined;
  76455. private _isVertical;
  76456. private _manualWidth;
  76457. private _manualHeight;
  76458. private _doNotTrackManualChanges;
  76459. /**
  76460. * Gets or sets a boolean indicating that layou warnings should be ignored
  76461. */
  76462. ignoreLayoutWarnings: boolean;
  76463. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76464. get isVertical(): boolean;
  76465. set isVertical(value: boolean);
  76466. /**
  76467. * Gets or sets panel width.
  76468. * This value should not be set when in horizontal mode as it will be computed automatically
  76469. */
  76470. set width(value: string | number);
  76471. get width(): string | number;
  76472. /**
  76473. * Gets or sets panel height.
  76474. * This value should not be set when in vertical mode as it will be computed automatically
  76475. */
  76476. set height(value: string | number);
  76477. get height(): string | number;
  76478. /**
  76479. * Creates a new StackPanel
  76480. * @param name defines control name
  76481. */
  76482. constructor(name?: string | undefined);
  76483. protected _getTypeName(): string;
  76484. /** @hidden */
  76485. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76486. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76487. protected _postMeasure(): void;
  76488. }
  76489. }
  76490. declare module BABYLON.GUI {
  76491. /**
  76492. * Class used to represent a 2D checkbox
  76493. */
  76494. export class Checkbox extends Control {
  76495. name?: string | undefined;
  76496. private _isChecked;
  76497. private _background;
  76498. private _checkSizeRatio;
  76499. private _thickness;
  76500. /** Gets or sets border thickness */
  76501. get thickness(): number;
  76502. set thickness(value: number);
  76503. /**
  76504. * BABYLON.Observable raised when isChecked property changes
  76505. */
  76506. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76507. /** Gets or sets a value indicating the ratio between overall size and check size */
  76508. get checkSizeRatio(): number;
  76509. set checkSizeRatio(value: number);
  76510. /** Gets or sets background color */
  76511. get background(): string;
  76512. set background(value: string);
  76513. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76514. get isChecked(): boolean;
  76515. set isChecked(value: boolean);
  76516. /**
  76517. * Creates a new CheckBox
  76518. * @param name defines the control name
  76519. */
  76520. constructor(name?: string | undefined);
  76521. protected _getTypeName(): string;
  76522. /** @hidden */
  76523. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76524. /** @hidden */
  76525. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76526. /**
  76527. * Utility function to easily create a checkbox with a header
  76528. * @param title defines the label to use for the header
  76529. * @param onValueChanged defines the callback to call when value changes
  76530. * @returns a StackPanel containing the checkbox and a textBlock
  76531. */
  76532. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76533. }
  76534. }
  76535. declare module BABYLON.GUI {
  76536. /**
  76537. * Class used to store key control properties
  76538. */
  76539. export class KeyPropertySet {
  76540. /** Width */
  76541. width?: string;
  76542. /** Height */
  76543. height?: string;
  76544. /** Left padding */
  76545. paddingLeft?: string;
  76546. /** Right padding */
  76547. paddingRight?: string;
  76548. /** Top padding */
  76549. paddingTop?: string;
  76550. /** Bottom padding */
  76551. paddingBottom?: string;
  76552. /** Foreground color */
  76553. color?: string;
  76554. /** Background color */
  76555. background?: string;
  76556. }
  76557. /**
  76558. * Class used to create virtual keyboard
  76559. */
  76560. export class VirtualKeyboard extends StackPanel {
  76561. /** BABYLON.Observable raised when a key is pressed */
  76562. onKeyPressObservable: BABYLON.Observable<string>;
  76563. /** Gets or sets default key button width */
  76564. defaultButtonWidth: string;
  76565. /** Gets or sets default key button height */
  76566. defaultButtonHeight: string;
  76567. /** Gets or sets default key button left padding */
  76568. defaultButtonPaddingLeft: string;
  76569. /** Gets or sets default key button right padding */
  76570. defaultButtonPaddingRight: string;
  76571. /** Gets or sets default key button top padding */
  76572. defaultButtonPaddingTop: string;
  76573. /** Gets or sets default key button bottom padding */
  76574. defaultButtonPaddingBottom: string;
  76575. /** Gets or sets default key button foreground color */
  76576. defaultButtonColor: string;
  76577. /** Gets or sets default key button background color */
  76578. defaultButtonBackground: string;
  76579. /** Gets or sets shift button foreground color */
  76580. shiftButtonColor: string;
  76581. /** Gets or sets shift button thickness*/
  76582. selectedShiftThickness: number;
  76583. /** Gets shift key state */
  76584. shiftState: number;
  76585. protected _getTypeName(): string;
  76586. private _createKey;
  76587. /**
  76588. * Adds a new row of keys
  76589. * @param keys defines the list of keys to add
  76590. * @param propertySets defines the associated property sets
  76591. */
  76592. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76593. /**
  76594. * Set the shift key to a specific state
  76595. * @param shiftState defines the new shift state
  76596. */
  76597. applyShiftState(shiftState: number): void;
  76598. private _currentlyConnectedInputText;
  76599. private _connectedInputTexts;
  76600. private _onKeyPressObserver;
  76601. /** Gets the input text control currently attached to the keyboard */
  76602. get connectedInputText(): BABYLON.Nullable<InputText>;
  76603. /**
  76604. * Connects the keyboard with an input text control
  76605. *
  76606. * @param input defines the target control
  76607. */
  76608. connect(input: InputText): void;
  76609. /**
  76610. * Disconnects the keyboard from connected InputText controls
  76611. *
  76612. * @param input optionally defines a target control, otherwise all are disconnected
  76613. */
  76614. disconnect(input?: InputText): void;
  76615. private _removeConnectedInputObservables;
  76616. /**
  76617. * Release all resources
  76618. */
  76619. dispose(): void;
  76620. /**
  76621. * Creates a new keyboard using a default layout
  76622. *
  76623. * @param name defines control name
  76624. * @returns a new VirtualKeyboard
  76625. */
  76626. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76627. }
  76628. }
  76629. declare module BABYLON.GUI {
  76630. /**
  76631. * Class used to create input text control
  76632. */
  76633. export class InputText extends Control implements IFocusableControl {
  76634. name?: string | undefined;
  76635. private _text;
  76636. private _placeholderText;
  76637. private _background;
  76638. private _focusedBackground;
  76639. private _focusedColor;
  76640. private _placeholderColor;
  76641. private _thickness;
  76642. private _margin;
  76643. private _autoStretchWidth;
  76644. private _maxWidth;
  76645. private _isFocused;
  76646. private _blinkTimeout;
  76647. private _blinkIsEven;
  76648. private _cursorOffset;
  76649. private _scrollLeft;
  76650. private _textWidth;
  76651. private _clickedCoordinate;
  76652. private _deadKey;
  76653. private _addKey;
  76654. private _currentKey;
  76655. private _isTextHighlightOn;
  76656. private _textHighlightColor;
  76657. private _highligherOpacity;
  76658. private _highlightedText;
  76659. private _startHighlightIndex;
  76660. private _endHighlightIndex;
  76661. private _cursorIndex;
  76662. private _onFocusSelectAll;
  76663. private _isPointerDown;
  76664. private _onClipboardObserver;
  76665. private _onPointerDblTapObserver;
  76666. /** @hidden */
  76667. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76668. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76669. promptMessage: string;
  76670. /** Force disable prompt on mobile device */
  76671. disableMobilePrompt: boolean;
  76672. /** BABYLON.Observable raised when the text changes */
  76673. onTextChangedObservable: BABYLON.Observable<InputText>;
  76674. /** BABYLON.Observable raised just before an entered character is to be added */
  76675. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76676. /** BABYLON.Observable raised when the control gets the focus */
  76677. onFocusObservable: BABYLON.Observable<InputText>;
  76678. /** BABYLON.Observable raised when the control loses the focus */
  76679. onBlurObservable: BABYLON.Observable<InputText>;
  76680. /**Observable raised when the text is highlighted */
  76681. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76682. /**Observable raised when copy event is triggered */
  76683. onTextCopyObservable: BABYLON.Observable<InputText>;
  76684. /** BABYLON.Observable raised when cut event is triggered */
  76685. onTextCutObservable: BABYLON.Observable<InputText>;
  76686. /** BABYLON.Observable raised when paste event is triggered */
  76687. onTextPasteObservable: BABYLON.Observable<InputText>;
  76688. /** BABYLON.Observable raised when a key event was processed */
  76689. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76690. /** Gets or sets the maximum width allowed by the control */
  76691. get maxWidth(): string | number;
  76692. /** Gets the maximum width allowed by the control in pixels */
  76693. get maxWidthInPixels(): number;
  76694. set maxWidth(value: string | number);
  76695. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76696. get highligherOpacity(): number;
  76697. set highligherOpacity(value: number);
  76698. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76699. get onFocusSelectAll(): boolean;
  76700. set onFocusSelectAll(value: boolean);
  76701. /** Gets or sets the text hightlight color */
  76702. get textHighlightColor(): string;
  76703. set textHighlightColor(value: string);
  76704. /** Gets or sets control margin */
  76705. get margin(): string;
  76706. /** Gets control margin in pixels */
  76707. get marginInPixels(): number;
  76708. set margin(value: string);
  76709. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76710. get autoStretchWidth(): boolean;
  76711. set autoStretchWidth(value: boolean);
  76712. /** Gets or sets border thickness */
  76713. get thickness(): number;
  76714. set thickness(value: number);
  76715. /** Gets or sets the background color when focused */
  76716. get focusedBackground(): string;
  76717. set focusedBackground(value: string);
  76718. /** Gets or sets the background color when focused */
  76719. get focusedColor(): string;
  76720. set focusedColor(value: string);
  76721. /** Gets or sets the background color */
  76722. get background(): string;
  76723. set background(value: string);
  76724. /** Gets or sets the placeholder color */
  76725. get placeholderColor(): string;
  76726. set placeholderColor(value: string);
  76727. /** Gets or sets the text displayed when the control is empty */
  76728. get placeholderText(): string;
  76729. set placeholderText(value: string);
  76730. /** Gets or sets the dead key flag */
  76731. get deadKey(): boolean;
  76732. set deadKey(flag: boolean);
  76733. /** Gets or sets the highlight text */
  76734. get highlightedText(): string;
  76735. set highlightedText(text: string);
  76736. /** Gets or sets if the current key should be added */
  76737. get addKey(): boolean;
  76738. set addKey(flag: boolean);
  76739. /** Gets or sets the value of the current key being entered */
  76740. get currentKey(): string;
  76741. set currentKey(key: string);
  76742. /** Gets or sets the text displayed in the control */
  76743. get text(): string;
  76744. set text(value: string);
  76745. /** Gets or sets control width */
  76746. get width(): string | number;
  76747. set width(value: string | number);
  76748. /**
  76749. * Creates a new InputText
  76750. * @param name defines the control name
  76751. * @param text defines the text of the control
  76752. */
  76753. constructor(name?: string | undefined, text?: string);
  76754. /** @hidden */
  76755. onBlur(): void;
  76756. /** @hidden */
  76757. onFocus(): void;
  76758. protected _getTypeName(): string;
  76759. /**
  76760. * Function called to get the list of controls that should not steal the focus from this control
  76761. * @returns an array of controls
  76762. */
  76763. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76764. /** @hidden */
  76765. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76766. /** @hidden */
  76767. private _updateValueFromCursorIndex;
  76768. /** @hidden */
  76769. private _processDblClick;
  76770. /** @hidden */
  76771. private _selectAllText;
  76772. /**
  76773. * Handles the keyboard event
  76774. * @param evt Defines the KeyboardEvent
  76775. */
  76776. processKeyboard(evt: KeyboardEvent): void;
  76777. /** @hidden */
  76778. private _onCopyText;
  76779. /** @hidden */
  76780. private _onCutText;
  76781. /** @hidden */
  76782. private _onPasteText;
  76783. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76784. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76785. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76786. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76787. protected _beforeRenderText(text: string): string;
  76788. dispose(): void;
  76789. }
  76790. }
  76791. declare module BABYLON.GUI {
  76792. /**
  76793. * Class used to create a 2D grid container
  76794. */
  76795. export class Grid extends Container {
  76796. name?: string | undefined;
  76797. private _rowDefinitions;
  76798. private _columnDefinitions;
  76799. private _cells;
  76800. private _childControls;
  76801. /**
  76802. * Gets the number of columns
  76803. */
  76804. get columnCount(): number;
  76805. /**
  76806. * Gets the number of rows
  76807. */
  76808. get rowCount(): number;
  76809. /** Gets the list of children */
  76810. get children(): Control[];
  76811. /** Gets the list of cells (e.g. the containers) */
  76812. get cells(): {
  76813. [key: string]: Container;
  76814. };
  76815. /**
  76816. * Gets the definition of a specific row
  76817. * @param index defines the index of the row
  76818. * @returns the row definition
  76819. */
  76820. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76821. /**
  76822. * Gets the definition of a specific column
  76823. * @param index defines the index of the column
  76824. * @returns the column definition
  76825. */
  76826. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76827. /**
  76828. * Adds a new row to the grid
  76829. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76830. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76831. * @returns the current grid
  76832. */
  76833. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76834. /**
  76835. * Adds a new column to the grid
  76836. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76837. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76838. * @returns the current grid
  76839. */
  76840. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76841. /**
  76842. * Update a row definition
  76843. * @param index defines the index of the row to update
  76844. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76845. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76846. * @returns the current grid
  76847. */
  76848. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76849. /**
  76850. * Update a column definition
  76851. * @param index defines the index of the column to update
  76852. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76853. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76854. * @returns the current grid
  76855. */
  76856. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76857. /**
  76858. * Gets the list of children stored in a specific cell
  76859. * @param row defines the row to check
  76860. * @param column defines the column to check
  76861. * @returns the list of controls
  76862. */
  76863. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76864. /**
  76865. * Gets a string representing the child cell info (row x column)
  76866. * @param child defines the control to get info from
  76867. * @returns a string containing the child cell info (row x column)
  76868. */
  76869. getChildCellInfo(child: Control): string;
  76870. private _removeCell;
  76871. private _offsetCell;
  76872. /**
  76873. * Remove a column definition at specified index
  76874. * @param index defines the index of the column to remove
  76875. * @returns the current grid
  76876. */
  76877. removeColumnDefinition(index: number): Grid;
  76878. /**
  76879. * Remove a row definition at specified index
  76880. * @param index defines the index of the row to remove
  76881. * @returns the current grid
  76882. */
  76883. removeRowDefinition(index: number): Grid;
  76884. /**
  76885. * Adds a new control to the current grid
  76886. * @param control defines the control to add
  76887. * @param row defines the row where to add the control (0 by default)
  76888. * @param column defines the column where to add the control (0 by default)
  76889. * @returns the current grid
  76890. */
  76891. addControl(control: Control, row?: number, column?: number): Grid;
  76892. /**
  76893. * Removes a control from the current container
  76894. * @param control defines the control to remove
  76895. * @returns the current container
  76896. */
  76897. removeControl(control: Control): Container;
  76898. /**
  76899. * Creates a new Grid
  76900. * @param name defines control name
  76901. */
  76902. constructor(name?: string | undefined);
  76903. protected _getTypeName(): string;
  76904. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76905. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76906. _flagDescendantsAsMatrixDirty(): void;
  76907. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76908. /** Releases associated resources */
  76909. dispose(): void;
  76910. }
  76911. }
  76912. declare module BABYLON.GUI {
  76913. /** Class used to create color pickers */
  76914. export class ColorPicker extends Control {
  76915. name?: string | undefined;
  76916. private static _Epsilon;
  76917. private _colorWheelCanvas;
  76918. private _value;
  76919. private _tmpColor;
  76920. private _pointerStartedOnSquare;
  76921. private _pointerStartedOnWheel;
  76922. private _squareLeft;
  76923. private _squareTop;
  76924. private _squareSize;
  76925. private _h;
  76926. private _s;
  76927. private _v;
  76928. private _lastPointerDownID;
  76929. /**
  76930. * BABYLON.Observable raised when the value changes
  76931. */
  76932. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76933. /** Gets or sets the color of the color picker */
  76934. get value(): BABYLON.Color3;
  76935. set value(value: BABYLON.Color3);
  76936. /**
  76937. * Gets or sets control width
  76938. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76939. */
  76940. get width(): string | number;
  76941. set width(value: string | number);
  76942. /**
  76943. * Gets or sets control height
  76944. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76945. */
  76946. get height(): string | number;
  76947. /** Gets or sets control height */
  76948. set height(value: string | number);
  76949. /** Gets or sets control size */
  76950. get size(): string | number;
  76951. set size(value: string | number);
  76952. /**
  76953. * Creates a new ColorPicker
  76954. * @param name defines the control name
  76955. */
  76956. constructor(name?: string | undefined);
  76957. protected _getTypeName(): string;
  76958. /** @hidden */
  76959. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76960. private _updateSquareProps;
  76961. private _drawGradientSquare;
  76962. private _drawCircle;
  76963. private _createColorWheelCanvas;
  76964. /** @hidden */
  76965. _draw(context: CanvasRenderingContext2D): void;
  76966. private _pointerIsDown;
  76967. private _updateValueFromPointer;
  76968. private _isPointOnSquare;
  76969. private _isPointOnWheel;
  76970. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76971. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76972. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76973. /**
  76974. * This function expands the color picker by creating a color picker dialog with manual
  76975. * color value input and the ability to save colors into an array to be used later in
  76976. * subsequent launches of the dialogue.
  76977. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76978. * @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.
  76979. * @returns picked color as a hex string and the saved colors array as hex strings.
  76980. */
  76981. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76982. pickerWidth?: string;
  76983. pickerHeight?: string;
  76984. headerHeight?: string;
  76985. lastColor?: string;
  76986. swatchLimit?: number;
  76987. numSwatchesPerLine?: number;
  76988. savedColors?: Array<string>;
  76989. }): Promise<{
  76990. savedColors?: string[];
  76991. pickedColor: string;
  76992. }>;
  76993. }
  76994. }
  76995. declare module BABYLON.GUI {
  76996. /** Class used to create 2D ellipse containers */
  76997. export class Ellipse extends Container {
  76998. name?: string | undefined;
  76999. private _thickness;
  77000. /** Gets or sets border thickness */
  77001. get thickness(): number;
  77002. set thickness(value: number);
  77003. /**
  77004. * Creates a new Ellipse
  77005. * @param name defines the control name
  77006. */
  77007. constructor(name?: string | undefined);
  77008. protected _getTypeName(): string;
  77009. protected _localDraw(context: CanvasRenderingContext2D): void;
  77010. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77011. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77012. }
  77013. }
  77014. declare module BABYLON.GUI {
  77015. /**
  77016. * Class used to create a password control
  77017. */
  77018. export class InputPassword extends InputText {
  77019. protected _beforeRenderText(text: string): string;
  77020. }
  77021. }
  77022. declare module BABYLON.GUI {
  77023. /** Class used to render 2D lines */
  77024. export class Line extends Control {
  77025. name?: string | undefined;
  77026. private _lineWidth;
  77027. private _x1;
  77028. private _y1;
  77029. private _x2;
  77030. private _y2;
  77031. private _dash;
  77032. private _connectedControl;
  77033. private _connectedControlDirtyObserver;
  77034. /** Gets or sets the dash pattern */
  77035. get dash(): Array<number>;
  77036. set dash(value: Array<number>);
  77037. /** Gets or sets the control connected with the line end */
  77038. get connectedControl(): Control;
  77039. set connectedControl(value: Control);
  77040. /** Gets or sets start coordinates on X axis */
  77041. get x1(): string | number;
  77042. set x1(value: string | number);
  77043. /** Gets or sets start coordinates on Y axis */
  77044. get y1(): string | number;
  77045. set y1(value: string | number);
  77046. /** Gets or sets end coordinates on X axis */
  77047. get x2(): string | number;
  77048. set x2(value: string | number);
  77049. /** Gets or sets end coordinates on Y axis */
  77050. get y2(): string | number;
  77051. set y2(value: string | number);
  77052. /** Gets or sets line width */
  77053. get lineWidth(): number;
  77054. set lineWidth(value: number);
  77055. /** Gets or sets horizontal alignment */
  77056. set horizontalAlignment(value: number);
  77057. /** Gets or sets vertical alignment */
  77058. set verticalAlignment(value: number);
  77059. private get _effectiveX2();
  77060. private get _effectiveY2();
  77061. /**
  77062. * Creates a new Line
  77063. * @param name defines the control name
  77064. */
  77065. constructor(name?: string | undefined);
  77066. protected _getTypeName(): string;
  77067. _draw(context: CanvasRenderingContext2D): void;
  77068. _measure(): void;
  77069. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77070. /**
  77071. * Move one end of the line given 3D cartesian coordinates.
  77072. * @param position Targeted world position
  77073. * @param scene BABYLON.Scene
  77074. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77075. */
  77076. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77077. /**
  77078. * Move one end of the line to a position in screen absolute space.
  77079. * @param projectedPosition Position in screen absolute space (X, Y)
  77080. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77081. */
  77082. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77083. }
  77084. }
  77085. declare module BABYLON.GUI {
  77086. /**
  77087. * Class used to store a point for a MultiLine object.
  77088. * The point can be pure 2D coordinates, a mesh or a control
  77089. */
  77090. export class MultiLinePoint {
  77091. private _multiLine;
  77092. private _x;
  77093. private _y;
  77094. private _control;
  77095. private _mesh;
  77096. private _controlObserver;
  77097. private _meshObserver;
  77098. /** @hidden */
  77099. _point: BABYLON.Vector2;
  77100. /**
  77101. * Creates a new MultiLinePoint
  77102. * @param multiLine defines the source MultiLine object
  77103. */
  77104. constructor(multiLine: MultiLine);
  77105. /** Gets or sets x coordinate */
  77106. get x(): string | number;
  77107. set x(value: string | number);
  77108. /** Gets or sets y coordinate */
  77109. get y(): string | number;
  77110. set y(value: string | number);
  77111. /** Gets or sets the control associated with this point */
  77112. get control(): BABYLON.Nullable<Control>;
  77113. set control(value: BABYLON.Nullable<Control>);
  77114. /** Gets or sets the mesh associated with this point */
  77115. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77116. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77117. /** Resets links */
  77118. resetLinks(): void;
  77119. /**
  77120. * Gets a translation vector
  77121. * @returns the translation vector
  77122. */
  77123. translate(): BABYLON.Vector2;
  77124. private _translatePoint;
  77125. /** Release associated resources */
  77126. dispose(): void;
  77127. }
  77128. }
  77129. declare module BABYLON.GUI {
  77130. /**
  77131. * Class used to create multi line control
  77132. */
  77133. export class MultiLine extends Control {
  77134. name?: string | undefined;
  77135. private _lineWidth;
  77136. private _dash;
  77137. private _points;
  77138. private _minX;
  77139. private _minY;
  77140. private _maxX;
  77141. private _maxY;
  77142. /**
  77143. * Creates a new MultiLine
  77144. * @param name defines the control name
  77145. */
  77146. constructor(name?: string | undefined);
  77147. /** Gets or sets dash pattern */
  77148. get dash(): Array<number>;
  77149. set dash(value: Array<number>);
  77150. /**
  77151. * Gets point stored at specified index
  77152. * @param index defines the index to look for
  77153. * @returns the requested point if found
  77154. */
  77155. getAt(index: number): MultiLinePoint;
  77156. /** Function called when a point is updated */
  77157. onPointUpdate: () => void;
  77158. /**
  77159. * Adds new points to the point collection
  77160. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77161. * @returns the list of created MultiLinePoint
  77162. */
  77163. add(...items: (AbstractMesh | Control | {
  77164. x: string | number;
  77165. y: string | number;
  77166. })[]): MultiLinePoint[];
  77167. /**
  77168. * Adds a new point to the point collection
  77169. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77170. * @returns the created MultiLinePoint
  77171. */
  77172. push(item?: (AbstractMesh | Control | {
  77173. x: string | number;
  77174. y: string | number;
  77175. })): MultiLinePoint;
  77176. /**
  77177. * Remove a specific value or point from the active point collection
  77178. * @param value defines the value or point to remove
  77179. */
  77180. remove(value: number | MultiLinePoint): void;
  77181. /**
  77182. * Resets this object to initial state (no point)
  77183. */
  77184. reset(): void;
  77185. /**
  77186. * Resets all links
  77187. */
  77188. resetLinks(): void;
  77189. /** Gets or sets line width */
  77190. get lineWidth(): number;
  77191. set lineWidth(value: number);
  77192. set horizontalAlignment(value: number);
  77193. set verticalAlignment(value: number);
  77194. protected _getTypeName(): string;
  77195. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77196. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77197. _measure(): void;
  77198. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77199. dispose(): void;
  77200. }
  77201. }
  77202. declare module BABYLON.GUI {
  77203. /**
  77204. * Class used to create radio button controls
  77205. */
  77206. export class RadioButton extends Control {
  77207. name?: string | undefined;
  77208. private _isChecked;
  77209. private _background;
  77210. private _checkSizeRatio;
  77211. private _thickness;
  77212. /** Gets or sets border thickness */
  77213. get thickness(): number;
  77214. set thickness(value: number);
  77215. /** Gets or sets group name */
  77216. group: string;
  77217. /** BABYLON.Observable raised when isChecked is changed */
  77218. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77219. /** Gets or sets a value indicating the ratio between overall size and check size */
  77220. get checkSizeRatio(): number;
  77221. set checkSizeRatio(value: number);
  77222. /** Gets or sets background color */
  77223. get background(): string;
  77224. set background(value: string);
  77225. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77226. get isChecked(): boolean;
  77227. set isChecked(value: boolean);
  77228. /**
  77229. * Creates a new RadioButton
  77230. * @param name defines the control name
  77231. */
  77232. constructor(name?: string | undefined);
  77233. protected _getTypeName(): string;
  77234. _draw(context: CanvasRenderingContext2D): void;
  77235. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77236. /**
  77237. * Utility function to easily create a radio button with a header
  77238. * @param title defines the label to use for the header
  77239. * @param group defines the group to use for the radio button
  77240. * @param isChecked defines the initial state of the radio button
  77241. * @param onValueChanged defines the callback to call when value changes
  77242. * @returns a StackPanel containing the radio button and a textBlock
  77243. */
  77244. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77245. }
  77246. }
  77247. declare module BABYLON.GUI {
  77248. /**
  77249. * Class used to create slider controls
  77250. */
  77251. export class BaseSlider extends Control {
  77252. name?: string | undefined;
  77253. protected _thumbWidth: ValueAndUnit;
  77254. private _minimum;
  77255. private _maximum;
  77256. private _value;
  77257. private _isVertical;
  77258. protected _barOffset: ValueAndUnit;
  77259. private _isThumbClamped;
  77260. protected _displayThumb: boolean;
  77261. private _step;
  77262. private _lastPointerDownID;
  77263. protected _effectiveBarOffset: number;
  77264. protected _renderLeft: number;
  77265. protected _renderTop: number;
  77266. protected _renderWidth: number;
  77267. protected _renderHeight: number;
  77268. protected _backgroundBoxLength: number;
  77269. protected _backgroundBoxThickness: number;
  77270. protected _effectiveThumbThickness: number;
  77271. /** BABYLON.Observable raised when the sldier value changes */
  77272. onValueChangedObservable: BABYLON.Observable<number>;
  77273. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77274. get displayThumb(): boolean;
  77275. set displayThumb(value: boolean);
  77276. /** Gets or sets a step to apply to values (0 by default) */
  77277. get step(): number;
  77278. set step(value: number);
  77279. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77280. get barOffset(): string | number;
  77281. /** Gets main bar offset in pixels*/
  77282. get barOffsetInPixels(): number;
  77283. set barOffset(value: string | number);
  77284. /** Gets or sets thumb width */
  77285. get thumbWidth(): string | number;
  77286. /** Gets thumb width in pixels */
  77287. get thumbWidthInPixels(): number;
  77288. set thumbWidth(value: string | number);
  77289. /** Gets or sets minimum value */
  77290. get minimum(): number;
  77291. set minimum(value: number);
  77292. /** Gets or sets maximum value */
  77293. get maximum(): number;
  77294. set maximum(value: number);
  77295. /** Gets or sets current value */
  77296. get value(): number;
  77297. set value(value: number);
  77298. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77299. get isVertical(): boolean;
  77300. set isVertical(value: boolean);
  77301. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77302. get isThumbClamped(): boolean;
  77303. set isThumbClamped(value: boolean);
  77304. /**
  77305. * Creates a new BaseSlider
  77306. * @param name defines the control name
  77307. */
  77308. constructor(name?: string | undefined);
  77309. protected _getTypeName(): string;
  77310. protected _getThumbPosition(): number;
  77311. protected _getThumbThickness(type: string): number;
  77312. protected _prepareRenderingData(type: string): void;
  77313. private _pointerIsDown;
  77314. /** @hidden */
  77315. protected _updateValueFromPointer(x: number, y: number): void;
  77316. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77317. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77318. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77319. }
  77320. }
  77321. declare module BABYLON.GUI {
  77322. /**
  77323. * Class used to create slider controls
  77324. */
  77325. export class Slider extends BaseSlider {
  77326. name?: string | undefined;
  77327. private _background;
  77328. private _borderColor;
  77329. private _isThumbCircle;
  77330. protected _displayValueBar: boolean;
  77331. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77332. get displayValueBar(): boolean;
  77333. set displayValueBar(value: boolean);
  77334. /** Gets or sets border color */
  77335. get borderColor(): string;
  77336. set borderColor(value: string);
  77337. /** Gets or sets background color */
  77338. get background(): string;
  77339. set background(value: string);
  77340. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77341. get isThumbCircle(): boolean;
  77342. set isThumbCircle(value: boolean);
  77343. /**
  77344. * Creates a new Slider
  77345. * @param name defines the control name
  77346. */
  77347. constructor(name?: string | undefined);
  77348. protected _getTypeName(): string;
  77349. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77350. }
  77351. }
  77352. declare module BABYLON.GUI {
  77353. /** Class used to create a RadioGroup
  77354. * which contains groups of radio buttons
  77355. */
  77356. export class SelectorGroup {
  77357. /** name of SelectorGroup */
  77358. name: string;
  77359. private _groupPanel;
  77360. private _selectors;
  77361. private _groupHeader;
  77362. /**
  77363. * Creates a new SelectorGroup
  77364. * @param name of group, used as a group heading
  77365. */
  77366. constructor(
  77367. /** name of SelectorGroup */
  77368. name: string);
  77369. /** Gets the groupPanel of the SelectorGroup */
  77370. get groupPanel(): StackPanel;
  77371. /** Gets the selectors array */
  77372. get selectors(): StackPanel[];
  77373. /** Gets and sets the group header */
  77374. get header(): string;
  77375. set header(label: string);
  77376. /** @hidden */
  77377. private _addGroupHeader;
  77378. /** @hidden*/
  77379. _getSelector(selectorNb: number): StackPanel | undefined;
  77380. /** Removes the selector at the given position
  77381. * @param selectorNb the position of the selector within the group
  77382. */
  77383. removeSelector(selectorNb: number): void;
  77384. }
  77385. /** Class used to create a CheckboxGroup
  77386. * which contains groups of checkbox buttons
  77387. */
  77388. export class CheckboxGroup extends SelectorGroup {
  77389. /** Adds a checkbox as a control
  77390. * @param text is the label for the selector
  77391. * @param func is the function called when the Selector is checked
  77392. * @param checked is true when Selector is checked
  77393. */
  77394. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77395. /** @hidden */
  77396. _setSelectorLabel(selectorNb: number, label: string): void;
  77397. /** @hidden */
  77398. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77399. /** @hidden */
  77400. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77401. /** @hidden */
  77402. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77403. }
  77404. /** Class used to create a RadioGroup
  77405. * which contains groups of radio buttons
  77406. */
  77407. export class RadioGroup extends SelectorGroup {
  77408. private _selectNb;
  77409. /** Adds a radio button as a control
  77410. * @param label is the label for the selector
  77411. * @param func is the function called when the Selector is checked
  77412. * @param checked is true when Selector is checked
  77413. */
  77414. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77415. /** @hidden */
  77416. _setSelectorLabel(selectorNb: number, label: string): void;
  77417. /** @hidden */
  77418. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77419. /** @hidden */
  77420. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77421. /** @hidden */
  77422. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77423. }
  77424. /** Class used to create a SliderGroup
  77425. * which contains groups of slider buttons
  77426. */
  77427. export class SliderGroup extends SelectorGroup {
  77428. /**
  77429. * Adds a slider to the SelectorGroup
  77430. * @param label is the label for the SliderBar
  77431. * @param func is the function called when the Slider moves
  77432. * @param unit is a string describing the units used, eg degrees or metres
  77433. * @param min is the minimum value for the Slider
  77434. * @param max is the maximum value for the Slider
  77435. * @param value is the start value for the Slider between min and max
  77436. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77437. */
  77438. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77439. /** @hidden */
  77440. _setSelectorLabel(selectorNb: number, label: string): void;
  77441. /** @hidden */
  77442. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77443. /** @hidden */
  77444. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77445. /** @hidden */
  77446. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77447. }
  77448. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77449. * @see https://doc.babylonjs.com/how_to/selector
  77450. */
  77451. export class SelectionPanel extends Rectangle {
  77452. /** name of SelectionPanel */
  77453. name: string;
  77454. /** an array of SelectionGroups */
  77455. groups: SelectorGroup[];
  77456. private _panel;
  77457. private _buttonColor;
  77458. private _buttonBackground;
  77459. private _headerColor;
  77460. private _barColor;
  77461. private _barHeight;
  77462. private _spacerHeight;
  77463. private _labelColor;
  77464. private _groups;
  77465. private _bars;
  77466. /**
  77467. * Creates a new SelectionPanel
  77468. * @param name of SelectionPanel
  77469. * @param groups is an array of SelectionGroups
  77470. */
  77471. constructor(
  77472. /** name of SelectionPanel */
  77473. name: string,
  77474. /** an array of SelectionGroups */
  77475. groups?: SelectorGroup[]);
  77476. protected _getTypeName(): string;
  77477. /** Gets or sets the headerColor */
  77478. get headerColor(): string;
  77479. set headerColor(color: string);
  77480. private _setHeaderColor;
  77481. /** Gets or sets the button color */
  77482. get buttonColor(): string;
  77483. set buttonColor(color: string);
  77484. private _setbuttonColor;
  77485. /** Gets or sets the label color */
  77486. get labelColor(): string;
  77487. set labelColor(color: string);
  77488. private _setLabelColor;
  77489. /** Gets or sets the button background */
  77490. get buttonBackground(): string;
  77491. set buttonBackground(color: string);
  77492. private _setButtonBackground;
  77493. /** Gets or sets the color of separator bar */
  77494. get barColor(): string;
  77495. set barColor(color: string);
  77496. private _setBarColor;
  77497. /** Gets or sets the height of separator bar */
  77498. get barHeight(): string;
  77499. set barHeight(value: string);
  77500. private _setBarHeight;
  77501. /** Gets or sets the height of spacers*/
  77502. get spacerHeight(): string;
  77503. set spacerHeight(value: string);
  77504. private _setSpacerHeight;
  77505. /** Adds a bar between groups */
  77506. private _addSpacer;
  77507. /** Add a group to the selection panel
  77508. * @param group is the selector group to add
  77509. */
  77510. addGroup(group: SelectorGroup): void;
  77511. /** Remove the group from the given position
  77512. * @param groupNb is the position of the group in the list
  77513. */
  77514. removeGroup(groupNb: number): void;
  77515. /** Change a group header label
  77516. * @param label is the new group header label
  77517. * @param groupNb is the number of the group to relabel
  77518. * */
  77519. setHeaderName(label: string, groupNb: number): void;
  77520. /** Change selector label to the one given
  77521. * @param label is the new selector label
  77522. * @param groupNb is the number of the groupcontaining the selector
  77523. * @param selectorNb is the number of the selector within a group to relabel
  77524. * */
  77525. relabel(label: string, groupNb: number, selectorNb: number): void;
  77526. /** For a given group position remove the selector at the given position
  77527. * @param groupNb is the number of the group to remove the selector from
  77528. * @param selectorNb is the number of the selector within the group
  77529. */
  77530. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77531. /** For a given group position of correct type add a checkbox button
  77532. * @param groupNb is the number of the group to remove the selector from
  77533. * @param label is the label for the selector
  77534. * @param func is the function called when the Selector is checked
  77535. * @param checked is true when Selector is checked
  77536. */
  77537. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77538. /** For a given group position of correct type add a radio button
  77539. * @param groupNb is the number of the group to remove the selector from
  77540. * @param label is the label for the selector
  77541. * @param func is the function called when the Selector is checked
  77542. * @param checked is true when Selector is checked
  77543. */
  77544. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77545. /**
  77546. * For a given slider group add a slider
  77547. * @param groupNb is the number of the group to add the slider to
  77548. * @param label is the label for the Slider
  77549. * @param func is the function called when the Slider moves
  77550. * @param unit is a string describing the units used, eg degrees or metres
  77551. * @param min is the minimum value for the Slider
  77552. * @param max is the maximum value for the Slider
  77553. * @param value is the start value for the Slider between min and max
  77554. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77555. */
  77556. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77557. }
  77558. }
  77559. declare module BABYLON.GUI {
  77560. /**
  77561. * Class used to hold a the container for ScrollViewer
  77562. * @hidden
  77563. */
  77564. export class _ScrollViewerWindow extends Container {
  77565. parentClientWidth: number;
  77566. parentClientHeight: number;
  77567. private _freezeControls;
  77568. private _parentMeasure;
  77569. private _oldLeft;
  77570. private _oldTop;
  77571. get freezeControls(): boolean;
  77572. set freezeControls(value: boolean);
  77573. private _bucketWidth;
  77574. private _bucketHeight;
  77575. private _buckets;
  77576. private _bucketLen;
  77577. get bucketWidth(): number;
  77578. get bucketHeight(): number;
  77579. setBucketSizes(width: number, height: number): void;
  77580. private _useBuckets;
  77581. private _makeBuckets;
  77582. private _dispatchInBuckets;
  77583. private _updateMeasures;
  77584. private _updateChildrenMeasures;
  77585. private _restoreMeasures;
  77586. /**
  77587. * Creates a new ScrollViewerWindow
  77588. * @param name of ScrollViewerWindow
  77589. */
  77590. constructor(name?: string);
  77591. protected _getTypeName(): string;
  77592. /** @hidden */
  77593. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77594. /** @hidden */
  77595. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77596. private _scrollChildren;
  77597. private _scrollChildrenWithBuckets;
  77598. /** @hidden */
  77599. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77600. protected _postMeasure(): void;
  77601. }
  77602. }
  77603. declare module BABYLON.GUI {
  77604. /**
  77605. * Class used to create slider controls
  77606. */
  77607. export class ScrollBar extends BaseSlider {
  77608. name?: string | undefined;
  77609. private _background;
  77610. private _borderColor;
  77611. private _tempMeasure;
  77612. /** Gets or sets border color */
  77613. get borderColor(): string;
  77614. set borderColor(value: string);
  77615. /** Gets or sets background color */
  77616. get background(): string;
  77617. set background(value: string);
  77618. /**
  77619. * Creates a new Slider
  77620. * @param name defines the control name
  77621. */
  77622. constructor(name?: string | undefined);
  77623. protected _getTypeName(): string;
  77624. protected _getThumbThickness(): number;
  77625. _draw(context: CanvasRenderingContext2D): void;
  77626. private _first;
  77627. private _originX;
  77628. private _originY;
  77629. /** @hidden */
  77630. protected _updateValueFromPointer(x: number, y: number): void;
  77631. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77632. }
  77633. }
  77634. declare module BABYLON.GUI {
  77635. /**
  77636. * Class used to create slider controls
  77637. */
  77638. export class ImageScrollBar extends BaseSlider {
  77639. name?: string | undefined;
  77640. private _backgroundBaseImage;
  77641. private _backgroundImage;
  77642. private _thumbImage;
  77643. private _thumbBaseImage;
  77644. private _thumbLength;
  77645. private _thumbHeight;
  77646. private _barImageHeight;
  77647. private _tempMeasure;
  77648. /** Number of 90° rotation to apply on the images when in vertical mode */
  77649. num90RotationInVerticalMode: number;
  77650. /**
  77651. * Gets or sets the image used to render the background for horizontal bar
  77652. */
  77653. get backgroundImage(): Image;
  77654. set backgroundImage(value: Image);
  77655. /**
  77656. * Gets or sets the image used to render the thumb
  77657. */
  77658. get thumbImage(): Image;
  77659. set thumbImage(value: Image);
  77660. /**
  77661. * Gets or sets the length of the thumb
  77662. */
  77663. get thumbLength(): number;
  77664. set thumbLength(value: number);
  77665. /**
  77666. * Gets or sets the height of the thumb
  77667. */
  77668. get thumbHeight(): number;
  77669. set thumbHeight(value: number);
  77670. /**
  77671. * Gets or sets the height of the bar image
  77672. */
  77673. get barImageHeight(): number;
  77674. set barImageHeight(value: number);
  77675. /**
  77676. * Creates a new ImageScrollBar
  77677. * @param name defines the control name
  77678. */
  77679. constructor(name?: string | undefined);
  77680. protected _getTypeName(): string;
  77681. protected _getThumbThickness(): number;
  77682. _draw(context: CanvasRenderingContext2D): void;
  77683. private _first;
  77684. private _originX;
  77685. private _originY;
  77686. /** @hidden */
  77687. protected _updateValueFromPointer(x: number, y: number): void;
  77688. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77689. }
  77690. }
  77691. declare module BABYLON.GUI {
  77692. /**
  77693. * Class used to hold a viewer window and sliders in a grid
  77694. */
  77695. export class ScrollViewer extends Rectangle {
  77696. private _grid;
  77697. private _horizontalBarSpace;
  77698. private _verticalBarSpace;
  77699. private _dragSpace;
  77700. private _horizontalBar;
  77701. private _verticalBar;
  77702. private _barColor;
  77703. private _barBackground;
  77704. private _barImage;
  77705. private _horizontalBarImage;
  77706. private _verticalBarImage;
  77707. private _barBackgroundImage;
  77708. private _horizontalBarBackgroundImage;
  77709. private _verticalBarBackgroundImage;
  77710. private _barSize;
  77711. private _window;
  77712. private _pointerIsOver;
  77713. private _wheelPrecision;
  77714. private _onWheelObserver;
  77715. private _clientWidth;
  77716. private _clientHeight;
  77717. private _useImageBar;
  77718. private _thumbLength;
  77719. private _thumbHeight;
  77720. private _barImageHeight;
  77721. private _horizontalBarImageHeight;
  77722. private _verticalBarImageHeight;
  77723. private _oldWindowContentsWidth;
  77724. private _oldWindowContentsHeight;
  77725. /**
  77726. * Gets the horizontal scrollbar
  77727. */
  77728. get horizontalBar(): ScrollBar | ImageScrollBar;
  77729. /**
  77730. * Gets the vertical scrollbar
  77731. */
  77732. get verticalBar(): ScrollBar | ImageScrollBar;
  77733. /**
  77734. * Adds a new control to the current container
  77735. * @param control defines the control to add
  77736. * @returns the current container
  77737. */
  77738. addControl(control: BABYLON.Nullable<Control>): Container;
  77739. /**
  77740. * Removes a control from the current container
  77741. * @param control defines the control to remove
  77742. * @returns the current container
  77743. */
  77744. removeControl(control: Control): Container;
  77745. /** Gets the list of children */
  77746. get children(): Control[];
  77747. _flagDescendantsAsMatrixDirty(): void;
  77748. /**
  77749. * Freezes or unfreezes the controls in the window.
  77750. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77751. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77752. */
  77753. get freezeControls(): boolean;
  77754. set freezeControls(value: boolean);
  77755. /** Gets the bucket width */
  77756. get bucketWidth(): number;
  77757. /** Gets the bucket height */
  77758. get bucketHeight(): number;
  77759. /**
  77760. * Sets the bucket sizes.
  77761. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77762. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77763. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77764. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77765. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77766. * used), that's why it is not enabled by default.
  77767. * @param width width of the bucket
  77768. * @param height height of the bucket
  77769. */
  77770. setBucketSizes(width: number, height: number): void;
  77771. private _forceHorizontalBar;
  77772. private _forceVerticalBar;
  77773. /**
  77774. * Forces the horizontal scroll bar to be displayed
  77775. */
  77776. get forceHorizontalBar(): boolean;
  77777. set forceHorizontalBar(value: boolean);
  77778. /**
  77779. * Forces the vertical scroll bar to be displayed
  77780. */
  77781. get forceVerticalBar(): boolean;
  77782. set forceVerticalBar(value: boolean);
  77783. /**
  77784. * Creates a new ScrollViewer
  77785. * @param name of ScrollViewer
  77786. */
  77787. constructor(name?: string, isImageBased?: boolean);
  77788. /** Reset the scroll viewer window to initial size */
  77789. resetWindow(): void;
  77790. protected _getTypeName(): string;
  77791. private _buildClientSizes;
  77792. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77793. protected _postMeasure(): void;
  77794. /**
  77795. * Gets or sets the mouse wheel precision
  77796. * from 0 to 1 with a default value of 0.05
  77797. * */
  77798. get wheelPrecision(): number;
  77799. set wheelPrecision(value: number);
  77800. /** Gets or sets the scroll bar container background color */
  77801. get scrollBackground(): string;
  77802. set scrollBackground(color: string);
  77803. /** Gets or sets the bar color */
  77804. get barColor(): string;
  77805. set barColor(color: string);
  77806. /** Gets or sets the bar image */
  77807. get thumbImage(): Image;
  77808. set thumbImage(value: Image);
  77809. /** Gets or sets the horizontal bar image */
  77810. get horizontalThumbImage(): Image;
  77811. set horizontalThumbImage(value: Image);
  77812. /** Gets or sets the vertical bar image */
  77813. get verticalThumbImage(): Image;
  77814. set verticalThumbImage(value: Image);
  77815. /** Gets or sets the size of the bar */
  77816. get barSize(): number;
  77817. set barSize(value: number);
  77818. /** Gets or sets the length of the thumb */
  77819. get thumbLength(): number;
  77820. set thumbLength(value: number);
  77821. /** Gets or sets the height of the thumb */
  77822. get thumbHeight(): number;
  77823. set thumbHeight(value: number);
  77824. /** Gets or sets the height of the bar image */
  77825. get barImageHeight(): number;
  77826. set barImageHeight(value: number);
  77827. /** Gets or sets the height of the horizontal bar image */
  77828. get horizontalBarImageHeight(): number;
  77829. set horizontalBarImageHeight(value: number);
  77830. /** Gets or sets the height of the vertical bar image */
  77831. get verticalBarImageHeight(): number;
  77832. set verticalBarImageHeight(value: number);
  77833. /** Gets or sets the bar background */
  77834. get barBackground(): string;
  77835. set barBackground(color: string);
  77836. /** Gets or sets the bar background image */
  77837. get barImage(): Image;
  77838. set barImage(value: Image);
  77839. /** Gets or sets the horizontal bar background image */
  77840. get horizontalBarImage(): Image;
  77841. set horizontalBarImage(value: Image);
  77842. /** Gets or sets the vertical bar background image */
  77843. get verticalBarImage(): Image;
  77844. set verticalBarImage(value: Image);
  77845. private _setWindowPosition;
  77846. /** @hidden */
  77847. private _updateScroller;
  77848. _link(host: AdvancedDynamicTexture): void;
  77849. /** @hidden */
  77850. private _addBar;
  77851. /** @hidden */
  77852. private _attachWheel;
  77853. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77854. /** Releases associated resources */
  77855. dispose(): void;
  77856. }
  77857. }
  77858. declare module BABYLON.GUI {
  77859. /** Class used to render a grid */
  77860. export class DisplayGrid extends Control {
  77861. name?: string | undefined;
  77862. private _cellWidth;
  77863. private _cellHeight;
  77864. private _minorLineTickness;
  77865. private _minorLineColor;
  77866. private _majorLineTickness;
  77867. private _majorLineColor;
  77868. private _majorLineFrequency;
  77869. private _background;
  77870. private _displayMajorLines;
  77871. private _displayMinorLines;
  77872. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77873. get displayMinorLines(): boolean;
  77874. set displayMinorLines(value: boolean);
  77875. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77876. get displayMajorLines(): boolean;
  77877. set displayMajorLines(value: boolean);
  77878. /** Gets or sets background color (Black by default) */
  77879. get background(): string;
  77880. set background(value: string);
  77881. /** Gets or sets the width of each cell (20 by default) */
  77882. get cellWidth(): number;
  77883. set cellWidth(value: number);
  77884. /** Gets or sets the height of each cell (20 by default) */
  77885. get cellHeight(): number;
  77886. set cellHeight(value: number);
  77887. /** Gets or sets the tickness of minor lines (1 by default) */
  77888. get minorLineTickness(): number;
  77889. set minorLineTickness(value: number);
  77890. /** Gets or sets the color of minor lines (DarkGray by default) */
  77891. get minorLineColor(): string;
  77892. set minorLineColor(value: string);
  77893. /** Gets or sets the tickness of major lines (2 by default) */
  77894. get majorLineTickness(): number;
  77895. set majorLineTickness(value: number);
  77896. /** Gets or sets the color of major lines (White by default) */
  77897. get majorLineColor(): string;
  77898. set majorLineColor(value: string);
  77899. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77900. get majorLineFrequency(): number;
  77901. set majorLineFrequency(value: number);
  77902. /**
  77903. * Creates a new GridDisplayRectangle
  77904. * @param name defines the control name
  77905. */
  77906. constructor(name?: string | undefined);
  77907. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77908. protected _getTypeName(): string;
  77909. }
  77910. }
  77911. declare module BABYLON.GUI {
  77912. /**
  77913. * Class used to create slider controls based on images
  77914. */
  77915. export class ImageBasedSlider extends BaseSlider {
  77916. name?: string | undefined;
  77917. private _backgroundImage;
  77918. private _thumbImage;
  77919. private _valueBarImage;
  77920. private _tempMeasure;
  77921. get displayThumb(): boolean;
  77922. set displayThumb(value: boolean);
  77923. /**
  77924. * Gets or sets the image used to render the background
  77925. */
  77926. get backgroundImage(): Image;
  77927. set backgroundImage(value: Image);
  77928. /**
  77929. * Gets or sets the image used to render the value bar
  77930. */
  77931. get valueBarImage(): Image;
  77932. set valueBarImage(value: Image);
  77933. /**
  77934. * Gets or sets the image used to render the thumb
  77935. */
  77936. get thumbImage(): Image;
  77937. set thumbImage(value: Image);
  77938. /**
  77939. * Creates a new ImageBasedSlider
  77940. * @param name defines the control name
  77941. */
  77942. constructor(name?: string | undefined);
  77943. protected _getTypeName(): string;
  77944. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77945. }
  77946. }
  77947. declare module BABYLON.GUI {
  77948. /**
  77949. * Forcing an export so that this code will execute
  77950. * @hidden
  77951. */
  77952. const name = "Statics";
  77953. }
  77954. declare module BABYLON.GUI {
  77955. /**
  77956. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77957. */
  77958. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77959. /**
  77960. * Define the instrumented AdvancedDynamicTexture.
  77961. */
  77962. texture: AdvancedDynamicTexture;
  77963. private _captureRenderTime;
  77964. private _renderTime;
  77965. private _captureLayoutTime;
  77966. private _layoutTime;
  77967. private _onBeginRenderObserver;
  77968. private _onEndRenderObserver;
  77969. private _onBeginLayoutObserver;
  77970. private _onEndLayoutObserver;
  77971. /**
  77972. * Gets the perf counter used to capture render time
  77973. */
  77974. get renderTimeCounter(): BABYLON.PerfCounter;
  77975. /**
  77976. * Gets the perf counter used to capture layout time
  77977. */
  77978. get layoutTimeCounter(): BABYLON.PerfCounter;
  77979. /**
  77980. * Enable or disable the render time capture
  77981. */
  77982. get captureRenderTime(): boolean;
  77983. set captureRenderTime(value: boolean);
  77984. /**
  77985. * Enable or disable the layout time capture
  77986. */
  77987. get captureLayoutTime(): boolean;
  77988. set captureLayoutTime(value: boolean);
  77989. /**
  77990. * Instantiates a new advanced dynamic texture instrumentation.
  77991. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77992. * @param texture Defines the AdvancedDynamicTexture to instrument
  77993. */
  77994. constructor(
  77995. /**
  77996. * Define the instrumented AdvancedDynamicTexture.
  77997. */
  77998. texture: AdvancedDynamicTexture);
  77999. /**
  78000. * Dispose and release associated resources.
  78001. */
  78002. dispose(): void;
  78003. }
  78004. }
  78005. declare module BABYLON.GUI {
  78006. /**
  78007. * Class used to load GUI via XML.
  78008. */
  78009. export class XmlLoader {
  78010. private _nodes;
  78011. private _nodeTypes;
  78012. private _isLoaded;
  78013. private _objectAttributes;
  78014. private _parentClass;
  78015. /**
  78016. * Create a new xml loader
  78017. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78018. */
  78019. constructor(parentClass?: null);
  78020. private _getChainElement;
  78021. private _getClassAttribute;
  78022. private _createGuiElement;
  78023. private _parseGrid;
  78024. private _parseElement;
  78025. private _prepareSourceElement;
  78026. private _parseElementsFromSource;
  78027. private _parseXml;
  78028. /**
  78029. * Gets if the loading has finished.
  78030. * @returns whether the loading has finished or not
  78031. */
  78032. isLoaded(): boolean;
  78033. /**
  78034. * Gets a loaded node / control by id.
  78035. * @param id the Controls id set in the xml
  78036. * @returns element of type Control
  78037. */
  78038. getNodeById(id: string): any;
  78039. /**
  78040. * Gets all loaded nodes / controls
  78041. * @returns Array of controls
  78042. */
  78043. getNodes(): any;
  78044. /**
  78045. * Initiates the xml layout loading
  78046. * @param xmlFile defines the xml layout to load
  78047. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78048. * @param callback defines the callback called on layout load.
  78049. */
  78050. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78051. }
  78052. }
  78053. declare module BABYLON.GUI {
  78054. /**
  78055. * Class used to create containers for controls
  78056. */
  78057. export class Container3D extends Control3D {
  78058. private _blockLayout;
  78059. /**
  78060. * Gets the list of child controls
  78061. */
  78062. protected _children: Control3D[];
  78063. /**
  78064. * Gets the list of child controls
  78065. */
  78066. get children(): Array<Control3D>;
  78067. /**
  78068. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78069. * This is helpful to optimize layout operation when adding multiple children in a row
  78070. */
  78071. get blockLayout(): boolean;
  78072. set blockLayout(value: boolean);
  78073. /**
  78074. * Creates a new container
  78075. * @param name defines the container name
  78076. */
  78077. constructor(name?: string);
  78078. /**
  78079. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78080. * @returns the current container
  78081. */
  78082. updateLayout(): Container3D;
  78083. /**
  78084. * Gets a boolean indicating if the given control is in the children of this control
  78085. * @param control defines the control to check
  78086. * @returns true if the control is in the child list
  78087. */
  78088. containsControl(control: Control3D): boolean;
  78089. /**
  78090. * Adds a control to the children of this control
  78091. * @param control defines the control to add
  78092. * @returns the current container
  78093. */
  78094. addControl(control: Control3D): Container3D;
  78095. /**
  78096. * This function will be called everytime a new control is added
  78097. */
  78098. protected _arrangeChildren(): void;
  78099. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78100. /**
  78101. * Removes a control from the children of this control
  78102. * @param control defines the control to remove
  78103. * @returns the current container
  78104. */
  78105. removeControl(control: Control3D): Container3D;
  78106. protected _getTypeName(): string;
  78107. /**
  78108. * Releases all associated resources
  78109. */
  78110. dispose(): void;
  78111. /** Control rotation will remain unchanged */
  78112. static readonly UNSET_ORIENTATION: number;
  78113. /** Control will rotate to make it look at sphere central axis */
  78114. static readonly FACEORIGIN_ORIENTATION: number;
  78115. /** Control will rotate to make it look back at sphere central axis */
  78116. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78117. /** Control will rotate to look at z axis (0, 0, 1) */
  78118. static readonly FACEFORWARD_ORIENTATION: number;
  78119. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78120. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78121. }
  78122. }
  78123. declare module BABYLON.GUI {
  78124. /**
  78125. * Class used to manage 3D user interface
  78126. * @see https://doc.babylonjs.com/how_to/gui3d
  78127. */
  78128. export class GUI3DManager implements BABYLON.IDisposable {
  78129. private _scene;
  78130. private _sceneDisposeObserver;
  78131. private _utilityLayer;
  78132. private _rootContainer;
  78133. private _pointerObserver;
  78134. private _pointerOutObserver;
  78135. /** @hidden */
  78136. _lastPickedControl: Control3D;
  78137. /** @hidden */
  78138. _lastControlOver: {
  78139. [pointerId: number]: Control3D;
  78140. };
  78141. /** @hidden */
  78142. _lastControlDown: {
  78143. [pointerId: number]: Control3D;
  78144. };
  78145. /**
  78146. * BABYLON.Observable raised when the point picked by the pointer events changed
  78147. */
  78148. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78149. /** @hidden */
  78150. _sharedMaterials: {
  78151. [key: string]: BABYLON.Material;
  78152. };
  78153. /** Gets the hosting scene */
  78154. get scene(): BABYLON.Scene;
  78155. /** Gets associated utility layer */
  78156. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78157. /**
  78158. * Creates a new GUI3DManager
  78159. * @param scene
  78160. */
  78161. constructor(scene?: BABYLON.Scene);
  78162. private _handlePointerOut;
  78163. private _doPicking;
  78164. /**
  78165. * Gets the root container
  78166. */
  78167. get rootContainer(): Container3D;
  78168. /**
  78169. * Gets a boolean indicating if the given control is in the root child list
  78170. * @param control defines the control to check
  78171. * @returns true if the control is in the root child list
  78172. */
  78173. containsControl(control: Control3D): boolean;
  78174. /**
  78175. * Adds a control to the root child list
  78176. * @param control defines the control to add
  78177. * @returns the current manager
  78178. */
  78179. addControl(control: Control3D): GUI3DManager;
  78180. /**
  78181. * Removes a control from the root child list
  78182. * @param control defines the control to remove
  78183. * @returns the current container
  78184. */
  78185. removeControl(control: Control3D): GUI3DManager;
  78186. /**
  78187. * Releases all associated resources
  78188. */
  78189. dispose(): void;
  78190. }
  78191. }
  78192. declare module BABYLON.GUI {
  78193. /**
  78194. * Class used to transport BABYLON.Vector3 information for pointer events
  78195. */
  78196. export class Vector3WithInfo extends BABYLON.Vector3 {
  78197. /** defines the current mouse button index */
  78198. buttonIndex: number;
  78199. /**
  78200. * Creates a new Vector3WithInfo
  78201. * @param source defines the vector3 data to transport
  78202. * @param buttonIndex defines the current mouse button index
  78203. */
  78204. constructor(source: BABYLON.Vector3,
  78205. /** defines the current mouse button index */
  78206. buttonIndex?: number);
  78207. }
  78208. }
  78209. declare module BABYLON.GUI {
  78210. /**
  78211. * Class used as base class for controls
  78212. */
  78213. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78214. /** Defines the control name */
  78215. name?: string | undefined;
  78216. /** @hidden */
  78217. _host: GUI3DManager;
  78218. private _node;
  78219. private _downCount;
  78220. private _enterCount;
  78221. private _downPointerIds;
  78222. private _isVisible;
  78223. /** Gets or sets the control position in world space */
  78224. get position(): BABYLON.Vector3;
  78225. set position(value: BABYLON.Vector3);
  78226. /** Gets or sets the control scaling in world space */
  78227. get scaling(): BABYLON.Vector3;
  78228. set scaling(value: BABYLON.Vector3);
  78229. /** Callback used to start pointer enter animation */
  78230. pointerEnterAnimation: () => void;
  78231. /** Callback used to start pointer out animation */
  78232. pointerOutAnimation: () => void;
  78233. /** Callback used to start pointer down animation */
  78234. pointerDownAnimation: () => void;
  78235. /** Callback used to start pointer up animation */
  78236. pointerUpAnimation: () => void;
  78237. /**
  78238. * An event triggered when the pointer move over the control
  78239. */
  78240. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78241. /**
  78242. * An event triggered when the pointer move out of the control
  78243. */
  78244. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78245. /**
  78246. * An event triggered when the pointer taps the control
  78247. */
  78248. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78249. /**
  78250. * An event triggered when pointer is up
  78251. */
  78252. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78253. /**
  78254. * An event triggered when a control is clicked on (with a mouse)
  78255. */
  78256. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78257. /**
  78258. * An event triggered when pointer enters the control
  78259. */
  78260. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78261. /**
  78262. * Gets or sets the parent container
  78263. */
  78264. parent: BABYLON.Nullable<Container3D>;
  78265. private _behaviors;
  78266. /**
  78267. * Gets the list of attached behaviors
  78268. * @see https://doc.babylonjs.com/features/behaviour
  78269. */
  78270. get behaviors(): BABYLON.Behavior<Control3D>[];
  78271. /**
  78272. * Attach a behavior to the control
  78273. * @see https://doc.babylonjs.com/features/behaviour
  78274. * @param behavior defines the behavior to attach
  78275. * @returns the current control
  78276. */
  78277. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78278. /**
  78279. * Remove an attached behavior
  78280. * @see https://doc.babylonjs.com/features/behaviour
  78281. * @param behavior defines the behavior to attach
  78282. * @returns the current control
  78283. */
  78284. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78285. /**
  78286. * Gets an attached behavior by name
  78287. * @param name defines the name of the behavior to look for
  78288. * @see https://doc.babylonjs.com/features/behaviour
  78289. * @returns null if behavior was not found else the requested behavior
  78290. */
  78291. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78292. /** Gets or sets a boolean indicating if the control is visible */
  78293. get isVisible(): boolean;
  78294. set isVisible(value: boolean);
  78295. /**
  78296. * Creates a new control
  78297. * @param name defines the control name
  78298. */
  78299. constructor(
  78300. /** Defines the control name */
  78301. name?: string | undefined);
  78302. /**
  78303. * Gets a string representing the class name
  78304. */
  78305. get typeName(): string;
  78306. /**
  78307. * Get the current class name of the control.
  78308. * @returns current class name
  78309. */
  78310. getClassName(): string;
  78311. protected _getTypeName(): string;
  78312. /**
  78313. * Gets the transform node used by this control
  78314. */
  78315. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78316. /**
  78317. * Gets the mesh used to render this control
  78318. */
  78319. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78320. /**
  78321. * Link the control as child of the given node
  78322. * @param node defines the node to link to. Use null to unlink the control
  78323. * @returns the current control
  78324. */
  78325. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78326. /** @hidden **/
  78327. _prepareNode(scene: BABYLON.Scene): void;
  78328. /**
  78329. * Node creation.
  78330. * Can be overriden by children
  78331. * @param scene defines the scene where the node must be attached
  78332. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78333. */
  78334. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78335. /**
  78336. * Affect a material to the given mesh
  78337. * @param mesh defines the mesh which will represent the control
  78338. */
  78339. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78340. /** @hidden */
  78341. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78342. /** @hidden */
  78343. _onPointerEnter(target: Control3D): boolean;
  78344. /** @hidden */
  78345. _onPointerOut(target: Control3D): void;
  78346. /** @hidden */
  78347. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78348. /** @hidden */
  78349. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78350. /** @hidden */
  78351. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78352. /** @hidden */
  78353. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78354. /** @hidden */
  78355. _disposeNode(): void;
  78356. /**
  78357. * Releases all associated resources
  78358. */
  78359. dispose(): void;
  78360. }
  78361. }
  78362. declare module BABYLON.GUI {
  78363. /**
  78364. * Class used as a root to all buttons
  78365. */
  78366. export class AbstractButton3D extends Control3D {
  78367. /**
  78368. * Creates a new button
  78369. * @param name defines the control name
  78370. */
  78371. constructor(name?: string);
  78372. protected _getTypeName(): string;
  78373. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78374. }
  78375. }
  78376. declare module BABYLON.GUI {
  78377. /**
  78378. * Class used to create a button in 3D
  78379. */
  78380. export class Button3D extends AbstractButton3D {
  78381. /** @hidden */
  78382. protected _currentMaterial: BABYLON.Material;
  78383. private _facadeTexture;
  78384. private _content;
  78385. private _contentResolution;
  78386. private _contentScaleRatio;
  78387. /**
  78388. * Gets or sets the texture resolution used to render content (512 by default)
  78389. */
  78390. get contentResolution(): BABYLON.int;
  78391. set contentResolution(value: BABYLON.int);
  78392. /**
  78393. * Gets or sets the texture scale ratio used to render content (2 by default)
  78394. */
  78395. get contentScaleRatio(): number;
  78396. set contentScaleRatio(value: number);
  78397. protected _disposeFacadeTexture(): void;
  78398. protected _resetContent(): void;
  78399. /**
  78400. * Creates a new button
  78401. * @param name defines the control name
  78402. */
  78403. constructor(name?: string);
  78404. /**
  78405. * Gets or sets the GUI 2D content used to display the button's facade
  78406. */
  78407. get content(): Control;
  78408. set content(value: Control);
  78409. /**
  78410. * Apply the facade texture (created from the content property).
  78411. * This function can be overloaded by child classes
  78412. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78413. */
  78414. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78415. protected _getTypeName(): string;
  78416. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78417. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78418. /**
  78419. * Releases all associated resources
  78420. */
  78421. dispose(): void;
  78422. }
  78423. }
  78424. declare module BABYLON.GUI {
  78425. /**
  78426. * Abstract class used to create a container panel deployed on the surface of a volume
  78427. */
  78428. export abstract class VolumeBasedPanel extends Container3D {
  78429. private _columns;
  78430. private _rows;
  78431. private _rowThenColum;
  78432. private _orientation;
  78433. protected _cellWidth: number;
  78434. protected _cellHeight: number;
  78435. /**
  78436. * Gets or sets the distance between elements
  78437. */
  78438. margin: number;
  78439. /**
  78440. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78441. * | Value | Type | Description |
  78442. * | ----- | ----------------------------------- | ----------- |
  78443. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78444. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78445. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78446. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78447. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78448. */
  78449. get orientation(): number;
  78450. set orientation(value: number);
  78451. /**
  78452. * Gets or sets the number of columns requested (10 by default).
  78453. * The panel will automatically compute the number of rows based on number of child controls.
  78454. */
  78455. get columns(): BABYLON.int;
  78456. set columns(value: BABYLON.int);
  78457. /**
  78458. * Gets or sets a the number of rows requested.
  78459. * The panel will automatically compute the number of columns based on number of child controls.
  78460. */
  78461. get rows(): BABYLON.int;
  78462. set rows(value: BABYLON.int);
  78463. /**
  78464. * Creates new VolumeBasedPanel
  78465. */
  78466. constructor();
  78467. protected _arrangeChildren(): void;
  78468. /** Child classes must implement this function to provide correct control positioning */
  78469. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78470. /** Child classes can implement this function to provide additional processing */
  78471. protected _finalProcessing(): void;
  78472. }
  78473. }
  78474. declare module BABYLON.GUI {
  78475. /**
  78476. * Class used to create a container panel deployed on the surface of a cylinder
  78477. */
  78478. export class CylinderPanel extends VolumeBasedPanel {
  78479. private _radius;
  78480. /**
  78481. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78482. */
  78483. get radius(): BABYLON.float;
  78484. set radius(value: BABYLON.float);
  78485. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78486. private _cylindricalMapping;
  78487. }
  78488. }
  78489. declare module BABYLON.GUI {
  78490. /** @hidden */
  78491. export var fluentVertexShader: {
  78492. name: string;
  78493. shader: string;
  78494. };
  78495. }
  78496. declare module BABYLON.GUI {
  78497. /** @hidden */
  78498. export var fluentPixelShader: {
  78499. name: string;
  78500. shader: string;
  78501. };
  78502. }
  78503. declare module BABYLON.GUI {
  78504. /** @hidden */
  78505. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78506. INNERGLOW: boolean;
  78507. BORDER: boolean;
  78508. HOVERLIGHT: boolean;
  78509. TEXTURE: boolean;
  78510. constructor();
  78511. }
  78512. /**
  78513. * Class used to render controls with fluent desgin
  78514. */
  78515. export class FluentMaterial extends BABYLON.PushMaterial {
  78516. /**
  78517. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78518. */
  78519. innerGlowColorIntensity: number;
  78520. /**
  78521. * Gets or sets the inner glow color (white by default)
  78522. */
  78523. innerGlowColor: BABYLON.Color3;
  78524. /**
  78525. * Gets or sets alpha value (default is 1.0)
  78526. */
  78527. alpha: number;
  78528. /**
  78529. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78530. */
  78531. albedoColor: BABYLON.Color3;
  78532. /**
  78533. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78534. */
  78535. renderBorders: boolean;
  78536. /**
  78537. * Gets or sets border width (default is 0.5)
  78538. */
  78539. borderWidth: number;
  78540. /**
  78541. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78542. */
  78543. edgeSmoothingValue: number;
  78544. /**
  78545. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78546. */
  78547. borderMinValue: number;
  78548. /**
  78549. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78550. */
  78551. renderHoverLight: boolean;
  78552. /**
  78553. * Gets or sets the radius used to render the hover light (default is 1.0)
  78554. */
  78555. hoverRadius: number;
  78556. /**
  78557. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78558. */
  78559. hoverColor: BABYLON.Color4;
  78560. /**
  78561. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78562. */
  78563. hoverPosition: BABYLON.Vector3;
  78564. private _albedoTexture;
  78565. /** Gets or sets the texture to use for albedo color */
  78566. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78567. /**
  78568. * Creates a new Fluent material
  78569. * @param name defines the name of the material
  78570. * @param scene defines the hosting scene
  78571. */
  78572. constructor(name: string, scene: BABYLON.Scene);
  78573. needAlphaBlending(): boolean;
  78574. needAlphaTesting(): boolean;
  78575. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78576. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78577. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78578. getActiveTextures(): BABYLON.BaseTexture[];
  78579. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78580. dispose(forceDisposeEffect?: boolean): void;
  78581. clone(name: string): FluentMaterial;
  78582. serialize(): any;
  78583. getClassName(): string;
  78584. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78585. }
  78586. }
  78587. declare module BABYLON.GUI {
  78588. /**
  78589. * Class used to create a holographic button in 3D
  78590. */
  78591. export class HolographicButton extends Button3D {
  78592. private _backPlate;
  78593. private _textPlate;
  78594. private _frontPlate;
  78595. private _text;
  78596. private _imageUrl;
  78597. private _shareMaterials;
  78598. private _frontMaterial;
  78599. private _backMaterial;
  78600. private _plateMaterial;
  78601. private _pickedPointObserver;
  78602. private _tooltipFade;
  78603. private _tooltipTextBlock;
  78604. private _tooltipTexture;
  78605. private _tooltipMesh;
  78606. private _tooltipHoverObserver;
  78607. private _tooltipOutObserver;
  78608. private _disposeTooltip;
  78609. /**
  78610. * Rendering ground id of all the mesh in the button
  78611. */
  78612. set renderingGroupId(id: number);
  78613. get renderingGroupId(): number;
  78614. /**
  78615. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78616. */
  78617. set tooltipText(text: BABYLON.Nullable<string>);
  78618. get tooltipText(): BABYLON.Nullable<string>;
  78619. /**
  78620. * Gets or sets text for the button
  78621. */
  78622. get text(): string;
  78623. set text(value: string);
  78624. /**
  78625. * Gets or sets the image url for the button
  78626. */
  78627. get imageUrl(): string;
  78628. set imageUrl(value: string);
  78629. /**
  78630. * Gets the back material used by this button
  78631. */
  78632. get backMaterial(): FluentMaterial;
  78633. /**
  78634. * Gets the front material used by this button
  78635. */
  78636. get frontMaterial(): FluentMaterial;
  78637. /**
  78638. * Gets the plate material used by this button
  78639. */
  78640. get plateMaterial(): BABYLON.StandardMaterial;
  78641. /**
  78642. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78643. */
  78644. get shareMaterials(): boolean;
  78645. /**
  78646. * Creates a new button
  78647. * @param name defines the control name
  78648. */
  78649. constructor(name?: string, shareMaterials?: boolean);
  78650. protected _getTypeName(): string;
  78651. private _rebuildContent;
  78652. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78653. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78654. private _createBackMaterial;
  78655. private _createFrontMaterial;
  78656. private _createPlateMaterial;
  78657. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78658. /**
  78659. * Releases all associated resources
  78660. */
  78661. dispose(): void;
  78662. }
  78663. }
  78664. declare module BABYLON.GUI {
  78665. /**
  78666. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78667. */
  78668. export class MeshButton3D extends Button3D {
  78669. /** @hidden */
  78670. protected _currentMesh: BABYLON.Mesh;
  78671. /**
  78672. * Creates a new 3D button based on a mesh
  78673. * @param mesh mesh to become a 3D button
  78674. * @param name defines the control name
  78675. */
  78676. constructor(mesh: BABYLON.Mesh, name?: string);
  78677. protected _getTypeName(): string;
  78678. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78679. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78680. }
  78681. }
  78682. declare module BABYLON.GUI {
  78683. /**
  78684. * Class used to create a container panel deployed on the surface of a plane
  78685. */
  78686. export class PlanePanel extends VolumeBasedPanel {
  78687. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78688. }
  78689. }
  78690. declare module BABYLON.GUI {
  78691. /**
  78692. * Class used to create a container panel where items get randomized planar mapping
  78693. */
  78694. export class ScatterPanel extends VolumeBasedPanel {
  78695. private _iteration;
  78696. /**
  78697. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78698. */
  78699. get iteration(): BABYLON.float;
  78700. set iteration(value: BABYLON.float);
  78701. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78702. private _scatterMapping;
  78703. protected _finalProcessing(): void;
  78704. }
  78705. }
  78706. declare module BABYLON.GUI {
  78707. /**
  78708. * Class used to create a container panel deployed on the surface of a sphere
  78709. */
  78710. export class SpherePanel extends VolumeBasedPanel {
  78711. private _radius;
  78712. /**
  78713. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78714. */
  78715. get radius(): BABYLON.float;
  78716. set radius(value: BABYLON.float);
  78717. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78718. private _sphericalMapping;
  78719. }
  78720. }
  78721. declare module BABYLON.GUI {
  78722. /**
  78723. * Class used to create a stack panel in 3D on XY plane
  78724. */
  78725. export class StackPanel3D extends Container3D {
  78726. private _isVertical;
  78727. /**
  78728. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78729. */
  78730. get isVertical(): boolean;
  78731. set isVertical(value: boolean);
  78732. /**
  78733. * Gets or sets the distance between elements
  78734. */
  78735. margin: number;
  78736. /**
  78737. * Creates new StackPanel
  78738. * @param isVertical
  78739. */
  78740. constructor(isVertical?: boolean);
  78741. protected _arrangeChildren(): void;
  78742. }
  78743. }
  78744. declare module BABYLON {
  78745. /**
  78746. * Configuration for glTF validation
  78747. */
  78748. export interface IGLTFValidationConfiguration {
  78749. /**
  78750. * The url of the glTF validator.
  78751. */
  78752. url: string;
  78753. }
  78754. /**
  78755. * glTF validation
  78756. */
  78757. export class GLTFValidation {
  78758. /**
  78759. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78760. */
  78761. static Configuration: IGLTFValidationConfiguration;
  78762. private static _LoadScriptPromise;
  78763. /**
  78764. * Validate a glTF asset using the glTF-Validator.
  78765. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78766. * @param rootUrl The root url for the glTF
  78767. * @param fileName The file name for the glTF
  78768. * @param getExternalResource The callback to get external resources for the glTF validator
  78769. * @returns A promise that resolves with the glTF validation results once complete
  78770. */
  78771. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78772. }
  78773. }
  78774. declare module BABYLON {
  78775. /**
  78776. * Mode that determines the coordinate system to use.
  78777. */
  78778. export enum GLTFLoaderCoordinateSystemMode {
  78779. /**
  78780. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78781. */
  78782. AUTO = 0,
  78783. /**
  78784. * Sets the useRightHandedSystem flag on the scene.
  78785. */
  78786. FORCE_RIGHT_HANDED = 1
  78787. }
  78788. /**
  78789. * Mode that determines what animations will start.
  78790. */
  78791. export enum GLTFLoaderAnimationStartMode {
  78792. /**
  78793. * No animation will start.
  78794. */
  78795. NONE = 0,
  78796. /**
  78797. * The first animation will start.
  78798. */
  78799. FIRST = 1,
  78800. /**
  78801. * All animations will start.
  78802. */
  78803. ALL = 2
  78804. }
  78805. /**
  78806. * Interface that contains the data for the glTF asset.
  78807. */
  78808. export interface IGLTFLoaderData {
  78809. /**
  78810. * The object that represents the glTF JSON.
  78811. */
  78812. json: Object;
  78813. /**
  78814. * The BIN chunk of a binary glTF.
  78815. */
  78816. bin: Nullable<IDataBuffer>;
  78817. }
  78818. /**
  78819. * Interface for extending the loader.
  78820. */
  78821. export interface IGLTFLoaderExtension {
  78822. /**
  78823. * The name of this extension.
  78824. */
  78825. readonly name: string;
  78826. /**
  78827. * Defines whether this extension is enabled.
  78828. */
  78829. enabled: boolean;
  78830. /**
  78831. * Defines the order of this extension.
  78832. * The loader sorts the extensions using these values when loading.
  78833. */
  78834. order?: number;
  78835. }
  78836. /**
  78837. * Loader state.
  78838. */
  78839. export enum GLTFLoaderState {
  78840. /**
  78841. * The asset is loading.
  78842. */
  78843. LOADING = 0,
  78844. /**
  78845. * The asset is ready for rendering.
  78846. */
  78847. READY = 1,
  78848. /**
  78849. * The asset is completely loaded.
  78850. */
  78851. COMPLETE = 2
  78852. }
  78853. /** @hidden */
  78854. export interface IImportMeshAsyncOutput {
  78855. meshes: AbstractMesh[];
  78856. particleSystems: IParticleSystem[];
  78857. skeletons: Skeleton[];
  78858. animationGroups: AnimationGroup[];
  78859. lights: Light[];
  78860. transformNodes: TransformNode[];
  78861. }
  78862. /** @hidden */
  78863. export interface IGLTFLoader extends IDisposable {
  78864. readonly state: Nullable<GLTFLoaderState>;
  78865. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78866. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78867. }
  78868. /**
  78869. * File loader for loading glTF files into a scene.
  78870. */
  78871. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78872. /** @hidden */
  78873. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78874. /** @hidden */
  78875. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78876. /**
  78877. * Raised when the asset has been parsed
  78878. */
  78879. onParsedObservable: Observable<IGLTFLoaderData>;
  78880. private _onParsedObserver;
  78881. /**
  78882. * Raised when the asset has been parsed
  78883. */
  78884. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78885. /**
  78886. * 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.
  78887. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78888. * Defaults to true.
  78889. * @hidden
  78890. */
  78891. static IncrementalLoading: boolean;
  78892. /**
  78893. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78894. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78895. * @hidden
  78896. */
  78897. static HomogeneousCoordinates: boolean;
  78898. /**
  78899. * The coordinate system mode. Defaults to AUTO.
  78900. */
  78901. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78902. /**
  78903. * The animation start mode. Defaults to FIRST.
  78904. */
  78905. animationStartMode: GLTFLoaderAnimationStartMode;
  78906. /**
  78907. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78908. */
  78909. compileMaterials: boolean;
  78910. /**
  78911. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78912. */
  78913. useClipPlane: boolean;
  78914. /**
  78915. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78916. */
  78917. compileShadowGenerators: boolean;
  78918. /**
  78919. * Defines if the Alpha blended materials are only applied as coverage.
  78920. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78921. * If true, no extra effects are applied to transparent pixels.
  78922. */
  78923. transparencyAsCoverage: boolean;
  78924. /**
  78925. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78926. * Enabling will disable offline support and glTF validator.
  78927. * Defaults to false.
  78928. */
  78929. useRangeRequests: boolean;
  78930. /**
  78931. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78932. */
  78933. createInstances: boolean;
  78934. /**
  78935. * 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.
  78936. */
  78937. alwaysComputeBoundingBox: boolean;
  78938. /**
  78939. * Function called before loading a url referenced by the asset.
  78940. */
  78941. preprocessUrlAsync: (url: string) => Promise<string>;
  78942. /**
  78943. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78944. */
  78945. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78946. private _onMeshLoadedObserver;
  78947. /**
  78948. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78949. */
  78950. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78951. /**
  78952. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78953. */
  78954. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78955. private _onTextureLoadedObserver;
  78956. /**
  78957. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78958. */
  78959. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78960. /**
  78961. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78962. */
  78963. readonly onMaterialLoadedObservable: Observable<Material>;
  78964. private _onMaterialLoadedObserver;
  78965. /**
  78966. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78967. */
  78968. set onMaterialLoaded(callback: (material: Material) => void);
  78969. /**
  78970. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78971. */
  78972. readonly onCameraLoadedObservable: Observable<Camera>;
  78973. private _onCameraLoadedObserver;
  78974. /**
  78975. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78976. */
  78977. set onCameraLoaded(callback: (camera: Camera) => void);
  78978. /**
  78979. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78980. * For assets with LODs, raised when all of the LODs are complete.
  78981. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78982. */
  78983. readonly onCompleteObservable: Observable<void>;
  78984. private _onCompleteObserver;
  78985. /**
  78986. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78987. * For assets with LODs, raised when all of the LODs are complete.
  78988. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78989. */
  78990. set onComplete(callback: () => void);
  78991. /**
  78992. * Observable raised when an error occurs.
  78993. */
  78994. readonly onErrorObservable: Observable<any>;
  78995. private _onErrorObserver;
  78996. /**
  78997. * Callback raised when an error occurs.
  78998. */
  78999. set onError(callback: (reason: any) => void);
  79000. /**
  79001. * Observable raised after the loader is disposed.
  79002. */
  79003. readonly onDisposeObservable: Observable<void>;
  79004. private _onDisposeObserver;
  79005. /**
  79006. * Callback raised after the loader is disposed.
  79007. */
  79008. set onDispose(callback: () => void);
  79009. /**
  79010. * Observable raised after a loader extension is created.
  79011. * Set additional options for a loader extension in this event.
  79012. */
  79013. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79014. private _onExtensionLoadedObserver;
  79015. /**
  79016. * Callback raised after a loader extension is created.
  79017. */
  79018. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79019. /**
  79020. * Defines if the loader logging is enabled.
  79021. */
  79022. get loggingEnabled(): boolean;
  79023. set loggingEnabled(value: boolean);
  79024. /**
  79025. * Defines if the loader should capture performance counters.
  79026. */
  79027. get capturePerformanceCounters(): boolean;
  79028. set capturePerformanceCounters(value: boolean);
  79029. /**
  79030. * Defines if the loader should validate the asset.
  79031. */
  79032. validate: boolean;
  79033. /**
  79034. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79035. */
  79036. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79037. private _onValidatedObserver;
  79038. /**
  79039. * Callback raised after a loader extension is created.
  79040. */
  79041. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79042. private _loader;
  79043. private _progressCallback?;
  79044. private _requests;
  79045. private static magicBase64Encoded;
  79046. /**
  79047. * Name of the loader ("gltf")
  79048. */
  79049. name: string;
  79050. /** @hidden */
  79051. extensions: ISceneLoaderPluginExtensions;
  79052. /**
  79053. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79054. */
  79055. dispose(): void;
  79056. /** @hidden */
  79057. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79058. /** @hidden */
  79059. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79060. /** @hidden */
  79061. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79062. meshes: AbstractMesh[];
  79063. particleSystems: IParticleSystem[];
  79064. skeletons: Skeleton[];
  79065. animationGroups: AnimationGroup[];
  79066. }>;
  79067. /** @hidden */
  79068. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79069. /** @hidden */
  79070. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79071. /** @hidden */
  79072. canDirectLoad(data: string): boolean;
  79073. /** @hidden */
  79074. directLoad(scene: Scene, data: string): Promise<any>;
  79075. /**
  79076. * The callback that allows custom handling of the root url based on the response url.
  79077. * @param rootUrl the original root url
  79078. * @param responseURL the response url if available
  79079. * @returns the new root url
  79080. */
  79081. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79082. /** @hidden */
  79083. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79084. /**
  79085. * The loader state or null if the loader is not active.
  79086. */
  79087. get loaderState(): Nullable<GLTFLoaderState>;
  79088. /**
  79089. * Returns a promise that resolves when the asset is completely loaded.
  79090. * @returns a promise that resolves when the asset is completely loaded.
  79091. */
  79092. whenCompleteAsync(): Promise<void>;
  79093. /** @hidden */
  79094. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79095. /** @hidden */
  79096. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79097. private _onProgress;
  79098. private _validate;
  79099. private _getLoader;
  79100. private _parseJson;
  79101. private _unpackBinaryAsync;
  79102. private _unpackBinaryV1Async;
  79103. private _unpackBinaryV2Async;
  79104. private static _parseVersion;
  79105. private static _compareVersion;
  79106. private static readonly _logSpaces;
  79107. private _logIndentLevel;
  79108. private _loggingEnabled;
  79109. /** @hidden */
  79110. _log: (message: string) => void;
  79111. /** @hidden */
  79112. _logOpen(message: string): void;
  79113. /** @hidden */
  79114. _logClose(): void;
  79115. private _logEnabled;
  79116. private _logDisabled;
  79117. private _capturePerformanceCounters;
  79118. /** @hidden */
  79119. _startPerformanceCounter: (counterName: string) => void;
  79120. /** @hidden */
  79121. _endPerformanceCounter: (counterName: string) => void;
  79122. private _startPerformanceCounterEnabled;
  79123. private _startPerformanceCounterDisabled;
  79124. private _endPerformanceCounterEnabled;
  79125. private _endPerformanceCounterDisabled;
  79126. }
  79127. }
  79128. declare module BABYLON.GLTF1 {
  79129. /**
  79130. * Enums
  79131. * @hidden
  79132. */
  79133. export enum EComponentType {
  79134. BYTE = 5120,
  79135. UNSIGNED_BYTE = 5121,
  79136. SHORT = 5122,
  79137. UNSIGNED_SHORT = 5123,
  79138. FLOAT = 5126
  79139. }
  79140. /** @hidden */
  79141. export enum EShaderType {
  79142. FRAGMENT = 35632,
  79143. VERTEX = 35633
  79144. }
  79145. /** @hidden */
  79146. export enum EParameterType {
  79147. BYTE = 5120,
  79148. UNSIGNED_BYTE = 5121,
  79149. SHORT = 5122,
  79150. UNSIGNED_SHORT = 5123,
  79151. INT = 5124,
  79152. UNSIGNED_INT = 5125,
  79153. FLOAT = 5126,
  79154. FLOAT_VEC2 = 35664,
  79155. FLOAT_VEC3 = 35665,
  79156. FLOAT_VEC4 = 35666,
  79157. INT_VEC2 = 35667,
  79158. INT_VEC3 = 35668,
  79159. INT_VEC4 = 35669,
  79160. BOOL = 35670,
  79161. BOOL_VEC2 = 35671,
  79162. BOOL_VEC3 = 35672,
  79163. BOOL_VEC4 = 35673,
  79164. FLOAT_MAT2 = 35674,
  79165. FLOAT_MAT3 = 35675,
  79166. FLOAT_MAT4 = 35676,
  79167. SAMPLER_2D = 35678
  79168. }
  79169. /** @hidden */
  79170. export enum ETextureWrapMode {
  79171. CLAMP_TO_EDGE = 33071,
  79172. MIRRORED_REPEAT = 33648,
  79173. REPEAT = 10497
  79174. }
  79175. /** @hidden */
  79176. export enum ETextureFilterType {
  79177. NEAREST = 9728,
  79178. LINEAR = 9728,
  79179. NEAREST_MIPMAP_NEAREST = 9984,
  79180. LINEAR_MIPMAP_NEAREST = 9985,
  79181. NEAREST_MIPMAP_LINEAR = 9986,
  79182. LINEAR_MIPMAP_LINEAR = 9987
  79183. }
  79184. /** @hidden */
  79185. export enum ETextureFormat {
  79186. ALPHA = 6406,
  79187. RGB = 6407,
  79188. RGBA = 6408,
  79189. LUMINANCE = 6409,
  79190. LUMINANCE_ALPHA = 6410
  79191. }
  79192. /** @hidden */
  79193. export enum ECullingType {
  79194. FRONT = 1028,
  79195. BACK = 1029,
  79196. FRONT_AND_BACK = 1032
  79197. }
  79198. /** @hidden */
  79199. export enum EBlendingFunction {
  79200. ZERO = 0,
  79201. ONE = 1,
  79202. SRC_COLOR = 768,
  79203. ONE_MINUS_SRC_COLOR = 769,
  79204. DST_COLOR = 774,
  79205. ONE_MINUS_DST_COLOR = 775,
  79206. SRC_ALPHA = 770,
  79207. ONE_MINUS_SRC_ALPHA = 771,
  79208. DST_ALPHA = 772,
  79209. ONE_MINUS_DST_ALPHA = 773,
  79210. CONSTANT_COLOR = 32769,
  79211. ONE_MINUS_CONSTANT_COLOR = 32770,
  79212. CONSTANT_ALPHA = 32771,
  79213. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79214. SRC_ALPHA_SATURATE = 776
  79215. }
  79216. /** @hidden */
  79217. export interface IGLTFProperty {
  79218. extensions?: {
  79219. [key: string]: any;
  79220. };
  79221. extras?: Object;
  79222. }
  79223. /** @hidden */
  79224. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79225. name?: string;
  79226. }
  79227. /** @hidden */
  79228. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79229. bufferView: string;
  79230. byteOffset: number;
  79231. byteStride: number;
  79232. count: number;
  79233. type: string;
  79234. componentType: EComponentType;
  79235. max?: number[];
  79236. min?: number[];
  79237. name?: string;
  79238. }
  79239. /** @hidden */
  79240. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79241. buffer: string;
  79242. byteOffset: number;
  79243. byteLength: number;
  79244. byteStride: number;
  79245. target?: number;
  79246. }
  79247. /** @hidden */
  79248. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79249. uri: string;
  79250. byteLength?: number;
  79251. type?: string;
  79252. }
  79253. /** @hidden */
  79254. export interface IGLTFShader extends IGLTFChildRootProperty {
  79255. uri: string;
  79256. type: EShaderType;
  79257. }
  79258. /** @hidden */
  79259. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79260. attributes: string[];
  79261. fragmentShader: string;
  79262. vertexShader: string;
  79263. }
  79264. /** @hidden */
  79265. export interface IGLTFTechniqueParameter {
  79266. type: number;
  79267. count?: number;
  79268. semantic?: string;
  79269. node?: string;
  79270. value?: number | boolean | string | Array<any>;
  79271. source?: string;
  79272. babylonValue?: any;
  79273. }
  79274. /** @hidden */
  79275. export interface IGLTFTechniqueCommonProfile {
  79276. lightingModel: string;
  79277. texcoordBindings: Object;
  79278. parameters?: Array<any>;
  79279. }
  79280. /** @hidden */
  79281. export interface IGLTFTechniqueStatesFunctions {
  79282. blendColor?: number[];
  79283. blendEquationSeparate?: number[];
  79284. blendFuncSeparate?: number[];
  79285. colorMask: boolean[];
  79286. cullFace: number[];
  79287. }
  79288. /** @hidden */
  79289. export interface IGLTFTechniqueStates {
  79290. enable: number[];
  79291. functions: IGLTFTechniqueStatesFunctions;
  79292. }
  79293. /** @hidden */
  79294. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79295. parameters: {
  79296. [key: string]: IGLTFTechniqueParameter;
  79297. };
  79298. program: string;
  79299. attributes: {
  79300. [key: string]: string;
  79301. };
  79302. uniforms: {
  79303. [key: string]: string;
  79304. };
  79305. states: IGLTFTechniqueStates;
  79306. }
  79307. /** @hidden */
  79308. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79309. technique?: string;
  79310. values: string[];
  79311. }
  79312. /** @hidden */
  79313. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79314. attributes: {
  79315. [key: string]: string;
  79316. };
  79317. indices: string;
  79318. material: string;
  79319. mode?: number;
  79320. }
  79321. /** @hidden */
  79322. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79323. primitives: IGLTFMeshPrimitive[];
  79324. }
  79325. /** @hidden */
  79326. export interface IGLTFImage extends IGLTFChildRootProperty {
  79327. uri: string;
  79328. }
  79329. /** @hidden */
  79330. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79331. magFilter?: number;
  79332. minFilter?: number;
  79333. wrapS?: number;
  79334. wrapT?: number;
  79335. }
  79336. /** @hidden */
  79337. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79338. sampler: string;
  79339. source: string;
  79340. format?: ETextureFormat;
  79341. internalFormat?: ETextureFormat;
  79342. target?: number;
  79343. type?: number;
  79344. babylonTexture?: Texture;
  79345. }
  79346. /** @hidden */
  79347. export interface IGLTFAmbienLight {
  79348. color?: number[];
  79349. }
  79350. /** @hidden */
  79351. export interface IGLTFDirectionalLight {
  79352. color?: number[];
  79353. }
  79354. /** @hidden */
  79355. export interface IGLTFPointLight {
  79356. color?: number[];
  79357. constantAttenuation?: number;
  79358. linearAttenuation?: number;
  79359. quadraticAttenuation?: number;
  79360. }
  79361. /** @hidden */
  79362. export interface IGLTFSpotLight {
  79363. color?: number[];
  79364. constantAttenuation?: number;
  79365. fallOfAngle?: number;
  79366. fallOffExponent?: number;
  79367. linearAttenuation?: number;
  79368. quadraticAttenuation?: number;
  79369. }
  79370. /** @hidden */
  79371. export interface IGLTFLight extends IGLTFChildRootProperty {
  79372. type: string;
  79373. }
  79374. /** @hidden */
  79375. export interface IGLTFCameraOrthographic {
  79376. xmag: number;
  79377. ymag: number;
  79378. zfar: number;
  79379. znear: number;
  79380. }
  79381. /** @hidden */
  79382. export interface IGLTFCameraPerspective {
  79383. aspectRatio: number;
  79384. yfov: number;
  79385. zfar: number;
  79386. znear: number;
  79387. }
  79388. /** @hidden */
  79389. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79390. type: string;
  79391. }
  79392. /** @hidden */
  79393. export interface IGLTFAnimationChannelTarget {
  79394. id: string;
  79395. path: string;
  79396. }
  79397. /** @hidden */
  79398. export interface IGLTFAnimationChannel {
  79399. sampler: string;
  79400. target: IGLTFAnimationChannelTarget;
  79401. }
  79402. /** @hidden */
  79403. export interface IGLTFAnimationSampler {
  79404. input: string;
  79405. output: string;
  79406. interpolation?: string;
  79407. }
  79408. /** @hidden */
  79409. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79410. channels?: IGLTFAnimationChannel[];
  79411. parameters?: {
  79412. [key: string]: string;
  79413. };
  79414. samplers?: {
  79415. [key: string]: IGLTFAnimationSampler;
  79416. };
  79417. }
  79418. /** @hidden */
  79419. export interface IGLTFNodeInstanceSkin {
  79420. skeletons: string[];
  79421. skin: string;
  79422. meshes: string[];
  79423. }
  79424. /** @hidden */
  79425. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79426. bindShapeMatrix: number[];
  79427. inverseBindMatrices: string;
  79428. jointNames: string[];
  79429. babylonSkeleton?: Skeleton;
  79430. }
  79431. /** @hidden */
  79432. export interface IGLTFNode extends IGLTFChildRootProperty {
  79433. camera?: string;
  79434. children: string[];
  79435. skin?: string;
  79436. jointName?: string;
  79437. light?: string;
  79438. matrix: number[];
  79439. mesh?: string;
  79440. meshes?: string[];
  79441. rotation?: number[];
  79442. scale?: number[];
  79443. translation?: number[];
  79444. babylonNode?: Node;
  79445. }
  79446. /** @hidden */
  79447. export interface IGLTFScene extends IGLTFChildRootProperty {
  79448. nodes: string[];
  79449. }
  79450. /** @hidden */
  79451. export interface IGLTFRuntime {
  79452. extensions: {
  79453. [key: string]: any;
  79454. };
  79455. accessors: {
  79456. [key: string]: IGLTFAccessor;
  79457. };
  79458. buffers: {
  79459. [key: string]: IGLTFBuffer;
  79460. };
  79461. bufferViews: {
  79462. [key: string]: IGLTFBufferView;
  79463. };
  79464. meshes: {
  79465. [key: string]: IGLTFMesh;
  79466. };
  79467. lights: {
  79468. [key: string]: IGLTFLight;
  79469. };
  79470. cameras: {
  79471. [key: string]: IGLTFCamera;
  79472. };
  79473. nodes: {
  79474. [key: string]: IGLTFNode;
  79475. };
  79476. images: {
  79477. [key: string]: IGLTFImage;
  79478. };
  79479. textures: {
  79480. [key: string]: IGLTFTexture;
  79481. };
  79482. shaders: {
  79483. [key: string]: IGLTFShader;
  79484. };
  79485. programs: {
  79486. [key: string]: IGLTFProgram;
  79487. };
  79488. samplers: {
  79489. [key: string]: IGLTFSampler;
  79490. };
  79491. techniques: {
  79492. [key: string]: IGLTFTechnique;
  79493. };
  79494. materials: {
  79495. [key: string]: IGLTFMaterial;
  79496. };
  79497. animations: {
  79498. [key: string]: IGLTFAnimation;
  79499. };
  79500. skins: {
  79501. [key: string]: IGLTFSkins;
  79502. };
  79503. currentScene?: Object;
  79504. scenes: {
  79505. [key: string]: IGLTFScene;
  79506. };
  79507. extensionsUsed: string[];
  79508. extensionsRequired?: string[];
  79509. buffersCount: number;
  79510. shaderscount: number;
  79511. scene: Scene;
  79512. rootUrl: string;
  79513. loadedBufferCount: number;
  79514. loadedBufferViews: {
  79515. [name: string]: ArrayBufferView;
  79516. };
  79517. loadedShaderCount: number;
  79518. importOnlyMeshes: boolean;
  79519. importMeshesNames?: string[];
  79520. dummyNodes: Node[];
  79521. forAssetContainer: boolean;
  79522. }
  79523. /** @hidden */
  79524. export interface INodeToRoot {
  79525. bone: Bone;
  79526. node: IGLTFNode;
  79527. id: string;
  79528. }
  79529. /** @hidden */
  79530. export interface IJointNode {
  79531. node: IGLTFNode;
  79532. id: string;
  79533. }
  79534. }
  79535. declare module BABYLON.GLTF1 {
  79536. /**
  79537. * Utils functions for GLTF
  79538. * @hidden
  79539. */
  79540. export class GLTFUtils {
  79541. /**
  79542. * Sets the given "parameter" matrix
  79543. * @param scene: the Scene object
  79544. * @param source: the source node where to pick the matrix
  79545. * @param parameter: the GLTF technique parameter
  79546. * @param uniformName: the name of the shader's uniform
  79547. * @param shaderMaterial: the shader material
  79548. */
  79549. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79550. /**
  79551. * Sets the given "parameter" matrix
  79552. * @param shaderMaterial: the shader material
  79553. * @param uniform: the name of the shader's uniform
  79554. * @param value: the value of the uniform
  79555. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79556. */
  79557. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79558. /**
  79559. * Returns the wrap mode of the texture
  79560. * @param mode: the mode value
  79561. */
  79562. static GetWrapMode(mode: number): number;
  79563. /**
  79564. * Returns the byte stride giving an accessor
  79565. * @param accessor: the GLTF accessor objet
  79566. */
  79567. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79568. /**
  79569. * Returns the texture filter mode giving a mode value
  79570. * @param mode: the filter mode value
  79571. */
  79572. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79573. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79574. /**
  79575. * Returns a buffer from its accessor
  79576. * @param gltfRuntime: the GLTF runtime
  79577. * @param accessor: the GLTF accessor
  79578. */
  79579. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79580. /**
  79581. * Decodes a buffer view into a string
  79582. * @param view: the buffer view
  79583. */
  79584. static DecodeBufferToText(view: ArrayBufferView): string;
  79585. /**
  79586. * Returns the default material of gltf. Related to
  79587. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79588. * @param scene: the Babylon.js scene
  79589. */
  79590. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79591. private static _DefaultMaterial;
  79592. }
  79593. }
  79594. declare module BABYLON.GLTF1 {
  79595. /**
  79596. * Implementation of the base glTF spec
  79597. * @hidden
  79598. */
  79599. export class GLTFLoaderBase {
  79600. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79601. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79602. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79603. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79604. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79605. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79606. }
  79607. /**
  79608. * glTF V1 Loader
  79609. * @hidden
  79610. */
  79611. export class GLTFLoader implements IGLTFLoader {
  79612. static Extensions: {
  79613. [name: string]: GLTFLoaderExtension;
  79614. };
  79615. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79616. state: Nullable<GLTFLoaderState>;
  79617. dispose(): void;
  79618. private _importMeshAsync;
  79619. /**
  79620. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79621. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79622. * @param scene the scene the meshes should be added to
  79623. * @param forAssetContainer defines if the entities must be stored in the scene
  79624. * @param data gltf data containing information of the meshes in a loaded file
  79625. * @param rootUrl root url to load from
  79626. * @param onProgress event that fires when loading progress has occured
  79627. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79628. */
  79629. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79630. private _loadAsync;
  79631. /**
  79632. * Imports all objects from a loaded gltf file and adds them to the scene
  79633. * @param scene the scene the objects should be added to
  79634. * @param data gltf data containing information of the meshes in a loaded file
  79635. * @param rootUrl root url to load from
  79636. * @param onProgress event that fires when loading progress has occured
  79637. * @returns a promise which completes when objects have been loaded to the scene
  79638. */
  79639. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79640. private _loadShadersAsync;
  79641. private _loadBuffersAsync;
  79642. private _createNodes;
  79643. }
  79644. /** @hidden */
  79645. export abstract class GLTFLoaderExtension {
  79646. private _name;
  79647. constructor(name: string);
  79648. get name(): string;
  79649. /**
  79650. * Defines an override for loading the runtime
  79651. * Return true to stop further extensions from loading the runtime
  79652. */
  79653. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79654. /**
  79655. * Defines an onverride for creating gltf runtime
  79656. * Return true to stop further extensions from creating the runtime
  79657. */
  79658. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79659. /**
  79660. * Defines an override for loading buffers
  79661. * Return true to stop further extensions from loading this buffer
  79662. */
  79663. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79664. /**
  79665. * Defines an override for loading texture buffers
  79666. * Return true to stop further extensions from loading this texture data
  79667. */
  79668. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79669. /**
  79670. * Defines an override for creating textures
  79671. * Return true to stop further extensions from loading this texture
  79672. */
  79673. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79674. /**
  79675. * Defines an override for loading shader strings
  79676. * Return true to stop further extensions from loading this shader data
  79677. */
  79678. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79679. /**
  79680. * Defines an override for loading materials
  79681. * Return true to stop further extensions from loading this material
  79682. */
  79683. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79684. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79685. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79686. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79687. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79688. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79689. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79690. private static LoadTextureBufferAsync;
  79691. private static CreateTextureAsync;
  79692. private static ApplyExtensions;
  79693. }
  79694. }
  79695. declare module BABYLON.GLTF1 {
  79696. /** @hidden */
  79697. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79698. private _bin;
  79699. constructor();
  79700. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79701. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79702. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79703. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79704. }
  79705. }
  79706. declare module BABYLON.GLTF1 {
  79707. /** @hidden */
  79708. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79709. constructor();
  79710. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79711. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79712. private _loadTexture;
  79713. }
  79714. }
  79715. declare module BABYLON.GLTF2.Loader {
  79716. /**
  79717. * Loader interface with an index field.
  79718. */
  79719. export interface IArrayItem {
  79720. /**
  79721. * The index of this item in the array.
  79722. */
  79723. index: number;
  79724. }
  79725. /**
  79726. * Loader interface with additional members.
  79727. */
  79728. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79729. /** @hidden */
  79730. _data?: Promise<ArrayBufferView>;
  79731. /** @hidden */
  79732. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79733. }
  79734. /**
  79735. * Loader interface with additional members.
  79736. */
  79737. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79738. }
  79739. /** @hidden */
  79740. export interface _IAnimationSamplerData {
  79741. input: Float32Array;
  79742. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79743. output: Float32Array;
  79744. }
  79745. /**
  79746. * Loader interface with additional members.
  79747. */
  79748. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79749. /** @hidden */
  79750. _data?: Promise<_IAnimationSamplerData>;
  79751. }
  79752. /**
  79753. * Loader interface with additional members.
  79754. */
  79755. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79756. channels: IAnimationChannel[];
  79757. samplers: IAnimationSampler[];
  79758. /** @hidden */
  79759. _babylonAnimationGroup?: AnimationGroup;
  79760. }
  79761. /**
  79762. * Loader interface with additional members.
  79763. */
  79764. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79765. /** @hidden */
  79766. _data?: Promise<ArrayBufferView>;
  79767. }
  79768. /**
  79769. * Loader interface with additional members.
  79770. */
  79771. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79772. /** @hidden */
  79773. _data?: Promise<ArrayBufferView>;
  79774. /** @hidden */
  79775. _babylonBuffer?: Promise<Buffer>;
  79776. }
  79777. /**
  79778. * Loader interface with additional members.
  79779. */
  79780. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79781. }
  79782. /**
  79783. * Loader interface with additional members.
  79784. */
  79785. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79786. /** @hidden */
  79787. _data?: Promise<ArrayBufferView>;
  79788. }
  79789. /**
  79790. * Loader interface with additional members.
  79791. */
  79792. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79793. }
  79794. /**
  79795. * Loader interface with additional members.
  79796. */
  79797. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79798. }
  79799. /**
  79800. * Loader interface with additional members.
  79801. */
  79802. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79803. baseColorTexture?: ITextureInfo;
  79804. metallicRoughnessTexture?: ITextureInfo;
  79805. }
  79806. /**
  79807. * Loader interface with additional members.
  79808. */
  79809. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79810. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79811. normalTexture?: IMaterialNormalTextureInfo;
  79812. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79813. emissiveTexture?: ITextureInfo;
  79814. /** @hidden */
  79815. _data?: {
  79816. [babylonDrawMode: number]: {
  79817. babylonMaterial: Material;
  79818. babylonMeshes: AbstractMesh[];
  79819. promise: Promise<void>;
  79820. };
  79821. };
  79822. }
  79823. /**
  79824. * Loader interface with additional members.
  79825. */
  79826. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79827. primitives: IMeshPrimitive[];
  79828. }
  79829. /**
  79830. * Loader interface with additional members.
  79831. */
  79832. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79833. /** @hidden */
  79834. _instanceData?: {
  79835. babylonSourceMesh: Mesh;
  79836. promise: Promise<any>;
  79837. };
  79838. }
  79839. /**
  79840. * Loader interface with additional members.
  79841. */
  79842. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79843. /**
  79844. * The parent glTF node.
  79845. */
  79846. parent?: INode;
  79847. /** @hidden */
  79848. _babylonTransformNode?: TransformNode;
  79849. /** @hidden */
  79850. _primitiveBabylonMeshes?: AbstractMesh[];
  79851. /** @hidden */
  79852. _babylonBones?: Bone[];
  79853. /** @hidden */
  79854. _numMorphTargets?: number;
  79855. }
  79856. /** @hidden */
  79857. export interface _ISamplerData {
  79858. noMipMaps: boolean;
  79859. samplingMode: number;
  79860. wrapU: number;
  79861. wrapV: number;
  79862. }
  79863. /**
  79864. * Loader interface with additional members.
  79865. */
  79866. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79867. /** @hidden */
  79868. _data?: _ISamplerData;
  79869. }
  79870. /**
  79871. * Loader interface with additional members.
  79872. */
  79873. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79874. }
  79875. /**
  79876. * Loader interface with additional members.
  79877. */
  79878. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79879. /** @hidden */
  79880. _data?: {
  79881. babylonSkeleton: Skeleton;
  79882. promise: Promise<void>;
  79883. };
  79884. }
  79885. /**
  79886. * Loader interface with additional members.
  79887. */
  79888. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79889. }
  79890. /**
  79891. * Loader interface with additional members.
  79892. */
  79893. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79894. }
  79895. /**
  79896. * Loader interface with additional members.
  79897. */
  79898. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79899. accessors?: IAccessor[];
  79900. animations?: IAnimation[];
  79901. buffers?: IBuffer[];
  79902. bufferViews?: IBufferView[];
  79903. cameras?: ICamera[];
  79904. images?: IImage[];
  79905. materials?: IMaterial[];
  79906. meshes?: IMesh[];
  79907. nodes?: INode[];
  79908. samplers?: ISampler[];
  79909. scenes?: IScene[];
  79910. skins?: ISkin[];
  79911. textures?: ITexture[];
  79912. }
  79913. }
  79914. declare module BABYLON.GLTF2 {
  79915. /**
  79916. * Interface for a glTF loader extension.
  79917. */
  79918. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79919. /**
  79920. * Called after the loader state changes to LOADING.
  79921. */
  79922. onLoading?(): void;
  79923. /**
  79924. * Called after the loader state changes to READY.
  79925. */
  79926. onReady?(): void;
  79927. /**
  79928. * Define this method to modify the default behavior when loading scenes.
  79929. * @param context The context when loading the asset
  79930. * @param scene The glTF scene property
  79931. * @returns A promise that resolves when the load is complete or null if not handled
  79932. */
  79933. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79934. /**
  79935. * Define this method to modify the default behavior when loading nodes.
  79936. * @param context The context when loading the asset
  79937. * @param node The glTF node property
  79938. * @param assign A function called synchronously after parsing the glTF properties
  79939. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79940. */
  79941. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79942. /**
  79943. * Define this method to modify the default behavior when loading cameras.
  79944. * @param context The context when loading the asset
  79945. * @param camera The glTF camera property
  79946. * @param assign A function called synchronously after parsing the glTF properties
  79947. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79948. */
  79949. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79950. /**
  79951. * @hidden
  79952. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79953. * @param context The context when loading the asset
  79954. * @param primitive The glTF mesh primitive property
  79955. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79956. */
  79957. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79958. /**
  79959. * @hidden
  79960. * Define this method to modify the default behavior when loading data for mesh primitives.
  79961. * @param context The context when loading the asset
  79962. * @param name The mesh name when loading the asset
  79963. * @param node The glTF node when loading the asset
  79964. * @param mesh The glTF mesh when loading the asset
  79965. * @param primitive The glTF mesh primitive property
  79966. * @param assign A function called synchronously after parsing the glTF properties
  79967. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79968. */
  79969. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79970. /**
  79971. * @hidden
  79972. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79973. * @param context The context when loading the asset
  79974. * @param material The glTF material property
  79975. * @param assign A function called synchronously after parsing the glTF properties
  79976. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79977. */
  79978. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79979. /**
  79980. * Define this method to modify the default behavior when creating materials.
  79981. * @param context The context when loading the asset
  79982. * @param material The glTF material property
  79983. * @param babylonDrawMode The draw mode for the Babylon material
  79984. * @returns The Babylon material or null if not handled
  79985. */
  79986. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79987. /**
  79988. * Define this method to modify the default behavior when loading material properties.
  79989. * @param context The context when loading the asset
  79990. * @param material The glTF material property
  79991. * @param babylonMaterial The Babylon material
  79992. * @returns A promise that resolves when the load is complete or null if not handled
  79993. */
  79994. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79995. /**
  79996. * Define this method to modify the default behavior when loading texture infos.
  79997. * @param context The context when loading the asset
  79998. * @param textureInfo The glTF texture info property
  79999. * @param assign A function called synchronously after parsing the glTF properties
  80000. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80001. */
  80002. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80003. /**
  80004. * @hidden
  80005. * Define this method to modify the default behavior when loading textures.
  80006. * @param context The context when loading the asset
  80007. * @param texture The glTF texture property
  80008. * @param assign A function called synchronously after parsing the glTF properties
  80009. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80010. */
  80011. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80012. /**
  80013. * Define this method to modify the default behavior when loading animations.
  80014. * @param context The context when loading the asset
  80015. * @param animation The glTF animation property
  80016. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80017. */
  80018. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80019. /**
  80020. * @hidden
  80021. * Define this method to modify the default behavior when loading skins.
  80022. * @param context The context when loading the asset
  80023. * @param node The glTF node property
  80024. * @param skin The glTF skin property
  80025. * @returns A promise that resolves when the load is complete or null if not handled
  80026. */
  80027. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80028. /**
  80029. * @hidden
  80030. * Define this method to modify the default behavior when loading uris.
  80031. * @param context The context when loading the asset
  80032. * @param property The glTF property associated with the uri
  80033. * @param uri The uri to load
  80034. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80035. */
  80036. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80037. /**
  80038. * Define this method to modify the default behavior when loading buffer views.
  80039. * @param context The context when loading the asset
  80040. * @param bufferView The glTF buffer view property
  80041. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80042. */
  80043. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80044. /**
  80045. * Define this method to modify the default behavior when loading buffers.
  80046. * @param context The context when loading the asset
  80047. * @param buffer The glTF buffer property
  80048. * @param byteOffset The byte offset to load
  80049. * @param byteLength The byte length to load
  80050. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80051. */
  80052. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80053. }
  80054. }
  80055. declare module BABYLON.GLTF2 {
  80056. /**
  80057. * Helper class for working with arrays when loading the glTF asset
  80058. */
  80059. export class ArrayItem {
  80060. /**
  80061. * Gets an item from the given array.
  80062. * @param context The context when loading the asset
  80063. * @param array The array to get the item from
  80064. * @param index The index to the array
  80065. * @returns The array item
  80066. */
  80067. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80068. /**
  80069. * Assign an `index` field to each item of the given array.
  80070. * @param array The array of items
  80071. */
  80072. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80073. }
  80074. /**
  80075. * The glTF 2.0 loader
  80076. */
  80077. export class GLTFLoader implements IGLTFLoader {
  80078. /** @hidden */
  80079. _completePromises: Promise<any>[];
  80080. /** @hidden */
  80081. _forAssetContainer: boolean;
  80082. /** Storage */
  80083. _babylonLights: Light[];
  80084. /** @hidden */
  80085. _disableInstancedMesh: number;
  80086. private _disposed;
  80087. private _parent;
  80088. private _state;
  80089. private _extensions;
  80090. private _rootUrl;
  80091. private _fileName;
  80092. private _uniqueRootUrl;
  80093. private _gltf;
  80094. private _bin;
  80095. private _babylonScene;
  80096. private _rootBabylonMesh;
  80097. private _defaultBabylonMaterialData;
  80098. private static _RegisteredExtensions;
  80099. /**
  80100. * The default glTF sampler.
  80101. */
  80102. static readonly DefaultSampler: ISampler;
  80103. /**
  80104. * Registers a loader extension.
  80105. * @param name The name of the loader extension.
  80106. * @param factory The factory function that creates the loader extension.
  80107. */
  80108. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80109. /**
  80110. * Unregisters a loader extension.
  80111. * @param name The name of the loader extension.
  80112. * @returns A boolean indicating whether the extension has been unregistered
  80113. */
  80114. static UnregisterExtension(name: string): boolean;
  80115. /**
  80116. * The loader state.
  80117. */
  80118. get state(): Nullable<GLTFLoaderState>;
  80119. /**
  80120. * The object that represents the glTF JSON.
  80121. */
  80122. get gltf(): IGLTF;
  80123. /**
  80124. * The BIN chunk of a binary glTF.
  80125. */
  80126. get bin(): Nullable<IDataBuffer>;
  80127. /**
  80128. * The parent file loader.
  80129. */
  80130. get parent(): GLTFFileLoader;
  80131. /**
  80132. * The Babylon scene when loading the asset.
  80133. */
  80134. get babylonScene(): Scene;
  80135. /**
  80136. * The root Babylon mesh when loading the asset.
  80137. */
  80138. get rootBabylonMesh(): Mesh;
  80139. /** @hidden */
  80140. constructor(parent: GLTFFileLoader);
  80141. /** @hidden */
  80142. dispose(): void;
  80143. /** @hidden */
  80144. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80145. /** @hidden */
  80146. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80147. private _loadAsync;
  80148. private _loadData;
  80149. private _setupData;
  80150. private _loadExtensions;
  80151. private _checkExtensions;
  80152. private _setState;
  80153. private _createRootNode;
  80154. /**
  80155. * Loads a glTF scene.
  80156. * @param context The context when loading the asset
  80157. * @param scene The glTF scene property
  80158. * @returns A promise that resolves when the load is complete
  80159. */
  80160. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80161. private _forEachPrimitive;
  80162. private _getMeshes;
  80163. private _getTransformNodes;
  80164. private _getSkeletons;
  80165. private _getAnimationGroups;
  80166. private _startAnimations;
  80167. /**
  80168. * Loads a glTF node.
  80169. * @param context The context when loading the asset
  80170. * @param node The glTF node property
  80171. * @param assign A function called synchronously after parsing the glTF properties
  80172. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80173. */
  80174. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80175. private _loadMeshAsync;
  80176. /**
  80177. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80178. * @param context The context when loading the asset
  80179. * @param name The mesh name when loading the asset
  80180. * @param node The glTF node when loading the asset
  80181. * @param mesh The glTF mesh when loading the asset
  80182. * @param primitive The glTF mesh primitive property
  80183. * @param assign A function called synchronously after parsing the glTF properties
  80184. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80185. */
  80186. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80187. private _loadVertexDataAsync;
  80188. private _createMorphTargets;
  80189. private _loadMorphTargetsAsync;
  80190. private _loadMorphTargetVertexDataAsync;
  80191. private static _LoadTransform;
  80192. private _loadSkinAsync;
  80193. private _loadBones;
  80194. private _loadBone;
  80195. private _loadSkinInverseBindMatricesDataAsync;
  80196. private _updateBoneMatrices;
  80197. private _getNodeMatrix;
  80198. /**
  80199. * Loads a glTF camera.
  80200. * @param context The context when loading the asset
  80201. * @param camera The glTF camera property
  80202. * @param assign A function called synchronously after parsing the glTF properties
  80203. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80204. */
  80205. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80206. private _loadAnimationsAsync;
  80207. /**
  80208. * Loads a glTF animation.
  80209. * @param context The context when loading the asset
  80210. * @param animation The glTF animation property
  80211. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80212. */
  80213. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80214. /**
  80215. * @hidden Loads a glTF animation channel.
  80216. * @param context The context when loading the asset
  80217. * @param animationContext The context of the animation when loading the asset
  80218. * @param animation The glTF animation property
  80219. * @param channel The glTF animation channel property
  80220. * @param babylonAnimationGroup The babylon animation group property
  80221. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80222. * @returns A void promise when the channel load is complete
  80223. */
  80224. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80225. private _loadAnimationSamplerAsync;
  80226. private _loadBufferAsync;
  80227. /**
  80228. * Loads a glTF buffer view.
  80229. * @param context The context when loading the asset
  80230. * @param bufferView The glTF buffer view property
  80231. * @returns A promise that resolves with the loaded data when the load is complete
  80232. */
  80233. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80234. private _loadAccessorAsync;
  80235. /** @hidden */
  80236. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80237. private _loadIndicesAccessorAsync;
  80238. private _loadVertexBufferViewAsync;
  80239. private _loadVertexAccessorAsync;
  80240. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80241. /** @hidden */
  80242. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80243. private _createDefaultMaterial;
  80244. /**
  80245. * Creates a Babylon material from a glTF material.
  80246. * @param context The context when loading the asset
  80247. * @param material The glTF material property
  80248. * @param babylonDrawMode The draw mode for the Babylon material
  80249. * @returns The Babylon material
  80250. */
  80251. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80252. /**
  80253. * Loads properties from a glTF material into a Babylon material.
  80254. * @param context The context when loading the asset
  80255. * @param material The glTF material property
  80256. * @param babylonMaterial The Babylon material
  80257. * @returns A promise that resolves when the load is complete
  80258. */
  80259. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80260. /**
  80261. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80262. * @param context The context when loading the asset
  80263. * @param material The glTF material property
  80264. * @param babylonMaterial The Babylon material
  80265. * @returns A promise that resolves when the load is complete
  80266. */
  80267. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80268. /**
  80269. * Loads the alpha properties from a glTF material into a Babylon material.
  80270. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80271. * @param context The context when loading the asset
  80272. * @param material The glTF material property
  80273. * @param babylonMaterial The Babylon material
  80274. */
  80275. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80276. /**
  80277. * Loads a glTF texture info.
  80278. * @param context The context when loading the asset
  80279. * @param textureInfo The glTF texture info property
  80280. * @param assign A function called synchronously after parsing the glTF properties
  80281. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80282. */
  80283. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80284. /** @hidden */
  80285. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80286. /** @hidden */
  80287. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80288. private _loadSampler;
  80289. /**
  80290. * Loads a glTF image.
  80291. * @param context The context when loading the asset
  80292. * @param image The glTF image property
  80293. * @returns A promise that resolves with the loaded data when the load is complete
  80294. */
  80295. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80296. /**
  80297. * Loads a glTF uri.
  80298. * @param context The context when loading the asset
  80299. * @param property The glTF property associated with the uri
  80300. * @param uri The base64 or relative uri
  80301. * @returns A promise that resolves with the loaded data when the load is complete
  80302. */
  80303. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80304. /**
  80305. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80306. * @param babylonObject the Babylon object with metadata
  80307. * @param pointer the JSON pointer
  80308. */
  80309. static AddPointerMetadata(babylonObject: {
  80310. metadata: any;
  80311. }, pointer: string): void;
  80312. private static _GetTextureWrapMode;
  80313. private static _GetTextureSamplingMode;
  80314. private static _GetTypedArrayConstructor;
  80315. private static _GetTypedArray;
  80316. private static _GetNumComponents;
  80317. private static _ValidateUri;
  80318. /** @hidden */
  80319. static _GetDrawMode(context: string, mode: number | undefined): number;
  80320. private _compileMaterialsAsync;
  80321. private _compileShadowGeneratorsAsync;
  80322. private _forEachExtensions;
  80323. private _applyExtensions;
  80324. private _extensionsOnLoading;
  80325. private _extensionsOnReady;
  80326. private _extensionsLoadSceneAsync;
  80327. private _extensionsLoadNodeAsync;
  80328. private _extensionsLoadCameraAsync;
  80329. private _extensionsLoadVertexDataAsync;
  80330. private _extensionsLoadMeshPrimitiveAsync;
  80331. private _extensionsLoadMaterialAsync;
  80332. private _extensionsCreateMaterial;
  80333. private _extensionsLoadMaterialPropertiesAsync;
  80334. private _extensionsLoadTextureInfoAsync;
  80335. private _extensionsLoadTextureAsync;
  80336. private _extensionsLoadAnimationAsync;
  80337. private _extensionsLoadSkinAsync;
  80338. private _extensionsLoadUriAsync;
  80339. private _extensionsLoadBufferViewAsync;
  80340. private _extensionsLoadBufferAsync;
  80341. /**
  80342. * Helper method called by a loader extension to load an glTF extension.
  80343. * @param context The context when loading the asset
  80344. * @param property The glTF property to load the extension from
  80345. * @param extensionName The name of the extension to load
  80346. * @param actionAsync The action to run
  80347. * @returns The promise returned by actionAsync or null if the extension does not exist
  80348. */
  80349. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80350. /**
  80351. * Helper method called by a loader extension to load a glTF extra.
  80352. * @param context The context when loading the asset
  80353. * @param property The glTF property to load the extra from
  80354. * @param extensionName The name of the extension to load
  80355. * @param actionAsync The action to run
  80356. * @returns The promise returned by actionAsync or null if the extra does not exist
  80357. */
  80358. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80359. /**
  80360. * Checks for presence of an extension.
  80361. * @param name The name of the extension to check
  80362. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80363. */
  80364. isExtensionUsed(name: string): boolean;
  80365. /**
  80366. * Increments the indentation level and logs a message.
  80367. * @param message The message to log
  80368. */
  80369. logOpen(message: string): void;
  80370. /**
  80371. * Decrements the indentation level.
  80372. */
  80373. logClose(): void;
  80374. /**
  80375. * Logs a message
  80376. * @param message The message to log
  80377. */
  80378. log(message: string): void;
  80379. /**
  80380. * Starts a performance counter.
  80381. * @param counterName The name of the performance counter
  80382. */
  80383. startPerformanceCounter(counterName: string): void;
  80384. /**
  80385. * Ends a performance counter.
  80386. * @param counterName The name of the performance counter
  80387. */
  80388. endPerformanceCounter(counterName: string): void;
  80389. }
  80390. }
  80391. declare module BABYLON.GLTF2.Loader.Extensions {
  80392. /** @hidden */
  80393. interface IEXTLightsImageBased_LightImageBased {
  80394. _babylonTexture?: BaseTexture;
  80395. _loaded?: Promise<void>;
  80396. }
  80397. /**
  80398. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80399. */
  80400. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80401. /**
  80402. * The name of this extension.
  80403. */
  80404. readonly name: string;
  80405. /**
  80406. * Defines whether this extension is enabled.
  80407. */
  80408. enabled: boolean;
  80409. private _loader;
  80410. private _lights?;
  80411. /** @hidden */
  80412. constructor(loader: GLTFLoader);
  80413. /** @hidden */
  80414. dispose(): void;
  80415. /** @hidden */
  80416. onLoading(): void;
  80417. /** @hidden */
  80418. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80419. private _loadLightAsync;
  80420. }
  80421. }
  80422. declare module BABYLON.GLTF2.Loader.Extensions {
  80423. /**
  80424. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80425. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80426. * !!! Experimental Extension Subject to Changes !!!
  80427. */
  80428. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80429. /**
  80430. * The name of this extension.
  80431. */
  80432. readonly name: string;
  80433. /**
  80434. * Defines whether this extension is enabled.
  80435. */
  80436. enabled: boolean;
  80437. private _loader;
  80438. /** @hidden */
  80439. constructor(loader: GLTFLoader);
  80440. /** @hidden */
  80441. dispose(): void;
  80442. /** @hidden */
  80443. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80444. }
  80445. }
  80446. declare module BABYLON.GLTF2.Loader.Extensions {
  80447. /**
  80448. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80449. */
  80450. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80451. /**
  80452. * The name of this extension.
  80453. */
  80454. readonly name: string;
  80455. /**
  80456. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80457. */
  80458. dracoCompression?: DracoCompression;
  80459. /**
  80460. * Defines whether this extension is enabled.
  80461. */
  80462. enabled: boolean;
  80463. private _loader;
  80464. /** @hidden */
  80465. constructor(loader: GLTFLoader);
  80466. /** @hidden */
  80467. dispose(): void;
  80468. /** @hidden */
  80469. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80470. }
  80471. }
  80472. declare module BABYLON.GLTF2.Loader.Extensions {
  80473. /**
  80474. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80475. */
  80476. export class KHR_lights implements IGLTFLoaderExtension {
  80477. /**
  80478. * The name of this extension.
  80479. */
  80480. readonly name: string;
  80481. /**
  80482. * Defines whether this extension is enabled.
  80483. */
  80484. enabled: boolean;
  80485. private _loader;
  80486. private _lights?;
  80487. /** @hidden */
  80488. constructor(loader: GLTFLoader);
  80489. /** @hidden */
  80490. dispose(): void;
  80491. /** @hidden */
  80492. onLoading(): void;
  80493. /** @hidden */
  80494. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80495. }
  80496. }
  80497. declare module BABYLON.GLTF2.Loader.Extensions {
  80498. /**
  80499. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80500. */
  80501. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80502. /**
  80503. * The name of this extension.
  80504. */
  80505. readonly name: string;
  80506. /**
  80507. * Defines whether this extension is enabled.
  80508. */
  80509. enabled: boolean;
  80510. /**
  80511. * Defines a number that determines the order the extensions are applied.
  80512. */
  80513. order: number;
  80514. private _loader;
  80515. /** @hidden */
  80516. constructor(loader: GLTFLoader);
  80517. /** @hidden */
  80518. dispose(): void;
  80519. /** @hidden */
  80520. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80521. private _loadSpecularGlossinessPropertiesAsync;
  80522. }
  80523. }
  80524. declare module BABYLON.GLTF2.Loader.Extensions {
  80525. /**
  80526. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80527. */
  80528. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80529. /**
  80530. * The name of this extension.
  80531. */
  80532. readonly name: string;
  80533. /**
  80534. * Defines whether this extension is enabled.
  80535. */
  80536. enabled: boolean;
  80537. /**
  80538. * Defines a number that determines the order the extensions are applied.
  80539. */
  80540. order: number;
  80541. private _loader;
  80542. /** @hidden */
  80543. constructor(loader: GLTFLoader);
  80544. /** @hidden */
  80545. dispose(): void;
  80546. /** @hidden */
  80547. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80548. private _loadUnlitPropertiesAsync;
  80549. }
  80550. }
  80551. declare module BABYLON.GLTF2.Loader.Extensions {
  80552. /**
  80553. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80554. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80555. * !!! Experimental Extension Subject to Changes !!!
  80556. */
  80557. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80558. /**
  80559. * The name of this extension.
  80560. */
  80561. readonly name: string;
  80562. /**
  80563. * Defines whether this extension is enabled.
  80564. */
  80565. enabled: boolean;
  80566. /**
  80567. * Defines a number that determines the order the extensions are applied.
  80568. */
  80569. order: number;
  80570. private _loader;
  80571. /** @hidden */
  80572. constructor(loader: GLTFLoader);
  80573. /** @hidden */
  80574. dispose(): void;
  80575. /** @hidden */
  80576. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80577. private _loadClearCoatPropertiesAsync;
  80578. }
  80579. }
  80580. declare module BABYLON.GLTF2.Loader.Extensions {
  80581. /**
  80582. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80583. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80584. * !!! Experimental Extension Subject to Changes !!!
  80585. */
  80586. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80587. /**
  80588. * The name of this extension.
  80589. */
  80590. readonly name: string;
  80591. /**
  80592. * Defines whether this extension is enabled.
  80593. */
  80594. enabled: boolean;
  80595. /**
  80596. * Defines a number that determines the order the extensions are applied.
  80597. */
  80598. order: number;
  80599. private _loader;
  80600. /** @hidden */
  80601. constructor(loader: GLTFLoader);
  80602. /** @hidden */
  80603. dispose(): void;
  80604. /** @hidden */
  80605. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80606. private _loadSheenPropertiesAsync;
  80607. }
  80608. }
  80609. declare module BABYLON.GLTF2.Loader.Extensions {
  80610. /**
  80611. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80612. * !!! Experimental Extension Subject to Changes !!!
  80613. */
  80614. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80615. /**
  80616. * The name of this extension.
  80617. */
  80618. readonly name: string;
  80619. /**
  80620. * Defines whether this extension is enabled.
  80621. */
  80622. enabled: boolean;
  80623. /**
  80624. * Defines a number that determines the order the extensions are applied.
  80625. */
  80626. order: number;
  80627. private _loader;
  80628. /** @hidden */
  80629. constructor(loader: GLTFLoader);
  80630. /** @hidden */
  80631. dispose(): void;
  80632. /** @hidden */
  80633. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80634. private _loadSpecularPropertiesAsync;
  80635. }
  80636. }
  80637. declare module BABYLON.GLTF2.Loader.Extensions {
  80638. /**
  80639. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80640. * !!! Experimental Extension Subject to Changes !!!
  80641. */
  80642. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80643. /**
  80644. * Default ior Value from the spec.
  80645. */
  80646. private static readonly _DEFAULT_IOR;
  80647. /**
  80648. * The name of this extension.
  80649. */
  80650. readonly name: string;
  80651. /**
  80652. * Defines whether this extension is enabled.
  80653. */
  80654. enabled: boolean;
  80655. /**
  80656. * Defines a number that determines the order the extensions are applied.
  80657. */
  80658. order: number;
  80659. private _loader;
  80660. /** @hidden */
  80661. constructor(loader: GLTFLoader);
  80662. /** @hidden */
  80663. dispose(): void;
  80664. /** @hidden */
  80665. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80666. private _loadIorPropertiesAsync;
  80667. }
  80668. }
  80669. declare module BABYLON.GLTF2.Loader.Extensions {
  80670. /**
  80671. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80672. * !!! Experimental Extension Subject to Changes !!!
  80673. */
  80674. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80675. /**
  80676. * The name of this extension.
  80677. */
  80678. readonly name: string;
  80679. /**
  80680. * Defines whether this extension is enabled.
  80681. */
  80682. enabled: boolean;
  80683. private _loader;
  80684. /** @hidden */
  80685. constructor(loader: GLTFLoader);
  80686. /** @hidden */
  80687. dispose(): void;
  80688. /**
  80689. * Gets the list of available variant tag names for this asset.
  80690. * @param rootMesh The glTF root mesh
  80691. * @returns the list of all the variant names for this model
  80692. */
  80693. static GetAvailableVariants(rootMesh: Mesh): string[];
  80694. /**
  80695. * Select a variant given a variant tag name or a list of variant tag names.
  80696. * @param rootMesh The glTF root mesh
  80697. * @param variantName The variant name(s) to select.
  80698. */
  80699. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80700. /**
  80701. * Reset back to the original before selecting a variant.
  80702. * @param rootMesh The glTF root mesh
  80703. */
  80704. static Reset(rootMesh: Mesh): void;
  80705. /**
  80706. * Gets the last selected variant tag name(s) or null if original.
  80707. * @param rootMesh The glTF root mesh
  80708. * @returns The selected variant tag name(s).
  80709. */
  80710. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80711. private static _GetExtensionMetadata;
  80712. /** @hidden */
  80713. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80714. }
  80715. }
  80716. declare module BABYLON.GLTF2.Loader.Extensions {
  80717. /**
  80718. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80719. * !!! Experimental Extension Subject to Changes !!!
  80720. */
  80721. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80722. /**
  80723. * The name of this extension.
  80724. */
  80725. readonly name: string;
  80726. /**
  80727. * Defines whether this extension is enabled.
  80728. */
  80729. enabled: boolean;
  80730. /**
  80731. * Defines a number that determines the order the extensions are applied.
  80732. */
  80733. order: number;
  80734. private _loader;
  80735. /** @hidden */
  80736. constructor(loader: GLTFLoader);
  80737. /** @hidden */
  80738. dispose(): void;
  80739. /** @hidden */
  80740. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80741. private _loadTransparentPropertiesAsync;
  80742. }
  80743. }
  80744. declare module BABYLON.GLTF2.Loader.Extensions {
  80745. /**
  80746. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80747. */
  80748. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80749. /**
  80750. * The name of this extension.
  80751. */
  80752. readonly name: string;
  80753. /**
  80754. * Defines whether this extension is enabled.
  80755. */
  80756. enabled: boolean;
  80757. /** @hidden */
  80758. constructor(loader: GLTFLoader);
  80759. /** @hidden */
  80760. dispose(): void;
  80761. }
  80762. }
  80763. declare module BABYLON.GLTF2.Loader.Extensions {
  80764. /**
  80765. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80766. * !!! Experimental Extension Subject to Changes !!!
  80767. */
  80768. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80769. /** The name of this extension. */
  80770. readonly name: string;
  80771. /** Defines whether this extension is enabled. */
  80772. enabled: boolean;
  80773. private _loader;
  80774. /** @hidden */
  80775. constructor(loader: GLTFLoader);
  80776. /** @hidden */
  80777. dispose(): void;
  80778. /** @hidden */
  80779. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80780. }
  80781. }
  80782. declare module BABYLON.GLTF2.Loader.Extensions {
  80783. /**
  80784. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80785. */
  80786. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80787. /**
  80788. * The name of this extension.
  80789. */
  80790. readonly name: string;
  80791. /**
  80792. * Defines whether this extension is enabled.
  80793. */
  80794. enabled: boolean;
  80795. private _loader;
  80796. /** @hidden */
  80797. constructor(loader: GLTFLoader);
  80798. /** @hidden */
  80799. dispose(): void;
  80800. /** @hidden */
  80801. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80802. }
  80803. }
  80804. declare module BABYLON.GLTF2.Loader.Extensions {
  80805. /**
  80806. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80807. * !!! Experimental Extension Subject to Changes !!!
  80808. */
  80809. export class KHR_xmp implements IGLTFLoaderExtension {
  80810. /**
  80811. * The name of this extension.
  80812. */
  80813. readonly name: string;
  80814. /**
  80815. * Defines whether this extension is enabled.
  80816. */
  80817. enabled: boolean;
  80818. /**
  80819. * Defines a number that determines the order the extensions are applied.
  80820. */
  80821. order: number;
  80822. private _loader;
  80823. /** @hidden */
  80824. constructor(loader: GLTFLoader);
  80825. /** @hidden */
  80826. dispose(): void;
  80827. /**
  80828. * Called after the loader state changes to LOADING.
  80829. */
  80830. onLoading(): void;
  80831. }
  80832. }
  80833. declare module BABYLON.GLTF2.Loader.Extensions {
  80834. /**
  80835. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80836. */
  80837. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80838. /**
  80839. * The name of this extension.
  80840. */
  80841. readonly name: string;
  80842. /**
  80843. * Defines whether this extension is enabled.
  80844. */
  80845. enabled: boolean;
  80846. private _loader;
  80847. private _clips;
  80848. private _emitters;
  80849. /** @hidden */
  80850. constructor(loader: GLTFLoader);
  80851. /** @hidden */
  80852. dispose(): void;
  80853. /** @hidden */
  80854. onLoading(): void;
  80855. /** @hidden */
  80856. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80857. /** @hidden */
  80858. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80859. /** @hidden */
  80860. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80861. private _loadClipAsync;
  80862. private _loadEmitterAsync;
  80863. private _getEventAction;
  80864. private _loadAnimationEventAsync;
  80865. }
  80866. }
  80867. declare module BABYLON.GLTF2.Loader.Extensions {
  80868. /**
  80869. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80870. */
  80871. export class MSFT_lod implements IGLTFLoaderExtension {
  80872. /**
  80873. * The name of this extension.
  80874. */
  80875. readonly name: string;
  80876. /**
  80877. * Defines whether this extension is enabled.
  80878. */
  80879. enabled: boolean;
  80880. /**
  80881. * Defines a number that determines the order the extensions are applied.
  80882. */
  80883. order: number;
  80884. /**
  80885. * Maximum number of LODs to load, starting from the lowest LOD.
  80886. */
  80887. maxLODsToLoad: number;
  80888. /**
  80889. * Observable raised when all node LODs of one level are loaded.
  80890. * The event data is the index of the loaded LOD starting from zero.
  80891. * Dispose the loader to cancel the loading of the next level of LODs.
  80892. */
  80893. onNodeLODsLoadedObservable: Observable<number>;
  80894. /**
  80895. * Observable raised when all material 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. onMaterialLODsLoadedObservable: Observable<number>;
  80900. private _loader;
  80901. private _bufferLODs;
  80902. private _nodeIndexLOD;
  80903. private _nodeSignalLODs;
  80904. private _nodePromiseLODs;
  80905. private _nodeBufferLODs;
  80906. private _materialIndexLOD;
  80907. private _materialSignalLODs;
  80908. private _materialPromiseLODs;
  80909. private _materialBufferLODs;
  80910. /** @hidden */
  80911. constructor(loader: GLTFLoader);
  80912. /** @hidden */
  80913. dispose(): void;
  80914. /** @hidden */
  80915. onReady(): void;
  80916. /** @hidden */
  80917. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80918. /** @hidden */
  80919. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80920. /** @hidden */
  80921. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80922. /** @hidden */
  80923. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80924. /** @hidden */
  80925. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80926. private _loadBufferLOD;
  80927. /**
  80928. * Gets an array of LOD properties from lowest to highest.
  80929. */
  80930. private _getLODs;
  80931. private _disposeTransformNode;
  80932. private _disposeMaterials;
  80933. }
  80934. }
  80935. declare module BABYLON.GLTF2.Loader.Extensions {
  80936. /** @hidden */
  80937. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80938. readonly name: string;
  80939. enabled: boolean;
  80940. private _loader;
  80941. constructor(loader: GLTFLoader);
  80942. dispose(): void;
  80943. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80944. }
  80945. }
  80946. declare module BABYLON.GLTF2.Loader.Extensions {
  80947. /** @hidden */
  80948. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80949. readonly name: string;
  80950. enabled: boolean;
  80951. private _loader;
  80952. constructor(loader: GLTFLoader);
  80953. dispose(): void;
  80954. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80955. }
  80956. }
  80957. declare module BABYLON.GLTF2.Loader.Extensions {
  80958. /**
  80959. * Store glTF extras (if present) in BJS objects' metadata
  80960. */
  80961. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80962. /**
  80963. * The name of this extension.
  80964. */
  80965. readonly name: string;
  80966. /**
  80967. * Defines whether this extension is enabled.
  80968. */
  80969. enabled: boolean;
  80970. private _loader;
  80971. private _assignExtras;
  80972. /** @hidden */
  80973. constructor(loader: GLTFLoader);
  80974. /** @hidden */
  80975. dispose(): void;
  80976. /** @hidden */
  80977. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80978. /** @hidden */
  80979. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80980. /** @hidden */
  80981. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80982. }
  80983. }
  80984. declare module BABYLON {
  80985. /**
  80986. * Class reading and parsing the MTL file bundled with the obj file.
  80987. */
  80988. export class MTLFileLoader {
  80989. /**
  80990. * Invert Y-Axis of referenced textures on load
  80991. */
  80992. static INVERT_TEXTURE_Y: boolean;
  80993. /**
  80994. * All material loaded from the mtl will be set here
  80995. */
  80996. materials: StandardMaterial[];
  80997. /**
  80998. * This function will read the mtl file and create each material described inside
  80999. * This function could be improve by adding :
  81000. * -some component missing (Ni, Tf...)
  81001. * -including the specific options available
  81002. *
  81003. * @param scene defines the scene the material will be created in
  81004. * @param data defines the mtl data to parse
  81005. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81006. * @param forAssetContainer defines if the material should be registered in the scene
  81007. */
  81008. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81009. /**
  81010. * Gets the texture for the material.
  81011. *
  81012. * If the material is imported from input file,
  81013. * We sanitize the url to ensure it takes the textre from aside the material.
  81014. *
  81015. * @param rootUrl The root url to load from
  81016. * @param value The value stored in the mtl
  81017. * @return The Texture
  81018. */
  81019. private static _getTexture;
  81020. }
  81021. }
  81022. declare module BABYLON {
  81023. /**
  81024. * Options for loading OBJ/MTL files
  81025. */
  81026. type MeshLoadOptions = {
  81027. /**
  81028. * Defines if UVs are optimized by default during load.
  81029. */
  81030. OptimizeWithUV: boolean;
  81031. /**
  81032. * Defines custom scaling of UV coordinates of loaded meshes.
  81033. */
  81034. UVScaling: Vector2;
  81035. /**
  81036. * Invert model on y-axis (does a model scaling inversion)
  81037. */
  81038. InvertY: boolean;
  81039. /**
  81040. * Invert Y-Axis of referenced textures on load
  81041. */
  81042. InvertTextureY: boolean;
  81043. /**
  81044. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81045. */
  81046. ImportVertexColors: boolean;
  81047. /**
  81048. * Compute the normals for the model, even if normals are present in the file.
  81049. */
  81050. ComputeNormals: boolean;
  81051. /**
  81052. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81053. */
  81054. SkipMaterials: boolean;
  81055. /**
  81056. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81057. */
  81058. MaterialLoadingFailsSilently: boolean;
  81059. };
  81060. /**
  81061. * OBJ file type loader.
  81062. * This is a babylon scene loader plugin.
  81063. */
  81064. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81065. /**
  81066. * Defines if UVs are optimized by default during load.
  81067. */
  81068. static OPTIMIZE_WITH_UV: boolean;
  81069. /**
  81070. * Invert model on y-axis (does a model scaling inversion)
  81071. */
  81072. static INVERT_Y: boolean;
  81073. /**
  81074. * Invert Y-Axis of referenced textures on load
  81075. */
  81076. static get INVERT_TEXTURE_Y(): boolean;
  81077. static set INVERT_TEXTURE_Y(value: boolean);
  81078. /**
  81079. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81080. */
  81081. static IMPORT_VERTEX_COLORS: boolean;
  81082. /**
  81083. * Compute the normals for the model, even if normals are present in the file.
  81084. */
  81085. static COMPUTE_NORMALS: boolean;
  81086. /**
  81087. * Defines custom scaling of UV coordinates of loaded meshes.
  81088. */
  81089. static UV_SCALING: Vector2;
  81090. /**
  81091. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81092. */
  81093. static SKIP_MATERIALS: boolean;
  81094. /**
  81095. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81096. *
  81097. * Defaults to true for backwards compatibility.
  81098. */
  81099. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81100. /**
  81101. * Defines the name of the plugin.
  81102. */
  81103. name: string;
  81104. /**
  81105. * Defines the extension the plugin is able to load.
  81106. */
  81107. extensions: string;
  81108. /** @hidden */
  81109. obj: RegExp;
  81110. /** @hidden */
  81111. group: RegExp;
  81112. /** @hidden */
  81113. mtllib: RegExp;
  81114. /** @hidden */
  81115. usemtl: RegExp;
  81116. /** @hidden */
  81117. smooth: RegExp;
  81118. /** @hidden */
  81119. vertexPattern: RegExp;
  81120. /** @hidden */
  81121. normalPattern: RegExp;
  81122. /** @hidden */
  81123. uvPattern: RegExp;
  81124. /** @hidden */
  81125. facePattern1: RegExp;
  81126. /** @hidden */
  81127. facePattern2: RegExp;
  81128. /** @hidden */
  81129. facePattern3: RegExp;
  81130. /** @hidden */
  81131. facePattern4: RegExp;
  81132. /** @hidden */
  81133. facePattern5: RegExp;
  81134. private _forAssetContainer;
  81135. private _meshLoadOptions;
  81136. /**
  81137. * Creates loader for .OBJ files
  81138. *
  81139. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81140. */
  81141. constructor(meshLoadOptions?: MeshLoadOptions);
  81142. private static get currentMeshLoadOptions();
  81143. /**
  81144. * Calls synchronously the MTL file attached to this obj.
  81145. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81146. * Without this function materials are not displayed in the first frame (but displayed after).
  81147. * In consequence it is impossible to get material information in your HTML file
  81148. *
  81149. * @param url The URL of the MTL file
  81150. * @param rootUrl
  81151. * @param onSuccess Callback function to be called when the MTL file is loaded
  81152. * @private
  81153. */
  81154. private _loadMTL;
  81155. /**
  81156. * Instantiates a OBJ file loader plugin.
  81157. * @returns the created plugin
  81158. */
  81159. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81160. /**
  81161. * If the data string can be loaded directly.
  81162. *
  81163. * @param data string containing the file data
  81164. * @returns if the data can be loaded directly
  81165. */
  81166. canDirectLoad(data: string): boolean;
  81167. /**
  81168. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81169. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81170. * @param scene the scene the meshes should be added to
  81171. * @param data the OBJ data to load
  81172. * @param rootUrl root url to load from
  81173. * @param onProgress event that fires when loading progress has occured
  81174. * @param fileName Defines the name of the file to load
  81175. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81176. */
  81177. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81178. meshes: AbstractMesh[];
  81179. particleSystems: IParticleSystem[];
  81180. skeletons: Skeleton[];
  81181. animationGroups: AnimationGroup[];
  81182. }>;
  81183. /**
  81184. * Imports all objects from the loaded OBJ data and adds them to the scene
  81185. * @param scene the scene the objects should be added to
  81186. * @param data the OBJ data to load
  81187. * @param rootUrl root url to load from
  81188. * @param onProgress event that fires when loading progress has occured
  81189. * @param fileName Defines the name of the file to load
  81190. * @returns a promise which completes when objects have been loaded to the scene
  81191. */
  81192. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81193. /**
  81194. * Load into an asset container.
  81195. * @param scene The scene to load into
  81196. * @param data The data to import
  81197. * @param rootUrl The root url for scene and resources
  81198. * @param onProgress The callback when the load progresses
  81199. * @param fileName Defines the name of the file to load
  81200. * @returns The loaded asset container
  81201. */
  81202. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81203. /**
  81204. * Read the OBJ file and create an Array of meshes.
  81205. * Each mesh contains all information given by the OBJ and the MTL file.
  81206. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81207. *
  81208. * @param meshesNames
  81209. * @param scene Scene The scene where are displayed the data
  81210. * @param data String The content of the obj file
  81211. * @param rootUrl String The path to the folder
  81212. * @returns Array<AbstractMesh>
  81213. * @private
  81214. */
  81215. private _parseSolid;
  81216. }
  81217. }
  81218. declare module BABYLON {
  81219. /**
  81220. * STL file type loader.
  81221. * This is a babylon scene loader plugin.
  81222. */
  81223. export class STLFileLoader implements ISceneLoaderPlugin {
  81224. /** @hidden */
  81225. solidPattern: RegExp;
  81226. /** @hidden */
  81227. facetsPattern: RegExp;
  81228. /** @hidden */
  81229. normalPattern: RegExp;
  81230. /** @hidden */
  81231. vertexPattern: RegExp;
  81232. /**
  81233. * Defines the name of the plugin.
  81234. */
  81235. name: string;
  81236. /**
  81237. * Defines the extensions the stl loader is able to load.
  81238. * force data to come in as an ArrayBuffer
  81239. * we'll convert to string if it looks like it's an ASCII .stl
  81240. */
  81241. extensions: ISceneLoaderPluginExtensions;
  81242. /**
  81243. * Import meshes into a scene.
  81244. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81245. * @param scene The scene to import into
  81246. * @param data The data to import
  81247. * @param rootUrl The root url for scene and resources
  81248. * @param meshes The meshes array to import into
  81249. * @param particleSystems The particle systems array to import into
  81250. * @param skeletons The skeletons array to import into
  81251. * @param onError The callback when import fails
  81252. * @returns True if successful or false otherwise
  81253. */
  81254. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81255. /**
  81256. * Load into a scene.
  81257. * @param scene The scene to load into
  81258. * @param data The data to import
  81259. * @param rootUrl The root url for scene and resources
  81260. * @param onError The callback when import fails
  81261. * @returns true if successful or false otherwise
  81262. */
  81263. load(scene: Scene, data: any, rootUrl: string): boolean;
  81264. /**
  81265. * Load into an asset container.
  81266. * @param scene The scene to load into
  81267. * @param data The data to import
  81268. * @param rootUrl The root url for scene and resources
  81269. * @param onError The callback when import fails
  81270. * @returns The loaded asset container
  81271. */
  81272. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81273. private _isBinary;
  81274. private _parseBinary;
  81275. private _parseASCII;
  81276. }
  81277. }
  81278. declare module BABYLON {
  81279. /**
  81280. * Class for generating OBJ data from a Babylon scene.
  81281. */
  81282. export class OBJExport {
  81283. /**
  81284. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81285. * @param mesh defines the list of meshes to serialize
  81286. * @param materials defines if materials should be exported
  81287. * @param matlibname defines the name of the associated mtl file
  81288. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81289. * @returns the OBJ content
  81290. */
  81291. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81292. /**
  81293. * Exports the material(s) of a mesh in .MTL file format (text)
  81294. * @param mesh defines the mesh to extract the material from
  81295. * @returns the mtl content
  81296. */
  81297. static MTL(mesh: Mesh): string;
  81298. }
  81299. }
  81300. declare module BABYLON {
  81301. /** @hidden */
  81302. export var __IGLTFExporterExtension: number;
  81303. /**
  81304. * Interface for extending the exporter
  81305. * @hidden
  81306. */
  81307. export interface IGLTFExporterExtension {
  81308. /**
  81309. * The name of this extension
  81310. */
  81311. readonly name: string;
  81312. /**
  81313. * Defines whether this extension is enabled
  81314. */
  81315. enabled: boolean;
  81316. /**
  81317. * Defines whether this extension is required
  81318. */
  81319. required: boolean;
  81320. }
  81321. }
  81322. declare module BABYLON.GLTF2.Exporter {
  81323. /** @hidden */
  81324. export var __IGLTFExporterExtensionV2: number;
  81325. /**
  81326. * Interface for a glTF exporter extension
  81327. * @hidden
  81328. */
  81329. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81330. /**
  81331. * Define this method to modify the default behavior before exporting a texture
  81332. * @param context The context when loading the asset
  81333. * @param babylonTexture The Babylon.js texture
  81334. * @param mimeType The mime-type of the generated image
  81335. * @returns A promise that resolves with the exported texture
  81336. */
  81337. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81338. /**
  81339. * Define this method to get notified when a texture info is created
  81340. * @param context The context when loading the asset
  81341. * @param textureInfo The glTF texture info
  81342. * @param babylonTexture The Babylon.js texture
  81343. */
  81344. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81345. /**
  81346. * Define this method to modify the default behavior when exporting texture info
  81347. * @param context The context when loading the asset
  81348. * @param meshPrimitive glTF mesh primitive
  81349. * @param babylonSubMesh Babylon submesh
  81350. * @param binaryWriter glTF serializer binary writer instance
  81351. * @returns nullable IMeshPrimitive promise
  81352. */
  81353. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81354. /**
  81355. * Define this method to modify the default behavior when exporting a node
  81356. * @param context The context when exporting the node
  81357. * @param node glTF node
  81358. * @param babylonNode BabylonJS node
  81359. * @returns nullable INode promise
  81360. */
  81361. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81362. [key: number]: number;
  81363. }): Promise<Nullable<INode>>;
  81364. /**
  81365. * Define this method to modify the default behavior when exporting a material
  81366. * @param material glTF material
  81367. * @param babylonMaterial BabylonJS material
  81368. * @returns nullable IMaterial promise
  81369. */
  81370. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81371. /**
  81372. * Define this method to return additional textures to export from a material
  81373. * @param material glTF material
  81374. * @param babylonMaterial BabylonJS material
  81375. * @returns List of textures
  81376. */
  81377. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81378. /** Gets a boolean indicating that this extension was used */
  81379. wasUsed: boolean;
  81380. /** Gets a boolean indicating that this extension is required for the file to work */
  81381. required: boolean;
  81382. /**
  81383. * Called after the exporter state changes to EXPORTING
  81384. */
  81385. onExporting?(): void;
  81386. }
  81387. }
  81388. declare module BABYLON.GLTF2.Exporter {
  81389. /**
  81390. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81391. * @hidden
  81392. */
  81393. export class _GLTFMaterialExporter {
  81394. /**
  81395. * Represents the dielectric specular values for R, G and B
  81396. */
  81397. private static readonly _DielectricSpecular;
  81398. /**
  81399. * Allows the maximum specular power to be defined for material calculations
  81400. */
  81401. private static readonly _MaxSpecularPower;
  81402. /**
  81403. * Mapping to store textures
  81404. */
  81405. private _textureMap;
  81406. /**
  81407. * Numeric tolerance value
  81408. */
  81409. private static readonly _Epsilon;
  81410. /**
  81411. * Reference to the glTF Exporter
  81412. */
  81413. private _exporter;
  81414. constructor(exporter: _Exporter);
  81415. /**
  81416. * Specifies if two colors are approximately equal in value
  81417. * @param color1 first color to compare to
  81418. * @param color2 second color to compare to
  81419. * @param epsilon threshold value
  81420. */
  81421. private static FuzzyEquals;
  81422. /**
  81423. * Gets the materials from a Babylon scene and converts them to glTF materials
  81424. * @param scene babylonjs scene
  81425. * @param mimeType texture mime type
  81426. * @param images array of images
  81427. * @param textures array of textures
  81428. * @param materials array of materials
  81429. * @param imageData mapping of texture names to base64 textures
  81430. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81431. */
  81432. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81433. /**
  81434. * Makes a copy of the glTF material without the texture parameters
  81435. * @param originalMaterial original glTF material
  81436. * @returns glTF material without texture parameters
  81437. */
  81438. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81439. /**
  81440. * Specifies if the material has any texture parameters present
  81441. * @param material glTF Material
  81442. * @returns boolean specifying if texture parameters are present
  81443. */
  81444. _hasTexturesPresent(material: IMaterial): boolean;
  81445. /**
  81446. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81447. * @param babylonStandardMaterial
  81448. * @returns glTF Metallic Roughness Material representation
  81449. */
  81450. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81451. /**
  81452. * Computes the metallic factor
  81453. * @param diffuse diffused value
  81454. * @param specular specular value
  81455. * @param oneMinusSpecularStrength one minus the specular strength
  81456. * @returns metallic value
  81457. */
  81458. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81459. /**
  81460. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81461. * @param glTFMaterial glTF material
  81462. * @param babylonMaterial Babylon material
  81463. */
  81464. private static _SetAlphaMode;
  81465. /**
  81466. * Converts a Babylon Standard Material to a glTF Material
  81467. * @param babylonStandardMaterial BJS Standard Material
  81468. * @param mimeType mime type to use for the textures
  81469. * @param images array of glTF image interfaces
  81470. * @param textures array of glTF texture interfaces
  81471. * @param materials array of glTF material interfaces
  81472. * @param imageData map of image file name to data
  81473. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81474. */
  81475. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81476. private _finishMaterial;
  81477. /**
  81478. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81479. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81480. * @param mimeType mime type to use for the textures
  81481. * @param images array of glTF image interfaces
  81482. * @param textures array of glTF texture interfaces
  81483. * @param materials array of glTF material interfaces
  81484. * @param imageData map of image file name to data
  81485. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81486. */
  81487. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81488. /**
  81489. * Converts an image typed array buffer to a base64 image
  81490. * @param buffer typed array buffer
  81491. * @param width width of the image
  81492. * @param height height of the image
  81493. * @param mimeType mimetype of the image
  81494. * @returns base64 image string
  81495. */
  81496. private _createBase64FromCanvasAsync;
  81497. /**
  81498. * Generates a white texture based on the specified width and height
  81499. * @param width width of the texture in pixels
  81500. * @param height height of the texture in pixels
  81501. * @param scene babylonjs scene
  81502. * @returns white texture
  81503. */
  81504. private _createWhiteTexture;
  81505. /**
  81506. * 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
  81507. * @param texture1 first texture to resize
  81508. * @param texture2 second texture to resize
  81509. * @param scene babylonjs scene
  81510. * @returns resized textures or null
  81511. */
  81512. private _resizeTexturesToSameDimensions;
  81513. /**
  81514. * Converts an array of pixels to a Float32Array
  81515. * Throws an error if the pixel format is not supported
  81516. * @param pixels - array buffer containing pixel values
  81517. * @returns Float32 of pixels
  81518. */
  81519. private _convertPixelArrayToFloat32;
  81520. /**
  81521. * Convert Specular Glossiness Textures to Metallic Roughness
  81522. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81523. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81524. * @param diffuseTexture texture used to store diffuse information
  81525. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81526. * @param factors specular glossiness material factors
  81527. * @param mimeType the mime type to use for the texture
  81528. * @returns pbr metallic roughness interface or null
  81529. */
  81530. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81531. /**
  81532. * Converts specular glossiness material properties to metallic roughness
  81533. * @param specularGlossiness interface with specular glossiness material properties
  81534. * @returns interface with metallic roughness material properties
  81535. */
  81536. private _convertSpecularGlossinessToMetallicRoughness;
  81537. /**
  81538. * Calculates the surface reflectance, independent of lighting conditions
  81539. * @param color Color source to calculate brightness from
  81540. * @returns number representing the perceived brightness, or zero if color is undefined
  81541. */
  81542. private _getPerceivedBrightness;
  81543. /**
  81544. * Returns the maximum color component value
  81545. * @param color
  81546. * @returns maximum color component value, or zero if color is null or undefined
  81547. */
  81548. private _getMaxComponent;
  81549. /**
  81550. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81551. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81552. * @param mimeType mime type to use for the textures
  81553. * @param images array of glTF image interfaces
  81554. * @param textures array of glTF texture interfaces
  81555. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81556. * @param imageData map of image file name to data
  81557. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81558. * @returns glTF PBR Metallic Roughness factors
  81559. */
  81560. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81561. private _getGLTFTextureSampler;
  81562. private _getGLTFTextureWrapMode;
  81563. private _getGLTFTextureWrapModesSampler;
  81564. /**
  81565. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81566. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81567. * @param mimeType mime type to use for the textures
  81568. * @param images array of glTF image interfaces
  81569. * @param textures array of glTF texture interfaces
  81570. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81571. * @param imageData map of image file name to data
  81572. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81573. * @returns glTF PBR Metallic Roughness factors
  81574. */
  81575. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81576. /**
  81577. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81578. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81579. * @param mimeType mime type to use for the textures
  81580. * @param images array of glTF image interfaces
  81581. * @param textures array of glTF texture interfaces
  81582. * @param materials array of glTF material interfaces
  81583. * @param imageData map of image file name to data
  81584. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81585. */
  81586. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81587. private setMetallicRoughnessPbrMaterial;
  81588. private getPixelsFromTexture;
  81589. /**
  81590. * Extracts a texture from a Babylon texture into file data and glTF data
  81591. * @param babylonTexture Babylon texture to extract
  81592. * @param mimeType Mime Type of the babylonTexture
  81593. * @return glTF texture info, or null if the texture format is not supported
  81594. */
  81595. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81596. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81597. /**
  81598. * Builds a texture from base64 string
  81599. * @param base64Texture base64 texture string
  81600. * @param baseTextureName Name to use for the texture
  81601. * @param mimeType image mime type for the texture
  81602. * @param images array of images
  81603. * @param textures array of textures
  81604. * @param imageData map of image data
  81605. * @returns glTF texture info, or null if the texture format is not supported
  81606. */
  81607. private _getTextureInfoFromBase64;
  81608. }
  81609. }
  81610. declare module BABYLON {
  81611. /**
  81612. * Class for holding and downloading glTF file data
  81613. */
  81614. export class GLTFData {
  81615. /**
  81616. * Object which contains the file name as the key and its data as the value
  81617. */
  81618. glTFFiles: {
  81619. [fileName: string]: string | Blob;
  81620. };
  81621. /**
  81622. * Initializes the glTF file object
  81623. */
  81624. constructor();
  81625. /**
  81626. * Downloads the glTF data as files based on their names and data
  81627. */
  81628. downloadFiles(): void;
  81629. }
  81630. }
  81631. declare module BABYLON {
  81632. /**
  81633. * Holds a collection of exporter options and parameters
  81634. */
  81635. export interface IExportOptions {
  81636. /**
  81637. * Function which indicates whether a babylon node should be exported or not
  81638. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81639. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81640. */
  81641. shouldExportNode?(node: Node): boolean;
  81642. /**
  81643. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81644. * @param metadata source metadata to read from
  81645. * @returns the data to store to glTF node extras
  81646. */
  81647. metadataSelector?(metadata: any): any;
  81648. /**
  81649. * The sample rate to bake animation curves
  81650. */
  81651. animationSampleRate?: number;
  81652. /**
  81653. * Begin serialization without waiting for the scene to be ready
  81654. */
  81655. exportWithoutWaitingForScene?: boolean;
  81656. /**
  81657. * Indicates if coordinate system swapping root nodes should be included in export
  81658. */
  81659. includeCoordinateSystemConversionNodes?: boolean;
  81660. }
  81661. /**
  81662. * Class for generating glTF data from a Babylon scene.
  81663. */
  81664. export class GLTF2Export {
  81665. /**
  81666. * Exports the geometry of the scene to .gltf file format asynchronously
  81667. * @param scene Babylon scene with scene hierarchy information
  81668. * @param filePrefix File prefix to use when generating the glTF file
  81669. * @param options Exporter options
  81670. * @returns Returns an object with a .gltf file and associates texture names
  81671. * as keys and their data and paths as values
  81672. */
  81673. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81674. private static _PreExportAsync;
  81675. private static _PostExportAsync;
  81676. /**
  81677. * Exports the geometry of the scene to .glb file format asychronously
  81678. * @param scene Babylon scene with scene hierarchy information
  81679. * @param filePrefix File prefix to use when generating glb file
  81680. * @param options Exporter options
  81681. * @returns Returns an object with a .glb filename as key and data as value
  81682. */
  81683. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81684. }
  81685. }
  81686. declare module BABYLON.GLTF2.Exporter {
  81687. /**
  81688. * @hidden
  81689. */
  81690. export class _GLTFUtilities {
  81691. /**
  81692. * Creates a buffer view based on the supplied arguments
  81693. * @param bufferIndex index value of the specified buffer
  81694. * @param byteOffset byte offset value
  81695. * @param byteLength byte length of the bufferView
  81696. * @param byteStride byte distance between conequential elements
  81697. * @param name name of the buffer view
  81698. * @returns bufferView for glTF
  81699. */
  81700. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81701. /**
  81702. * Creates an accessor based on the supplied arguments
  81703. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81704. * @param name The name of the accessor
  81705. * @param type The type of the accessor
  81706. * @param componentType The datatype of components in the attribute
  81707. * @param count The number of attributes referenced by this accessor
  81708. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81709. * @param min Minimum value of each component in this attribute
  81710. * @param max Maximum value of each component in this attribute
  81711. * @returns accessor for glTF
  81712. */
  81713. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81714. /**
  81715. * Calculates the minimum and maximum values of an array of position floats
  81716. * @param positions Positions array of a mesh
  81717. * @param vertexStart Starting vertex offset to calculate min and max values
  81718. * @param vertexCount Number of vertices to check for min and max values
  81719. * @returns min number array and max number array
  81720. */
  81721. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81722. min: number[];
  81723. max: number[];
  81724. };
  81725. /**
  81726. * Converts a new right-handed Vector3
  81727. * @param vector vector3 array
  81728. * @returns right-handed Vector3
  81729. */
  81730. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81731. /**
  81732. * Converts a Vector3 to right-handed
  81733. * @param vector Vector3 to convert to right-handed
  81734. */
  81735. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81736. /**
  81737. * Converts a three element number array to right-handed
  81738. * @param vector number array to convert to right-handed
  81739. */
  81740. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81741. /**
  81742. * Converts a new right-handed Vector3
  81743. * @param vector vector3 array
  81744. * @returns right-handed Vector3
  81745. */
  81746. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81747. /**
  81748. * Converts a Vector3 to right-handed
  81749. * @param vector Vector3 to convert to right-handed
  81750. */
  81751. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81752. /**
  81753. * Converts a three element number array to right-handed
  81754. * @param vector number array to convert to right-handed
  81755. */
  81756. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81757. /**
  81758. * Converts a Vector4 to right-handed
  81759. * @param vector Vector4 to convert to right-handed
  81760. */
  81761. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81762. /**
  81763. * Converts a Vector4 to right-handed
  81764. * @param vector Vector4 to convert to right-handed
  81765. */
  81766. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81767. /**
  81768. * Converts a Quaternion to right-handed
  81769. * @param quaternion Source quaternion to convert to right-handed
  81770. */
  81771. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81772. /**
  81773. * Converts a Quaternion to right-handed
  81774. * @param quaternion Source quaternion to convert to right-handed
  81775. */
  81776. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81777. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81778. }
  81779. }
  81780. declare module BABYLON.GLTF2.Exporter {
  81781. /**
  81782. * Converts Babylon Scene into glTF 2.0.
  81783. * @hidden
  81784. */
  81785. export class _Exporter {
  81786. /**
  81787. * Stores the glTF to export
  81788. */
  81789. _glTF: IGLTF;
  81790. /**
  81791. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81792. */
  81793. _bufferViews: IBufferView[];
  81794. /**
  81795. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81796. */
  81797. _accessors: IAccessor[];
  81798. /**
  81799. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81800. */
  81801. _nodes: INode[];
  81802. /**
  81803. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81804. */
  81805. private _scenes;
  81806. /**
  81807. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81808. */
  81809. private _meshes;
  81810. /**
  81811. * Stores all the generated material information, which represents the appearance of each primitive
  81812. */
  81813. _materials: IMaterial[];
  81814. _materialMap: {
  81815. [materialID: number]: number;
  81816. };
  81817. /**
  81818. * Stores all the generated texture information, which is referenced by glTF materials
  81819. */
  81820. _textures: ITexture[];
  81821. /**
  81822. * Stores all the generated image information, which is referenced by glTF textures
  81823. */
  81824. _images: IImage[];
  81825. /**
  81826. * Stores all the texture samplers
  81827. */
  81828. _samplers: ISampler[];
  81829. /**
  81830. * Stores all the generated animation samplers, which is referenced by glTF animations
  81831. */
  81832. /**
  81833. * Stores the animations for glTF models
  81834. */
  81835. private _animations;
  81836. /**
  81837. * Stores the total amount of bytes stored in the glTF buffer
  81838. */
  81839. private _totalByteLength;
  81840. /**
  81841. * Stores a reference to the Babylon scene containing the source geometry and material information
  81842. */
  81843. _babylonScene: Scene;
  81844. /**
  81845. * Stores a map of the image data, where the key is the file name and the value
  81846. * is the image data
  81847. */
  81848. _imageData: {
  81849. [fileName: string]: {
  81850. data: Uint8Array;
  81851. mimeType: ImageMimeType;
  81852. };
  81853. };
  81854. /**
  81855. * Stores a map of the unique id of a node to its index in the node array
  81856. */
  81857. _nodeMap: {
  81858. [key: number]: number;
  81859. };
  81860. /**
  81861. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81862. */
  81863. _convertToRightHandedSystem: boolean;
  81864. /**
  81865. * Specifies if a Babylon node should be converted to right-handed on export
  81866. */
  81867. _convertToRightHandedSystemMap: {
  81868. [nodeId: number]: boolean;
  81869. };
  81870. _includeCoordinateSystemConversionNodes: boolean;
  81871. /**
  81872. * Baked animation sample rate
  81873. */
  81874. private _animationSampleRate;
  81875. private _options;
  81876. private _localEngine;
  81877. _glTFMaterialExporter: _GLTFMaterialExporter;
  81878. private _extensions;
  81879. private static _ExtensionNames;
  81880. private static _ExtensionFactories;
  81881. private _applyExtension;
  81882. private _applyExtensions;
  81883. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81884. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81885. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81886. [key: number]: number;
  81887. }): Promise<Nullable<INode>>;
  81888. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81889. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81890. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81891. private _forEachExtensions;
  81892. private _extensionsOnExporting;
  81893. /**
  81894. * Load glTF serializer extensions
  81895. */
  81896. private _loadExtensions;
  81897. /**
  81898. * Creates a glTF Exporter instance, which can accept optional exporter options
  81899. * @param babylonScene Babylon scene object
  81900. * @param options Options to modify the behavior of the exporter
  81901. */
  81902. constructor(babylonScene: Scene, options?: IExportOptions);
  81903. dispose(): void;
  81904. /**
  81905. * Registers a glTF exporter extension
  81906. * @param name Name of the extension to export
  81907. * @param factory The factory function that creates the exporter extension
  81908. */
  81909. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81910. /**
  81911. * Un-registers an exporter extension
  81912. * @param name The name fo the exporter extension
  81913. * @returns A boolean indicating whether the extension has been un-registered
  81914. */
  81915. static UnregisterExtension(name: string): boolean;
  81916. /**
  81917. * Lazy load a local engine
  81918. */
  81919. _getLocalEngine(): Engine;
  81920. private reorderIndicesBasedOnPrimitiveMode;
  81921. /**
  81922. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81923. * clock-wise during export to glTF
  81924. * @param submesh BabylonJS submesh
  81925. * @param primitiveMode Primitive mode of the mesh
  81926. * @param sideOrientation the winding order of the submesh
  81927. * @param vertexBufferKind The type of vertex attribute
  81928. * @param meshAttributeArray The vertex attribute data
  81929. * @param byteOffset The offset to the binary data
  81930. * @param binaryWriter The binary data for the glTF file
  81931. * @param convertToRightHandedSystem Converts the values to right-handed
  81932. */
  81933. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81934. /**
  81935. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81936. * clock-wise during export to glTF
  81937. * @param submesh BabylonJS submesh
  81938. * @param primitiveMode Primitive mode of the mesh
  81939. * @param sideOrientation the winding order of the submesh
  81940. * @param vertexBufferKind The type of vertex attribute
  81941. * @param meshAttributeArray The vertex attribute data
  81942. * @param byteOffset The offset to the binary data
  81943. * @param binaryWriter The binary data for the glTF file
  81944. * @param convertToRightHandedSystem Converts the values to right-handed
  81945. */
  81946. private reorderTriangleFillMode;
  81947. /**
  81948. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81949. * clock-wise during export to glTF
  81950. * @param submesh BabylonJS submesh
  81951. * @param primitiveMode Primitive mode of the mesh
  81952. * @param sideOrientation the winding order of the submesh
  81953. * @param vertexBufferKind The type of vertex attribute
  81954. * @param meshAttributeArray The vertex attribute data
  81955. * @param byteOffset The offset to the binary data
  81956. * @param binaryWriter The binary data for the glTF file
  81957. * @param convertToRightHandedSystem Converts the values to right-handed
  81958. */
  81959. private reorderTriangleStripDrawMode;
  81960. /**
  81961. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81962. * clock-wise during export to glTF
  81963. * @param submesh BabylonJS submesh
  81964. * @param primitiveMode Primitive mode of the mesh
  81965. * @param sideOrientation the winding order of the submesh
  81966. * @param vertexBufferKind The type of vertex attribute
  81967. * @param meshAttributeArray The vertex attribute data
  81968. * @param byteOffset The offset to the binary data
  81969. * @param binaryWriter The binary data for the glTF file
  81970. * @param convertToRightHandedSystem Converts the values to right-handed
  81971. */
  81972. private reorderTriangleFanMode;
  81973. /**
  81974. * Writes the vertex attribute data to binary
  81975. * @param vertices The vertices to write to the binary writer
  81976. * @param byteOffset The offset into the binary writer to overwrite binary data
  81977. * @param vertexAttributeKind The vertex attribute type
  81978. * @param meshAttributeArray The vertex attribute data
  81979. * @param binaryWriter The writer containing the binary data
  81980. * @param convertToRightHandedSystem Converts the values to right-handed
  81981. */
  81982. private writeVertexAttributeData;
  81983. /**
  81984. * Writes mesh attribute data to a data buffer
  81985. * Returns the bytelength of the data
  81986. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81987. * @param meshAttributeArray Array containing the attribute data
  81988. * @param binaryWriter The buffer to write the binary data to
  81989. * @param indices Used to specify the order of the vertex data
  81990. * @param convertToRightHandedSystem Converts the values to right-handed
  81991. */
  81992. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81993. /**
  81994. * Generates glTF json data
  81995. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81996. * @param glTFPrefix Text to use when prefixing a glTF file
  81997. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81998. * @returns json data as string
  81999. */
  82000. private generateJSON;
  82001. /**
  82002. * Generates data for .gltf and .bin files based on the glTF prefix string
  82003. * @param glTFPrefix Text to use when prefixing a glTF file
  82004. * @param dispose Dispose the exporter
  82005. * @returns GLTFData with glTF file data
  82006. */
  82007. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82008. /**
  82009. * Creates a binary buffer for glTF
  82010. * @returns array buffer for binary data
  82011. */
  82012. private _generateBinaryAsync;
  82013. /**
  82014. * Pads the number to a multiple of 4
  82015. * @param num number to pad
  82016. * @returns padded number
  82017. */
  82018. private _getPadding;
  82019. /**
  82020. * @hidden
  82021. */
  82022. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82023. /**
  82024. * Sets the TRS for each node
  82025. * @param node glTF Node for storing the transformation data
  82026. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82027. * @param convertToRightHandedSystem Converts the values to right-handed
  82028. */
  82029. private setNodeTransformation;
  82030. private getVertexBufferFromMesh;
  82031. /**
  82032. * Creates a bufferview based on the vertices type for the Babylon mesh
  82033. * @param kind Indicates the type of vertices data
  82034. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82035. * @param binaryWriter The buffer to write the bufferview data to
  82036. * @param convertToRightHandedSystem Converts the values to right-handed
  82037. */
  82038. private createBufferViewKind;
  82039. /**
  82040. * The primitive mode of the Babylon mesh
  82041. * @param babylonMesh The BabylonJS mesh
  82042. */
  82043. private getMeshPrimitiveMode;
  82044. /**
  82045. * Sets the primitive mode of the glTF mesh primitive
  82046. * @param meshPrimitive glTF mesh primitive
  82047. * @param primitiveMode The primitive mode
  82048. */
  82049. private setPrimitiveMode;
  82050. /**
  82051. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82052. * @param meshPrimitive glTF mesh primitive
  82053. * @param attributeKind vertex attribute
  82054. * @returns boolean specifying if uv coordinates are present
  82055. */
  82056. private setAttributeKind;
  82057. /**
  82058. * Sets data for the primitive attributes of each submesh
  82059. * @param mesh glTF Mesh object to store the primitive attribute information
  82060. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82061. * @param binaryWriter Buffer to write the attribute data to
  82062. * @param convertToRightHandedSystem Converts the values to right-handed
  82063. */
  82064. private setPrimitiveAttributesAsync;
  82065. /**
  82066. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82067. * @param node The node to check
  82068. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82069. */
  82070. private isBabylonCoordinateSystemConvertingNode;
  82071. /**
  82072. * Creates a glTF scene based on the array of meshes
  82073. * Returns the the total byte offset
  82074. * @param babylonScene Babylon scene to get the mesh data from
  82075. * @param binaryWriter Buffer to write binary data to
  82076. */
  82077. private createSceneAsync;
  82078. /**
  82079. * Creates a mapping of Node unique id to node index and handles animations
  82080. * @param babylonScene Babylon Scene
  82081. * @param nodes Babylon transform nodes
  82082. * @param binaryWriter Buffer to write binary data to
  82083. * @returns Node mapping of unique id to index
  82084. */
  82085. private createNodeMapAndAnimationsAsync;
  82086. /**
  82087. * Creates a glTF node from a Babylon mesh
  82088. * @param babylonMesh Source Babylon mesh
  82089. * @param binaryWriter Buffer for storing geometry data
  82090. * @param convertToRightHandedSystem Converts the values to right-handed
  82091. * @param nodeMap Node mapping of unique id to glTF node index
  82092. * @returns glTF node
  82093. */
  82094. private createNodeAsync;
  82095. }
  82096. /**
  82097. * @hidden
  82098. *
  82099. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82100. */
  82101. export class _BinaryWriter {
  82102. /**
  82103. * Array buffer which stores all binary data
  82104. */
  82105. private _arrayBuffer;
  82106. /**
  82107. * View of the array buffer
  82108. */
  82109. private _dataView;
  82110. /**
  82111. * byte offset of data in array buffer
  82112. */
  82113. private _byteOffset;
  82114. /**
  82115. * Initialize binary writer with an initial byte length
  82116. * @param byteLength Initial byte length of the array buffer
  82117. */
  82118. constructor(byteLength: number);
  82119. /**
  82120. * Resize the array buffer to the specified byte length
  82121. * @param byteLength
  82122. */
  82123. private resizeBuffer;
  82124. /**
  82125. * Get an array buffer with the length of the byte offset
  82126. * @returns ArrayBuffer resized to the byte offset
  82127. */
  82128. getArrayBuffer(): ArrayBuffer;
  82129. /**
  82130. * Get the byte offset of the array buffer
  82131. * @returns byte offset
  82132. */
  82133. getByteOffset(): number;
  82134. /**
  82135. * Stores an UInt8 in the array buffer
  82136. * @param entry
  82137. * @param byteOffset If defined, specifies where to set the value as an offset.
  82138. */
  82139. setUInt8(entry: number, byteOffset?: number): void;
  82140. /**
  82141. * Gets an UInt32 in the array buffer
  82142. * @param entry
  82143. * @param byteOffset If defined, specifies where to set the value as an offset.
  82144. */
  82145. getUInt32(byteOffset: number): number;
  82146. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82147. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82148. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82149. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82150. /**
  82151. * Stores a Float32 in the array buffer
  82152. * @param entry
  82153. */
  82154. setFloat32(entry: number, byteOffset?: number): void;
  82155. /**
  82156. * Stores an UInt32 in the array buffer
  82157. * @param entry
  82158. * @param byteOffset If defined, specifies where to set the value as an offset.
  82159. */
  82160. setUInt32(entry: number, byteOffset?: number): void;
  82161. }
  82162. }
  82163. declare module BABYLON.GLTF2.Exporter {
  82164. /**
  82165. * @hidden
  82166. * Interface to store animation data.
  82167. */
  82168. export interface _IAnimationData {
  82169. /**
  82170. * Keyframe data.
  82171. */
  82172. inputs: number[];
  82173. /**
  82174. * Value data.
  82175. */
  82176. outputs: number[][];
  82177. /**
  82178. * Animation interpolation data.
  82179. */
  82180. samplerInterpolation: AnimationSamplerInterpolation;
  82181. /**
  82182. * Minimum keyframe value.
  82183. */
  82184. inputsMin: number;
  82185. /**
  82186. * Maximum keyframe value.
  82187. */
  82188. inputsMax: number;
  82189. }
  82190. /**
  82191. * @hidden
  82192. */
  82193. export interface _IAnimationInfo {
  82194. /**
  82195. * The target channel for the animation
  82196. */
  82197. animationChannelTargetPath: AnimationChannelTargetPath;
  82198. /**
  82199. * The glTF accessor type for the data.
  82200. */
  82201. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82202. /**
  82203. * Specifies if quaternions should be used.
  82204. */
  82205. useQuaternion: boolean;
  82206. }
  82207. /**
  82208. * @hidden
  82209. * Utility class for generating glTF animation data from BabylonJS.
  82210. */
  82211. export class _GLTFAnimation {
  82212. /**
  82213. * @ignore
  82214. *
  82215. * Creates glTF channel animation from BabylonJS animation.
  82216. * @param babylonTransformNode - BabylonJS mesh.
  82217. * @param animation - animation.
  82218. * @param animationChannelTargetPath - The target animation channel.
  82219. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82220. * @param useQuaternion - Specifies if quaternions are used.
  82221. * @returns nullable IAnimationData
  82222. */
  82223. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82224. private static _DeduceAnimationInfo;
  82225. /**
  82226. * @ignore
  82227. * Create node animations from the transform node animations
  82228. * @param babylonNode
  82229. * @param runtimeGLTFAnimation
  82230. * @param idleGLTFAnimations
  82231. * @param nodeMap
  82232. * @param nodes
  82233. * @param binaryWriter
  82234. * @param bufferViews
  82235. * @param accessors
  82236. * @param convertToRightHandedSystem
  82237. * @param animationSampleRate
  82238. */
  82239. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82240. [key: number]: number;
  82241. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82242. /**
  82243. * @ignore
  82244. * Create node animations from the animation groups
  82245. * @param babylonScene
  82246. * @param glTFAnimations
  82247. * @param nodeMap
  82248. * @param nodes
  82249. * @param binaryWriter
  82250. * @param bufferViews
  82251. * @param accessors
  82252. * @param convertToRightHandedSystemMap
  82253. * @param animationSampleRate
  82254. */
  82255. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82256. [key: number]: number;
  82257. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82258. [nodeId: number]: boolean;
  82259. }, animationSampleRate: number): void;
  82260. private static AddAnimation;
  82261. /**
  82262. * Create a baked animation
  82263. * @param babylonTransformNode BabylonJS mesh
  82264. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82265. * @param animationChannelTargetPath animation target channel
  82266. * @param minFrame minimum animation frame
  82267. * @param maxFrame maximum animation frame
  82268. * @param fps frames per second of the animation
  82269. * @param inputs input key frames of the animation
  82270. * @param outputs output key frame data of the animation
  82271. * @param convertToRightHandedSystem converts the values to right-handed
  82272. * @param useQuaternion specifies if quaternions should be used
  82273. */
  82274. private static _CreateBakedAnimation;
  82275. private static _ConvertFactorToVector3OrQuaternion;
  82276. private static _SetInterpolatedValue;
  82277. /**
  82278. * Creates linear animation from the animation key frames
  82279. * @param babylonTransformNode BabylonJS mesh
  82280. * @param animation BabylonJS animation
  82281. * @param animationChannelTargetPath The target animation channel
  82282. * @param frameDelta The difference between the last and first frame of the animation
  82283. * @param inputs Array to store the key frame times
  82284. * @param outputs Array to store the key frame data
  82285. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82286. * @param useQuaternion Specifies if quaternions are used in the animation
  82287. */
  82288. private static _CreateLinearOrStepAnimation;
  82289. /**
  82290. * Creates cubic spline animation from the animation key frames
  82291. * @param babylonTransformNode BabylonJS mesh
  82292. * @param animation BabylonJS animation
  82293. * @param animationChannelTargetPath The target animation channel
  82294. * @param frameDelta The difference between the last and first frame of the animation
  82295. * @param inputs Array to store the key frame times
  82296. * @param outputs Array to store the key frame data
  82297. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82298. * @param useQuaternion Specifies if quaternions are used in the animation
  82299. */
  82300. private static _CreateCubicSplineAnimation;
  82301. private static _GetBasePositionRotationOrScale;
  82302. /**
  82303. * Adds a key frame value
  82304. * @param keyFrame
  82305. * @param animation
  82306. * @param outputs
  82307. * @param animationChannelTargetPath
  82308. * @param basePositionRotationOrScale
  82309. * @param convertToRightHandedSystem
  82310. * @param useQuaternion
  82311. */
  82312. private static _AddKeyframeValue;
  82313. /**
  82314. * Determine the interpolation based on the key frames
  82315. * @param keyFrames
  82316. * @param animationChannelTargetPath
  82317. * @param useQuaternion
  82318. */
  82319. private static _DeduceInterpolation;
  82320. /**
  82321. * Adds an input tangent or output tangent to the output data
  82322. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82323. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82324. * @param outputs The animation data by keyframe
  82325. * @param animationChannelTargetPath The target animation channel
  82326. * @param interpolation The interpolation type
  82327. * @param keyFrame The key frame with the animation data
  82328. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82329. * @param useQuaternion Specifies if quaternions are used
  82330. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82331. */
  82332. private static AddSplineTangent;
  82333. /**
  82334. * Get the minimum and maximum key frames' frame values
  82335. * @param keyFrames animation key frames
  82336. * @returns the minimum and maximum key frame value
  82337. */
  82338. private static calculateMinMaxKeyFrames;
  82339. }
  82340. }
  82341. declare module BABYLON.GLTF2.Exporter {
  82342. /** @hidden */
  82343. export var textureTransformPixelShader: {
  82344. name: string;
  82345. shader: string;
  82346. };
  82347. }
  82348. declare module BABYLON.GLTF2.Exporter.Extensions {
  82349. /**
  82350. * @hidden
  82351. */
  82352. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82353. private _recordedTextures;
  82354. /** Name of this extension */
  82355. readonly name: string;
  82356. /** Defines whether this extension is enabled */
  82357. enabled: boolean;
  82358. /** Defines whether this extension is required */
  82359. required: boolean;
  82360. /** Reference to the glTF exporter */
  82361. private _wasUsed;
  82362. constructor(exporter: _Exporter);
  82363. dispose(): void;
  82364. /** @hidden */
  82365. get wasUsed(): boolean;
  82366. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82367. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82368. /**
  82369. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82370. * @param babylonTexture
  82371. * @param offset
  82372. * @param rotation
  82373. * @param scale
  82374. * @param scene
  82375. */
  82376. private _textureTransformTextureAsync;
  82377. }
  82378. }
  82379. declare module BABYLON.GLTF2.Exporter.Extensions {
  82380. /**
  82381. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82382. */
  82383. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82384. /** The name of this extension. */
  82385. readonly name: string;
  82386. /** Defines whether this extension is enabled. */
  82387. enabled: boolean;
  82388. /** Defines whether this extension is required */
  82389. required: boolean;
  82390. /** Reference to the glTF exporter */
  82391. private _exporter;
  82392. private _lights;
  82393. /** @hidden */
  82394. constructor(exporter: _Exporter);
  82395. /** @hidden */
  82396. dispose(): void;
  82397. /** @hidden */
  82398. get wasUsed(): boolean;
  82399. /** @hidden */
  82400. onExporting(): void;
  82401. /**
  82402. * Define this method to modify the default behavior when exporting a node
  82403. * @param context The context when exporting the node
  82404. * @param node glTF node
  82405. * @param babylonNode BabylonJS node
  82406. * @param nodeMap Node mapping of unique id to glTF node index
  82407. * @returns nullable INode promise
  82408. */
  82409. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82410. [key: number]: number;
  82411. }): Promise<Nullable<INode>>;
  82412. }
  82413. }
  82414. declare module BABYLON.GLTF2.Exporter.Extensions {
  82415. /**
  82416. * @hidden
  82417. */
  82418. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82419. /** Name of this extension */
  82420. readonly name: string;
  82421. /** Defines whether this extension is enabled */
  82422. enabled: boolean;
  82423. /** Defines whether this extension is required */
  82424. required: boolean;
  82425. /** Reference to the glTF exporter */
  82426. private _textureInfos;
  82427. private _exportedTextures;
  82428. private _wasUsed;
  82429. constructor(exporter: _Exporter);
  82430. dispose(): void;
  82431. /** @hidden */
  82432. get wasUsed(): boolean;
  82433. private _getTextureIndex;
  82434. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82435. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82436. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82437. }
  82438. }
  82439. declare module BABYLON.GLTF2.Exporter.Extensions {
  82440. /**
  82441. * @hidden
  82442. */
  82443. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82444. /** Name of this extension */
  82445. readonly name: string;
  82446. /** Defines whether this extension is enabled */
  82447. enabled: boolean;
  82448. /** Defines whether this extension is required */
  82449. required: boolean;
  82450. private _wasUsed;
  82451. constructor(exporter: _Exporter);
  82452. /** @hidden */
  82453. get wasUsed(): boolean;
  82454. dispose(): void;
  82455. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82456. }
  82457. }
  82458. declare module BABYLON {
  82459. /**
  82460. * Class for generating STL data from a Babylon scene.
  82461. */
  82462. export class STLExport {
  82463. /**
  82464. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82465. * @param meshes list defines the mesh to serialize
  82466. * @param download triggers the automatic download of the file.
  82467. * @param fileName changes the downloads fileName.
  82468. * @param binary changes the STL to a binary type.
  82469. * @param isLittleEndian toggle for binary type exporter.
  82470. * @returns the STL as UTF8 string
  82471. */
  82472. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82473. }
  82474. }
  82475. declare module "babylonjs-gltf2interface" {
  82476. export = BABYLON.GLTF2;
  82477. }
  82478. /**
  82479. * Module for glTF 2.0 Interface
  82480. */
  82481. declare module BABYLON.GLTF2 {
  82482. /**
  82483. * The datatype of the components in the attribute
  82484. */
  82485. const enum AccessorComponentType {
  82486. /**
  82487. * Byte
  82488. */
  82489. BYTE = 5120,
  82490. /**
  82491. * Unsigned Byte
  82492. */
  82493. UNSIGNED_BYTE = 5121,
  82494. /**
  82495. * Short
  82496. */
  82497. SHORT = 5122,
  82498. /**
  82499. * Unsigned Short
  82500. */
  82501. UNSIGNED_SHORT = 5123,
  82502. /**
  82503. * Unsigned Int
  82504. */
  82505. UNSIGNED_INT = 5125,
  82506. /**
  82507. * Float
  82508. */
  82509. FLOAT = 5126,
  82510. }
  82511. /**
  82512. * Specifies if the attirbute is a scalar, vector, or matrix
  82513. */
  82514. const enum AccessorType {
  82515. /**
  82516. * Scalar
  82517. */
  82518. SCALAR = "SCALAR",
  82519. /**
  82520. * Vector2
  82521. */
  82522. VEC2 = "VEC2",
  82523. /**
  82524. * Vector3
  82525. */
  82526. VEC3 = "VEC3",
  82527. /**
  82528. * Vector4
  82529. */
  82530. VEC4 = "VEC4",
  82531. /**
  82532. * Matrix2x2
  82533. */
  82534. MAT2 = "MAT2",
  82535. /**
  82536. * Matrix3x3
  82537. */
  82538. MAT3 = "MAT3",
  82539. /**
  82540. * Matrix4x4
  82541. */
  82542. MAT4 = "MAT4",
  82543. }
  82544. /**
  82545. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82546. */
  82547. const enum AnimationChannelTargetPath {
  82548. /**
  82549. * Translation
  82550. */
  82551. TRANSLATION = "translation",
  82552. /**
  82553. * Rotation
  82554. */
  82555. ROTATION = "rotation",
  82556. /**
  82557. * Scale
  82558. */
  82559. SCALE = "scale",
  82560. /**
  82561. * Weights
  82562. */
  82563. WEIGHTS = "weights",
  82564. }
  82565. /**
  82566. * Interpolation algorithm
  82567. */
  82568. const enum AnimationSamplerInterpolation {
  82569. /**
  82570. * The animated values are linearly interpolated between keyframes
  82571. */
  82572. LINEAR = "LINEAR",
  82573. /**
  82574. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82575. */
  82576. STEP = "STEP",
  82577. /**
  82578. * The animation's interpolation is computed using a cubic spline with specified tangents
  82579. */
  82580. CUBICSPLINE = "CUBICSPLINE",
  82581. }
  82582. /**
  82583. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82584. */
  82585. const enum CameraType {
  82586. /**
  82587. * A perspective camera containing properties to create a perspective projection matrix
  82588. */
  82589. PERSPECTIVE = "perspective",
  82590. /**
  82591. * An orthographic camera containing properties to create an orthographic projection matrix
  82592. */
  82593. ORTHOGRAPHIC = "orthographic",
  82594. }
  82595. /**
  82596. * The mime-type of the image
  82597. */
  82598. const enum ImageMimeType {
  82599. /**
  82600. * JPEG Mime-type
  82601. */
  82602. JPEG = "image/jpeg",
  82603. /**
  82604. * PNG Mime-type
  82605. */
  82606. PNG = "image/png",
  82607. }
  82608. /**
  82609. * The alpha rendering mode of the material
  82610. */
  82611. const enum MaterialAlphaMode {
  82612. /**
  82613. * The alpha value is ignored and the rendered output is fully opaque
  82614. */
  82615. OPAQUE = "OPAQUE",
  82616. /**
  82617. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82618. */
  82619. MASK = "MASK",
  82620. /**
  82621. * 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)
  82622. */
  82623. BLEND = "BLEND",
  82624. }
  82625. /**
  82626. * The type of the primitives to render
  82627. */
  82628. const enum MeshPrimitiveMode {
  82629. /**
  82630. * Points
  82631. */
  82632. POINTS = 0,
  82633. /**
  82634. * Lines
  82635. */
  82636. LINES = 1,
  82637. /**
  82638. * Line Loop
  82639. */
  82640. LINE_LOOP = 2,
  82641. /**
  82642. * Line Strip
  82643. */
  82644. LINE_STRIP = 3,
  82645. /**
  82646. * Triangles
  82647. */
  82648. TRIANGLES = 4,
  82649. /**
  82650. * Triangle Strip
  82651. */
  82652. TRIANGLE_STRIP = 5,
  82653. /**
  82654. * Triangle Fan
  82655. */
  82656. TRIANGLE_FAN = 6,
  82657. }
  82658. /**
  82659. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82660. */
  82661. const enum TextureMagFilter {
  82662. /**
  82663. * Nearest
  82664. */
  82665. NEAREST = 9728,
  82666. /**
  82667. * Linear
  82668. */
  82669. LINEAR = 9729,
  82670. }
  82671. /**
  82672. * Minification filter. All valid values correspond to WebGL enums
  82673. */
  82674. const enum TextureMinFilter {
  82675. /**
  82676. * Nearest
  82677. */
  82678. NEAREST = 9728,
  82679. /**
  82680. * Linear
  82681. */
  82682. LINEAR = 9729,
  82683. /**
  82684. * Nearest Mip-Map Nearest
  82685. */
  82686. NEAREST_MIPMAP_NEAREST = 9984,
  82687. /**
  82688. * Linear Mipmap Nearest
  82689. */
  82690. LINEAR_MIPMAP_NEAREST = 9985,
  82691. /**
  82692. * Nearest Mipmap Linear
  82693. */
  82694. NEAREST_MIPMAP_LINEAR = 9986,
  82695. /**
  82696. * Linear Mipmap Linear
  82697. */
  82698. LINEAR_MIPMAP_LINEAR = 9987,
  82699. }
  82700. /**
  82701. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82702. */
  82703. const enum TextureWrapMode {
  82704. /**
  82705. * Clamp to Edge
  82706. */
  82707. CLAMP_TO_EDGE = 33071,
  82708. /**
  82709. * Mirrored Repeat
  82710. */
  82711. MIRRORED_REPEAT = 33648,
  82712. /**
  82713. * Repeat
  82714. */
  82715. REPEAT = 10497,
  82716. }
  82717. /**
  82718. * glTF Property
  82719. */
  82720. interface IProperty {
  82721. /**
  82722. * Dictionary object with extension-specific objects
  82723. */
  82724. extensions?: {
  82725. [key: string]: any;
  82726. };
  82727. /**
  82728. * Application-Specific data
  82729. */
  82730. extras?: any;
  82731. }
  82732. /**
  82733. * glTF Child of Root Property
  82734. */
  82735. interface IChildRootProperty extends IProperty {
  82736. /**
  82737. * The user-defined name of this object
  82738. */
  82739. name?: string;
  82740. }
  82741. /**
  82742. * Indices of those attributes that deviate from their initialization value
  82743. */
  82744. interface IAccessorSparseIndices extends IProperty {
  82745. /**
  82746. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82747. */
  82748. bufferView: number;
  82749. /**
  82750. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82751. */
  82752. byteOffset?: number;
  82753. /**
  82754. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82755. */
  82756. componentType: AccessorComponentType;
  82757. }
  82758. /**
  82759. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82760. */
  82761. interface IAccessorSparseValues extends IProperty {
  82762. /**
  82763. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82764. */
  82765. bufferView: number;
  82766. /**
  82767. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82768. */
  82769. byteOffset?: number;
  82770. }
  82771. /**
  82772. * Sparse storage of attributes that deviate from their initialization value
  82773. */
  82774. interface IAccessorSparse extends IProperty {
  82775. /**
  82776. * The number of attributes encoded in this sparse accessor
  82777. */
  82778. count: number;
  82779. /**
  82780. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82781. */
  82782. indices: IAccessorSparseIndices;
  82783. /**
  82784. * 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
  82785. */
  82786. values: IAccessorSparseValues;
  82787. }
  82788. /**
  82789. * 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
  82790. */
  82791. interface IAccessor extends IChildRootProperty {
  82792. /**
  82793. * The index of the bufferview
  82794. */
  82795. bufferView?: number;
  82796. /**
  82797. * The offset relative to the start of the bufferView in bytes
  82798. */
  82799. byteOffset?: number;
  82800. /**
  82801. * The datatype of components in the attribute
  82802. */
  82803. componentType: AccessorComponentType;
  82804. /**
  82805. * Specifies whether integer data values should be normalized
  82806. */
  82807. normalized?: boolean;
  82808. /**
  82809. * The number of attributes referenced by this accessor
  82810. */
  82811. count: number;
  82812. /**
  82813. * Specifies if the attribute is a scalar, vector, or matrix
  82814. */
  82815. type: AccessorType;
  82816. /**
  82817. * Maximum value of each component in this attribute
  82818. */
  82819. max?: number[];
  82820. /**
  82821. * Minimum value of each component in this attribute
  82822. */
  82823. min?: number[];
  82824. /**
  82825. * Sparse storage of attributes that deviate from their initialization value
  82826. */
  82827. sparse?: IAccessorSparse;
  82828. }
  82829. /**
  82830. * Targets an animation's sampler at a node's property
  82831. */
  82832. interface IAnimationChannel extends IProperty {
  82833. /**
  82834. * The index of a sampler in this animation used to compute the value for the target
  82835. */
  82836. sampler: number;
  82837. /**
  82838. * The index of the node and TRS property to target
  82839. */
  82840. target: IAnimationChannelTarget;
  82841. }
  82842. /**
  82843. * The index of the node and TRS property that an animation channel targets
  82844. */
  82845. interface IAnimationChannelTarget extends IProperty {
  82846. /**
  82847. * The index of the node to target
  82848. */
  82849. node: number;
  82850. /**
  82851. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82852. */
  82853. path: AnimationChannelTargetPath;
  82854. }
  82855. /**
  82856. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82857. */
  82858. interface IAnimationSampler extends IProperty {
  82859. /**
  82860. * The index of an accessor containing keyframe input values, e.g., time
  82861. */
  82862. input: number;
  82863. /**
  82864. * Interpolation algorithm
  82865. */
  82866. interpolation?: AnimationSamplerInterpolation;
  82867. /**
  82868. * The index of an accessor, containing keyframe output values
  82869. */
  82870. output: number;
  82871. }
  82872. /**
  82873. * A keyframe animation
  82874. */
  82875. interface IAnimation extends IChildRootProperty {
  82876. /**
  82877. * An array of channels, each of which targets an animation's sampler at a node's property
  82878. */
  82879. channels: IAnimationChannel[];
  82880. /**
  82881. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82882. */
  82883. samplers: IAnimationSampler[];
  82884. }
  82885. /**
  82886. * Metadata about the glTF asset
  82887. */
  82888. interface IAsset extends IChildRootProperty {
  82889. /**
  82890. * A copyright message suitable for display to credit the content creator
  82891. */
  82892. copyright?: string;
  82893. /**
  82894. * Tool that generated this glTF model. Useful for debugging
  82895. */
  82896. generator?: string;
  82897. /**
  82898. * The glTF version that this asset targets
  82899. */
  82900. version: string;
  82901. /**
  82902. * The minimum glTF version that this asset targets
  82903. */
  82904. minVersion?: string;
  82905. }
  82906. /**
  82907. * A buffer points to binary geometry, animation, or skins
  82908. */
  82909. interface IBuffer extends IChildRootProperty {
  82910. /**
  82911. * 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
  82912. */
  82913. uri?: string;
  82914. /**
  82915. * The length of the buffer in bytes
  82916. */
  82917. byteLength: number;
  82918. }
  82919. /**
  82920. * A view into a buffer generally representing a subset of the buffer
  82921. */
  82922. interface IBufferView extends IChildRootProperty {
  82923. /**
  82924. * The index of the buffer
  82925. */
  82926. buffer: number;
  82927. /**
  82928. * The offset into the buffer in bytes
  82929. */
  82930. byteOffset?: number;
  82931. /**
  82932. * The lenth of the bufferView in bytes
  82933. */
  82934. byteLength: number;
  82935. /**
  82936. * The stride, in bytes
  82937. */
  82938. byteStride?: number;
  82939. }
  82940. /**
  82941. * An orthographic camera containing properties to create an orthographic projection matrix
  82942. */
  82943. interface ICameraOrthographic extends IProperty {
  82944. /**
  82945. * The floating-point horizontal magnification of the view. Must not be zero
  82946. */
  82947. xmag: number;
  82948. /**
  82949. * The floating-point vertical magnification of the view. Must not be zero
  82950. */
  82951. ymag: number;
  82952. /**
  82953. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82954. */
  82955. zfar: number;
  82956. /**
  82957. * The floating-point distance to the near clipping plane
  82958. */
  82959. znear: number;
  82960. }
  82961. /**
  82962. * A perspective camera containing properties to create a perspective projection matrix
  82963. */
  82964. interface ICameraPerspective extends IProperty {
  82965. /**
  82966. * The floating-point aspect ratio of the field of view
  82967. */
  82968. aspectRatio?: number;
  82969. /**
  82970. * The floating-point vertical field of view in radians
  82971. */
  82972. yfov: number;
  82973. /**
  82974. * The floating-point distance to the far clipping plane
  82975. */
  82976. zfar?: number;
  82977. /**
  82978. * The floating-point distance to the near clipping plane
  82979. */
  82980. znear: number;
  82981. }
  82982. /**
  82983. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82984. */
  82985. interface ICamera extends IChildRootProperty {
  82986. /**
  82987. * An orthographic camera containing properties to create an orthographic projection matrix
  82988. */
  82989. orthographic?: ICameraOrthographic;
  82990. /**
  82991. * A perspective camera containing properties to create a perspective projection matrix
  82992. */
  82993. perspective?: ICameraPerspective;
  82994. /**
  82995. * Specifies if the camera uses a perspective or orthographic projection
  82996. */
  82997. type: CameraType;
  82998. }
  82999. /**
  83000. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83001. */
  83002. interface IImage extends IChildRootProperty {
  83003. /**
  83004. * 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
  83005. */
  83006. uri?: string;
  83007. /**
  83008. * The image's MIME type
  83009. */
  83010. mimeType?: ImageMimeType;
  83011. /**
  83012. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83013. */
  83014. bufferView?: number;
  83015. }
  83016. /**
  83017. * Material Normal Texture Info
  83018. */
  83019. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83020. /**
  83021. * The scalar multiplier applied to each normal vector of the normal texture
  83022. */
  83023. scale?: number;
  83024. }
  83025. /**
  83026. * Material Occlusion Texture Info
  83027. */
  83028. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83029. /**
  83030. * A scalar multiplier controlling the amount of occlusion applied
  83031. */
  83032. strength?: number;
  83033. }
  83034. /**
  83035. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83036. */
  83037. interface IMaterialPbrMetallicRoughness {
  83038. /**
  83039. * The material's base color factor
  83040. */
  83041. baseColorFactor?: number[];
  83042. /**
  83043. * The base color texture
  83044. */
  83045. baseColorTexture?: ITextureInfo;
  83046. /**
  83047. * The metalness of the material
  83048. */
  83049. metallicFactor?: number;
  83050. /**
  83051. * The roughness of the material
  83052. */
  83053. roughnessFactor?: number;
  83054. /**
  83055. * The metallic-roughness texture
  83056. */
  83057. metallicRoughnessTexture?: ITextureInfo;
  83058. }
  83059. /**
  83060. * The material appearance of a primitive
  83061. */
  83062. interface IMaterial extends IChildRootProperty {
  83063. /**
  83064. * 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
  83065. */
  83066. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83067. /**
  83068. * The normal map texture
  83069. */
  83070. normalTexture?: IMaterialNormalTextureInfo;
  83071. /**
  83072. * The occlusion map texture
  83073. */
  83074. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83075. /**
  83076. * The emissive map texture
  83077. */
  83078. emissiveTexture?: ITextureInfo;
  83079. /**
  83080. * 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
  83081. */
  83082. emissiveFactor?: number[];
  83083. /**
  83084. * The alpha rendering mode of the material
  83085. */
  83086. alphaMode?: MaterialAlphaMode;
  83087. /**
  83088. * The alpha cutoff value of the material
  83089. */
  83090. alphaCutoff?: number;
  83091. /**
  83092. * Specifies whether the material is double sided
  83093. */
  83094. doubleSided?: boolean;
  83095. }
  83096. /**
  83097. * Geometry to be rendered with the given material
  83098. */
  83099. interface IMeshPrimitive extends IProperty {
  83100. /**
  83101. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83102. */
  83103. attributes: {
  83104. [name: string]: number;
  83105. };
  83106. /**
  83107. * The index of the accessor that contains the indices
  83108. */
  83109. indices?: number;
  83110. /**
  83111. * The index of the material to apply to this primitive when rendering
  83112. */
  83113. material?: number;
  83114. /**
  83115. * The type of primitives to render. All valid values correspond to WebGL enums
  83116. */
  83117. mode?: MeshPrimitiveMode;
  83118. /**
  83119. * 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
  83120. */
  83121. targets?: {
  83122. [name: string]: number;
  83123. }[];
  83124. }
  83125. /**
  83126. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83127. */
  83128. interface IMesh extends IChildRootProperty {
  83129. /**
  83130. * An array of primitives, each defining geometry to be rendered with a material
  83131. */
  83132. primitives: IMeshPrimitive[];
  83133. /**
  83134. * Array of weights to be applied to the Morph Targets
  83135. */
  83136. weights?: number[];
  83137. }
  83138. /**
  83139. * A node in the node hierarchy
  83140. */
  83141. interface INode extends IChildRootProperty {
  83142. /**
  83143. * The index of the camera referenced by this node
  83144. */
  83145. camera?: number;
  83146. /**
  83147. * The indices of this node's children
  83148. */
  83149. children?: number[];
  83150. /**
  83151. * The index of the skin referenced by this node
  83152. */
  83153. skin?: number;
  83154. /**
  83155. * A floating-point 4x4 transformation matrix stored in column-major order
  83156. */
  83157. matrix?: number[];
  83158. /**
  83159. * The index of the mesh in this node
  83160. */
  83161. mesh?: number;
  83162. /**
  83163. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83164. */
  83165. rotation?: number[];
  83166. /**
  83167. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83168. */
  83169. scale?: number[];
  83170. /**
  83171. * The node's translation along the x, y, and z axes
  83172. */
  83173. translation?: number[];
  83174. /**
  83175. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83176. */
  83177. weights?: number[];
  83178. }
  83179. /**
  83180. * Texture sampler properties for filtering and wrapping modes
  83181. */
  83182. interface ISampler extends IChildRootProperty {
  83183. /**
  83184. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83185. */
  83186. magFilter?: TextureMagFilter;
  83187. /**
  83188. * Minification filter. All valid values correspond to WebGL enums
  83189. */
  83190. minFilter?: TextureMinFilter;
  83191. /**
  83192. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83193. */
  83194. wrapS?: TextureWrapMode;
  83195. /**
  83196. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83197. */
  83198. wrapT?: TextureWrapMode;
  83199. }
  83200. /**
  83201. * The root nodes of a scene
  83202. */
  83203. interface IScene extends IChildRootProperty {
  83204. /**
  83205. * The indices of each root node
  83206. */
  83207. nodes: number[];
  83208. }
  83209. /**
  83210. * Joints and matrices defining a skin
  83211. */
  83212. interface ISkin extends IChildRootProperty {
  83213. /**
  83214. * 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
  83215. */
  83216. inverseBindMatrices?: number;
  83217. /**
  83218. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83219. */
  83220. skeleton?: number;
  83221. /**
  83222. * 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)
  83223. */
  83224. joints: number[];
  83225. }
  83226. /**
  83227. * A texture and its sampler
  83228. */
  83229. interface ITexture extends IChildRootProperty {
  83230. /**
  83231. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83232. */
  83233. sampler?: number;
  83234. /**
  83235. * The index of the image used by this texture
  83236. */
  83237. source: number;
  83238. }
  83239. /**
  83240. * Reference to a texture
  83241. */
  83242. interface ITextureInfo extends IProperty {
  83243. /**
  83244. * The index of the texture
  83245. */
  83246. index: number;
  83247. /**
  83248. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83249. */
  83250. texCoord?: number;
  83251. }
  83252. /**
  83253. * The root object for a glTF asset
  83254. */
  83255. interface IGLTF extends IProperty {
  83256. /**
  83257. * An array of accessors. An accessor is a typed view into a bufferView
  83258. */
  83259. accessors?: IAccessor[];
  83260. /**
  83261. * An array of keyframe animations
  83262. */
  83263. animations?: IAnimation[];
  83264. /**
  83265. * Metadata about the glTF asset
  83266. */
  83267. asset: IAsset;
  83268. /**
  83269. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83270. */
  83271. buffers?: IBuffer[];
  83272. /**
  83273. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83274. */
  83275. bufferViews?: IBufferView[];
  83276. /**
  83277. * An array of cameras
  83278. */
  83279. cameras?: ICamera[];
  83280. /**
  83281. * Names of glTF extensions used somewhere in this asset
  83282. */
  83283. extensionsUsed?: string[];
  83284. /**
  83285. * Names of glTF extensions required to properly load this asset
  83286. */
  83287. extensionsRequired?: string[];
  83288. /**
  83289. * An array of images. An image defines data used to create a texture
  83290. */
  83291. images?: IImage[];
  83292. /**
  83293. * An array of materials. A material defines the appearance of a primitive
  83294. */
  83295. materials?: IMaterial[];
  83296. /**
  83297. * An array of meshes. A mesh is a set of primitives to be rendered
  83298. */
  83299. meshes?: IMesh[];
  83300. /**
  83301. * An array of nodes
  83302. */
  83303. nodes?: INode[];
  83304. /**
  83305. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83306. */
  83307. samplers?: ISampler[];
  83308. /**
  83309. * The index of the default scene
  83310. */
  83311. scene?: number;
  83312. /**
  83313. * An array of scenes
  83314. */
  83315. scenes?: IScene[];
  83316. /**
  83317. * An array of skins. A skin is defined by joints and matrices
  83318. */
  83319. skins?: ISkin[];
  83320. /**
  83321. * An array of textures
  83322. */
  83323. textures?: ITexture[];
  83324. }
  83325. /**
  83326. * The glTF validation results
  83327. * @ignore
  83328. */
  83329. interface IGLTFValidationResults {
  83330. info: {
  83331. generator: string;
  83332. hasAnimations: boolean;
  83333. hasDefaultScene: boolean;
  83334. hasMaterials: boolean;
  83335. hasMorphTargets: boolean;
  83336. hasSkins: boolean;
  83337. hasTextures: boolean;
  83338. maxAttributesUsed: number;
  83339. primitivesCount: number
  83340. };
  83341. issues: {
  83342. messages: Array<string>;
  83343. numErrors: number;
  83344. numHints: number;
  83345. numInfos: number;
  83346. numWarnings: number;
  83347. truncated: boolean
  83348. };
  83349. mimeType: string;
  83350. uri: string;
  83351. validatedAt: string;
  83352. validatorVersion: string;
  83353. }
  83354. /**
  83355. * The glTF validation options
  83356. */
  83357. interface IGLTFValidationOptions {
  83358. /** Uri to use */
  83359. uri?: string;
  83360. /** Function used to load external resources */
  83361. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83362. /** Boolean indicating that we need to validate accessor data */
  83363. validateAccessorData?: boolean;
  83364. /** max number of issues allowed */
  83365. maxIssues?: number;
  83366. /** Ignored issues */
  83367. ignoredIssues?: Array<string>;
  83368. /** Value to override severy settings */
  83369. severityOverrides?: Object;
  83370. }
  83371. /**
  83372. * The glTF validator object
  83373. * @ignore
  83374. */
  83375. interface IGLTFValidator {
  83376. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83377. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83378. }
  83379. /**
  83380. * Interfaces from the EXT_lights_image_based extension
  83381. */
  83382. /** @hidden */
  83383. interface IEXTLightsImageBased_LightReferenceImageBased {
  83384. light: number;
  83385. }
  83386. /** @hidden */
  83387. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83388. intensity: number;
  83389. rotation: number[];
  83390. specularImageSize: number;
  83391. specularImages: number[][];
  83392. irradianceCoefficients: number[][];
  83393. }
  83394. /** @hidden */
  83395. interface IEXTLightsImageBased {
  83396. lights: IEXTLightsImageBased_LightImageBased[];
  83397. }
  83398. /**
  83399. * Interfaces from the EXT_mesh_gpu_instancing extension
  83400. * !!! Experimental Extension Subject to Changes !!!
  83401. */
  83402. /** @hidden */
  83403. interface IEXTMeshGpuInstancing {
  83404. mesh?: number;
  83405. attributes: { [name: string]: number };
  83406. }
  83407. /**
  83408. * Interfaces from the KHR_draco_mesh_compression extension
  83409. */
  83410. /** @hidden */
  83411. interface IKHRDracoMeshCompression {
  83412. bufferView: number;
  83413. attributes: { [name: string]: number };
  83414. }
  83415. /**
  83416. * Interfaces from the KHR_lights_punctual extension
  83417. */
  83418. /** @hidden */
  83419. const enum IKHRLightsPunctual_LightType {
  83420. DIRECTIONAL = "directional",
  83421. POINT = "point",
  83422. SPOT = "spot"
  83423. }
  83424. /** @hidden */
  83425. interface IKHRLightsPunctual_LightReference {
  83426. light: number;
  83427. }
  83428. /** @hidden */
  83429. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83430. type: IKHRLightsPunctual_LightType;
  83431. color?: number[];
  83432. intensity?: number;
  83433. range?: number;
  83434. spot?: {
  83435. innerConeAngle?: number;
  83436. outerConeAngle?: number;
  83437. };
  83438. }
  83439. /** @hidden */
  83440. interface IKHRLightsPunctual {
  83441. lights: IKHRLightsPunctual_Light[];
  83442. }
  83443. /**
  83444. * Interfaces from the KHR_materials_clearcoat extension
  83445. * !!! Experimental Extension Subject to Changes !!!
  83446. */
  83447. /** @hidden */
  83448. interface IKHRMaterialsClearcoat {
  83449. clearcoatFactor: number;
  83450. clearcoatTexture: ITextureInfo;
  83451. clearcoatRoughnessFactor: number;
  83452. clearcoatRoughnessTexture: ITextureInfo;
  83453. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83454. }
  83455. /**
  83456. * Interfaces from the KHR_materials_ior extension
  83457. * !!! Experimental Extension Subject to Changes !!!
  83458. */
  83459. /** @hidden */
  83460. interface IKHRMaterialsIor {
  83461. ior: number;
  83462. }
  83463. /**
  83464. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83465. */
  83466. /** @hidden */
  83467. interface IKHRMaterialsPbrSpecularGlossiness {
  83468. diffuseFactor: number[];
  83469. diffuseTexture: ITextureInfo;
  83470. specularFactor: number[];
  83471. glossinessFactor: number;
  83472. specularGlossinessTexture: ITextureInfo;
  83473. }
  83474. /**
  83475. * Interfaces from the KHR_materials_sheen extension
  83476. * !!! Experimental Extension Subject to Changes !!!
  83477. */
  83478. /** @hidden */
  83479. interface IKHRMaterialsSheen {
  83480. sheenColorFactor?: number[];
  83481. sheenTexture?: ITextureInfo;
  83482. sheenRoughnessFactor?: number;
  83483. }
  83484. /**
  83485. * Interfaces from the KHR_materials_specular extension
  83486. * !!! Experimental Extension Subject to Changes !!!
  83487. */
  83488. /** @hidden */
  83489. interface IKHRMaterialsSpecular {
  83490. specularFactor: number;
  83491. specularColorFactor: number[];
  83492. specularTexture: ITextureInfo;
  83493. }
  83494. /**
  83495. * Interfaces from the KHR_materials_transmission extension
  83496. * !!! Experimental Extension Subject to Changes !!!
  83497. */
  83498. /** @hidden */
  83499. interface IKHRMaterialsTransmission {
  83500. transmissionFactor?: number;
  83501. transmissionTexture?: ITextureInfo;
  83502. }
  83503. /**
  83504. * Interfaces from the KHR_materials_variants extension
  83505. * !!! Experimental Extension Subject to Changes !!!
  83506. */
  83507. /** @hidden */
  83508. interface IKHRMaterialVariants_Mapping {
  83509. tags: string[];
  83510. material: number;
  83511. }
  83512. /** @hidden */
  83513. interface IKHRMaterialVariants {
  83514. mapping: IKHRMaterialVariants_Mapping[];
  83515. }
  83516. /**
  83517. * Interfaces from the KHR_texture_basisu extension
  83518. * !!! Experimental Extension Subject to Changes !!!
  83519. */
  83520. /** @hidden */
  83521. interface IKHRTextureBasisU {
  83522. source: number;
  83523. }
  83524. /**
  83525. * Interfaces from the KHR_texture_transform extension
  83526. */
  83527. /** @hidden */
  83528. interface IKHRTextureTransform {
  83529. offset?: number[];
  83530. rotation?: number;
  83531. scale?: number[];
  83532. texCoord?: number;
  83533. }
  83534. /**
  83535. * Interfaces from the KHR_xmp extension
  83536. * !!! Experimental Extension Subject to Changes !!!
  83537. */
  83538. /** @hidden */
  83539. interface IKHRXmp_Data {
  83540. [key: string]: unknown;
  83541. }
  83542. /** @hidden */
  83543. interface IKHRXmp_Gltf {
  83544. packets: IKHRXmp_Data[];
  83545. }
  83546. /** @hidden */
  83547. interface IKHRXmp_Node {
  83548. packet: number;
  83549. }
  83550. /**
  83551. * Interfaces from the MSFT_audio_emitter extension
  83552. */
  83553. /** @hidden */
  83554. interface IMSFTAudioEmitter_ClipReference {
  83555. clip: number;
  83556. weight?: number;
  83557. }
  83558. /** @hidden */
  83559. interface IMSFTAudioEmitter_EmittersReference {
  83560. emitters: number[];
  83561. }
  83562. /** @hidden */
  83563. const enum IMSFTAudioEmitter_DistanceModel {
  83564. linear = "linear",
  83565. inverse = "inverse",
  83566. exponential = "exponential",
  83567. }
  83568. /** @hidden */
  83569. interface IMSFTAudioEmitter_Emitter {
  83570. name?: string;
  83571. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  83572. refDistance?: number;
  83573. maxDistance?: number;
  83574. rolloffFactor?: number;
  83575. innerAngle?: number;
  83576. outerAngle?: number;
  83577. loop?: boolean;
  83578. volume?: number;
  83579. clips: IMSFTAudioEmitter_ClipReference[];
  83580. }
  83581. /** @hidden */
  83582. const enum IMSFTAudioEmitter_AudioMimeType {
  83583. WAV = "audio/wav",
  83584. }
  83585. /** @hidden */
  83586. interface IMSFTAudioEmitter_Clip extends IProperty {
  83587. uri?: string;
  83588. bufferView?: number;
  83589. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  83590. }
  83591. /** @hidden */
  83592. const enum IMSFTAudioEmitter_AnimationEventAction {
  83593. play = "play",
  83594. pause = "pause",
  83595. stop = "stop",
  83596. }
  83597. /** @hidden */
  83598. interface IMSFTAudioEmitter_AnimationEvent {
  83599. action: IMSFTAudioEmitter_AnimationEventAction;
  83600. emitter: number;
  83601. time: number;
  83602. startOffset?: number;
  83603. }
  83604. /**
  83605. * Interfaces from the MSFT_lod extension
  83606. */
  83607. /** @hidden */
  83608. interface IMSFTLOD {
  83609. ids: number[];
  83610. }
  83611. }
  83612. declare module BABYLON {
  83613. /** @hidden */
  83614. export var cellPixelShader: {
  83615. name: string;
  83616. shader: string;
  83617. };
  83618. }
  83619. declare module BABYLON {
  83620. /** @hidden */
  83621. export var cellVertexShader: {
  83622. name: string;
  83623. shader: string;
  83624. };
  83625. }
  83626. declare module BABYLON {
  83627. export class CellMaterial extends BABYLON.PushMaterial {
  83628. private _diffuseTexture;
  83629. diffuseTexture: BABYLON.BaseTexture;
  83630. diffuseColor: BABYLON.Color3;
  83631. _computeHighLevel: boolean;
  83632. computeHighLevel: boolean;
  83633. private _disableLighting;
  83634. disableLighting: boolean;
  83635. private _maxSimultaneousLights;
  83636. maxSimultaneousLights: number;
  83637. constructor(name: string, scene: BABYLON.Scene);
  83638. needAlphaBlending(): boolean;
  83639. needAlphaTesting(): boolean;
  83640. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83641. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83642. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83643. getAnimatables(): BABYLON.IAnimatable[];
  83644. getActiveTextures(): BABYLON.BaseTexture[];
  83645. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83646. dispose(forceDisposeEffect?: boolean): void;
  83647. getClassName(): string;
  83648. clone(name: string): CellMaterial;
  83649. serialize(): any;
  83650. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83651. }
  83652. }
  83653. declare module BABYLON {
  83654. export class CustomShaderStructure {
  83655. FragmentStore: string;
  83656. VertexStore: string;
  83657. constructor();
  83658. }
  83659. export class ShaderSpecialParts {
  83660. constructor();
  83661. Fragment_Begin: string;
  83662. Fragment_Definitions: string;
  83663. Fragment_MainBegin: string;
  83664. Fragment_Custom_Diffuse: string;
  83665. Fragment_Before_Lights: string;
  83666. Fragment_Before_Fog: string;
  83667. Fragment_Custom_Alpha: string;
  83668. Fragment_Before_FragColor: string;
  83669. Vertex_Begin: string;
  83670. Vertex_Definitions: string;
  83671. Vertex_MainBegin: string;
  83672. Vertex_Before_PositionUpdated: string;
  83673. Vertex_Before_NormalUpdated: string;
  83674. Vertex_After_WorldPosComputed: string;
  83675. Vertex_MainEnd: string;
  83676. }
  83677. export class CustomMaterial extends BABYLON.StandardMaterial {
  83678. static ShaderIndexer: number;
  83679. CustomParts: ShaderSpecialParts;
  83680. _isCreatedShader: boolean;
  83681. _createdShaderName: string;
  83682. _customUniform: string[];
  83683. _newUniforms: string[];
  83684. _newUniformInstances: {
  83685. [name: string]: any;
  83686. };
  83687. _newSamplerInstances: {
  83688. [name: string]: BABYLON.Texture;
  83689. };
  83690. _customAttributes: string[];
  83691. FragmentShader: string;
  83692. VertexShader: string;
  83693. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83694. ReviewUniform(name: string, arr: string[]): string[];
  83695. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83696. constructor(name: string, scene: BABYLON.Scene);
  83697. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  83698. AddAttribute(name: string): CustomMaterial;
  83699. Fragment_Begin(shaderPart: string): CustomMaterial;
  83700. Fragment_Definitions(shaderPart: string): CustomMaterial;
  83701. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  83702. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  83703. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  83704. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  83705. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  83706. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  83707. Vertex_Begin(shaderPart: string): CustomMaterial;
  83708. Vertex_Definitions(shaderPart: string): CustomMaterial;
  83709. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  83710. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  83711. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  83712. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  83713. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  83714. }
  83715. }
  83716. declare module BABYLON {
  83717. export class ShaderAlebdoParts {
  83718. constructor();
  83719. Fragment_Begin: string;
  83720. Fragment_Definitions: string;
  83721. Fragment_MainBegin: string;
  83722. Fragment_Custom_Albedo: string;
  83723. Fragment_Before_Lights: string;
  83724. Fragment_Custom_MetallicRoughness: string;
  83725. Fragment_Custom_MicroSurface: string;
  83726. Fragment_Before_Fog: string;
  83727. Fragment_Custom_Alpha: string;
  83728. Fragment_Before_FragColor: string;
  83729. Vertex_Begin: string;
  83730. Vertex_Definitions: string;
  83731. Vertex_MainBegin: string;
  83732. Vertex_Before_PositionUpdated: string;
  83733. Vertex_Before_NormalUpdated: string;
  83734. Vertex_After_WorldPosComputed: string;
  83735. Vertex_MainEnd: string;
  83736. }
  83737. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83738. static ShaderIndexer: number;
  83739. CustomParts: ShaderAlebdoParts;
  83740. _isCreatedShader: boolean;
  83741. _createdShaderName: string;
  83742. _customUniform: string[];
  83743. _newUniforms: string[];
  83744. _newUniformInstances: {
  83745. [name: string]: any;
  83746. };
  83747. _newSamplerInstances: {
  83748. [name: string]: BABYLON.Texture;
  83749. };
  83750. _customAttributes: string[];
  83751. FragmentShader: string;
  83752. VertexShader: string;
  83753. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83754. ReviewUniform(name: string, arr: string[]): string[];
  83755. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83756. constructor(name: string, scene: BABYLON.Scene);
  83757. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83758. AddAttribute(name: string): PBRCustomMaterial;
  83759. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83760. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83761. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83762. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83763. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83764. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83765. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83766. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83767. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83768. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83769. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83770. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83771. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83772. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83773. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83774. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83775. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83776. }
  83777. }
  83778. declare module BABYLON {
  83779. /** @hidden */
  83780. export var firePixelShader: {
  83781. name: string;
  83782. shader: string;
  83783. };
  83784. }
  83785. declare module BABYLON {
  83786. /** @hidden */
  83787. export var fireVertexShader: {
  83788. name: string;
  83789. shader: string;
  83790. };
  83791. }
  83792. declare module BABYLON {
  83793. export class FireMaterial extends BABYLON.PushMaterial {
  83794. private _diffuseTexture;
  83795. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83796. private _distortionTexture;
  83797. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83798. private _opacityTexture;
  83799. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83800. diffuseColor: BABYLON.Color3;
  83801. speed: number;
  83802. private _scaledDiffuse;
  83803. private _lastTime;
  83804. constructor(name: string, scene: BABYLON.Scene);
  83805. needAlphaBlending(): boolean;
  83806. needAlphaTesting(): boolean;
  83807. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83808. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83809. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83810. getAnimatables(): BABYLON.IAnimatable[];
  83811. getActiveTextures(): BABYLON.BaseTexture[];
  83812. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83813. getClassName(): string;
  83814. dispose(forceDisposeEffect?: boolean): void;
  83815. clone(name: string): FireMaterial;
  83816. serialize(): any;
  83817. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83818. }
  83819. }
  83820. declare module BABYLON {
  83821. /** @hidden */
  83822. export var furPixelShader: {
  83823. name: string;
  83824. shader: string;
  83825. };
  83826. }
  83827. declare module BABYLON {
  83828. /** @hidden */
  83829. export var furVertexShader: {
  83830. name: string;
  83831. shader: string;
  83832. };
  83833. }
  83834. declare module BABYLON {
  83835. export class FurMaterial extends BABYLON.PushMaterial {
  83836. private _diffuseTexture;
  83837. diffuseTexture: BABYLON.BaseTexture;
  83838. private _heightTexture;
  83839. heightTexture: BABYLON.BaseTexture;
  83840. diffuseColor: BABYLON.Color3;
  83841. furLength: number;
  83842. furAngle: number;
  83843. furColor: BABYLON.Color3;
  83844. furOffset: number;
  83845. furSpacing: number;
  83846. furGravity: BABYLON.Vector3;
  83847. furSpeed: number;
  83848. furDensity: number;
  83849. furOcclusion: number;
  83850. furTexture: BABYLON.DynamicTexture;
  83851. private _disableLighting;
  83852. disableLighting: boolean;
  83853. private _maxSimultaneousLights;
  83854. maxSimultaneousLights: number;
  83855. highLevelFur: boolean;
  83856. _meshes: BABYLON.AbstractMesh[];
  83857. private _furTime;
  83858. constructor(name: string, scene: BABYLON.Scene);
  83859. get furTime(): number;
  83860. set furTime(furTime: number);
  83861. needAlphaBlending(): boolean;
  83862. needAlphaTesting(): boolean;
  83863. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83864. updateFur(): void;
  83865. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83866. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83867. getAnimatables(): BABYLON.IAnimatable[];
  83868. getActiveTextures(): BABYLON.BaseTexture[];
  83869. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83870. dispose(forceDisposeEffect?: boolean): void;
  83871. clone(name: string): FurMaterial;
  83872. serialize(): any;
  83873. getClassName(): string;
  83874. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83875. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83876. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83877. }
  83878. }
  83879. declare module BABYLON {
  83880. /** @hidden */
  83881. export var gradientPixelShader: {
  83882. name: string;
  83883. shader: string;
  83884. };
  83885. }
  83886. declare module BABYLON {
  83887. /** @hidden */
  83888. export var gradientVertexShader: {
  83889. name: string;
  83890. shader: string;
  83891. };
  83892. }
  83893. declare module BABYLON {
  83894. export class GradientMaterial extends BABYLON.PushMaterial {
  83895. private _maxSimultaneousLights;
  83896. maxSimultaneousLights: number;
  83897. topColor: BABYLON.Color3;
  83898. topColorAlpha: number;
  83899. bottomColor: BABYLON.Color3;
  83900. bottomColorAlpha: number;
  83901. offset: number;
  83902. scale: number;
  83903. smoothness: number;
  83904. private _disableLighting;
  83905. disableLighting: boolean;
  83906. constructor(name: string, scene: BABYLON.Scene);
  83907. needAlphaBlending(): boolean;
  83908. needAlphaTesting(): boolean;
  83909. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83911. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83912. getAnimatables(): BABYLON.IAnimatable[];
  83913. dispose(forceDisposeEffect?: boolean): void;
  83914. clone(name: string): GradientMaterial;
  83915. serialize(): any;
  83916. getClassName(): string;
  83917. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83918. }
  83919. }
  83920. declare module BABYLON {
  83921. /** @hidden */
  83922. export var gridPixelShader: {
  83923. name: string;
  83924. shader: string;
  83925. };
  83926. }
  83927. declare module BABYLON {
  83928. /** @hidden */
  83929. export var gridVertexShader: {
  83930. name: string;
  83931. shader: string;
  83932. };
  83933. }
  83934. declare module BABYLON {
  83935. /**
  83936. * The grid materials allows you to wrap any shape with a grid.
  83937. * Colors are customizable.
  83938. */
  83939. export class GridMaterial extends BABYLON.PushMaterial {
  83940. /**
  83941. * Main color of the grid (e.g. between lines)
  83942. */
  83943. mainColor: BABYLON.Color3;
  83944. /**
  83945. * Color of the grid lines.
  83946. */
  83947. lineColor: BABYLON.Color3;
  83948. /**
  83949. * The scale of the grid compared to unit.
  83950. */
  83951. gridRatio: number;
  83952. /**
  83953. * Allows setting an offset for the grid lines.
  83954. */
  83955. gridOffset: BABYLON.Vector3;
  83956. /**
  83957. * The frequency of thicker lines.
  83958. */
  83959. majorUnitFrequency: number;
  83960. /**
  83961. * The visibility of minor units in the grid.
  83962. */
  83963. minorUnitVisibility: number;
  83964. /**
  83965. * The grid opacity outside of the lines.
  83966. */
  83967. opacity: number;
  83968. /**
  83969. * Determine RBG output is premultiplied by alpha value.
  83970. */
  83971. preMultiplyAlpha: boolean;
  83972. private _opacityTexture;
  83973. opacityTexture: BABYLON.BaseTexture;
  83974. private _gridControl;
  83975. /**
  83976. * constructor
  83977. * @param name The name given to the material in order to identify it afterwards.
  83978. * @param scene The scene the material is used in.
  83979. */
  83980. constructor(name: string, scene: BABYLON.Scene);
  83981. /**
  83982. * Returns wehter or not the grid requires alpha blending.
  83983. */
  83984. needAlphaBlending(): boolean;
  83985. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83986. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83987. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83988. /**
  83989. * Dispose the material and its associated resources.
  83990. * @param forceDisposeEffect will also dispose the used effect when true
  83991. */
  83992. dispose(forceDisposeEffect?: boolean): void;
  83993. clone(name: string): GridMaterial;
  83994. serialize(): any;
  83995. getClassName(): string;
  83996. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83997. }
  83998. }
  83999. declare module BABYLON {
  84000. /** @hidden */
  84001. export var lavaPixelShader: {
  84002. name: string;
  84003. shader: string;
  84004. };
  84005. }
  84006. declare module BABYLON {
  84007. /** @hidden */
  84008. export var lavaVertexShader: {
  84009. name: string;
  84010. shader: string;
  84011. };
  84012. }
  84013. declare module BABYLON {
  84014. export class LavaMaterial extends BABYLON.PushMaterial {
  84015. private _diffuseTexture;
  84016. diffuseTexture: BABYLON.BaseTexture;
  84017. noiseTexture: BABYLON.BaseTexture;
  84018. fogColor: BABYLON.Color3;
  84019. speed: number;
  84020. movingSpeed: number;
  84021. lowFrequencySpeed: number;
  84022. fogDensity: number;
  84023. private _lastTime;
  84024. diffuseColor: BABYLON.Color3;
  84025. private _disableLighting;
  84026. disableLighting: boolean;
  84027. private _unlit;
  84028. unlit: boolean;
  84029. private _maxSimultaneousLights;
  84030. maxSimultaneousLights: number;
  84031. private _scaledDiffuse;
  84032. constructor(name: string, scene: BABYLON.Scene);
  84033. needAlphaBlending(): boolean;
  84034. needAlphaTesting(): boolean;
  84035. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84036. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84037. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84038. getAnimatables(): BABYLON.IAnimatable[];
  84039. getActiveTextures(): BABYLON.BaseTexture[];
  84040. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84041. dispose(forceDisposeEffect?: boolean): void;
  84042. clone(name: string): LavaMaterial;
  84043. serialize(): any;
  84044. getClassName(): string;
  84045. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84046. }
  84047. }
  84048. declare module BABYLON {
  84049. /** @hidden */
  84050. export var mixPixelShader: {
  84051. name: string;
  84052. shader: string;
  84053. };
  84054. }
  84055. declare module BABYLON {
  84056. /** @hidden */
  84057. export var mixVertexShader: {
  84058. name: string;
  84059. shader: string;
  84060. };
  84061. }
  84062. declare module BABYLON {
  84063. export class MixMaterial extends BABYLON.PushMaterial {
  84064. /**
  84065. * Mix textures
  84066. */
  84067. private _mixTexture1;
  84068. mixTexture1: BABYLON.BaseTexture;
  84069. private _mixTexture2;
  84070. mixTexture2: BABYLON.BaseTexture;
  84071. /**
  84072. * Diffuse textures
  84073. */
  84074. private _diffuseTexture1;
  84075. diffuseTexture1: BABYLON.Texture;
  84076. private _diffuseTexture2;
  84077. diffuseTexture2: BABYLON.Texture;
  84078. private _diffuseTexture3;
  84079. diffuseTexture3: BABYLON.Texture;
  84080. private _diffuseTexture4;
  84081. diffuseTexture4: BABYLON.Texture;
  84082. private _diffuseTexture5;
  84083. diffuseTexture5: BABYLON.Texture;
  84084. private _diffuseTexture6;
  84085. diffuseTexture6: BABYLON.Texture;
  84086. private _diffuseTexture7;
  84087. diffuseTexture7: BABYLON.Texture;
  84088. private _diffuseTexture8;
  84089. diffuseTexture8: BABYLON.Texture;
  84090. /**
  84091. * Uniforms
  84092. */
  84093. diffuseColor: BABYLON.Color3;
  84094. specularColor: BABYLON.Color3;
  84095. specularPower: number;
  84096. private _disableLighting;
  84097. disableLighting: boolean;
  84098. private _maxSimultaneousLights;
  84099. maxSimultaneousLights: number;
  84100. constructor(name: string, scene: BABYLON.Scene);
  84101. needAlphaBlending(): boolean;
  84102. needAlphaTesting(): boolean;
  84103. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84104. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84105. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84106. getAnimatables(): BABYLON.IAnimatable[];
  84107. getActiveTextures(): BABYLON.BaseTexture[];
  84108. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84109. dispose(forceDisposeEffect?: boolean): void;
  84110. clone(name: string): MixMaterial;
  84111. serialize(): any;
  84112. getClassName(): string;
  84113. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84114. }
  84115. }
  84116. declare module BABYLON {
  84117. /** @hidden */
  84118. export var normalPixelShader: {
  84119. name: string;
  84120. shader: string;
  84121. };
  84122. }
  84123. declare module BABYLON {
  84124. /** @hidden */
  84125. export var normalVertexShader: {
  84126. name: string;
  84127. shader: string;
  84128. };
  84129. }
  84130. declare module BABYLON {
  84131. export class NormalMaterial extends BABYLON.PushMaterial {
  84132. private _diffuseTexture;
  84133. diffuseTexture: BABYLON.BaseTexture;
  84134. diffuseColor: BABYLON.Color3;
  84135. private _disableLighting;
  84136. disableLighting: boolean;
  84137. private _maxSimultaneousLights;
  84138. maxSimultaneousLights: number;
  84139. constructor(name: string, scene: BABYLON.Scene);
  84140. needAlphaBlending(): boolean;
  84141. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84142. needAlphaTesting(): boolean;
  84143. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84145. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84146. getAnimatables(): BABYLON.IAnimatable[];
  84147. getActiveTextures(): BABYLON.BaseTexture[];
  84148. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84149. dispose(forceDisposeEffect?: boolean): void;
  84150. clone(name: string): NormalMaterial;
  84151. serialize(): any;
  84152. getClassName(): string;
  84153. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84154. }
  84155. }
  84156. declare module BABYLON {
  84157. /** @hidden */
  84158. export var shadowOnlyPixelShader: {
  84159. name: string;
  84160. shader: string;
  84161. };
  84162. }
  84163. declare module BABYLON {
  84164. /** @hidden */
  84165. export var shadowOnlyVertexShader: {
  84166. name: string;
  84167. shader: string;
  84168. };
  84169. }
  84170. declare module BABYLON {
  84171. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84172. private _activeLight;
  84173. private _needAlphaBlending;
  84174. constructor(name: string, scene: BABYLON.Scene);
  84175. shadowColor: BABYLON.Color3;
  84176. needAlphaBlending(): boolean;
  84177. needAlphaTesting(): boolean;
  84178. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84179. get activeLight(): BABYLON.IShadowLight;
  84180. set activeLight(light: BABYLON.IShadowLight);
  84181. private _getFirstShadowLightForMesh;
  84182. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84183. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84184. clone(name: string): ShadowOnlyMaterial;
  84185. serialize(): any;
  84186. getClassName(): string;
  84187. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84188. }
  84189. }
  84190. declare module BABYLON {
  84191. /** @hidden */
  84192. export var simplePixelShader: {
  84193. name: string;
  84194. shader: string;
  84195. };
  84196. }
  84197. declare module BABYLON {
  84198. /** @hidden */
  84199. export var simpleVertexShader: {
  84200. name: string;
  84201. shader: string;
  84202. };
  84203. }
  84204. declare module BABYLON {
  84205. export class SimpleMaterial extends BABYLON.PushMaterial {
  84206. private _diffuseTexture;
  84207. diffuseTexture: BABYLON.BaseTexture;
  84208. diffuseColor: BABYLON.Color3;
  84209. private _disableLighting;
  84210. disableLighting: boolean;
  84211. private _maxSimultaneousLights;
  84212. maxSimultaneousLights: number;
  84213. constructor(name: string, scene: BABYLON.Scene);
  84214. needAlphaBlending(): boolean;
  84215. needAlphaTesting(): boolean;
  84216. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84217. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84218. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84219. getAnimatables(): BABYLON.IAnimatable[];
  84220. getActiveTextures(): BABYLON.BaseTexture[];
  84221. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84222. dispose(forceDisposeEffect?: boolean): void;
  84223. clone(name: string): SimpleMaterial;
  84224. serialize(): any;
  84225. getClassName(): string;
  84226. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84227. }
  84228. }
  84229. declare module BABYLON {
  84230. /** @hidden */
  84231. export var skyPixelShader: {
  84232. name: string;
  84233. shader: string;
  84234. };
  84235. }
  84236. declare module BABYLON {
  84237. /** @hidden */
  84238. export var skyVertexShader: {
  84239. name: string;
  84240. shader: string;
  84241. };
  84242. }
  84243. declare module BABYLON {
  84244. /**
  84245. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84246. * @see https://doc.babylonjs.com/extensions/sky
  84247. */
  84248. export class SkyMaterial extends BABYLON.PushMaterial {
  84249. /**
  84250. * Defines the overall luminance of sky in interval ]0, 1[.
  84251. */
  84252. luminance: number;
  84253. /**
  84254. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84255. */
  84256. turbidity: number;
  84257. /**
  84258. * Defines the sky appearance (light intensity).
  84259. */
  84260. rayleigh: number;
  84261. /**
  84262. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84263. */
  84264. mieCoefficient: number;
  84265. /**
  84266. * Defines the amount of haze particles following the Mie scattering theory.
  84267. */
  84268. mieDirectionalG: number;
  84269. /**
  84270. * Defines the distance of the sun according to the active scene camera.
  84271. */
  84272. distance: number;
  84273. /**
  84274. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84275. * "inclined".
  84276. */
  84277. inclination: number;
  84278. /**
  84279. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84280. * an object direction and a reference direction.
  84281. */
  84282. azimuth: number;
  84283. /**
  84284. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84285. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84286. */
  84287. sunPosition: BABYLON.Vector3;
  84288. /**
  84289. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84290. * .sunPosition property.
  84291. */
  84292. useSunPosition: boolean;
  84293. /**
  84294. * Defines an offset vector used to get a horizon offset.
  84295. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84296. */
  84297. cameraOffset: BABYLON.Vector3;
  84298. private _cameraPosition;
  84299. /**
  84300. * Instantiates a new sky material.
  84301. * This material allows to create dynamic and texture free
  84302. * effects for skyboxes by taking care of the atmosphere state.
  84303. * @see https://doc.babylonjs.com/extensions/sky
  84304. * @param name Define the name of the material in the scene
  84305. * @param scene Define the scene the material belong to
  84306. */
  84307. constructor(name: string, scene: BABYLON.Scene);
  84308. /**
  84309. * Specifies if the material will require alpha blending
  84310. * @returns a boolean specifying if alpha blending is needed
  84311. */
  84312. needAlphaBlending(): boolean;
  84313. /**
  84314. * Specifies if this material should be rendered in alpha test mode
  84315. * @returns false as the sky material doesn't need alpha testing.
  84316. */
  84317. needAlphaTesting(): boolean;
  84318. /**
  84319. * Get the texture used for alpha test purpose.
  84320. * @returns null as the sky material has no texture.
  84321. */
  84322. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84323. /**
  84324. * Get if the submesh is ready to be used and all its information available.
  84325. * Child classes can use it to update shaders
  84326. * @param mesh defines the mesh to check
  84327. * @param subMesh defines which submesh to check
  84328. * @param useInstances specifies that instances should be used
  84329. * @returns a boolean indicating that the submesh is ready or not
  84330. */
  84331. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84332. /**
  84333. * Binds the submesh to this material by preparing the effect and shader to draw
  84334. * @param world defines the world transformation matrix
  84335. * @param mesh defines the mesh containing the submesh
  84336. * @param subMesh defines the submesh to bind the material to
  84337. */
  84338. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84339. /**
  84340. * Get the list of animatables in the material.
  84341. * @returns the list of animatables object used in the material
  84342. */
  84343. getAnimatables(): BABYLON.IAnimatable[];
  84344. /**
  84345. * Disposes the material
  84346. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84347. */
  84348. dispose(forceDisposeEffect?: boolean): void;
  84349. /**
  84350. * Makes a duplicate of the material, and gives it a new name
  84351. * @param name defines the new name for the duplicated material
  84352. * @returns the cloned material
  84353. */
  84354. clone(name: string): SkyMaterial;
  84355. /**
  84356. * Serializes this material in a JSON representation
  84357. * @returns the serialized material object
  84358. */
  84359. serialize(): any;
  84360. /**
  84361. * Gets the current class name of the material e.g. "SkyMaterial"
  84362. * Mainly use in serialization.
  84363. * @returns the class name
  84364. */
  84365. getClassName(): string;
  84366. /**
  84367. * Creates a sky material from parsed material data
  84368. * @param source defines the JSON representation of the material
  84369. * @param scene defines the hosting scene
  84370. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84371. * @returns a new sky material
  84372. */
  84373. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84374. }
  84375. }
  84376. declare module BABYLON {
  84377. /** @hidden */
  84378. export var terrainPixelShader: {
  84379. name: string;
  84380. shader: string;
  84381. };
  84382. }
  84383. declare module BABYLON {
  84384. /** @hidden */
  84385. export var terrainVertexShader: {
  84386. name: string;
  84387. shader: string;
  84388. };
  84389. }
  84390. declare module BABYLON {
  84391. export class TerrainMaterial extends BABYLON.PushMaterial {
  84392. private _mixTexture;
  84393. mixTexture: BABYLON.BaseTexture;
  84394. private _diffuseTexture1;
  84395. diffuseTexture1: BABYLON.Texture;
  84396. private _diffuseTexture2;
  84397. diffuseTexture2: BABYLON.Texture;
  84398. private _diffuseTexture3;
  84399. diffuseTexture3: BABYLON.Texture;
  84400. private _bumpTexture1;
  84401. bumpTexture1: BABYLON.Texture;
  84402. private _bumpTexture2;
  84403. bumpTexture2: BABYLON.Texture;
  84404. private _bumpTexture3;
  84405. bumpTexture3: BABYLON.Texture;
  84406. diffuseColor: BABYLON.Color3;
  84407. specularColor: BABYLON.Color3;
  84408. specularPower: number;
  84409. private _disableLighting;
  84410. disableLighting: boolean;
  84411. private _maxSimultaneousLights;
  84412. maxSimultaneousLights: number;
  84413. constructor(name: string, scene: BABYLON.Scene);
  84414. needAlphaBlending(): boolean;
  84415. needAlphaTesting(): boolean;
  84416. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84417. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84418. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84419. getAnimatables(): BABYLON.IAnimatable[];
  84420. getActiveTextures(): BABYLON.BaseTexture[];
  84421. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84422. dispose(forceDisposeEffect?: boolean): void;
  84423. clone(name: string): TerrainMaterial;
  84424. serialize(): any;
  84425. getClassName(): string;
  84426. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84427. }
  84428. }
  84429. declare module BABYLON {
  84430. /** @hidden */
  84431. export var triplanarPixelShader: {
  84432. name: string;
  84433. shader: string;
  84434. };
  84435. }
  84436. declare module BABYLON {
  84437. /** @hidden */
  84438. export var triplanarVertexShader: {
  84439. name: string;
  84440. shader: string;
  84441. };
  84442. }
  84443. declare module BABYLON {
  84444. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84445. mixTexture: BABYLON.BaseTexture;
  84446. private _diffuseTextureX;
  84447. diffuseTextureX: BABYLON.BaseTexture;
  84448. private _diffuseTextureY;
  84449. diffuseTextureY: BABYLON.BaseTexture;
  84450. private _diffuseTextureZ;
  84451. diffuseTextureZ: BABYLON.BaseTexture;
  84452. private _normalTextureX;
  84453. normalTextureX: BABYLON.BaseTexture;
  84454. private _normalTextureY;
  84455. normalTextureY: BABYLON.BaseTexture;
  84456. private _normalTextureZ;
  84457. normalTextureZ: BABYLON.BaseTexture;
  84458. tileSize: number;
  84459. diffuseColor: BABYLON.Color3;
  84460. specularColor: BABYLON.Color3;
  84461. specularPower: number;
  84462. private _disableLighting;
  84463. disableLighting: boolean;
  84464. private _maxSimultaneousLights;
  84465. maxSimultaneousLights: number;
  84466. constructor(name: string, scene: BABYLON.Scene);
  84467. needAlphaBlending(): boolean;
  84468. needAlphaTesting(): boolean;
  84469. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84470. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84471. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84472. getAnimatables(): BABYLON.IAnimatable[];
  84473. getActiveTextures(): BABYLON.BaseTexture[];
  84474. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84475. dispose(forceDisposeEffect?: boolean): void;
  84476. clone(name: string): TriPlanarMaterial;
  84477. serialize(): any;
  84478. getClassName(): string;
  84479. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84480. }
  84481. }
  84482. declare module BABYLON {
  84483. /** @hidden */
  84484. export var waterPixelShader: {
  84485. name: string;
  84486. shader: string;
  84487. };
  84488. }
  84489. declare module BABYLON {
  84490. /** @hidden */
  84491. export var waterVertexShader: {
  84492. name: string;
  84493. shader: string;
  84494. };
  84495. }
  84496. declare module BABYLON {
  84497. export class WaterMaterial extends BABYLON.PushMaterial {
  84498. renderTargetSize: BABYLON.Vector2;
  84499. private _bumpTexture;
  84500. bumpTexture: BABYLON.BaseTexture;
  84501. diffuseColor: BABYLON.Color3;
  84502. specularColor: BABYLON.Color3;
  84503. specularPower: number;
  84504. private _disableLighting;
  84505. disableLighting: boolean;
  84506. private _maxSimultaneousLights;
  84507. maxSimultaneousLights: number;
  84508. /**
  84509. * @param {number}: Represents the wind force
  84510. */
  84511. windForce: number;
  84512. /**
  84513. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84514. */
  84515. windDirection: BABYLON.Vector2;
  84516. /**
  84517. * @param {number}: Wave height, represents the height of the waves
  84518. */
  84519. waveHeight: number;
  84520. /**
  84521. * @param {number}: Bump height, represents the bump height related to the bump map
  84522. */
  84523. bumpHeight: number;
  84524. /**
  84525. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84526. */
  84527. private _bumpSuperimpose;
  84528. bumpSuperimpose: boolean;
  84529. /**
  84530. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84531. */
  84532. private _fresnelSeparate;
  84533. fresnelSeparate: boolean;
  84534. /**
  84535. * @param {boolean}: bump Waves modify the reflection.
  84536. */
  84537. private _bumpAffectsReflection;
  84538. bumpAffectsReflection: boolean;
  84539. /**
  84540. * @param {number}: The water color blended with the refraction (near)
  84541. */
  84542. waterColor: BABYLON.Color3;
  84543. /**
  84544. * @param {number}: The blend factor related to the water color
  84545. */
  84546. colorBlendFactor: number;
  84547. /**
  84548. * @param {number}: The water color blended with the reflection (far)
  84549. */
  84550. waterColor2: BABYLON.Color3;
  84551. /**
  84552. * @param {number}: The blend factor related to the water color (reflection, far)
  84553. */
  84554. colorBlendFactor2: number;
  84555. /**
  84556. * @param {number}: Represents the maximum length of a wave
  84557. */
  84558. waveLength: number;
  84559. /**
  84560. * @param {number}: Defines the waves speed
  84561. */
  84562. waveSpeed: number;
  84563. /**
  84564. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84565. * will avoid calculating useless pixels in the pixel shader of the water material.
  84566. */
  84567. disableClipPlane: boolean;
  84568. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84569. private _mesh;
  84570. private _refractionRTT;
  84571. private _reflectionRTT;
  84572. private _reflectionTransform;
  84573. private _lastTime;
  84574. private _lastDeltaTime;
  84575. private _useLogarithmicDepth;
  84576. private _waitingRenderList;
  84577. private _imageProcessingConfiguration;
  84578. private _imageProcessingObserver;
  84579. /**
  84580. * Gets a boolean indicating that current material needs to register RTT
  84581. */
  84582. get hasRenderTargetTextures(): boolean;
  84583. /**
  84584. * Constructor
  84585. */
  84586. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84587. get useLogarithmicDepth(): boolean;
  84588. set useLogarithmicDepth(value: boolean);
  84589. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84590. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84591. addToRenderList(node: any): void;
  84592. enableRenderTargets(enable: boolean): void;
  84593. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84594. get renderTargetsEnabled(): boolean;
  84595. needAlphaBlending(): boolean;
  84596. needAlphaTesting(): boolean;
  84597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84599. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84600. private _createRenderTargets;
  84601. getAnimatables(): BABYLON.IAnimatable[];
  84602. getActiveTextures(): BABYLON.BaseTexture[];
  84603. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84604. dispose(forceDisposeEffect?: boolean): void;
  84605. clone(name: string): WaterMaterial;
  84606. serialize(): any;
  84607. getClassName(): string;
  84608. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84609. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84610. }
  84611. }
  84612. declare module BABYLON {
  84613. /** @hidden */
  84614. export var asciiartPixelShader: {
  84615. name: string;
  84616. shader: string;
  84617. };
  84618. }
  84619. declare module BABYLON {
  84620. /**
  84621. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84622. *
  84623. * It basically takes care rendering the font front the given font size to a texture.
  84624. * This is used later on in the postprocess.
  84625. */
  84626. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84627. private _font;
  84628. private _text;
  84629. private _charSize;
  84630. /**
  84631. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84632. */
  84633. get charSize(): number;
  84634. /**
  84635. * Create a new instance of the Ascii Art FontTexture class
  84636. * @param name the name of the texture
  84637. * @param font the font to use, use the W3C CSS notation
  84638. * @param text the caracter set to use in the rendering.
  84639. * @param scene the scene that owns the texture
  84640. */
  84641. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84642. /**
  84643. * Gets the max char width of a font.
  84644. * @param font the font to use, use the W3C CSS notation
  84645. * @return the max char width
  84646. */
  84647. private getFontWidth;
  84648. /**
  84649. * Gets the max char height of a font.
  84650. * @param font the font to use, use the W3C CSS notation
  84651. * @return the max char height
  84652. */
  84653. private getFontHeight;
  84654. /**
  84655. * Clones the current AsciiArtTexture.
  84656. * @return the clone of the texture.
  84657. */
  84658. clone(): AsciiArtFontTexture;
  84659. /**
  84660. * Parses a json object representing the texture and returns an instance of it.
  84661. * @param source the source JSON representation
  84662. * @param scene the scene to create the texture for
  84663. * @return the parsed texture
  84664. */
  84665. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84666. }
  84667. /**
  84668. * Option available in the Ascii Art Post Process.
  84669. */
  84670. export interface IAsciiArtPostProcessOptions {
  84671. /**
  84672. * The font to use following the w3c font definition.
  84673. */
  84674. font?: string;
  84675. /**
  84676. * The character set to use in the postprocess.
  84677. */
  84678. characterSet?: string;
  84679. /**
  84680. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84681. * This number is defined between 0 and 1;
  84682. */
  84683. mixToTile?: number;
  84684. /**
  84685. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84686. * This number is defined between 0 and 1;
  84687. */
  84688. mixToNormal?: number;
  84689. }
  84690. /**
  84691. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  84692. *
  84693. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84694. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  84695. */
  84696. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  84697. /**
  84698. * The font texture used to render the char in the post process.
  84699. */
  84700. private _asciiArtFontTexture;
  84701. /**
  84702. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84703. * This number is defined between 0 and 1;
  84704. */
  84705. mixToTile: number;
  84706. /**
  84707. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84708. * This number is defined between 0 and 1;
  84709. */
  84710. mixToNormal: number;
  84711. /**
  84712. * Instantiates a new Ascii Art Post Process.
  84713. * @param name the name to give to the postprocess
  84714. * @camera the camera to apply the post process to.
  84715. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  84716. */
  84717. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  84718. }
  84719. }
  84720. declare module BABYLON {
  84721. /** @hidden */
  84722. export var digitalrainPixelShader: {
  84723. name: string;
  84724. shader: string;
  84725. };
  84726. }
  84727. declare module BABYLON {
  84728. /**
  84729. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84730. *
  84731. * It basically takes care rendering the font front the given font size to a texture.
  84732. * This is used later on in the postprocess.
  84733. */
  84734. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84735. private _font;
  84736. private _text;
  84737. private _charSize;
  84738. /**
  84739. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84740. */
  84741. get charSize(): number;
  84742. /**
  84743. * Create a new instance of the Digital Rain FontTexture class
  84744. * @param name the name of the texture
  84745. * @param font the font to use, use the W3C CSS notation
  84746. * @param text the caracter set to use in the rendering.
  84747. * @param scene the scene that owns the texture
  84748. */
  84749. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84750. /**
  84751. * Gets the max char width of a font.
  84752. * @param font the font to use, use the W3C CSS notation
  84753. * @return the max char width
  84754. */
  84755. private getFontWidth;
  84756. /**
  84757. * Gets the max char height of a font.
  84758. * @param font the font to use, use the W3C CSS notation
  84759. * @return the max char height
  84760. */
  84761. private getFontHeight;
  84762. /**
  84763. * Clones the current DigitalRainFontTexture.
  84764. * @return the clone of the texture.
  84765. */
  84766. clone(): DigitalRainFontTexture;
  84767. /**
  84768. * Parses a json object representing the texture and returns an instance of it.
  84769. * @param source the source JSON representation
  84770. * @param scene the scene to create the texture for
  84771. * @return the parsed texture
  84772. */
  84773. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84774. }
  84775. /**
  84776. * Option available in the Digital Rain Post Process.
  84777. */
  84778. export interface IDigitalRainPostProcessOptions {
  84779. /**
  84780. * The font to use following the w3c font definition.
  84781. */
  84782. font?: string;
  84783. /**
  84784. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84785. * This number is defined between 0 and 1;
  84786. */
  84787. mixToTile?: number;
  84788. /**
  84789. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84790. * This number is defined between 0 and 1;
  84791. */
  84792. mixToNormal?: number;
  84793. }
  84794. /**
  84795. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84796. *
  84797. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84798. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84799. */
  84800. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84801. /**
  84802. * The font texture used to render the char in the post process.
  84803. */
  84804. private _digitalRainFontTexture;
  84805. /**
  84806. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84807. * This number is defined between 0 and 1;
  84808. */
  84809. mixToTile: number;
  84810. /**
  84811. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84812. * This number is defined between 0 and 1;
  84813. */
  84814. mixToNormal: number;
  84815. /**
  84816. * Instantiates a new Digital Rain Post Process.
  84817. * @param name the name to give to the postprocess
  84818. * @camera the camera to apply the post process to.
  84819. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84820. */
  84821. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84822. }
  84823. }
  84824. declare module BABYLON {
  84825. /** @hidden */
  84826. export var brickProceduralTexturePixelShader: {
  84827. name: string;
  84828. shader: string;
  84829. };
  84830. }
  84831. declare module BABYLON {
  84832. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84833. private _numberOfBricksHeight;
  84834. private _numberOfBricksWidth;
  84835. private _jointColor;
  84836. private _brickColor;
  84837. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84838. updateShaderUniforms(): void;
  84839. get numberOfBricksHeight(): number;
  84840. set numberOfBricksHeight(value: number);
  84841. get numberOfBricksWidth(): number;
  84842. set numberOfBricksWidth(value: number);
  84843. get jointColor(): BABYLON.Color3;
  84844. set jointColor(value: BABYLON.Color3);
  84845. get brickColor(): BABYLON.Color3;
  84846. set brickColor(value: BABYLON.Color3);
  84847. /**
  84848. * Serializes this brick procedural texture
  84849. * @returns a serialized brick procedural texture object
  84850. */
  84851. serialize(): any;
  84852. /**
  84853. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84854. * @param parsedTexture defines parsed texture data
  84855. * @param scene defines the current scene
  84856. * @param rootUrl defines the root URL containing brick procedural texture information
  84857. * @returns a parsed Brick Procedural BABYLON.Texture
  84858. */
  84859. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84860. }
  84861. }
  84862. declare module BABYLON {
  84863. /** @hidden */
  84864. export var cloudProceduralTexturePixelShader: {
  84865. name: string;
  84866. shader: string;
  84867. };
  84868. }
  84869. declare module BABYLON {
  84870. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84871. private _skyColor;
  84872. private _cloudColor;
  84873. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84874. updateShaderUniforms(): void;
  84875. get skyColor(): BABYLON.Color4;
  84876. set skyColor(value: BABYLON.Color4);
  84877. get cloudColor(): BABYLON.Color4;
  84878. set cloudColor(value: BABYLON.Color4);
  84879. /**
  84880. * Serializes this cloud procedural texture
  84881. * @returns a serialized cloud procedural texture object
  84882. */
  84883. serialize(): any;
  84884. /**
  84885. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84886. * @param parsedTexture defines parsed texture data
  84887. * @param scene defines the current scene
  84888. * @param rootUrl defines the root URL containing cloud procedural texture information
  84889. * @returns a parsed Cloud Procedural BABYLON.Texture
  84890. */
  84891. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84892. }
  84893. }
  84894. declare module BABYLON {
  84895. /** @hidden */
  84896. export var fireProceduralTexturePixelShader: {
  84897. name: string;
  84898. shader: string;
  84899. };
  84900. }
  84901. declare module BABYLON {
  84902. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84903. private _time;
  84904. private _speed;
  84905. private _autoGenerateTime;
  84906. private _fireColors;
  84907. private _alphaThreshold;
  84908. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84909. updateShaderUniforms(): void;
  84910. render(useCameraPostProcess?: boolean): void;
  84911. static get PurpleFireColors(): BABYLON.Color3[];
  84912. static get GreenFireColors(): BABYLON.Color3[];
  84913. static get RedFireColors(): BABYLON.Color3[];
  84914. static get BlueFireColors(): BABYLON.Color3[];
  84915. get autoGenerateTime(): boolean;
  84916. set autoGenerateTime(value: boolean);
  84917. get fireColors(): BABYLON.Color3[];
  84918. set fireColors(value: BABYLON.Color3[]);
  84919. get time(): number;
  84920. set time(value: number);
  84921. get speed(): BABYLON.Vector2;
  84922. set speed(value: BABYLON.Vector2);
  84923. get alphaThreshold(): number;
  84924. set alphaThreshold(value: number);
  84925. /**
  84926. * Serializes this fire procedural texture
  84927. * @returns a serialized fire procedural texture object
  84928. */
  84929. serialize(): any;
  84930. /**
  84931. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84932. * @param parsedTexture defines parsed texture data
  84933. * @param scene defines the current scene
  84934. * @param rootUrl defines the root URL containing fire procedural texture information
  84935. * @returns a parsed Fire Procedural BABYLON.Texture
  84936. */
  84937. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84938. }
  84939. }
  84940. declare module BABYLON {
  84941. /** @hidden */
  84942. export var grassProceduralTexturePixelShader: {
  84943. name: string;
  84944. shader: string;
  84945. };
  84946. }
  84947. declare module BABYLON {
  84948. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84949. private _grassColors;
  84950. private _groundColor;
  84951. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84952. updateShaderUniforms(): void;
  84953. get grassColors(): BABYLON.Color3[];
  84954. set grassColors(value: BABYLON.Color3[]);
  84955. get groundColor(): BABYLON.Color3;
  84956. set groundColor(value: BABYLON.Color3);
  84957. /**
  84958. * Serializes this grass procedural texture
  84959. * @returns a serialized grass procedural texture object
  84960. */
  84961. serialize(): any;
  84962. /**
  84963. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84964. * @param parsedTexture defines parsed texture data
  84965. * @param scene defines the current scene
  84966. * @param rootUrl defines the root URL containing grass procedural texture information
  84967. * @returns a parsed Grass Procedural BABYLON.Texture
  84968. */
  84969. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84970. }
  84971. }
  84972. declare module BABYLON {
  84973. /** @hidden */
  84974. export var marbleProceduralTexturePixelShader: {
  84975. name: string;
  84976. shader: string;
  84977. };
  84978. }
  84979. declare module BABYLON {
  84980. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84981. private _numberOfTilesHeight;
  84982. private _numberOfTilesWidth;
  84983. private _amplitude;
  84984. private _jointColor;
  84985. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84986. updateShaderUniforms(): void;
  84987. get numberOfTilesHeight(): number;
  84988. set numberOfTilesHeight(value: number);
  84989. get amplitude(): number;
  84990. set amplitude(value: number);
  84991. get numberOfTilesWidth(): number;
  84992. set numberOfTilesWidth(value: number);
  84993. get jointColor(): BABYLON.Color3;
  84994. set jointColor(value: BABYLON.Color3);
  84995. /**
  84996. * Serializes this marble procedural texture
  84997. * @returns a serialized marble procedural texture object
  84998. */
  84999. serialize(): any;
  85000. /**
  85001. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85002. * @param parsedTexture defines parsed texture data
  85003. * @param scene defines the current scene
  85004. * @param rootUrl defines the root URL containing marble procedural texture information
  85005. * @returns a parsed Marble Procedural BABYLON.Texture
  85006. */
  85007. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85008. }
  85009. }
  85010. declare module BABYLON {
  85011. /** @hidden */
  85012. export var normalMapProceduralTexturePixelShader: {
  85013. name: string;
  85014. shader: string;
  85015. };
  85016. }
  85017. declare module BABYLON {
  85018. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85019. private _baseTexture;
  85020. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85021. updateShaderUniforms(): void;
  85022. render(useCameraPostProcess?: boolean): void;
  85023. resize(size: any, generateMipMaps: any): void;
  85024. get baseTexture(): BABYLON.Texture;
  85025. set baseTexture(texture: BABYLON.Texture);
  85026. /**
  85027. * Serializes this normal map procedural texture
  85028. * @returns a serialized normal map procedural texture object
  85029. */
  85030. serialize(): any;
  85031. /**
  85032. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85033. * @param parsedTexture defines parsed texture data
  85034. * @param scene defines the current scene
  85035. * @param rootUrl defines the root URL containing normal map procedural texture information
  85036. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85037. */
  85038. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85039. }
  85040. }
  85041. declare module BABYLON {
  85042. /** @hidden */
  85043. export var perlinNoiseProceduralTexturePixelShader: {
  85044. name: string;
  85045. shader: string;
  85046. };
  85047. }
  85048. declare module BABYLON {
  85049. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85050. time: number;
  85051. timeScale: number;
  85052. translationSpeed: number;
  85053. private _currentTranslation;
  85054. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85055. updateShaderUniforms(): void;
  85056. render(useCameraPostProcess?: boolean): void;
  85057. resize(size: any, generateMipMaps: any): void;
  85058. /**
  85059. * Serializes this perlin noise procedural texture
  85060. * @returns a serialized perlin noise procedural texture object
  85061. */
  85062. serialize(): any;
  85063. /**
  85064. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85065. * @param parsedTexture defines parsed texture data
  85066. * @param scene defines the current scene
  85067. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85068. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85069. */
  85070. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85071. }
  85072. }
  85073. declare module BABYLON {
  85074. /** @hidden */
  85075. export var roadProceduralTexturePixelShader: {
  85076. name: string;
  85077. shader: string;
  85078. };
  85079. }
  85080. declare module BABYLON {
  85081. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85082. private _roadColor;
  85083. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85084. updateShaderUniforms(): void;
  85085. get roadColor(): BABYLON.Color3;
  85086. set roadColor(value: BABYLON.Color3);
  85087. /**
  85088. * Serializes this road procedural texture
  85089. * @returns a serialized road procedural texture object
  85090. */
  85091. serialize(): any;
  85092. /**
  85093. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85094. * @param parsedTexture defines parsed texture data
  85095. * @param scene defines the current scene
  85096. * @param rootUrl defines the root URL containing road procedural texture information
  85097. * @returns a parsed Road Procedural BABYLON.Texture
  85098. */
  85099. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85100. }
  85101. }
  85102. declare module BABYLON {
  85103. /** @hidden */
  85104. export var starfieldProceduralTexturePixelShader: {
  85105. name: string;
  85106. shader: string;
  85107. };
  85108. }
  85109. declare module BABYLON {
  85110. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85111. private _time;
  85112. private _alpha;
  85113. private _beta;
  85114. private _zoom;
  85115. private _formuparam;
  85116. private _stepsize;
  85117. private _tile;
  85118. private _brightness;
  85119. private _darkmatter;
  85120. private _distfading;
  85121. private _saturation;
  85122. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85123. updateShaderUniforms(): void;
  85124. get time(): number;
  85125. set time(value: number);
  85126. get alpha(): number;
  85127. set alpha(value: number);
  85128. get beta(): number;
  85129. set beta(value: number);
  85130. get formuparam(): number;
  85131. set formuparam(value: number);
  85132. get stepsize(): number;
  85133. set stepsize(value: number);
  85134. get zoom(): number;
  85135. set zoom(value: number);
  85136. get tile(): number;
  85137. set tile(value: number);
  85138. get brightness(): number;
  85139. set brightness(value: number);
  85140. get darkmatter(): number;
  85141. set darkmatter(value: number);
  85142. get distfading(): number;
  85143. set distfading(value: number);
  85144. get saturation(): number;
  85145. set saturation(value: number);
  85146. /**
  85147. * Serializes this starfield procedural texture
  85148. * @returns a serialized starfield procedural texture object
  85149. */
  85150. serialize(): any;
  85151. /**
  85152. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85153. * @param parsedTexture defines parsed texture data
  85154. * @param scene defines the current scene
  85155. * @param rootUrl defines the root URL containing startfield procedural texture information
  85156. * @returns a parsed Starfield Procedural BABYLON.Texture
  85157. */
  85158. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85159. }
  85160. }
  85161. declare module BABYLON {
  85162. /** @hidden */
  85163. export var woodProceduralTexturePixelShader: {
  85164. name: string;
  85165. shader: string;
  85166. };
  85167. }
  85168. declare module BABYLON {
  85169. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85170. private _ampScale;
  85171. private _woodColor;
  85172. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85173. updateShaderUniforms(): void;
  85174. get ampScale(): number;
  85175. set ampScale(value: number);
  85176. get woodColor(): BABYLON.Color3;
  85177. set woodColor(value: BABYLON.Color3);
  85178. /**
  85179. * Serializes this wood procedural texture
  85180. * @returns a serialized wood procedural texture object
  85181. */
  85182. serialize(): any;
  85183. /**
  85184. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85185. * @param parsedTexture defines parsed texture data
  85186. * @param scene defines the current scene
  85187. * @param rootUrl defines the root URL containing wood procedural texture information
  85188. * @returns a parsed Wood Procedural BABYLON.Texture
  85189. */
  85190. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85191. }
  85192. }