documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039
  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. * Creates a new geometry
  24678. * @param id defines the unique ID
  24679. * @param scene defines the hosting scene
  24680. * @param vertexData defines the VertexData used to get geometry data
  24681. * @param updatable defines if geometry must be updatable (false by default)
  24682. * @param mesh defines the mesh that will be associated with the geometry
  24683. */
  24684. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24685. /**
  24686. * Gets the current extend of the geometry
  24687. */
  24688. get extend(): {
  24689. minimum: Vector3;
  24690. maximum: Vector3;
  24691. };
  24692. /**
  24693. * Gets the hosting scene
  24694. * @returns the hosting Scene
  24695. */
  24696. getScene(): Scene;
  24697. /**
  24698. * Gets the hosting engine
  24699. * @returns the hosting Engine
  24700. */
  24701. getEngine(): Engine;
  24702. /**
  24703. * Defines if the geometry is ready to use
  24704. * @returns true if the geometry is ready to be used
  24705. */
  24706. isReady(): boolean;
  24707. /**
  24708. * Gets a value indicating that the geometry should not be serialized
  24709. */
  24710. get doNotSerialize(): boolean;
  24711. /** @hidden */
  24712. _rebuild(): void;
  24713. /**
  24714. * Affects all geometry data in one call
  24715. * @param vertexData defines the geometry data
  24716. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24717. */
  24718. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24719. /**
  24720. * Set specific vertex data
  24721. * @param kind defines the data kind (Position, normal, etc...)
  24722. * @param data defines the vertex data to use
  24723. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24724. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24725. */
  24726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24727. /**
  24728. * Removes a specific vertex data
  24729. * @param kind defines the data kind (Position, normal, etc...)
  24730. */
  24731. removeVerticesData(kind: string): void;
  24732. /**
  24733. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24734. * @param buffer defines the vertex buffer to use
  24735. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24736. */
  24737. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24738. /**
  24739. * Update a specific vertex buffer
  24740. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24741. * It will do nothing if the buffer is not updatable
  24742. * @param kind defines the data kind (Position, normal, etc...)
  24743. * @param data defines the data to use
  24744. * @param offset defines the offset in the target buffer where to store the data
  24745. * @param useBytes set to true if the offset is in bytes
  24746. */
  24747. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24748. /**
  24749. * Update a specific vertex buffer
  24750. * This function will create a new buffer if the current one is not updatable
  24751. * @param kind defines the data kind (Position, normal, etc...)
  24752. * @param data defines the data to use
  24753. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24754. */
  24755. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24756. private _updateBoundingInfo;
  24757. /** @hidden */
  24758. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24759. /**
  24760. * Gets total number of vertices
  24761. * @returns the total number of vertices
  24762. */
  24763. getTotalVertices(): number;
  24764. /**
  24765. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24766. * @param kind defines the data kind (Position, normal, etc...)
  24767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24769. * @returns a float array containing vertex data
  24770. */
  24771. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24772. /**
  24773. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24774. * @param kind defines the data kind (Position, normal, etc...)
  24775. * @returns true if the vertex buffer with the specified kind is updatable
  24776. */
  24777. isVertexBufferUpdatable(kind: string): boolean;
  24778. /**
  24779. * Gets a specific vertex buffer
  24780. * @param kind defines the data kind (Position, normal, etc...)
  24781. * @returns a VertexBuffer
  24782. */
  24783. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24784. /**
  24785. * Returns all vertex buffers
  24786. * @return an object holding all vertex buffers indexed by kind
  24787. */
  24788. getVertexBuffers(): Nullable<{
  24789. [key: string]: VertexBuffer;
  24790. }>;
  24791. /**
  24792. * Gets a boolean indicating if specific vertex buffer is present
  24793. * @param kind defines the data kind (Position, normal, etc...)
  24794. * @returns true if data is present
  24795. */
  24796. isVerticesDataPresent(kind: string): boolean;
  24797. /**
  24798. * Gets a list of all attached data kinds (Position, normal, etc...)
  24799. * @returns a list of string containing all kinds
  24800. */
  24801. getVerticesDataKinds(): string[];
  24802. /**
  24803. * Update index buffer
  24804. * @param indices defines the indices to store in the index buffer
  24805. * @param offset defines the offset in the target buffer where to store the data
  24806. * @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)
  24807. */
  24808. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24809. /**
  24810. * Creates a new index buffer
  24811. * @param indices defines the indices to store in the index buffer
  24812. * @param totalVertices defines the total number of vertices (could be null)
  24813. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24814. */
  24815. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24816. /**
  24817. * Return the total number of indices
  24818. * @returns the total number of indices
  24819. */
  24820. getTotalIndices(): number;
  24821. /**
  24822. * Gets the index buffer array
  24823. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24824. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24825. * @returns the index buffer array
  24826. */
  24827. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24828. /**
  24829. * Gets the index buffer
  24830. * @return the index buffer
  24831. */
  24832. getIndexBuffer(): Nullable<DataBuffer>;
  24833. /** @hidden */
  24834. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24835. /**
  24836. * Release the associated resources for a specific mesh
  24837. * @param mesh defines the source mesh
  24838. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24839. */
  24840. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24841. /**
  24842. * Apply current geometry to a given mesh
  24843. * @param mesh defines the mesh to apply geometry to
  24844. */
  24845. applyToMesh(mesh: Mesh): void;
  24846. private _updateExtend;
  24847. private _applyToMesh;
  24848. private notifyUpdate;
  24849. /**
  24850. * Load the geometry if it was flagged as delay loaded
  24851. * @param scene defines the hosting scene
  24852. * @param onLoaded defines a callback called when the geometry is loaded
  24853. */
  24854. load(scene: Scene, onLoaded?: () => void): void;
  24855. private _queueLoad;
  24856. /**
  24857. * Invert the geometry to move from a right handed system to a left handed one.
  24858. */
  24859. toLeftHanded(): void;
  24860. /** @hidden */
  24861. _resetPointsArrayCache(): void;
  24862. /** @hidden */
  24863. _generatePointsArray(): boolean;
  24864. /**
  24865. * Gets a value indicating if the geometry is disposed
  24866. * @returns true if the geometry was disposed
  24867. */
  24868. isDisposed(): boolean;
  24869. private _disposeVertexArrayObjects;
  24870. /**
  24871. * Free all associated resources
  24872. */
  24873. dispose(): void;
  24874. /**
  24875. * Clone the current geometry into a new geometry
  24876. * @param id defines the unique ID of the new geometry
  24877. * @returns a new geometry object
  24878. */
  24879. copy(id: string): Geometry;
  24880. /**
  24881. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24882. * @return a JSON representation of the current geometry data (without the vertices data)
  24883. */
  24884. serialize(): any;
  24885. private toNumberArray;
  24886. /**
  24887. * Serialize all vertices data into a JSON oject
  24888. * @returns a JSON representation of the current geometry data
  24889. */
  24890. serializeVerticeData(): any;
  24891. /**
  24892. * Extracts a clone of a mesh geometry
  24893. * @param mesh defines the source mesh
  24894. * @param id defines the unique ID of the new geometry object
  24895. * @returns the new geometry object
  24896. */
  24897. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24898. /**
  24899. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24900. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24901. * Be aware Math.random() could cause collisions, but:
  24902. * "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"
  24903. * @returns a string containing a new GUID
  24904. */
  24905. static RandomId(): string;
  24906. /** @hidden */
  24907. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24908. private static _CleanMatricesWeights;
  24909. /**
  24910. * Create a new geometry from persisted data (Using .babylon file format)
  24911. * @param parsedVertexData defines the persisted data
  24912. * @param scene defines the hosting scene
  24913. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24914. * @returns the new geometry object
  24915. */
  24916. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24917. }
  24918. }
  24919. declare module BABYLON {
  24920. /**
  24921. * Define an interface for all classes that will get and set the data on vertices
  24922. */
  24923. export interface IGetSetVerticesData {
  24924. /**
  24925. * Gets a boolean indicating if specific vertex data is present
  24926. * @param kind defines the vertex data kind to use
  24927. * @returns true is data kind is present
  24928. */
  24929. isVerticesDataPresent(kind: string): boolean;
  24930. /**
  24931. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24932. * @param kind defines the data kind (Position, normal, etc...)
  24933. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24934. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24935. * @returns a float array containing vertex data
  24936. */
  24937. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24938. /**
  24939. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24940. * @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.
  24941. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24942. * @returns the indices array or an empty array if the mesh has no geometry
  24943. */
  24944. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24945. /**
  24946. * Set specific vertex data
  24947. * @param kind defines the data kind (Position, normal, etc...)
  24948. * @param data defines the vertex data to use
  24949. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24950. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24951. */
  24952. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24953. /**
  24954. * Update a specific associated vertex buffer
  24955. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24956. * - VertexBuffer.PositionKind
  24957. * - VertexBuffer.UVKind
  24958. * - VertexBuffer.UV2Kind
  24959. * - VertexBuffer.UV3Kind
  24960. * - VertexBuffer.UV4Kind
  24961. * - VertexBuffer.UV5Kind
  24962. * - VertexBuffer.UV6Kind
  24963. * - VertexBuffer.ColorKind
  24964. * - VertexBuffer.MatricesIndicesKind
  24965. * - VertexBuffer.MatricesIndicesExtraKind
  24966. * - VertexBuffer.MatricesWeightsKind
  24967. * - VertexBuffer.MatricesWeightsExtraKind
  24968. * @param data defines the data source
  24969. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24970. * @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)
  24971. */
  24972. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24973. /**
  24974. * Creates a new index buffer
  24975. * @param indices defines the indices to store in the index buffer
  24976. * @param totalVertices defines the total number of vertices (could be null)
  24977. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24978. */
  24979. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24980. }
  24981. /**
  24982. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24983. */
  24984. export class VertexData {
  24985. /**
  24986. * Mesh side orientation : usually the external or front surface
  24987. */
  24988. static readonly FRONTSIDE: number;
  24989. /**
  24990. * Mesh side orientation : usually the internal or back surface
  24991. */
  24992. static readonly BACKSIDE: number;
  24993. /**
  24994. * Mesh side orientation : both internal and external or front and back surfaces
  24995. */
  24996. static readonly DOUBLESIDE: number;
  24997. /**
  24998. * Mesh side orientation : by default, `FRONTSIDE`
  24999. */
  25000. static readonly DEFAULTSIDE: number;
  25001. /**
  25002. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25003. */
  25004. positions: Nullable<FloatArray>;
  25005. /**
  25006. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25007. */
  25008. normals: Nullable<FloatArray>;
  25009. /**
  25010. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25011. */
  25012. tangents: Nullable<FloatArray>;
  25013. /**
  25014. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25015. */
  25016. uvs: Nullable<FloatArray>;
  25017. /**
  25018. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25019. */
  25020. uvs2: Nullable<FloatArray>;
  25021. /**
  25022. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25023. */
  25024. uvs3: Nullable<FloatArray>;
  25025. /**
  25026. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25027. */
  25028. uvs4: Nullable<FloatArray>;
  25029. /**
  25030. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25031. */
  25032. uvs5: Nullable<FloatArray>;
  25033. /**
  25034. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25035. */
  25036. uvs6: Nullable<FloatArray>;
  25037. /**
  25038. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25039. */
  25040. colors: Nullable<FloatArray>;
  25041. /**
  25042. * 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).
  25043. */
  25044. matricesIndices: Nullable<FloatArray>;
  25045. /**
  25046. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25047. */
  25048. matricesWeights: Nullable<FloatArray>;
  25049. /**
  25050. * An array extending the number of possible indices
  25051. */
  25052. matricesIndicesExtra: Nullable<FloatArray>;
  25053. /**
  25054. * An array extending the number of possible weights when the number of indices is extended
  25055. */
  25056. matricesWeightsExtra: Nullable<FloatArray>;
  25057. /**
  25058. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25059. */
  25060. indices: Nullable<IndicesArray>;
  25061. /**
  25062. * Uses the passed data array to set the set the values for the specified kind of data
  25063. * @param data a linear array of floating numbers
  25064. * @param kind the type of data that is being set, eg positions, colors etc
  25065. */
  25066. set(data: FloatArray, kind: string): void;
  25067. /**
  25068. * Associates the vertexData to the passed Mesh.
  25069. * Sets it as updatable or not (default `false`)
  25070. * @param mesh the mesh the vertexData is applied to
  25071. * @param updatable when used and having the value true allows new data to update the vertexData
  25072. * @returns the VertexData
  25073. */
  25074. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25075. /**
  25076. * Associates the vertexData to the passed Geometry.
  25077. * Sets it as updatable or not (default `false`)
  25078. * @param geometry the geometry the vertexData is applied to
  25079. * @param updatable when used and having the value true allows new data to update the vertexData
  25080. * @returns VertexData
  25081. */
  25082. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25083. /**
  25084. * Updates the associated mesh
  25085. * @param mesh the mesh to be updated
  25086. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25087. * @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
  25088. * @returns VertexData
  25089. */
  25090. updateMesh(mesh: Mesh): VertexData;
  25091. /**
  25092. * Updates the associated geometry
  25093. * @param geometry the geometry to be updated
  25094. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25095. * @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
  25096. * @returns VertexData.
  25097. */
  25098. updateGeometry(geometry: Geometry): VertexData;
  25099. private _applyTo;
  25100. private _update;
  25101. /**
  25102. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25103. * @param matrix the transforming matrix
  25104. * @returns the VertexData
  25105. */
  25106. transform(matrix: Matrix): VertexData;
  25107. /**
  25108. * Merges the passed VertexData into the current one
  25109. * @param other the VertexData to be merged into the current one
  25110. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25111. * @returns the modified VertexData
  25112. */
  25113. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25114. private _mergeElement;
  25115. private _validate;
  25116. /**
  25117. * Serializes the VertexData
  25118. * @returns a serialized object
  25119. */
  25120. serialize(): any;
  25121. /**
  25122. * Extracts the vertexData from a mesh
  25123. * @param mesh the mesh from which to extract the VertexData
  25124. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25125. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25126. * @returns the object VertexData associated to the passed mesh
  25127. */
  25128. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25129. /**
  25130. * Extracts the vertexData from the geometry
  25131. * @param geometry the geometry from which to extract the VertexData
  25132. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25133. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25134. * @returns the object VertexData associated to the passed mesh
  25135. */
  25136. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25137. private static _ExtractFrom;
  25138. /**
  25139. * Creates the VertexData for a Ribbon
  25140. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25141. * * pathArray array of paths, each of which an array of successive Vector3
  25142. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25143. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25144. * * 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
  25145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25146. * * 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)
  25147. * * 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)
  25148. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25149. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25150. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25151. * @returns the VertexData of the ribbon
  25152. */
  25153. static CreateRibbon(options: {
  25154. pathArray: Vector3[][];
  25155. closeArray?: boolean;
  25156. closePath?: boolean;
  25157. offset?: number;
  25158. sideOrientation?: number;
  25159. frontUVs?: Vector4;
  25160. backUVs?: Vector4;
  25161. invertUV?: boolean;
  25162. uvs?: Vector2[];
  25163. colors?: Color4[];
  25164. }): VertexData;
  25165. /**
  25166. * Creates the VertexData for a box
  25167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25168. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25169. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25170. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25171. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25172. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25173. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25175. * * 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)
  25176. * * 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)
  25177. * @returns the VertexData of the box
  25178. */
  25179. static CreateBox(options: {
  25180. size?: number;
  25181. width?: number;
  25182. height?: number;
  25183. depth?: number;
  25184. faceUV?: Vector4[];
  25185. faceColors?: Color4[];
  25186. sideOrientation?: number;
  25187. frontUVs?: Vector4;
  25188. backUVs?: Vector4;
  25189. }): VertexData;
  25190. /**
  25191. * Creates the VertexData for a tiled box
  25192. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25193. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25194. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25195. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25197. * @returns the VertexData of the box
  25198. */
  25199. static CreateTiledBox(options: {
  25200. pattern?: number;
  25201. width?: number;
  25202. height?: number;
  25203. depth?: number;
  25204. tileSize?: number;
  25205. tileWidth?: number;
  25206. tileHeight?: number;
  25207. alignHorizontal?: number;
  25208. alignVertical?: number;
  25209. faceUV?: Vector4[];
  25210. faceColors?: Color4[];
  25211. sideOrientation?: number;
  25212. }): VertexData;
  25213. /**
  25214. * Creates the VertexData for a tiled plane
  25215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25216. * * pattern a limited pattern arrangement depending on the number
  25217. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25218. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25219. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25221. * * 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)
  25222. * * 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)
  25223. * @returns the VertexData of the tiled plane
  25224. */
  25225. static CreateTiledPlane(options: {
  25226. pattern?: number;
  25227. tileSize?: number;
  25228. tileWidth?: number;
  25229. tileHeight?: number;
  25230. size?: number;
  25231. width?: number;
  25232. height?: number;
  25233. alignHorizontal?: number;
  25234. alignVertical?: number;
  25235. sideOrientation?: number;
  25236. frontUVs?: Vector4;
  25237. backUVs?: Vector4;
  25238. }): VertexData;
  25239. /**
  25240. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25242. * * segments sets the number of horizontal strips optional, default 32
  25243. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25244. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25245. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25246. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25247. * * 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
  25248. * * 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
  25249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25250. * * 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)
  25251. * * 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)
  25252. * @returns the VertexData of the ellipsoid
  25253. */
  25254. static CreateSphere(options: {
  25255. segments?: number;
  25256. diameter?: number;
  25257. diameterX?: number;
  25258. diameterY?: number;
  25259. diameterZ?: number;
  25260. arc?: number;
  25261. slice?: number;
  25262. sideOrientation?: number;
  25263. frontUVs?: Vector4;
  25264. backUVs?: Vector4;
  25265. }): VertexData;
  25266. /**
  25267. * Creates the VertexData for a cylinder, cone or prism
  25268. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25269. * * height sets the height (y direction) of the cylinder, optional, default 2
  25270. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25271. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25272. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25273. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25274. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25275. * * 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
  25276. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25277. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25278. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25279. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25281. * * 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)
  25282. * * 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)
  25283. * @returns the VertexData of the cylinder, cone or prism
  25284. */
  25285. static CreateCylinder(options: {
  25286. height?: number;
  25287. diameterTop?: number;
  25288. diameterBottom?: number;
  25289. diameter?: number;
  25290. tessellation?: number;
  25291. subdivisions?: number;
  25292. arc?: number;
  25293. faceColors?: Color4[];
  25294. faceUV?: Vector4[];
  25295. hasRings?: boolean;
  25296. enclose?: boolean;
  25297. sideOrientation?: number;
  25298. frontUVs?: Vector4;
  25299. backUVs?: Vector4;
  25300. }): VertexData;
  25301. /**
  25302. * Creates the VertexData for a torus
  25303. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25304. * * diameter the diameter of the torus, optional default 1
  25305. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25306. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25308. * * 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)
  25309. * * 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)
  25310. * @returns the VertexData of the torus
  25311. */
  25312. static CreateTorus(options: {
  25313. diameter?: number;
  25314. thickness?: number;
  25315. tessellation?: number;
  25316. sideOrientation?: number;
  25317. frontUVs?: Vector4;
  25318. backUVs?: Vector4;
  25319. }): VertexData;
  25320. /**
  25321. * Creates the VertexData of the LineSystem
  25322. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25323. * - lines an array of lines, each line being an array of successive Vector3
  25324. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25325. * @returns the VertexData of the LineSystem
  25326. */
  25327. static CreateLineSystem(options: {
  25328. lines: Vector3[][];
  25329. colors?: Nullable<Color4[][]>;
  25330. }): VertexData;
  25331. /**
  25332. * Create the VertexData for a DashedLines
  25333. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25334. * - points an array successive Vector3
  25335. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25336. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25337. * - dashNb the intended total number of dashes, optional, default 200
  25338. * @returns the VertexData for the DashedLines
  25339. */
  25340. static CreateDashedLines(options: {
  25341. points: Vector3[];
  25342. dashSize?: number;
  25343. gapSize?: number;
  25344. dashNb?: number;
  25345. }): VertexData;
  25346. /**
  25347. * Creates the VertexData for a Ground
  25348. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25349. * - width the width (x direction) of the ground, optional, default 1
  25350. * - height the height (z direction) of the ground, optional, default 1
  25351. * - subdivisions the number of subdivisions per side, optional, default 1
  25352. * @returns the VertexData of the Ground
  25353. */
  25354. static CreateGround(options: {
  25355. width?: number;
  25356. height?: number;
  25357. subdivisions?: number;
  25358. subdivisionsX?: number;
  25359. subdivisionsY?: number;
  25360. }): VertexData;
  25361. /**
  25362. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25363. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25364. * * xmin the ground minimum X coordinate, optional, default -1
  25365. * * zmin the ground minimum Z coordinate, optional, default -1
  25366. * * xmax the ground maximum X coordinate, optional, default 1
  25367. * * zmax the ground maximum Z coordinate, optional, default 1
  25368. * * 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}
  25369. * * 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}
  25370. * @returns the VertexData of the TiledGround
  25371. */
  25372. static CreateTiledGround(options: {
  25373. xmin: number;
  25374. zmin: number;
  25375. xmax: number;
  25376. zmax: number;
  25377. subdivisions?: {
  25378. w: number;
  25379. h: number;
  25380. };
  25381. precision?: {
  25382. w: number;
  25383. h: number;
  25384. };
  25385. }): VertexData;
  25386. /**
  25387. * Creates the VertexData of the Ground designed from a heightmap
  25388. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25389. * * width the width (x direction) of the ground
  25390. * * height the height (z direction) of the ground
  25391. * * subdivisions the number of subdivisions per side
  25392. * * minHeight the minimum altitude on the ground, optional, default 0
  25393. * * maxHeight the maximum altitude on the ground, optional default 1
  25394. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25395. * * buffer the array holding the image color data
  25396. * * bufferWidth the width of image
  25397. * * bufferHeight the height of image
  25398. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25399. * @returns the VertexData of the Ground designed from a heightmap
  25400. */
  25401. static CreateGroundFromHeightMap(options: {
  25402. width: number;
  25403. height: number;
  25404. subdivisions: number;
  25405. minHeight: number;
  25406. maxHeight: number;
  25407. colorFilter: Color3;
  25408. buffer: Uint8Array;
  25409. bufferWidth: number;
  25410. bufferHeight: number;
  25411. alphaFilter: number;
  25412. }): VertexData;
  25413. /**
  25414. * Creates the VertexData for a Plane
  25415. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25416. * * size sets the width and height of the plane to the value of size, optional default 1
  25417. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25418. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25419. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25420. * * 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)
  25421. * * 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)
  25422. * @returns the VertexData of the box
  25423. */
  25424. static CreatePlane(options: {
  25425. size?: number;
  25426. width?: number;
  25427. height?: number;
  25428. sideOrientation?: number;
  25429. frontUVs?: Vector4;
  25430. backUVs?: Vector4;
  25431. }): VertexData;
  25432. /**
  25433. * Creates the VertexData of the Disc or regular Polygon
  25434. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25435. * * radius the radius of the disc, optional default 0.5
  25436. * * tessellation the number of polygon sides, optional, default 64
  25437. * * 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
  25438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25439. * * 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)
  25440. * * 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)
  25441. * @returns the VertexData of the box
  25442. */
  25443. static CreateDisc(options: {
  25444. radius?: number;
  25445. tessellation?: number;
  25446. arc?: number;
  25447. sideOrientation?: number;
  25448. frontUVs?: Vector4;
  25449. backUVs?: Vector4;
  25450. }): VertexData;
  25451. /**
  25452. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25453. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25454. * @param polygon a mesh built from polygonTriangulation.build()
  25455. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25456. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25457. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25458. * @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)
  25459. * @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)
  25460. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25461. * @returns the VertexData of the Polygon
  25462. */
  25463. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25464. /**
  25465. * Creates the VertexData of the IcoSphere
  25466. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25467. * * radius the radius of the IcoSphere, optional default 1
  25468. * * radiusX allows stretching in the x direction, optional, default radius
  25469. * * radiusY allows stretching in the y direction, optional, default radius
  25470. * * radiusZ allows stretching in the z direction, optional, default radius
  25471. * * flat when true creates a flat shaded mesh, optional, default true
  25472. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25474. * * 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)
  25475. * * 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)
  25476. * @returns the VertexData of the IcoSphere
  25477. */
  25478. static CreateIcoSphere(options: {
  25479. radius?: number;
  25480. radiusX?: number;
  25481. radiusY?: number;
  25482. radiusZ?: number;
  25483. flat?: boolean;
  25484. subdivisions?: number;
  25485. sideOrientation?: number;
  25486. frontUVs?: Vector4;
  25487. backUVs?: Vector4;
  25488. }): VertexData;
  25489. /**
  25490. * Creates the VertexData for a Polyhedron
  25491. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25492. * * type provided types are:
  25493. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25494. * * 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)
  25495. * * size the size of the IcoSphere, optional default 1
  25496. * * sizeX allows stretching in the x direction, optional, default size
  25497. * * sizeY allows stretching in the y direction, optional, default size
  25498. * * sizeZ allows stretching in the z direction, optional, default size
  25499. * * 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
  25500. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25501. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25502. * * flat when true creates a flat shaded mesh, optional, default true
  25503. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25505. * * 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)
  25506. * * 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)
  25507. * @returns the VertexData of the Polyhedron
  25508. */
  25509. static CreatePolyhedron(options: {
  25510. type?: number;
  25511. size?: number;
  25512. sizeX?: number;
  25513. sizeY?: number;
  25514. sizeZ?: number;
  25515. custom?: any;
  25516. faceUV?: Vector4[];
  25517. faceColors?: Color4[];
  25518. flat?: boolean;
  25519. sideOrientation?: number;
  25520. frontUVs?: Vector4;
  25521. backUVs?: Vector4;
  25522. }): VertexData;
  25523. /**
  25524. * Creates the VertexData for a TorusKnot
  25525. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25526. * * radius the radius of the torus knot, optional, default 2
  25527. * * tube the thickness of the tube, optional, default 0.5
  25528. * * radialSegments the number of sides on each tube segments, optional, default 32
  25529. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25530. * * p the number of windings around the z axis, optional, default 2
  25531. * * q the number of windings around the x axis, optional, default 3
  25532. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25533. * * 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)
  25534. * * 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)
  25535. * @returns the VertexData of the Torus Knot
  25536. */
  25537. static CreateTorusKnot(options: {
  25538. radius?: number;
  25539. tube?: number;
  25540. radialSegments?: number;
  25541. tubularSegments?: number;
  25542. p?: number;
  25543. q?: number;
  25544. sideOrientation?: number;
  25545. frontUVs?: Vector4;
  25546. backUVs?: Vector4;
  25547. }): VertexData;
  25548. /**
  25549. * Compute normals for given positions and indices
  25550. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25551. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25552. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25553. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25554. * * facetNormals : optional array of facet normals (vector3)
  25555. * * facetPositions : optional array of facet positions (vector3)
  25556. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25557. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25558. * * bInfo : optional bounding info, required for facetPartitioning computation
  25559. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25560. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25561. * * useRightHandedSystem: optional boolean to for right handed system computation
  25562. * * depthSort : optional boolean to enable the facet depth sort computation
  25563. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25564. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25565. */
  25566. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25567. facetNormals?: any;
  25568. facetPositions?: any;
  25569. facetPartitioning?: any;
  25570. ratio?: number;
  25571. bInfo?: any;
  25572. bbSize?: Vector3;
  25573. subDiv?: any;
  25574. useRightHandedSystem?: boolean;
  25575. depthSort?: boolean;
  25576. distanceTo?: Vector3;
  25577. depthSortedFacets?: any;
  25578. }): void;
  25579. /** @hidden */
  25580. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25581. /**
  25582. * Applies VertexData created from the imported parameters to the geometry
  25583. * @param parsedVertexData the parsed data from an imported file
  25584. * @param geometry the geometry to apply the VertexData to
  25585. */
  25586. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25587. }
  25588. }
  25589. declare module BABYLON {
  25590. /**
  25591. * Defines a target to use with MorphTargetManager
  25592. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25593. */
  25594. export class MorphTarget implements IAnimatable {
  25595. /** defines the name of the target */
  25596. name: string;
  25597. /**
  25598. * Gets or sets the list of animations
  25599. */
  25600. animations: Animation[];
  25601. private _scene;
  25602. private _positions;
  25603. private _normals;
  25604. private _tangents;
  25605. private _uvs;
  25606. private _influence;
  25607. private _uniqueId;
  25608. /**
  25609. * Observable raised when the influence changes
  25610. */
  25611. onInfluenceChanged: Observable<boolean>;
  25612. /** @hidden */
  25613. _onDataLayoutChanged: Observable<void>;
  25614. /**
  25615. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25616. */
  25617. get influence(): number;
  25618. set influence(influence: number);
  25619. /**
  25620. * Gets or sets the id of the morph Target
  25621. */
  25622. id: string;
  25623. private _animationPropertiesOverride;
  25624. /**
  25625. * Gets or sets the animation properties override
  25626. */
  25627. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25628. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25629. /**
  25630. * Creates a new MorphTarget
  25631. * @param name defines the name of the target
  25632. * @param influence defines the influence to use
  25633. * @param scene defines the scene the morphtarget belongs to
  25634. */
  25635. constructor(
  25636. /** defines the name of the target */
  25637. name: string, influence?: number, scene?: Nullable<Scene>);
  25638. /**
  25639. * Gets the unique ID of this manager
  25640. */
  25641. get uniqueId(): number;
  25642. /**
  25643. * Gets a boolean defining if the target contains position data
  25644. */
  25645. get hasPositions(): boolean;
  25646. /**
  25647. * Gets a boolean defining if the target contains normal data
  25648. */
  25649. get hasNormals(): boolean;
  25650. /**
  25651. * Gets a boolean defining if the target contains tangent data
  25652. */
  25653. get hasTangents(): boolean;
  25654. /**
  25655. * Gets a boolean defining if the target contains texture coordinates data
  25656. */
  25657. get hasUVs(): boolean;
  25658. /**
  25659. * Affects position data to this target
  25660. * @param data defines the position data to use
  25661. */
  25662. setPositions(data: Nullable<FloatArray>): void;
  25663. /**
  25664. * Gets the position data stored in this target
  25665. * @returns a FloatArray containing the position data (or null if not present)
  25666. */
  25667. getPositions(): Nullable<FloatArray>;
  25668. /**
  25669. * Affects normal data to this target
  25670. * @param data defines the normal data to use
  25671. */
  25672. setNormals(data: Nullable<FloatArray>): void;
  25673. /**
  25674. * Gets the normal data stored in this target
  25675. * @returns a FloatArray containing the normal data (or null if not present)
  25676. */
  25677. getNormals(): Nullable<FloatArray>;
  25678. /**
  25679. * Affects tangent data to this target
  25680. * @param data defines the tangent data to use
  25681. */
  25682. setTangents(data: Nullable<FloatArray>): void;
  25683. /**
  25684. * Gets the tangent data stored in this target
  25685. * @returns a FloatArray containing the tangent data (or null if not present)
  25686. */
  25687. getTangents(): Nullable<FloatArray>;
  25688. /**
  25689. * Affects texture coordinates data to this target
  25690. * @param data defines the texture coordinates data to use
  25691. */
  25692. setUVs(data: Nullable<FloatArray>): void;
  25693. /**
  25694. * Gets the texture coordinates data stored in this target
  25695. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25696. */
  25697. getUVs(): Nullable<FloatArray>;
  25698. /**
  25699. * Clone the current target
  25700. * @returns a new MorphTarget
  25701. */
  25702. clone(): MorphTarget;
  25703. /**
  25704. * Serializes the current target into a Serialization object
  25705. * @returns the serialized object
  25706. */
  25707. serialize(): any;
  25708. /**
  25709. * Returns the string "MorphTarget"
  25710. * @returns "MorphTarget"
  25711. */
  25712. getClassName(): string;
  25713. /**
  25714. * Creates a new target from serialized data
  25715. * @param serializationObject defines the serialized data to use
  25716. * @returns a new MorphTarget
  25717. */
  25718. static Parse(serializationObject: any): MorphTarget;
  25719. /**
  25720. * Creates a MorphTarget from mesh data
  25721. * @param mesh defines the source mesh
  25722. * @param name defines the name to use for the new target
  25723. * @param influence defines the influence to attach to the target
  25724. * @returns a new MorphTarget
  25725. */
  25726. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25727. }
  25728. }
  25729. declare module BABYLON {
  25730. /**
  25731. * This class is used to deform meshes using morphing between different targets
  25732. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25733. */
  25734. export class MorphTargetManager {
  25735. private _targets;
  25736. private _targetInfluenceChangedObservers;
  25737. private _targetDataLayoutChangedObservers;
  25738. private _activeTargets;
  25739. private _scene;
  25740. private _influences;
  25741. private _supportsNormals;
  25742. private _supportsTangents;
  25743. private _supportsUVs;
  25744. private _vertexCount;
  25745. private _uniqueId;
  25746. private _tempInfluences;
  25747. /**
  25748. * Gets or sets a boolean indicating if normals must be morphed
  25749. */
  25750. enableNormalMorphing: boolean;
  25751. /**
  25752. * Gets or sets a boolean indicating if tangents must be morphed
  25753. */
  25754. enableTangentMorphing: boolean;
  25755. /**
  25756. * Gets or sets a boolean indicating if UV must be morphed
  25757. */
  25758. enableUVMorphing: boolean;
  25759. /**
  25760. * Creates a new MorphTargetManager
  25761. * @param scene defines the current scene
  25762. */
  25763. constructor(scene?: Nullable<Scene>);
  25764. /**
  25765. * Gets the unique ID of this manager
  25766. */
  25767. get uniqueId(): number;
  25768. /**
  25769. * Gets the number of vertices handled by this manager
  25770. */
  25771. get vertexCount(): number;
  25772. /**
  25773. * Gets a boolean indicating if this manager supports morphing of normals
  25774. */
  25775. get supportsNormals(): boolean;
  25776. /**
  25777. * Gets a boolean indicating if this manager supports morphing of tangents
  25778. */
  25779. get supportsTangents(): boolean;
  25780. /**
  25781. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25782. */
  25783. get supportsUVs(): boolean;
  25784. /**
  25785. * Gets the number of targets stored in this manager
  25786. */
  25787. get numTargets(): number;
  25788. /**
  25789. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25790. */
  25791. get numInfluencers(): number;
  25792. /**
  25793. * Gets the list of influences (one per target)
  25794. */
  25795. get influences(): Float32Array;
  25796. /**
  25797. * Gets the active target at specified index. An active target is a target with an influence > 0
  25798. * @param index defines the index to check
  25799. * @returns the requested target
  25800. */
  25801. getActiveTarget(index: number): MorphTarget;
  25802. /**
  25803. * Gets the target at specified index
  25804. * @param index defines the index to check
  25805. * @returns the requested target
  25806. */
  25807. getTarget(index: number): MorphTarget;
  25808. /**
  25809. * Add a new target to this manager
  25810. * @param target defines the target to add
  25811. */
  25812. addTarget(target: MorphTarget): void;
  25813. /**
  25814. * Removes a target from the manager
  25815. * @param target defines the target to remove
  25816. */
  25817. removeTarget(target: MorphTarget): void;
  25818. /**
  25819. * Clone the current manager
  25820. * @returns a new MorphTargetManager
  25821. */
  25822. clone(): MorphTargetManager;
  25823. /**
  25824. * Serializes the current manager into a Serialization object
  25825. * @returns the serialized object
  25826. */
  25827. serialize(): any;
  25828. private _syncActiveTargets;
  25829. /**
  25830. * Syncrhonize the targets with all the meshes using this morph target manager
  25831. */
  25832. synchronize(): void;
  25833. /**
  25834. * Creates a new MorphTargetManager from serialized data
  25835. * @param serializationObject defines the serialized data
  25836. * @param scene defines the hosting scene
  25837. * @returns the new MorphTargetManager
  25838. */
  25839. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25840. }
  25841. }
  25842. declare module BABYLON {
  25843. /**
  25844. * Class used to represent a specific level of detail of a mesh
  25845. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25846. */
  25847. export class MeshLODLevel {
  25848. /** Defines the distance where this level should start being displayed */
  25849. distance: number;
  25850. /** Defines the mesh to use to render this level */
  25851. mesh: Nullable<Mesh>;
  25852. /**
  25853. * Creates a new LOD level
  25854. * @param distance defines the distance where this level should star being displayed
  25855. * @param mesh defines the mesh to use to render this level
  25856. */
  25857. constructor(
  25858. /** Defines the distance where this level should start being displayed */
  25859. distance: number,
  25860. /** Defines the mesh to use to render this level */
  25861. mesh: Nullable<Mesh>);
  25862. }
  25863. }
  25864. declare module BABYLON {
  25865. /**
  25866. * Helper class used to generate a canvas to manipulate images
  25867. */
  25868. export class CanvasGenerator {
  25869. /**
  25870. * Create a new canvas (or offscreen canvas depending on the context)
  25871. * @param width defines the expected width
  25872. * @param height defines the expected height
  25873. * @return a new canvas or offscreen canvas
  25874. */
  25875. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  25876. }
  25877. }
  25878. declare module BABYLON {
  25879. /**
  25880. * Mesh representing the gorund
  25881. */
  25882. export class GroundMesh extends Mesh {
  25883. /** If octree should be generated */
  25884. generateOctree: boolean;
  25885. private _heightQuads;
  25886. /** @hidden */
  25887. _subdivisionsX: number;
  25888. /** @hidden */
  25889. _subdivisionsY: number;
  25890. /** @hidden */
  25891. _width: number;
  25892. /** @hidden */
  25893. _height: number;
  25894. /** @hidden */
  25895. _minX: number;
  25896. /** @hidden */
  25897. _maxX: number;
  25898. /** @hidden */
  25899. _minZ: number;
  25900. /** @hidden */
  25901. _maxZ: number;
  25902. constructor(name: string, scene: Scene);
  25903. /**
  25904. * "GroundMesh"
  25905. * @returns "GroundMesh"
  25906. */
  25907. getClassName(): string;
  25908. /**
  25909. * The minimum of x and y subdivisions
  25910. */
  25911. get subdivisions(): number;
  25912. /**
  25913. * X subdivisions
  25914. */
  25915. get subdivisionsX(): number;
  25916. /**
  25917. * Y subdivisions
  25918. */
  25919. get subdivisionsY(): number;
  25920. /**
  25921. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25922. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25923. * @param chunksCount the number of subdivisions for x and y
  25924. * @param octreeBlocksSize (Default: 32)
  25925. */
  25926. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25927. /**
  25928. * Returns a height (y) value in the Worl system :
  25929. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25930. * @param x x coordinate
  25931. * @param z z coordinate
  25932. * @returns the ground y position if (x, z) are outside the ground surface.
  25933. */
  25934. getHeightAtCoordinates(x: number, z: number): number;
  25935. /**
  25936. * Returns a normalized vector (Vector3) orthogonal to the ground
  25937. * at the ground coordinates (x, z) expressed in the World system.
  25938. * @param x x coordinate
  25939. * @param z z coordinate
  25940. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25941. */
  25942. getNormalAtCoordinates(x: number, z: number): Vector3;
  25943. /**
  25944. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25945. * at the ground coordinates (x, z) expressed in the World system.
  25946. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25947. * @param x x coordinate
  25948. * @param z z coordinate
  25949. * @param ref vector to store the result
  25950. * @returns the GroundMesh.
  25951. */
  25952. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25953. /**
  25954. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25955. * if the ground has been updated.
  25956. * This can be used in the render loop.
  25957. * @returns the GroundMesh.
  25958. */
  25959. updateCoordinateHeights(): GroundMesh;
  25960. private _getFacetAt;
  25961. private _initHeightQuads;
  25962. private _computeHeightQuads;
  25963. /**
  25964. * Serializes this ground mesh
  25965. * @param serializationObject object to write serialization to
  25966. */
  25967. serialize(serializationObject: any): void;
  25968. /**
  25969. * Parses a serialized ground mesh
  25970. * @param parsedMesh the serialized mesh
  25971. * @param scene the scene to create the ground mesh in
  25972. * @returns the created ground mesh
  25973. */
  25974. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25975. }
  25976. }
  25977. declare module BABYLON {
  25978. /**
  25979. * Interface for Physics-Joint data
  25980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25981. */
  25982. export interface PhysicsJointData {
  25983. /**
  25984. * The main pivot of the joint
  25985. */
  25986. mainPivot?: Vector3;
  25987. /**
  25988. * The connected pivot of the joint
  25989. */
  25990. connectedPivot?: Vector3;
  25991. /**
  25992. * The main axis of the joint
  25993. */
  25994. mainAxis?: Vector3;
  25995. /**
  25996. * The connected axis of the joint
  25997. */
  25998. connectedAxis?: Vector3;
  25999. /**
  26000. * The collision of the joint
  26001. */
  26002. collision?: boolean;
  26003. /**
  26004. * Native Oimo/Cannon/Energy data
  26005. */
  26006. nativeParams?: any;
  26007. }
  26008. /**
  26009. * This is a holder class for the physics joint created by the physics plugin
  26010. * It holds a set of functions to control the underlying joint
  26011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26012. */
  26013. export class PhysicsJoint {
  26014. /**
  26015. * The type of the physics joint
  26016. */
  26017. type: number;
  26018. /**
  26019. * The data for the physics joint
  26020. */
  26021. jointData: PhysicsJointData;
  26022. private _physicsJoint;
  26023. protected _physicsPlugin: IPhysicsEnginePlugin;
  26024. /**
  26025. * Initializes the physics joint
  26026. * @param type The type of the physics joint
  26027. * @param jointData The data for the physics joint
  26028. */
  26029. constructor(
  26030. /**
  26031. * The type of the physics joint
  26032. */
  26033. type: number,
  26034. /**
  26035. * The data for the physics joint
  26036. */
  26037. jointData: PhysicsJointData);
  26038. /**
  26039. * Gets the physics joint
  26040. */
  26041. get physicsJoint(): any;
  26042. /**
  26043. * Sets the physics joint
  26044. */
  26045. set physicsJoint(newJoint: any);
  26046. /**
  26047. * Sets the physics plugin
  26048. */
  26049. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26050. /**
  26051. * Execute a function that is physics-plugin specific.
  26052. * @param {Function} func the function that will be executed.
  26053. * It accepts two parameters: the physics world and the physics joint
  26054. */
  26055. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26056. /**
  26057. * Distance-Joint type
  26058. */
  26059. static DistanceJoint: number;
  26060. /**
  26061. * Hinge-Joint type
  26062. */
  26063. static HingeJoint: number;
  26064. /**
  26065. * Ball-and-Socket joint type
  26066. */
  26067. static BallAndSocketJoint: number;
  26068. /**
  26069. * Wheel-Joint type
  26070. */
  26071. static WheelJoint: number;
  26072. /**
  26073. * Slider-Joint type
  26074. */
  26075. static SliderJoint: number;
  26076. /**
  26077. * Prismatic-Joint type
  26078. */
  26079. static PrismaticJoint: number;
  26080. /**
  26081. * Universal-Joint type
  26082. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26083. */
  26084. static UniversalJoint: number;
  26085. /**
  26086. * Hinge-Joint 2 type
  26087. */
  26088. static Hinge2Joint: number;
  26089. /**
  26090. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26091. */
  26092. static PointToPointJoint: number;
  26093. /**
  26094. * Spring-Joint type
  26095. */
  26096. static SpringJoint: number;
  26097. /**
  26098. * Lock-Joint type
  26099. */
  26100. static LockJoint: number;
  26101. }
  26102. /**
  26103. * A class representing a physics distance joint
  26104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26105. */
  26106. export class DistanceJoint extends PhysicsJoint {
  26107. /**
  26108. *
  26109. * @param jointData The data for the Distance-Joint
  26110. */
  26111. constructor(jointData: DistanceJointData);
  26112. /**
  26113. * Update the predefined distance.
  26114. * @param maxDistance The maximum preferred distance
  26115. * @param minDistance The minimum preferred distance
  26116. */
  26117. updateDistance(maxDistance: number, minDistance?: number): void;
  26118. }
  26119. /**
  26120. * Represents a Motor-Enabled Joint
  26121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26122. */
  26123. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26124. /**
  26125. * Initializes the Motor-Enabled Joint
  26126. * @param type The type of the joint
  26127. * @param jointData The physica joint data for the joint
  26128. */
  26129. constructor(type: number, jointData: PhysicsJointData);
  26130. /**
  26131. * Set the motor values.
  26132. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26133. * @param force the force to apply
  26134. * @param maxForce max force for this motor.
  26135. */
  26136. setMotor(force?: number, maxForce?: number): void;
  26137. /**
  26138. * Set the motor's limits.
  26139. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26140. * @param upperLimit The upper limit of the motor
  26141. * @param lowerLimit The lower limit of the motor
  26142. */
  26143. setLimit(upperLimit: number, lowerLimit?: number): void;
  26144. }
  26145. /**
  26146. * This class represents a single physics Hinge-Joint
  26147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26148. */
  26149. export class HingeJoint extends MotorEnabledJoint {
  26150. /**
  26151. * Initializes the Hinge-Joint
  26152. * @param jointData The joint data for the Hinge-Joint
  26153. */
  26154. constructor(jointData: PhysicsJointData);
  26155. /**
  26156. * Set the motor values.
  26157. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26158. * @param {number} force the force to apply
  26159. * @param {number} maxForce max force for this motor.
  26160. */
  26161. setMotor(force?: number, maxForce?: number): void;
  26162. /**
  26163. * Set the motor's limits.
  26164. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26165. * @param upperLimit The upper limit of the motor
  26166. * @param lowerLimit The lower limit of the motor
  26167. */
  26168. setLimit(upperLimit: number, lowerLimit?: number): void;
  26169. }
  26170. /**
  26171. * This class represents a dual hinge physics joint (same as wheel joint)
  26172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26173. */
  26174. export class Hinge2Joint extends MotorEnabledJoint {
  26175. /**
  26176. * Initializes the Hinge2-Joint
  26177. * @param jointData The joint data for the Hinge2-Joint
  26178. */
  26179. constructor(jointData: PhysicsJointData);
  26180. /**
  26181. * Set the motor values.
  26182. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26183. * @param {number} targetSpeed the speed the motor is to reach
  26184. * @param {number} maxForce max force for this motor.
  26185. * @param {motorIndex} the motor's index, 0 or 1.
  26186. */
  26187. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26188. /**
  26189. * Set the motor limits.
  26190. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26191. * @param {number} upperLimit the upper limit
  26192. * @param {number} lowerLimit lower limit
  26193. * @param {motorIndex} the motor's index, 0 or 1.
  26194. */
  26195. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26196. }
  26197. /**
  26198. * Interface for a motor enabled joint
  26199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26200. */
  26201. export interface IMotorEnabledJoint {
  26202. /**
  26203. * Physics joint
  26204. */
  26205. physicsJoint: any;
  26206. /**
  26207. * Sets the motor of the motor-enabled joint
  26208. * @param force The force of the motor
  26209. * @param maxForce The maximum force of the motor
  26210. * @param motorIndex The index of the motor
  26211. */
  26212. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26213. /**
  26214. * Sets the limit of the motor
  26215. * @param upperLimit The upper limit of the motor
  26216. * @param lowerLimit The lower limit of the motor
  26217. * @param motorIndex The index of the motor
  26218. */
  26219. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26220. }
  26221. /**
  26222. * Joint data for a Distance-Joint
  26223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26224. */
  26225. export interface DistanceJointData extends PhysicsJointData {
  26226. /**
  26227. * Max distance the 2 joint objects can be apart
  26228. */
  26229. maxDistance: number;
  26230. }
  26231. /**
  26232. * Joint data from a spring joint
  26233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26234. */
  26235. export interface SpringJointData extends PhysicsJointData {
  26236. /**
  26237. * Length of the spring
  26238. */
  26239. length: number;
  26240. /**
  26241. * Stiffness of the spring
  26242. */
  26243. stiffness: number;
  26244. /**
  26245. * Damping of the spring
  26246. */
  26247. damping: number;
  26248. /** this callback will be called when applying the force to the impostors. */
  26249. forceApplicationCallback: () => void;
  26250. }
  26251. }
  26252. declare module BABYLON {
  26253. /**
  26254. * Holds the data for the raycast result
  26255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26256. */
  26257. export class PhysicsRaycastResult {
  26258. private _hasHit;
  26259. private _hitDistance;
  26260. private _hitNormalWorld;
  26261. private _hitPointWorld;
  26262. private _rayFromWorld;
  26263. private _rayToWorld;
  26264. /**
  26265. * Gets if there was a hit
  26266. */
  26267. get hasHit(): boolean;
  26268. /**
  26269. * Gets the distance from the hit
  26270. */
  26271. get hitDistance(): number;
  26272. /**
  26273. * Gets the hit normal/direction in the world
  26274. */
  26275. get hitNormalWorld(): Vector3;
  26276. /**
  26277. * Gets the hit point in the world
  26278. */
  26279. get hitPointWorld(): Vector3;
  26280. /**
  26281. * Gets the ray "start point" of the ray in the world
  26282. */
  26283. get rayFromWorld(): Vector3;
  26284. /**
  26285. * Gets the ray "end point" of the ray in the world
  26286. */
  26287. get rayToWorld(): Vector3;
  26288. /**
  26289. * Sets the hit data (normal & point in world space)
  26290. * @param hitNormalWorld defines the normal in world space
  26291. * @param hitPointWorld defines the point in world space
  26292. */
  26293. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26294. /**
  26295. * Sets the distance from the start point to the hit point
  26296. * @param distance
  26297. */
  26298. setHitDistance(distance: number): void;
  26299. /**
  26300. * Calculates the distance manually
  26301. */
  26302. calculateHitDistance(): void;
  26303. /**
  26304. * Resets all the values to default
  26305. * @param from The from point on world space
  26306. * @param to The to point on world space
  26307. */
  26308. reset(from?: Vector3, to?: Vector3): void;
  26309. }
  26310. /**
  26311. * Interface for the size containing width and height
  26312. */
  26313. interface IXYZ {
  26314. /**
  26315. * X
  26316. */
  26317. x: number;
  26318. /**
  26319. * Y
  26320. */
  26321. y: number;
  26322. /**
  26323. * Z
  26324. */
  26325. z: number;
  26326. }
  26327. }
  26328. declare module BABYLON {
  26329. /**
  26330. * Interface used to describe a physics joint
  26331. */
  26332. export interface PhysicsImpostorJoint {
  26333. /** Defines the main impostor to which the joint is linked */
  26334. mainImpostor: PhysicsImpostor;
  26335. /** Defines the impostor that is connected to the main impostor using this joint */
  26336. connectedImpostor: PhysicsImpostor;
  26337. /** Defines the joint itself */
  26338. joint: PhysicsJoint;
  26339. }
  26340. /** @hidden */
  26341. export interface IPhysicsEnginePlugin {
  26342. world: any;
  26343. name: string;
  26344. setGravity(gravity: Vector3): void;
  26345. setTimeStep(timeStep: number): void;
  26346. getTimeStep(): number;
  26347. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26348. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26349. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26350. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26351. removePhysicsBody(impostor: PhysicsImpostor): void;
  26352. generateJoint(joint: PhysicsImpostorJoint): void;
  26353. removeJoint(joint: PhysicsImpostorJoint): void;
  26354. isSupported(): boolean;
  26355. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26356. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26357. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26358. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26359. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26360. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26361. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26362. getBodyMass(impostor: PhysicsImpostor): number;
  26363. getBodyFriction(impostor: PhysicsImpostor): number;
  26364. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26365. getBodyRestitution(impostor: PhysicsImpostor): number;
  26366. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26367. getBodyPressure?(impostor: PhysicsImpostor): number;
  26368. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26369. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26370. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26371. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26372. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26373. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26374. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26375. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26376. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26377. sleepBody(impostor: PhysicsImpostor): void;
  26378. wakeUpBody(impostor: PhysicsImpostor): void;
  26379. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26380. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26381. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26382. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26383. getRadius(impostor: PhysicsImpostor): number;
  26384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26385. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26386. dispose(): void;
  26387. }
  26388. /**
  26389. * Interface used to define a physics engine
  26390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26391. */
  26392. export interface IPhysicsEngine {
  26393. /**
  26394. * Gets the gravity vector used by the simulation
  26395. */
  26396. gravity: Vector3;
  26397. /**
  26398. * Sets the gravity vector used by the simulation
  26399. * @param gravity defines the gravity vector to use
  26400. */
  26401. setGravity(gravity: Vector3): void;
  26402. /**
  26403. * Set the time step of the physics engine.
  26404. * Default is 1/60.
  26405. * To slow it down, enter 1/600 for example.
  26406. * To speed it up, 1/30
  26407. * @param newTimeStep the new timestep to apply to this world.
  26408. */
  26409. setTimeStep(newTimeStep: number): void;
  26410. /**
  26411. * Get the time step of the physics engine.
  26412. * @returns the current time step
  26413. */
  26414. getTimeStep(): number;
  26415. /**
  26416. * Set the sub time step of the physics engine.
  26417. * Default is 0 meaning there is no sub steps
  26418. * To increase physics resolution precision, set a small value (like 1 ms)
  26419. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26420. */
  26421. setSubTimeStep(subTimeStep: number): void;
  26422. /**
  26423. * Get the sub time step of the physics engine.
  26424. * @returns the current sub time step
  26425. */
  26426. getSubTimeStep(): number;
  26427. /**
  26428. * Release all resources
  26429. */
  26430. dispose(): void;
  26431. /**
  26432. * Gets the name of the current physics plugin
  26433. * @returns the name of the plugin
  26434. */
  26435. getPhysicsPluginName(): string;
  26436. /**
  26437. * Adding a new impostor for the impostor tracking.
  26438. * This will be done by the impostor itself.
  26439. * @param impostor the impostor to add
  26440. */
  26441. addImpostor(impostor: PhysicsImpostor): void;
  26442. /**
  26443. * Remove an impostor from the engine.
  26444. * This impostor and its mesh will not longer be updated by the physics engine.
  26445. * @param impostor the impostor to remove
  26446. */
  26447. removeImpostor(impostor: PhysicsImpostor): void;
  26448. /**
  26449. * Add a joint to the physics engine
  26450. * @param mainImpostor defines the main impostor to which the joint is added.
  26451. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26452. * @param joint defines the joint that will connect both impostors.
  26453. */
  26454. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26455. /**
  26456. * Removes a joint from the simulation
  26457. * @param mainImpostor defines the impostor used with the joint
  26458. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26459. * @param joint defines the joint to remove
  26460. */
  26461. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26462. /**
  26463. * Gets the current plugin used to run the simulation
  26464. * @returns current plugin
  26465. */
  26466. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26467. /**
  26468. * Gets the list of physic impostors
  26469. * @returns an array of PhysicsImpostor
  26470. */
  26471. getImpostors(): Array<PhysicsImpostor>;
  26472. /**
  26473. * Gets the impostor for a physics enabled object
  26474. * @param object defines the object impersonated by the impostor
  26475. * @returns the PhysicsImpostor or null if not found
  26476. */
  26477. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26478. /**
  26479. * Gets the impostor for a physics body object
  26480. * @param body defines physics body used by the impostor
  26481. * @returns the PhysicsImpostor or null if not found
  26482. */
  26483. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26484. /**
  26485. * Does a raycast in the physics world
  26486. * @param from when should the ray start?
  26487. * @param to when should the ray end?
  26488. * @returns PhysicsRaycastResult
  26489. */
  26490. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26491. /**
  26492. * Called by the scene. No need to call it.
  26493. * @param delta defines the timespam between frames
  26494. */
  26495. _step(delta: number): void;
  26496. }
  26497. }
  26498. declare module BABYLON {
  26499. /**
  26500. * The interface for the physics imposter parameters
  26501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26502. */
  26503. export interface PhysicsImpostorParameters {
  26504. /**
  26505. * The mass of the physics imposter
  26506. */
  26507. mass: number;
  26508. /**
  26509. * The friction of the physics imposter
  26510. */
  26511. friction?: number;
  26512. /**
  26513. * The coefficient of restitution of the physics imposter
  26514. */
  26515. restitution?: number;
  26516. /**
  26517. * The native options of the physics imposter
  26518. */
  26519. nativeOptions?: any;
  26520. /**
  26521. * Specifies if the parent should be ignored
  26522. */
  26523. ignoreParent?: boolean;
  26524. /**
  26525. * Specifies if bi-directional transformations should be disabled
  26526. */
  26527. disableBidirectionalTransformation?: boolean;
  26528. /**
  26529. * The pressure inside the physics imposter, soft object only
  26530. */
  26531. pressure?: number;
  26532. /**
  26533. * The stiffness the physics imposter, soft object only
  26534. */
  26535. stiffness?: number;
  26536. /**
  26537. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26538. */
  26539. velocityIterations?: number;
  26540. /**
  26541. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26542. */
  26543. positionIterations?: number;
  26544. /**
  26545. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26546. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26547. * Add to fix multiple points
  26548. */
  26549. fixedPoints?: number;
  26550. /**
  26551. * The collision margin around a soft object
  26552. */
  26553. margin?: number;
  26554. /**
  26555. * The collision margin around a soft object
  26556. */
  26557. damping?: number;
  26558. /**
  26559. * The path for a rope based on an extrusion
  26560. */
  26561. path?: any;
  26562. /**
  26563. * The shape of an extrusion used for a rope based on an extrusion
  26564. */
  26565. shape?: any;
  26566. }
  26567. /**
  26568. * Interface for a physics-enabled object
  26569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26570. */
  26571. export interface IPhysicsEnabledObject {
  26572. /**
  26573. * The position of the physics-enabled object
  26574. */
  26575. position: Vector3;
  26576. /**
  26577. * The rotation of the physics-enabled object
  26578. */
  26579. rotationQuaternion: Nullable<Quaternion>;
  26580. /**
  26581. * The scale of the physics-enabled object
  26582. */
  26583. scaling: Vector3;
  26584. /**
  26585. * The rotation of the physics-enabled object
  26586. */
  26587. rotation?: Vector3;
  26588. /**
  26589. * The parent of the physics-enabled object
  26590. */
  26591. parent?: any;
  26592. /**
  26593. * The bounding info of the physics-enabled object
  26594. * @returns The bounding info of the physics-enabled object
  26595. */
  26596. getBoundingInfo(): BoundingInfo;
  26597. /**
  26598. * Computes the world matrix
  26599. * @param force Specifies if the world matrix should be computed by force
  26600. * @returns A world matrix
  26601. */
  26602. computeWorldMatrix(force: boolean): Matrix;
  26603. /**
  26604. * Gets the world matrix
  26605. * @returns A world matrix
  26606. */
  26607. getWorldMatrix?(): Matrix;
  26608. /**
  26609. * Gets the child meshes
  26610. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26611. * @returns An array of abstract meshes
  26612. */
  26613. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26614. /**
  26615. * Gets the vertex data
  26616. * @param kind The type of vertex data
  26617. * @returns A nullable array of numbers, or a float32 array
  26618. */
  26619. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26620. /**
  26621. * Gets the indices from the mesh
  26622. * @returns A nullable array of index arrays
  26623. */
  26624. getIndices?(): Nullable<IndicesArray>;
  26625. /**
  26626. * Gets the scene from the mesh
  26627. * @returns the indices array or null
  26628. */
  26629. getScene?(): Scene;
  26630. /**
  26631. * Gets the absolute position from the mesh
  26632. * @returns the absolute position
  26633. */
  26634. getAbsolutePosition(): Vector3;
  26635. /**
  26636. * Gets the absolute pivot point from the mesh
  26637. * @returns the absolute pivot point
  26638. */
  26639. getAbsolutePivotPoint(): Vector3;
  26640. /**
  26641. * Rotates the mesh
  26642. * @param axis The axis of rotation
  26643. * @param amount The amount of rotation
  26644. * @param space The space of the rotation
  26645. * @returns The rotation transform node
  26646. */
  26647. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26648. /**
  26649. * Translates the mesh
  26650. * @param axis The axis of translation
  26651. * @param distance The distance of translation
  26652. * @param space The space of the translation
  26653. * @returns The transform node
  26654. */
  26655. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26656. /**
  26657. * Sets the absolute position of the mesh
  26658. * @param absolutePosition The absolute position of the mesh
  26659. * @returns The transform node
  26660. */
  26661. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26662. /**
  26663. * Gets the class name of the mesh
  26664. * @returns The class name
  26665. */
  26666. getClassName(): string;
  26667. }
  26668. /**
  26669. * Represents a physics imposter
  26670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26671. */
  26672. export class PhysicsImpostor {
  26673. /**
  26674. * The physics-enabled object used as the physics imposter
  26675. */
  26676. object: IPhysicsEnabledObject;
  26677. /**
  26678. * The type of the physics imposter
  26679. */
  26680. type: number;
  26681. private _options;
  26682. private _scene?;
  26683. /**
  26684. * The default object size of the imposter
  26685. */
  26686. static DEFAULT_OBJECT_SIZE: Vector3;
  26687. /**
  26688. * The identity quaternion of the imposter
  26689. */
  26690. static IDENTITY_QUATERNION: Quaternion;
  26691. /** @hidden */
  26692. _pluginData: any;
  26693. private _physicsEngine;
  26694. private _physicsBody;
  26695. private _bodyUpdateRequired;
  26696. private _onBeforePhysicsStepCallbacks;
  26697. private _onAfterPhysicsStepCallbacks;
  26698. /** @hidden */
  26699. _onPhysicsCollideCallbacks: Array<{
  26700. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26701. otherImpostors: Array<PhysicsImpostor>;
  26702. }>;
  26703. private _deltaPosition;
  26704. private _deltaRotation;
  26705. private _deltaRotationConjugated;
  26706. /** @hidden */
  26707. _isFromLine: boolean;
  26708. private _parent;
  26709. private _isDisposed;
  26710. private static _tmpVecs;
  26711. private static _tmpQuat;
  26712. /**
  26713. * Specifies if the physics imposter is disposed
  26714. */
  26715. get isDisposed(): boolean;
  26716. /**
  26717. * Gets the mass of the physics imposter
  26718. */
  26719. get mass(): number;
  26720. set mass(value: number);
  26721. /**
  26722. * Gets the coefficient of friction
  26723. */
  26724. get friction(): number;
  26725. /**
  26726. * Sets the coefficient of friction
  26727. */
  26728. set friction(value: number);
  26729. /**
  26730. * Gets the coefficient of restitution
  26731. */
  26732. get restitution(): number;
  26733. /**
  26734. * Sets the coefficient of restitution
  26735. */
  26736. set restitution(value: number);
  26737. /**
  26738. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26739. */
  26740. get pressure(): number;
  26741. /**
  26742. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26743. */
  26744. set pressure(value: number);
  26745. /**
  26746. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26747. */
  26748. get stiffness(): number;
  26749. /**
  26750. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26751. */
  26752. set stiffness(value: number);
  26753. /**
  26754. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26755. */
  26756. get velocityIterations(): number;
  26757. /**
  26758. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26759. */
  26760. set velocityIterations(value: number);
  26761. /**
  26762. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26763. */
  26764. get positionIterations(): number;
  26765. /**
  26766. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26767. */
  26768. set positionIterations(value: number);
  26769. /**
  26770. * The unique id of the physics imposter
  26771. * set by the physics engine when adding this impostor to the array
  26772. */
  26773. uniqueId: number;
  26774. /**
  26775. * @hidden
  26776. */
  26777. soft: boolean;
  26778. /**
  26779. * @hidden
  26780. */
  26781. segments: number;
  26782. private _joints;
  26783. /**
  26784. * Initializes the physics imposter
  26785. * @param object The physics-enabled object used as the physics imposter
  26786. * @param type The type of the physics imposter
  26787. * @param _options The options for the physics imposter
  26788. * @param _scene The Babylon scene
  26789. */
  26790. constructor(
  26791. /**
  26792. * The physics-enabled object used as the physics imposter
  26793. */
  26794. object: IPhysicsEnabledObject,
  26795. /**
  26796. * The type of the physics imposter
  26797. */
  26798. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26799. /**
  26800. * This function will completly initialize this impostor.
  26801. * It will create a new body - but only if this mesh has no parent.
  26802. * If it has, this impostor will not be used other than to define the impostor
  26803. * of the child mesh.
  26804. * @hidden
  26805. */
  26806. _init(): void;
  26807. private _getPhysicsParent;
  26808. /**
  26809. * Should a new body be generated.
  26810. * @returns boolean specifying if body initialization is required
  26811. */
  26812. isBodyInitRequired(): boolean;
  26813. /**
  26814. * Sets the updated scaling
  26815. * @param updated Specifies if the scaling is updated
  26816. */
  26817. setScalingUpdated(): void;
  26818. /**
  26819. * Force a regeneration of this or the parent's impostor's body.
  26820. * Use under cautious - This will remove all joints already implemented.
  26821. */
  26822. forceUpdate(): void;
  26823. /**
  26824. * Gets the body that holds this impostor. Either its own, or its parent.
  26825. */
  26826. get physicsBody(): any;
  26827. /**
  26828. * Get the parent of the physics imposter
  26829. * @returns Physics imposter or null
  26830. */
  26831. get parent(): Nullable<PhysicsImpostor>;
  26832. /**
  26833. * Sets the parent of the physics imposter
  26834. */
  26835. set parent(value: Nullable<PhysicsImpostor>);
  26836. /**
  26837. * Set the physics body. Used mainly by the physics engine/plugin
  26838. */
  26839. set physicsBody(physicsBody: any);
  26840. /**
  26841. * Resets the update flags
  26842. */
  26843. resetUpdateFlags(): void;
  26844. /**
  26845. * Gets the object extend size
  26846. * @returns the object extend size
  26847. */
  26848. getObjectExtendSize(): Vector3;
  26849. /**
  26850. * Gets the object center
  26851. * @returns The object center
  26852. */
  26853. getObjectCenter(): Vector3;
  26854. /**
  26855. * Get a specific parameter from the options parameters
  26856. * @param paramName The object parameter name
  26857. * @returns The object parameter
  26858. */
  26859. getParam(paramName: string): any;
  26860. /**
  26861. * Sets a specific parameter in the options given to the physics plugin
  26862. * @param paramName The parameter name
  26863. * @param value The value of the parameter
  26864. */
  26865. setParam(paramName: string, value: number): void;
  26866. /**
  26867. * Specifically change the body's mass option. Won't recreate the physics body object
  26868. * @param mass The mass of the physics imposter
  26869. */
  26870. setMass(mass: number): void;
  26871. /**
  26872. * Gets the linear velocity
  26873. * @returns linear velocity or null
  26874. */
  26875. getLinearVelocity(): Nullable<Vector3>;
  26876. /**
  26877. * Sets the linear velocity
  26878. * @param velocity linear velocity or null
  26879. */
  26880. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26881. /**
  26882. * Gets the angular velocity
  26883. * @returns angular velocity or null
  26884. */
  26885. getAngularVelocity(): Nullable<Vector3>;
  26886. /**
  26887. * Sets the angular velocity
  26888. * @param velocity The velocity or null
  26889. */
  26890. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26891. /**
  26892. * Execute a function with the physics plugin native code
  26893. * Provide a function the will have two variables - the world object and the physics body object
  26894. * @param func The function to execute with the physics plugin native code
  26895. */
  26896. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26897. /**
  26898. * Register a function that will be executed before the physics world is stepping forward
  26899. * @param func The function to execute before the physics world is stepped forward
  26900. */
  26901. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26902. /**
  26903. * Unregister 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. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26907. /**
  26908. * Register a function that will be executed after the physics step
  26909. * @param func The function to execute after physics step
  26910. */
  26911. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26912. /**
  26913. * Unregisters a function that will be executed after the physics step
  26914. * @param func The function to execute after physics step
  26915. */
  26916. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26917. /**
  26918. * register a function that will be executed when this impostor collides against a different body
  26919. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26920. * @param func Callback that is executed on collision
  26921. */
  26922. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26923. /**
  26924. * Unregisters the physics imposter on contact
  26925. * @param collideAgainst The physics object to collide against
  26926. * @param func Callback to execute on collision
  26927. */
  26928. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26929. private _tmpQuat;
  26930. private _tmpQuat2;
  26931. /**
  26932. * Get the parent rotation
  26933. * @returns The parent rotation
  26934. */
  26935. getParentsRotation(): Quaternion;
  26936. /**
  26937. * this function is executed by the physics engine.
  26938. */
  26939. beforeStep: () => void;
  26940. /**
  26941. * this function is executed by the physics engine
  26942. */
  26943. afterStep: () => void;
  26944. /**
  26945. * Legacy collision detection event support
  26946. */
  26947. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26948. /**
  26949. * event and body object due to cannon's event-based architecture.
  26950. */
  26951. onCollide: (e: {
  26952. body: any;
  26953. }) => void;
  26954. /**
  26955. * Apply a force
  26956. * @param force The force to apply
  26957. * @param contactPoint The contact point for the force
  26958. * @returns The physics imposter
  26959. */
  26960. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26961. /**
  26962. * Apply an impulse
  26963. * @param force The impulse force
  26964. * @param contactPoint The contact point for the impulse force
  26965. * @returns The physics imposter
  26966. */
  26967. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26968. /**
  26969. * A help function to create a joint
  26970. * @param otherImpostor A physics imposter used to create a joint
  26971. * @param jointType The type of joint
  26972. * @param jointData The data for the joint
  26973. * @returns The physics imposter
  26974. */
  26975. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26976. /**
  26977. * Add a joint to this impostor with a different impostor
  26978. * @param otherImpostor A physics imposter used to add a joint
  26979. * @param joint The joint to add
  26980. * @returns The physics imposter
  26981. */
  26982. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26983. /**
  26984. * Add an anchor to a cloth impostor
  26985. * @param otherImpostor rigid impostor to anchor to
  26986. * @param width ratio across width from 0 to 1
  26987. * @param height ratio up height from 0 to 1
  26988. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26989. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26990. * @returns impostor the soft imposter
  26991. */
  26992. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26993. /**
  26994. * Add a hook to a rope impostor
  26995. * @param otherImpostor rigid impostor to anchor to
  26996. * @param length ratio across rope from 0 to 1
  26997. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26998. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26999. * @returns impostor the rope imposter
  27000. */
  27001. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27002. /**
  27003. * Will keep this body still, in a sleep mode.
  27004. * @returns the physics imposter
  27005. */
  27006. sleep(): PhysicsImpostor;
  27007. /**
  27008. * Wake the body up.
  27009. * @returns The physics imposter
  27010. */
  27011. wakeUp(): PhysicsImpostor;
  27012. /**
  27013. * Clones the physics imposter
  27014. * @param newObject The physics imposter clones to this physics-enabled object
  27015. * @returns A nullable physics imposter
  27016. */
  27017. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27018. /**
  27019. * Disposes the physics imposter
  27020. */
  27021. dispose(): void;
  27022. /**
  27023. * Sets the delta position
  27024. * @param position The delta position amount
  27025. */
  27026. setDeltaPosition(position: Vector3): void;
  27027. /**
  27028. * Sets the delta rotation
  27029. * @param rotation The delta rotation amount
  27030. */
  27031. setDeltaRotation(rotation: Quaternion): void;
  27032. /**
  27033. * Gets the box size of the physics imposter and stores the result in the input parameter
  27034. * @param result Stores the box size
  27035. * @returns The physics imposter
  27036. */
  27037. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27038. /**
  27039. * Gets the radius of the physics imposter
  27040. * @returns Radius of the physics imposter
  27041. */
  27042. getRadius(): number;
  27043. /**
  27044. * Sync a bone with this impostor
  27045. * @param bone The bone to sync to the impostor.
  27046. * @param boneMesh The mesh that the bone is influencing.
  27047. * @param jointPivot The pivot of the joint / bone in local space.
  27048. * @param distToJoint Optional distance from the impostor to the joint.
  27049. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27050. */
  27051. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27052. /**
  27053. * Sync impostor to a bone
  27054. * @param bone The bone that the impostor will be synced to.
  27055. * @param boneMesh The mesh that the bone is influencing.
  27056. * @param jointPivot The pivot of the joint / bone in local space.
  27057. * @param distToJoint Optional distance from the impostor to the joint.
  27058. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27059. * @param boneAxis Optional vector3 axis the bone is aligned with
  27060. */
  27061. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27062. /**
  27063. * No-Imposter type
  27064. */
  27065. static NoImpostor: number;
  27066. /**
  27067. * Sphere-Imposter type
  27068. */
  27069. static SphereImpostor: number;
  27070. /**
  27071. * Box-Imposter type
  27072. */
  27073. static BoxImpostor: number;
  27074. /**
  27075. * Plane-Imposter type
  27076. */
  27077. static PlaneImpostor: number;
  27078. /**
  27079. * Mesh-imposter type
  27080. */
  27081. static MeshImpostor: number;
  27082. /**
  27083. * Capsule-Impostor type (Ammo.js plugin only)
  27084. */
  27085. static CapsuleImpostor: number;
  27086. /**
  27087. * Cylinder-Imposter type
  27088. */
  27089. static CylinderImpostor: number;
  27090. /**
  27091. * Particle-Imposter type
  27092. */
  27093. static ParticleImpostor: number;
  27094. /**
  27095. * Heightmap-Imposter type
  27096. */
  27097. static HeightmapImpostor: number;
  27098. /**
  27099. * ConvexHull-Impostor type (Ammo.js plugin only)
  27100. */
  27101. static ConvexHullImpostor: number;
  27102. /**
  27103. * Custom-Imposter type (Ammo.js plugin only)
  27104. */
  27105. static CustomImpostor: number;
  27106. /**
  27107. * Rope-Imposter type
  27108. */
  27109. static RopeImpostor: number;
  27110. /**
  27111. * Cloth-Imposter type
  27112. */
  27113. static ClothImpostor: number;
  27114. /**
  27115. * Softbody-Imposter type
  27116. */
  27117. static SoftbodyImpostor: number;
  27118. }
  27119. }
  27120. declare module BABYLON {
  27121. /**
  27122. * @hidden
  27123. **/
  27124. export class _CreationDataStorage {
  27125. closePath?: boolean;
  27126. closeArray?: boolean;
  27127. idx: number[];
  27128. dashSize: number;
  27129. gapSize: number;
  27130. path3D: Path3D;
  27131. pathArray: Vector3[][];
  27132. arc: number;
  27133. radius: number;
  27134. cap: number;
  27135. tessellation: number;
  27136. }
  27137. /**
  27138. * @hidden
  27139. **/
  27140. class _InstanceDataStorage {
  27141. visibleInstances: any;
  27142. batchCache: _InstancesBatch;
  27143. instancesBufferSize: number;
  27144. instancesBuffer: Nullable<Buffer>;
  27145. instancesData: Float32Array;
  27146. overridenInstanceCount: number;
  27147. isFrozen: boolean;
  27148. previousBatch: Nullable<_InstancesBatch>;
  27149. hardwareInstancedRendering: boolean;
  27150. sideOrientation: number;
  27151. manualUpdate: boolean;
  27152. }
  27153. /**
  27154. * @hidden
  27155. **/
  27156. export class _InstancesBatch {
  27157. mustReturn: boolean;
  27158. visibleInstances: Nullable<InstancedMesh[]>[];
  27159. renderSelf: boolean[];
  27160. hardwareInstancedRendering: boolean[];
  27161. }
  27162. /**
  27163. * @hidden
  27164. **/
  27165. class _ThinInstanceDataStorage {
  27166. instancesCount: number;
  27167. matrixBuffer: Nullable<Buffer>;
  27168. matrixBufferSize: number;
  27169. matrixData: Nullable<Float32Array>;
  27170. boundingVectors: Array<Vector3>;
  27171. }
  27172. /**
  27173. * Class used to represent renderable models
  27174. */
  27175. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27176. /**
  27177. * Mesh side orientation : usually the external or front surface
  27178. */
  27179. static readonly FRONTSIDE: number;
  27180. /**
  27181. * Mesh side orientation : usually the internal or back surface
  27182. */
  27183. static readonly BACKSIDE: number;
  27184. /**
  27185. * Mesh side orientation : both internal and external or front and back surfaces
  27186. */
  27187. static readonly DOUBLESIDE: number;
  27188. /**
  27189. * Mesh side orientation : by default, `FRONTSIDE`
  27190. */
  27191. static readonly DEFAULTSIDE: number;
  27192. /**
  27193. * Mesh cap setting : no cap
  27194. */
  27195. static readonly NO_CAP: number;
  27196. /**
  27197. * Mesh cap setting : one cap at the beginning of the mesh
  27198. */
  27199. static readonly CAP_START: number;
  27200. /**
  27201. * Mesh cap setting : one cap at the end of the mesh
  27202. */
  27203. static readonly CAP_END: number;
  27204. /**
  27205. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27206. */
  27207. static readonly CAP_ALL: number;
  27208. /**
  27209. * Mesh pattern setting : no flip or rotate
  27210. */
  27211. static readonly NO_FLIP: number;
  27212. /**
  27213. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27214. */
  27215. static readonly FLIP_TILE: number;
  27216. /**
  27217. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27218. */
  27219. static readonly ROTATE_TILE: number;
  27220. /**
  27221. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27222. */
  27223. static readonly FLIP_ROW: number;
  27224. /**
  27225. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27226. */
  27227. static readonly ROTATE_ROW: number;
  27228. /**
  27229. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27230. */
  27231. static readonly FLIP_N_ROTATE_TILE: number;
  27232. /**
  27233. * Mesh pattern setting : rotate pattern and rotate
  27234. */
  27235. static readonly FLIP_N_ROTATE_ROW: number;
  27236. /**
  27237. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27238. */
  27239. static readonly CENTER: number;
  27240. /**
  27241. * Mesh tile positioning : part tiles on left
  27242. */
  27243. static readonly LEFT: number;
  27244. /**
  27245. * Mesh tile positioning : part tiles on right
  27246. */
  27247. static readonly RIGHT: number;
  27248. /**
  27249. * Mesh tile positioning : part tiles on top
  27250. */
  27251. static readonly TOP: number;
  27252. /**
  27253. * Mesh tile positioning : part tiles on bottom
  27254. */
  27255. static readonly BOTTOM: number;
  27256. /**
  27257. * Gets the default side orientation.
  27258. * @param orientation the orientation to value to attempt to get
  27259. * @returns the default orientation
  27260. * @hidden
  27261. */
  27262. static _GetDefaultSideOrientation(orientation?: number): number;
  27263. private _internalMeshDataInfo;
  27264. /**
  27265. * An event triggered before rendering the mesh
  27266. */
  27267. get onBeforeRenderObservable(): Observable<Mesh>;
  27268. /**
  27269. * An event triggered before binding the mesh
  27270. */
  27271. get onBeforeBindObservable(): Observable<Mesh>;
  27272. /**
  27273. * An event triggered after rendering the mesh
  27274. */
  27275. get onAfterRenderObservable(): Observable<Mesh>;
  27276. /**
  27277. * An event triggered before drawing the mesh
  27278. */
  27279. get onBeforeDrawObservable(): Observable<Mesh>;
  27280. private _onBeforeDrawObserver;
  27281. /**
  27282. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27283. */
  27284. set onBeforeDraw(callback: () => void);
  27285. get hasInstances(): boolean;
  27286. get hasThinInstances(): boolean;
  27287. /**
  27288. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27289. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27290. */
  27291. delayLoadState: number;
  27292. /**
  27293. * Gets the list of instances created from this mesh
  27294. * it is not supposed to be modified manually.
  27295. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27296. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27297. */
  27298. instances: InstancedMesh[];
  27299. /**
  27300. * Gets the file containing delay loading data for this mesh
  27301. */
  27302. delayLoadingFile: string;
  27303. /** @hidden */
  27304. _binaryInfo: any;
  27305. /**
  27306. * User defined function used to change how LOD level selection is done
  27307. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27308. */
  27309. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27310. /**
  27311. * Gets or sets the morph target manager
  27312. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27313. */
  27314. get morphTargetManager(): Nullable<MorphTargetManager>;
  27315. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27316. /** @hidden */
  27317. _creationDataStorage: Nullable<_CreationDataStorage>;
  27318. /** @hidden */
  27319. _geometry: Nullable<Geometry>;
  27320. /** @hidden */
  27321. _delayInfo: Array<string>;
  27322. /** @hidden */
  27323. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27324. /** @hidden */
  27325. _instanceDataStorage: _InstanceDataStorage;
  27326. /** @hidden */
  27327. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27328. private _effectiveMaterial;
  27329. /** @hidden */
  27330. _shouldGenerateFlatShading: boolean;
  27331. /** @hidden */
  27332. _originalBuilderSideOrientation: number;
  27333. /**
  27334. * Use this property to change the original side orientation defined at construction time
  27335. */
  27336. overrideMaterialSideOrientation: Nullable<number>;
  27337. /**
  27338. * Gets the source mesh (the one used to clone this one from)
  27339. */
  27340. get source(): Nullable<Mesh>;
  27341. /**
  27342. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27343. */
  27344. get isUnIndexed(): boolean;
  27345. set isUnIndexed(value: boolean);
  27346. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27347. get worldMatrixInstancedBuffer(): Float32Array;
  27348. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27349. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27350. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27351. /**
  27352. * @constructor
  27353. * @param name The value used by scene.getMeshByName() to do a lookup.
  27354. * @param scene The scene to add this mesh to.
  27355. * @param parent The parent of this mesh, if it has one
  27356. * @param source An optional Mesh from which geometry is shared, cloned.
  27357. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27358. * When false, achieved by calling a clone(), also passing False.
  27359. * This will make creation of children, recursive.
  27360. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27361. */
  27362. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27363. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27364. doNotInstantiate: boolean;
  27365. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27366. /**
  27367. * Gets the class name
  27368. * @returns the string "Mesh".
  27369. */
  27370. getClassName(): string;
  27371. /** @hidden */
  27372. get _isMesh(): boolean;
  27373. /**
  27374. * Returns a description of this mesh
  27375. * @param fullDetails define if full details about this mesh must be used
  27376. * @returns a descriptive string representing this mesh
  27377. */
  27378. toString(fullDetails?: boolean): string;
  27379. /** @hidden */
  27380. _unBindEffect(): void;
  27381. /**
  27382. * Gets a boolean indicating if this mesh has LOD
  27383. */
  27384. get hasLODLevels(): boolean;
  27385. /**
  27386. * Gets the list of MeshLODLevel associated with the current mesh
  27387. * @returns an array of MeshLODLevel
  27388. */
  27389. getLODLevels(): MeshLODLevel[];
  27390. private _sortLODLevels;
  27391. /**
  27392. * Add a mesh as LOD level triggered at the given distance.
  27393. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27394. * @param distance The distance from the center of the object to show this level
  27395. * @param mesh The mesh to be added as LOD level (can be null)
  27396. * @return This mesh (for chaining)
  27397. */
  27398. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27399. /**
  27400. * Returns the LOD level mesh at the passed distance or null if not found.
  27401. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27402. * @param distance The distance from the center of the object to show this level
  27403. * @returns a Mesh or `null`
  27404. */
  27405. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27406. /**
  27407. * Remove a mesh from the LOD array
  27408. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27409. * @param mesh defines the mesh to be removed
  27410. * @return This mesh (for chaining)
  27411. */
  27412. removeLODLevel(mesh: Mesh): Mesh;
  27413. /**
  27414. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27415. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27416. * @param camera defines the camera to use to compute distance
  27417. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27418. * @return This mesh (for chaining)
  27419. */
  27420. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27421. /**
  27422. * Gets the mesh internal Geometry object
  27423. */
  27424. get geometry(): Nullable<Geometry>;
  27425. /**
  27426. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27427. * @returns the total number of vertices
  27428. */
  27429. getTotalVertices(): number;
  27430. /**
  27431. * Returns the content of an associated vertex buffer
  27432. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27433. * - VertexBuffer.PositionKind
  27434. * - VertexBuffer.UVKind
  27435. * - VertexBuffer.UV2Kind
  27436. * - VertexBuffer.UV3Kind
  27437. * - VertexBuffer.UV4Kind
  27438. * - VertexBuffer.UV5Kind
  27439. * - VertexBuffer.UV6Kind
  27440. * - VertexBuffer.ColorKind
  27441. * - VertexBuffer.MatricesIndicesKind
  27442. * - VertexBuffer.MatricesIndicesExtraKind
  27443. * - VertexBuffer.MatricesWeightsKind
  27444. * - VertexBuffer.MatricesWeightsExtraKind
  27445. * @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
  27446. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27447. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27448. */
  27449. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27450. /**
  27451. * Returns the mesh VertexBuffer object from the requested `kind`
  27452. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27453. * - VertexBuffer.PositionKind
  27454. * - VertexBuffer.NormalKind
  27455. * - VertexBuffer.UVKind
  27456. * - VertexBuffer.UV2Kind
  27457. * - VertexBuffer.UV3Kind
  27458. * - VertexBuffer.UV4Kind
  27459. * - VertexBuffer.UV5Kind
  27460. * - VertexBuffer.UV6Kind
  27461. * - VertexBuffer.ColorKind
  27462. * - VertexBuffer.MatricesIndicesKind
  27463. * - VertexBuffer.MatricesIndicesExtraKind
  27464. * - VertexBuffer.MatricesWeightsKind
  27465. * - VertexBuffer.MatricesWeightsExtraKind
  27466. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27467. */
  27468. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27469. /**
  27470. * Tests if a specific vertex buffer is associated with this mesh
  27471. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27472. * - VertexBuffer.PositionKind
  27473. * - VertexBuffer.NormalKind
  27474. * - VertexBuffer.UVKind
  27475. * - VertexBuffer.UV2Kind
  27476. * - VertexBuffer.UV3Kind
  27477. * - VertexBuffer.UV4Kind
  27478. * - VertexBuffer.UV5Kind
  27479. * - VertexBuffer.UV6Kind
  27480. * - VertexBuffer.ColorKind
  27481. * - VertexBuffer.MatricesIndicesKind
  27482. * - VertexBuffer.MatricesIndicesExtraKind
  27483. * - VertexBuffer.MatricesWeightsKind
  27484. * - VertexBuffer.MatricesWeightsExtraKind
  27485. * @returns a boolean
  27486. */
  27487. isVerticesDataPresent(kind: string): boolean;
  27488. /**
  27489. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27490. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27491. * - VertexBuffer.PositionKind
  27492. * - VertexBuffer.UVKind
  27493. * - VertexBuffer.UV2Kind
  27494. * - VertexBuffer.UV3Kind
  27495. * - VertexBuffer.UV4Kind
  27496. * - VertexBuffer.UV5Kind
  27497. * - VertexBuffer.UV6Kind
  27498. * - VertexBuffer.ColorKind
  27499. * - VertexBuffer.MatricesIndicesKind
  27500. * - VertexBuffer.MatricesIndicesExtraKind
  27501. * - VertexBuffer.MatricesWeightsKind
  27502. * - VertexBuffer.MatricesWeightsExtraKind
  27503. * @returns a boolean
  27504. */
  27505. isVertexBufferUpdatable(kind: string): boolean;
  27506. /**
  27507. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27508. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27509. * - VertexBuffer.PositionKind
  27510. * - VertexBuffer.NormalKind
  27511. * - VertexBuffer.UVKind
  27512. * - VertexBuffer.UV2Kind
  27513. * - VertexBuffer.UV3Kind
  27514. * - VertexBuffer.UV4Kind
  27515. * - VertexBuffer.UV5Kind
  27516. * - VertexBuffer.UV6Kind
  27517. * - VertexBuffer.ColorKind
  27518. * - VertexBuffer.MatricesIndicesKind
  27519. * - VertexBuffer.MatricesIndicesExtraKind
  27520. * - VertexBuffer.MatricesWeightsKind
  27521. * - VertexBuffer.MatricesWeightsExtraKind
  27522. * @returns an array of strings
  27523. */
  27524. getVerticesDataKinds(): string[];
  27525. /**
  27526. * Returns a positive integer : the total number of indices in this mesh geometry.
  27527. * @returns the numner of indices or zero if the mesh has no geometry.
  27528. */
  27529. getTotalIndices(): number;
  27530. /**
  27531. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27532. * @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.
  27533. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27534. * @returns the indices array or an empty array if the mesh has no geometry
  27535. */
  27536. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27537. get isBlocked(): boolean;
  27538. /**
  27539. * Determine if the current mesh is ready to be rendered
  27540. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27541. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27542. * @returns true if all associated assets are ready (material, textures, shaders)
  27543. */
  27544. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27545. /**
  27546. * 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.
  27547. */
  27548. get areNormalsFrozen(): boolean;
  27549. /**
  27550. * 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.
  27551. * @returns the current mesh
  27552. */
  27553. freezeNormals(): Mesh;
  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 reactivates the mesh normals computation if it was previously frozen
  27556. * @returns the current mesh
  27557. */
  27558. unfreezeNormals(): Mesh;
  27559. /**
  27560. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27561. */
  27562. set overridenInstanceCount(count: number);
  27563. /** @hidden */
  27564. _preActivate(): Mesh;
  27565. /** @hidden */
  27566. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27567. /** @hidden */
  27568. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27569. protected _afterComputeWorldMatrix(): void;
  27570. /** @hidden */
  27571. _postActivate(): void;
  27572. /**
  27573. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27574. * This means the mesh underlying bounding box and sphere are recomputed.
  27575. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27576. * @returns the current mesh
  27577. */
  27578. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27579. /** @hidden */
  27580. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27581. /**
  27582. * This function will subdivide the mesh into multiple submeshes
  27583. * @param count defines the expected number of submeshes
  27584. */
  27585. subdivide(count: number): void;
  27586. /**
  27587. * Copy a FloatArray into a specific associated vertex buffer
  27588. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27589. * - VertexBuffer.PositionKind
  27590. * - VertexBuffer.UVKind
  27591. * - VertexBuffer.UV2Kind
  27592. * - VertexBuffer.UV3Kind
  27593. * - VertexBuffer.UV4Kind
  27594. * - VertexBuffer.UV5Kind
  27595. * - VertexBuffer.UV6Kind
  27596. * - VertexBuffer.ColorKind
  27597. * - VertexBuffer.MatricesIndicesKind
  27598. * - VertexBuffer.MatricesIndicesExtraKind
  27599. * - VertexBuffer.MatricesWeightsKind
  27600. * - VertexBuffer.MatricesWeightsExtraKind
  27601. * @param data defines the data source
  27602. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27603. * @param stride defines the data stride size (can be null)
  27604. * @returns the current mesh
  27605. */
  27606. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27607. /**
  27608. * Delete a vertex buffer associated with this mesh
  27609. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27610. * - VertexBuffer.PositionKind
  27611. * - VertexBuffer.UVKind
  27612. * - VertexBuffer.UV2Kind
  27613. * - VertexBuffer.UV3Kind
  27614. * - VertexBuffer.UV4Kind
  27615. * - VertexBuffer.UV5Kind
  27616. * - VertexBuffer.UV6Kind
  27617. * - VertexBuffer.ColorKind
  27618. * - VertexBuffer.MatricesIndicesKind
  27619. * - VertexBuffer.MatricesIndicesExtraKind
  27620. * - VertexBuffer.MatricesWeightsKind
  27621. * - VertexBuffer.MatricesWeightsExtraKind
  27622. */
  27623. removeVerticesData(kind: string): void;
  27624. /**
  27625. * Flags an associated vertex buffer as updatable
  27626. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27627. * - VertexBuffer.PositionKind
  27628. * - VertexBuffer.UVKind
  27629. * - VertexBuffer.UV2Kind
  27630. * - VertexBuffer.UV3Kind
  27631. * - VertexBuffer.UV4Kind
  27632. * - VertexBuffer.UV5Kind
  27633. * - VertexBuffer.UV6Kind
  27634. * - VertexBuffer.ColorKind
  27635. * - VertexBuffer.MatricesIndicesKind
  27636. * - VertexBuffer.MatricesIndicesExtraKind
  27637. * - VertexBuffer.MatricesWeightsKind
  27638. * - VertexBuffer.MatricesWeightsExtraKind
  27639. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27640. */
  27641. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27642. /**
  27643. * Sets the mesh global Vertex Buffer
  27644. * @param buffer defines the buffer to use
  27645. * @returns the current mesh
  27646. */
  27647. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27648. /**
  27649. * Update a specific associated vertex buffer
  27650. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27651. * - VertexBuffer.PositionKind
  27652. * - VertexBuffer.UVKind
  27653. * - VertexBuffer.UV2Kind
  27654. * - VertexBuffer.UV3Kind
  27655. * - VertexBuffer.UV4Kind
  27656. * - VertexBuffer.UV5Kind
  27657. * - VertexBuffer.UV6Kind
  27658. * - VertexBuffer.ColorKind
  27659. * - VertexBuffer.MatricesIndicesKind
  27660. * - VertexBuffer.MatricesIndicesExtraKind
  27661. * - VertexBuffer.MatricesWeightsKind
  27662. * - VertexBuffer.MatricesWeightsExtraKind
  27663. * @param data defines the data source
  27664. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27665. * @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)
  27666. * @returns the current mesh
  27667. */
  27668. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27669. /**
  27670. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27671. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27672. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27673. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27674. * @returns the current mesh
  27675. */
  27676. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27677. /**
  27678. * Creates a un-shared specific occurence of the geometry for the mesh.
  27679. * @returns the current mesh
  27680. */
  27681. makeGeometryUnique(): Mesh;
  27682. /**
  27683. * Set the index buffer of this mesh
  27684. * @param indices defines the source data
  27685. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27686. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27687. * @returns the current mesh
  27688. */
  27689. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27690. /**
  27691. * Update the current index buffer
  27692. * @param indices defines the source data
  27693. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27694. * @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)
  27695. * @returns the current mesh
  27696. */
  27697. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27698. /**
  27699. * Invert the geometry to move from a right handed system to a left handed one.
  27700. * @returns the current mesh
  27701. */
  27702. toLeftHanded(): Mesh;
  27703. /** @hidden */
  27704. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27705. /** @hidden */
  27706. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27707. /**
  27708. * Registers for this mesh a javascript function called just before the rendering process
  27709. * @param func defines the function to call before rendering this mesh
  27710. * @returns the current mesh
  27711. */
  27712. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27713. /**
  27714. * Disposes a previously registered javascript function called before the rendering
  27715. * @param func defines the function to remove
  27716. * @returns the current mesh
  27717. */
  27718. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27719. /**
  27720. * Registers for this mesh a javascript function called just after the rendering is complete
  27721. * @param func defines the function to call after rendering this mesh
  27722. * @returns the current mesh
  27723. */
  27724. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27725. /**
  27726. * Disposes a previously registered javascript function called after the rendering.
  27727. * @param func defines the function to remove
  27728. * @returns the current mesh
  27729. */
  27730. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27731. /** @hidden */
  27732. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27733. /** @hidden */
  27734. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27735. /** @hidden */
  27736. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27737. /** @hidden */
  27738. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27739. /** @hidden */
  27740. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27741. /** @hidden */
  27742. _rebuild(): void;
  27743. /** @hidden */
  27744. _freeze(): void;
  27745. /** @hidden */
  27746. _unFreeze(): void;
  27747. /**
  27748. * 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
  27749. * @param subMesh defines the subMesh to render
  27750. * @param enableAlphaMode defines if alpha mode can be changed
  27751. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27752. * @returns the current mesh
  27753. */
  27754. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27755. private _onBeforeDraw;
  27756. /**
  27757. * Renormalize the mesh and patch it up if there are no weights
  27758. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27759. * However in the case of zero weights then we set just a single influence to 1.
  27760. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27761. */
  27762. cleanMatrixWeights(): void;
  27763. private normalizeSkinFourWeights;
  27764. private normalizeSkinWeightsAndExtra;
  27765. /**
  27766. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27767. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27768. * the user know there was an issue with importing the mesh
  27769. * @returns a validation object with skinned, valid and report string
  27770. */
  27771. validateSkinning(): {
  27772. skinned: boolean;
  27773. valid: boolean;
  27774. report: string;
  27775. };
  27776. /** @hidden */
  27777. _checkDelayState(): Mesh;
  27778. private _queueLoad;
  27779. /**
  27780. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27781. * A mesh is in the frustum if its bounding box intersects the frustum
  27782. * @param frustumPlanes defines the frustum to test
  27783. * @returns true if the mesh is in the frustum planes
  27784. */
  27785. isInFrustum(frustumPlanes: Plane[]): boolean;
  27786. /**
  27787. * Sets the mesh material by the material or multiMaterial `id` property
  27788. * @param id is a string identifying the material or the multiMaterial
  27789. * @returns the current mesh
  27790. */
  27791. setMaterialByID(id: string): Mesh;
  27792. /**
  27793. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27794. * @returns an array of IAnimatable
  27795. */
  27796. getAnimatables(): IAnimatable[];
  27797. /**
  27798. * Modifies the mesh geometry according to the passed transformation matrix.
  27799. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27800. * The mesh normals are modified using the same transformation.
  27801. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27802. * @param transform defines the transform matrix to use
  27803. * @see https://doc.babylonjs.com/resources/baking_transformations
  27804. * @returns the current mesh
  27805. */
  27806. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27807. /**
  27808. * Modifies the mesh geometry according to its own current World Matrix.
  27809. * The mesh World Matrix is then reset.
  27810. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27811. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27812. * @see https://doc.babylonjs.com/resources/baking_transformations
  27813. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27814. * @returns the current mesh
  27815. */
  27816. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27817. /** @hidden */
  27818. get _positions(): Nullable<Vector3[]>;
  27819. /** @hidden */
  27820. _resetPointsArrayCache(): Mesh;
  27821. /** @hidden */
  27822. _generatePointsArray(): boolean;
  27823. /**
  27824. * Returns a new Mesh object generated from the current mesh properties.
  27825. * This method must not get confused with createInstance()
  27826. * @param name is a string, the name given to the new mesh
  27827. * @param newParent can be any Node object (default `null`)
  27828. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27829. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27830. * @returns a new mesh
  27831. */
  27832. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27833. /**
  27834. * Releases resources associated with this mesh.
  27835. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27836. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27837. */
  27838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27839. /** @hidden */
  27840. _disposeInstanceSpecificData(): void;
  27841. /** @hidden */
  27842. _disposeThinInstanceSpecificData(): void;
  27843. /**
  27844. * Modifies the mesh geometry according to a displacement map.
  27845. * 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.
  27846. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27847. * @param url is a string, the URL from the image file is to be downloaded.
  27848. * @param minHeight is the lower limit of the displacement.
  27849. * @param maxHeight is the upper limit of the displacement.
  27850. * @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.
  27851. * @param uvOffset is an optional vector2 used to offset UV.
  27852. * @param uvScale is an optional vector2 used to scale UV.
  27853. * @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.
  27854. * @returns the Mesh.
  27855. */
  27856. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27857. /**
  27858. * Modifies the mesh geometry according to a displacementMap buffer.
  27859. * 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.
  27860. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27861. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27862. * @param heightMapWidth is the width of the buffer image.
  27863. * @param heightMapHeight is the height of the buffer image.
  27864. * @param minHeight is the lower limit of the displacement.
  27865. * @param maxHeight is the upper limit of the displacement.
  27866. * @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.
  27867. * @param uvOffset is an optional vector2 used to offset UV.
  27868. * @param uvScale is an optional vector2 used to scale UV.
  27869. * @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.
  27870. * @returns the Mesh.
  27871. */
  27872. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27873. /**
  27874. * Modify the mesh to get a flat shading rendering.
  27875. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27876. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27877. * @returns current mesh
  27878. */
  27879. convertToFlatShadedMesh(): Mesh;
  27880. /**
  27881. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27882. * In other words, more vertices, no more indices and a single bigger VBO.
  27883. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27884. * @returns current mesh
  27885. */
  27886. convertToUnIndexedMesh(): Mesh;
  27887. /**
  27888. * Inverses facet orientations.
  27889. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27890. * @param flipNormals will also inverts the normals
  27891. * @returns current mesh
  27892. */
  27893. flipFaces(flipNormals?: boolean): Mesh;
  27894. /**
  27895. * Increase the number of facets and hence vertices in a mesh
  27896. * Vertex normals are interpolated from existing vertex normals
  27897. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27898. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27899. */
  27900. increaseVertices(numberPerEdge: number): void;
  27901. /**
  27902. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27903. * This will undo any application of covertToFlatShadedMesh
  27904. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27905. */
  27906. forceSharedVertices(): void;
  27907. /** @hidden */
  27908. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27909. /** @hidden */
  27910. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27911. /**
  27912. * Creates a new InstancedMesh object from the mesh model.
  27913. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27914. * @param name defines the name of the new instance
  27915. * @returns a new InstancedMesh
  27916. */
  27917. createInstance(name: string): InstancedMesh;
  27918. /**
  27919. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27920. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27921. * @returns the current mesh
  27922. */
  27923. synchronizeInstances(): Mesh;
  27924. /**
  27925. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27926. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27927. * This should be used together with the simplification to avoid disappearing triangles.
  27928. * @param successCallback an optional success callback to be called after the optimization finished.
  27929. * @returns the current mesh
  27930. */
  27931. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27932. /**
  27933. * Serialize current mesh
  27934. * @param serializationObject defines the object which will receive the serialization data
  27935. */
  27936. serialize(serializationObject: any): void;
  27937. /** @hidden */
  27938. _syncGeometryWithMorphTargetManager(): void;
  27939. /** @hidden */
  27940. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27941. /**
  27942. * Returns a new Mesh object parsed from the source provided.
  27943. * @param parsedMesh is the source
  27944. * @param scene defines the hosting scene
  27945. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27946. * @returns a new Mesh
  27947. */
  27948. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27949. /**
  27950. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27951. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  27952. * @param name defines the name of the mesh to create
  27953. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27954. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27955. * @param closePath creates a seam between the first and the last points of each path of the path array
  27956. * @param offset is taken in account only if the `pathArray` is containing a single path
  27957. * @param scene defines the hosting scene
  27958. * @param updatable defines if the mesh must be flagged as updatable
  27959. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27960. * @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)
  27961. * @returns a new Mesh
  27962. */
  27963. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27964. /**
  27965. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27966. * @param name defines the name of the mesh to create
  27967. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27968. * @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
  27969. * @param scene defines the hosting scene
  27970. * @param updatable defines if the mesh must be flagged as updatable
  27971. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27972. * @returns a new Mesh
  27973. */
  27974. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27975. /**
  27976. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27977. * @param name defines the name of the mesh to create
  27978. * @param size sets the size (float) of each box side (default 1)
  27979. * @param scene defines the hosting scene
  27980. * @param updatable defines if the mesh must be flagged as updatable
  27981. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27982. * @returns a new Mesh
  27983. */
  27984. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27985. /**
  27986. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27987. * @param name defines the name of the mesh to create
  27988. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27989. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27990. * @param scene defines the hosting scene
  27991. * @param updatable defines if the mesh must be flagged as updatable
  27992. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27993. * @returns a new Mesh
  27994. */
  27995. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27996. /**
  27997. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27998. * @param name defines the name of the mesh to create
  27999. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28000. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28001. * @param scene defines the hosting scene
  28002. * @returns a new Mesh
  28003. */
  28004. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28005. /**
  28006. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28007. * @param name defines the name of the mesh to create
  28008. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28009. * @param diameterTop set the top cap diameter (floats, default 1)
  28010. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28011. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28012. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28013. * @param scene defines the hosting scene
  28014. * @param updatable defines if the mesh must be flagged as updatable
  28015. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28016. * @returns a new Mesh
  28017. */
  28018. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28019. /**
  28020. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28021. * @param name defines the name of the mesh to create
  28022. * @param diameter sets the diameter size (float) of the torus (default 1)
  28023. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28024. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28025. * @param scene defines the hosting scene
  28026. * @param updatable defines if the mesh must be flagged as updatable
  28027. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28028. * @returns a new Mesh
  28029. */
  28030. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28031. /**
  28032. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28033. * @param name defines the name of the mesh to create
  28034. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28035. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28036. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28037. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28038. * @param p the number of windings on X axis (positive integers, default 2)
  28039. * @param q the number of windings on Y axis (positive integers, default 3)
  28040. * @param scene defines the hosting scene
  28041. * @param updatable defines if the mesh must be flagged as updatable
  28042. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28043. * @returns a new Mesh
  28044. */
  28045. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28046. /**
  28047. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28048. * @param name defines the name of the mesh to create
  28049. * @param points is an array successive Vector3
  28050. * @param scene defines the hosting scene
  28051. * @param updatable defines if the mesh must be flagged as updatable
  28052. * @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).
  28053. * @returns a new Mesh
  28054. */
  28055. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28056. /**
  28057. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28058. * @param name defines the name of the mesh to create
  28059. * @param points is an array successive Vector3
  28060. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28061. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28062. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28063. * @param scene defines the hosting scene
  28064. * @param updatable defines if the mesh must be flagged as updatable
  28065. * @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)
  28066. * @returns a new Mesh
  28067. */
  28068. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28069. /**
  28070. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28071. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28072. * 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.
  28073. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28074. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28075. * Remember you can only change the shape positions, not their number when updating a polygon.
  28076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28077. * @param name defines the name of the mesh to create
  28078. * @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
  28079. * @param scene defines the hosting scene
  28080. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28081. * @param updatable defines if the mesh must be flagged as updatable
  28082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28083. * @param earcutInjection can be used to inject your own earcut reference
  28084. * @returns a new Mesh
  28085. */
  28086. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28087. /**
  28088. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28090. * @param name defines the name of the mesh to create
  28091. * @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
  28092. * @param depth defines the height of extrusion
  28093. * @param scene defines the hosting scene
  28094. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28095. * @param updatable defines if the mesh must be flagged as updatable
  28096. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28097. * @param earcutInjection can be used to inject your own earcut reference
  28098. * @returns a new Mesh
  28099. */
  28100. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28101. /**
  28102. * Creates an extruded shape mesh.
  28103. * 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
  28104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28106. * @param name defines the name of the mesh to create
  28107. * @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
  28108. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28109. * @param scale is the value to scale the shape
  28110. * @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
  28111. * @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
  28112. * @param scene defines the hosting scene
  28113. * @param updatable defines if the mesh must be flagged as updatable
  28114. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28115. * @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)
  28116. * @returns a new Mesh
  28117. */
  28118. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28119. /**
  28120. * Creates an custom extruded shape mesh.
  28121. * The custom extrusion is a parametric shape.
  28122. * It has no predefined shape. Its final shape will depend on the input parameters.
  28123. * Please consider using the same method from the MeshBuilder class instead
  28124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28125. * @param name defines the name of the mesh to create
  28126. * @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
  28127. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28128. * @param scaleFunction is a custom Javascript function called on each path point
  28129. * @param rotationFunction is a custom Javascript function called on each path point
  28130. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28131. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28132. * @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
  28133. * @param scene defines the hosting scene
  28134. * @param updatable defines if the mesh must be flagged as updatable
  28135. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28136. * @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)
  28137. * @returns a new Mesh
  28138. */
  28139. 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;
  28140. /**
  28141. * Creates lathe mesh.
  28142. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28143. * Please consider using the same method from the MeshBuilder class instead
  28144. * @param name defines the name of the mesh to create
  28145. * @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
  28146. * @param radius is the radius value of the lathe
  28147. * @param tessellation is the side number of the lathe.
  28148. * @param scene defines the hosting scene
  28149. * @param updatable defines if the mesh must be flagged as updatable
  28150. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28151. * @returns a new Mesh
  28152. */
  28153. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28154. /**
  28155. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28156. * @param name defines the name of the mesh to create
  28157. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28158. * @param scene defines the hosting scene
  28159. * @param updatable defines if the mesh must be flagged as updatable
  28160. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28161. * @returns a new Mesh
  28162. */
  28163. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28164. /**
  28165. * Creates a ground mesh.
  28166. * Please consider using the same method from the MeshBuilder class instead
  28167. * @param name defines the name of the mesh to create
  28168. * @param width set the width of the ground
  28169. * @param height set the height of the ground
  28170. * @param subdivisions sets the number of subdivisions per side
  28171. * @param scene defines the hosting scene
  28172. * @param updatable defines if the mesh must be flagged as updatable
  28173. * @returns a new Mesh
  28174. */
  28175. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28176. /**
  28177. * Creates a tiled ground mesh.
  28178. * Please consider using the same method from the MeshBuilder class instead
  28179. * @param name defines the name of the mesh to create
  28180. * @param xmin set the ground minimum X coordinate
  28181. * @param zmin set the ground minimum Y coordinate
  28182. * @param xmax set the ground maximum X coordinate
  28183. * @param zmax set the ground maximum Z coordinate
  28184. * @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
  28185. * @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
  28186. * @param scene defines the hosting scene
  28187. * @param updatable defines if the mesh must be flagged as updatable
  28188. * @returns a new Mesh
  28189. */
  28190. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28191. w: number;
  28192. h: number;
  28193. }, precision: {
  28194. w: number;
  28195. h: number;
  28196. }, scene: Scene, updatable?: boolean): Mesh;
  28197. /**
  28198. * Creates a ground mesh from a height map.
  28199. * Please consider using the same method from the MeshBuilder class instead
  28200. * @see https://doc.babylonjs.com/babylon101/height_map
  28201. * @param name defines the name of the mesh to create
  28202. * @param url sets the URL of the height map image resource
  28203. * @param width set the ground width size
  28204. * @param height set the ground height size
  28205. * @param subdivisions sets the number of subdivision per side
  28206. * @param minHeight is the minimum altitude on the ground
  28207. * @param maxHeight is the maximum altitude on the ground
  28208. * @param scene defines the hosting scene
  28209. * @param updatable defines if the mesh must be flagged as updatable
  28210. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28211. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28212. * @returns a new Mesh
  28213. */
  28214. 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;
  28215. /**
  28216. * Creates a tube mesh.
  28217. * The tube is a parametric shape.
  28218. * It has no predefined shape. Its final shape will depend on the input parameters.
  28219. * Please consider using the same method from the MeshBuilder class instead
  28220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28221. * @param name defines the name of the mesh to create
  28222. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28223. * @param radius sets the tube radius size
  28224. * @param tessellation is the number of sides on the tubular surface
  28225. * @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
  28226. * @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
  28227. * @param scene defines the hosting scene
  28228. * @param updatable defines if the mesh must be flagged as updatable
  28229. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28230. * @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)
  28231. * @returns a new Mesh
  28232. */
  28233. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28234. (i: number, distance: number): number;
  28235. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28236. /**
  28237. * Creates a polyhedron mesh.
  28238. * Please consider using the same method from the MeshBuilder class instead.
  28239. * * 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
  28240. * * The parameter `size` (positive float, default 1) sets the polygon size
  28241. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28242. * * 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`
  28243. * * 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
  28244. * * 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)`)
  28245. * * 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
  28246. * * 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
  28247. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28248. * * 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
  28249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28250. * @param name defines the name of the mesh to create
  28251. * @param options defines the options used to create the mesh
  28252. * @param scene defines the hosting scene
  28253. * @returns a new Mesh
  28254. */
  28255. static CreatePolyhedron(name: string, options: {
  28256. type?: number;
  28257. size?: number;
  28258. sizeX?: number;
  28259. sizeY?: number;
  28260. sizeZ?: number;
  28261. custom?: any;
  28262. faceUV?: Vector4[];
  28263. faceColors?: Color4[];
  28264. updatable?: boolean;
  28265. sideOrientation?: number;
  28266. }, scene: Scene): Mesh;
  28267. /**
  28268. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28269. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28270. * * 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`)
  28271. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28272. * * 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
  28273. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28276. * @param name defines the name of the mesh
  28277. * @param options defines the options used to create the mesh
  28278. * @param scene defines the hosting scene
  28279. * @returns a new Mesh
  28280. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28281. */
  28282. static CreateIcoSphere(name: string, options: {
  28283. radius?: number;
  28284. flat?: boolean;
  28285. subdivisions?: number;
  28286. sideOrientation?: number;
  28287. updatable?: boolean;
  28288. }, scene: Scene): Mesh;
  28289. /**
  28290. * Creates a decal mesh.
  28291. * Please consider using the same method from the MeshBuilder class instead.
  28292. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28293. * @param name defines the name of the mesh
  28294. * @param sourceMesh defines the mesh receiving the decal
  28295. * @param position sets the position of the decal in world coordinates
  28296. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28297. * @param size sets the decal scaling
  28298. * @param angle sets the angle to rotate the decal
  28299. * @returns a new Mesh
  28300. */
  28301. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28302. /**
  28303. * Prepare internal position array for software CPU skinning
  28304. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28305. */
  28306. setPositionsForCPUSkinning(): Float32Array;
  28307. /**
  28308. * Prepare internal normal array for software CPU skinning
  28309. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28310. */
  28311. setNormalsForCPUSkinning(): Float32Array;
  28312. /**
  28313. * Updates the vertex buffer by applying transformation from the bones
  28314. * @param skeleton defines the skeleton to apply to current mesh
  28315. * @returns the current mesh
  28316. */
  28317. applySkeleton(skeleton: Skeleton): Mesh;
  28318. /**
  28319. * 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
  28320. * @param meshes defines the list of meshes to scan
  28321. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28322. */
  28323. static MinMax(meshes: AbstractMesh[]): {
  28324. min: Vector3;
  28325. max: Vector3;
  28326. };
  28327. /**
  28328. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28329. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28330. * @returns a vector3
  28331. */
  28332. static Center(meshesOrMinMaxVector: {
  28333. min: Vector3;
  28334. max: Vector3;
  28335. } | AbstractMesh[]): Vector3;
  28336. /**
  28337. * Merge the array of meshes into a single mesh for performance reasons.
  28338. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28339. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28340. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28341. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28342. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28343. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28344. * @returns a new mesh
  28345. */
  28346. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28347. /** @hidden */
  28348. addInstance(instance: InstancedMesh): void;
  28349. /** @hidden */
  28350. removeInstance(instance: InstancedMesh): void;
  28351. }
  28352. }
  28353. declare module BABYLON {
  28354. /**
  28355. * This is the base class of all the camera used in the application.
  28356. * @see https://doc.babylonjs.com/features/cameras
  28357. */
  28358. export class Camera extends Node {
  28359. /** @hidden */
  28360. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28361. /**
  28362. * This is the default projection mode used by the cameras.
  28363. * It helps recreating a feeling of perspective and better appreciate depth.
  28364. * This is the best way to simulate real life cameras.
  28365. */
  28366. static readonly PERSPECTIVE_CAMERA: number;
  28367. /**
  28368. * This helps creating camera with an orthographic mode.
  28369. * 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.
  28370. */
  28371. static readonly ORTHOGRAPHIC_CAMERA: number;
  28372. /**
  28373. * This is the default FOV mode for perspective cameras.
  28374. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28375. */
  28376. static readonly FOVMODE_VERTICAL_FIXED: number;
  28377. /**
  28378. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28379. */
  28380. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28381. /**
  28382. * This specifies ther is no need for a camera rig.
  28383. * Basically only one eye is rendered corresponding to the camera.
  28384. */
  28385. static readonly RIG_MODE_NONE: number;
  28386. /**
  28387. * Simulates a camera Rig with one blue eye and one red eye.
  28388. * This can be use with 3d blue and red glasses.
  28389. */
  28390. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28391. /**
  28392. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28393. */
  28394. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28395. /**
  28396. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28397. */
  28398. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28399. /**
  28400. * Defines that both eyes of the camera will be rendered over under each other.
  28401. */
  28402. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28403. /**
  28404. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28405. */
  28406. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28407. /**
  28408. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28409. */
  28410. static readonly RIG_MODE_VR: number;
  28411. /**
  28412. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28413. */
  28414. static readonly RIG_MODE_WEBVR: number;
  28415. /**
  28416. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28417. */
  28418. static readonly RIG_MODE_CUSTOM: number;
  28419. /**
  28420. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28421. */
  28422. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28423. /**
  28424. * Define the input manager associated with the camera.
  28425. */
  28426. inputs: CameraInputsManager<Camera>;
  28427. /** @hidden */
  28428. _position: Vector3;
  28429. /**
  28430. * Define the current local position of the camera in the scene
  28431. */
  28432. get position(): Vector3;
  28433. set position(newPosition: Vector3);
  28434. /**
  28435. * The vector the camera should consider as up.
  28436. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28437. */
  28438. upVector: Vector3;
  28439. /**
  28440. * Define the current limit on the left side for an orthographic camera
  28441. * In scene unit
  28442. */
  28443. orthoLeft: Nullable<number>;
  28444. /**
  28445. * Define the current limit on the right side for an orthographic camera
  28446. * In scene unit
  28447. */
  28448. orthoRight: Nullable<number>;
  28449. /**
  28450. * Define the current limit on the bottom side for an orthographic camera
  28451. * In scene unit
  28452. */
  28453. orthoBottom: Nullable<number>;
  28454. /**
  28455. * Define the current limit on the top side for an orthographic camera
  28456. * In scene unit
  28457. */
  28458. orthoTop: Nullable<number>;
  28459. /**
  28460. * Field Of View is set in Radians. (default is 0.8)
  28461. */
  28462. fov: number;
  28463. /**
  28464. * Define the minimum distance the camera can see from.
  28465. * This is important to note that the depth buffer are not infinite and the closer it starts
  28466. * the more your scene might encounter depth fighting issue.
  28467. */
  28468. minZ: number;
  28469. /**
  28470. * Define the maximum distance the camera can see to.
  28471. * This is important to note that the depth buffer are not infinite and the further it end
  28472. * the more your scene might encounter depth fighting issue.
  28473. */
  28474. maxZ: number;
  28475. /**
  28476. * Define the default inertia of the camera.
  28477. * This helps giving a smooth feeling to the camera movement.
  28478. */
  28479. inertia: number;
  28480. /**
  28481. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28482. */
  28483. mode: number;
  28484. /**
  28485. * Define whether the camera is intermediate.
  28486. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28487. */
  28488. isIntermediate: boolean;
  28489. /**
  28490. * Define the viewport of the camera.
  28491. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28492. */
  28493. viewport: Viewport;
  28494. /**
  28495. * Restricts the camera to viewing objects with the same layerMask.
  28496. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28497. */
  28498. layerMask: number;
  28499. /**
  28500. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28501. */
  28502. fovMode: number;
  28503. /**
  28504. * Rig mode of the camera.
  28505. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28506. * This is normally controlled byt the camera themselves as internal use.
  28507. */
  28508. cameraRigMode: number;
  28509. /**
  28510. * Defines the distance between both "eyes" in case of a RIG
  28511. */
  28512. interaxialDistance: number;
  28513. /**
  28514. * Defines if stereoscopic rendering is done side by side or over under.
  28515. */
  28516. isStereoscopicSideBySide: boolean;
  28517. /**
  28518. * 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
  28519. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28520. * else in the scene. (Eg. security camera)
  28521. *
  28522. * 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)
  28523. */
  28524. customRenderTargets: RenderTargetTexture[];
  28525. /**
  28526. * When set, the camera will render to this render target instead of the default canvas
  28527. *
  28528. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28529. */
  28530. outputRenderTarget: Nullable<RenderTargetTexture>;
  28531. /**
  28532. * Observable triggered when the camera view matrix has changed.
  28533. */
  28534. onViewMatrixChangedObservable: Observable<Camera>;
  28535. /**
  28536. * Observable triggered when the camera Projection matrix has changed.
  28537. */
  28538. onProjectionMatrixChangedObservable: Observable<Camera>;
  28539. /**
  28540. * Observable triggered when the inputs have been processed.
  28541. */
  28542. onAfterCheckInputsObservable: Observable<Camera>;
  28543. /**
  28544. * Observable triggered when reset has been called and applied to the camera.
  28545. */
  28546. onRestoreStateObservable: Observable<Camera>;
  28547. /**
  28548. * Is this camera a part of a rig system?
  28549. */
  28550. isRigCamera: boolean;
  28551. /**
  28552. * If isRigCamera set to true this will be set with the parent camera.
  28553. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28554. */
  28555. rigParent?: Camera;
  28556. /** @hidden */
  28557. _cameraRigParams: any;
  28558. /** @hidden */
  28559. _rigCameras: Camera[];
  28560. /** @hidden */
  28561. _rigPostProcess: Nullable<PostProcess>;
  28562. protected _webvrViewMatrix: Matrix;
  28563. /** @hidden */
  28564. _skipRendering: boolean;
  28565. /** @hidden */
  28566. _projectionMatrix: Matrix;
  28567. /** @hidden */
  28568. _postProcesses: Nullable<PostProcess>[];
  28569. /** @hidden */
  28570. _activeMeshes: SmartArray<AbstractMesh>;
  28571. protected _globalPosition: Vector3;
  28572. /** @hidden */
  28573. _computedViewMatrix: Matrix;
  28574. private _doNotComputeProjectionMatrix;
  28575. private _transformMatrix;
  28576. private _frustumPlanes;
  28577. private _refreshFrustumPlanes;
  28578. private _storedFov;
  28579. private _stateStored;
  28580. /**
  28581. * Instantiates a new camera object.
  28582. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28583. * @see https://doc.babylonjs.com/features/cameras
  28584. * @param name Defines the name of the camera in the scene
  28585. * @param position Defines the position of the camera
  28586. * @param scene Defines the scene the camera belongs too
  28587. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28588. */
  28589. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28590. /**
  28591. * Store current camera state (fov, position, etc..)
  28592. * @returns the camera
  28593. */
  28594. storeState(): Camera;
  28595. /**
  28596. * Restores the camera state values if it has been stored. You must call storeState() first
  28597. */
  28598. protected _restoreStateValues(): boolean;
  28599. /**
  28600. * Restored camera state. You must call storeState() first.
  28601. * @returns true if restored and false otherwise
  28602. */
  28603. restoreState(): boolean;
  28604. /**
  28605. * Gets the class name of the camera.
  28606. * @returns the class name
  28607. */
  28608. getClassName(): string;
  28609. /** @hidden */
  28610. readonly _isCamera: boolean;
  28611. /**
  28612. * Gets a string representation of the camera useful for debug purpose.
  28613. * @param fullDetails Defines that a more verboe level of logging is required
  28614. * @returns the string representation
  28615. */
  28616. toString(fullDetails?: boolean): string;
  28617. /**
  28618. * Gets the current world space position of the camera.
  28619. */
  28620. get globalPosition(): Vector3;
  28621. /**
  28622. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28623. * @returns the active meshe list
  28624. */
  28625. getActiveMeshes(): SmartArray<AbstractMesh>;
  28626. /**
  28627. * Check whether a mesh is part of the current active mesh list of the camera
  28628. * @param mesh Defines the mesh to check
  28629. * @returns true if active, false otherwise
  28630. */
  28631. isActiveMesh(mesh: Mesh): boolean;
  28632. /**
  28633. * Is this camera ready to be used/rendered
  28634. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28635. * @return true if the camera is ready
  28636. */
  28637. isReady(completeCheck?: boolean): boolean;
  28638. /** @hidden */
  28639. _initCache(): void;
  28640. /** @hidden */
  28641. _updateCache(ignoreParentClass?: boolean): void;
  28642. /** @hidden */
  28643. _isSynchronized(): boolean;
  28644. /** @hidden */
  28645. _isSynchronizedViewMatrix(): boolean;
  28646. /** @hidden */
  28647. _isSynchronizedProjectionMatrix(): boolean;
  28648. /**
  28649. * Attach the input controls to a specific dom element to get the input from.
  28650. * @param element Defines the element the controls should be listened from
  28651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28652. */
  28653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28654. /**
  28655. * Detach the current controls from the specified dom element.
  28656. * @param element Defines the element to stop listening the inputs from
  28657. */
  28658. detachControl(element: HTMLElement): void;
  28659. /**
  28660. * Update the camera state according to the different inputs gathered during the frame.
  28661. */
  28662. update(): void;
  28663. /** @hidden */
  28664. _checkInputs(): void;
  28665. /** @hidden */
  28666. get rigCameras(): Camera[];
  28667. /**
  28668. * Gets the post process used by the rig cameras
  28669. */
  28670. get rigPostProcess(): Nullable<PostProcess>;
  28671. /**
  28672. * Internal, gets the first post proces.
  28673. * @returns the first post process to be run on this camera.
  28674. */
  28675. _getFirstPostProcess(): Nullable<PostProcess>;
  28676. private _cascadePostProcessesToRigCams;
  28677. /**
  28678. * Attach a post process to the camera.
  28679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28680. * @param postProcess The post process to attach to the camera
  28681. * @param insertAt The position of the post process in case several of them are in use in the scene
  28682. * @returns the position the post process has been inserted at
  28683. */
  28684. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28685. /**
  28686. * Detach a post process to the camera.
  28687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28688. * @param postProcess The post process to detach from the camera
  28689. */
  28690. detachPostProcess(postProcess: PostProcess): void;
  28691. /**
  28692. * Gets the current world matrix of the camera
  28693. */
  28694. getWorldMatrix(): Matrix;
  28695. /** @hidden */
  28696. _getViewMatrix(): Matrix;
  28697. /**
  28698. * Gets the current view matrix of the camera.
  28699. * @param force forces the camera to recompute the matrix without looking at the cached state
  28700. * @returns the view matrix
  28701. */
  28702. getViewMatrix(force?: boolean): Matrix;
  28703. /**
  28704. * Freeze the projection matrix.
  28705. * It will prevent the cache check of the camera projection compute and can speed up perf
  28706. * if no parameter of the camera are meant to change
  28707. * @param projection Defines manually a projection if necessary
  28708. */
  28709. freezeProjectionMatrix(projection?: Matrix): void;
  28710. /**
  28711. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28712. */
  28713. unfreezeProjectionMatrix(): void;
  28714. /**
  28715. * Gets the current projection matrix of the camera.
  28716. * @param force forces the camera to recompute the matrix without looking at the cached state
  28717. * @returns the projection matrix
  28718. */
  28719. getProjectionMatrix(force?: boolean): Matrix;
  28720. /**
  28721. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28722. * @returns a Matrix
  28723. */
  28724. getTransformationMatrix(): Matrix;
  28725. private _updateFrustumPlanes;
  28726. /**
  28727. * Checks if a cullable object (mesh...) is in the camera frustum
  28728. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28729. * @param target The object to check
  28730. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28731. * @returns true if the object is in frustum otherwise false
  28732. */
  28733. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28734. /**
  28735. * Checks if a cullable object (mesh...) is in the camera frustum
  28736. * Unlike isInFrustum this cheks the full bounding box
  28737. * @param target The object to check
  28738. * @returns true if the object is in frustum otherwise false
  28739. */
  28740. isCompletelyInFrustum(target: ICullable): boolean;
  28741. /**
  28742. * Gets a ray in the forward direction from the camera.
  28743. * @param length Defines the length of the ray to create
  28744. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28745. * @param origin Defines the start point of the ray which defaults to the camera position
  28746. * @returns the forward ray
  28747. */
  28748. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28749. /**
  28750. * Releases resources associated with this node.
  28751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28753. */
  28754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28755. /** @hidden */
  28756. _isLeftCamera: boolean;
  28757. /**
  28758. * Gets the left camera of a rig setup in case of Rigged Camera
  28759. */
  28760. get isLeftCamera(): boolean;
  28761. /** @hidden */
  28762. _isRightCamera: boolean;
  28763. /**
  28764. * Gets the right camera of a rig setup in case of Rigged Camera
  28765. */
  28766. get isRightCamera(): boolean;
  28767. /**
  28768. * Gets the left camera of a rig setup in case of Rigged Camera
  28769. */
  28770. get leftCamera(): Nullable<FreeCamera>;
  28771. /**
  28772. * Gets the right camera of a rig setup in case of Rigged Camera
  28773. */
  28774. get rightCamera(): Nullable<FreeCamera>;
  28775. /**
  28776. * Gets the left camera target of a rig setup in case of Rigged Camera
  28777. * @returns the target position
  28778. */
  28779. getLeftTarget(): Nullable<Vector3>;
  28780. /**
  28781. * Gets the right camera target of a rig setup in case of Rigged Camera
  28782. * @returns the target position
  28783. */
  28784. getRightTarget(): Nullable<Vector3>;
  28785. /**
  28786. * @hidden
  28787. */
  28788. setCameraRigMode(mode: number, rigParams: any): void;
  28789. /** @hidden */
  28790. static _setStereoscopicRigMode(camera: Camera): void;
  28791. /** @hidden */
  28792. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28793. /** @hidden */
  28794. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28795. /** @hidden */
  28796. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28797. /** @hidden */
  28798. _getVRProjectionMatrix(): Matrix;
  28799. protected _updateCameraRotationMatrix(): void;
  28800. protected _updateWebVRCameraRotationMatrix(): void;
  28801. /**
  28802. * This function MUST be overwritten by the different WebVR cameras available.
  28803. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28804. * @hidden
  28805. */
  28806. _getWebVRProjectionMatrix(): Matrix;
  28807. /**
  28808. * This function MUST be overwritten by the different WebVR cameras available.
  28809. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28810. * @hidden
  28811. */
  28812. _getWebVRViewMatrix(): Matrix;
  28813. /** @hidden */
  28814. setCameraRigParameter(name: string, value: any): void;
  28815. /**
  28816. * needs to be overridden by children so sub has required properties to be copied
  28817. * @hidden
  28818. */
  28819. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28820. /**
  28821. * May need to be overridden by children
  28822. * @hidden
  28823. */
  28824. _updateRigCameras(): void;
  28825. /** @hidden */
  28826. _setupInputs(): void;
  28827. /**
  28828. * Serialiaze the camera setup to a json represention
  28829. * @returns the JSON representation
  28830. */
  28831. serialize(): any;
  28832. /**
  28833. * Clones the current camera.
  28834. * @param name The cloned camera name
  28835. * @returns the cloned camera
  28836. */
  28837. clone(name: string): Camera;
  28838. /**
  28839. * Gets the direction of the camera relative to a given local axis.
  28840. * @param localAxis Defines the reference axis to provide a relative direction.
  28841. * @return the direction
  28842. */
  28843. getDirection(localAxis: Vector3): Vector3;
  28844. /**
  28845. * Returns the current camera absolute rotation
  28846. */
  28847. get absoluteRotation(): Quaternion;
  28848. /**
  28849. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28850. * @param localAxis Defines the reference axis to provide a relative direction.
  28851. * @param result Defines the vector to store the result in
  28852. */
  28853. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28854. /**
  28855. * Gets a camera constructor for a given camera type
  28856. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28857. * @param name The name of the camera the result will be able to instantiate
  28858. * @param scene The scene the result will construct the camera in
  28859. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28860. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28861. * @returns a factory method to construc the camera
  28862. */
  28863. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28864. /**
  28865. * Compute the world matrix of the camera.
  28866. * @returns the camera world matrix
  28867. */
  28868. computeWorldMatrix(): Matrix;
  28869. /**
  28870. * Parse a JSON and creates the camera from the parsed information
  28871. * @param parsedCamera The JSON to parse
  28872. * @param scene The scene to instantiate the camera in
  28873. * @returns the newly constructed camera
  28874. */
  28875. static Parse(parsedCamera: any, scene: Scene): Camera;
  28876. }
  28877. }
  28878. declare module BABYLON {
  28879. /**
  28880. * Class containing static functions to help procedurally build meshes
  28881. */
  28882. export class DiscBuilder {
  28883. /**
  28884. * Creates a plane polygonal mesh. By default, this is a disc
  28885. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28886. * * 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
  28887. * * 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
  28888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28889. * * 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
  28890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28891. * @param name defines the name of the mesh
  28892. * @param options defines the options used to create the mesh
  28893. * @param scene defines the hosting scene
  28894. * @returns the plane polygonal mesh
  28895. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28896. */
  28897. static CreateDisc(name: string, options: {
  28898. radius?: number;
  28899. tessellation?: number;
  28900. arc?: number;
  28901. updatable?: boolean;
  28902. sideOrientation?: number;
  28903. frontUVs?: Vector4;
  28904. backUVs?: Vector4;
  28905. }, scene?: Nullable<Scene>): Mesh;
  28906. }
  28907. }
  28908. declare module BABYLON {
  28909. /**
  28910. * Options to be used when creating a FresnelParameters.
  28911. */
  28912. export type IFresnelParametersCreationOptions = {
  28913. /**
  28914. * Define the color used on edges (grazing angle)
  28915. */
  28916. leftColor?: Color3;
  28917. /**
  28918. * Define the color used on center
  28919. */
  28920. rightColor?: Color3;
  28921. /**
  28922. * Define bias applied to computed fresnel term
  28923. */
  28924. bias?: number;
  28925. /**
  28926. * Defined the power exponent applied to fresnel term
  28927. */
  28928. power?: number;
  28929. /**
  28930. * Define if the fresnel effect is enable or not.
  28931. */
  28932. isEnabled?: boolean;
  28933. };
  28934. /**
  28935. * Serialized format for FresnelParameters.
  28936. */
  28937. export type IFresnelParametersSerialized = {
  28938. /**
  28939. * Define the color used on edges (grazing angle) [as an array]
  28940. */
  28941. leftColor: number[];
  28942. /**
  28943. * Define the color used on center [as an array]
  28944. */
  28945. rightColor: number[];
  28946. /**
  28947. * Define bias applied to computed fresnel term
  28948. */
  28949. bias: number;
  28950. /**
  28951. * Defined the power exponent applied to fresnel term
  28952. */
  28953. power?: number;
  28954. /**
  28955. * Define if the fresnel effect is enable or not.
  28956. */
  28957. isEnabled: boolean;
  28958. };
  28959. /**
  28960. * This represents all the required information to add a fresnel effect on a material:
  28961. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28962. */
  28963. export class FresnelParameters {
  28964. private _isEnabled;
  28965. /**
  28966. * Define if the fresnel effect is enable or not.
  28967. */
  28968. get isEnabled(): boolean;
  28969. set isEnabled(value: boolean);
  28970. /**
  28971. * Define the color used on edges (grazing angle)
  28972. */
  28973. leftColor: Color3;
  28974. /**
  28975. * Define the color used on center
  28976. */
  28977. rightColor: Color3;
  28978. /**
  28979. * Define bias applied to computed fresnel term
  28980. */
  28981. bias: number;
  28982. /**
  28983. * Defined the power exponent applied to fresnel term
  28984. */
  28985. power: number;
  28986. /**
  28987. * Creates a new FresnelParameters object.
  28988. *
  28989. * @param options provide your own settings to optionally to override defaults
  28990. */
  28991. constructor(options?: IFresnelParametersCreationOptions);
  28992. /**
  28993. * Clones the current fresnel and its valuues
  28994. * @returns a clone fresnel configuration
  28995. */
  28996. clone(): FresnelParameters;
  28997. /**
  28998. * Determines equality between FresnelParameters objects
  28999. * @param otherFresnelParameters defines the second operand
  29000. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29001. */
  29002. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29003. /**
  29004. * Serializes the current fresnel parameters to a JSON representation.
  29005. * @return the JSON serialization
  29006. */
  29007. serialize(): IFresnelParametersSerialized;
  29008. /**
  29009. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29010. * @param parsedFresnelParameters Define the JSON representation
  29011. * @returns the parsed parameters
  29012. */
  29013. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29014. }
  29015. }
  29016. declare module BABYLON {
  29017. /**
  29018. * This groups all the flags used to control the materials channel.
  29019. */
  29020. export class MaterialFlags {
  29021. private static _DiffuseTextureEnabled;
  29022. /**
  29023. * Are diffuse textures enabled in the application.
  29024. */
  29025. static get DiffuseTextureEnabled(): boolean;
  29026. static set DiffuseTextureEnabled(value: boolean);
  29027. private static _DetailTextureEnabled;
  29028. /**
  29029. * Are detail textures enabled in the application.
  29030. */
  29031. static get DetailTextureEnabled(): boolean;
  29032. static set DetailTextureEnabled(value: boolean);
  29033. private static _AmbientTextureEnabled;
  29034. /**
  29035. * Are ambient textures enabled in the application.
  29036. */
  29037. static get AmbientTextureEnabled(): boolean;
  29038. static set AmbientTextureEnabled(value: boolean);
  29039. private static _OpacityTextureEnabled;
  29040. /**
  29041. * Are opacity textures enabled in the application.
  29042. */
  29043. static get OpacityTextureEnabled(): boolean;
  29044. static set OpacityTextureEnabled(value: boolean);
  29045. private static _ReflectionTextureEnabled;
  29046. /**
  29047. * Are reflection textures enabled in the application.
  29048. */
  29049. static get ReflectionTextureEnabled(): boolean;
  29050. static set ReflectionTextureEnabled(value: boolean);
  29051. private static _EmissiveTextureEnabled;
  29052. /**
  29053. * Are emissive textures enabled in the application.
  29054. */
  29055. static get EmissiveTextureEnabled(): boolean;
  29056. static set EmissiveTextureEnabled(value: boolean);
  29057. private static _SpecularTextureEnabled;
  29058. /**
  29059. * Are specular textures enabled in the application.
  29060. */
  29061. static get SpecularTextureEnabled(): boolean;
  29062. static set SpecularTextureEnabled(value: boolean);
  29063. private static _BumpTextureEnabled;
  29064. /**
  29065. * Are bump textures enabled in the application.
  29066. */
  29067. static get BumpTextureEnabled(): boolean;
  29068. static set BumpTextureEnabled(value: boolean);
  29069. private static _LightmapTextureEnabled;
  29070. /**
  29071. * Are lightmap textures enabled in the application.
  29072. */
  29073. static get LightmapTextureEnabled(): boolean;
  29074. static set LightmapTextureEnabled(value: boolean);
  29075. private static _RefractionTextureEnabled;
  29076. /**
  29077. * Are refraction textures enabled in the application.
  29078. */
  29079. static get RefractionTextureEnabled(): boolean;
  29080. static set RefractionTextureEnabled(value: boolean);
  29081. private static _ColorGradingTextureEnabled;
  29082. /**
  29083. * Are color grading textures enabled in the application.
  29084. */
  29085. static get ColorGradingTextureEnabled(): boolean;
  29086. static set ColorGradingTextureEnabled(value: boolean);
  29087. private static _FresnelEnabled;
  29088. /**
  29089. * Are fresnels enabled in the application.
  29090. */
  29091. static get FresnelEnabled(): boolean;
  29092. static set FresnelEnabled(value: boolean);
  29093. private static _ClearCoatTextureEnabled;
  29094. /**
  29095. * Are clear coat textures enabled in the application.
  29096. */
  29097. static get ClearCoatTextureEnabled(): boolean;
  29098. static set ClearCoatTextureEnabled(value: boolean);
  29099. private static _ClearCoatBumpTextureEnabled;
  29100. /**
  29101. * Are clear coat bump textures enabled in the application.
  29102. */
  29103. static get ClearCoatBumpTextureEnabled(): boolean;
  29104. static set ClearCoatBumpTextureEnabled(value: boolean);
  29105. private static _ClearCoatTintTextureEnabled;
  29106. /**
  29107. * Are clear coat tint textures enabled in the application.
  29108. */
  29109. static get ClearCoatTintTextureEnabled(): boolean;
  29110. static set ClearCoatTintTextureEnabled(value: boolean);
  29111. private static _SheenTextureEnabled;
  29112. /**
  29113. * Are sheen textures enabled in the application.
  29114. */
  29115. static get SheenTextureEnabled(): boolean;
  29116. static set SheenTextureEnabled(value: boolean);
  29117. private static _AnisotropicTextureEnabled;
  29118. /**
  29119. * Are anisotropic textures enabled in the application.
  29120. */
  29121. static get AnisotropicTextureEnabled(): boolean;
  29122. static set AnisotropicTextureEnabled(value: boolean);
  29123. private static _ThicknessTextureEnabled;
  29124. /**
  29125. * Are thickness textures enabled in the application.
  29126. */
  29127. static get ThicknessTextureEnabled(): boolean;
  29128. static set ThicknessTextureEnabled(value: boolean);
  29129. }
  29130. }
  29131. declare module BABYLON {
  29132. /** @hidden */
  29133. export var defaultFragmentDeclaration: {
  29134. name: string;
  29135. shader: string;
  29136. };
  29137. }
  29138. declare module BABYLON {
  29139. /** @hidden */
  29140. export var defaultUboDeclaration: {
  29141. name: string;
  29142. shader: string;
  29143. };
  29144. }
  29145. declare module BABYLON {
  29146. /** @hidden */
  29147. export var lightFragmentDeclaration: {
  29148. name: string;
  29149. shader: string;
  29150. };
  29151. }
  29152. declare module BABYLON {
  29153. /** @hidden */
  29154. export var lightUboDeclaration: {
  29155. name: string;
  29156. shader: string;
  29157. };
  29158. }
  29159. declare module BABYLON {
  29160. /** @hidden */
  29161. export var lightsFragmentFunctions: {
  29162. name: string;
  29163. shader: string;
  29164. };
  29165. }
  29166. declare module BABYLON {
  29167. /** @hidden */
  29168. export var shadowsFragmentFunctions: {
  29169. name: string;
  29170. shader: string;
  29171. };
  29172. }
  29173. declare module BABYLON {
  29174. /** @hidden */
  29175. export var fresnelFunction: {
  29176. name: string;
  29177. shader: string;
  29178. };
  29179. }
  29180. declare module BABYLON {
  29181. /** @hidden */
  29182. export var bumpFragmentMainFunctions: {
  29183. name: string;
  29184. shader: string;
  29185. };
  29186. }
  29187. declare module BABYLON {
  29188. /** @hidden */
  29189. export var bumpFragmentFunctions: {
  29190. name: string;
  29191. shader: string;
  29192. };
  29193. }
  29194. declare module BABYLON {
  29195. /** @hidden */
  29196. export var logDepthDeclaration: {
  29197. name: string;
  29198. shader: string;
  29199. };
  29200. }
  29201. declare module BABYLON {
  29202. /** @hidden */
  29203. export var bumpFragment: {
  29204. name: string;
  29205. shader: string;
  29206. };
  29207. }
  29208. declare module BABYLON {
  29209. /** @hidden */
  29210. export var depthPrePass: {
  29211. name: string;
  29212. shader: string;
  29213. };
  29214. }
  29215. declare module BABYLON {
  29216. /** @hidden */
  29217. export var lightFragment: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module BABYLON {
  29223. /** @hidden */
  29224. export var logDepthFragment: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module BABYLON {
  29230. /** @hidden */
  29231. export var defaultPixelShader: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module BABYLON {
  29237. /** @hidden */
  29238. export var defaultVertexDeclaration: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module BABYLON {
  29244. /** @hidden */
  29245. export var bumpVertexDeclaration: {
  29246. name: string;
  29247. shader: string;
  29248. };
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export var bumpVertex: {
  29253. name: string;
  29254. shader: string;
  29255. };
  29256. }
  29257. declare module BABYLON {
  29258. /** @hidden */
  29259. export var fogVertex: {
  29260. name: string;
  29261. shader: string;
  29262. };
  29263. }
  29264. declare module BABYLON {
  29265. /** @hidden */
  29266. export var shadowsVertex: {
  29267. name: string;
  29268. shader: string;
  29269. };
  29270. }
  29271. declare module BABYLON {
  29272. /** @hidden */
  29273. export var pointCloudVertex: {
  29274. name: string;
  29275. shader: string;
  29276. };
  29277. }
  29278. declare module BABYLON {
  29279. /** @hidden */
  29280. export var logDepthVertex: {
  29281. name: string;
  29282. shader: string;
  29283. };
  29284. }
  29285. declare module BABYLON {
  29286. /** @hidden */
  29287. export var defaultVertexShader: {
  29288. name: string;
  29289. shader: string;
  29290. };
  29291. }
  29292. declare module BABYLON {
  29293. /**
  29294. * @hidden
  29295. */
  29296. export interface IMaterialDetailMapDefines {
  29297. DETAIL: boolean;
  29298. DETAILDIRECTUV: number;
  29299. DETAIL_NORMALBLENDMETHOD: number;
  29300. /** @hidden */
  29301. _areTexturesDirty: boolean;
  29302. }
  29303. /**
  29304. * Define the code related to the detail map parameters of a material
  29305. *
  29306. * Inspired from:
  29307. * 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
  29308. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29309. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29310. */
  29311. export class DetailMapConfiguration {
  29312. private _texture;
  29313. /**
  29314. * The detail texture of the material.
  29315. */
  29316. texture: Nullable<BaseTexture>;
  29317. /**
  29318. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29319. * Bigger values mean stronger blending
  29320. */
  29321. diffuseBlendLevel: number;
  29322. /**
  29323. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29324. * Bigger values mean stronger blending. Only used with PBR materials
  29325. */
  29326. roughnessBlendLevel: number;
  29327. /**
  29328. * Defines how strong the bump effect from the detail map is
  29329. * Bigger values mean stronger effect
  29330. */
  29331. bumpLevel: number;
  29332. private _normalBlendMethod;
  29333. /**
  29334. * The method used to blend the bump and detail normals together
  29335. */
  29336. normalBlendMethod: number;
  29337. private _isEnabled;
  29338. /**
  29339. * Enable or disable the detail map on this material
  29340. */
  29341. isEnabled: boolean;
  29342. /** @hidden */
  29343. private _internalMarkAllSubMeshesAsTexturesDirty;
  29344. /** @hidden */
  29345. _markAllSubMeshesAsTexturesDirty(): void;
  29346. /**
  29347. * Instantiate a new detail map
  29348. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29349. */
  29350. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29351. /**
  29352. * Gets whether the submesh is ready to be used or not.
  29353. * @param defines the list of "defines" to update.
  29354. * @param scene defines the scene the material belongs to.
  29355. * @returns - boolean indicating that the submesh is ready or not.
  29356. */
  29357. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29358. /**
  29359. * Update the defines for detail map usage
  29360. * @param defines the list of "defines" to update.
  29361. * @param scene defines the scene the material belongs to.
  29362. */
  29363. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29364. /**
  29365. * Binds the material data.
  29366. * @param uniformBuffer defines the Uniform buffer to fill in.
  29367. * @param scene defines the scene the material belongs to.
  29368. * @param isFrozen defines whether the material is frozen or not.
  29369. */
  29370. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29371. /**
  29372. * Checks to see if a texture is used in the material.
  29373. * @param texture - Base texture to use.
  29374. * @returns - Boolean specifying if a texture is used in the material.
  29375. */
  29376. hasTexture(texture: BaseTexture): boolean;
  29377. /**
  29378. * Returns an array of the actively used textures.
  29379. * @param activeTextures Array of BaseTextures
  29380. */
  29381. getActiveTextures(activeTextures: BaseTexture[]): void;
  29382. /**
  29383. * Returns the animatable textures.
  29384. * @param animatables Array of animatable textures.
  29385. */
  29386. getAnimatables(animatables: IAnimatable[]): void;
  29387. /**
  29388. * Disposes the resources of the material.
  29389. * @param forceDisposeTextures - Forces the disposal of all textures.
  29390. */
  29391. dispose(forceDisposeTextures?: boolean): void;
  29392. /**
  29393. * Get the current class name useful for serialization or dynamic coding.
  29394. * @returns "DetailMap"
  29395. */
  29396. getClassName(): string;
  29397. /**
  29398. * Add the required uniforms to the current list.
  29399. * @param uniforms defines the current uniform list.
  29400. */
  29401. static AddUniforms(uniforms: string[]): void;
  29402. /**
  29403. * Add the required samplers to the current list.
  29404. * @param samplers defines the current sampler list.
  29405. */
  29406. static AddSamplers(samplers: string[]): void;
  29407. /**
  29408. * Add the required uniforms to the current buffer.
  29409. * @param uniformBuffer defines the current uniform buffer.
  29410. */
  29411. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29412. /**
  29413. * Makes a duplicate of the current instance into another one.
  29414. * @param detailMap define the instance where to copy the info
  29415. */
  29416. copyTo(detailMap: DetailMapConfiguration): void;
  29417. /**
  29418. * Serializes this detail map instance
  29419. * @returns - An object with the serialized instance.
  29420. */
  29421. serialize(): any;
  29422. /**
  29423. * Parses a detail map setting from a serialized object.
  29424. * @param source - Serialized object.
  29425. * @param scene Defines the scene we are parsing for
  29426. * @param rootUrl Defines the rootUrl to load from
  29427. */
  29428. parse(source: any, scene: Scene, rootUrl: string): void;
  29429. }
  29430. }
  29431. declare module BABYLON {
  29432. /** @hidden */
  29433. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29434. MAINUV1: boolean;
  29435. MAINUV2: boolean;
  29436. DIFFUSE: boolean;
  29437. DIFFUSEDIRECTUV: number;
  29438. DETAIL: boolean;
  29439. DETAILDIRECTUV: number;
  29440. DETAIL_NORMALBLENDMETHOD: number;
  29441. AMBIENT: boolean;
  29442. AMBIENTDIRECTUV: number;
  29443. OPACITY: boolean;
  29444. OPACITYDIRECTUV: number;
  29445. OPACITYRGB: boolean;
  29446. REFLECTION: boolean;
  29447. EMISSIVE: boolean;
  29448. EMISSIVEDIRECTUV: number;
  29449. SPECULAR: boolean;
  29450. SPECULARDIRECTUV: number;
  29451. BUMP: boolean;
  29452. BUMPDIRECTUV: number;
  29453. PARALLAX: boolean;
  29454. PARALLAXOCCLUSION: boolean;
  29455. SPECULAROVERALPHA: boolean;
  29456. CLIPPLANE: boolean;
  29457. CLIPPLANE2: boolean;
  29458. CLIPPLANE3: boolean;
  29459. CLIPPLANE4: boolean;
  29460. CLIPPLANE5: boolean;
  29461. CLIPPLANE6: boolean;
  29462. ALPHATEST: boolean;
  29463. DEPTHPREPASS: boolean;
  29464. ALPHAFROMDIFFUSE: boolean;
  29465. POINTSIZE: boolean;
  29466. FOG: boolean;
  29467. SPECULARTERM: boolean;
  29468. DIFFUSEFRESNEL: boolean;
  29469. OPACITYFRESNEL: boolean;
  29470. REFLECTIONFRESNEL: boolean;
  29471. REFRACTIONFRESNEL: boolean;
  29472. EMISSIVEFRESNEL: boolean;
  29473. FRESNEL: boolean;
  29474. NORMAL: boolean;
  29475. UV1: boolean;
  29476. UV2: boolean;
  29477. VERTEXCOLOR: boolean;
  29478. VERTEXALPHA: boolean;
  29479. NUM_BONE_INFLUENCERS: number;
  29480. BonesPerMesh: number;
  29481. BONETEXTURE: boolean;
  29482. INSTANCES: boolean;
  29483. THIN_INSTANCES: boolean;
  29484. GLOSSINESS: boolean;
  29485. ROUGHNESS: boolean;
  29486. EMISSIVEASILLUMINATION: boolean;
  29487. LINKEMISSIVEWITHDIFFUSE: boolean;
  29488. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29489. LIGHTMAP: boolean;
  29490. LIGHTMAPDIRECTUV: number;
  29491. OBJECTSPACE_NORMALMAP: boolean;
  29492. USELIGHTMAPASSHADOWMAP: boolean;
  29493. REFLECTIONMAP_3D: boolean;
  29494. REFLECTIONMAP_SPHERICAL: boolean;
  29495. REFLECTIONMAP_PLANAR: boolean;
  29496. REFLECTIONMAP_CUBIC: boolean;
  29497. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29498. REFLECTIONMAP_PROJECTION: boolean;
  29499. REFLECTIONMAP_SKYBOX: boolean;
  29500. REFLECTIONMAP_EXPLICIT: boolean;
  29501. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29502. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29503. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29504. INVERTCUBICMAP: boolean;
  29505. LOGARITHMICDEPTH: boolean;
  29506. REFRACTION: boolean;
  29507. REFRACTIONMAP_3D: boolean;
  29508. REFLECTIONOVERALPHA: boolean;
  29509. TWOSIDEDLIGHTING: boolean;
  29510. SHADOWFLOAT: boolean;
  29511. MORPHTARGETS: boolean;
  29512. MORPHTARGETS_NORMAL: boolean;
  29513. MORPHTARGETS_TANGENT: boolean;
  29514. MORPHTARGETS_UV: boolean;
  29515. NUM_MORPH_INFLUENCERS: number;
  29516. NONUNIFORMSCALING: boolean;
  29517. PREMULTIPLYALPHA: boolean;
  29518. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29519. ALPHABLEND: boolean;
  29520. PREPASS: boolean;
  29521. SCENE_MRT_COUNT: number;
  29522. RGBDLIGHTMAP: boolean;
  29523. RGBDREFLECTION: boolean;
  29524. RGBDREFRACTION: boolean;
  29525. IMAGEPROCESSING: boolean;
  29526. VIGNETTE: boolean;
  29527. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29528. VIGNETTEBLENDMODEOPAQUE: boolean;
  29529. TONEMAPPING: boolean;
  29530. TONEMAPPING_ACES: boolean;
  29531. CONTRAST: boolean;
  29532. COLORCURVES: boolean;
  29533. COLORGRADING: boolean;
  29534. COLORGRADING3D: boolean;
  29535. SAMPLER3DGREENDEPTH: boolean;
  29536. SAMPLER3DBGRMAP: boolean;
  29537. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29538. MULTIVIEW: boolean;
  29539. /**
  29540. * If the reflection texture on this material is in linear color space
  29541. * @hidden
  29542. */
  29543. IS_REFLECTION_LINEAR: boolean;
  29544. /**
  29545. * If the refraction texture on this material is in linear color space
  29546. * @hidden
  29547. */
  29548. IS_REFRACTION_LINEAR: boolean;
  29549. EXPOSURE: boolean;
  29550. constructor();
  29551. setReflectionMode(modeToEnable: string): void;
  29552. }
  29553. /**
  29554. * This is the default material used in Babylon. It is the best trade off between quality
  29555. * and performances.
  29556. * @see https://doc.babylonjs.com/babylon101/materials
  29557. */
  29558. export class StandardMaterial extends PushMaterial {
  29559. private _diffuseTexture;
  29560. /**
  29561. * The basic texture of the material as viewed under a light.
  29562. */
  29563. diffuseTexture: Nullable<BaseTexture>;
  29564. private _ambientTexture;
  29565. /**
  29566. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29567. */
  29568. ambientTexture: Nullable<BaseTexture>;
  29569. private _opacityTexture;
  29570. /**
  29571. * Define the transparency of the material from a texture.
  29572. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29573. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29574. */
  29575. opacityTexture: Nullable<BaseTexture>;
  29576. private _reflectionTexture;
  29577. /**
  29578. * Define the texture used to display the reflection.
  29579. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29580. */
  29581. reflectionTexture: Nullable<BaseTexture>;
  29582. private _emissiveTexture;
  29583. /**
  29584. * Define texture of the material as if self lit.
  29585. * This will be mixed in the final result even in the absence of light.
  29586. */
  29587. emissiveTexture: Nullable<BaseTexture>;
  29588. private _specularTexture;
  29589. /**
  29590. * Define how the color and intensity of the highlight given by the light in the material.
  29591. */
  29592. specularTexture: Nullable<BaseTexture>;
  29593. private _bumpTexture;
  29594. /**
  29595. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29596. * 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.
  29597. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  29598. */
  29599. bumpTexture: Nullable<BaseTexture>;
  29600. private _lightmapTexture;
  29601. /**
  29602. * Complex lighting can be computationally expensive to compute at runtime.
  29603. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29604. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  29605. */
  29606. lightmapTexture: Nullable<BaseTexture>;
  29607. private _refractionTexture;
  29608. /**
  29609. * Define the texture used to display the refraction.
  29610. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29611. */
  29612. refractionTexture: Nullable<BaseTexture>;
  29613. /**
  29614. * The color of the material lit by the environmental background lighting.
  29615. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29616. */
  29617. ambientColor: Color3;
  29618. /**
  29619. * The basic color of the material as viewed under a light.
  29620. */
  29621. diffuseColor: Color3;
  29622. /**
  29623. * Define how the color and intensity of the highlight given by the light in the material.
  29624. */
  29625. specularColor: Color3;
  29626. /**
  29627. * Define the color of the material as if self lit.
  29628. * This will be mixed in the final result even in the absence of light.
  29629. */
  29630. emissiveColor: Color3;
  29631. /**
  29632. * Defines how sharp are the highlights in the material.
  29633. * The bigger the value the sharper giving a more glossy feeling to the result.
  29634. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29635. */
  29636. specularPower: number;
  29637. private _useAlphaFromDiffuseTexture;
  29638. /**
  29639. * Does the transparency come from the diffuse texture alpha channel.
  29640. */
  29641. useAlphaFromDiffuseTexture: boolean;
  29642. private _useEmissiveAsIllumination;
  29643. /**
  29644. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29645. */
  29646. useEmissiveAsIllumination: boolean;
  29647. private _linkEmissiveWithDiffuse;
  29648. /**
  29649. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29650. * the emissive level when the final color is close to one.
  29651. */
  29652. linkEmissiveWithDiffuse: boolean;
  29653. private _useSpecularOverAlpha;
  29654. /**
  29655. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29656. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29657. */
  29658. useSpecularOverAlpha: boolean;
  29659. private _useReflectionOverAlpha;
  29660. /**
  29661. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29662. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29663. */
  29664. useReflectionOverAlpha: boolean;
  29665. private _disableLighting;
  29666. /**
  29667. * Does lights from the scene impacts this material.
  29668. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29669. */
  29670. disableLighting: boolean;
  29671. private _useObjectSpaceNormalMap;
  29672. /**
  29673. * Allows using an object space normal map (instead of tangent space).
  29674. */
  29675. useObjectSpaceNormalMap: boolean;
  29676. private _useParallax;
  29677. /**
  29678. * Is parallax enabled or not.
  29679. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29680. */
  29681. useParallax: boolean;
  29682. private _useParallaxOcclusion;
  29683. /**
  29684. * Is parallax occlusion enabled or not.
  29685. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29686. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29687. */
  29688. useParallaxOcclusion: boolean;
  29689. /**
  29690. * 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.
  29691. */
  29692. parallaxScaleBias: number;
  29693. private _roughness;
  29694. /**
  29695. * Helps to define how blurry the reflections should appears in the material.
  29696. */
  29697. roughness: number;
  29698. /**
  29699. * In case of refraction, define the value of the index of refraction.
  29700. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29701. */
  29702. indexOfRefraction: number;
  29703. /**
  29704. * Invert the refraction texture alongside the y axis.
  29705. * It can be useful with procedural textures or probe for instance.
  29706. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29707. */
  29708. invertRefractionY: boolean;
  29709. /**
  29710. * Defines the alpha limits in alpha test mode.
  29711. */
  29712. alphaCutOff: number;
  29713. private _useLightmapAsShadowmap;
  29714. /**
  29715. * In case of light mapping, define whether the map contains light or shadow informations.
  29716. */
  29717. useLightmapAsShadowmap: boolean;
  29718. private _diffuseFresnelParameters;
  29719. /**
  29720. * Define the diffuse fresnel parameters of the material.
  29721. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29722. */
  29723. diffuseFresnelParameters: FresnelParameters;
  29724. private _opacityFresnelParameters;
  29725. /**
  29726. * Define the opacity fresnel parameters of the material.
  29727. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29728. */
  29729. opacityFresnelParameters: FresnelParameters;
  29730. private _reflectionFresnelParameters;
  29731. /**
  29732. * Define the reflection fresnel parameters of the material.
  29733. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29734. */
  29735. reflectionFresnelParameters: FresnelParameters;
  29736. private _refractionFresnelParameters;
  29737. /**
  29738. * Define the refraction fresnel parameters of the material.
  29739. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29740. */
  29741. refractionFresnelParameters: FresnelParameters;
  29742. private _emissiveFresnelParameters;
  29743. /**
  29744. * Define the emissive fresnel parameters of the material.
  29745. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29746. */
  29747. emissiveFresnelParameters: FresnelParameters;
  29748. private _useReflectionFresnelFromSpecular;
  29749. /**
  29750. * If true automatically deducts the fresnels values from the material specularity.
  29751. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29752. */
  29753. useReflectionFresnelFromSpecular: boolean;
  29754. private _useGlossinessFromSpecularMapAlpha;
  29755. /**
  29756. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29757. */
  29758. useGlossinessFromSpecularMapAlpha: boolean;
  29759. private _maxSimultaneousLights;
  29760. /**
  29761. * Defines the maximum number of lights that can be used in the material
  29762. */
  29763. maxSimultaneousLights: number;
  29764. private _invertNormalMapX;
  29765. /**
  29766. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29767. */
  29768. invertNormalMapX: boolean;
  29769. private _invertNormalMapY;
  29770. /**
  29771. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29772. */
  29773. invertNormalMapY: boolean;
  29774. private _twoSidedLighting;
  29775. /**
  29776. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29777. */
  29778. twoSidedLighting: boolean;
  29779. /**
  29780. * Default configuration related to image processing available in the standard Material.
  29781. */
  29782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29783. /**
  29784. * Gets the image processing configuration used either in this material.
  29785. */
  29786. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29787. /**
  29788. * Sets the Default image processing configuration used either in the this material.
  29789. *
  29790. * If sets to null, the scene one is in use.
  29791. */
  29792. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29793. /**
  29794. * Keep track of the image processing observer to allow dispose and replace.
  29795. */
  29796. private _imageProcessingObserver;
  29797. /**
  29798. * Attaches a new image processing configuration to the Standard Material.
  29799. * @param configuration
  29800. */
  29801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29802. /**
  29803. * Gets wether the color curves effect is enabled.
  29804. */
  29805. get cameraColorCurvesEnabled(): boolean;
  29806. /**
  29807. * Sets wether the color curves effect is enabled.
  29808. */
  29809. set cameraColorCurvesEnabled(value: boolean);
  29810. /**
  29811. * Gets wether the color grading effect is enabled.
  29812. */
  29813. get cameraColorGradingEnabled(): boolean;
  29814. /**
  29815. * Gets wether the color grading effect is enabled.
  29816. */
  29817. set cameraColorGradingEnabled(value: boolean);
  29818. /**
  29819. * Gets wether tonemapping is enabled or not.
  29820. */
  29821. get cameraToneMappingEnabled(): boolean;
  29822. /**
  29823. * Sets wether tonemapping is enabled or not
  29824. */
  29825. set cameraToneMappingEnabled(value: boolean);
  29826. /**
  29827. * The camera exposure used on this material.
  29828. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29829. * This corresponds to a photographic exposure.
  29830. */
  29831. get cameraExposure(): number;
  29832. /**
  29833. * The camera exposure used on this material.
  29834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29835. * This corresponds to a photographic exposure.
  29836. */
  29837. set cameraExposure(value: number);
  29838. /**
  29839. * Gets The camera contrast used on this material.
  29840. */
  29841. get cameraContrast(): number;
  29842. /**
  29843. * Sets The camera contrast used on this material.
  29844. */
  29845. set cameraContrast(value: number);
  29846. /**
  29847. * Gets the Color Grading 2D Lookup Texture.
  29848. */
  29849. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29850. /**
  29851. * Sets the Color Grading 2D Lookup Texture.
  29852. */
  29853. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29854. /**
  29855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29857. * 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;
  29858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29859. */
  29860. get cameraColorCurves(): Nullable<ColorCurves>;
  29861. /**
  29862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29864. * 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;
  29865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29866. */
  29867. set cameraColorCurves(value: Nullable<ColorCurves>);
  29868. /**
  29869. * Defines the detail map parameters for the material.
  29870. */
  29871. readonly detailMap: DetailMapConfiguration;
  29872. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29873. protected _worldViewProjectionMatrix: Matrix;
  29874. protected _globalAmbientColor: Color3;
  29875. protected _useLogarithmicDepth: boolean;
  29876. protected _rebuildInParallel: boolean;
  29877. /**
  29878. * Instantiates a new standard material.
  29879. * This is the default material used in Babylon. It is the best trade off between quality
  29880. * and performances.
  29881. * @see https://doc.babylonjs.com/babylon101/materials
  29882. * @param name Define the name of the material in the scene
  29883. * @param scene Define the scene the material belong to
  29884. */
  29885. constructor(name: string, scene: Scene);
  29886. /**
  29887. * Gets a boolean indicating that current material needs to register RTT
  29888. */
  29889. get hasRenderTargetTextures(): boolean;
  29890. /**
  29891. * Gets the current class name of the material e.g. "StandardMaterial"
  29892. * Mainly use in serialization.
  29893. * @returns the class name
  29894. */
  29895. getClassName(): string;
  29896. /**
  29897. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29898. * You can try switching to logarithmic depth.
  29899. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29900. */
  29901. get useLogarithmicDepth(): boolean;
  29902. set useLogarithmicDepth(value: boolean);
  29903. /**
  29904. * Specifies if the material will require alpha blending
  29905. * @returns a boolean specifying if alpha blending is needed
  29906. */
  29907. needAlphaBlending(): boolean;
  29908. /**
  29909. * Specifies if this material should be rendered in alpha test mode
  29910. * @returns a boolean specifying if an alpha test is needed.
  29911. */
  29912. needAlphaTesting(): boolean;
  29913. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29914. /**
  29915. * Get the texture used for alpha test purpose.
  29916. * @returns the diffuse texture in case of the standard material.
  29917. */
  29918. getAlphaTestTexture(): Nullable<BaseTexture>;
  29919. /**
  29920. * Get if the submesh is ready to be used and all its information available.
  29921. * Child classes can use it to update shaders
  29922. * @param mesh defines the mesh to check
  29923. * @param subMesh defines which submesh to check
  29924. * @param useInstances specifies that instances should be used
  29925. * @returns a boolean indicating that the submesh is ready or not
  29926. */
  29927. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29928. /**
  29929. * Builds the material UBO layouts.
  29930. * Used internally during the effect preparation.
  29931. */
  29932. buildUniformLayout(): void;
  29933. /**
  29934. * Unbinds the material from the mesh
  29935. */
  29936. unbind(): void;
  29937. /**
  29938. * Binds the submesh to this material by preparing the effect and shader to draw
  29939. * @param world defines the world transformation matrix
  29940. * @param mesh defines the mesh containing the submesh
  29941. * @param subMesh defines the submesh to bind the material to
  29942. */
  29943. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29944. /**
  29945. * Get the list of animatables in the material.
  29946. * @returns the list of animatables object used in the material
  29947. */
  29948. getAnimatables(): IAnimatable[];
  29949. /**
  29950. * Gets the active textures from the material
  29951. * @returns an array of textures
  29952. */
  29953. getActiveTextures(): BaseTexture[];
  29954. /**
  29955. * Specifies if the material uses a texture
  29956. * @param texture defines the texture to check against the material
  29957. * @returns a boolean specifying if the material uses the texture
  29958. */
  29959. hasTexture(texture: BaseTexture): boolean;
  29960. /**
  29961. * Disposes the material
  29962. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29963. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29964. */
  29965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29966. /**
  29967. * Makes a duplicate of the material, and gives it a new name
  29968. * @param name defines the new name for the duplicated material
  29969. * @returns the cloned material
  29970. */
  29971. clone(name: string): StandardMaterial;
  29972. /**
  29973. * Serializes this material in a JSON representation
  29974. * @returns the serialized material object
  29975. */
  29976. serialize(): any;
  29977. /**
  29978. * Creates a standard material from parsed material data
  29979. * @param source defines the JSON representation of the material
  29980. * @param scene defines the hosting scene
  29981. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29982. * @returns a new standard material
  29983. */
  29984. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29985. /**
  29986. * Are diffuse textures enabled in the application.
  29987. */
  29988. static get DiffuseTextureEnabled(): boolean;
  29989. static set DiffuseTextureEnabled(value: boolean);
  29990. /**
  29991. * Are detail textures enabled in the application.
  29992. */
  29993. static get DetailTextureEnabled(): boolean;
  29994. static set DetailTextureEnabled(value: boolean);
  29995. /**
  29996. * Are ambient textures enabled in the application.
  29997. */
  29998. static get AmbientTextureEnabled(): boolean;
  29999. static set AmbientTextureEnabled(value: boolean);
  30000. /**
  30001. * Are opacity textures enabled in the application.
  30002. */
  30003. static get OpacityTextureEnabled(): boolean;
  30004. static set OpacityTextureEnabled(value: boolean);
  30005. /**
  30006. * Are reflection textures enabled in the application.
  30007. */
  30008. static get ReflectionTextureEnabled(): boolean;
  30009. static set ReflectionTextureEnabled(value: boolean);
  30010. /**
  30011. * Are emissive textures enabled in the application.
  30012. */
  30013. static get EmissiveTextureEnabled(): boolean;
  30014. static set EmissiveTextureEnabled(value: boolean);
  30015. /**
  30016. * Are specular textures enabled in the application.
  30017. */
  30018. static get SpecularTextureEnabled(): boolean;
  30019. static set SpecularTextureEnabled(value: boolean);
  30020. /**
  30021. * Are bump textures enabled in the application.
  30022. */
  30023. static get BumpTextureEnabled(): boolean;
  30024. static set BumpTextureEnabled(value: boolean);
  30025. /**
  30026. * Are lightmap textures enabled in the application.
  30027. */
  30028. static get LightmapTextureEnabled(): boolean;
  30029. static set LightmapTextureEnabled(value: boolean);
  30030. /**
  30031. * Are refraction textures enabled in the application.
  30032. */
  30033. static get RefractionTextureEnabled(): boolean;
  30034. static set RefractionTextureEnabled(value: boolean);
  30035. /**
  30036. * Are color grading textures enabled in the application.
  30037. */
  30038. static get ColorGradingTextureEnabled(): boolean;
  30039. static set ColorGradingTextureEnabled(value: boolean);
  30040. /**
  30041. * Are fresnels enabled in the application.
  30042. */
  30043. static get FresnelEnabled(): boolean;
  30044. static set FresnelEnabled(value: boolean);
  30045. }
  30046. }
  30047. declare module BABYLON {
  30048. /**
  30049. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30050. *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.
  30051. * The SPS is also a particle system. It provides some methods to manage the particles.
  30052. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30053. *
  30054. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30055. */
  30056. export class SolidParticleSystem implements IDisposable {
  30057. /**
  30058. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30059. * Example : var p = SPS.particles[i];
  30060. */
  30061. particles: SolidParticle[];
  30062. /**
  30063. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30064. */
  30065. nbParticles: number;
  30066. /**
  30067. * If the particles must ever face the camera (default false). Useful for planar particles.
  30068. */
  30069. billboard: boolean;
  30070. /**
  30071. * Recompute normals when adding a shape
  30072. */
  30073. recomputeNormals: boolean;
  30074. /**
  30075. * This a counter ofr your own usage. It's not set by any SPS functions.
  30076. */
  30077. counter: number;
  30078. /**
  30079. * The SPS name. This name is also given to the underlying mesh.
  30080. */
  30081. name: string;
  30082. /**
  30083. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30084. */
  30085. mesh: Mesh;
  30086. /**
  30087. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30088. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30089. */
  30090. vars: any;
  30091. /**
  30092. * This array is populated when the SPS is set as 'pickable'.
  30093. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30094. * Each element of this array is an object `{idx: int, faceId: int}`.
  30095. * `idx` is the picked particle index in the `SPS.particles` array
  30096. * `faceId` is the picked face index counted within this particle.
  30097. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30098. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30099. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30100. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30101. */
  30102. pickedParticles: {
  30103. idx: number;
  30104. faceId: number;
  30105. }[];
  30106. /**
  30107. * This array is populated when the SPS is set as 'pickable'
  30108. * Each key of this array is a submesh index.
  30109. * Each element of this array is a second array defined like this :
  30110. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30111. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30112. * `idx` is the picked particle index in the `SPS.particles` array
  30113. * `faceId` is the picked face index counted within this particle.
  30114. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30115. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30116. */
  30117. pickedBySubMesh: {
  30118. idx: number;
  30119. faceId: number;
  30120. }[][];
  30121. /**
  30122. * This array is populated when `enableDepthSort` is set to true.
  30123. * Each element of this array is an instance of the class DepthSortedParticle.
  30124. */
  30125. depthSortedParticles: DepthSortedParticle[];
  30126. /**
  30127. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30128. * @hidden
  30129. */
  30130. _bSphereOnly: boolean;
  30131. /**
  30132. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30133. * @hidden
  30134. */
  30135. _bSphereRadiusFactor: number;
  30136. private _scene;
  30137. private _positions;
  30138. private _indices;
  30139. private _normals;
  30140. private _colors;
  30141. private _uvs;
  30142. private _indices32;
  30143. private _positions32;
  30144. private _normals32;
  30145. private _fixedNormal32;
  30146. private _colors32;
  30147. private _uvs32;
  30148. private _index;
  30149. private _updatable;
  30150. private _pickable;
  30151. private _isVisibilityBoxLocked;
  30152. private _alwaysVisible;
  30153. private _depthSort;
  30154. private _expandable;
  30155. private _shapeCounter;
  30156. private _copy;
  30157. private _color;
  30158. private _computeParticleColor;
  30159. private _computeParticleTexture;
  30160. private _computeParticleRotation;
  30161. private _computeParticleVertex;
  30162. private _computeBoundingBox;
  30163. private _depthSortParticles;
  30164. private _camera;
  30165. private _mustUnrotateFixedNormals;
  30166. private _particlesIntersect;
  30167. private _needs32Bits;
  30168. private _isNotBuilt;
  30169. private _lastParticleId;
  30170. private _idxOfId;
  30171. private _multimaterialEnabled;
  30172. private _useModelMaterial;
  30173. private _indicesByMaterial;
  30174. private _materialIndexes;
  30175. private _depthSortFunction;
  30176. private _materialSortFunction;
  30177. private _materials;
  30178. private _multimaterial;
  30179. private _materialIndexesById;
  30180. private _defaultMaterial;
  30181. private _autoUpdateSubMeshes;
  30182. private _tmpVertex;
  30183. /**
  30184. * Creates a SPS (Solid Particle System) object.
  30185. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30186. * @param scene (Scene) is the scene in which the SPS is added.
  30187. * @param options defines the options of the sps e.g.
  30188. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30189. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30190. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30191. * * 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.
  30192. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30193. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30194. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30195. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30196. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30197. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30198. */
  30199. constructor(name: string, scene: Scene, options?: {
  30200. updatable?: boolean;
  30201. isPickable?: boolean;
  30202. enableDepthSort?: boolean;
  30203. particleIntersection?: boolean;
  30204. boundingSphereOnly?: boolean;
  30205. bSphereRadiusFactor?: number;
  30206. expandable?: boolean;
  30207. useModelMaterial?: boolean;
  30208. enableMultiMaterial?: boolean;
  30209. });
  30210. /**
  30211. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30212. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30213. * @returns the created mesh
  30214. */
  30215. buildMesh(): Mesh;
  30216. /**
  30217. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30218. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30219. * Thus the particles generated from `digest()` have their property `position` set yet.
  30220. * @param mesh ( Mesh ) is the mesh to be digested
  30221. * @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
  30222. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30223. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30224. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30225. * @returns the current SPS
  30226. */
  30227. digest(mesh: Mesh, options?: {
  30228. facetNb?: number;
  30229. number?: number;
  30230. delta?: number;
  30231. storage?: [];
  30232. }): SolidParticleSystem;
  30233. /**
  30234. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30235. * @hidden
  30236. */
  30237. private _unrotateFixedNormals;
  30238. /**
  30239. * Resets the temporary working copy particle
  30240. * @hidden
  30241. */
  30242. private _resetCopy;
  30243. /**
  30244. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30245. * @param p the current index in the positions array to be updated
  30246. * @param ind the current index in the indices array
  30247. * @param shape a Vector3 array, the shape geometry
  30248. * @param positions the positions array to be updated
  30249. * @param meshInd the shape indices array
  30250. * @param indices the indices array to be updated
  30251. * @param meshUV the shape uv array
  30252. * @param uvs the uv array to be updated
  30253. * @param meshCol the shape color array
  30254. * @param colors the color array to be updated
  30255. * @param meshNor the shape normals array
  30256. * @param normals the normals array to be updated
  30257. * @param idx the particle index
  30258. * @param idxInShape the particle index in its shape
  30259. * @param options the addShape() method passed options
  30260. * @model the particle model
  30261. * @hidden
  30262. */
  30263. private _meshBuilder;
  30264. /**
  30265. * Returns a shape Vector3 array from positions float array
  30266. * @param positions float array
  30267. * @returns a vector3 array
  30268. * @hidden
  30269. */
  30270. private _posToShape;
  30271. /**
  30272. * Returns a shapeUV array from a float uvs (array deep copy)
  30273. * @param uvs as a float array
  30274. * @returns a shapeUV array
  30275. * @hidden
  30276. */
  30277. private _uvsToShapeUV;
  30278. /**
  30279. * Adds a new particle object in the particles array
  30280. * @param idx particle index in particles array
  30281. * @param id particle id
  30282. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30283. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30284. * @param model particle ModelShape object
  30285. * @param shapeId model shape identifier
  30286. * @param idxInShape index of the particle in the current model
  30287. * @param bInfo model bounding info object
  30288. * @param storage target storage array, if any
  30289. * @hidden
  30290. */
  30291. private _addParticle;
  30292. /**
  30293. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30294. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30295. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30296. * @param nb (positive integer) the number of particles to be created from this model
  30297. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30298. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30299. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30300. * @returns the number of shapes in the system
  30301. */
  30302. addShape(mesh: Mesh, nb: number, options?: {
  30303. positionFunction?: any;
  30304. vertexFunction?: any;
  30305. storage?: [];
  30306. }): number;
  30307. /**
  30308. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30309. * @hidden
  30310. */
  30311. private _rebuildParticle;
  30312. /**
  30313. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30314. * @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.
  30315. * @returns the SPS.
  30316. */
  30317. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30318. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30319. * Returns an array with the removed particles.
  30320. * 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.
  30321. * The SPS can't be empty so at least one particle needs to remain in place.
  30322. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30323. * @param start index of the first particle to remove
  30324. * @param end index of the last particle to remove (included)
  30325. * @returns an array populated with the removed particles
  30326. */
  30327. removeParticles(start: number, end: number): SolidParticle[];
  30328. /**
  30329. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30330. * @param solidParticleArray an array populated with Solid Particles objects
  30331. * @returns the SPS
  30332. */
  30333. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30334. /**
  30335. * Creates a new particle and modifies the SPS mesh geometry :
  30336. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30337. * - calls _addParticle() to populate the particle array
  30338. * factorized code from addShape() and insertParticlesFromArray()
  30339. * @param idx particle index in the particles array
  30340. * @param i particle index in its shape
  30341. * @param modelShape particle ModelShape object
  30342. * @param shape shape vertex array
  30343. * @param meshInd shape indices array
  30344. * @param meshUV shape uv array
  30345. * @param meshCol shape color array
  30346. * @param meshNor shape normals array
  30347. * @param bbInfo shape bounding info
  30348. * @param storage target particle storage
  30349. * @options addShape() passed options
  30350. * @hidden
  30351. */
  30352. private _insertNewParticle;
  30353. /**
  30354. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30355. * This method calls `updateParticle()` for each particle of the SPS.
  30356. * For an animated SPS, it is usually called within the render loop.
  30357. * 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.
  30358. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30359. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30360. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30361. * @returns the SPS.
  30362. */
  30363. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30364. /**
  30365. * Disposes the SPS.
  30366. */
  30367. dispose(): void;
  30368. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30369. * idx is the particle index in the SPS
  30370. * faceId is the picked face index counted within this particle.
  30371. * Returns null if the pickInfo can't identify a picked particle.
  30372. * @param pickingInfo (PickingInfo object)
  30373. * @returns {idx: number, faceId: number} or null
  30374. */
  30375. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30376. idx: number;
  30377. faceId: number;
  30378. }>;
  30379. /**
  30380. * Returns a SolidParticle object from its identifier : particle.id
  30381. * @param id (integer) the particle Id
  30382. * @returns the searched particle or null if not found in the SPS.
  30383. */
  30384. getParticleById(id: number): Nullable<SolidParticle>;
  30385. /**
  30386. * Returns a new array populated with the particles having the passed shapeId.
  30387. * @param shapeId (integer) the shape identifier
  30388. * @returns a new solid particle array
  30389. */
  30390. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30391. /**
  30392. * Populates the passed array "ref" with the particles having the passed shapeId.
  30393. * @param shapeId the shape identifier
  30394. * @returns the SPS
  30395. * @param ref
  30396. */
  30397. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30398. /**
  30399. * Computes the required SubMeshes according the materials assigned to the particles.
  30400. * @returns the solid particle system.
  30401. * Does nothing if called before the SPS mesh is built.
  30402. */
  30403. computeSubMeshes(): SolidParticleSystem;
  30404. /**
  30405. * Sorts the solid particles by material when MultiMaterial is enabled.
  30406. * Updates the indices32 array.
  30407. * Updates the indicesByMaterial array.
  30408. * Updates the mesh indices array.
  30409. * @returns the SPS
  30410. * @hidden
  30411. */
  30412. private _sortParticlesByMaterial;
  30413. /**
  30414. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30415. * @hidden
  30416. */
  30417. private _setMaterialIndexesById;
  30418. /**
  30419. * Returns an array with unique values of Materials from the passed array
  30420. * @param array the material array to be checked and filtered
  30421. * @hidden
  30422. */
  30423. private _filterUniqueMaterialId;
  30424. /**
  30425. * Sets a new Standard Material as _defaultMaterial if not already set.
  30426. * @hidden
  30427. */
  30428. private _setDefaultMaterial;
  30429. /**
  30430. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30431. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30432. * @returns the SPS.
  30433. */
  30434. refreshVisibleSize(): SolidParticleSystem;
  30435. /**
  30436. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30437. * @param size the size (float) of the visibility box
  30438. * note : this doesn't lock the SPS mesh bounding box.
  30439. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30440. */
  30441. setVisibilityBox(size: number): void;
  30442. /**
  30443. * Gets whether the SPS as always visible or not
  30444. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30445. */
  30446. get isAlwaysVisible(): boolean;
  30447. /**
  30448. * Sets the SPS as always visible or not
  30449. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30450. */
  30451. set isAlwaysVisible(val: boolean);
  30452. /**
  30453. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30454. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30455. */
  30456. set isVisibilityBoxLocked(val: boolean);
  30457. /**
  30458. * Gets if 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. get isVisibilityBoxLocked(): boolean;
  30462. /**
  30463. * Tells to `setParticles()` to compute the particle rotations or not.
  30464. * Default value : true. The SPS is faster when it's set to false.
  30465. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30466. */
  30467. set computeParticleRotation(val: boolean);
  30468. /**
  30469. * Tells to `setParticles()` to compute the particle colors or not.
  30470. * Default value : true. The SPS is faster when it's set to false.
  30471. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30472. */
  30473. set computeParticleColor(val: boolean);
  30474. set computeParticleTexture(val: boolean);
  30475. /**
  30476. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30477. * Default value : false. The SPS is faster when it's set to false.
  30478. * Note : the particle custom vertex positions aren't stored values.
  30479. */
  30480. set computeParticleVertex(val: boolean);
  30481. /**
  30482. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30483. */
  30484. set computeBoundingBox(val: boolean);
  30485. /**
  30486. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30487. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30488. * Default : `true`
  30489. */
  30490. set depthSortParticles(val: boolean);
  30491. /**
  30492. * Gets if `setParticles()` computes the particle rotations or not.
  30493. * Default value : true. The SPS is faster when it's set to false.
  30494. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30495. */
  30496. get computeParticleRotation(): boolean;
  30497. /**
  30498. * Gets if `setParticles()` computes the particle colors or not.
  30499. * Default value : true. The SPS is faster when it's set to false.
  30500. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30501. */
  30502. get computeParticleColor(): boolean;
  30503. /**
  30504. * Gets if `setParticles()` computes the particle textures or not.
  30505. * Default value : true. The SPS is faster when it's set to false.
  30506. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30507. */
  30508. get computeParticleTexture(): boolean;
  30509. /**
  30510. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30511. * Default value : false. The SPS is faster when it's set to false.
  30512. * Note : the particle custom vertex positions aren't stored values.
  30513. */
  30514. get computeParticleVertex(): boolean;
  30515. /**
  30516. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30517. */
  30518. get computeBoundingBox(): boolean;
  30519. /**
  30520. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30521. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30522. * Default : `true`
  30523. */
  30524. get depthSortParticles(): boolean;
  30525. /**
  30526. * Gets if the SPS is created as expandable at construction time.
  30527. * Default : `false`
  30528. */
  30529. get expandable(): boolean;
  30530. /**
  30531. * Gets if the SPS supports the Multi Materials
  30532. */
  30533. get multimaterialEnabled(): boolean;
  30534. /**
  30535. * Gets if the SPS uses the model materials for its own multimaterial.
  30536. */
  30537. get useModelMaterial(): boolean;
  30538. /**
  30539. * The SPS used material array.
  30540. */
  30541. get materials(): Material[];
  30542. /**
  30543. * Sets the SPS MultiMaterial from the passed materials.
  30544. * Note : the passed array is internally copied and not used then by reference.
  30545. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30546. */
  30547. setMultiMaterial(materials: Material[]): void;
  30548. /**
  30549. * The SPS computed multimaterial object
  30550. */
  30551. get multimaterial(): MultiMaterial;
  30552. set multimaterial(mm: MultiMaterial);
  30553. /**
  30554. * If the subMeshes must be updated on the next call to setParticles()
  30555. */
  30556. get autoUpdateSubMeshes(): boolean;
  30557. set autoUpdateSubMeshes(val: boolean);
  30558. /**
  30559. * This function does nothing. It may be overwritten to set all the particle first values.
  30560. * The SPS doesn't call this function, you may have to call it by your own.
  30561. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30562. */
  30563. initParticles(): void;
  30564. /**
  30565. * This function does nothing. It may be overwritten to recycle a particle.
  30566. * The SPS doesn't call this function, you may have to call it by your own.
  30567. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30568. * @param particle The particle to recycle
  30569. * @returns the recycled particle
  30570. */
  30571. recycleParticle(particle: SolidParticle): SolidParticle;
  30572. /**
  30573. * Updates a particle : this function should be overwritten by the user.
  30574. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30575. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30576. * @example : just set a particle position or velocity and recycle conditions
  30577. * @param particle The particle to update
  30578. * @returns the updated particle
  30579. */
  30580. updateParticle(particle: SolidParticle): SolidParticle;
  30581. /**
  30582. * Updates a vertex of a particle : it can be overwritten by the user.
  30583. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30584. * @param particle the current particle
  30585. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30586. * @param pt the index of the current vertex in the particle shape
  30587. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30588. * @example : just set a vertex particle position or color
  30589. * @returns the sps
  30590. */
  30591. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30592. /**
  30593. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30594. * This does nothing and may be overwritten by the user.
  30595. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30596. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30597. * @param update the boolean update value actually passed to setParticles()
  30598. */
  30599. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30600. /**
  30601. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30602. * This will be passed three parameters.
  30603. * This does nothing and may be overwritten by the user.
  30604. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30605. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30606. * @param update the boolean update value actually passed to setParticles()
  30607. */
  30608. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30609. }
  30610. }
  30611. declare module BABYLON {
  30612. /**
  30613. * Represents one particle of a solid particle system.
  30614. */
  30615. export class SolidParticle {
  30616. /**
  30617. * particle global index
  30618. */
  30619. idx: number;
  30620. /**
  30621. * particle identifier
  30622. */
  30623. id: number;
  30624. /**
  30625. * The color of the particle
  30626. */
  30627. color: Nullable<Color4>;
  30628. /**
  30629. * The world space position of the particle.
  30630. */
  30631. position: Vector3;
  30632. /**
  30633. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30634. */
  30635. rotation: Vector3;
  30636. /**
  30637. * The world space rotation quaternion of the particle.
  30638. */
  30639. rotationQuaternion: Nullable<Quaternion>;
  30640. /**
  30641. * The scaling of the particle.
  30642. */
  30643. scaling: Vector3;
  30644. /**
  30645. * The uvs of the particle.
  30646. */
  30647. uvs: Vector4;
  30648. /**
  30649. * The current speed of the particle.
  30650. */
  30651. velocity: Vector3;
  30652. /**
  30653. * The pivot point in the particle local space.
  30654. */
  30655. pivot: Vector3;
  30656. /**
  30657. * Must the particle be translated from its pivot point in its local space ?
  30658. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30659. * Default : false
  30660. */
  30661. translateFromPivot: boolean;
  30662. /**
  30663. * Is the particle active or not ?
  30664. */
  30665. alive: boolean;
  30666. /**
  30667. * Is the particle visible or not ?
  30668. */
  30669. isVisible: boolean;
  30670. /**
  30671. * Index of this particle in the global "positions" array (Internal use)
  30672. * @hidden
  30673. */
  30674. _pos: number;
  30675. /**
  30676. * @hidden Index of this particle in the global "indices" array (Internal use)
  30677. */
  30678. _ind: number;
  30679. /**
  30680. * @hidden ModelShape of this particle (Internal use)
  30681. */
  30682. _model: ModelShape;
  30683. /**
  30684. * ModelShape id of this particle
  30685. */
  30686. shapeId: number;
  30687. /**
  30688. * Index of the particle in its shape id
  30689. */
  30690. idxInShape: number;
  30691. /**
  30692. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30693. */
  30694. _modelBoundingInfo: BoundingInfo;
  30695. /**
  30696. * @hidden Particle BoundingInfo object (Internal use)
  30697. */
  30698. _boundingInfo: BoundingInfo;
  30699. /**
  30700. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30701. */
  30702. _sps: SolidParticleSystem;
  30703. /**
  30704. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30705. */
  30706. _stillInvisible: boolean;
  30707. /**
  30708. * @hidden Last computed particle rotation matrix
  30709. */
  30710. _rotationMatrix: number[];
  30711. /**
  30712. * Parent particle Id, if any.
  30713. * Default null.
  30714. */
  30715. parentId: Nullable<number>;
  30716. /**
  30717. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30718. */
  30719. materialIndex: Nullable<number>;
  30720. /**
  30721. * Custom object or properties.
  30722. */
  30723. props: Nullable<any>;
  30724. /**
  30725. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30726. * The possible values are :
  30727. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30728. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30729. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30730. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30731. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30732. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30733. * */
  30734. cullingStrategy: number;
  30735. /**
  30736. * @hidden Internal global position in the SPS.
  30737. */
  30738. _globalPosition: Vector3;
  30739. /**
  30740. * Creates a Solid Particle object.
  30741. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30742. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30743. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30744. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30745. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30746. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30747. * @param shapeId (integer) is the model shape identifier in the SPS.
  30748. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30749. * @param sps defines the sps it is associated to
  30750. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30751. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30752. */
  30753. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30754. /**
  30755. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30756. * @param target the particle target
  30757. * @returns the current particle
  30758. */
  30759. copyToRef(target: SolidParticle): SolidParticle;
  30760. /**
  30761. * Legacy support, changed scale to scaling
  30762. */
  30763. get scale(): Vector3;
  30764. /**
  30765. * Legacy support, changed scale to scaling
  30766. */
  30767. set scale(scale: Vector3);
  30768. /**
  30769. * Legacy support, changed quaternion to rotationQuaternion
  30770. */
  30771. get quaternion(): Nullable<Quaternion>;
  30772. /**
  30773. * Legacy support, changed quaternion to rotationQuaternion
  30774. */
  30775. set quaternion(q: Nullable<Quaternion>);
  30776. /**
  30777. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30778. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30779. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30780. * @returns true if it intersects
  30781. */
  30782. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30783. /**
  30784. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30785. * A particle is in the frustum if its bounding box intersects the frustum
  30786. * @param frustumPlanes defines the frustum to test
  30787. * @returns true if the particle is in the frustum planes
  30788. */
  30789. isInFrustum(frustumPlanes: Plane[]): boolean;
  30790. /**
  30791. * get the rotation matrix of the particle
  30792. * @hidden
  30793. */
  30794. getRotationMatrix(m: Matrix): void;
  30795. }
  30796. /**
  30797. * Represents the shape of the model used by one particle of a solid particle system.
  30798. * SPS internal tool, don't use it manually.
  30799. */
  30800. export class ModelShape {
  30801. /**
  30802. * The shape id
  30803. * @hidden
  30804. */
  30805. shapeID: number;
  30806. /**
  30807. * flat array of model positions (internal use)
  30808. * @hidden
  30809. */
  30810. _shape: Vector3[];
  30811. /**
  30812. * flat array of model UVs (internal use)
  30813. * @hidden
  30814. */
  30815. _shapeUV: number[];
  30816. /**
  30817. * color array of the model
  30818. * @hidden
  30819. */
  30820. _shapeColors: number[];
  30821. /**
  30822. * indices array of the model
  30823. * @hidden
  30824. */
  30825. _indices: number[];
  30826. /**
  30827. * normals array of the model
  30828. * @hidden
  30829. */
  30830. _normals: number[];
  30831. /**
  30832. * length of the shape in the model indices array (internal use)
  30833. * @hidden
  30834. */
  30835. _indicesLength: number;
  30836. /**
  30837. * Custom position function (internal use)
  30838. * @hidden
  30839. */
  30840. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30841. /**
  30842. * Custom vertex function (internal use)
  30843. * @hidden
  30844. */
  30845. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30846. /**
  30847. * Model material (internal use)
  30848. * @hidden
  30849. */
  30850. _material: Nullable<Material>;
  30851. /**
  30852. * 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.
  30853. * SPS internal tool, don't use it manually.
  30854. * @hidden
  30855. */
  30856. 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>);
  30857. }
  30858. /**
  30859. * Represents a Depth Sorted Particle in the solid particle system.
  30860. * @hidden
  30861. */
  30862. export class DepthSortedParticle {
  30863. /**
  30864. * Particle index
  30865. */
  30866. idx: number;
  30867. /**
  30868. * Index of the particle in the "indices" array
  30869. */
  30870. ind: number;
  30871. /**
  30872. * Length of the particle shape in the "indices" array
  30873. */
  30874. indicesLength: number;
  30875. /**
  30876. * Squared distance from the particle to the camera
  30877. */
  30878. sqDistance: number;
  30879. /**
  30880. * Material index when used with MultiMaterials
  30881. */
  30882. materialIndex: number;
  30883. /**
  30884. * Creates a new sorted particle
  30885. * @param materialIndex
  30886. */
  30887. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30888. }
  30889. /**
  30890. * Represents a solid particle vertex
  30891. */
  30892. export class SolidParticleVertex {
  30893. /**
  30894. * Vertex position
  30895. */
  30896. position: Vector3;
  30897. /**
  30898. * Vertex color
  30899. */
  30900. color: Color4;
  30901. /**
  30902. * Vertex UV
  30903. */
  30904. uv: Vector2;
  30905. /**
  30906. * Creates a new solid particle vertex
  30907. */
  30908. constructor();
  30909. /** Vertex x coordinate */
  30910. get x(): number;
  30911. set x(val: number);
  30912. /** Vertex y coordinate */
  30913. get y(): number;
  30914. set y(val: number);
  30915. /** Vertex z coordinate */
  30916. get z(): number;
  30917. set z(val: number);
  30918. }
  30919. }
  30920. declare module BABYLON {
  30921. /**
  30922. * @hidden
  30923. */
  30924. export class _MeshCollisionData {
  30925. _checkCollisions: boolean;
  30926. _collisionMask: number;
  30927. _collisionGroup: number;
  30928. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30929. _collider: Nullable<Collider>;
  30930. _oldPositionForCollisions: Vector3;
  30931. _diffPositionForCollisions: Vector3;
  30932. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30933. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30934. }
  30935. }
  30936. declare module BABYLON {
  30937. /** @hidden */
  30938. class _FacetDataStorage {
  30939. facetPositions: Vector3[];
  30940. facetNormals: Vector3[];
  30941. facetPartitioning: number[][];
  30942. facetNb: number;
  30943. partitioningSubdivisions: number;
  30944. partitioningBBoxRatio: number;
  30945. facetDataEnabled: boolean;
  30946. facetParameters: any;
  30947. bbSize: Vector3;
  30948. subDiv: {
  30949. max: number;
  30950. X: number;
  30951. Y: number;
  30952. Z: number;
  30953. };
  30954. facetDepthSort: boolean;
  30955. facetDepthSortEnabled: boolean;
  30956. depthSortedIndices: IndicesArray;
  30957. depthSortedFacets: {
  30958. ind: number;
  30959. sqDistance: number;
  30960. }[];
  30961. facetDepthSortFunction: (f1: {
  30962. ind: number;
  30963. sqDistance: number;
  30964. }, f2: {
  30965. ind: number;
  30966. sqDistance: number;
  30967. }) => number;
  30968. facetDepthSortFrom: Vector3;
  30969. facetDepthSortOrigin: Vector3;
  30970. invertedMatrix: Matrix;
  30971. }
  30972. /**
  30973. * @hidden
  30974. **/
  30975. class _InternalAbstractMeshDataInfo {
  30976. _hasVertexAlpha: boolean;
  30977. _useVertexColors: boolean;
  30978. _numBoneInfluencers: number;
  30979. _applyFog: boolean;
  30980. _receiveShadows: boolean;
  30981. _facetData: _FacetDataStorage;
  30982. _visibility: number;
  30983. _skeleton: Nullable<Skeleton>;
  30984. _layerMask: number;
  30985. _computeBonesUsingShaders: boolean;
  30986. _isActive: boolean;
  30987. _onlyForInstances: boolean;
  30988. _isActiveIntermediate: boolean;
  30989. _onlyForInstancesIntermediate: boolean;
  30990. _actAsRegularMesh: boolean;
  30991. }
  30992. /**
  30993. * Class used to store all common mesh properties
  30994. */
  30995. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30996. /** No occlusion */
  30997. static OCCLUSION_TYPE_NONE: number;
  30998. /** Occlusion set to optimisitic */
  30999. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31000. /** Occlusion set to strict */
  31001. static OCCLUSION_TYPE_STRICT: number;
  31002. /** Use an accurante occlusion algorithm */
  31003. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31004. /** Use a conservative occlusion algorithm */
  31005. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31007. * Test order :
  31008. * Is the bounding sphere outside the frustum ?
  31009. * If not, are the bounding box vertices outside the frustum ?
  31010. * It not, then the cullable object is in the frustum.
  31011. */
  31012. static readonly CULLINGSTRATEGY_STANDARD: number;
  31013. /** Culling strategy : Bounding Sphere Only.
  31014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31015. * It's also less accurate than the standard because some not visible objects can still be selected.
  31016. * Test : is the bounding sphere outside the frustum ?
  31017. * If not, then the cullable object is in the frustum.
  31018. */
  31019. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31020. /** Culling strategy : Optimistic Inclusion.
  31021. * This in an inclusion test first, then the standard exclusion test.
  31022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31023. * 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.
  31024. * Anyway, it's as accurate as the standard strategy.
  31025. * Test :
  31026. * Is the cullable object bounding sphere center in the frustum ?
  31027. * If not, apply the default culling strategy.
  31028. */
  31029. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31033. * 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.
  31034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31035. * Test :
  31036. * Is the cullable object bounding sphere center in the frustum ?
  31037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31038. */
  31039. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31040. /**
  31041. * No billboard
  31042. */
  31043. static get BILLBOARDMODE_NONE(): number;
  31044. /** Billboard on X axis */
  31045. static get BILLBOARDMODE_X(): number;
  31046. /** Billboard on Y axis */
  31047. static get BILLBOARDMODE_Y(): number;
  31048. /** Billboard on Z axis */
  31049. static get BILLBOARDMODE_Z(): number;
  31050. /** Billboard on all axes */
  31051. static get BILLBOARDMODE_ALL(): number;
  31052. /** Billboard on using position instead of orientation */
  31053. static get BILLBOARDMODE_USE_POSITION(): number;
  31054. /** @hidden */
  31055. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31056. /**
  31057. * The culling strategy to use to check whether the mesh must be rendered or not.
  31058. * This value can be changed at any time and will be used on the next render mesh selection.
  31059. * The possible values are :
  31060. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31061. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31062. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31063. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31064. * Please read each static variable documentation to get details about the culling process.
  31065. * */
  31066. cullingStrategy: number;
  31067. /**
  31068. * Gets the number of facets in the mesh
  31069. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31070. */
  31071. get facetNb(): number;
  31072. /**
  31073. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31074. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31075. */
  31076. get partitioningSubdivisions(): number;
  31077. set partitioningSubdivisions(nb: number);
  31078. /**
  31079. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31080. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31081. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31082. */
  31083. get partitioningBBoxRatio(): number;
  31084. set partitioningBBoxRatio(ratio: number);
  31085. /**
  31086. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31087. * Works only for updatable meshes.
  31088. * Doesn't work with multi-materials
  31089. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31090. */
  31091. get mustDepthSortFacets(): boolean;
  31092. set mustDepthSortFacets(sort: boolean);
  31093. /**
  31094. * The location (Vector3) where the facet depth sort must be computed from.
  31095. * By default, the active camera position.
  31096. * Used only when facet depth sort is enabled
  31097. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31098. */
  31099. get facetDepthSortFrom(): Vector3;
  31100. set facetDepthSortFrom(location: Vector3);
  31101. /**
  31102. * gets a boolean indicating if facetData is enabled
  31103. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31104. */
  31105. get isFacetDataEnabled(): boolean;
  31106. /** @hidden */
  31107. _updateNonUniformScalingState(value: boolean): boolean;
  31108. /**
  31109. * An event triggered when this mesh collides with another one
  31110. */
  31111. onCollideObservable: Observable<AbstractMesh>;
  31112. /** Set a function to call when this mesh collides with another one */
  31113. set onCollide(callback: () => void);
  31114. /**
  31115. * An event triggered when the collision's position changes
  31116. */
  31117. onCollisionPositionChangeObservable: Observable<Vector3>;
  31118. /** Set a function to call when the collision's position changes */
  31119. set onCollisionPositionChange(callback: () => void);
  31120. /**
  31121. * An event triggered when material is changed
  31122. */
  31123. onMaterialChangedObservable: Observable<AbstractMesh>;
  31124. /**
  31125. * Gets or sets the orientation for POV movement & rotation
  31126. */
  31127. definedFacingForward: boolean;
  31128. /** @hidden */
  31129. _occlusionQuery: Nullable<WebGLQuery>;
  31130. /** @hidden */
  31131. _renderingGroup: Nullable<RenderingGroup>;
  31132. /**
  31133. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31134. */
  31135. get visibility(): number;
  31136. /**
  31137. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31138. */
  31139. set visibility(value: number);
  31140. /** Gets or sets the alpha index used to sort transparent meshes
  31141. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31142. */
  31143. alphaIndex: number;
  31144. /**
  31145. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31146. */
  31147. isVisible: boolean;
  31148. /**
  31149. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31150. */
  31151. isPickable: boolean;
  31152. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31153. showSubMeshesBoundingBox: boolean;
  31154. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31155. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31156. */
  31157. isBlocker: boolean;
  31158. /**
  31159. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31160. */
  31161. enablePointerMoveEvents: boolean;
  31162. /**
  31163. * Specifies the rendering group id for this mesh (0 by default)
  31164. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31165. */
  31166. renderingGroupId: number;
  31167. private _material;
  31168. /** Gets or sets current material */
  31169. get material(): Nullable<Material>;
  31170. set material(value: Nullable<Material>);
  31171. /**
  31172. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31173. * @see https://doc.babylonjs.com/babylon101/shadows
  31174. */
  31175. get receiveShadows(): boolean;
  31176. set receiveShadows(value: boolean);
  31177. /** Defines color to use when rendering outline */
  31178. outlineColor: Color3;
  31179. /** Define width to use when rendering outline */
  31180. outlineWidth: number;
  31181. /** Defines color to use when rendering overlay */
  31182. overlayColor: Color3;
  31183. /** Defines alpha to use when rendering overlay */
  31184. overlayAlpha: number;
  31185. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31186. get hasVertexAlpha(): boolean;
  31187. set hasVertexAlpha(value: boolean);
  31188. /** 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) */
  31189. get useVertexColors(): boolean;
  31190. set useVertexColors(value: boolean);
  31191. /**
  31192. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31193. */
  31194. get computeBonesUsingShaders(): boolean;
  31195. set computeBonesUsingShaders(value: boolean);
  31196. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31197. get numBoneInfluencers(): number;
  31198. set numBoneInfluencers(value: number);
  31199. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31200. get applyFog(): boolean;
  31201. set applyFog(value: boolean);
  31202. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31203. useOctreeForRenderingSelection: boolean;
  31204. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31205. useOctreeForPicking: boolean;
  31206. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31207. useOctreeForCollisions: boolean;
  31208. /**
  31209. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31210. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31211. */
  31212. get layerMask(): number;
  31213. set layerMask(value: number);
  31214. /**
  31215. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31216. */
  31217. alwaysSelectAsActiveMesh: boolean;
  31218. /**
  31219. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31220. */
  31221. doNotSyncBoundingInfo: boolean;
  31222. /**
  31223. * Gets or sets the current action manager
  31224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31225. */
  31226. actionManager: Nullable<AbstractActionManager>;
  31227. private _meshCollisionData;
  31228. /**
  31229. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31230. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31231. */
  31232. ellipsoid: Vector3;
  31233. /**
  31234. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31235. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31236. */
  31237. ellipsoidOffset: Vector3;
  31238. /**
  31239. * Gets or sets a collision mask used to mask collisions (default is -1).
  31240. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31241. */
  31242. get collisionMask(): number;
  31243. set collisionMask(mask: number);
  31244. /**
  31245. * Gets or sets the current collision group mask (-1 by default).
  31246. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31247. */
  31248. get collisionGroup(): number;
  31249. set collisionGroup(mask: number);
  31250. /**
  31251. * Gets or sets current surrounding meshes (null by default).
  31252. *
  31253. * By default collision detection is tested against every mesh in the scene.
  31254. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31255. * meshes will be tested for the collision.
  31256. *
  31257. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31258. */
  31259. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31260. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31261. /**
  31262. * Defines edge width used when edgesRenderer is enabled
  31263. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31264. */
  31265. edgesWidth: number;
  31266. /**
  31267. * Defines edge color used when edgesRenderer is enabled
  31268. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31269. */
  31270. edgesColor: Color4;
  31271. /** @hidden */
  31272. _edgesRenderer: Nullable<IEdgesRenderer>;
  31273. /** @hidden */
  31274. _masterMesh: Nullable<AbstractMesh>;
  31275. /** @hidden */
  31276. _boundingInfo: Nullable<BoundingInfo>;
  31277. /** @hidden */
  31278. _renderId: number;
  31279. /**
  31280. * Gets or sets the list of subMeshes
  31281. * @see https://doc.babylonjs.com/how_to/multi_materials
  31282. */
  31283. subMeshes: SubMesh[];
  31284. /** @hidden */
  31285. _intersectionsInProgress: AbstractMesh[];
  31286. /** @hidden */
  31287. _unIndexed: boolean;
  31288. /** @hidden */
  31289. _lightSources: Light[];
  31290. /** Gets the list of lights affecting that mesh */
  31291. get lightSources(): Light[];
  31292. /** @hidden */
  31293. get _positions(): Nullable<Vector3[]>;
  31294. /** @hidden */
  31295. _waitingData: {
  31296. lods: Nullable<any>;
  31297. actions: Nullable<any>;
  31298. freezeWorldMatrix: Nullable<boolean>;
  31299. };
  31300. /** @hidden */
  31301. _bonesTransformMatrices: Nullable<Float32Array>;
  31302. /** @hidden */
  31303. _transformMatrixTexture: Nullable<RawTexture>;
  31304. /**
  31305. * Gets or sets a skeleton to apply skining transformations
  31306. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31307. */
  31308. set skeleton(value: Nullable<Skeleton>);
  31309. get skeleton(): Nullable<Skeleton>;
  31310. /**
  31311. * An event triggered when the mesh is rebuilt.
  31312. */
  31313. onRebuildObservable: Observable<AbstractMesh>;
  31314. /**
  31315. * Creates a new AbstractMesh
  31316. * @param name defines the name of the mesh
  31317. * @param scene defines the hosting scene
  31318. */
  31319. constructor(name: string, scene?: Nullable<Scene>);
  31320. /**
  31321. * Returns the string "AbstractMesh"
  31322. * @returns "AbstractMesh"
  31323. */
  31324. getClassName(): string;
  31325. /**
  31326. * Gets a string representation of the current mesh
  31327. * @param fullDetails defines a boolean indicating if full details must be included
  31328. * @returns a string representation of the current mesh
  31329. */
  31330. toString(fullDetails?: boolean): string;
  31331. /**
  31332. * @hidden
  31333. */
  31334. protected _getEffectiveParent(): Nullable<Node>;
  31335. /** @hidden */
  31336. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31337. /** @hidden */
  31338. _rebuild(): void;
  31339. /** @hidden */
  31340. _resyncLightSources(): void;
  31341. /** @hidden */
  31342. _resyncLightSource(light: Light): void;
  31343. /** @hidden */
  31344. _unBindEffect(): void;
  31345. /** @hidden */
  31346. _removeLightSource(light: Light, dispose: boolean): void;
  31347. private _markSubMeshesAsDirty;
  31348. /** @hidden */
  31349. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31350. /** @hidden */
  31351. _markSubMeshesAsAttributesDirty(): void;
  31352. /** @hidden */
  31353. _markSubMeshesAsMiscDirty(): void;
  31354. /**
  31355. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31356. */
  31357. get scaling(): Vector3;
  31358. set scaling(newScaling: Vector3);
  31359. /**
  31360. * Returns true if the mesh is blocked. Implemented by child classes
  31361. */
  31362. get isBlocked(): boolean;
  31363. /**
  31364. * Returns the mesh itself by default. Implemented by child classes
  31365. * @param camera defines the camera to use to pick the right LOD level
  31366. * @returns the currentAbstractMesh
  31367. */
  31368. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31369. /**
  31370. * Returns 0 by default. Implemented by child classes
  31371. * @returns an integer
  31372. */
  31373. getTotalVertices(): number;
  31374. /**
  31375. * Returns a positive integer : the total number of indices in this mesh geometry.
  31376. * @returns the numner of indices or zero if the mesh has no geometry.
  31377. */
  31378. getTotalIndices(): number;
  31379. /**
  31380. * Returns null by default. Implemented by child classes
  31381. * @returns null
  31382. */
  31383. getIndices(): Nullable<IndicesArray>;
  31384. /**
  31385. * Returns the array of the requested vertex data kind. Implemented by child classes
  31386. * @param kind defines the vertex data kind to use
  31387. * @returns null
  31388. */
  31389. getVerticesData(kind: string): Nullable<FloatArray>;
  31390. /**
  31391. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31392. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31393. * Note that a new underlying VertexBuffer object is created each call.
  31394. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31395. * @param kind defines vertex data kind:
  31396. * * VertexBuffer.PositionKind
  31397. * * VertexBuffer.UVKind
  31398. * * VertexBuffer.UV2Kind
  31399. * * VertexBuffer.UV3Kind
  31400. * * VertexBuffer.UV4Kind
  31401. * * VertexBuffer.UV5Kind
  31402. * * VertexBuffer.UV6Kind
  31403. * * VertexBuffer.ColorKind
  31404. * * VertexBuffer.MatricesIndicesKind
  31405. * * VertexBuffer.MatricesIndicesExtraKind
  31406. * * VertexBuffer.MatricesWeightsKind
  31407. * * VertexBuffer.MatricesWeightsExtraKind
  31408. * @param data defines the data source
  31409. * @param updatable defines if the data must be flagged as updatable (or static)
  31410. * @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
  31411. * @returns the current mesh
  31412. */
  31413. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31414. /**
  31415. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31416. * If the mesh has no geometry, it is simply returned as it is.
  31417. * @param kind defines vertex data kind:
  31418. * * VertexBuffer.PositionKind
  31419. * * VertexBuffer.UVKind
  31420. * * VertexBuffer.UV2Kind
  31421. * * VertexBuffer.UV3Kind
  31422. * * VertexBuffer.UV4Kind
  31423. * * VertexBuffer.UV5Kind
  31424. * * VertexBuffer.UV6Kind
  31425. * * VertexBuffer.ColorKind
  31426. * * VertexBuffer.MatricesIndicesKind
  31427. * * VertexBuffer.MatricesIndicesExtraKind
  31428. * * VertexBuffer.MatricesWeightsKind
  31429. * * VertexBuffer.MatricesWeightsExtraKind
  31430. * @param data defines the data source
  31431. * @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
  31432. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31433. * @returns the current mesh
  31434. */
  31435. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31436. /**
  31437. * Sets the mesh indices,
  31438. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31439. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31440. * @param totalVertices Defines the total number of vertices
  31441. * @returns the current mesh
  31442. */
  31443. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31444. /**
  31445. * Gets a boolean indicating if specific vertex data is present
  31446. * @param kind defines the vertex data kind to use
  31447. * @returns true is data kind is present
  31448. */
  31449. isVerticesDataPresent(kind: string): boolean;
  31450. /**
  31451. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31452. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31453. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31454. * @returns a BoundingInfo
  31455. */
  31456. getBoundingInfo(): BoundingInfo;
  31457. /**
  31458. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31459. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31460. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31461. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31462. * @returns the current mesh
  31463. */
  31464. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31465. /**
  31466. * Overwrite the current bounding info
  31467. * @param boundingInfo defines the new bounding info
  31468. * @returns the current mesh
  31469. */
  31470. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31471. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31472. get useBones(): boolean;
  31473. /** @hidden */
  31474. _preActivate(): void;
  31475. /** @hidden */
  31476. _preActivateForIntermediateRendering(renderId: number): void;
  31477. /** @hidden */
  31478. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31479. /** @hidden */
  31480. _postActivate(): void;
  31481. /** @hidden */
  31482. _freeze(): void;
  31483. /** @hidden */
  31484. _unFreeze(): void;
  31485. /**
  31486. * Gets the current world matrix
  31487. * @returns a Matrix
  31488. */
  31489. getWorldMatrix(): Matrix;
  31490. /** @hidden */
  31491. _getWorldMatrixDeterminant(): number;
  31492. /**
  31493. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31494. */
  31495. get isAnInstance(): boolean;
  31496. /**
  31497. * Gets a boolean indicating if this mesh has instances
  31498. */
  31499. get hasInstances(): boolean;
  31500. /**
  31501. * Gets a boolean indicating if this mesh has thin instances
  31502. */
  31503. get hasThinInstances(): boolean;
  31504. /**
  31505. * Perform relative position change from the point of view of behind the front of the mesh.
  31506. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31507. * Supports definition of mesh facing forward or backward
  31508. * @param amountRight defines the distance on the right axis
  31509. * @param amountUp defines the distance on the up axis
  31510. * @param amountForward defines the distance on the forward axis
  31511. * @returns the current mesh
  31512. */
  31513. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31514. /**
  31515. * Calculate relative position change from the point of view of behind the front of the mesh.
  31516. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31517. * Supports definition of mesh facing forward or backward
  31518. * @param amountRight defines the distance on the right axis
  31519. * @param amountUp defines the distance on the up axis
  31520. * @param amountForward defines the distance on the forward axis
  31521. * @returns the new displacement vector
  31522. */
  31523. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31524. /**
  31525. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31526. * Supports definition of mesh facing forward or backward
  31527. * @param flipBack defines the flip
  31528. * @param twirlClockwise defines the twirl
  31529. * @param tiltRight defines the tilt
  31530. * @returns the current mesh
  31531. */
  31532. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31533. /**
  31534. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31535. * Supports definition of mesh facing forward or backward.
  31536. * @param flipBack defines the flip
  31537. * @param twirlClockwise defines the twirl
  31538. * @param tiltRight defines the tilt
  31539. * @returns the new rotation vector
  31540. */
  31541. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31542. /**
  31543. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31544. * This means the mesh underlying bounding box and sphere are recomputed.
  31545. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31546. * @returns the current mesh
  31547. */
  31548. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31549. /** @hidden */
  31550. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31551. /** @hidden */
  31552. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31553. /** @hidden */
  31554. _updateBoundingInfo(): AbstractMesh;
  31555. /** @hidden */
  31556. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31557. /** @hidden */
  31558. protected _afterComputeWorldMatrix(): void;
  31559. /** @hidden */
  31560. get _effectiveMesh(): AbstractMesh;
  31561. /**
  31562. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31563. * A mesh is in the frustum if its bounding box intersects the frustum
  31564. * @param frustumPlanes defines the frustum to test
  31565. * @returns true if the mesh is in the frustum planes
  31566. */
  31567. isInFrustum(frustumPlanes: Plane[]): boolean;
  31568. /**
  31569. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31570. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31571. * @param frustumPlanes defines the frustum to test
  31572. * @returns true if the mesh is completely in the frustum planes
  31573. */
  31574. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31575. /**
  31576. * True if the mesh intersects another mesh or a SolidParticle object
  31577. * @param mesh defines a target mesh or SolidParticle to test
  31578. * @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)
  31579. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31580. * @returns true if there is an intersection
  31581. */
  31582. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31583. /**
  31584. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31585. * @param point defines the point to test
  31586. * @returns true if there is an intersection
  31587. */
  31588. intersectsPoint(point: Vector3): boolean;
  31589. /**
  31590. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31591. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31592. */
  31593. get checkCollisions(): boolean;
  31594. set checkCollisions(collisionEnabled: boolean);
  31595. /**
  31596. * Gets Collider object used to compute collisions (not physics)
  31597. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31598. */
  31599. get collider(): Nullable<Collider>;
  31600. /**
  31601. * Move the mesh using collision engine
  31602. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31603. * @param displacement defines the requested displacement vector
  31604. * @returns the current mesh
  31605. */
  31606. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31607. private _onCollisionPositionChange;
  31608. /** @hidden */
  31609. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31610. /** @hidden */
  31611. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31612. /** @hidden */
  31613. _checkCollision(collider: Collider): AbstractMesh;
  31614. /** @hidden */
  31615. _generatePointsArray(): boolean;
  31616. /**
  31617. * Checks if the passed Ray intersects with the mesh
  31618. * @param ray defines the ray to use
  31619. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31620. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31621. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31622. * @returns the picking info
  31623. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31624. */
  31625. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31626. /**
  31627. * Clones the current mesh
  31628. * @param name defines the mesh name
  31629. * @param newParent defines the new mesh parent
  31630. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31631. * @returns the new mesh
  31632. */
  31633. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31634. /**
  31635. * Disposes all the submeshes of the current meshnp
  31636. * @returns the current mesh
  31637. */
  31638. releaseSubMeshes(): AbstractMesh;
  31639. /**
  31640. * Releases resources associated with this abstract mesh.
  31641. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31642. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31643. */
  31644. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31645. /**
  31646. * Adds the passed mesh as a child to the current mesh
  31647. * @param mesh defines the child mesh
  31648. * @returns the current mesh
  31649. */
  31650. addChild(mesh: AbstractMesh): AbstractMesh;
  31651. /**
  31652. * Removes the passed mesh from the current mesh children list
  31653. * @param mesh defines the child mesh
  31654. * @returns the current mesh
  31655. */
  31656. removeChild(mesh: AbstractMesh): AbstractMesh;
  31657. /** @hidden */
  31658. private _initFacetData;
  31659. /**
  31660. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31661. * This method can be called within the render loop.
  31662. * 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
  31663. * @returns the current mesh
  31664. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31665. */
  31666. updateFacetData(): AbstractMesh;
  31667. /**
  31668. * Returns the facetLocalNormals array.
  31669. * The normals are expressed in the mesh local spac
  31670. * @returns an array of Vector3
  31671. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31672. */
  31673. getFacetLocalNormals(): Vector3[];
  31674. /**
  31675. * Returns the facetLocalPositions array.
  31676. * The facet positions are expressed in the mesh local space
  31677. * @returns an array of Vector3
  31678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31679. */
  31680. getFacetLocalPositions(): Vector3[];
  31681. /**
  31682. * Returns the facetLocalPartioning array
  31683. * @returns an array of array of numbers
  31684. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31685. */
  31686. getFacetLocalPartitioning(): number[][];
  31687. /**
  31688. * Returns the i-th facet position in the world system.
  31689. * This method allocates a new Vector3 per call
  31690. * @param i defines the facet index
  31691. * @returns a new Vector3
  31692. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31693. */
  31694. getFacetPosition(i: number): Vector3;
  31695. /**
  31696. * Sets the reference Vector3 with the i-th facet position in the world system
  31697. * @param i defines the facet index
  31698. * @param ref defines the target vector
  31699. * @returns the current mesh
  31700. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31701. */
  31702. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31703. /**
  31704. * Returns the i-th facet normal in the world system.
  31705. * This method allocates a new Vector3 per call
  31706. * @param i defines the facet index
  31707. * @returns a new Vector3
  31708. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31709. */
  31710. getFacetNormal(i: number): Vector3;
  31711. /**
  31712. * Sets the reference Vector3 with the i-th facet normal in the world system
  31713. * @param i defines the facet index
  31714. * @param ref defines the target vector
  31715. * @returns the current mesh
  31716. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31717. */
  31718. getFacetNormalToRef(i: number, ref: Vector3): this;
  31719. /**
  31720. * 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)
  31721. * @param x defines x coordinate
  31722. * @param y defines y coordinate
  31723. * @param z defines z coordinate
  31724. * @returns the array of facet indexes
  31725. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31726. */
  31727. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31728. /**
  31729. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31730. * @param projected sets as the (x,y,z) world projection on the facet
  31731. * @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
  31732. * @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
  31733. * @param x defines x coordinate
  31734. * @param y defines y coordinate
  31735. * @param z defines z coordinate
  31736. * @returns the face index if found (or null instead)
  31737. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31738. */
  31739. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31740. /**
  31741. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31742. * @param projected sets as the (x,y,z) local projection on the facet
  31743. * @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
  31744. * @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
  31745. * @param x defines x coordinate
  31746. * @param y defines y coordinate
  31747. * @param z defines z coordinate
  31748. * @returns the face index if found (or null instead)
  31749. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31750. */
  31751. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31752. /**
  31753. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31754. * @returns the parameters
  31755. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31756. */
  31757. getFacetDataParameters(): any;
  31758. /**
  31759. * Disables the feature FacetData and frees the related memory
  31760. * @returns the current mesh
  31761. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31762. */
  31763. disableFacetData(): AbstractMesh;
  31764. /**
  31765. * Updates the AbstractMesh indices array
  31766. * @param indices defines the data source
  31767. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31768. * @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)
  31769. * @returns the current mesh
  31770. */
  31771. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31772. /**
  31773. * Creates new normals data for the mesh
  31774. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31775. * @returns the current mesh
  31776. */
  31777. createNormals(updatable: boolean): AbstractMesh;
  31778. /**
  31779. * Align the mesh with a normal
  31780. * @param normal defines the normal to use
  31781. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31782. * @returns the current mesh
  31783. */
  31784. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31785. /** @hidden */
  31786. _checkOcclusionQuery(): boolean;
  31787. /**
  31788. * Disables the mesh edge rendering mode
  31789. * @returns the currentAbstractMesh
  31790. */
  31791. disableEdgesRendering(): AbstractMesh;
  31792. /**
  31793. * Enables the edge rendering mode on the mesh.
  31794. * This mode makes the mesh edges visible
  31795. * @param epsilon defines the maximal distance between two angles to detect a face
  31796. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31797. * @returns the currentAbstractMesh
  31798. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31799. */
  31800. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31801. /**
  31802. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  31803. * @returns an array of particle systems in the scene that use the mesh as an emitter
  31804. */
  31805. getConnectedParticleSystems(): IParticleSystem[];
  31806. }
  31807. }
  31808. declare module BABYLON {
  31809. /**
  31810. * Interface used to define ActionEvent
  31811. */
  31812. export interface IActionEvent {
  31813. /** The mesh or sprite that triggered the action */
  31814. source: any;
  31815. /** The X mouse cursor position at the time of the event */
  31816. pointerX: number;
  31817. /** The Y mouse cursor position at the time of the event */
  31818. pointerY: number;
  31819. /** The mesh that is currently pointed at (can be null) */
  31820. meshUnderPointer: Nullable<AbstractMesh>;
  31821. /** the original (browser) event that triggered the ActionEvent */
  31822. sourceEvent?: any;
  31823. /** additional data for the event */
  31824. additionalData?: any;
  31825. }
  31826. /**
  31827. * ActionEvent is the event being sent when an action is triggered.
  31828. */
  31829. export class ActionEvent implements IActionEvent {
  31830. /** The mesh or sprite that triggered the action */
  31831. source: any;
  31832. /** The X mouse cursor position at the time of the event */
  31833. pointerX: number;
  31834. /** The Y mouse cursor position at the time of the event */
  31835. pointerY: number;
  31836. /** The mesh that is currently pointed at (can be null) */
  31837. meshUnderPointer: Nullable<AbstractMesh>;
  31838. /** the original (browser) event that triggered the ActionEvent */
  31839. sourceEvent?: any;
  31840. /** additional data for the event */
  31841. additionalData?: any;
  31842. /**
  31843. * Creates a new ActionEvent
  31844. * @param source The mesh or sprite that triggered the action
  31845. * @param pointerX The X mouse cursor position at the time of the event
  31846. * @param pointerY The Y mouse cursor position at the time of the event
  31847. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31848. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31849. * @param additionalData additional data for the event
  31850. */
  31851. constructor(
  31852. /** The mesh or sprite that triggered the action */
  31853. source: any,
  31854. /** The X mouse cursor position at the time of the event */
  31855. pointerX: number,
  31856. /** The Y mouse cursor position at the time of the event */
  31857. pointerY: number,
  31858. /** The mesh that is currently pointed at (can be null) */
  31859. meshUnderPointer: Nullable<AbstractMesh>,
  31860. /** the original (browser) event that triggered the ActionEvent */
  31861. sourceEvent?: any,
  31862. /** additional data for the event */
  31863. additionalData?: any);
  31864. /**
  31865. * Helper function to auto-create an ActionEvent from a source mesh.
  31866. * @param source The source mesh that triggered the event
  31867. * @param evt The original (browser) event
  31868. * @param additionalData additional data for the event
  31869. * @returns the new ActionEvent
  31870. */
  31871. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31872. /**
  31873. * Helper function to auto-create an ActionEvent from a source sprite
  31874. * @param source The source sprite that triggered the event
  31875. * @param scene Scene associated with the sprite
  31876. * @param evt The original (browser) event
  31877. * @param additionalData additional data for the event
  31878. * @returns the new ActionEvent
  31879. */
  31880. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31881. /**
  31882. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31883. * @param scene the scene where the event occurred
  31884. * @param evt The original (browser) event
  31885. * @returns the new ActionEvent
  31886. */
  31887. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31888. /**
  31889. * Helper function to auto-create an ActionEvent from a primitive
  31890. * @param prim defines the target primitive
  31891. * @param pointerPos defines the pointer position
  31892. * @param evt The original (browser) event
  31893. * @param additionalData additional data for the event
  31894. * @returns the new ActionEvent
  31895. */
  31896. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31897. }
  31898. }
  31899. declare module BABYLON {
  31900. /**
  31901. * Abstract class used to decouple action Manager from scene and meshes.
  31902. * Do not instantiate.
  31903. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31904. */
  31905. export abstract class AbstractActionManager implements IDisposable {
  31906. /** Gets the list of active triggers */
  31907. static Triggers: {
  31908. [key: string]: number;
  31909. };
  31910. /** Gets the cursor to use when hovering items */
  31911. hoverCursor: string;
  31912. /** Gets the list of actions */
  31913. actions: IAction[];
  31914. /**
  31915. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31916. */
  31917. isRecursive: boolean;
  31918. /**
  31919. * Releases all associated resources
  31920. */
  31921. abstract dispose(): void;
  31922. /**
  31923. * Does this action manager has pointer triggers
  31924. */
  31925. abstract get hasPointerTriggers(): boolean;
  31926. /**
  31927. * Does this action manager has pick triggers
  31928. */
  31929. abstract get hasPickTriggers(): boolean;
  31930. /**
  31931. * Process a specific trigger
  31932. * @param trigger defines the trigger to process
  31933. * @param evt defines the event details to be processed
  31934. */
  31935. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31936. /**
  31937. * Does this action manager handles actions of any of the given triggers
  31938. * @param triggers defines the triggers to be tested
  31939. * @return a boolean indicating whether one (or more) of the triggers is handled
  31940. */
  31941. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31942. /**
  31943. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31944. * speed.
  31945. * @param triggerA defines the trigger to be tested
  31946. * @param triggerB defines the trigger to be tested
  31947. * @return a boolean indicating whether one (or more) of the triggers is handled
  31948. */
  31949. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31950. /**
  31951. * Does this action manager handles actions of a given trigger
  31952. * @param trigger defines the trigger to be tested
  31953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31954. * @return whether the trigger is handled
  31955. */
  31956. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31957. /**
  31958. * Serialize this manager to a JSON object
  31959. * @param name defines the property name to store this manager
  31960. * @returns a JSON representation of this manager
  31961. */
  31962. abstract serialize(name: string): any;
  31963. /**
  31964. * Registers an action to this action manager
  31965. * @param action defines the action to be registered
  31966. * @return the action amended (prepared) after registration
  31967. */
  31968. abstract registerAction(action: IAction): Nullable<IAction>;
  31969. /**
  31970. * Unregisters an action to this action manager
  31971. * @param action defines the action to be unregistered
  31972. * @return a boolean indicating whether the action has been unregistered
  31973. */
  31974. abstract unregisterAction(action: IAction): Boolean;
  31975. /**
  31976. * Does exist one action manager with at least one trigger
  31977. **/
  31978. static get HasTriggers(): boolean;
  31979. /**
  31980. * Does exist one action manager with at least one pick trigger
  31981. **/
  31982. static get HasPickTriggers(): boolean;
  31983. /**
  31984. * Does exist one action manager that handles actions of a given trigger
  31985. * @param trigger defines the trigger to be tested
  31986. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31987. **/
  31988. static HasSpecificTrigger(trigger: number): boolean;
  31989. }
  31990. }
  31991. declare module BABYLON {
  31992. /**
  31993. * Defines how a node can be built from a string name.
  31994. */
  31995. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31996. /**
  31997. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31998. */
  31999. export class Node implements IBehaviorAware<Node> {
  32000. /** @hidden */
  32001. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32002. private static _NodeConstructors;
  32003. /**
  32004. * Add a new node constructor
  32005. * @param type defines the type name of the node to construct
  32006. * @param constructorFunc defines the constructor function
  32007. */
  32008. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32009. /**
  32010. * Returns a node constructor based on type name
  32011. * @param type defines the type name
  32012. * @param name defines the new node name
  32013. * @param scene defines the hosting scene
  32014. * @param options defines optional options to transmit to constructors
  32015. * @returns the new constructor or null
  32016. */
  32017. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32018. /**
  32019. * Gets or sets the name of the node
  32020. */
  32021. name: string;
  32022. /**
  32023. * Gets or sets the id of the node
  32024. */
  32025. id: string;
  32026. /**
  32027. * Gets or sets the unique id of the node
  32028. */
  32029. uniqueId: number;
  32030. /**
  32031. * Gets or sets a string used to store user defined state for the node
  32032. */
  32033. state: string;
  32034. /**
  32035. * Gets or sets an object used to store user defined information for the node
  32036. */
  32037. metadata: any;
  32038. /**
  32039. * For internal use only. Please do not use.
  32040. */
  32041. reservedDataStore: any;
  32042. /**
  32043. * List of inspectable custom properties (used by the Inspector)
  32044. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32045. */
  32046. inspectableCustomProperties: IInspectable[];
  32047. private _doNotSerialize;
  32048. /**
  32049. * Gets or sets a boolean used to define if the node must be serialized
  32050. */
  32051. get doNotSerialize(): boolean;
  32052. set doNotSerialize(value: boolean);
  32053. /** @hidden */
  32054. _isDisposed: boolean;
  32055. /**
  32056. * Gets a list of Animations associated with the node
  32057. */
  32058. animations: Animation[];
  32059. protected _ranges: {
  32060. [name: string]: Nullable<AnimationRange>;
  32061. };
  32062. /**
  32063. * Callback raised when the node is ready to be used
  32064. */
  32065. onReady: Nullable<(node: Node) => void>;
  32066. private _isEnabled;
  32067. private _isParentEnabled;
  32068. private _isReady;
  32069. /** @hidden */
  32070. _currentRenderId: number;
  32071. private _parentUpdateId;
  32072. /** @hidden */
  32073. _childUpdateId: number;
  32074. /** @hidden */
  32075. _waitingParentId: Nullable<string>;
  32076. /** @hidden */
  32077. _scene: Scene;
  32078. /** @hidden */
  32079. _cache: any;
  32080. private _parentNode;
  32081. private _children;
  32082. /** @hidden */
  32083. _worldMatrix: Matrix;
  32084. /** @hidden */
  32085. _worldMatrixDeterminant: number;
  32086. /** @hidden */
  32087. _worldMatrixDeterminantIsDirty: boolean;
  32088. /** @hidden */
  32089. private _sceneRootNodesIndex;
  32090. /**
  32091. * Gets a boolean indicating if the node has been disposed
  32092. * @returns true if the node was disposed
  32093. */
  32094. isDisposed(): boolean;
  32095. /**
  32096. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32097. * @see https://doc.babylonjs.com/how_to/parenting
  32098. */
  32099. set parent(parent: Nullable<Node>);
  32100. get parent(): Nullable<Node>;
  32101. /** @hidden */
  32102. _addToSceneRootNodes(): void;
  32103. /** @hidden */
  32104. _removeFromSceneRootNodes(): void;
  32105. private _animationPropertiesOverride;
  32106. /**
  32107. * Gets or sets the animation properties override
  32108. */
  32109. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32110. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32111. /**
  32112. * Gets a string idenfifying the name of the class
  32113. * @returns "Node" string
  32114. */
  32115. getClassName(): string;
  32116. /** @hidden */
  32117. readonly _isNode: boolean;
  32118. /**
  32119. * An event triggered when the mesh is disposed
  32120. */
  32121. onDisposeObservable: Observable<Node>;
  32122. private _onDisposeObserver;
  32123. /**
  32124. * Sets a callback that will be raised when the node will be disposed
  32125. */
  32126. set onDispose(callback: () => void);
  32127. /**
  32128. * Creates a new Node
  32129. * @param name the name and id to be given to this node
  32130. * @param scene the scene this node will be added to
  32131. */
  32132. constructor(name: string, scene?: Nullable<Scene>);
  32133. /**
  32134. * Gets the scene of the node
  32135. * @returns a scene
  32136. */
  32137. getScene(): Scene;
  32138. /**
  32139. * Gets the engine of the node
  32140. * @returns a Engine
  32141. */
  32142. getEngine(): Engine;
  32143. private _behaviors;
  32144. /**
  32145. * Attach a behavior to the node
  32146. * @see https://doc.babylonjs.com/features/behaviour
  32147. * @param behavior defines the behavior to attach
  32148. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32149. * @returns the current Node
  32150. */
  32151. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32152. /**
  32153. * Remove an attached behavior
  32154. * @see https://doc.babylonjs.com/features/behaviour
  32155. * @param behavior defines the behavior to attach
  32156. * @returns the current Node
  32157. */
  32158. removeBehavior(behavior: Behavior<Node>): Node;
  32159. /**
  32160. * Gets the list of attached behaviors
  32161. * @see https://doc.babylonjs.com/features/behaviour
  32162. */
  32163. get behaviors(): Behavior<Node>[];
  32164. /**
  32165. * Gets an attached behavior by name
  32166. * @param name defines the name of the behavior to look for
  32167. * @see https://doc.babylonjs.com/features/behaviour
  32168. * @returns null if behavior was not found else the requested behavior
  32169. */
  32170. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32171. /**
  32172. * Returns the latest update of the World matrix
  32173. * @returns a Matrix
  32174. */
  32175. getWorldMatrix(): Matrix;
  32176. /** @hidden */
  32177. _getWorldMatrixDeterminant(): number;
  32178. /**
  32179. * Returns directly the latest state of the mesh World matrix.
  32180. * A Matrix is returned.
  32181. */
  32182. get worldMatrixFromCache(): Matrix;
  32183. /** @hidden */
  32184. _initCache(): void;
  32185. /** @hidden */
  32186. updateCache(force?: boolean): void;
  32187. /** @hidden */
  32188. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32189. /** @hidden */
  32190. _updateCache(ignoreParentClass?: boolean): void;
  32191. /** @hidden */
  32192. _isSynchronized(): boolean;
  32193. /** @hidden */
  32194. _markSyncedWithParent(): void;
  32195. /** @hidden */
  32196. isSynchronizedWithParent(): boolean;
  32197. /** @hidden */
  32198. isSynchronized(): boolean;
  32199. /**
  32200. * Is this node ready to be used/rendered
  32201. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32202. * @return true if the node is ready
  32203. */
  32204. isReady(completeCheck?: boolean): boolean;
  32205. /**
  32206. * Is this node enabled?
  32207. * 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
  32208. * @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
  32209. * @return whether this node (and its parent) is enabled
  32210. */
  32211. isEnabled(checkAncestors?: boolean): boolean;
  32212. /** @hidden */
  32213. protected _syncParentEnabledState(): void;
  32214. /**
  32215. * Set the enabled state of this node
  32216. * @param value defines the new enabled state
  32217. */
  32218. setEnabled(value: boolean): void;
  32219. /**
  32220. * Is this node a descendant of the given node?
  32221. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32222. * @param ancestor defines the parent node to inspect
  32223. * @returns a boolean indicating if this node is a descendant of the given node
  32224. */
  32225. isDescendantOf(ancestor: Node): boolean;
  32226. /** @hidden */
  32227. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32228. /**
  32229. * Will return all nodes that have this node as ascendant
  32230. * @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
  32231. * @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
  32232. * @return all children nodes of all types
  32233. */
  32234. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32235. /**
  32236. * Get all child-meshes of this node
  32237. * @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)
  32238. * @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
  32239. * @returns an array of AbstractMesh
  32240. */
  32241. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32242. /**
  32243. * Get all direct children of this node
  32244. * @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
  32245. * @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)
  32246. * @returns an array of Node
  32247. */
  32248. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32249. /** @hidden */
  32250. _setReady(state: boolean): void;
  32251. /**
  32252. * Get an animation by name
  32253. * @param name defines the name of the animation to look for
  32254. * @returns null if not found else the requested animation
  32255. */
  32256. getAnimationByName(name: string): Nullable<Animation>;
  32257. /**
  32258. * Creates an animation range for this node
  32259. * @param name defines the name of the range
  32260. * @param from defines the starting key
  32261. * @param to defines the end key
  32262. */
  32263. createAnimationRange(name: string, from: number, to: number): void;
  32264. /**
  32265. * Delete a specific animation range
  32266. * @param name defines the name of the range to delete
  32267. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32268. */
  32269. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32270. /**
  32271. * Get an animation range by name
  32272. * @param name defines the name of the animation range to look for
  32273. * @returns null if not found else the requested animation range
  32274. */
  32275. getAnimationRange(name: string): Nullable<AnimationRange>;
  32276. /**
  32277. * Gets the list of all animation ranges defined on this node
  32278. * @returns an array
  32279. */
  32280. getAnimationRanges(): Nullable<AnimationRange>[];
  32281. /**
  32282. * Will start the animation sequence
  32283. * @param name defines the range frames for animation sequence
  32284. * @param loop defines if the animation should loop (false by default)
  32285. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32286. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32287. * @returns the object created for this animation. If range does not exist, it will return null
  32288. */
  32289. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32290. /**
  32291. * Serialize animation ranges into a JSON compatible object
  32292. * @returns serialization object
  32293. */
  32294. serializeAnimationRanges(): any;
  32295. /**
  32296. * Computes the world matrix of the node
  32297. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32298. * @returns the world matrix
  32299. */
  32300. computeWorldMatrix(force?: boolean): Matrix;
  32301. /**
  32302. * Releases resources associated with this node.
  32303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32305. */
  32306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32307. /**
  32308. * Parse animation range data from a serialization object and store them into a given node
  32309. * @param node defines where to store the animation ranges
  32310. * @param parsedNode defines the serialization object to read data from
  32311. * @param scene defines the hosting scene
  32312. */
  32313. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32314. /**
  32315. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32316. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32317. * @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
  32318. * @returns the new bounding vectors
  32319. */
  32320. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32321. min: Vector3;
  32322. max: Vector3;
  32323. };
  32324. }
  32325. }
  32326. declare module BABYLON {
  32327. /**
  32328. * @hidden
  32329. */
  32330. export class _IAnimationState {
  32331. key: number;
  32332. repeatCount: number;
  32333. workValue?: any;
  32334. loopMode?: number;
  32335. offsetValue?: any;
  32336. highLimitValue?: any;
  32337. }
  32338. /**
  32339. * Class used to store any kind of animation
  32340. */
  32341. export class Animation {
  32342. /**Name of the animation */
  32343. name: string;
  32344. /**Property to animate */
  32345. targetProperty: string;
  32346. /**The frames per second of the animation */
  32347. framePerSecond: number;
  32348. /**The data type of the animation */
  32349. dataType: number;
  32350. /**The loop mode of the animation */
  32351. loopMode?: number | undefined;
  32352. /**Specifies if blending should be enabled */
  32353. enableBlending?: boolean | undefined;
  32354. /**
  32355. * Use matrix interpolation instead of using direct key value when animating matrices
  32356. */
  32357. static AllowMatricesInterpolation: boolean;
  32358. /**
  32359. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32360. */
  32361. static AllowMatrixDecomposeForInterpolation: boolean;
  32362. /** Define the Url to load snippets */
  32363. static SnippetUrl: string;
  32364. /** Snippet ID if the animation was created from the snippet server */
  32365. snippetId: string;
  32366. /**
  32367. * Stores the key frames of the animation
  32368. */
  32369. private _keys;
  32370. /**
  32371. * Stores the easing function of the animation
  32372. */
  32373. private _easingFunction;
  32374. /**
  32375. * @hidden Internal use only
  32376. */
  32377. _runtimeAnimations: RuntimeAnimation[];
  32378. /**
  32379. * The set of event that will be linked to this animation
  32380. */
  32381. private _events;
  32382. /**
  32383. * Stores an array of target property paths
  32384. */
  32385. targetPropertyPath: string[];
  32386. /**
  32387. * Stores the blending speed of the animation
  32388. */
  32389. blendingSpeed: number;
  32390. /**
  32391. * Stores the animation ranges for the animation
  32392. */
  32393. private _ranges;
  32394. /**
  32395. * @hidden Internal use
  32396. */
  32397. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32398. /**
  32399. * Sets up an animation
  32400. * @param property The property to animate
  32401. * @param animationType The animation type to apply
  32402. * @param framePerSecond The frames per second of the animation
  32403. * @param easingFunction The easing function used in the animation
  32404. * @returns The created animation
  32405. */
  32406. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32407. /**
  32408. * Create and start an animation on a node
  32409. * @param name defines the name of the global animation that will be run on all nodes
  32410. * @param node defines the root node where the animation will take place
  32411. * @param targetProperty defines property to animate
  32412. * @param framePerSecond defines the number of frame per second yo use
  32413. * @param totalFrame defines the number of frames in total
  32414. * @param from defines the initial value
  32415. * @param to defines the final value
  32416. * @param loopMode defines which loop mode you want to use (off by default)
  32417. * @param easingFunction defines the easing function to use (linear by default)
  32418. * @param onAnimationEnd defines the callback to call when animation end
  32419. * @returns the animatable created for this animation
  32420. */
  32421. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32422. /**
  32423. * Create and start an animation on a node and its descendants
  32424. * @param name defines the name of the global animation that will be run on all nodes
  32425. * @param node defines the root node where the animation will take place
  32426. * @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
  32427. * @param targetProperty defines property to animate
  32428. * @param framePerSecond defines the number of frame per second to use
  32429. * @param totalFrame defines the number of frames in total
  32430. * @param from defines the initial value
  32431. * @param to defines the final value
  32432. * @param loopMode defines which loop mode you want to use (off by default)
  32433. * @param easingFunction defines the easing function to use (linear by default)
  32434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32435. * @returns the list of animatables created for all nodes
  32436. * @example https://www.babylonjs-playground.com/#MH0VLI
  32437. */
  32438. 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[]>;
  32439. /**
  32440. * Creates a new animation, merges it with the existing animations and starts it
  32441. * @param name Name of the animation
  32442. * @param node Node which contains the scene that begins the animations
  32443. * @param targetProperty Specifies which property to animate
  32444. * @param framePerSecond The frames per second of the animation
  32445. * @param totalFrame The total number of frames
  32446. * @param from The frame at the beginning of the animation
  32447. * @param to The frame at the end of the animation
  32448. * @param loopMode Specifies the loop mode of the animation
  32449. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32450. * @param onAnimationEnd Callback to run once the animation is complete
  32451. * @returns Nullable animation
  32452. */
  32453. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32454. /**
  32455. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32456. * @param sourceAnimation defines the Animation containing keyframes to convert
  32457. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32458. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32459. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32460. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32461. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32462. */
  32463. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32464. /**
  32465. * Transition property of an host to the target Value
  32466. * @param property The property to transition
  32467. * @param targetValue The target Value of the property
  32468. * @param host The object where the property to animate belongs
  32469. * @param scene Scene used to run the animation
  32470. * @param frameRate Framerate (in frame/s) to use
  32471. * @param transition The transition type we want to use
  32472. * @param duration The duration of the animation, in milliseconds
  32473. * @param onAnimationEnd Callback trigger at the end of the animation
  32474. * @returns Nullable animation
  32475. */
  32476. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32477. /**
  32478. * Return the array of runtime animations currently using this animation
  32479. */
  32480. get runtimeAnimations(): RuntimeAnimation[];
  32481. /**
  32482. * Specifies if any of the runtime animations are currently running
  32483. */
  32484. get hasRunningRuntimeAnimations(): boolean;
  32485. /**
  32486. * Initializes the animation
  32487. * @param name Name of the animation
  32488. * @param targetProperty Property to animate
  32489. * @param framePerSecond The frames per second of the animation
  32490. * @param dataType The data type of the animation
  32491. * @param loopMode The loop mode of the animation
  32492. * @param enableBlending Specifies if blending should be enabled
  32493. */
  32494. constructor(
  32495. /**Name of the animation */
  32496. name: string,
  32497. /**Property to animate */
  32498. targetProperty: string,
  32499. /**The frames per second of the animation */
  32500. framePerSecond: number,
  32501. /**The data type of the animation */
  32502. dataType: number,
  32503. /**The loop mode of the animation */
  32504. loopMode?: number | undefined,
  32505. /**Specifies if blending should be enabled */
  32506. enableBlending?: boolean | undefined);
  32507. /**
  32508. * Converts the animation to a string
  32509. * @param fullDetails support for multiple levels of logging within scene loading
  32510. * @returns String form of the animation
  32511. */
  32512. toString(fullDetails?: boolean): string;
  32513. /**
  32514. * Add an event to this animation
  32515. * @param event Event to add
  32516. */
  32517. addEvent(event: AnimationEvent): void;
  32518. /**
  32519. * Remove all events found at the given frame
  32520. * @param frame The frame to remove events from
  32521. */
  32522. removeEvents(frame: number): void;
  32523. /**
  32524. * Retrieves all the events from the animation
  32525. * @returns Events from the animation
  32526. */
  32527. getEvents(): AnimationEvent[];
  32528. /**
  32529. * Creates an animation range
  32530. * @param name Name of the animation range
  32531. * @param from Starting frame of the animation range
  32532. * @param to Ending frame of the animation
  32533. */
  32534. createRange(name: string, from: number, to: number): void;
  32535. /**
  32536. * Deletes an animation range by name
  32537. * @param name Name of the animation range to delete
  32538. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32539. */
  32540. deleteRange(name: string, deleteFrames?: boolean): void;
  32541. /**
  32542. * Gets the animation range by name, or null if not defined
  32543. * @param name Name of the animation range
  32544. * @returns Nullable animation range
  32545. */
  32546. getRange(name: string): Nullable<AnimationRange>;
  32547. /**
  32548. * Gets the key frames from the animation
  32549. * @returns The key frames of the animation
  32550. */
  32551. getKeys(): Array<IAnimationKey>;
  32552. /**
  32553. * Gets the highest frame rate of the animation
  32554. * @returns Highest frame rate of the animation
  32555. */
  32556. getHighestFrame(): number;
  32557. /**
  32558. * Gets the easing function of the animation
  32559. * @returns Easing function of the animation
  32560. */
  32561. getEasingFunction(): IEasingFunction;
  32562. /**
  32563. * Sets the easing function of the animation
  32564. * @param easingFunction A custom mathematical formula for animation
  32565. */
  32566. setEasingFunction(easingFunction: EasingFunction): void;
  32567. /**
  32568. * Interpolates a scalar linearly
  32569. * @param startValue Start value of the animation curve
  32570. * @param endValue End value of the animation curve
  32571. * @param gradient Scalar amount to interpolate
  32572. * @returns Interpolated scalar value
  32573. */
  32574. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32575. /**
  32576. * Interpolates a scalar cubically
  32577. * @param startValue Start value of the animation curve
  32578. * @param outTangent End tangent of the animation
  32579. * @param endValue End value of the animation curve
  32580. * @param inTangent Start tangent of the animation curve
  32581. * @param gradient Scalar amount to interpolate
  32582. * @returns Interpolated scalar value
  32583. */
  32584. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32585. /**
  32586. * Interpolates a quaternion using a spherical linear interpolation
  32587. * @param startValue Start value of the animation curve
  32588. * @param endValue End value of the animation curve
  32589. * @param gradient Scalar amount to interpolate
  32590. * @returns Interpolated quaternion value
  32591. */
  32592. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32593. /**
  32594. * Interpolates a quaternion cubically
  32595. * @param startValue Start value of the animation curve
  32596. * @param outTangent End tangent of the animation curve
  32597. * @param endValue End value of the animation curve
  32598. * @param inTangent Start tangent of the animation curve
  32599. * @param gradient Scalar amount to interpolate
  32600. * @returns Interpolated quaternion value
  32601. */
  32602. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32603. /**
  32604. * Interpolates a Vector3 linearl
  32605. * @param startValue Start value of the animation curve
  32606. * @param endValue End value of the animation curve
  32607. * @param gradient Scalar amount to interpolate
  32608. * @returns Interpolated scalar value
  32609. */
  32610. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32611. /**
  32612. * Interpolates a Vector3 cubically
  32613. * @param startValue Start value of the animation curve
  32614. * @param outTangent End tangent of the animation
  32615. * @param endValue End value of the animation curve
  32616. * @param inTangent Start tangent of the animation curve
  32617. * @param gradient Scalar amount to interpolate
  32618. * @returns InterpolatedVector3 value
  32619. */
  32620. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32621. /**
  32622. * Interpolates a Vector2 linearly
  32623. * @param startValue Start value of the animation curve
  32624. * @param endValue End value of the animation curve
  32625. * @param gradient Scalar amount to interpolate
  32626. * @returns Interpolated Vector2 value
  32627. */
  32628. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32629. /**
  32630. * Interpolates a Vector2 cubically
  32631. * @param startValue Start value of the animation curve
  32632. * @param outTangent End tangent of the animation
  32633. * @param endValue End value of the animation curve
  32634. * @param inTangent Start tangent of the animation curve
  32635. * @param gradient Scalar amount to interpolate
  32636. * @returns Interpolated Vector2 value
  32637. */
  32638. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32639. /**
  32640. * Interpolates a size linearly
  32641. * @param startValue Start value of the animation curve
  32642. * @param endValue End value of the animation curve
  32643. * @param gradient Scalar amount to interpolate
  32644. * @returns Interpolated Size value
  32645. */
  32646. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32647. /**
  32648. * Interpolates a Color3 linearly
  32649. * @param startValue Start value of the animation curve
  32650. * @param endValue End value of the animation curve
  32651. * @param gradient Scalar amount to interpolate
  32652. * @returns Interpolated Color3 value
  32653. */
  32654. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32655. /**
  32656. * Interpolates a Color4 linearly
  32657. * @param startValue Start value of the animation curve
  32658. * @param endValue End value of the animation curve
  32659. * @param gradient Scalar amount to interpolate
  32660. * @returns Interpolated Color3 value
  32661. */
  32662. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32663. /**
  32664. * @hidden Internal use only
  32665. */
  32666. _getKeyValue(value: any): any;
  32667. /**
  32668. * @hidden Internal use only
  32669. */
  32670. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32671. /**
  32672. * Defines the function to use to interpolate matrices
  32673. * @param startValue defines the start matrix
  32674. * @param endValue defines the end matrix
  32675. * @param gradient defines the gradient between both matrices
  32676. * @param result defines an optional target matrix where to store the interpolation
  32677. * @returns the interpolated matrix
  32678. */
  32679. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32680. /**
  32681. * Makes a copy of the animation
  32682. * @returns Cloned animation
  32683. */
  32684. clone(): Animation;
  32685. /**
  32686. * Sets the key frames of the animation
  32687. * @param values The animation key frames to set
  32688. */
  32689. setKeys(values: Array<IAnimationKey>): void;
  32690. /**
  32691. * Serializes the animation to an object
  32692. * @returns Serialized object
  32693. */
  32694. serialize(): any;
  32695. /**
  32696. * Float animation type
  32697. */
  32698. static readonly ANIMATIONTYPE_FLOAT: number;
  32699. /**
  32700. * Vector3 animation type
  32701. */
  32702. static readonly ANIMATIONTYPE_VECTOR3: number;
  32703. /**
  32704. * Quaternion animation type
  32705. */
  32706. static readonly ANIMATIONTYPE_QUATERNION: number;
  32707. /**
  32708. * Matrix animation type
  32709. */
  32710. static readonly ANIMATIONTYPE_MATRIX: number;
  32711. /**
  32712. * Color3 animation type
  32713. */
  32714. static readonly ANIMATIONTYPE_COLOR3: number;
  32715. /**
  32716. * Color3 animation type
  32717. */
  32718. static readonly ANIMATIONTYPE_COLOR4: number;
  32719. /**
  32720. * Vector2 animation type
  32721. */
  32722. static readonly ANIMATIONTYPE_VECTOR2: number;
  32723. /**
  32724. * Size animation type
  32725. */
  32726. static readonly ANIMATIONTYPE_SIZE: number;
  32727. /**
  32728. * Relative Loop Mode
  32729. */
  32730. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32731. /**
  32732. * Cycle Loop Mode
  32733. */
  32734. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32735. /**
  32736. * Constant Loop Mode
  32737. */
  32738. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32739. /** @hidden */
  32740. static _UniversalLerp(left: any, right: any, amount: number): any;
  32741. /**
  32742. * Parses an animation object and creates an animation
  32743. * @param parsedAnimation Parsed animation object
  32744. * @returns Animation object
  32745. */
  32746. static Parse(parsedAnimation: any): Animation;
  32747. /**
  32748. * Appends the serialized animations from the source animations
  32749. * @param source Source containing the animations
  32750. * @param destination Target to store the animations
  32751. */
  32752. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32753. /**
  32754. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32755. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32756. * @param url defines the url to load from
  32757. * @returns a promise that will resolve to the new animation or an array of animations
  32758. */
  32759. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32760. /**
  32761. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32762. * @param snippetId defines the snippet to load
  32763. * @returns a promise that will resolve to the new animation or a new array of animations
  32764. */
  32765. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32766. }
  32767. }
  32768. declare module BABYLON {
  32769. /**
  32770. * Interface containing an array of animations
  32771. */
  32772. export interface IAnimatable {
  32773. /**
  32774. * Array of animations
  32775. */
  32776. animations: Nullable<Array<Animation>>;
  32777. }
  32778. }
  32779. declare module BABYLON {
  32780. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32781. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32782. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32783. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32784. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32785. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32786. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32787. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32788. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32789. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32790. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32791. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32792. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32793. /**
  32794. * Decorator used to define property that can be serialized as reference to a camera
  32795. * @param sourceName defines the name of the property to decorate
  32796. */
  32797. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32798. /**
  32799. * Class used to help serialization objects
  32800. */
  32801. export class SerializationHelper {
  32802. /** @hidden */
  32803. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32804. /** @hidden */
  32805. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32806. /** @hidden */
  32807. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32808. /** @hidden */
  32809. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32810. /**
  32811. * Appends the serialized animations from the source animations
  32812. * @param source Source containing the animations
  32813. * @param destination Target to store the animations
  32814. */
  32815. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32816. /**
  32817. * Static function used to serialized a specific entity
  32818. * @param entity defines the entity to serialize
  32819. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32820. * @returns a JSON compatible object representing the serialization of the entity
  32821. */
  32822. static Serialize<T>(entity: T, serializationObject?: any): any;
  32823. /**
  32824. * Creates a new entity from a serialization data object
  32825. * @param creationFunction defines a function used to instanciated the new entity
  32826. * @param source defines the source serialization data
  32827. * @param scene defines the hosting scene
  32828. * @param rootUrl defines the root url for resources
  32829. * @returns a new entity
  32830. */
  32831. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32832. /**
  32833. * Clones an object
  32834. * @param creationFunction defines the function used to instanciate the new object
  32835. * @param source defines the source object
  32836. * @returns the cloned object
  32837. */
  32838. static Clone<T>(creationFunction: () => T, source: T): T;
  32839. /**
  32840. * Instanciates a new object based on a source one (some data will be shared between both object)
  32841. * @param creationFunction defines the function used to instanciate the new object
  32842. * @param source defines the source object
  32843. * @returns the new object
  32844. */
  32845. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32846. }
  32847. }
  32848. declare module BABYLON {
  32849. /**
  32850. * Base class of all the textures in babylon.
  32851. * It groups all the common properties the materials, post process, lights... might need
  32852. * in order to make a correct use of the texture.
  32853. */
  32854. export class BaseTexture implements IAnimatable {
  32855. /**
  32856. * Default anisotropic filtering level for the application.
  32857. * It is set to 4 as a good tradeoff between perf and quality.
  32858. */
  32859. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32860. /**
  32861. * Gets or sets the unique id of the texture
  32862. */
  32863. uniqueId: number;
  32864. /**
  32865. * Define the name of the texture.
  32866. */
  32867. name: string;
  32868. /**
  32869. * Gets or sets an object used to store user defined information.
  32870. */
  32871. metadata: any;
  32872. /**
  32873. * For internal use only. Please do not use.
  32874. */
  32875. reservedDataStore: any;
  32876. private _hasAlpha;
  32877. /**
  32878. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32879. */
  32880. set hasAlpha(value: boolean);
  32881. get hasAlpha(): boolean;
  32882. /**
  32883. * Defines if the alpha value should be determined via the rgb values.
  32884. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32885. */
  32886. getAlphaFromRGB: boolean;
  32887. /**
  32888. * Intensity or strength of the texture.
  32889. * It is commonly used by materials to fine tune the intensity of the texture
  32890. */
  32891. level: number;
  32892. /**
  32893. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32894. * This is part of the texture as textures usually maps to one uv set.
  32895. */
  32896. coordinatesIndex: number;
  32897. private _coordinatesMode;
  32898. /**
  32899. * How a texture is mapped.
  32900. *
  32901. * | Value | Type | Description |
  32902. * | ----- | ----------------------------------- | ----------- |
  32903. * | 0 | EXPLICIT_MODE | |
  32904. * | 1 | SPHERICAL_MODE | |
  32905. * | 2 | PLANAR_MODE | |
  32906. * | 3 | CUBIC_MODE | |
  32907. * | 4 | PROJECTION_MODE | |
  32908. * | 5 | SKYBOX_MODE | |
  32909. * | 6 | INVCUBIC_MODE | |
  32910. * | 7 | EQUIRECTANGULAR_MODE | |
  32911. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32912. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32913. */
  32914. set coordinatesMode(value: number);
  32915. get coordinatesMode(): number;
  32916. /**
  32917. * | Value | Type | Description |
  32918. * | ----- | ------------------ | ----------- |
  32919. * | 0 | CLAMP_ADDRESSMODE | |
  32920. * | 1 | WRAP_ADDRESSMODE | |
  32921. * | 2 | MIRROR_ADDRESSMODE | |
  32922. */
  32923. wrapU: number;
  32924. /**
  32925. * | Value | Type | Description |
  32926. * | ----- | ------------------ | ----------- |
  32927. * | 0 | CLAMP_ADDRESSMODE | |
  32928. * | 1 | WRAP_ADDRESSMODE | |
  32929. * | 2 | MIRROR_ADDRESSMODE | |
  32930. */
  32931. wrapV: number;
  32932. /**
  32933. * | Value | Type | Description |
  32934. * | ----- | ------------------ | ----------- |
  32935. * | 0 | CLAMP_ADDRESSMODE | |
  32936. * | 1 | WRAP_ADDRESSMODE | |
  32937. * | 2 | MIRROR_ADDRESSMODE | |
  32938. */
  32939. wrapR: number;
  32940. /**
  32941. * With compliant hardware and browser (supporting anisotropic filtering)
  32942. * this defines the level of anisotropic filtering in the texture.
  32943. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32944. */
  32945. anisotropicFilteringLevel: number;
  32946. /**
  32947. * Define if the texture is a cube texture or if false a 2d texture.
  32948. */
  32949. get isCube(): boolean;
  32950. set isCube(value: boolean);
  32951. /**
  32952. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32953. */
  32954. get is3D(): boolean;
  32955. set is3D(value: boolean);
  32956. /**
  32957. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32958. */
  32959. get is2DArray(): boolean;
  32960. set is2DArray(value: boolean);
  32961. /**
  32962. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32963. * HDR texture are usually stored in linear space.
  32964. * This only impacts the PBR and Background materials
  32965. */
  32966. gammaSpace: boolean;
  32967. /**
  32968. * Gets or sets whether or not the texture contains RGBD data.
  32969. */
  32970. get isRGBD(): boolean;
  32971. set isRGBD(value: boolean);
  32972. /**
  32973. * Is Z inverted in the texture (useful in a cube texture).
  32974. */
  32975. invertZ: boolean;
  32976. /**
  32977. * Are mip maps generated for this texture or not.
  32978. */
  32979. get noMipmap(): boolean;
  32980. /**
  32981. * @hidden
  32982. */
  32983. lodLevelInAlpha: boolean;
  32984. /**
  32985. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32986. */
  32987. get lodGenerationOffset(): number;
  32988. set lodGenerationOffset(value: number);
  32989. /**
  32990. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32991. */
  32992. get lodGenerationScale(): number;
  32993. set lodGenerationScale(value: number);
  32994. /**
  32995. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32996. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32997. * average roughness values.
  32998. */
  32999. get linearSpecularLOD(): boolean;
  33000. set linearSpecularLOD(value: boolean);
  33001. /**
  33002. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33003. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33004. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33005. */
  33006. get irradianceTexture(): Nullable<BaseTexture>;
  33007. set irradianceTexture(value: Nullable<BaseTexture>);
  33008. /**
  33009. * Define if the texture is a render target.
  33010. */
  33011. isRenderTarget: boolean;
  33012. /**
  33013. * Define the unique id of the texture in the scene.
  33014. */
  33015. get uid(): string;
  33016. /** @hidden */
  33017. _prefiltered: boolean;
  33018. /**
  33019. * Return a string representation of the texture.
  33020. * @returns the texture as a string
  33021. */
  33022. toString(): string;
  33023. /**
  33024. * Get the class name of the texture.
  33025. * @returns "BaseTexture"
  33026. */
  33027. getClassName(): string;
  33028. /**
  33029. * Define the list of animation attached to the texture.
  33030. */
  33031. animations: Animation[];
  33032. /**
  33033. * An event triggered when the texture is disposed.
  33034. */
  33035. onDisposeObservable: Observable<BaseTexture>;
  33036. private _onDisposeObserver;
  33037. /**
  33038. * Callback triggered when the texture has been disposed.
  33039. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33040. */
  33041. set onDispose(callback: () => void);
  33042. /**
  33043. * Define the current state of the loading sequence when in delayed load mode.
  33044. */
  33045. delayLoadState: number;
  33046. private _scene;
  33047. private _engine;
  33048. /** @hidden */
  33049. _texture: Nullable<InternalTexture>;
  33050. private _uid;
  33051. /**
  33052. * Define if the texture is preventinga material to render or not.
  33053. * If not and the texture is not ready, the engine will use a default black texture instead.
  33054. */
  33055. get isBlocking(): boolean;
  33056. /**
  33057. * Instantiates a new BaseTexture.
  33058. * Base class of all the textures in babylon.
  33059. * It groups all the common properties the materials, post process, lights... might need
  33060. * in order to make a correct use of the texture.
  33061. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33062. */
  33063. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33064. /**
  33065. * Get the scene the texture belongs to.
  33066. * @returns the scene or null if undefined
  33067. */
  33068. getScene(): Nullable<Scene>;
  33069. /** @hidden */
  33070. protected _getEngine(): Nullable<ThinEngine>;
  33071. /**
  33072. * Get the texture transform matrix used to offset tile the texture for istance.
  33073. * @returns the transformation matrix
  33074. */
  33075. getTextureMatrix(): Matrix;
  33076. /**
  33077. * Get the texture reflection matrix used to rotate/transform the reflection.
  33078. * @returns the reflection matrix
  33079. */
  33080. getReflectionTextureMatrix(): Matrix;
  33081. /**
  33082. * Get the underlying lower level texture from Babylon.
  33083. * @returns the insternal texture
  33084. */
  33085. getInternalTexture(): Nullable<InternalTexture>;
  33086. /**
  33087. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33088. * @returns true if ready or not blocking
  33089. */
  33090. isReadyOrNotBlocking(): boolean;
  33091. /**
  33092. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33093. * @returns true if fully ready
  33094. */
  33095. isReady(): boolean;
  33096. private _cachedSize;
  33097. /**
  33098. * Get the size of the texture.
  33099. * @returns the texture size.
  33100. */
  33101. getSize(): ISize;
  33102. /**
  33103. * Get the base size of the texture.
  33104. * It can be different from the size if the texture has been resized for POT for instance
  33105. * @returns the base size
  33106. */
  33107. getBaseSize(): ISize;
  33108. /**
  33109. * Update the sampling mode of the texture.
  33110. * Default is Trilinear mode.
  33111. *
  33112. * | Value | Type | Description |
  33113. * | ----- | ------------------ | ----------- |
  33114. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33115. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33116. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33117. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33118. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33119. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33120. * | 7 | NEAREST_LINEAR | |
  33121. * | 8 | NEAREST_NEAREST | |
  33122. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33123. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33124. * | 11 | LINEAR_LINEAR | |
  33125. * | 12 | LINEAR_NEAREST | |
  33126. *
  33127. * > _mag_: magnification filter (close to the viewer)
  33128. * > _min_: minification filter (far from the viewer)
  33129. * > _mip_: filter used between mip map levels
  33130. *@param samplingMode Define the new sampling mode of the texture
  33131. */
  33132. updateSamplingMode(samplingMode: number): void;
  33133. /**
  33134. * Scales the texture if is `canRescale()`
  33135. * @param ratio the resize factor we want to use to rescale
  33136. */
  33137. scale(ratio: number): void;
  33138. /**
  33139. * Get if the texture can rescale.
  33140. */
  33141. get canRescale(): boolean;
  33142. /** @hidden */
  33143. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33144. /** @hidden */
  33145. _rebuild(): void;
  33146. /**
  33147. * Triggers the load sequence in delayed load mode.
  33148. */
  33149. delayLoad(): void;
  33150. /**
  33151. * Clones the texture.
  33152. * @returns the cloned texture
  33153. */
  33154. clone(): Nullable<BaseTexture>;
  33155. /**
  33156. * Get the texture underlying type (INT, FLOAT...)
  33157. */
  33158. get textureType(): number;
  33159. /**
  33160. * Get the texture underlying format (RGB, RGBA...)
  33161. */
  33162. get textureFormat(): number;
  33163. /**
  33164. * Indicates that textures need to be re-calculated for all materials
  33165. */
  33166. protected _markAllSubMeshesAsTexturesDirty(): void;
  33167. /**
  33168. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33169. * This will returns an RGBA array buffer containing either in values (0-255) or
  33170. * float values (0-1) depending of the underlying buffer type.
  33171. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33172. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33173. * @param buffer defines a user defined buffer to fill with data (can be null)
  33174. * @returns The Array buffer containing the pixels data.
  33175. */
  33176. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33177. /**
  33178. * Release and destroy the underlying lower level texture aka internalTexture.
  33179. */
  33180. releaseInternalTexture(): void;
  33181. /** @hidden */
  33182. get _lodTextureHigh(): Nullable<BaseTexture>;
  33183. /** @hidden */
  33184. get _lodTextureMid(): Nullable<BaseTexture>;
  33185. /** @hidden */
  33186. get _lodTextureLow(): Nullable<BaseTexture>;
  33187. /**
  33188. * Dispose the texture and release its associated resources.
  33189. */
  33190. dispose(): void;
  33191. /**
  33192. * Serialize the texture into a JSON representation that can be parsed later on.
  33193. * @returns the JSON representation of the texture
  33194. */
  33195. serialize(): any;
  33196. /**
  33197. * Helper function to be called back once a list of texture contains only ready textures.
  33198. * @param textures Define the list of textures to wait for
  33199. * @param callback Define the callback triggered once the entire list will be ready
  33200. */
  33201. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33202. private static _isScene;
  33203. }
  33204. }
  33205. declare module BABYLON {
  33206. /**
  33207. * Options to be used when creating an effect.
  33208. */
  33209. export interface IEffectCreationOptions {
  33210. /**
  33211. * Atrributes that will be used in the shader.
  33212. */
  33213. attributes: string[];
  33214. /**
  33215. * Uniform varible names that will be set in the shader.
  33216. */
  33217. uniformsNames: string[];
  33218. /**
  33219. * Uniform buffer variable names that will be set in the shader.
  33220. */
  33221. uniformBuffersNames: string[];
  33222. /**
  33223. * Sampler texture variable names that will be set in the shader.
  33224. */
  33225. samplers: string[];
  33226. /**
  33227. * Define statements that will be set in the shader.
  33228. */
  33229. defines: any;
  33230. /**
  33231. * Possible fallbacks for this effect to improve performance when needed.
  33232. */
  33233. fallbacks: Nullable<IEffectFallbacks>;
  33234. /**
  33235. * Callback that will be called when the shader is compiled.
  33236. */
  33237. onCompiled: Nullable<(effect: Effect) => void>;
  33238. /**
  33239. * Callback that will be called if an error occurs during shader compilation.
  33240. */
  33241. onError: Nullable<(effect: Effect, errors: string) => void>;
  33242. /**
  33243. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33244. */
  33245. indexParameters?: any;
  33246. /**
  33247. * Max number of lights that can be used in the shader.
  33248. */
  33249. maxSimultaneousLights?: number;
  33250. /**
  33251. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33252. */
  33253. transformFeedbackVaryings?: Nullable<string[]>;
  33254. /**
  33255. * 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
  33256. */
  33257. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33258. /**
  33259. * Is this effect rendering to several color attachments ?
  33260. */
  33261. multiTarget?: boolean;
  33262. }
  33263. /**
  33264. * Effect containing vertex and fragment shader that can be executed on an object.
  33265. */
  33266. export class Effect implements IDisposable {
  33267. /**
  33268. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33269. */
  33270. static ShadersRepository: string;
  33271. /**
  33272. * Enable logging of the shader code when a compilation error occurs
  33273. */
  33274. static LogShaderCodeOnCompilationError: boolean;
  33275. /**
  33276. * Name of the effect.
  33277. */
  33278. name: any;
  33279. /**
  33280. * String container all the define statements that should be set on the shader.
  33281. */
  33282. defines: string;
  33283. /**
  33284. * Callback that will be called when the shader is compiled.
  33285. */
  33286. onCompiled: Nullable<(effect: Effect) => void>;
  33287. /**
  33288. * Callback that will be called if an error occurs during shader compilation.
  33289. */
  33290. onError: Nullable<(effect: Effect, errors: string) => void>;
  33291. /**
  33292. * Callback that will be called when effect is bound.
  33293. */
  33294. onBind: Nullable<(effect: Effect) => void>;
  33295. /**
  33296. * Unique ID of the effect.
  33297. */
  33298. uniqueId: number;
  33299. /**
  33300. * Observable that will be called when the shader is compiled.
  33301. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33302. */
  33303. onCompileObservable: Observable<Effect>;
  33304. /**
  33305. * Observable that will be called if an error occurs during shader compilation.
  33306. */
  33307. onErrorObservable: Observable<Effect>;
  33308. /** @hidden */
  33309. _onBindObservable: Nullable<Observable<Effect>>;
  33310. /**
  33311. * @hidden
  33312. * Specifies if the effect was previously ready
  33313. */
  33314. _wasPreviouslyReady: boolean;
  33315. /**
  33316. * Observable that will be called when effect is bound.
  33317. */
  33318. get onBindObservable(): Observable<Effect>;
  33319. /** @hidden */
  33320. _bonesComputationForcedToCPU: boolean;
  33321. /** @hidden */
  33322. _multiTarget: boolean;
  33323. private static _uniqueIdSeed;
  33324. private _engine;
  33325. private _uniformBuffersNames;
  33326. private _uniformBuffersNamesList;
  33327. private _uniformsNames;
  33328. private _samplerList;
  33329. private _samplers;
  33330. private _isReady;
  33331. private _compilationError;
  33332. private _allFallbacksProcessed;
  33333. private _attributesNames;
  33334. private _attributes;
  33335. private _attributeLocationByName;
  33336. private _uniforms;
  33337. /**
  33338. * Key for the effect.
  33339. * @hidden
  33340. */
  33341. _key: string;
  33342. private _indexParameters;
  33343. private _fallbacks;
  33344. private _vertexSourceCode;
  33345. private _fragmentSourceCode;
  33346. private _vertexSourceCodeOverride;
  33347. private _fragmentSourceCodeOverride;
  33348. private _transformFeedbackVaryings;
  33349. /**
  33350. * Compiled shader to webGL program.
  33351. * @hidden
  33352. */
  33353. _pipelineContext: Nullable<IPipelineContext>;
  33354. private _valueCache;
  33355. private static _baseCache;
  33356. /**
  33357. * Instantiates an effect.
  33358. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33359. * @param baseName Name of the effect.
  33360. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33361. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33362. * @param samplers List of sampler variables that will be passed to the shader.
  33363. * @param engine Engine to be used to render the effect
  33364. * @param defines Define statements to be added to the shader.
  33365. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33366. * @param onCompiled Callback that will be called when the shader is compiled.
  33367. * @param onError Callback that will be called if an error occurs during shader compilation.
  33368. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33369. */
  33370. 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);
  33371. private _useFinalCode;
  33372. /**
  33373. * Unique key for this effect
  33374. */
  33375. get key(): string;
  33376. /**
  33377. * If the effect has been compiled and prepared.
  33378. * @returns if the effect is compiled and prepared.
  33379. */
  33380. isReady(): boolean;
  33381. private _isReadyInternal;
  33382. /**
  33383. * The engine the effect was initialized with.
  33384. * @returns the engine.
  33385. */
  33386. getEngine(): Engine;
  33387. /**
  33388. * The pipeline context for this effect
  33389. * @returns the associated pipeline context
  33390. */
  33391. getPipelineContext(): Nullable<IPipelineContext>;
  33392. /**
  33393. * The set of names of attribute variables for the shader.
  33394. * @returns An array of attribute names.
  33395. */
  33396. getAttributesNames(): string[];
  33397. /**
  33398. * Returns the attribute at the given index.
  33399. * @param index The index of the attribute.
  33400. * @returns The location of the attribute.
  33401. */
  33402. getAttributeLocation(index: number): number;
  33403. /**
  33404. * Returns the attribute based on the name of the variable.
  33405. * @param name of the attribute to look up.
  33406. * @returns the attribute location.
  33407. */
  33408. getAttributeLocationByName(name: string): number;
  33409. /**
  33410. * The number of attributes.
  33411. * @returns the numnber of attributes.
  33412. */
  33413. getAttributesCount(): number;
  33414. /**
  33415. * Gets the index of a uniform variable.
  33416. * @param uniformName of the uniform to look up.
  33417. * @returns the index.
  33418. */
  33419. getUniformIndex(uniformName: string): number;
  33420. /**
  33421. * Returns the attribute based on the name of the variable.
  33422. * @param uniformName of the uniform to look up.
  33423. * @returns the location of the uniform.
  33424. */
  33425. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33426. /**
  33427. * Returns an array of sampler variable names
  33428. * @returns The array of sampler variable names.
  33429. */
  33430. getSamplers(): string[];
  33431. /**
  33432. * Returns an array of uniform variable names
  33433. * @returns The array of uniform variable names.
  33434. */
  33435. getUniformNames(): string[];
  33436. /**
  33437. * Returns an array of uniform buffer variable names
  33438. * @returns The array of uniform buffer variable names.
  33439. */
  33440. getUniformBuffersNames(): string[];
  33441. /**
  33442. * Returns the index parameters used to create the effect
  33443. * @returns The index parameters object
  33444. */
  33445. getIndexParameters(): any;
  33446. /**
  33447. * The error from the last compilation.
  33448. * @returns the error string.
  33449. */
  33450. getCompilationError(): string;
  33451. /**
  33452. * Gets a boolean indicating that all fallbacks were used during compilation
  33453. * @returns true if all fallbacks were used
  33454. */
  33455. allFallbacksProcessed(): boolean;
  33456. /**
  33457. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33458. * @param func The callback to be used.
  33459. */
  33460. executeWhenCompiled(func: (effect: Effect) => void): void;
  33461. private _checkIsReady;
  33462. private _loadShader;
  33463. /**
  33464. * Gets the vertex shader source code of this effect
  33465. */
  33466. get vertexSourceCode(): string;
  33467. /**
  33468. * Gets the fragment shader source code of this effect
  33469. */
  33470. get fragmentSourceCode(): string;
  33471. /**
  33472. * Recompiles the webGL program
  33473. * @param vertexSourceCode The source code for the vertex shader.
  33474. * @param fragmentSourceCode The source code for the fragment shader.
  33475. * @param onCompiled Callback called when completed.
  33476. * @param onError Callback called on error.
  33477. * @hidden
  33478. */
  33479. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33480. /**
  33481. * Prepares the effect
  33482. * @hidden
  33483. */
  33484. _prepareEffect(): void;
  33485. private _getShaderCodeAndErrorLine;
  33486. private _processCompilationErrors;
  33487. /**
  33488. * Checks if the effect is supported. (Must be called after compilation)
  33489. */
  33490. get isSupported(): boolean;
  33491. /**
  33492. * Binds a texture to the engine to be used as output of the shader.
  33493. * @param channel Name of the output variable.
  33494. * @param texture Texture to bind.
  33495. * @hidden
  33496. */
  33497. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33498. /**
  33499. * Sets a texture on the engine to be used in the shader.
  33500. * @param channel Name of the sampler variable.
  33501. * @param texture Texture to set.
  33502. */
  33503. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33504. /**
  33505. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33506. * @param channel Name of the sampler variable.
  33507. * @param texture Texture to set.
  33508. */
  33509. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33510. /**
  33511. * Sets an array of textures on the engine to be used in the shader.
  33512. * @param channel Name of the variable.
  33513. * @param textures Textures to set.
  33514. */
  33515. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33516. /**
  33517. * 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)
  33518. * @param channel Name of the sampler variable.
  33519. * @param postProcess Post process to get the input texture from.
  33520. */
  33521. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33522. /**
  33523. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33524. * 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)
  33525. * @param channel Name of the sampler variable.
  33526. * @param postProcess Post process to get the output texture from.
  33527. */
  33528. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33529. /** @hidden */
  33530. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33531. /** @hidden */
  33532. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33533. /** @hidden */
  33534. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33535. /** @hidden */
  33536. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33537. /**
  33538. * Binds a buffer to a uniform.
  33539. * @param buffer Buffer to bind.
  33540. * @param name Name of the uniform variable to bind to.
  33541. */
  33542. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33543. /**
  33544. * Binds block to a uniform.
  33545. * @param blockName Name of the block to bind.
  33546. * @param index Index to bind.
  33547. */
  33548. bindUniformBlock(blockName: string, index: number): void;
  33549. /**
  33550. * Sets an interger value on a uniform variable.
  33551. * @param uniformName Name of the variable.
  33552. * @param value Value to be set.
  33553. * @returns this effect.
  33554. */
  33555. setInt(uniformName: string, value: number): Effect;
  33556. /**
  33557. * Sets an int array on a uniform variable.
  33558. * @param uniformName Name of the variable.
  33559. * @param array array to be set.
  33560. * @returns this effect.
  33561. */
  33562. setIntArray(uniformName: string, array: Int32Array): Effect;
  33563. /**
  33564. * 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)
  33565. * @param uniformName Name of the variable.
  33566. * @param array array to be set.
  33567. * @returns this effect.
  33568. */
  33569. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33570. /**
  33571. * 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)
  33572. * @param uniformName Name of the variable.
  33573. * @param array array to be set.
  33574. * @returns this effect.
  33575. */
  33576. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33577. /**
  33578. * 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)
  33579. * @param uniformName Name of the variable.
  33580. * @param array array to be set.
  33581. * @returns this effect.
  33582. */
  33583. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33584. /**
  33585. * Sets an float array on a uniform variable.
  33586. * @param uniformName Name of the variable.
  33587. * @param array array to be set.
  33588. * @returns this effect.
  33589. */
  33590. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33591. /**
  33592. * 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)
  33593. * @param uniformName Name of the variable.
  33594. * @param array array to be set.
  33595. * @returns this effect.
  33596. */
  33597. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33598. /**
  33599. * 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)
  33600. * @param uniformName Name of the variable.
  33601. * @param array array to be set.
  33602. * @returns this effect.
  33603. */
  33604. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33605. /**
  33606. * 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)
  33607. * @param uniformName Name of the variable.
  33608. * @param array array to be set.
  33609. * @returns this effect.
  33610. */
  33611. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33612. /**
  33613. * Sets an array on a uniform variable.
  33614. * @param uniformName Name of the variable.
  33615. * @param array array to be set.
  33616. * @returns this effect.
  33617. */
  33618. setArray(uniformName: string, array: number[]): Effect;
  33619. /**
  33620. * 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)
  33621. * @param uniformName Name of the variable.
  33622. * @param array array to be set.
  33623. * @returns this effect.
  33624. */
  33625. setArray2(uniformName: string, array: number[]): Effect;
  33626. /**
  33627. * 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)
  33628. * @param uniformName Name of the variable.
  33629. * @param array array to be set.
  33630. * @returns this effect.
  33631. */
  33632. setArray3(uniformName: string, array: number[]): Effect;
  33633. /**
  33634. * 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)
  33635. * @param uniformName Name of the variable.
  33636. * @param array array to be set.
  33637. * @returns this effect.
  33638. */
  33639. setArray4(uniformName: string, array: number[]): Effect;
  33640. /**
  33641. * Sets matrices on a uniform variable.
  33642. * @param uniformName Name of the variable.
  33643. * @param matrices matrices to be set.
  33644. * @returns this effect.
  33645. */
  33646. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33647. /**
  33648. * Sets matrix on a uniform variable.
  33649. * @param uniformName Name of the variable.
  33650. * @param matrix matrix to be set.
  33651. * @returns this effect.
  33652. */
  33653. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33654. /**
  33655. * 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)
  33656. * @param uniformName Name of the variable.
  33657. * @param matrix matrix to be set.
  33658. * @returns this effect.
  33659. */
  33660. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33661. /**
  33662. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33663. * @param uniformName Name of the variable.
  33664. * @param matrix matrix to be set.
  33665. * @returns this effect.
  33666. */
  33667. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33668. /**
  33669. * Sets a float on a uniform variable.
  33670. * @param uniformName Name of the variable.
  33671. * @param value value to be set.
  33672. * @returns this effect.
  33673. */
  33674. setFloat(uniformName: string, value: number): Effect;
  33675. /**
  33676. * Sets a boolean on a uniform variable.
  33677. * @param uniformName Name of the variable.
  33678. * @param bool value to be set.
  33679. * @returns this effect.
  33680. */
  33681. setBool(uniformName: string, bool: boolean): Effect;
  33682. /**
  33683. * Sets a Vector2 on a uniform variable.
  33684. * @param uniformName Name of the variable.
  33685. * @param vector2 vector2 to be set.
  33686. * @returns this effect.
  33687. */
  33688. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33689. /**
  33690. * Sets a float2 on a uniform variable.
  33691. * @param uniformName Name of the variable.
  33692. * @param x First float in float2.
  33693. * @param y Second float in float2.
  33694. * @returns this effect.
  33695. */
  33696. setFloat2(uniformName: string, x: number, y: number): Effect;
  33697. /**
  33698. * Sets a Vector3 on a uniform variable.
  33699. * @param uniformName Name of the variable.
  33700. * @param vector3 Value to be set.
  33701. * @returns this effect.
  33702. */
  33703. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33704. /**
  33705. * Sets a float3 on a uniform variable.
  33706. * @param uniformName Name of the variable.
  33707. * @param x First float in float3.
  33708. * @param y Second float in float3.
  33709. * @param z Third float in float3.
  33710. * @returns this effect.
  33711. */
  33712. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33713. /**
  33714. * Sets a Vector4 on a uniform variable.
  33715. * @param uniformName Name of the variable.
  33716. * @param vector4 Value to be set.
  33717. * @returns this effect.
  33718. */
  33719. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33720. /**
  33721. * Sets a float4 on a uniform variable.
  33722. * @param uniformName Name of the variable.
  33723. * @param x First float in float4.
  33724. * @param y Second float in float4.
  33725. * @param z Third float in float4.
  33726. * @param w Fourth float in float4.
  33727. * @returns this effect.
  33728. */
  33729. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33730. /**
  33731. * Sets a Color3 on a uniform variable.
  33732. * @param uniformName Name of the variable.
  33733. * @param color3 Value to be set.
  33734. * @returns this effect.
  33735. */
  33736. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33737. /**
  33738. * Sets a Color4 on a uniform variable.
  33739. * @param uniformName Name of the variable.
  33740. * @param color3 Value to be set.
  33741. * @param alpha Alpha value to be set.
  33742. * @returns this effect.
  33743. */
  33744. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33745. /**
  33746. * Sets a Color4 on a uniform variable
  33747. * @param uniformName defines the name of the variable
  33748. * @param color4 defines the value to be set
  33749. * @returns this effect.
  33750. */
  33751. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33752. /** Release all associated resources */
  33753. dispose(): void;
  33754. /**
  33755. * This function will add a new shader to the shader store
  33756. * @param name the name of the shader
  33757. * @param pixelShader optional pixel shader content
  33758. * @param vertexShader optional vertex shader content
  33759. */
  33760. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33761. /**
  33762. * Store of each shader (The can be looked up using effect.key)
  33763. */
  33764. static ShadersStore: {
  33765. [key: string]: string;
  33766. };
  33767. /**
  33768. * Store of each included file for a shader (The can be looked up using effect.key)
  33769. */
  33770. static IncludesShadersStore: {
  33771. [key: string]: string;
  33772. };
  33773. /**
  33774. * Resets the cache of effects.
  33775. */
  33776. static ResetCache(): void;
  33777. }
  33778. }
  33779. declare module BABYLON {
  33780. /**
  33781. * Interface used to describe the capabilities of the engine relatively to the current browser
  33782. */
  33783. export interface EngineCapabilities {
  33784. /** Maximum textures units per fragment shader */
  33785. maxTexturesImageUnits: number;
  33786. /** Maximum texture units per vertex shader */
  33787. maxVertexTextureImageUnits: number;
  33788. /** Maximum textures units in the entire pipeline */
  33789. maxCombinedTexturesImageUnits: number;
  33790. /** Maximum texture size */
  33791. maxTextureSize: number;
  33792. /** Maximum texture samples */
  33793. maxSamples?: number;
  33794. /** Maximum cube texture size */
  33795. maxCubemapTextureSize: number;
  33796. /** Maximum render texture size */
  33797. maxRenderTextureSize: number;
  33798. /** Maximum number of vertex attributes */
  33799. maxVertexAttribs: number;
  33800. /** Maximum number of varyings */
  33801. maxVaryingVectors: number;
  33802. /** Maximum number of uniforms per vertex shader */
  33803. maxVertexUniformVectors: number;
  33804. /** Maximum number of uniforms per fragment shader */
  33805. maxFragmentUniformVectors: number;
  33806. /** Defines if standard derivates (dx/dy) are supported */
  33807. standardDerivatives: boolean;
  33808. /** Defines if s3tc texture compression is supported */
  33809. s3tc?: WEBGL_compressed_texture_s3tc;
  33810. /** Defines if pvrtc texture compression is supported */
  33811. pvrtc: any;
  33812. /** Defines if etc1 texture compression is supported */
  33813. etc1: any;
  33814. /** Defines if etc2 texture compression is supported */
  33815. etc2: any;
  33816. /** Defines if astc texture compression is supported */
  33817. astc: any;
  33818. /** Defines if float textures are supported */
  33819. textureFloat: boolean;
  33820. /** Defines if vertex array objects are supported */
  33821. vertexArrayObject: boolean;
  33822. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33823. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33824. /** Gets the maximum level of anisotropy supported */
  33825. maxAnisotropy: number;
  33826. /** Defines if instancing is supported */
  33827. instancedArrays: boolean;
  33828. /** Defines if 32 bits indices are supported */
  33829. uintIndices: boolean;
  33830. /** Defines if high precision shaders are supported */
  33831. highPrecisionShaderSupported: boolean;
  33832. /** Defines if depth reading in the fragment shader is supported */
  33833. fragmentDepthSupported: boolean;
  33834. /** Defines if float texture linear filtering is supported*/
  33835. textureFloatLinearFiltering: boolean;
  33836. /** Defines if rendering to float textures is supported */
  33837. textureFloatRender: boolean;
  33838. /** Defines if half float textures are supported*/
  33839. textureHalfFloat: boolean;
  33840. /** Defines if half float texture linear filtering is supported*/
  33841. textureHalfFloatLinearFiltering: boolean;
  33842. /** Defines if rendering to half float textures is supported */
  33843. textureHalfFloatRender: boolean;
  33844. /** Defines if textureLOD shader command is supported */
  33845. textureLOD: boolean;
  33846. /** Defines if draw buffers extension is supported */
  33847. drawBuffersExtension: boolean;
  33848. /** Defines if depth textures are supported */
  33849. depthTextureExtension: boolean;
  33850. /** Defines if float color buffer are supported */
  33851. colorBufferFloat: boolean;
  33852. /** Gets disjoint timer query extension (null if not supported) */
  33853. timerQuery?: EXT_disjoint_timer_query;
  33854. /** Defines if timestamp can be used with timer query */
  33855. canUseTimestampForTimerQuery: boolean;
  33856. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33857. multiview?: any;
  33858. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33859. oculusMultiview?: any;
  33860. /** Function used to let the system compiles shaders in background */
  33861. parallelShaderCompile?: {
  33862. COMPLETION_STATUS_KHR: number;
  33863. };
  33864. /** Max number of texture samples for MSAA */
  33865. maxMSAASamples: number;
  33866. /** Defines if the blend min max extension is supported */
  33867. blendMinMax: boolean;
  33868. }
  33869. }
  33870. declare module BABYLON {
  33871. /**
  33872. * @hidden
  33873. **/
  33874. export class DepthCullingState {
  33875. private _isDepthTestDirty;
  33876. private _isDepthMaskDirty;
  33877. private _isDepthFuncDirty;
  33878. private _isCullFaceDirty;
  33879. private _isCullDirty;
  33880. private _isZOffsetDirty;
  33881. private _isFrontFaceDirty;
  33882. private _depthTest;
  33883. private _depthMask;
  33884. private _depthFunc;
  33885. private _cull;
  33886. private _cullFace;
  33887. private _zOffset;
  33888. private _frontFace;
  33889. /**
  33890. * Initializes the state.
  33891. */
  33892. constructor();
  33893. get isDirty(): boolean;
  33894. get zOffset(): number;
  33895. set zOffset(value: number);
  33896. get cullFace(): Nullable<number>;
  33897. set cullFace(value: Nullable<number>);
  33898. get cull(): Nullable<boolean>;
  33899. set cull(value: Nullable<boolean>);
  33900. get depthFunc(): Nullable<number>;
  33901. set depthFunc(value: Nullable<number>);
  33902. get depthMask(): boolean;
  33903. set depthMask(value: boolean);
  33904. get depthTest(): boolean;
  33905. set depthTest(value: boolean);
  33906. get frontFace(): Nullable<number>;
  33907. set frontFace(value: Nullable<number>);
  33908. reset(): void;
  33909. apply(gl: WebGLRenderingContext): void;
  33910. }
  33911. }
  33912. declare module BABYLON {
  33913. /**
  33914. * @hidden
  33915. **/
  33916. export class StencilState {
  33917. /** 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 */
  33918. static readonly ALWAYS: number;
  33919. /** Passed to stencilOperation to specify that stencil value must be kept */
  33920. static readonly KEEP: number;
  33921. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33922. static readonly REPLACE: number;
  33923. private _isStencilTestDirty;
  33924. private _isStencilMaskDirty;
  33925. private _isStencilFuncDirty;
  33926. private _isStencilOpDirty;
  33927. private _stencilTest;
  33928. private _stencilMask;
  33929. private _stencilFunc;
  33930. private _stencilFuncRef;
  33931. private _stencilFuncMask;
  33932. private _stencilOpStencilFail;
  33933. private _stencilOpDepthFail;
  33934. private _stencilOpStencilDepthPass;
  33935. get isDirty(): boolean;
  33936. get stencilFunc(): number;
  33937. set stencilFunc(value: number);
  33938. get stencilFuncRef(): number;
  33939. set stencilFuncRef(value: number);
  33940. get stencilFuncMask(): number;
  33941. set stencilFuncMask(value: number);
  33942. get stencilOpStencilFail(): number;
  33943. set stencilOpStencilFail(value: number);
  33944. get stencilOpDepthFail(): number;
  33945. set stencilOpDepthFail(value: number);
  33946. get stencilOpStencilDepthPass(): number;
  33947. set stencilOpStencilDepthPass(value: number);
  33948. get stencilMask(): number;
  33949. set stencilMask(value: number);
  33950. get stencilTest(): boolean;
  33951. set stencilTest(value: boolean);
  33952. constructor();
  33953. reset(): void;
  33954. apply(gl: WebGLRenderingContext): void;
  33955. }
  33956. }
  33957. declare module BABYLON {
  33958. /**
  33959. * @hidden
  33960. **/
  33961. export class AlphaState {
  33962. private _isAlphaBlendDirty;
  33963. private _isBlendFunctionParametersDirty;
  33964. private _isBlendEquationParametersDirty;
  33965. private _isBlendConstantsDirty;
  33966. private _alphaBlend;
  33967. private _blendFunctionParameters;
  33968. private _blendEquationParameters;
  33969. private _blendConstants;
  33970. /**
  33971. * Initializes the state.
  33972. */
  33973. constructor();
  33974. get isDirty(): boolean;
  33975. get alphaBlend(): boolean;
  33976. set alphaBlend(value: boolean);
  33977. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33978. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33979. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33980. reset(): void;
  33981. apply(gl: WebGLRenderingContext): void;
  33982. }
  33983. }
  33984. declare module BABYLON {
  33985. /** @hidden */
  33986. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33987. attributeProcessor(attribute: string): string;
  33988. varyingProcessor(varying: string, isFragment: boolean): string;
  33989. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33990. }
  33991. }
  33992. declare module BABYLON {
  33993. /**
  33994. * Interface for attribute information associated with buffer instanciation
  33995. */
  33996. export interface InstancingAttributeInfo {
  33997. /**
  33998. * Name of the GLSL attribute
  33999. * if attribute index is not specified, this is used to retrieve the index from the effect
  34000. */
  34001. attributeName: string;
  34002. /**
  34003. * Index/offset of the attribute in the vertex shader
  34004. * if not specified, this will be computes from the name.
  34005. */
  34006. index?: number;
  34007. /**
  34008. * size of the attribute, 1, 2, 3 or 4
  34009. */
  34010. attributeSize: number;
  34011. /**
  34012. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34013. */
  34014. offset: number;
  34015. /**
  34016. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34017. * default to 1
  34018. */
  34019. divisor?: number;
  34020. /**
  34021. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34022. * default is FLOAT
  34023. */
  34024. attributeType?: number;
  34025. /**
  34026. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34027. */
  34028. normalized?: boolean;
  34029. }
  34030. }
  34031. declare module BABYLON {
  34032. interface ThinEngine {
  34033. /**
  34034. * Update a video texture
  34035. * @param texture defines the texture to update
  34036. * @param video defines the video element to use
  34037. * @param invertY defines if data must be stored with Y axis inverted
  34038. */
  34039. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34040. }
  34041. }
  34042. declare module BABYLON {
  34043. interface ThinEngine {
  34044. /**
  34045. * Creates a dynamic texture
  34046. * @param width defines the width of the texture
  34047. * @param height defines the height of the texture
  34048. * @param generateMipMaps defines if the engine should generate the mip levels
  34049. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34050. * @returns the dynamic texture inside an InternalTexture
  34051. */
  34052. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34053. /**
  34054. * Update the content of a dynamic texture
  34055. * @param texture defines the texture to update
  34056. * @param canvas defines the canvas containing the source
  34057. * @param invertY defines if data must be stored with Y axis inverted
  34058. * @param premulAlpha defines if alpha is stored as premultiplied
  34059. * @param format defines the format of the data
  34060. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34061. */
  34062. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34063. }
  34064. }
  34065. declare module BABYLON {
  34066. /**
  34067. * Settings for finer control over video usage
  34068. */
  34069. export interface VideoTextureSettings {
  34070. /**
  34071. * Applies `autoplay` to video, if specified
  34072. */
  34073. autoPlay?: boolean;
  34074. /**
  34075. * Applies `loop` to video, if specified
  34076. */
  34077. loop?: boolean;
  34078. /**
  34079. * Automatically updates internal texture from video at every frame in the render loop
  34080. */
  34081. autoUpdateTexture: boolean;
  34082. /**
  34083. * Image src displayed during the video loading or until the user interacts with the video.
  34084. */
  34085. poster?: string;
  34086. }
  34087. /**
  34088. * If you want to display a video in your scene, this is the special texture for that.
  34089. * This special texture works similar to other textures, with the exception of a few parameters.
  34090. * @see https://doc.babylonjs.com/how_to/video_texture
  34091. */
  34092. export class VideoTexture extends Texture {
  34093. /**
  34094. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34095. */
  34096. readonly autoUpdateTexture: boolean;
  34097. /**
  34098. * The video instance used by the texture internally
  34099. */
  34100. readonly video: HTMLVideoElement;
  34101. private _onUserActionRequestedObservable;
  34102. /**
  34103. * Event triggerd when a dom action is required by the user to play the video.
  34104. * This happens due to recent changes in browser policies preventing video to auto start.
  34105. */
  34106. get onUserActionRequestedObservable(): Observable<Texture>;
  34107. private _generateMipMaps;
  34108. private _stillImageCaptured;
  34109. private _displayingPosterTexture;
  34110. private _settings;
  34111. private _createInternalTextureOnEvent;
  34112. private _frameId;
  34113. private _currentSrc;
  34114. /**
  34115. * Creates a video texture.
  34116. * If you want to display a video in your scene, this is the special texture for that.
  34117. * This special texture works similar to other textures, with the exception of a few parameters.
  34118. * @see https://doc.babylonjs.com/how_to/video_texture
  34119. * @param name optional name, will detect from video source, if not defined
  34120. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34121. * @param scene is obviously the current scene.
  34122. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34123. * @param invertY is false by default but can be used to invert video on Y axis
  34124. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34125. * @param settings allows finer control over video usage
  34126. */
  34127. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34128. private _getName;
  34129. private _getVideo;
  34130. private _createInternalTexture;
  34131. private reset;
  34132. /**
  34133. * @hidden Internal method to initiate `update`.
  34134. */
  34135. _rebuild(): void;
  34136. /**
  34137. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34138. */
  34139. update(): void;
  34140. /**
  34141. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34142. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34143. */
  34144. updateTexture(isVisible: boolean): void;
  34145. protected _updateInternalTexture: () => void;
  34146. /**
  34147. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34148. * @param url New url.
  34149. */
  34150. updateURL(url: string): void;
  34151. /**
  34152. * Clones the texture.
  34153. * @returns the cloned texture
  34154. */
  34155. clone(): VideoTexture;
  34156. /**
  34157. * Dispose the texture and release its associated resources.
  34158. */
  34159. dispose(): void;
  34160. /**
  34161. * Creates a video texture straight from a stream.
  34162. * @param scene Define the scene the texture should be created in
  34163. * @param stream Define the stream the texture should be created from
  34164. * @returns The created video texture as a promise
  34165. */
  34166. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34167. /**
  34168. * Creates a video texture straight from your WebCam video feed.
  34169. * @param scene Define the scene the texture should be created in
  34170. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34171. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34172. * @returns The created video texture as a promise
  34173. */
  34174. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34175. minWidth: number;
  34176. maxWidth: number;
  34177. minHeight: number;
  34178. maxHeight: number;
  34179. deviceId: string;
  34180. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34181. /**
  34182. * Creates a video texture straight from your WebCam video feed.
  34183. * @param scene Define the scene the texture should be created in
  34184. * @param onReady Define a callback to triggered once the texture will be ready
  34185. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34186. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34187. */
  34188. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34189. minWidth: number;
  34190. maxWidth: number;
  34191. minHeight: number;
  34192. maxHeight: number;
  34193. deviceId: string;
  34194. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34195. }
  34196. }
  34197. declare module BABYLON {
  34198. /**
  34199. * Defines the interface used by objects working like Scene
  34200. * @hidden
  34201. */
  34202. export interface ISceneLike {
  34203. _addPendingData(data: any): void;
  34204. _removePendingData(data: any): void;
  34205. offlineProvider: IOfflineProvider;
  34206. }
  34207. /** Interface defining initialization parameters for Engine class */
  34208. export interface EngineOptions extends WebGLContextAttributes {
  34209. /**
  34210. * Defines if the engine should no exceed a specified device ratio
  34211. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34212. */
  34213. limitDeviceRatio?: number;
  34214. /**
  34215. * Defines if webvr should be enabled automatically
  34216. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34217. */
  34218. autoEnableWebVR?: boolean;
  34219. /**
  34220. * Defines if webgl2 should be turned off even if supported
  34221. * @see https://doc.babylonjs.com/features/webgl2
  34222. */
  34223. disableWebGL2Support?: boolean;
  34224. /**
  34225. * Defines if webaudio should be initialized as well
  34226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  34227. */
  34228. audioEngine?: boolean;
  34229. /**
  34230. * Defines if animations should run using a deterministic lock step
  34231. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34232. */
  34233. deterministicLockstep?: boolean;
  34234. /** Defines the maximum steps to use with deterministic lock step mode */
  34235. lockstepMaxSteps?: number;
  34236. /** Defines the seconds between each deterministic lock step */
  34237. timeStep?: number;
  34238. /**
  34239. * Defines that engine should ignore context lost events
  34240. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34241. */
  34242. doNotHandleContextLost?: boolean;
  34243. /**
  34244. * Defines that engine should ignore modifying touch action attribute and style
  34245. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34246. */
  34247. doNotHandleTouchAction?: boolean;
  34248. /**
  34249. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34250. */
  34251. useHighPrecisionFloats?: boolean;
  34252. /**
  34253. * Make the canvas XR Compatible for XR sessions
  34254. */
  34255. xrCompatible?: boolean;
  34256. }
  34257. /**
  34258. * The base engine class (root of all engines)
  34259. */
  34260. export class ThinEngine {
  34261. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34262. static ExceptionList: ({
  34263. key: string;
  34264. capture: string;
  34265. captureConstraint: number;
  34266. targets: string[];
  34267. } | {
  34268. key: string;
  34269. capture: null;
  34270. captureConstraint: null;
  34271. targets: string[];
  34272. })[];
  34273. /** @hidden */
  34274. static _TextureLoaders: IInternalTextureLoader[];
  34275. /**
  34276. * Returns the current npm package of the sdk
  34277. */
  34278. static get NpmPackage(): string;
  34279. /**
  34280. * Returns the current version of the framework
  34281. */
  34282. static get Version(): string;
  34283. /**
  34284. * Returns a string describing the current engine
  34285. */
  34286. get description(): string;
  34287. /**
  34288. * Gets or sets the epsilon value used by collision engine
  34289. */
  34290. static CollisionsEpsilon: number;
  34291. /**
  34292. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34293. */
  34294. static get ShadersRepository(): string;
  34295. static set ShadersRepository(value: string);
  34296. /** @hidden */
  34297. _shaderProcessor: IShaderProcessor;
  34298. /**
  34299. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34300. */
  34301. forcePOTTextures: boolean;
  34302. /**
  34303. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34304. */
  34305. isFullscreen: boolean;
  34306. /**
  34307. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34308. */
  34309. cullBackFaces: boolean;
  34310. /**
  34311. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34312. */
  34313. renderEvenInBackground: boolean;
  34314. /**
  34315. * Gets or sets a boolean indicating that cache can be kept between frames
  34316. */
  34317. preventCacheWipeBetweenFrames: boolean;
  34318. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34319. validateShaderPrograms: boolean;
  34320. /**
  34321. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34322. * This can provide greater z depth for distant objects.
  34323. */
  34324. useReverseDepthBuffer: boolean;
  34325. /**
  34326. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34327. */
  34328. disableUniformBuffers: boolean;
  34329. /** @hidden */
  34330. _uniformBuffers: UniformBuffer[];
  34331. /**
  34332. * Gets a boolean indicating that the engine supports uniform buffers
  34333. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34334. */
  34335. get supportsUniformBuffers(): boolean;
  34336. /** @hidden */
  34337. _gl: WebGLRenderingContext;
  34338. /** @hidden */
  34339. _webGLVersion: number;
  34340. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34341. protected _windowIsBackground: boolean;
  34342. protected _creationOptions: EngineOptions;
  34343. protected _highPrecisionShadersAllowed: boolean;
  34344. /** @hidden */
  34345. get _shouldUseHighPrecisionShader(): boolean;
  34346. /**
  34347. * Gets a boolean indicating that only power of 2 textures are supported
  34348. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34349. */
  34350. get needPOTTextures(): boolean;
  34351. /** @hidden */
  34352. _badOS: boolean;
  34353. /** @hidden */
  34354. _badDesktopOS: boolean;
  34355. private _hardwareScalingLevel;
  34356. /** @hidden */
  34357. _caps: EngineCapabilities;
  34358. private _isStencilEnable;
  34359. private _glVersion;
  34360. private _glRenderer;
  34361. private _glVendor;
  34362. /** @hidden */
  34363. _videoTextureSupported: boolean;
  34364. protected _renderingQueueLaunched: boolean;
  34365. protected _activeRenderLoops: (() => void)[];
  34366. /**
  34367. * Observable signaled when a context lost event is raised
  34368. */
  34369. onContextLostObservable: Observable<ThinEngine>;
  34370. /**
  34371. * Observable signaled when a context restored event is raised
  34372. */
  34373. onContextRestoredObservable: Observable<ThinEngine>;
  34374. private _onContextLost;
  34375. private _onContextRestored;
  34376. protected _contextWasLost: boolean;
  34377. /** @hidden */
  34378. _doNotHandleContextLost: boolean;
  34379. /**
  34380. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34381. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34382. */
  34383. get doNotHandleContextLost(): boolean;
  34384. set doNotHandleContextLost(value: boolean);
  34385. /**
  34386. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34387. */
  34388. disableVertexArrayObjects: boolean;
  34389. /** @hidden */
  34390. protected _colorWrite: boolean;
  34391. /** @hidden */
  34392. protected _colorWriteChanged: boolean;
  34393. /** @hidden */
  34394. protected _depthCullingState: DepthCullingState;
  34395. /** @hidden */
  34396. protected _stencilState: StencilState;
  34397. /** @hidden */
  34398. _alphaState: AlphaState;
  34399. /** @hidden */
  34400. _alphaMode: number;
  34401. /** @hidden */
  34402. _alphaEquation: number;
  34403. /** @hidden */
  34404. _internalTexturesCache: InternalTexture[];
  34405. /** @hidden */
  34406. protected _activeChannel: number;
  34407. private _currentTextureChannel;
  34408. /** @hidden */
  34409. protected _boundTexturesCache: {
  34410. [key: string]: Nullable<InternalTexture>;
  34411. };
  34412. /** @hidden */
  34413. protected _currentEffect: Nullable<Effect>;
  34414. /** @hidden */
  34415. protected _currentProgram: Nullable<WebGLProgram>;
  34416. private _compiledEffects;
  34417. private _vertexAttribArraysEnabled;
  34418. /** @hidden */
  34419. protected _cachedViewport: Nullable<IViewportLike>;
  34420. private _cachedVertexArrayObject;
  34421. /** @hidden */
  34422. protected _cachedVertexBuffers: any;
  34423. /** @hidden */
  34424. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34425. /** @hidden */
  34426. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34427. /** @hidden */
  34428. _currentRenderTarget: Nullable<InternalTexture>;
  34429. private _uintIndicesCurrentlySet;
  34430. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34431. /** @hidden */
  34432. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34433. /** @hidden */
  34434. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34435. private _currentBufferPointers;
  34436. private _currentInstanceLocations;
  34437. private _currentInstanceBuffers;
  34438. private _textureUnits;
  34439. /** @hidden */
  34440. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34441. /** @hidden */
  34442. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34443. /** @hidden */
  34444. _boundRenderFunction: any;
  34445. private _vaoRecordInProgress;
  34446. private _mustWipeVertexAttributes;
  34447. private _emptyTexture;
  34448. private _emptyCubeTexture;
  34449. private _emptyTexture3D;
  34450. private _emptyTexture2DArray;
  34451. /** @hidden */
  34452. _frameHandler: number;
  34453. private _nextFreeTextureSlots;
  34454. private _maxSimultaneousTextures;
  34455. private _activeRequests;
  34456. /** @hidden */
  34457. _transformTextureUrl: Nullable<(url: string) => string>;
  34458. protected get _supportsHardwareTextureRescaling(): boolean;
  34459. private _framebufferDimensionsObject;
  34460. /**
  34461. * sets the object from which width and height will be taken from when getting render width and height
  34462. * Will fallback to the gl object
  34463. * @param dimensions the framebuffer width and height that will be used.
  34464. */
  34465. set framebufferDimensionsObject(dimensions: Nullable<{
  34466. framebufferWidth: number;
  34467. framebufferHeight: number;
  34468. }>);
  34469. /**
  34470. * Gets the current viewport
  34471. */
  34472. get currentViewport(): Nullable<IViewportLike>;
  34473. /**
  34474. * Gets the default empty texture
  34475. */
  34476. get emptyTexture(): InternalTexture;
  34477. /**
  34478. * Gets the default empty 3D texture
  34479. */
  34480. get emptyTexture3D(): InternalTexture;
  34481. /**
  34482. * Gets the default empty 2D array texture
  34483. */
  34484. get emptyTexture2DArray(): InternalTexture;
  34485. /**
  34486. * Gets the default empty cube texture
  34487. */
  34488. get emptyCubeTexture(): InternalTexture;
  34489. /**
  34490. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34491. */
  34492. readonly premultipliedAlpha: boolean;
  34493. /**
  34494. * Observable event triggered before each texture is initialized
  34495. */
  34496. onBeforeTextureInitObservable: Observable<Texture>;
  34497. /**
  34498. * Creates a new engine
  34499. * @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
  34500. * @param antialias defines enable antialiasing (default: false)
  34501. * @param options defines further options to be sent to the getContext() function
  34502. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34503. */
  34504. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34505. private _rebuildInternalTextures;
  34506. private _rebuildEffects;
  34507. /**
  34508. * Gets a boolean indicating if all created effects are ready
  34509. * @returns true if all effects are ready
  34510. */
  34511. areAllEffectsReady(): boolean;
  34512. protected _rebuildBuffers(): void;
  34513. protected _initGLContext(): void;
  34514. /**
  34515. * Gets version of the current webGL context
  34516. */
  34517. get webGLVersion(): number;
  34518. /**
  34519. * Gets a string idenfifying the name of the class
  34520. * @returns "Engine" string
  34521. */
  34522. getClassName(): string;
  34523. /**
  34524. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34525. */
  34526. get isStencilEnable(): boolean;
  34527. /** @hidden */
  34528. _prepareWorkingCanvas(): void;
  34529. /**
  34530. * Reset the texture cache to empty state
  34531. */
  34532. resetTextureCache(): void;
  34533. /**
  34534. * Gets an object containing information about the current webGL context
  34535. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34536. */
  34537. getGlInfo(): {
  34538. vendor: string;
  34539. renderer: string;
  34540. version: string;
  34541. };
  34542. /**
  34543. * Defines the hardware scaling level.
  34544. * By default the hardware scaling level is computed from the window device ratio.
  34545. * 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.
  34546. * @param level defines the level to use
  34547. */
  34548. setHardwareScalingLevel(level: number): void;
  34549. /**
  34550. * Gets the current hardware scaling level.
  34551. * By default the hardware scaling level is computed from the window device ratio.
  34552. * 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.
  34553. * @returns a number indicating the current hardware scaling level
  34554. */
  34555. getHardwareScalingLevel(): number;
  34556. /**
  34557. * Gets the list of loaded textures
  34558. * @returns an array containing all loaded textures
  34559. */
  34560. getLoadedTexturesCache(): InternalTexture[];
  34561. /**
  34562. * Gets the object containing all engine capabilities
  34563. * @returns the EngineCapabilities object
  34564. */
  34565. getCaps(): EngineCapabilities;
  34566. /**
  34567. * stop executing a render loop function and remove it from the execution array
  34568. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34569. */
  34570. stopRenderLoop(renderFunction?: () => void): void;
  34571. /** @hidden */
  34572. _renderLoop(): void;
  34573. /**
  34574. * Gets the HTML canvas attached with the current webGL context
  34575. * @returns a HTML canvas
  34576. */
  34577. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34578. /**
  34579. * Gets host window
  34580. * @returns the host window object
  34581. */
  34582. getHostWindow(): Nullable<Window>;
  34583. /**
  34584. * Gets the current render width
  34585. * @param useScreen defines if screen size must be used (or the current render target if any)
  34586. * @returns a number defining the current render width
  34587. */
  34588. getRenderWidth(useScreen?: boolean): number;
  34589. /**
  34590. * Gets the current render height
  34591. * @param useScreen defines if screen size must be used (or the current render target if any)
  34592. * @returns a number defining the current render height
  34593. */
  34594. getRenderHeight(useScreen?: boolean): number;
  34595. /**
  34596. * Can be used to override the current requestAnimationFrame requester.
  34597. * @hidden
  34598. */
  34599. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34600. /**
  34601. * Register and execute a render loop. The engine can have more than one render function
  34602. * @param renderFunction defines the function to continuously execute
  34603. */
  34604. runRenderLoop(renderFunction: () => void): void;
  34605. /**
  34606. * Clear the current render buffer or the current render target (if any is set up)
  34607. * @param color defines the color to use
  34608. * @param backBuffer defines if the back buffer must be cleared
  34609. * @param depth defines if the depth buffer must be cleared
  34610. * @param stencil defines if the stencil buffer must be cleared
  34611. */
  34612. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34613. private _viewportCached;
  34614. /** @hidden */
  34615. _viewport(x: number, y: number, width: number, height: number): void;
  34616. /**
  34617. * Set the WebGL's viewport
  34618. * @param viewport defines the viewport element to be used
  34619. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34620. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34621. */
  34622. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34623. /**
  34624. * Begin a new frame
  34625. */
  34626. beginFrame(): void;
  34627. /**
  34628. * Enf the current frame
  34629. */
  34630. endFrame(): void;
  34631. /**
  34632. * Resize the view according to the canvas' size
  34633. */
  34634. resize(): void;
  34635. /**
  34636. * Force a specific size of the canvas
  34637. * @param width defines the new canvas' width
  34638. * @param height defines the new canvas' height
  34639. * @returns true if the size was changed
  34640. */
  34641. setSize(width: number, height: number): boolean;
  34642. /**
  34643. * Binds the frame buffer to the specified texture.
  34644. * @param texture The texture to render to or null for the default canvas
  34645. * @param faceIndex The face of the texture to render to in case of cube texture
  34646. * @param requiredWidth The width of the target to render to
  34647. * @param requiredHeight The height of the target to render to
  34648. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34649. * @param lodLevel defines the lod level to bind to the frame buffer
  34650. * @param layer defines the 2d array index to bind to frame buffer to
  34651. */
  34652. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34653. /** @hidden */
  34654. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34655. /**
  34656. * Unbind the current render target texture from the webGL context
  34657. * @param texture defines the render target texture to unbind
  34658. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34659. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34660. */
  34661. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34662. /**
  34663. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34664. */
  34665. flushFramebuffer(): void;
  34666. /**
  34667. * Unbind the current render target and bind the default framebuffer
  34668. */
  34669. restoreDefaultFramebuffer(): void;
  34670. /** @hidden */
  34671. protected _resetVertexBufferBinding(): void;
  34672. /**
  34673. * Creates a vertex buffer
  34674. * @param data the data for the vertex buffer
  34675. * @returns the new WebGL static buffer
  34676. */
  34677. createVertexBuffer(data: DataArray): DataBuffer;
  34678. private _createVertexBuffer;
  34679. /**
  34680. * Creates a dynamic vertex buffer
  34681. * @param data the data for the dynamic vertex buffer
  34682. * @returns the new WebGL dynamic buffer
  34683. */
  34684. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34685. protected _resetIndexBufferBinding(): void;
  34686. /**
  34687. * Creates a new index buffer
  34688. * @param indices defines the content of the index buffer
  34689. * @param updatable defines if the index buffer must be updatable
  34690. * @returns a new webGL buffer
  34691. */
  34692. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34693. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34694. /**
  34695. * Bind a webGL buffer to the webGL context
  34696. * @param buffer defines the buffer to bind
  34697. */
  34698. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34699. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34700. private bindBuffer;
  34701. /**
  34702. * update the bound buffer with the given data
  34703. * @param data defines the data to update
  34704. */
  34705. updateArrayBuffer(data: Float32Array): void;
  34706. private _vertexAttribPointer;
  34707. /** @hidden */
  34708. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34709. private _bindVertexBuffersAttributes;
  34710. /**
  34711. * Records a vertex array object
  34712. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34713. * @param vertexBuffers defines the list of vertex buffers to store
  34714. * @param indexBuffer defines the index buffer to store
  34715. * @param effect defines the effect to store
  34716. * @returns the new vertex array object
  34717. */
  34718. recordVertexArrayObject(vertexBuffers: {
  34719. [key: string]: VertexBuffer;
  34720. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34721. /**
  34722. * Bind a specific vertex array object
  34723. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34724. * @param vertexArrayObject defines the vertex array object to bind
  34725. * @param indexBuffer defines the index buffer to bind
  34726. */
  34727. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34728. /**
  34729. * Bind webGl buffers directly to the webGL context
  34730. * @param vertexBuffer defines the vertex buffer to bind
  34731. * @param indexBuffer defines the index buffer to bind
  34732. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34733. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34734. * @param effect defines the effect associated with the vertex buffer
  34735. */
  34736. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34737. private _unbindVertexArrayObject;
  34738. /**
  34739. * Bind a list of vertex buffers to the webGL context
  34740. * @param vertexBuffers defines the list of vertex buffers to bind
  34741. * @param indexBuffer defines the index buffer to bind
  34742. * @param effect defines the effect associated with the vertex buffers
  34743. */
  34744. bindBuffers(vertexBuffers: {
  34745. [key: string]: Nullable<VertexBuffer>;
  34746. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34747. /**
  34748. * Unbind all instance attributes
  34749. */
  34750. unbindInstanceAttributes(): void;
  34751. /**
  34752. * Release and free the memory of a vertex array object
  34753. * @param vao defines the vertex array object to delete
  34754. */
  34755. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34756. /** @hidden */
  34757. _releaseBuffer(buffer: DataBuffer): boolean;
  34758. protected _deleteBuffer(buffer: DataBuffer): void;
  34759. /**
  34760. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34761. * @param instancesBuffer defines the webGL buffer to update and bind
  34762. * @param data defines the data to store in the buffer
  34763. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34764. */
  34765. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34766. /**
  34767. * Bind the content of a webGL buffer used with instantiation
  34768. * @param instancesBuffer defines the webGL buffer to bind
  34769. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34770. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34771. */
  34772. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34773. /**
  34774. * Disable the instance attribute corresponding to the name in parameter
  34775. * @param name defines the name of the attribute to disable
  34776. */
  34777. disableInstanceAttributeByName(name: string): void;
  34778. /**
  34779. * Disable the instance attribute corresponding to the location in parameter
  34780. * @param attributeLocation defines the attribute location of the attribute to disable
  34781. */
  34782. disableInstanceAttribute(attributeLocation: number): void;
  34783. /**
  34784. * Disable the attribute corresponding to the location in parameter
  34785. * @param attributeLocation defines the attribute location of the attribute to disable
  34786. */
  34787. disableAttributeByIndex(attributeLocation: number): void;
  34788. /**
  34789. * Send a draw order
  34790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34791. * @param indexStart defines the starting index
  34792. * @param indexCount defines the number of index to draw
  34793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34794. */
  34795. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34796. /**
  34797. * Draw a list of points
  34798. * @param verticesStart defines the index of first vertex to draw
  34799. * @param verticesCount defines the count of vertices to draw
  34800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34801. */
  34802. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34803. /**
  34804. * Draw a list of unindexed primitives
  34805. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34806. * @param verticesStart defines the index of first vertex to draw
  34807. * @param verticesCount defines the count of vertices to draw
  34808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34809. */
  34810. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34811. /**
  34812. * Draw a list of indexed primitives
  34813. * @param fillMode defines the primitive to use
  34814. * @param indexStart defines the starting index
  34815. * @param indexCount defines the number of index to draw
  34816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34817. */
  34818. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34819. /**
  34820. * Draw a list of unindexed primitives
  34821. * @param fillMode defines the primitive to use
  34822. * @param verticesStart defines the index of first vertex to draw
  34823. * @param verticesCount defines the count of vertices to draw
  34824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34825. */
  34826. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34827. private _drawMode;
  34828. /** @hidden */
  34829. protected _reportDrawCall(): void;
  34830. /** @hidden */
  34831. _releaseEffect(effect: Effect): void;
  34832. /** @hidden */
  34833. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34834. /**
  34835. * Create a new effect (used to store vertex/fragment shaders)
  34836. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34837. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34838. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34839. * @param samplers defines an array of string used to represent textures
  34840. * @param defines defines the string containing the defines to use to compile the shaders
  34841. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34842. * @param onCompiled defines a function to call when the effect creation is successful
  34843. * @param onError defines a function to call when the effect creation has failed
  34844. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34845. * @returns the new Effect
  34846. */
  34847. 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;
  34848. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34849. private _compileShader;
  34850. private _compileRawShader;
  34851. /** @hidden */
  34852. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34853. /**
  34854. * Directly creates a webGL program
  34855. * @param pipelineContext defines the pipeline context to attach to
  34856. * @param vertexCode defines the vertex shader code to use
  34857. * @param fragmentCode defines the fragment shader code to use
  34858. * @param context defines the webGL context to use (if not set, the current one will be used)
  34859. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34860. * @returns the new webGL program
  34861. */
  34862. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34863. /**
  34864. * Creates a webGL program
  34865. * @param pipelineContext defines the pipeline context to attach to
  34866. * @param vertexCode defines the vertex shader code to use
  34867. * @param fragmentCode defines the fragment shader code to use
  34868. * @param defines defines the string containing the defines to use to compile the shaders
  34869. * @param context defines the webGL context to use (if not set, the current one will be used)
  34870. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34871. * @returns the new webGL program
  34872. */
  34873. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34874. /**
  34875. * Creates a new pipeline context
  34876. * @returns the new pipeline
  34877. */
  34878. createPipelineContext(): IPipelineContext;
  34879. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34880. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34881. /** @hidden */
  34882. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34883. /** @hidden */
  34884. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34885. /** @hidden */
  34886. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34887. /**
  34888. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34889. * @param pipelineContext defines the pipeline context to use
  34890. * @param uniformsNames defines the list of uniform names
  34891. * @returns an array of webGL uniform locations
  34892. */
  34893. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34894. /**
  34895. * Gets the lsit of active attributes for a given webGL program
  34896. * @param pipelineContext defines the pipeline context to use
  34897. * @param attributesNames defines the list of attribute names to get
  34898. * @returns an array of indices indicating the offset of each attribute
  34899. */
  34900. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34901. /**
  34902. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34903. * @param effect defines the effect to activate
  34904. */
  34905. enableEffect(effect: Nullable<Effect>): void;
  34906. /**
  34907. * Set the value of an uniform to a number (int)
  34908. * @param uniform defines the webGL uniform location where to store the value
  34909. * @param value defines the int number to store
  34910. */
  34911. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34912. /**
  34913. * Set the value of an uniform to an array of int32
  34914. * @param uniform defines the webGL uniform location where to store the value
  34915. * @param array defines the array of int32 to store
  34916. */
  34917. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34918. /**
  34919. * Set the value of an uniform to an array of int32 (stored as vec2)
  34920. * @param uniform defines the webGL uniform location where to store the value
  34921. * @param array defines the array of int32 to store
  34922. */
  34923. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34924. /**
  34925. * Set the value of an uniform to an array of int32 (stored as vec3)
  34926. * @param uniform defines the webGL uniform location where to store the value
  34927. * @param array defines the array of int32 to store
  34928. */
  34929. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34930. /**
  34931. * Set the value of an uniform to an array of int32 (stored as vec4)
  34932. * @param uniform defines the webGL uniform location where to store the value
  34933. * @param array defines the array of int32 to store
  34934. */
  34935. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34936. /**
  34937. * Set the value of an uniform to an array of number
  34938. * @param uniform defines the webGL uniform location where to store the value
  34939. * @param array defines the array of number to store
  34940. */
  34941. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34942. /**
  34943. * Set the value of an uniform to an array of number (stored as vec2)
  34944. * @param uniform defines the webGL uniform location where to store the value
  34945. * @param array defines the array of number to store
  34946. */
  34947. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34948. /**
  34949. * Set the value of an uniform to an array of number (stored as vec3)
  34950. * @param uniform defines the webGL uniform location where to store the value
  34951. * @param array defines the array of number to store
  34952. */
  34953. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34954. /**
  34955. * Set the value of an uniform to an array of number (stored as vec4)
  34956. * @param uniform defines the webGL uniform location where to store the value
  34957. * @param array defines the array of number to store
  34958. */
  34959. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34960. /**
  34961. * Set the value of an uniform to an array of float32 (stored as matrices)
  34962. * @param uniform defines the webGL uniform location where to store the value
  34963. * @param matrices defines the array of float32 to store
  34964. */
  34965. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34966. /**
  34967. * Set the value of an uniform to a matrix (3x3)
  34968. * @param uniform defines the webGL uniform location where to store the value
  34969. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34970. */
  34971. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34972. /**
  34973. * Set the value of an uniform to a matrix (2x2)
  34974. * @param uniform defines the webGL uniform location where to store the value
  34975. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34976. */
  34977. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34978. /**
  34979. * Set the value of an uniform to a number (float)
  34980. * @param uniform defines the webGL uniform location where to store the value
  34981. * @param value defines the float number to store
  34982. */
  34983. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34984. /**
  34985. * Set the value of an uniform to a vec2
  34986. * @param uniform defines the webGL uniform location where to store the value
  34987. * @param x defines the 1st component of the value
  34988. * @param y defines the 2nd component of the value
  34989. */
  34990. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34991. /**
  34992. * Set the value of an uniform to a vec3
  34993. * @param uniform defines the webGL uniform location where to store the value
  34994. * @param x defines the 1st component of the value
  34995. * @param y defines the 2nd component of the value
  34996. * @param z defines the 3rd component of the value
  34997. */
  34998. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34999. /**
  35000. * Set the value of an uniform to a vec4
  35001. * @param uniform defines the webGL uniform location where to store the value
  35002. * @param x defines the 1st component of the value
  35003. * @param y defines the 2nd component of the value
  35004. * @param z defines the 3rd component of the value
  35005. * @param w defines the 4th component of the value
  35006. */
  35007. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35008. /**
  35009. * Apply all cached states (depth, culling, stencil and alpha)
  35010. */
  35011. applyStates(): void;
  35012. /**
  35013. * Enable or disable color writing
  35014. * @param enable defines the state to set
  35015. */
  35016. setColorWrite(enable: boolean): void;
  35017. /**
  35018. * Gets a boolean indicating if color writing is enabled
  35019. * @returns the current color writing state
  35020. */
  35021. getColorWrite(): boolean;
  35022. /**
  35023. * Gets the depth culling state manager
  35024. */
  35025. get depthCullingState(): DepthCullingState;
  35026. /**
  35027. * Gets the alpha state manager
  35028. */
  35029. get alphaState(): AlphaState;
  35030. /**
  35031. * Gets the stencil state manager
  35032. */
  35033. get stencilState(): StencilState;
  35034. /**
  35035. * Clears the list of texture accessible through engine.
  35036. * This can help preventing texture load conflict due to name collision.
  35037. */
  35038. clearInternalTexturesCache(): void;
  35039. /**
  35040. * Force the entire cache to be cleared
  35041. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35042. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35043. */
  35044. wipeCaches(bruteForce?: boolean): void;
  35045. /** @hidden */
  35046. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35047. min: number;
  35048. mag: number;
  35049. };
  35050. /** @hidden */
  35051. _createTexture(): WebGLTexture;
  35052. /**
  35053. * Usually called from Texture.ts.
  35054. * Passed information to create a WebGLTexture
  35055. * @param url defines a value which contains one of the following:
  35056. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35057. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35058. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35059. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35060. * @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)
  35061. * @param scene needed for loading to the correct scene
  35062. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35063. * @param onLoad optional callback to be called upon successful completion
  35064. * @param onError optional callback to be called upon failure
  35065. * @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
  35066. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35067. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35068. * @param forcedExtension defines the extension to use to pick the right loader
  35069. * @param mimeType defines an optional mime type
  35070. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35071. */
  35072. 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;
  35073. /**
  35074. * Loads an image as an HTMLImageElement.
  35075. * @param input url string, ArrayBuffer, or Blob to load
  35076. * @param onLoad callback called when the image successfully loads
  35077. * @param onError callback called when the image fails to load
  35078. * @param offlineProvider offline provider for caching
  35079. * @param mimeType optional mime type
  35080. * @returns the HTMLImageElement of the loaded image
  35081. * @hidden
  35082. */
  35083. 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>;
  35084. /**
  35085. * @hidden
  35086. */
  35087. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35088. private _unpackFlipYCached;
  35089. /**
  35090. * In case you are sharing the context with other applications, it might
  35091. * be interested to not cache the unpack flip y state to ensure a consistent
  35092. * value would be set.
  35093. */
  35094. enableUnpackFlipYCached: boolean;
  35095. /** @hidden */
  35096. _unpackFlipY(value: boolean): void;
  35097. /** @hidden */
  35098. _getUnpackAlignement(): number;
  35099. private _getTextureTarget;
  35100. /**
  35101. * Update the sampling mode of a given texture
  35102. * @param samplingMode defines the required sampling mode
  35103. * @param texture defines the texture to update
  35104. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35105. */
  35106. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35107. /**
  35108. * Update the sampling mode of a given texture
  35109. * @param texture defines the texture to update
  35110. * @param wrapU defines the texture wrap mode of the u coordinates
  35111. * @param wrapV defines the texture wrap mode of the v coordinates
  35112. * @param wrapR defines the texture wrap mode of the r coordinates
  35113. */
  35114. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35115. /** @hidden */
  35116. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35117. width: number;
  35118. height: number;
  35119. layers?: number;
  35120. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35121. /** @hidden */
  35122. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35123. /** @hidden */
  35124. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35125. /**
  35126. * Update a portion of an internal texture
  35127. * @param texture defines the texture to update
  35128. * @param imageData defines the data to store into the texture
  35129. * @param xOffset defines the x coordinates of the update rectangle
  35130. * @param yOffset defines the y coordinates of the update rectangle
  35131. * @param width defines the width of the update rectangle
  35132. * @param height defines the height of the update rectangle
  35133. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35134. * @param lod defines the lod level to update (0 by default)
  35135. */
  35136. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35137. /** @hidden */
  35138. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35139. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35140. private _prepareWebGLTexture;
  35141. /** @hidden */
  35142. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35143. private _getDepthStencilBuffer;
  35144. /** @hidden */
  35145. _releaseFramebufferObjects(texture: InternalTexture): void;
  35146. /** @hidden */
  35147. _releaseTexture(texture: InternalTexture): void;
  35148. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35149. protected _setProgram(program: WebGLProgram): void;
  35150. protected _boundUniforms: {
  35151. [key: number]: WebGLUniformLocation;
  35152. };
  35153. /**
  35154. * Binds an effect to the webGL context
  35155. * @param effect defines the effect to bind
  35156. */
  35157. bindSamplers(effect: Effect): void;
  35158. private _activateCurrentTexture;
  35159. /** @hidden */
  35160. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35161. /** @hidden */
  35162. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35163. /**
  35164. * Unbind all textures from the webGL context
  35165. */
  35166. unbindAllTextures(): void;
  35167. /**
  35168. * Sets a texture to the according uniform.
  35169. * @param channel The texture channel
  35170. * @param uniform The uniform to set
  35171. * @param texture The texture to apply
  35172. */
  35173. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35174. private _bindSamplerUniformToChannel;
  35175. private _getTextureWrapMode;
  35176. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35177. /**
  35178. * Sets an array of texture to the webGL context
  35179. * @param channel defines the channel where the texture array must be set
  35180. * @param uniform defines the associated uniform location
  35181. * @param textures defines the array of textures to bind
  35182. */
  35183. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35184. /** @hidden */
  35185. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35186. private _setTextureParameterFloat;
  35187. private _setTextureParameterInteger;
  35188. /**
  35189. * Unbind all vertex attributes from the webGL context
  35190. */
  35191. unbindAllAttributes(): void;
  35192. /**
  35193. * 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
  35194. */
  35195. releaseEffects(): void;
  35196. /**
  35197. * Dispose and release all associated resources
  35198. */
  35199. dispose(): void;
  35200. /**
  35201. * Attach a new callback raised when context lost event is fired
  35202. * @param callback defines the callback to call
  35203. */
  35204. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35205. /**
  35206. * Attach a new callback raised when context restored event is fired
  35207. * @param callback defines the callback to call
  35208. */
  35209. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35210. /**
  35211. * Get the current error code of the webGL context
  35212. * @returns the error code
  35213. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35214. */
  35215. getError(): number;
  35216. private _canRenderToFloatFramebuffer;
  35217. private _canRenderToHalfFloatFramebuffer;
  35218. private _canRenderToFramebuffer;
  35219. /** @hidden */
  35220. _getWebGLTextureType(type: number): number;
  35221. /** @hidden */
  35222. _getInternalFormat(format: number): number;
  35223. /** @hidden */
  35224. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35225. /** @hidden */
  35226. _getRGBAMultiSampleBufferFormat(type: number): number;
  35227. /** @hidden */
  35228. _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;
  35229. /**
  35230. * Loads a file from a url
  35231. * @param url url to load
  35232. * @param onSuccess callback called when the file successfully loads
  35233. * @param onProgress callback called while file is loading (if the server supports this mode)
  35234. * @param offlineProvider defines the offline provider for caching
  35235. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35236. * @param onError callback called when the file fails to load
  35237. * @returns a file request object
  35238. * @hidden
  35239. */
  35240. 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;
  35241. /**
  35242. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35243. * @param x defines the x coordinate of the rectangle where pixels must be read
  35244. * @param y defines the y coordinate of the rectangle where pixels must be read
  35245. * @param width defines the width of the rectangle where pixels must be read
  35246. * @param height defines the height of the rectangle where pixels must be read
  35247. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35248. * @returns a Uint8Array containing RGBA colors
  35249. */
  35250. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35251. private static _isSupported;
  35252. /**
  35253. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35254. * @returns true if the engine can be created
  35255. * @ignorenaming
  35256. */
  35257. static isSupported(): boolean;
  35258. /**
  35259. * Find the next highest power of two.
  35260. * @param x Number to start search from.
  35261. * @return Next highest power of two.
  35262. */
  35263. static CeilingPOT(x: number): number;
  35264. /**
  35265. * Find the next lowest power of two.
  35266. * @param x Number to start search from.
  35267. * @return Next lowest power of two.
  35268. */
  35269. static FloorPOT(x: number): number;
  35270. /**
  35271. * Find the nearest power of two.
  35272. * @param x Number to start search from.
  35273. * @return Next nearest power of two.
  35274. */
  35275. static NearestPOT(x: number): number;
  35276. /**
  35277. * Get the closest exponent of two
  35278. * @param value defines the value to approximate
  35279. * @param max defines the maximum value to return
  35280. * @param mode defines how to define the closest value
  35281. * @returns closest exponent of two of the given value
  35282. */
  35283. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35284. /**
  35285. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35286. * @param func - the function to be called
  35287. * @param requester - the object that will request the next frame. Falls back to window.
  35288. * @returns frame number
  35289. */
  35290. static QueueNewFrame(func: () => void, requester?: any): number;
  35291. /**
  35292. * Gets host document
  35293. * @returns the host document object
  35294. */
  35295. getHostDocument(): Nullable<Document>;
  35296. }
  35297. }
  35298. declare module BABYLON {
  35299. /**
  35300. * Class representing spherical harmonics coefficients to the 3rd degree
  35301. */
  35302. export class SphericalHarmonics {
  35303. /**
  35304. * Defines whether or not the harmonics have been prescaled for rendering.
  35305. */
  35306. preScaled: boolean;
  35307. /**
  35308. * The l0,0 coefficients of the spherical harmonics
  35309. */
  35310. l00: Vector3;
  35311. /**
  35312. * The l1,-1 coefficients of the spherical harmonics
  35313. */
  35314. l1_1: Vector3;
  35315. /**
  35316. * The l1,0 coefficients of the spherical harmonics
  35317. */
  35318. l10: Vector3;
  35319. /**
  35320. * The l1,1 coefficients of the spherical harmonics
  35321. */
  35322. l11: Vector3;
  35323. /**
  35324. * The l2,-2 coefficients of the spherical harmonics
  35325. */
  35326. l2_2: Vector3;
  35327. /**
  35328. * The l2,-1 coefficients of the spherical harmonics
  35329. */
  35330. l2_1: Vector3;
  35331. /**
  35332. * The l2,0 coefficients of the spherical harmonics
  35333. */
  35334. l20: Vector3;
  35335. /**
  35336. * The l2,1 coefficients of the spherical harmonics
  35337. */
  35338. l21: Vector3;
  35339. /**
  35340. * The l2,2 coefficients of the spherical harmonics
  35341. */
  35342. l22: Vector3;
  35343. /**
  35344. * Adds a light to the spherical harmonics
  35345. * @param direction the direction of the light
  35346. * @param color the color of the light
  35347. * @param deltaSolidAngle the delta solid angle of the light
  35348. */
  35349. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35350. /**
  35351. * Scales the spherical harmonics by the given amount
  35352. * @param scale the amount to scale
  35353. */
  35354. scaleInPlace(scale: number): void;
  35355. /**
  35356. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35357. *
  35358. * ```
  35359. * E_lm = A_l * L_lm
  35360. * ```
  35361. *
  35362. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35363. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35364. * the scaling factors are given in equation 9.
  35365. */
  35366. convertIncidentRadianceToIrradiance(): void;
  35367. /**
  35368. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35369. *
  35370. * ```
  35371. * L = (1/pi) * E * rho
  35372. * ```
  35373. *
  35374. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35375. */
  35376. convertIrradianceToLambertianRadiance(): void;
  35377. /**
  35378. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35379. * required operations at run time.
  35380. *
  35381. * This is simply done by scaling back the SH with Ylm constants parameter.
  35382. * The trigonometric part being applied by the shader at run time.
  35383. */
  35384. preScaleForRendering(): void;
  35385. /**
  35386. * Constructs a spherical harmonics from an array.
  35387. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35388. * @returns the spherical harmonics
  35389. */
  35390. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35391. /**
  35392. * Gets the spherical harmonics from polynomial
  35393. * @param polynomial the spherical polynomial
  35394. * @returns the spherical harmonics
  35395. */
  35396. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35397. }
  35398. /**
  35399. * Class representing spherical polynomial coefficients to the 3rd degree
  35400. */
  35401. export class SphericalPolynomial {
  35402. private _harmonics;
  35403. /**
  35404. * The spherical harmonics used to create the polynomials.
  35405. */
  35406. get preScaledHarmonics(): SphericalHarmonics;
  35407. /**
  35408. * The x coefficients of the spherical polynomial
  35409. */
  35410. x: Vector3;
  35411. /**
  35412. * The y coefficients of the spherical polynomial
  35413. */
  35414. y: Vector3;
  35415. /**
  35416. * The z coefficients of the spherical polynomial
  35417. */
  35418. z: Vector3;
  35419. /**
  35420. * The xx coefficients of the spherical polynomial
  35421. */
  35422. xx: Vector3;
  35423. /**
  35424. * The yy coefficients of the spherical polynomial
  35425. */
  35426. yy: Vector3;
  35427. /**
  35428. * The zz coefficients of the spherical polynomial
  35429. */
  35430. zz: Vector3;
  35431. /**
  35432. * The xy coefficients of the spherical polynomial
  35433. */
  35434. xy: Vector3;
  35435. /**
  35436. * The yz coefficients of the spherical polynomial
  35437. */
  35438. yz: Vector3;
  35439. /**
  35440. * The zx coefficients of the spherical polynomial
  35441. */
  35442. zx: Vector3;
  35443. /**
  35444. * Adds an ambient color to the spherical polynomial
  35445. * @param color the color to add
  35446. */
  35447. addAmbient(color: Color3): void;
  35448. /**
  35449. * Scales the spherical polynomial by the given amount
  35450. * @param scale the amount to scale
  35451. */
  35452. scaleInPlace(scale: number): void;
  35453. /**
  35454. * Gets the spherical polynomial from harmonics
  35455. * @param harmonics the spherical harmonics
  35456. * @returns the spherical polynomial
  35457. */
  35458. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35459. /**
  35460. * Constructs a spherical polynomial from an array.
  35461. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35462. * @returns the spherical polynomial
  35463. */
  35464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35465. }
  35466. }
  35467. declare module BABYLON {
  35468. /**
  35469. * Defines the source of the internal texture
  35470. */
  35471. export enum InternalTextureSource {
  35472. /**
  35473. * The source of the texture data is unknown
  35474. */
  35475. Unknown = 0,
  35476. /**
  35477. * Texture data comes from an URL
  35478. */
  35479. Url = 1,
  35480. /**
  35481. * Texture data is only used for temporary storage
  35482. */
  35483. Temp = 2,
  35484. /**
  35485. * Texture data comes from raw data (ArrayBuffer)
  35486. */
  35487. Raw = 3,
  35488. /**
  35489. * Texture content is dynamic (video or dynamic texture)
  35490. */
  35491. Dynamic = 4,
  35492. /**
  35493. * Texture content is generated by rendering to it
  35494. */
  35495. RenderTarget = 5,
  35496. /**
  35497. * Texture content is part of a multi render target process
  35498. */
  35499. MultiRenderTarget = 6,
  35500. /**
  35501. * Texture data comes from a cube data file
  35502. */
  35503. Cube = 7,
  35504. /**
  35505. * Texture data comes from a raw cube data
  35506. */
  35507. CubeRaw = 8,
  35508. /**
  35509. * Texture data come from a prefiltered cube data file
  35510. */
  35511. CubePrefiltered = 9,
  35512. /**
  35513. * Texture content is raw 3D data
  35514. */
  35515. Raw3D = 10,
  35516. /**
  35517. * Texture content is raw 2D array data
  35518. */
  35519. Raw2DArray = 11,
  35520. /**
  35521. * Texture content is a depth texture
  35522. */
  35523. Depth = 12,
  35524. /**
  35525. * Texture data comes from a raw cube data encoded with RGBD
  35526. */
  35527. CubeRawRGBD = 13
  35528. }
  35529. /**
  35530. * Class used to store data associated with WebGL texture data for the engine
  35531. * This class should not be used directly
  35532. */
  35533. export class InternalTexture {
  35534. /** @hidden */
  35535. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35536. /**
  35537. * Defines if the texture is ready
  35538. */
  35539. isReady: boolean;
  35540. /**
  35541. * Defines if the texture is a cube texture
  35542. */
  35543. isCube: boolean;
  35544. /**
  35545. * Defines if the texture contains 3D data
  35546. */
  35547. is3D: boolean;
  35548. /**
  35549. * Defines if the texture contains 2D array data
  35550. */
  35551. is2DArray: boolean;
  35552. /**
  35553. * Defines if the texture contains multiview data
  35554. */
  35555. isMultiview: boolean;
  35556. /**
  35557. * Gets the URL used to load this texture
  35558. */
  35559. url: string;
  35560. /**
  35561. * Gets the sampling mode of the texture
  35562. */
  35563. samplingMode: number;
  35564. /**
  35565. * Gets a boolean indicating if the texture needs mipmaps generation
  35566. */
  35567. generateMipMaps: boolean;
  35568. /**
  35569. * Gets the number of samples used by the texture (WebGL2+ only)
  35570. */
  35571. samples: number;
  35572. /**
  35573. * Gets the type of the texture (int, float...)
  35574. */
  35575. type: number;
  35576. /**
  35577. * Gets the format of the texture (RGB, RGBA...)
  35578. */
  35579. format: number;
  35580. /**
  35581. * Observable called when the texture is loaded
  35582. */
  35583. onLoadedObservable: Observable<InternalTexture>;
  35584. /**
  35585. * Gets the width of the texture
  35586. */
  35587. width: number;
  35588. /**
  35589. * Gets the height of the texture
  35590. */
  35591. height: number;
  35592. /**
  35593. * Gets the depth of the texture
  35594. */
  35595. depth: number;
  35596. /**
  35597. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35598. */
  35599. baseWidth: number;
  35600. /**
  35601. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35602. */
  35603. baseHeight: number;
  35604. /**
  35605. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35606. */
  35607. baseDepth: number;
  35608. /**
  35609. * Gets a boolean indicating if the texture is inverted on Y axis
  35610. */
  35611. invertY: boolean;
  35612. /** @hidden */
  35613. _invertVScale: boolean;
  35614. /** @hidden */
  35615. _associatedChannel: number;
  35616. /** @hidden */
  35617. _source: InternalTextureSource;
  35618. /** @hidden */
  35619. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35620. /** @hidden */
  35621. _bufferView: Nullable<ArrayBufferView>;
  35622. /** @hidden */
  35623. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35624. /** @hidden */
  35625. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35626. /** @hidden */
  35627. _size: number;
  35628. /** @hidden */
  35629. _extension: string;
  35630. /** @hidden */
  35631. _files: Nullable<string[]>;
  35632. /** @hidden */
  35633. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35634. /** @hidden */
  35635. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35636. /** @hidden */
  35637. _framebuffer: Nullable<WebGLFramebuffer>;
  35638. /** @hidden */
  35639. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35640. /** @hidden */
  35641. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35642. /** @hidden */
  35643. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35644. /** @hidden */
  35645. _attachments: Nullable<number[]>;
  35646. /** @hidden */
  35647. _textureArray: Nullable<InternalTexture[]>;
  35648. /** @hidden */
  35649. _cachedCoordinatesMode: Nullable<number>;
  35650. /** @hidden */
  35651. _cachedWrapU: Nullable<number>;
  35652. /** @hidden */
  35653. _cachedWrapV: Nullable<number>;
  35654. /** @hidden */
  35655. _cachedWrapR: Nullable<number>;
  35656. /** @hidden */
  35657. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35658. /** @hidden */
  35659. _isDisabled: boolean;
  35660. /** @hidden */
  35661. _compression: Nullable<string>;
  35662. /** @hidden */
  35663. _generateStencilBuffer: boolean;
  35664. /** @hidden */
  35665. _generateDepthBuffer: boolean;
  35666. /** @hidden */
  35667. _comparisonFunction: number;
  35668. /** @hidden */
  35669. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35670. /** @hidden */
  35671. _lodGenerationScale: number;
  35672. /** @hidden */
  35673. _lodGenerationOffset: number;
  35674. /** @hidden */
  35675. _depthStencilTexture: Nullable<InternalTexture>;
  35676. /** @hidden */
  35677. _colorTextureArray: Nullable<WebGLTexture>;
  35678. /** @hidden */
  35679. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35680. /** @hidden */
  35681. _lodTextureHigh: Nullable<BaseTexture>;
  35682. /** @hidden */
  35683. _lodTextureMid: Nullable<BaseTexture>;
  35684. /** @hidden */
  35685. _lodTextureLow: Nullable<BaseTexture>;
  35686. /** @hidden */
  35687. _isRGBD: boolean;
  35688. /** @hidden */
  35689. _linearSpecularLOD: boolean;
  35690. /** @hidden */
  35691. _irradianceTexture: Nullable<BaseTexture>;
  35692. /** @hidden */
  35693. _webGLTexture: Nullable<WebGLTexture>;
  35694. /** @hidden */
  35695. _references: number;
  35696. private _engine;
  35697. /**
  35698. * Gets the Engine the texture belongs to.
  35699. * @returns The babylon engine
  35700. */
  35701. getEngine(): ThinEngine;
  35702. /**
  35703. * Gets the data source type of the texture
  35704. */
  35705. get source(): InternalTextureSource;
  35706. /**
  35707. * Creates a new InternalTexture
  35708. * @param engine defines the engine to use
  35709. * @param source defines the type of data that will be used
  35710. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35711. */
  35712. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35713. /**
  35714. * Increments the number of references (ie. the number of Texture that point to it)
  35715. */
  35716. incrementReferences(): void;
  35717. /**
  35718. * Change the size of the texture (not the size of the content)
  35719. * @param width defines the new width
  35720. * @param height defines the new height
  35721. * @param depth defines the new depth (1 by default)
  35722. */
  35723. updateSize(width: int, height: int, depth?: int): void;
  35724. /** @hidden */
  35725. _rebuild(): void;
  35726. /** @hidden */
  35727. _swapAndDie(target: InternalTexture): void;
  35728. /**
  35729. * Dispose the current allocated resources
  35730. */
  35731. dispose(): void;
  35732. }
  35733. }
  35734. declare module BABYLON {
  35735. /**
  35736. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35737. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35738. */
  35739. export class Analyser {
  35740. /**
  35741. * Gets or sets the smoothing
  35742. * @ignorenaming
  35743. */
  35744. SMOOTHING: number;
  35745. /**
  35746. * Gets or sets the FFT table size
  35747. * @ignorenaming
  35748. */
  35749. FFT_SIZE: number;
  35750. /**
  35751. * Gets or sets the bar graph amplitude
  35752. * @ignorenaming
  35753. */
  35754. BARGRAPHAMPLITUDE: number;
  35755. /**
  35756. * Gets or sets the position of the debug canvas
  35757. * @ignorenaming
  35758. */
  35759. DEBUGCANVASPOS: {
  35760. x: number;
  35761. y: number;
  35762. };
  35763. /**
  35764. * Gets or sets the debug canvas size
  35765. * @ignorenaming
  35766. */
  35767. DEBUGCANVASSIZE: {
  35768. width: number;
  35769. height: number;
  35770. };
  35771. private _byteFreqs;
  35772. private _byteTime;
  35773. private _floatFreqs;
  35774. private _webAudioAnalyser;
  35775. private _debugCanvas;
  35776. private _debugCanvasContext;
  35777. private _scene;
  35778. private _registerFunc;
  35779. private _audioEngine;
  35780. /**
  35781. * Creates a new analyser
  35782. * @param scene defines hosting scene
  35783. */
  35784. constructor(scene: Scene);
  35785. /**
  35786. * Get the number of data values you will have to play with for the visualization
  35787. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35788. * @returns a number
  35789. */
  35790. getFrequencyBinCount(): number;
  35791. /**
  35792. * Gets the current frequency data as a byte array
  35793. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35794. * @returns a Uint8Array
  35795. */
  35796. getByteFrequencyData(): Uint8Array;
  35797. /**
  35798. * Gets the current waveform as a byte array
  35799. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35800. * @returns a Uint8Array
  35801. */
  35802. getByteTimeDomainData(): Uint8Array;
  35803. /**
  35804. * Gets the current frequency data as a float array
  35805. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35806. * @returns a Float32Array
  35807. */
  35808. getFloatFrequencyData(): Float32Array;
  35809. /**
  35810. * Renders the debug canvas
  35811. */
  35812. drawDebugCanvas(): void;
  35813. /**
  35814. * Stops rendering the debug canvas and removes it
  35815. */
  35816. stopDebugCanvas(): void;
  35817. /**
  35818. * Connects two audio nodes
  35819. * @param inputAudioNode defines first node to connect
  35820. * @param outputAudioNode defines second node to connect
  35821. */
  35822. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35823. /**
  35824. * Releases all associated resources
  35825. */
  35826. dispose(): void;
  35827. }
  35828. }
  35829. declare module BABYLON {
  35830. /**
  35831. * This represents an audio engine and it is responsible
  35832. * to play, synchronize and analyse sounds throughout the application.
  35833. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35834. */
  35835. export interface IAudioEngine extends IDisposable {
  35836. /**
  35837. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35838. */
  35839. readonly canUseWebAudio: boolean;
  35840. /**
  35841. * Gets the current AudioContext if available.
  35842. */
  35843. readonly audioContext: Nullable<AudioContext>;
  35844. /**
  35845. * The master gain node defines the global audio volume of your audio engine.
  35846. */
  35847. readonly masterGain: GainNode;
  35848. /**
  35849. * Gets whether or not mp3 are supported by your browser.
  35850. */
  35851. readonly isMP3supported: boolean;
  35852. /**
  35853. * Gets whether or not ogg are supported by your browser.
  35854. */
  35855. readonly isOGGsupported: boolean;
  35856. /**
  35857. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35858. * @ignoreNaming
  35859. */
  35860. WarnedWebAudioUnsupported: boolean;
  35861. /**
  35862. * Defines if the audio engine relies on a custom unlocked button.
  35863. * In this case, the embedded button will not be displayed.
  35864. */
  35865. useCustomUnlockedButton: boolean;
  35866. /**
  35867. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35868. */
  35869. readonly unlocked: boolean;
  35870. /**
  35871. * Event raised when audio has been unlocked on the browser.
  35872. */
  35873. onAudioUnlockedObservable: Observable<AudioEngine>;
  35874. /**
  35875. * Event raised when audio has been locked on the browser.
  35876. */
  35877. onAudioLockedObservable: Observable<AudioEngine>;
  35878. /**
  35879. * Flags the audio engine in Locked state.
  35880. * This happens due to new browser policies preventing audio to autoplay.
  35881. */
  35882. lock(): void;
  35883. /**
  35884. * Unlocks the audio engine once a user action has been done on the dom.
  35885. * This is helpful to resume play once browser policies have been satisfied.
  35886. */
  35887. unlock(): void;
  35888. /**
  35889. * Gets the global volume sets on the master gain.
  35890. * @returns the global volume if set or -1 otherwise
  35891. */
  35892. getGlobalVolume(): number;
  35893. /**
  35894. * Sets the global volume of your experience (sets on the master gain).
  35895. * @param newVolume Defines the new global volume of the application
  35896. */
  35897. setGlobalVolume(newVolume: number): void;
  35898. /**
  35899. * Connect the audio engine to an audio analyser allowing some amazing
  35900. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35901. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35902. * @param analyser The analyser to connect to the engine
  35903. */
  35904. connectToAnalyser(analyser: Analyser): void;
  35905. }
  35906. /**
  35907. * This represents the default audio engine used in babylon.
  35908. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35909. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35910. */
  35911. export class AudioEngine implements IAudioEngine {
  35912. private _audioContext;
  35913. private _audioContextInitialized;
  35914. private _muteButton;
  35915. private _hostElement;
  35916. /**
  35917. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35918. */
  35919. canUseWebAudio: boolean;
  35920. /**
  35921. * The master gain node defines the global audio volume of your audio engine.
  35922. */
  35923. masterGain: GainNode;
  35924. /**
  35925. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35926. * @ignoreNaming
  35927. */
  35928. WarnedWebAudioUnsupported: boolean;
  35929. /**
  35930. * Gets whether or not mp3 are supported by your browser.
  35931. */
  35932. isMP3supported: boolean;
  35933. /**
  35934. * Gets whether or not ogg are supported by your browser.
  35935. */
  35936. isOGGsupported: boolean;
  35937. /**
  35938. * Gets whether audio has been unlocked on the device.
  35939. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35940. * a user interaction has happened.
  35941. */
  35942. unlocked: boolean;
  35943. /**
  35944. * Defines if the audio engine relies on a custom unlocked button.
  35945. * In this case, the embedded button will not be displayed.
  35946. */
  35947. useCustomUnlockedButton: boolean;
  35948. /**
  35949. * Event raised when audio has been unlocked on the browser.
  35950. */
  35951. onAudioUnlockedObservable: Observable<AudioEngine>;
  35952. /**
  35953. * Event raised when audio has been locked on the browser.
  35954. */
  35955. onAudioLockedObservable: Observable<AudioEngine>;
  35956. /**
  35957. * Gets the current AudioContext if available.
  35958. */
  35959. get audioContext(): Nullable<AudioContext>;
  35960. private _connectedAnalyser;
  35961. /**
  35962. * Instantiates a new audio engine.
  35963. *
  35964. * There should be only one per page as some browsers restrict the number
  35965. * of audio contexts you can create.
  35966. * @param hostElement defines the host element where to display the mute icon if necessary
  35967. */
  35968. constructor(hostElement?: Nullable<HTMLElement>);
  35969. /**
  35970. * Flags the audio engine in Locked state.
  35971. * This happens due to new browser policies preventing audio to autoplay.
  35972. */
  35973. lock(): void;
  35974. /**
  35975. * Unlocks the audio engine once a user action has been done on the dom.
  35976. * This is helpful to resume play once browser policies have been satisfied.
  35977. */
  35978. unlock(): void;
  35979. private _resumeAudioContext;
  35980. private _initializeAudioContext;
  35981. private _tryToRun;
  35982. private _triggerRunningState;
  35983. private _triggerSuspendedState;
  35984. private _displayMuteButton;
  35985. private _moveButtonToTopLeft;
  35986. private _onResize;
  35987. private _hideMuteButton;
  35988. /**
  35989. * Destroy and release the resources associated with the audio ccontext.
  35990. */
  35991. dispose(): void;
  35992. /**
  35993. * Gets the global volume sets on the master gain.
  35994. * @returns the global volume if set or -1 otherwise
  35995. */
  35996. getGlobalVolume(): number;
  35997. /**
  35998. * Sets the global volume of your experience (sets on the master gain).
  35999. * @param newVolume Defines the new global volume of the application
  36000. */
  36001. setGlobalVolume(newVolume: number): void;
  36002. /**
  36003. * Connect the audio engine to an audio analyser allowing some amazing
  36004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36005. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36006. * @param analyser The analyser to connect to the engine
  36007. */
  36008. connectToAnalyser(analyser: Analyser): void;
  36009. }
  36010. }
  36011. declare module BABYLON {
  36012. /**
  36013. * Interface used to present a loading screen while loading a scene
  36014. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36015. */
  36016. export interface ILoadingScreen {
  36017. /**
  36018. * Function called to display the loading screen
  36019. */
  36020. displayLoadingUI: () => void;
  36021. /**
  36022. * Function called to hide the loading screen
  36023. */
  36024. hideLoadingUI: () => void;
  36025. /**
  36026. * Gets or sets the color to use for the background
  36027. */
  36028. loadingUIBackgroundColor: string;
  36029. /**
  36030. * Gets or sets the text to display while loading
  36031. */
  36032. loadingUIText: string;
  36033. }
  36034. /**
  36035. * Class used for the default loading screen
  36036. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36037. */
  36038. export class DefaultLoadingScreen implements ILoadingScreen {
  36039. private _renderingCanvas;
  36040. private _loadingText;
  36041. private _loadingDivBackgroundColor;
  36042. private _loadingDiv;
  36043. private _loadingTextDiv;
  36044. /** Gets or sets the logo url to use for the default loading screen */
  36045. static DefaultLogoUrl: string;
  36046. /** Gets or sets the spinner url to use for the default loading screen */
  36047. static DefaultSpinnerUrl: string;
  36048. /**
  36049. * Creates a new default loading screen
  36050. * @param _renderingCanvas defines the canvas used to render the scene
  36051. * @param _loadingText defines the default text to display
  36052. * @param _loadingDivBackgroundColor defines the default background color
  36053. */
  36054. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36055. /**
  36056. * Function called to display the loading screen
  36057. */
  36058. displayLoadingUI(): void;
  36059. /**
  36060. * Function called to hide the loading screen
  36061. */
  36062. hideLoadingUI(): void;
  36063. /**
  36064. * Gets or sets the text to display while loading
  36065. */
  36066. set loadingUIText(text: string);
  36067. get loadingUIText(): string;
  36068. /**
  36069. * Gets or sets the color to use for the background
  36070. */
  36071. get loadingUIBackgroundColor(): string;
  36072. set loadingUIBackgroundColor(color: string);
  36073. private _resizeLoadingUI;
  36074. }
  36075. }
  36076. declare module BABYLON {
  36077. /**
  36078. * Interface for any object that can request an animation frame
  36079. */
  36080. export interface ICustomAnimationFrameRequester {
  36081. /**
  36082. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36083. */
  36084. renderFunction?: Function;
  36085. /**
  36086. * Called to request the next frame to render to
  36087. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36088. */
  36089. requestAnimationFrame: Function;
  36090. /**
  36091. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36092. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36093. */
  36094. requestID?: number;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36100. */
  36101. export class PerformanceMonitor {
  36102. private _enabled;
  36103. private _rollingFrameTime;
  36104. private _lastFrameTimeMs;
  36105. /**
  36106. * constructor
  36107. * @param frameSampleSize The number of samples required to saturate the sliding window
  36108. */
  36109. constructor(frameSampleSize?: number);
  36110. /**
  36111. * Samples current frame
  36112. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36113. */
  36114. sampleFrame(timeMs?: number): void;
  36115. /**
  36116. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36117. */
  36118. get averageFrameTime(): number;
  36119. /**
  36120. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36121. */
  36122. get averageFrameTimeVariance(): number;
  36123. /**
  36124. * Returns the frame time of the most recent frame
  36125. */
  36126. get instantaneousFrameTime(): number;
  36127. /**
  36128. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36129. */
  36130. get averageFPS(): number;
  36131. /**
  36132. * Returns the average framerate in frames per second using the most recent frame time
  36133. */
  36134. get instantaneousFPS(): number;
  36135. /**
  36136. * Returns true if enough samples have been taken to completely fill the sliding window
  36137. */
  36138. get isSaturated(): boolean;
  36139. /**
  36140. * Enables contributions to the sliding window sample set
  36141. */
  36142. enable(): void;
  36143. /**
  36144. * Disables contributions to the sliding window sample set
  36145. * Samples will not be interpolated over the disabled period
  36146. */
  36147. disable(): void;
  36148. /**
  36149. * Returns true if sampling is enabled
  36150. */
  36151. get isEnabled(): boolean;
  36152. /**
  36153. * Resets performance monitor
  36154. */
  36155. reset(): void;
  36156. }
  36157. /**
  36158. * RollingAverage
  36159. *
  36160. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36161. */
  36162. export class RollingAverage {
  36163. /**
  36164. * Current average
  36165. */
  36166. average: number;
  36167. /**
  36168. * Current variance
  36169. */
  36170. variance: number;
  36171. protected _samples: Array<number>;
  36172. protected _sampleCount: number;
  36173. protected _pos: number;
  36174. protected _m2: number;
  36175. /**
  36176. * constructor
  36177. * @param length The number of samples required to saturate the sliding window
  36178. */
  36179. constructor(length: number);
  36180. /**
  36181. * Adds a sample to the sample set
  36182. * @param v The sample value
  36183. */
  36184. add(v: number): void;
  36185. /**
  36186. * Returns previously added values or null if outside of history or outside the sliding window domain
  36187. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36188. * @return Value previously recorded with add() or null if outside of range
  36189. */
  36190. history(i: number): number;
  36191. /**
  36192. * Returns true if enough samples have been taken to completely fill the sliding window
  36193. * @return true if sample-set saturated
  36194. */
  36195. isSaturated(): boolean;
  36196. /**
  36197. * Resets the rolling average (equivalent to 0 samples taken so far)
  36198. */
  36199. reset(): void;
  36200. /**
  36201. * Wraps a value around the sample range boundaries
  36202. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36203. * @return Wrapped position in sample range
  36204. */
  36205. protected _wrapPosition(i: number): number;
  36206. }
  36207. }
  36208. declare module BABYLON {
  36209. /**
  36210. * This class is used to track a performance counter which is number based.
  36211. * The user has access to many properties which give statistics of different nature.
  36212. *
  36213. * The implementer can track two kinds of Performance Counter: time and count.
  36214. * 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.
  36215. * 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.
  36216. */
  36217. export class PerfCounter {
  36218. /**
  36219. * Gets or sets a global boolean to turn on and off all the counters
  36220. */
  36221. static Enabled: boolean;
  36222. /**
  36223. * Returns the smallest value ever
  36224. */
  36225. get min(): number;
  36226. /**
  36227. * Returns the biggest value ever
  36228. */
  36229. get max(): number;
  36230. /**
  36231. * Returns the average value since the performance counter is running
  36232. */
  36233. get average(): number;
  36234. /**
  36235. * Returns the average value of the last second the counter was monitored
  36236. */
  36237. get lastSecAverage(): number;
  36238. /**
  36239. * Returns the current value
  36240. */
  36241. get current(): number;
  36242. /**
  36243. * Gets the accumulated total
  36244. */
  36245. get total(): number;
  36246. /**
  36247. * Gets the total value count
  36248. */
  36249. get count(): number;
  36250. /**
  36251. * Creates a new counter
  36252. */
  36253. constructor();
  36254. /**
  36255. * Call this method to start monitoring a new frame.
  36256. * 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.
  36257. */
  36258. fetchNewFrame(): void;
  36259. /**
  36260. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36261. * @param newCount the count value to add to the monitored count
  36262. * @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.
  36263. */
  36264. addCount(newCount: number, fetchResult: boolean): void;
  36265. /**
  36266. * Start monitoring this performance counter
  36267. */
  36268. beginMonitoring(): void;
  36269. /**
  36270. * Compute the time lapsed since the previous beginMonitoring() call.
  36271. * @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
  36272. */
  36273. endMonitoring(newFrame?: boolean): void;
  36274. private _fetchResult;
  36275. private _startMonitoringTime;
  36276. private _min;
  36277. private _max;
  36278. private _average;
  36279. private _current;
  36280. private _totalValueCount;
  36281. private _totalAccumulated;
  36282. private _lastSecAverage;
  36283. private _lastSecAccumulated;
  36284. private _lastSecTime;
  36285. private _lastSecValueCount;
  36286. }
  36287. }
  36288. declare module BABYLON {
  36289. interface ThinEngine {
  36290. /**
  36291. * Sets alpha constants used by some alpha blending modes
  36292. * @param r defines the red component
  36293. * @param g defines the green component
  36294. * @param b defines the blue component
  36295. * @param a defines the alpha component
  36296. */
  36297. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36298. /**
  36299. * Sets the current alpha mode
  36300. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36301. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36302. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36303. */
  36304. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36305. /**
  36306. * Gets the current alpha mode
  36307. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36308. * @returns the current alpha mode
  36309. */
  36310. getAlphaMode(): number;
  36311. /**
  36312. * Sets the current alpha equation
  36313. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36314. */
  36315. setAlphaEquation(equation: number): void;
  36316. /**
  36317. * Gets the current alpha equation.
  36318. * @returns the current alpha equation
  36319. */
  36320. getAlphaEquation(): number;
  36321. }
  36322. }
  36323. declare module BABYLON {
  36324. interface ThinEngine {
  36325. /** @hidden */
  36326. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36327. }
  36328. }
  36329. declare module BABYLON {
  36330. /**
  36331. * Defines the interface used by display changed events
  36332. */
  36333. export interface IDisplayChangedEventArgs {
  36334. /** Gets the vrDisplay object (if any) */
  36335. vrDisplay: Nullable<any>;
  36336. /** Gets a boolean indicating if webVR is supported */
  36337. vrSupported: boolean;
  36338. }
  36339. /**
  36340. * Defines the interface used by objects containing a viewport (like a camera)
  36341. */
  36342. interface IViewportOwnerLike {
  36343. /**
  36344. * Gets or sets the viewport
  36345. */
  36346. viewport: IViewportLike;
  36347. }
  36348. /**
  36349. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36350. */
  36351. export class Engine extends ThinEngine {
  36352. /** Defines that alpha blending is disabled */
  36353. static readonly ALPHA_DISABLE: number;
  36354. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36355. static readonly ALPHA_ADD: number;
  36356. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36357. static readonly ALPHA_COMBINE: number;
  36358. /** Defines that alpha blending to DEST - SRC * DEST */
  36359. static readonly ALPHA_SUBTRACT: number;
  36360. /** Defines that alpha blending to SRC * DEST */
  36361. static readonly ALPHA_MULTIPLY: number;
  36362. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36363. static readonly ALPHA_MAXIMIZED: number;
  36364. /** Defines that alpha blending to SRC + DEST */
  36365. static readonly ALPHA_ONEONE: number;
  36366. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36367. static readonly ALPHA_PREMULTIPLIED: number;
  36368. /**
  36369. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36370. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36371. */
  36372. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36373. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36374. static readonly ALPHA_INTERPOLATE: number;
  36375. /**
  36376. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36377. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36378. */
  36379. static readonly ALPHA_SCREENMODE: number;
  36380. /** Defines that the ressource is not delayed*/
  36381. static readonly DELAYLOADSTATE_NONE: number;
  36382. /** Defines that the ressource was successfully delay loaded */
  36383. static readonly DELAYLOADSTATE_LOADED: number;
  36384. /** Defines that the ressource is currently delay loading */
  36385. static readonly DELAYLOADSTATE_LOADING: number;
  36386. /** Defines that the ressource is delayed and has not started loading */
  36387. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36388. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36389. static readonly NEVER: number;
  36390. /** 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 */
  36391. static readonly ALWAYS: number;
  36392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36393. static readonly LESS: number;
  36394. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36395. static readonly EQUAL: number;
  36396. /** 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 */
  36397. static readonly LEQUAL: number;
  36398. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36399. static readonly GREATER: number;
  36400. /** 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 */
  36401. static readonly GEQUAL: number;
  36402. /** 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 */
  36403. static readonly NOTEQUAL: number;
  36404. /** Passed to stencilOperation to specify that stencil value must be kept */
  36405. static readonly KEEP: number;
  36406. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36407. static readonly REPLACE: number;
  36408. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36409. static readonly INCR: number;
  36410. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36411. static readonly DECR: number;
  36412. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36413. static readonly INVERT: number;
  36414. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36415. static readonly INCR_WRAP: number;
  36416. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36417. static readonly DECR_WRAP: number;
  36418. /** Texture is not repeating outside of 0..1 UVs */
  36419. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36420. /** Texture is repeating outside of 0..1 UVs */
  36421. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36422. /** Texture is repeating and mirrored */
  36423. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36424. /** ALPHA */
  36425. static readonly TEXTUREFORMAT_ALPHA: number;
  36426. /** LUMINANCE */
  36427. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36428. /** LUMINANCE_ALPHA */
  36429. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36430. /** RGB */
  36431. static readonly TEXTUREFORMAT_RGB: number;
  36432. /** RGBA */
  36433. static readonly TEXTUREFORMAT_RGBA: number;
  36434. /** RED */
  36435. static readonly TEXTUREFORMAT_RED: number;
  36436. /** RED (2nd reference) */
  36437. static readonly TEXTUREFORMAT_R: number;
  36438. /** RG */
  36439. static readonly TEXTUREFORMAT_RG: number;
  36440. /** RED_INTEGER */
  36441. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36442. /** RED_INTEGER (2nd reference) */
  36443. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36444. /** RG_INTEGER */
  36445. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36446. /** RGB_INTEGER */
  36447. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36448. /** RGBA_INTEGER */
  36449. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36450. /** UNSIGNED_BYTE */
  36451. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36452. /** UNSIGNED_BYTE (2nd reference) */
  36453. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36454. /** FLOAT */
  36455. static readonly TEXTURETYPE_FLOAT: number;
  36456. /** HALF_FLOAT */
  36457. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36458. /** BYTE */
  36459. static readonly TEXTURETYPE_BYTE: number;
  36460. /** SHORT */
  36461. static readonly TEXTURETYPE_SHORT: number;
  36462. /** UNSIGNED_SHORT */
  36463. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36464. /** INT */
  36465. static readonly TEXTURETYPE_INT: number;
  36466. /** UNSIGNED_INT */
  36467. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36468. /** UNSIGNED_SHORT_4_4_4_4 */
  36469. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36470. /** UNSIGNED_SHORT_5_5_5_1 */
  36471. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36472. /** UNSIGNED_SHORT_5_6_5 */
  36473. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36474. /** UNSIGNED_INT_2_10_10_10_REV */
  36475. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36476. /** UNSIGNED_INT_24_8 */
  36477. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36478. /** UNSIGNED_INT_10F_11F_11F_REV */
  36479. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36480. /** UNSIGNED_INT_5_9_9_9_REV */
  36481. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36482. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36483. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36484. /** nearest is mag = nearest and min = nearest and mip = linear */
  36485. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36487. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36488. /** Trilinear is mag = linear and min = linear and mip = linear */
  36489. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36490. /** nearest is mag = nearest and min = nearest and mip = linear */
  36491. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36492. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36493. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36494. /** Trilinear is mag = linear and min = linear and mip = linear */
  36495. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36496. /** mag = nearest and min = nearest and mip = nearest */
  36497. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36498. /** mag = nearest and min = linear and mip = nearest */
  36499. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36500. /** mag = nearest and min = linear and mip = linear */
  36501. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36502. /** mag = nearest and min = linear and mip = none */
  36503. static readonly TEXTURE_NEAREST_LINEAR: number;
  36504. /** mag = nearest and min = nearest and mip = none */
  36505. static readonly TEXTURE_NEAREST_NEAREST: number;
  36506. /** mag = linear and min = nearest and mip = nearest */
  36507. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36508. /** mag = linear and min = nearest and mip = linear */
  36509. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36510. /** mag = linear and min = linear and mip = none */
  36511. static readonly TEXTURE_LINEAR_LINEAR: number;
  36512. /** mag = linear and min = nearest and mip = none */
  36513. static readonly TEXTURE_LINEAR_NEAREST: number;
  36514. /** Explicit coordinates mode */
  36515. static readonly TEXTURE_EXPLICIT_MODE: number;
  36516. /** Spherical coordinates mode */
  36517. static readonly TEXTURE_SPHERICAL_MODE: number;
  36518. /** Planar coordinates mode */
  36519. static readonly TEXTURE_PLANAR_MODE: number;
  36520. /** Cubic coordinates mode */
  36521. static readonly TEXTURE_CUBIC_MODE: number;
  36522. /** Projection coordinates mode */
  36523. static readonly TEXTURE_PROJECTION_MODE: number;
  36524. /** Skybox coordinates mode */
  36525. static readonly TEXTURE_SKYBOX_MODE: number;
  36526. /** Inverse Cubic coordinates mode */
  36527. static readonly TEXTURE_INVCUBIC_MODE: number;
  36528. /** Equirectangular coordinates mode */
  36529. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36530. /** Equirectangular Fixed coordinates mode */
  36531. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36532. /** Equirectangular Fixed Mirrored coordinates mode */
  36533. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36534. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36535. static readonly SCALEMODE_FLOOR: number;
  36536. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36537. static readonly SCALEMODE_NEAREST: number;
  36538. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36539. static readonly SCALEMODE_CEILING: number;
  36540. /**
  36541. * Returns the current npm package of the sdk
  36542. */
  36543. static get NpmPackage(): string;
  36544. /**
  36545. * Returns the current version of the framework
  36546. */
  36547. static get Version(): string;
  36548. /** Gets the list of created engines */
  36549. static get Instances(): Engine[];
  36550. /**
  36551. * Gets the latest created engine
  36552. */
  36553. static get LastCreatedEngine(): Nullable<Engine>;
  36554. /**
  36555. * Gets the latest created scene
  36556. */
  36557. static get LastCreatedScene(): Nullable<Scene>;
  36558. /**
  36559. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36560. * @param flag defines which part of the materials must be marked as dirty
  36561. * @param predicate defines a predicate used to filter which materials should be affected
  36562. */
  36563. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36564. /**
  36565. * Method called to create the default loading screen.
  36566. * This can be overriden in your own app.
  36567. * @param canvas The rendering canvas element
  36568. * @returns The loading screen
  36569. */
  36570. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36571. /**
  36572. * Method called to create the default rescale post process on each engine.
  36573. */
  36574. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36575. /**
  36576. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36577. **/
  36578. enableOfflineSupport: boolean;
  36579. /**
  36580. * 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)
  36581. **/
  36582. disableManifestCheck: boolean;
  36583. /**
  36584. * Gets the list of created scenes
  36585. */
  36586. scenes: Scene[];
  36587. /**
  36588. * Event raised when a new scene is created
  36589. */
  36590. onNewSceneAddedObservable: Observable<Scene>;
  36591. /**
  36592. * Gets the list of created postprocesses
  36593. */
  36594. postProcesses: PostProcess[];
  36595. /**
  36596. * Gets a boolean indicating if the pointer is currently locked
  36597. */
  36598. isPointerLock: boolean;
  36599. /**
  36600. * Observable event triggered each time the rendering canvas is resized
  36601. */
  36602. onResizeObservable: Observable<Engine>;
  36603. /**
  36604. * Observable event triggered each time the canvas loses focus
  36605. */
  36606. onCanvasBlurObservable: Observable<Engine>;
  36607. /**
  36608. * Observable event triggered each time the canvas gains focus
  36609. */
  36610. onCanvasFocusObservable: Observable<Engine>;
  36611. /**
  36612. * Observable event triggered each time the canvas receives pointerout event
  36613. */
  36614. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36615. /**
  36616. * Observable raised when the engine begins a new frame
  36617. */
  36618. onBeginFrameObservable: Observable<Engine>;
  36619. /**
  36620. * If set, will be used to request the next animation frame for the render loop
  36621. */
  36622. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36623. /**
  36624. * Observable raised when the engine ends the current frame
  36625. */
  36626. onEndFrameObservable: Observable<Engine>;
  36627. /**
  36628. * Observable raised when the engine is about to compile a shader
  36629. */
  36630. onBeforeShaderCompilationObservable: Observable<Engine>;
  36631. /**
  36632. * Observable raised when the engine has jsut compiled a shader
  36633. */
  36634. onAfterShaderCompilationObservable: Observable<Engine>;
  36635. /**
  36636. * Gets the audio engine
  36637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36638. * @ignorenaming
  36639. */
  36640. static audioEngine: IAudioEngine;
  36641. /**
  36642. * Default AudioEngine factory responsible of creating the Audio Engine.
  36643. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36644. */
  36645. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36646. /**
  36647. * Default offline support factory responsible of creating a tool used to store data locally.
  36648. * By default, this will create a Database object if the workload has been embedded.
  36649. */
  36650. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36651. private _loadingScreen;
  36652. private _pointerLockRequested;
  36653. private _rescalePostProcess;
  36654. private _deterministicLockstep;
  36655. private _lockstepMaxSteps;
  36656. private _timeStep;
  36657. protected get _supportsHardwareTextureRescaling(): boolean;
  36658. private _fps;
  36659. private _deltaTime;
  36660. /** @hidden */
  36661. _drawCalls: PerfCounter;
  36662. /** 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 */
  36663. canvasTabIndex: number;
  36664. /**
  36665. * Turn this value on if you want to pause FPS computation when in background
  36666. */
  36667. disablePerformanceMonitorInBackground: boolean;
  36668. private _performanceMonitor;
  36669. /**
  36670. * Gets the performance monitor attached to this engine
  36671. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36672. */
  36673. get performanceMonitor(): PerformanceMonitor;
  36674. private _onFocus;
  36675. private _onBlur;
  36676. private _onCanvasPointerOut;
  36677. private _onCanvasBlur;
  36678. private _onCanvasFocus;
  36679. private _onFullscreenChange;
  36680. private _onPointerLockChange;
  36681. /**
  36682. * Gets the HTML element used to attach event listeners
  36683. * @returns a HTML element
  36684. */
  36685. getInputElement(): Nullable<HTMLElement>;
  36686. /**
  36687. * Creates a new engine
  36688. * @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
  36689. * @param antialias defines enable antialiasing (default: false)
  36690. * @param options defines further options to be sent to the getContext() function
  36691. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36692. */
  36693. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36694. /**
  36695. * Gets current aspect ratio
  36696. * @param viewportOwner defines the camera to use to get the aspect ratio
  36697. * @param useScreen defines if screen size must be used (or the current render target if any)
  36698. * @returns a number defining the aspect ratio
  36699. */
  36700. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36701. /**
  36702. * Gets current screen aspect ratio
  36703. * @returns a number defining the aspect ratio
  36704. */
  36705. getScreenAspectRatio(): number;
  36706. /**
  36707. * Gets the client rect of the HTML canvas attached with the current webGL context
  36708. * @returns a client rectanglee
  36709. */
  36710. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36711. /**
  36712. * Gets the client rect of the HTML element used for events
  36713. * @returns a client rectanglee
  36714. */
  36715. getInputElementClientRect(): Nullable<ClientRect>;
  36716. /**
  36717. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36718. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36719. * @returns true if engine is in deterministic lock step mode
  36720. */
  36721. isDeterministicLockStep(): boolean;
  36722. /**
  36723. * Gets the max steps when engine is running in deterministic lock step
  36724. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36725. * @returns the max steps
  36726. */
  36727. getLockstepMaxSteps(): number;
  36728. /**
  36729. * Returns the time in ms between steps when using deterministic lock step.
  36730. * @returns time step in (ms)
  36731. */
  36732. getTimeStep(): number;
  36733. /**
  36734. * Force the mipmap generation for the given render target texture
  36735. * @param texture defines the render target texture to use
  36736. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36737. */
  36738. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36739. /** States */
  36740. /**
  36741. * Set various states to the webGL context
  36742. * @param culling defines backface culling state
  36743. * @param zOffset defines the value to apply to zOffset (0 by default)
  36744. * @param force defines if states must be applied even if cache is up to date
  36745. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36746. */
  36747. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36748. /**
  36749. * Set the z offset to apply to current rendering
  36750. * @param value defines the offset to apply
  36751. */
  36752. setZOffset(value: number): void;
  36753. /**
  36754. * Gets the current value of the zOffset
  36755. * @returns the current zOffset state
  36756. */
  36757. getZOffset(): number;
  36758. /**
  36759. * Enable or disable depth buffering
  36760. * @param enable defines the state to set
  36761. */
  36762. setDepthBuffer(enable: boolean): void;
  36763. /**
  36764. * Gets a boolean indicating if depth writing is enabled
  36765. * @returns the current depth writing state
  36766. */
  36767. getDepthWrite(): boolean;
  36768. /**
  36769. * Enable or disable depth writing
  36770. * @param enable defines the state to set
  36771. */
  36772. setDepthWrite(enable: boolean): void;
  36773. /**
  36774. * Gets a boolean indicating if stencil buffer is enabled
  36775. * @returns the current stencil buffer state
  36776. */
  36777. getStencilBuffer(): boolean;
  36778. /**
  36779. * Enable or disable the stencil buffer
  36780. * @param enable defines if the stencil buffer must be enabled or disabled
  36781. */
  36782. setStencilBuffer(enable: boolean): void;
  36783. /**
  36784. * Gets the current stencil mask
  36785. * @returns a number defining the new stencil mask to use
  36786. */
  36787. getStencilMask(): number;
  36788. /**
  36789. * Sets the current stencil mask
  36790. * @param mask defines the new stencil mask to use
  36791. */
  36792. setStencilMask(mask: number): void;
  36793. /**
  36794. * Gets the current stencil function
  36795. * @returns a number defining the stencil function to use
  36796. */
  36797. getStencilFunction(): number;
  36798. /**
  36799. * Gets the current stencil reference value
  36800. * @returns a number defining the stencil reference value to use
  36801. */
  36802. getStencilFunctionReference(): number;
  36803. /**
  36804. * Gets the current stencil mask
  36805. * @returns a number defining the stencil mask to use
  36806. */
  36807. getStencilFunctionMask(): number;
  36808. /**
  36809. * Sets the current stencil function
  36810. * @param stencilFunc defines the new stencil function to use
  36811. */
  36812. setStencilFunction(stencilFunc: number): void;
  36813. /**
  36814. * Sets the current stencil reference
  36815. * @param reference defines the new stencil reference to use
  36816. */
  36817. setStencilFunctionReference(reference: number): void;
  36818. /**
  36819. * Sets the current stencil mask
  36820. * @param mask defines the new stencil mask to use
  36821. */
  36822. setStencilFunctionMask(mask: number): void;
  36823. /**
  36824. * Gets the current stencil operation when stencil fails
  36825. * @returns a number defining stencil operation to use when stencil fails
  36826. */
  36827. getStencilOperationFail(): number;
  36828. /**
  36829. * Gets the current stencil operation when depth fails
  36830. * @returns a number defining stencil operation to use when depth fails
  36831. */
  36832. getStencilOperationDepthFail(): number;
  36833. /**
  36834. * Gets the current stencil operation when stencil passes
  36835. * @returns a number defining stencil operation to use when stencil passes
  36836. */
  36837. getStencilOperationPass(): number;
  36838. /**
  36839. * Sets the stencil operation to use when stencil fails
  36840. * @param operation defines the stencil operation to use when stencil fails
  36841. */
  36842. setStencilOperationFail(operation: number): void;
  36843. /**
  36844. * Sets the stencil operation to use when depth fails
  36845. * @param operation defines the stencil operation to use when depth fails
  36846. */
  36847. setStencilOperationDepthFail(operation: number): void;
  36848. /**
  36849. * Sets the stencil operation to use when stencil passes
  36850. * @param operation defines the stencil operation to use when stencil passes
  36851. */
  36852. setStencilOperationPass(operation: number): void;
  36853. /**
  36854. * Sets a boolean indicating if the dithering state is enabled or disabled
  36855. * @param value defines the dithering state
  36856. */
  36857. setDitheringState(value: boolean): void;
  36858. /**
  36859. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36860. * @param value defines the rasterizer state
  36861. */
  36862. setRasterizerState(value: boolean): void;
  36863. /**
  36864. * Gets the current depth function
  36865. * @returns a number defining the depth function
  36866. */
  36867. getDepthFunction(): Nullable<number>;
  36868. /**
  36869. * Sets the current depth function
  36870. * @param depthFunc defines the function to use
  36871. */
  36872. setDepthFunction(depthFunc: number): void;
  36873. /**
  36874. * Sets the current depth function to GREATER
  36875. */
  36876. setDepthFunctionToGreater(): void;
  36877. /**
  36878. * Sets the current depth function to GEQUAL
  36879. */
  36880. setDepthFunctionToGreaterOrEqual(): void;
  36881. /**
  36882. * Sets the current depth function to LESS
  36883. */
  36884. setDepthFunctionToLess(): void;
  36885. /**
  36886. * Sets the current depth function to LEQUAL
  36887. */
  36888. setDepthFunctionToLessOrEqual(): void;
  36889. private _cachedStencilBuffer;
  36890. private _cachedStencilFunction;
  36891. private _cachedStencilMask;
  36892. private _cachedStencilOperationPass;
  36893. private _cachedStencilOperationFail;
  36894. private _cachedStencilOperationDepthFail;
  36895. private _cachedStencilReference;
  36896. /**
  36897. * Caches the the state of the stencil buffer
  36898. */
  36899. cacheStencilState(): void;
  36900. /**
  36901. * Restores the state of the stencil buffer
  36902. */
  36903. restoreStencilState(): void;
  36904. /**
  36905. * Directly set the WebGL Viewport
  36906. * @param x defines the x coordinate of the viewport (in screen space)
  36907. * @param y defines the y coordinate of the viewport (in screen space)
  36908. * @param width defines the width of the viewport (in screen space)
  36909. * @param height defines the height of the viewport (in screen space)
  36910. * @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
  36911. */
  36912. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36913. /**
  36914. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36915. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36916. * @param y defines the y-coordinate of the corner of the clear rectangle
  36917. * @param width defines the width of the clear rectangle
  36918. * @param height defines the height of the clear rectangle
  36919. * @param clearColor defines the clear color
  36920. */
  36921. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36922. /**
  36923. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36924. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36925. * @param y defines the y-coordinate of the corner of the clear rectangle
  36926. * @param width defines the width of the clear rectangle
  36927. * @param height defines the height of the clear rectangle
  36928. */
  36929. enableScissor(x: number, y: number, width: number, height: number): void;
  36930. /**
  36931. * Disable previously set scissor test rectangle
  36932. */
  36933. disableScissor(): void;
  36934. protected _reportDrawCall(): void;
  36935. /**
  36936. * Initializes a webVR display and starts listening to display change events
  36937. * The onVRDisplayChangedObservable will be notified upon these changes
  36938. * @returns The onVRDisplayChangedObservable
  36939. */
  36940. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36941. /** @hidden */
  36942. _prepareVRComponent(): void;
  36943. /** @hidden */
  36944. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36945. /** @hidden */
  36946. _submitVRFrame(): void;
  36947. /**
  36948. * Call this function to leave webVR mode
  36949. * Will do nothing if webVR is not supported or if there is no webVR device
  36950. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36951. */
  36952. disableVR(): void;
  36953. /**
  36954. * Gets a boolean indicating that the system is in VR mode and is presenting
  36955. * @returns true if VR mode is engaged
  36956. */
  36957. isVRPresenting(): boolean;
  36958. /** @hidden */
  36959. _requestVRFrame(): void;
  36960. /** @hidden */
  36961. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36962. /**
  36963. * Gets the source code of the vertex shader associated with a specific webGL program
  36964. * @param program defines the program to use
  36965. * @returns a string containing the source code of the vertex shader associated with the program
  36966. */
  36967. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36968. /**
  36969. * Gets the source code of the fragment shader associated with a specific webGL program
  36970. * @param program defines the program to use
  36971. * @returns a string containing the source code of the fragment shader associated with the program
  36972. */
  36973. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36974. /**
  36975. * Sets a depth stencil texture from a render target to the according uniform.
  36976. * @param channel The texture channel
  36977. * @param uniform The uniform to set
  36978. * @param texture The render target texture containing the depth stencil texture to apply
  36979. */
  36980. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36981. /**
  36982. * Sets a texture to the webGL context from a postprocess
  36983. * @param channel defines the channel to use
  36984. * @param postProcess defines the source postprocess
  36985. */
  36986. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36987. /**
  36988. * Binds the output of the passed in post process to the texture channel specified
  36989. * @param channel The channel the texture should be bound to
  36990. * @param postProcess The post process which's output should be bound
  36991. */
  36992. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36993. protected _rebuildBuffers(): void;
  36994. /** @hidden */
  36995. _renderFrame(): void;
  36996. _renderLoop(): void;
  36997. /** @hidden */
  36998. _renderViews(): boolean;
  36999. /**
  37000. * Toggle full screen mode
  37001. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37002. */
  37003. switchFullscreen(requestPointerLock: boolean): void;
  37004. /**
  37005. * Enters full screen mode
  37006. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37007. */
  37008. enterFullscreen(requestPointerLock: boolean): void;
  37009. /**
  37010. * Exits full screen mode
  37011. */
  37012. exitFullscreen(): void;
  37013. /**
  37014. * Enters Pointerlock mode
  37015. */
  37016. enterPointerlock(): void;
  37017. /**
  37018. * Exits Pointerlock mode
  37019. */
  37020. exitPointerlock(): void;
  37021. /**
  37022. * Begin a new frame
  37023. */
  37024. beginFrame(): void;
  37025. /**
  37026. * Enf the current frame
  37027. */
  37028. endFrame(): void;
  37029. resize(): void;
  37030. /**
  37031. * Force a specific size of the canvas
  37032. * @param width defines the new canvas' width
  37033. * @param height defines the new canvas' height
  37034. * @returns true if the size was changed
  37035. */
  37036. setSize(width: number, height: number): boolean;
  37037. /**
  37038. * Updates a dynamic vertex buffer.
  37039. * @param vertexBuffer the vertex buffer to update
  37040. * @param data the data used to update the vertex buffer
  37041. * @param byteOffset the byte offset of the data
  37042. * @param byteLength the byte length of the data
  37043. */
  37044. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37045. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37046. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37047. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37048. _releaseTexture(texture: InternalTexture): void;
  37049. /**
  37050. * @hidden
  37051. * Rescales a texture
  37052. * @param source input texutre
  37053. * @param destination destination texture
  37054. * @param scene scene to use to render the resize
  37055. * @param internalFormat format to use when resizing
  37056. * @param onComplete callback to be called when resize has completed
  37057. */
  37058. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37059. /**
  37060. * Gets the current framerate
  37061. * @returns a number representing the framerate
  37062. */
  37063. getFps(): number;
  37064. /**
  37065. * Gets the time spent between current and previous frame
  37066. * @returns a number representing the delta time in ms
  37067. */
  37068. getDeltaTime(): number;
  37069. private _measureFps;
  37070. /** @hidden */
  37071. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37072. /**
  37073. * Update a dynamic index buffer
  37074. * @param indexBuffer defines the target index buffer
  37075. * @param indices defines the data to update
  37076. * @param offset defines the offset in the target index buffer where update should start
  37077. */
  37078. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37079. /**
  37080. * Updates the sample count of a render target texture
  37081. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37082. * @param texture defines the texture to update
  37083. * @param samples defines the sample count to set
  37084. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37085. */
  37086. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37087. /**
  37088. * Updates a depth texture Comparison Mode and Function.
  37089. * If the comparison Function is equal to 0, the mode will be set to none.
  37090. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37091. * @param texture The texture to set the comparison function for
  37092. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37093. */
  37094. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37095. /**
  37096. * Creates a webGL buffer to use with instanciation
  37097. * @param capacity defines the size of the buffer
  37098. * @returns the webGL buffer
  37099. */
  37100. createInstancesBuffer(capacity: number): DataBuffer;
  37101. /**
  37102. * Delete a webGL buffer used with instanciation
  37103. * @param buffer defines the webGL buffer to delete
  37104. */
  37105. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37106. private _clientWaitAsync;
  37107. /** @hidden */
  37108. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37109. dispose(): void;
  37110. private _disableTouchAction;
  37111. /**
  37112. * Display the loading screen
  37113. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37114. */
  37115. displayLoadingUI(): void;
  37116. /**
  37117. * Hide the loading screen
  37118. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37119. */
  37120. hideLoadingUI(): void;
  37121. /**
  37122. * Gets the current loading screen object
  37123. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37124. */
  37125. get loadingScreen(): ILoadingScreen;
  37126. /**
  37127. * Sets the current loading screen object
  37128. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37129. */
  37130. set loadingScreen(loadingScreen: ILoadingScreen);
  37131. /**
  37132. * Sets the current loading screen text
  37133. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37134. */
  37135. set loadingUIText(text: string);
  37136. /**
  37137. * Sets the current loading screen background color
  37138. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37139. */
  37140. set loadingUIBackgroundColor(color: string);
  37141. /** Pointerlock and fullscreen */
  37142. /**
  37143. * Ask the browser to promote the current element to pointerlock mode
  37144. * @param element defines the DOM element to promote
  37145. */
  37146. static _RequestPointerlock(element: HTMLElement): void;
  37147. /**
  37148. * Asks the browser to exit pointerlock mode
  37149. */
  37150. static _ExitPointerlock(): void;
  37151. /**
  37152. * Ask the browser to promote the current element to fullscreen rendering mode
  37153. * @param element defines the DOM element to promote
  37154. */
  37155. static _RequestFullscreen(element: HTMLElement): void;
  37156. /**
  37157. * Asks the browser to exit fullscreen mode
  37158. */
  37159. static _ExitFullscreen(): void;
  37160. }
  37161. }
  37162. declare module BABYLON {
  37163. /**
  37164. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37165. * during the life time of the application.
  37166. */
  37167. export class EngineStore {
  37168. /** Gets the list of created engines */
  37169. static Instances: Engine[];
  37170. /** @hidden */
  37171. static _LastCreatedScene: Nullable<Scene>;
  37172. /**
  37173. * Gets the latest created engine
  37174. */
  37175. static get LastCreatedEngine(): Nullable<Engine>;
  37176. /**
  37177. * Gets the latest created scene
  37178. */
  37179. static get LastCreatedScene(): Nullable<Scene>;
  37180. /**
  37181. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37182. * @ignorenaming
  37183. */
  37184. static UseFallbackTexture: boolean;
  37185. /**
  37186. * Texture content used if a texture cannot loaded
  37187. * @ignorenaming
  37188. */
  37189. static FallbackTexture: string;
  37190. }
  37191. }
  37192. declare module BABYLON {
  37193. /**
  37194. * Helper class that provides a small promise polyfill
  37195. */
  37196. export class PromisePolyfill {
  37197. /**
  37198. * Static function used to check if the polyfill is required
  37199. * If this is the case then the function will inject the polyfill to window.Promise
  37200. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37201. */
  37202. static Apply(force?: boolean): void;
  37203. }
  37204. }
  37205. declare module BABYLON {
  37206. /**
  37207. * Interface for screenshot methods with describe argument called `size` as object with options
  37208. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37209. */
  37210. export interface IScreenshotSize {
  37211. /**
  37212. * number in pixels for canvas height
  37213. */
  37214. height?: number;
  37215. /**
  37216. * multiplier allowing render at a higher or lower resolution
  37217. * If value is defined then height and width will be ignored and taken from camera
  37218. */
  37219. precision?: number;
  37220. /**
  37221. * number in pixels for canvas width
  37222. */
  37223. width?: number;
  37224. }
  37225. }
  37226. declare module BABYLON {
  37227. interface IColor4Like {
  37228. r: float;
  37229. g: float;
  37230. b: float;
  37231. a: float;
  37232. }
  37233. /**
  37234. * Class containing a set of static utilities functions
  37235. */
  37236. export class Tools {
  37237. /**
  37238. * Gets or sets the base URL to use to load assets
  37239. */
  37240. static get BaseUrl(): string;
  37241. static set BaseUrl(value: string);
  37242. /**
  37243. * Enable/Disable Custom HTTP Request Headers globally.
  37244. * default = false
  37245. * @see CustomRequestHeaders
  37246. */
  37247. static UseCustomRequestHeaders: boolean;
  37248. /**
  37249. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37250. * i.e. when loading files, where the server/service expects an Authorization header
  37251. */
  37252. static CustomRequestHeaders: {
  37253. [key: string]: string;
  37254. };
  37255. /**
  37256. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37257. */
  37258. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37259. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37260. /**
  37261. * Default behaviour for cors in the application.
  37262. * It can be a string if the expected behavior is identical in the entire app.
  37263. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37264. */
  37265. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37266. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37267. /**
  37268. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37269. * @ignorenaming
  37270. */
  37271. static get UseFallbackTexture(): boolean;
  37272. static set UseFallbackTexture(value: boolean);
  37273. /**
  37274. * Use this object to register external classes like custom textures or material
  37275. * to allow the laoders to instantiate them
  37276. */
  37277. static get RegisteredExternalClasses(): {
  37278. [key: string]: Object;
  37279. };
  37280. static set RegisteredExternalClasses(classes: {
  37281. [key: string]: Object;
  37282. });
  37283. /**
  37284. * Texture content used if a texture cannot loaded
  37285. * @ignorenaming
  37286. */
  37287. static get fallbackTexture(): string;
  37288. static set fallbackTexture(value: string);
  37289. /**
  37290. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37291. * @param u defines the coordinate on X axis
  37292. * @param v defines the coordinate on Y axis
  37293. * @param width defines the width of the source data
  37294. * @param height defines the height of the source data
  37295. * @param pixels defines the source byte array
  37296. * @param color defines the output color
  37297. */
  37298. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37299. /**
  37300. * Interpolates between a and b via alpha
  37301. * @param a The lower value (returned when alpha = 0)
  37302. * @param b The upper value (returned when alpha = 1)
  37303. * @param alpha The interpolation-factor
  37304. * @return The mixed value
  37305. */
  37306. static Mix(a: number, b: number, alpha: number): number;
  37307. /**
  37308. * Tries to instantiate a new object from a given class name
  37309. * @param className defines the class name to instantiate
  37310. * @returns the new object or null if the system was not able to do the instantiation
  37311. */
  37312. static Instantiate(className: string): any;
  37313. /**
  37314. * Provides a slice function that will work even on IE
  37315. * @param data defines the array to slice
  37316. * @param start defines the start of the data (optional)
  37317. * @param end defines the end of the data (optional)
  37318. * @returns the new sliced array
  37319. */
  37320. static Slice<T>(data: T, start?: number, end?: number): T;
  37321. /**
  37322. * Polyfill for setImmediate
  37323. * @param action defines the action to execute after the current execution block
  37324. */
  37325. static SetImmediate(action: () => void): void;
  37326. /**
  37327. * Function indicating if a number is an exponent of 2
  37328. * @param value defines the value to test
  37329. * @returns true if the value is an exponent of 2
  37330. */
  37331. static IsExponentOfTwo(value: number): boolean;
  37332. private static _tmpFloatArray;
  37333. /**
  37334. * Returns the nearest 32-bit single precision float representation of a Number
  37335. * @param value A Number. If the parameter is of a different type, it will get converted
  37336. * to a number or to NaN if it cannot be converted
  37337. * @returns number
  37338. */
  37339. static FloatRound(value: number): number;
  37340. /**
  37341. * Extracts the filename from a path
  37342. * @param path defines the path to use
  37343. * @returns the filename
  37344. */
  37345. static GetFilename(path: string): string;
  37346. /**
  37347. * Extracts the "folder" part of a path (everything before the filename).
  37348. * @param uri The URI to extract the info from
  37349. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37350. * @returns The "folder" part of the path
  37351. */
  37352. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37353. /**
  37354. * Extracts text content from a DOM element hierarchy
  37355. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37356. */
  37357. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37358. /**
  37359. * Convert an angle in radians to degrees
  37360. * @param angle defines the angle to convert
  37361. * @returns the angle in degrees
  37362. */
  37363. static ToDegrees(angle: number): number;
  37364. /**
  37365. * Convert an angle in degrees to radians
  37366. * @param angle defines the angle to convert
  37367. * @returns the angle in radians
  37368. */
  37369. static ToRadians(angle: number): number;
  37370. /**
  37371. * Returns an array if obj is not an array
  37372. * @param obj defines the object to evaluate as an array
  37373. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37374. * @returns either obj directly if obj is an array or a new array containing obj
  37375. */
  37376. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37377. /**
  37378. * Gets the pointer prefix to use
  37379. * @param engine defines the engine we are finding the prefix for
  37380. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37381. */
  37382. static GetPointerPrefix(engine: Engine): string;
  37383. /**
  37384. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37385. * @param url define the url we are trying
  37386. * @param element define the dom element where to configure the cors policy
  37387. */
  37388. static SetCorsBehavior(url: string | string[], element: {
  37389. crossOrigin: string | null;
  37390. }): void;
  37391. /**
  37392. * Removes unwanted characters from an url
  37393. * @param url defines the url to clean
  37394. * @returns the cleaned url
  37395. */
  37396. static CleanUrl(url: string): string;
  37397. /**
  37398. * Gets or sets a function used to pre-process url before using them to load assets
  37399. */
  37400. static get PreprocessUrl(): (url: string) => string;
  37401. static set PreprocessUrl(processor: (url: string) => string);
  37402. /**
  37403. * Loads an image as an HTMLImageElement.
  37404. * @param input url string, ArrayBuffer, or Blob to load
  37405. * @param onLoad callback called when the image successfully loads
  37406. * @param onError callback called when the image fails to load
  37407. * @param offlineProvider offline provider for caching
  37408. * @param mimeType optional mime type
  37409. * @returns the HTMLImageElement of the loaded image
  37410. */
  37411. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37412. /**
  37413. * Loads a file from a url
  37414. * @param url url string, ArrayBuffer, or Blob to load
  37415. * @param onSuccess callback called when the file successfully loads
  37416. * @param onProgress callback called while file is loading (if the server supports this mode)
  37417. * @param offlineProvider defines the offline provider for caching
  37418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37419. * @param onError callback called when the file fails to load
  37420. * @returns a file request object
  37421. */
  37422. 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;
  37423. /**
  37424. * Loads a file from a url
  37425. * @param url the file url to load
  37426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37427. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37428. */
  37429. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37430. /**
  37431. * Load a script (identified by an url). When the url returns, the
  37432. * content of this file is added into a new script element, attached to the DOM (body element)
  37433. * @param scriptUrl defines the url of the script to laod
  37434. * @param onSuccess defines the callback called when the script is loaded
  37435. * @param onError defines the callback to call if an error occurs
  37436. * @param scriptId defines the id of the script element
  37437. */
  37438. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37439. /**
  37440. * Load an asynchronous script (identified by an url). When the url returns, the
  37441. * content of this file is added into a new script element, attached to the DOM (body element)
  37442. * @param scriptUrl defines the url of the script to laod
  37443. * @param scriptId defines the id of the script element
  37444. * @returns a promise request object
  37445. */
  37446. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37447. /**
  37448. * Loads a file from a blob
  37449. * @param fileToLoad defines the blob to use
  37450. * @param callback defines the callback to call when data is loaded
  37451. * @param progressCallback defines the callback to call during loading process
  37452. * @returns a file request object
  37453. */
  37454. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37455. /**
  37456. * Reads a file from a File object
  37457. * @param file defines the file to load
  37458. * @param onSuccess defines the callback to call when data is loaded
  37459. * @param onProgress defines the callback to call during loading process
  37460. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37461. * @param onError defines the callback to call when an error occurs
  37462. * @returns a file request object
  37463. */
  37464. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37465. /**
  37466. * Creates a data url from a given string content
  37467. * @param content defines the content to convert
  37468. * @returns the new data url link
  37469. */
  37470. static FileAsURL(content: string): string;
  37471. /**
  37472. * Format the given number to a specific decimal format
  37473. * @param value defines the number to format
  37474. * @param decimals defines the number of decimals to use
  37475. * @returns the formatted string
  37476. */
  37477. static Format(value: number, decimals?: number): string;
  37478. /**
  37479. * Tries to copy an object by duplicating every property
  37480. * @param source defines the source object
  37481. * @param destination defines the target object
  37482. * @param doNotCopyList defines a list of properties to avoid
  37483. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37484. */
  37485. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37486. /**
  37487. * Gets a boolean indicating if the given object has no own property
  37488. * @param obj defines the object to test
  37489. * @returns true if object has no own property
  37490. */
  37491. static IsEmpty(obj: any): boolean;
  37492. /**
  37493. * Function used to register events at window level
  37494. * @param windowElement defines the Window object to use
  37495. * @param events defines the events to register
  37496. */
  37497. static RegisterTopRootEvents(windowElement: Window, events: {
  37498. name: string;
  37499. handler: Nullable<(e: FocusEvent) => any>;
  37500. }[]): void;
  37501. /**
  37502. * Function used to unregister events from window level
  37503. * @param windowElement defines the Window object to use
  37504. * @param events defines the events to unregister
  37505. */
  37506. static UnregisterTopRootEvents(windowElement: Window, events: {
  37507. name: string;
  37508. handler: Nullable<(e: FocusEvent) => any>;
  37509. }[]): void;
  37510. /**
  37511. * @ignore
  37512. */
  37513. static _ScreenshotCanvas: HTMLCanvasElement;
  37514. /**
  37515. * Dumps the current bound framebuffer
  37516. * @param width defines the rendering width
  37517. * @param height defines the rendering height
  37518. * @param engine defines the hosting engine
  37519. * @param successCallback defines the callback triggered once the data are available
  37520. * @param mimeType defines the mime type of the result
  37521. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37522. */
  37523. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37524. /**
  37525. * Converts the canvas data to blob.
  37526. * This acts as a polyfill for browsers not supporting the to blob function.
  37527. * @param canvas Defines the canvas to extract the data from
  37528. * @param successCallback Defines the callback triggered once the data are available
  37529. * @param mimeType Defines the mime type of the result
  37530. */
  37531. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37532. /**
  37533. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37534. * @param successCallback defines the callback triggered once the data are available
  37535. * @param mimeType defines the mime type of the result
  37536. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37537. */
  37538. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37539. /**
  37540. * Downloads a blob in the browser
  37541. * @param blob defines the blob to download
  37542. * @param fileName defines the name of the downloaded file
  37543. */
  37544. static Download(blob: Blob, fileName: string): void;
  37545. /**
  37546. * Captures a screenshot of the current rendering
  37547. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37548. * @param engine defines the rendering engine
  37549. * @param camera defines the source camera
  37550. * @param size This parameter can be set to a single number or to an object with the
  37551. * following (optional) properties: precision, width, height. If a single number is passed,
  37552. * it will be used for both width and height. If an object is passed, the screenshot size
  37553. * will be derived from the parameters. The precision property is a multiplier allowing
  37554. * rendering at a higher or lower resolution
  37555. * @param successCallback defines the callback receives a single parameter which contains the
  37556. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37557. * src parameter of an <img> to display it
  37558. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37559. * Check your browser for supported MIME types
  37560. */
  37561. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37562. /**
  37563. * Captures a screenshot of the current rendering
  37564. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37565. * @param engine defines the rendering engine
  37566. * @param camera defines the source camera
  37567. * @param size This parameter can be set to a single number or to an object with the
  37568. * following (optional) properties: precision, width, height. If a single number is passed,
  37569. * it will be used for both width and height. If an object is passed, the screenshot size
  37570. * will be derived from the parameters. The precision property is a multiplier allowing
  37571. * rendering at a higher or lower resolution
  37572. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37573. * Check your browser for supported MIME types
  37574. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37575. * to the src parameter of an <img> to display it
  37576. */
  37577. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37578. /**
  37579. * Generates an image screenshot from the specified camera.
  37580. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37581. * @param engine The engine to use for rendering
  37582. * @param camera The camera to use for rendering
  37583. * @param size This parameter can be set to a single number or to an object with the
  37584. * following (optional) properties: precision, width, height. If a single number is passed,
  37585. * it will be used for both width and height. If an object is passed, the screenshot size
  37586. * will be derived from the parameters. The precision property is a multiplier allowing
  37587. * rendering at a higher or lower resolution
  37588. * @param successCallback The callback receives a single parameter which contains the
  37589. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37590. * src parameter of an <img> to display it
  37591. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37592. * Check your browser for supported MIME types
  37593. * @param samples Texture samples (default: 1)
  37594. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37595. * @param fileName A name for for the downloaded file.
  37596. */
  37597. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37598. /**
  37599. * Generates an image screenshot from the specified camera.
  37600. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37601. * @param engine The engine to use for rendering
  37602. * @param camera The camera to use for rendering
  37603. * @param size This parameter can be set to a single number or to an object with the
  37604. * following (optional) properties: precision, width, height. If a single number is passed,
  37605. * it will be used for both width and height. If an object is passed, the screenshot size
  37606. * will be derived from the parameters. The precision property is a multiplier allowing
  37607. * rendering at a higher or lower resolution
  37608. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37609. * Check your browser for supported MIME types
  37610. * @param samples Texture samples (default: 1)
  37611. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37612. * @param fileName A name for for the downloaded file.
  37613. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37614. * to the src parameter of an <img> to display it
  37615. */
  37616. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37617. /**
  37618. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37619. * Be aware Math.random() could cause collisions, but:
  37620. * "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"
  37621. * @returns a pseudo random id
  37622. */
  37623. static RandomId(): string;
  37624. /**
  37625. * Test if the given uri is a base64 string
  37626. * @param uri The uri to test
  37627. * @return True if the uri is a base64 string or false otherwise
  37628. */
  37629. static IsBase64(uri: string): boolean;
  37630. /**
  37631. * Decode the given base64 uri.
  37632. * @param uri The uri to decode
  37633. * @return The decoded base64 data.
  37634. */
  37635. static DecodeBase64(uri: string): ArrayBuffer;
  37636. /**
  37637. * Gets the absolute url.
  37638. * @param url the input url
  37639. * @return the absolute url
  37640. */
  37641. static GetAbsoluteUrl(url: string): string;
  37642. /**
  37643. * No log
  37644. */
  37645. static readonly NoneLogLevel: number;
  37646. /**
  37647. * Only message logs
  37648. */
  37649. static readonly MessageLogLevel: number;
  37650. /**
  37651. * Only warning logs
  37652. */
  37653. static readonly WarningLogLevel: number;
  37654. /**
  37655. * Only error logs
  37656. */
  37657. static readonly ErrorLogLevel: number;
  37658. /**
  37659. * All logs
  37660. */
  37661. static readonly AllLogLevel: number;
  37662. /**
  37663. * Gets a value indicating the number of loading errors
  37664. * @ignorenaming
  37665. */
  37666. static get errorsCount(): number;
  37667. /**
  37668. * Callback called when a new log is added
  37669. */
  37670. static OnNewCacheEntry: (entry: string) => void;
  37671. /**
  37672. * Log a message to the console
  37673. * @param message defines the message to log
  37674. */
  37675. static Log(message: string): void;
  37676. /**
  37677. * Write a warning message to the console
  37678. * @param message defines the message to log
  37679. */
  37680. static Warn(message: string): void;
  37681. /**
  37682. * Write an error message to the console
  37683. * @param message defines the message to log
  37684. */
  37685. static Error(message: string): void;
  37686. /**
  37687. * Gets current log cache (list of logs)
  37688. */
  37689. static get LogCache(): string;
  37690. /**
  37691. * Clears the log cache
  37692. */
  37693. static ClearLogCache(): void;
  37694. /**
  37695. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37696. */
  37697. static set LogLevels(level: number);
  37698. /**
  37699. * Checks if the window object exists
  37700. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37701. */
  37702. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37703. /**
  37704. * No performance log
  37705. */
  37706. static readonly PerformanceNoneLogLevel: number;
  37707. /**
  37708. * Use user marks to log performance
  37709. */
  37710. static readonly PerformanceUserMarkLogLevel: number;
  37711. /**
  37712. * Log performance to the console
  37713. */
  37714. static readonly PerformanceConsoleLogLevel: number;
  37715. private static _performance;
  37716. /**
  37717. * Sets the current performance log level
  37718. */
  37719. static set PerformanceLogLevel(level: number);
  37720. private static _StartPerformanceCounterDisabled;
  37721. private static _EndPerformanceCounterDisabled;
  37722. private static _StartUserMark;
  37723. private static _EndUserMark;
  37724. private static _StartPerformanceConsole;
  37725. private static _EndPerformanceConsole;
  37726. /**
  37727. * Starts a performance counter
  37728. */
  37729. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37730. /**
  37731. * Ends a specific performance coutner
  37732. */
  37733. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37734. /**
  37735. * Gets either window.performance.now() if supported or Date.now() else
  37736. */
  37737. static get Now(): number;
  37738. /**
  37739. * This method will return the name of the class used to create the instance of the given object.
  37740. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37741. * @param object the object to get the class name from
  37742. * @param isType defines if the object is actually a type
  37743. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37744. */
  37745. static GetClassName(object: any, isType?: boolean): string;
  37746. /**
  37747. * Gets the first element of an array satisfying a given predicate
  37748. * @param array defines the array to browse
  37749. * @param predicate defines the predicate to use
  37750. * @returns null if not found or the element
  37751. */
  37752. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37753. /**
  37754. * This method will return the name of the full name of the class, including its owning module (if any).
  37755. * 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).
  37756. * @param object the object to get the class name from
  37757. * @param isType defines if the object is actually a type
  37758. * @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.
  37759. * @ignorenaming
  37760. */
  37761. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37762. /**
  37763. * Returns a promise that resolves after the given amount of time.
  37764. * @param delay Number of milliseconds to delay
  37765. * @returns Promise that resolves after the given amount of time
  37766. */
  37767. static DelayAsync(delay: number): Promise<void>;
  37768. /**
  37769. * Utility function to detect if the current user agent is Safari
  37770. * @returns whether or not the current user agent is safari
  37771. */
  37772. static IsSafari(): boolean;
  37773. }
  37774. /**
  37775. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37776. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37777. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37778. * @param name The name of the class, case should be preserved
  37779. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37780. */
  37781. export function className(name: string, module?: string): (target: Object) => void;
  37782. /**
  37783. * An implementation of a loop for asynchronous functions.
  37784. */
  37785. export class AsyncLoop {
  37786. /**
  37787. * Defines the number of iterations for the loop
  37788. */
  37789. iterations: number;
  37790. /**
  37791. * Defines the current index of the loop.
  37792. */
  37793. index: number;
  37794. private _done;
  37795. private _fn;
  37796. private _successCallback;
  37797. /**
  37798. * Constructor.
  37799. * @param iterations the number of iterations.
  37800. * @param func the function to run each iteration
  37801. * @param successCallback the callback that will be called upon succesful execution
  37802. * @param offset starting offset.
  37803. */
  37804. constructor(
  37805. /**
  37806. * Defines the number of iterations for the loop
  37807. */
  37808. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37809. /**
  37810. * Execute the next iteration. Must be called after the last iteration was finished.
  37811. */
  37812. executeNext(): void;
  37813. /**
  37814. * Break the loop and run the success callback.
  37815. */
  37816. breakLoop(): void;
  37817. /**
  37818. * Create and run an async loop.
  37819. * @param iterations the number of iterations.
  37820. * @param fn the function to run each iteration
  37821. * @param successCallback the callback that will be called upon succesful execution
  37822. * @param offset starting offset.
  37823. * @returns the created async loop object
  37824. */
  37825. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37826. /**
  37827. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37828. * @param iterations total number of iterations
  37829. * @param syncedIterations number of synchronous iterations in each async iteration.
  37830. * @param fn the function to call each iteration.
  37831. * @param callback a success call back that will be called when iterating stops.
  37832. * @param breakFunction a break condition (optional)
  37833. * @param timeout timeout settings for the setTimeout function. default - 0.
  37834. * @returns the created async loop object
  37835. */
  37836. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37837. }
  37838. }
  37839. declare module BABYLON {
  37840. /**
  37841. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37842. * The underlying implementation relies on an associative array to ensure the best performances.
  37843. * The value can be anything including 'null' but except 'undefined'
  37844. */
  37845. export class StringDictionary<T> {
  37846. /**
  37847. * This will clear this dictionary and copy the content from the 'source' one.
  37848. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37849. * @param source the dictionary to take the content from and copy to this dictionary
  37850. */
  37851. copyFrom(source: StringDictionary<T>): void;
  37852. /**
  37853. * Get a value based from its key
  37854. * @param key the given key to get the matching value from
  37855. * @return the value if found, otherwise undefined is returned
  37856. */
  37857. get(key: string): T | undefined;
  37858. /**
  37859. * Get a value from its key or add it if it doesn't exist.
  37860. * This method will ensure you that a given key/data will be present in the dictionary.
  37861. * @param key the given key to get the matching value from
  37862. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37863. * The factory will only be invoked if there's no data for the given key.
  37864. * @return the value corresponding to the key.
  37865. */
  37866. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37867. /**
  37868. * Get a value from its key if present in the dictionary otherwise add it
  37869. * @param key the key to get the value from
  37870. * @param val if there's no such key/value pair in the dictionary add it with this value
  37871. * @return the value corresponding to the key
  37872. */
  37873. getOrAdd(key: string, val: T): T;
  37874. /**
  37875. * Check if there's a given key in the dictionary
  37876. * @param key the key to check for
  37877. * @return true if the key is present, false otherwise
  37878. */
  37879. contains(key: string): boolean;
  37880. /**
  37881. * Add a new key and its corresponding value
  37882. * @param key the key to add
  37883. * @param value the value corresponding to the key
  37884. * @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
  37885. */
  37886. add(key: string, value: T): boolean;
  37887. /**
  37888. * Update a specific value associated to a key
  37889. * @param key defines the key to use
  37890. * @param value defines the value to store
  37891. * @returns true if the value was updated (or false if the key was not found)
  37892. */
  37893. set(key: string, value: T): boolean;
  37894. /**
  37895. * Get the element of the given key and remove it from the dictionary
  37896. * @param key defines the key to search
  37897. * @returns the value associated with the key or null if not found
  37898. */
  37899. getAndRemove(key: string): Nullable<T>;
  37900. /**
  37901. * Remove a key/value from the dictionary.
  37902. * @param key the key to remove
  37903. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37904. */
  37905. remove(key: string): boolean;
  37906. /**
  37907. * Clear the whole content of the dictionary
  37908. */
  37909. clear(): void;
  37910. /**
  37911. * Gets the current count
  37912. */
  37913. get count(): number;
  37914. /**
  37915. * Execute a callback on each key/val of the dictionary.
  37916. * Note that you can remove any element in this dictionary in the callback implementation
  37917. * @param callback the callback to execute on a given key/value pair
  37918. */
  37919. forEach(callback: (key: string, val: T) => void): void;
  37920. /**
  37921. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37922. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37923. * Note that you can remove any element in this dictionary in the callback implementation
  37924. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37925. * @returns the first item
  37926. */
  37927. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37928. private _count;
  37929. private _data;
  37930. }
  37931. }
  37932. declare module BABYLON {
  37933. /** @hidden */
  37934. export interface ICollisionCoordinator {
  37935. createCollider(): Collider;
  37936. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37937. init(scene: Scene): void;
  37938. }
  37939. /** @hidden */
  37940. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37941. private _scene;
  37942. private _scaledPosition;
  37943. private _scaledVelocity;
  37944. private _finalPosition;
  37945. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37946. createCollider(): Collider;
  37947. init(scene: Scene): void;
  37948. private _collideWithWorld;
  37949. }
  37950. }
  37951. declare module BABYLON {
  37952. /**
  37953. * Class used to manage all inputs for the scene.
  37954. */
  37955. export class InputManager {
  37956. /** The distance in pixel that you have to move to prevent some events */
  37957. static DragMovementThreshold: number;
  37958. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37959. static LongPressDelay: number;
  37960. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37961. static DoubleClickDelay: number;
  37962. /** If you need to check double click without raising a single click at first click, enable this flag */
  37963. static ExclusiveDoubleClickMode: boolean;
  37964. private _wheelEventName;
  37965. private _onPointerMove;
  37966. private _onPointerDown;
  37967. private _onPointerUp;
  37968. private _initClickEvent;
  37969. private _initActionManager;
  37970. private _delayedSimpleClick;
  37971. private _delayedSimpleClickTimeout;
  37972. private _previousDelayedSimpleClickTimeout;
  37973. private _meshPickProceed;
  37974. private _previousButtonPressed;
  37975. private _currentPickResult;
  37976. private _previousPickResult;
  37977. private _totalPointersPressed;
  37978. private _doubleClickOccured;
  37979. private _pointerOverMesh;
  37980. private _pickedDownMesh;
  37981. private _pickedUpMesh;
  37982. private _pointerX;
  37983. private _pointerY;
  37984. private _unTranslatedPointerX;
  37985. private _unTranslatedPointerY;
  37986. private _startingPointerPosition;
  37987. private _previousStartingPointerPosition;
  37988. private _startingPointerTime;
  37989. private _previousStartingPointerTime;
  37990. private _pointerCaptures;
  37991. private _onKeyDown;
  37992. private _onKeyUp;
  37993. private _onCanvasFocusObserver;
  37994. private _onCanvasBlurObserver;
  37995. private _scene;
  37996. /**
  37997. * Creates a new InputManager
  37998. * @param scene defines the hosting scene
  37999. */
  38000. constructor(scene: Scene);
  38001. /**
  38002. * Gets the mesh that is currently under the pointer
  38003. */
  38004. get meshUnderPointer(): Nullable<AbstractMesh>;
  38005. /**
  38006. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38007. */
  38008. get unTranslatedPointer(): Vector2;
  38009. /**
  38010. * Gets or sets the current on-screen X position of the pointer
  38011. */
  38012. get pointerX(): number;
  38013. set pointerX(value: number);
  38014. /**
  38015. * Gets or sets the current on-screen Y position of the pointer
  38016. */
  38017. get pointerY(): number;
  38018. set pointerY(value: number);
  38019. private _updatePointerPosition;
  38020. private _processPointerMove;
  38021. private _setRayOnPointerInfo;
  38022. private _checkPrePointerObservable;
  38023. /**
  38024. * Use this method to simulate a pointer move on a mesh
  38025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38028. */
  38029. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38030. /**
  38031. * Use this method to simulate a pointer down on a mesh
  38032. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38033. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38034. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38035. */
  38036. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38037. private _processPointerDown;
  38038. /** @hidden */
  38039. _isPointerSwiping(): boolean;
  38040. /**
  38041. * Use this method to simulate a pointer up on a mesh
  38042. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38043. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38044. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38045. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38046. */
  38047. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38048. private _processPointerUp;
  38049. /**
  38050. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38051. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38052. * @returns true if the pointer was captured
  38053. */
  38054. isPointerCaptured(pointerId?: number): boolean;
  38055. /**
  38056. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38057. * @param attachUp defines if you want to attach events to pointerup
  38058. * @param attachDown defines if you want to attach events to pointerdown
  38059. * @param attachMove defines if you want to attach events to pointermove
  38060. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38061. */
  38062. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38063. /**
  38064. * Detaches all event handlers
  38065. */
  38066. detachControl(): void;
  38067. /**
  38068. * Force the value of meshUnderPointer
  38069. * @param mesh defines the mesh to use
  38070. */
  38071. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38072. /**
  38073. * Gets the mesh under the pointer
  38074. * @returns a Mesh or null if no mesh is under the pointer
  38075. */
  38076. getPointerOverMesh(): Nullable<AbstractMesh>;
  38077. }
  38078. }
  38079. declare module BABYLON {
  38080. /**
  38081. * This class defines the direct association between an animation and a target
  38082. */
  38083. export class TargetedAnimation {
  38084. /**
  38085. * Animation to perform
  38086. */
  38087. animation: Animation;
  38088. /**
  38089. * Target to animate
  38090. */
  38091. target: any;
  38092. /**
  38093. * Returns the string "TargetedAnimation"
  38094. * @returns "TargetedAnimation"
  38095. */
  38096. getClassName(): string;
  38097. /**
  38098. * Serialize the object
  38099. * @returns the JSON object representing the current entity
  38100. */
  38101. serialize(): any;
  38102. }
  38103. /**
  38104. * Use this class to create coordinated animations on multiple targets
  38105. */
  38106. export class AnimationGroup implements IDisposable {
  38107. /** The name of the animation group */
  38108. name: string;
  38109. private _scene;
  38110. private _targetedAnimations;
  38111. private _animatables;
  38112. private _from;
  38113. private _to;
  38114. private _isStarted;
  38115. private _isPaused;
  38116. private _speedRatio;
  38117. private _loopAnimation;
  38118. private _isAdditive;
  38119. /**
  38120. * Gets or sets the unique id of the node
  38121. */
  38122. uniqueId: number;
  38123. /**
  38124. * This observable will notify when one animation have ended
  38125. */
  38126. onAnimationEndObservable: Observable<TargetedAnimation>;
  38127. /**
  38128. * Observer raised when one animation loops
  38129. */
  38130. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38131. /**
  38132. * Observer raised when all animations have looped
  38133. */
  38134. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38135. /**
  38136. * This observable will notify when all animations have ended.
  38137. */
  38138. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38139. /**
  38140. * This observable will notify when all animations have paused.
  38141. */
  38142. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38143. /**
  38144. * This observable will notify when all animations are playing.
  38145. */
  38146. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38147. /**
  38148. * Gets the first frame
  38149. */
  38150. get from(): number;
  38151. /**
  38152. * Gets the last frame
  38153. */
  38154. get to(): number;
  38155. /**
  38156. * Define if the animations are started
  38157. */
  38158. get isStarted(): boolean;
  38159. /**
  38160. * Gets a value indicating that the current group is playing
  38161. */
  38162. get isPlaying(): boolean;
  38163. /**
  38164. * Gets or sets the speed ratio to use for all animations
  38165. */
  38166. get speedRatio(): number;
  38167. /**
  38168. * Gets or sets the speed ratio to use for all animations
  38169. */
  38170. set speedRatio(value: number);
  38171. /**
  38172. * Gets or sets if all animations should loop or not
  38173. */
  38174. get loopAnimation(): boolean;
  38175. set loopAnimation(value: boolean);
  38176. /**
  38177. * Gets or sets if all animations should be evaluated additively
  38178. */
  38179. get isAdditive(): boolean;
  38180. set isAdditive(value: boolean);
  38181. /**
  38182. * Gets the targeted animations for this animation group
  38183. */
  38184. get targetedAnimations(): Array<TargetedAnimation>;
  38185. /**
  38186. * returning the list of animatables controlled by this animation group.
  38187. */
  38188. get animatables(): Array<Animatable>;
  38189. /**
  38190. * Gets the list of target animations
  38191. */
  38192. get children(): TargetedAnimation[];
  38193. /**
  38194. * Instantiates a new Animation Group.
  38195. * This helps managing several animations at once.
  38196. * @see https://doc.babylonjs.com/how_to/group
  38197. * @param name Defines the name of the group
  38198. * @param scene Defines the scene the group belongs to
  38199. */
  38200. constructor(
  38201. /** The name of the animation group */
  38202. name: string, scene?: Nullable<Scene>);
  38203. /**
  38204. * Add an animation (with its target) in the group
  38205. * @param animation defines the animation we want to add
  38206. * @param target defines the target of the animation
  38207. * @returns the TargetedAnimation object
  38208. */
  38209. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38210. /**
  38211. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38212. * It can add constant keys at begin or end
  38213. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38214. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38215. * @returns the animation group
  38216. */
  38217. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38218. private _animationLoopCount;
  38219. private _animationLoopFlags;
  38220. private _processLoop;
  38221. /**
  38222. * Start all animations on given targets
  38223. * @param loop defines if animations must loop
  38224. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38225. * @param from defines the from key (optional)
  38226. * @param to defines the to key (optional)
  38227. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38228. * @returns the current animation group
  38229. */
  38230. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38231. /**
  38232. * Pause all animations
  38233. * @returns the animation group
  38234. */
  38235. pause(): AnimationGroup;
  38236. /**
  38237. * Play all animations to initial state
  38238. * This function will start() the animations if they were not started or will restart() them if they were paused
  38239. * @param loop defines if animations must loop
  38240. * @returns the animation group
  38241. */
  38242. play(loop?: boolean): AnimationGroup;
  38243. /**
  38244. * Reset all animations to initial state
  38245. * @returns the animation group
  38246. */
  38247. reset(): AnimationGroup;
  38248. /**
  38249. * Restart animations from key 0
  38250. * @returns the animation group
  38251. */
  38252. restart(): AnimationGroup;
  38253. /**
  38254. * Stop all animations
  38255. * @returns the animation group
  38256. */
  38257. stop(): AnimationGroup;
  38258. /**
  38259. * Set animation weight for all animatables
  38260. * @param weight defines the weight to use
  38261. * @return the animationGroup
  38262. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38263. */
  38264. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38265. /**
  38266. * Synchronize and normalize all animatables with a source animatable
  38267. * @param root defines the root animatable to synchronize with
  38268. * @return the animationGroup
  38269. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38270. */
  38271. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38272. /**
  38273. * Goes to a specific frame in this animation group
  38274. * @param frame the frame number to go to
  38275. * @return the animationGroup
  38276. */
  38277. goToFrame(frame: number): AnimationGroup;
  38278. /**
  38279. * Dispose all associated resources
  38280. */
  38281. dispose(): void;
  38282. private _checkAnimationGroupEnded;
  38283. /**
  38284. * Clone the current animation group and returns a copy
  38285. * @param newName defines the name of the new group
  38286. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38287. * @returns the new aniamtion group
  38288. */
  38289. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38290. /**
  38291. * Serializes the animationGroup to an object
  38292. * @returns Serialized object
  38293. */
  38294. serialize(): any;
  38295. /**
  38296. * Returns a new AnimationGroup object parsed from the source provided.
  38297. * @param parsedAnimationGroup defines the source
  38298. * @param scene defines the scene that will receive the animationGroup
  38299. * @returns a new AnimationGroup
  38300. */
  38301. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38302. /**
  38303. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38304. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38305. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38306. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38307. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38308. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38309. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38310. */
  38311. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38312. /**
  38313. * Returns the string "AnimationGroup"
  38314. * @returns "AnimationGroup"
  38315. */
  38316. getClassName(): string;
  38317. /**
  38318. * Creates a detailled string about the object
  38319. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38320. * @returns a string representing the object
  38321. */
  38322. toString(fullDetails?: boolean): string;
  38323. }
  38324. }
  38325. declare module BABYLON {
  38326. /**
  38327. * Define an interface for all classes that will hold resources
  38328. */
  38329. export interface IDisposable {
  38330. /**
  38331. * Releases all held resources
  38332. */
  38333. dispose(): void;
  38334. }
  38335. /** Interface defining initialization parameters for Scene class */
  38336. export interface SceneOptions {
  38337. /**
  38338. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38339. * It will improve performance when the number of geometries becomes important.
  38340. */
  38341. useGeometryUniqueIdsMap?: boolean;
  38342. /**
  38343. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38344. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38345. */
  38346. useMaterialMeshMap?: boolean;
  38347. /**
  38348. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned 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. useClonedMeshMap?: boolean;
  38352. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38353. virtual?: boolean;
  38354. }
  38355. /**
  38356. * Represents a scene to be rendered by the engine.
  38357. * @see https://doc.babylonjs.com/features/scene
  38358. */
  38359. export class Scene extends AbstractScene implements IAnimatable {
  38360. /** The fog is deactivated */
  38361. static readonly FOGMODE_NONE: number;
  38362. /** The fog density is following an exponential function */
  38363. static readonly FOGMODE_EXP: number;
  38364. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38365. static readonly FOGMODE_EXP2: number;
  38366. /** The fog density is following a linear function. */
  38367. static readonly FOGMODE_LINEAR: number;
  38368. /**
  38369. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38370. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38371. */
  38372. static MinDeltaTime: number;
  38373. /**
  38374. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38375. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38376. */
  38377. static MaxDeltaTime: number;
  38378. /**
  38379. * Factory used to create the default material.
  38380. * @param name The name of the material to create
  38381. * @param scene The scene to create the material for
  38382. * @returns The default material
  38383. */
  38384. static DefaultMaterialFactory(scene: Scene): Material;
  38385. /**
  38386. * Factory used to create the a collision coordinator.
  38387. * @returns The collision coordinator
  38388. */
  38389. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38390. /** @hidden */
  38391. _inputManager: InputManager;
  38392. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38393. cameraToUseForPointers: Nullable<Camera>;
  38394. /** @hidden */
  38395. readonly _isScene: boolean;
  38396. /** @hidden */
  38397. _blockEntityCollection: boolean;
  38398. /**
  38399. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38400. */
  38401. autoClear: boolean;
  38402. /**
  38403. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38404. */
  38405. autoClearDepthAndStencil: boolean;
  38406. /**
  38407. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38408. */
  38409. clearColor: Color4;
  38410. /**
  38411. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38412. */
  38413. ambientColor: Color3;
  38414. /**
  38415. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38416. * It should only be one of the following (if not the default embedded one):
  38417. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38418. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38419. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38420. * The material properties need to be setup according to the type of texture in use.
  38421. */
  38422. environmentBRDFTexture: BaseTexture;
  38423. /** @hidden */
  38424. protected _environmentTexture: Nullable<BaseTexture>;
  38425. /**
  38426. * Texture used in all pbr material as the reflection texture.
  38427. * As in the majority of the scene they are the same (exception for multi room and so on),
  38428. * this is easier to reference from here than from all the materials.
  38429. */
  38430. get environmentTexture(): Nullable<BaseTexture>;
  38431. /**
  38432. * Texture used in all pbr material as the reflection texture.
  38433. * As in the majority of the scene they are the same (exception for multi room and so on),
  38434. * this is easier to set here than in all the materials.
  38435. */
  38436. set environmentTexture(value: Nullable<BaseTexture>);
  38437. /** @hidden */
  38438. protected _environmentIntensity: number;
  38439. /**
  38440. * Intensity of the environment in all pbr material.
  38441. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38442. * As in the majority of the scene they are the same (exception for multi room and so on),
  38443. * this is easier to reference from here than from all the materials.
  38444. */
  38445. get environmentIntensity(): number;
  38446. /**
  38447. * Intensity of the environment in all pbr material.
  38448. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38449. * As in the majority of the scene they are the same (exception for multi room and so on),
  38450. * this is easier to set here than in all the materials.
  38451. */
  38452. set environmentIntensity(value: number);
  38453. /** @hidden */
  38454. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38455. /**
  38456. * Default image processing configuration used either in the rendering
  38457. * Forward main pass or through the imageProcessingPostProcess if present.
  38458. * As in the majority of the scene they are the same (exception for multi camera),
  38459. * this is easier to reference from here than from all the materials and post process.
  38460. *
  38461. * No setter as we it is a shared configuration, you can set the values instead.
  38462. */
  38463. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38464. private _forceWireframe;
  38465. /**
  38466. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38467. */
  38468. set forceWireframe(value: boolean);
  38469. get forceWireframe(): boolean;
  38470. private _skipFrustumClipping;
  38471. /**
  38472. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38473. */
  38474. set skipFrustumClipping(value: boolean);
  38475. get skipFrustumClipping(): boolean;
  38476. private _forcePointsCloud;
  38477. /**
  38478. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38479. */
  38480. set forcePointsCloud(value: boolean);
  38481. get forcePointsCloud(): boolean;
  38482. /**
  38483. * Gets or sets the active clipplane 1
  38484. */
  38485. clipPlane: Nullable<Plane>;
  38486. /**
  38487. * Gets or sets the active clipplane 2
  38488. */
  38489. clipPlane2: Nullable<Plane>;
  38490. /**
  38491. * Gets or sets the active clipplane 3
  38492. */
  38493. clipPlane3: Nullable<Plane>;
  38494. /**
  38495. * Gets or sets the active clipplane 4
  38496. */
  38497. clipPlane4: Nullable<Plane>;
  38498. /**
  38499. * Gets or sets the active clipplane 5
  38500. */
  38501. clipPlane5: Nullable<Plane>;
  38502. /**
  38503. * Gets or sets the active clipplane 6
  38504. */
  38505. clipPlane6: Nullable<Plane>;
  38506. /**
  38507. * Gets or sets a boolean indicating if animations are enabled
  38508. */
  38509. animationsEnabled: boolean;
  38510. private _animationPropertiesOverride;
  38511. /**
  38512. * Gets or sets the animation properties override
  38513. */
  38514. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38515. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38516. /**
  38517. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38518. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38519. */
  38520. useConstantAnimationDeltaTime: boolean;
  38521. /**
  38522. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38523. * Please note that it requires to run a ray cast through the scene on every frame
  38524. */
  38525. constantlyUpdateMeshUnderPointer: boolean;
  38526. /**
  38527. * Defines the HTML cursor to use when hovering over interactive elements
  38528. */
  38529. hoverCursor: string;
  38530. /**
  38531. * Defines the HTML default cursor to use (empty by default)
  38532. */
  38533. defaultCursor: string;
  38534. /**
  38535. * Defines whether cursors are handled by the scene.
  38536. */
  38537. doNotHandleCursors: boolean;
  38538. /**
  38539. * This is used to call preventDefault() on pointer down
  38540. * in order to block unwanted artifacts like system double clicks
  38541. */
  38542. preventDefaultOnPointerDown: boolean;
  38543. /**
  38544. * This is used to call preventDefault() on pointer up
  38545. * in order to block unwanted artifacts like system double clicks
  38546. */
  38547. preventDefaultOnPointerUp: boolean;
  38548. /**
  38549. * Gets or sets user defined metadata
  38550. */
  38551. metadata: any;
  38552. /**
  38553. * For internal use only. Please do not use.
  38554. */
  38555. reservedDataStore: any;
  38556. /**
  38557. * Gets the name of the plugin used to load this scene (null by default)
  38558. */
  38559. loadingPluginName: string;
  38560. /**
  38561. * Use this array to add regular expressions used to disable offline support for specific urls
  38562. */
  38563. disableOfflineSupportExceptionRules: RegExp[];
  38564. /**
  38565. * An event triggered when the scene is disposed.
  38566. */
  38567. onDisposeObservable: Observable<Scene>;
  38568. private _onDisposeObserver;
  38569. /** Sets a function to be executed when this scene is disposed. */
  38570. set onDispose(callback: () => void);
  38571. /**
  38572. * An event triggered before rendering the scene (right after animations and physics)
  38573. */
  38574. onBeforeRenderObservable: Observable<Scene>;
  38575. private _onBeforeRenderObserver;
  38576. /** Sets a function to be executed before rendering this scene */
  38577. set beforeRender(callback: Nullable<() => void>);
  38578. /**
  38579. * An event triggered after rendering the scene
  38580. */
  38581. onAfterRenderObservable: Observable<Scene>;
  38582. /**
  38583. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38584. */
  38585. onAfterRenderCameraObservable: Observable<Camera>;
  38586. private _onAfterRenderObserver;
  38587. /** Sets a function to be executed after rendering this scene */
  38588. set afterRender(callback: Nullable<() => void>);
  38589. /**
  38590. * An event triggered before animating the scene
  38591. */
  38592. onBeforeAnimationsObservable: Observable<Scene>;
  38593. /**
  38594. * An event triggered after animations processing
  38595. */
  38596. onAfterAnimationsObservable: Observable<Scene>;
  38597. /**
  38598. * An event triggered before draw calls are ready to be sent
  38599. */
  38600. onBeforeDrawPhaseObservable: Observable<Scene>;
  38601. /**
  38602. * An event triggered after draw calls have been sent
  38603. */
  38604. onAfterDrawPhaseObservable: Observable<Scene>;
  38605. /**
  38606. * An event triggered when the scene is ready
  38607. */
  38608. onReadyObservable: Observable<Scene>;
  38609. /**
  38610. * An event triggered before rendering a camera
  38611. */
  38612. onBeforeCameraRenderObservable: Observable<Camera>;
  38613. private _onBeforeCameraRenderObserver;
  38614. /** Sets a function to be executed before rendering a camera*/
  38615. set beforeCameraRender(callback: () => void);
  38616. /**
  38617. * An event triggered after rendering a camera
  38618. */
  38619. onAfterCameraRenderObservable: Observable<Camera>;
  38620. private _onAfterCameraRenderObserver;
  38621. /** Sets a function to be executed after rendering a camera*/
  38622. set afterCameraRender(callback: () => void);
  38623. /**
  38624. * An event triggered when active meshes evaluation is about to start
  38625. */
  38626. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38627. /**
  38628. * An event triggered when active meshes evaluation is done
  38629. */
  38630. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38631. /**
  38632. * An event triggered when particles rendering is about to start
  38633. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38634. */
  38635. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38636. /**
  38637. * An event triggered when particles rendering is done
  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. onAfterParticlesRenderingObservable: Observable<Scene>;
  38641. /**
  38642. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38643. */
  38644. onDataLoadedObservable: Observable<Scene>;
  38645. /**
  38646. * An event triggered when a camera is created
  38647. */
  38648. onNewCameraAddedObservable: Observable<Camera>;
  38649. /**
  38650. * An event triggered when a camera is removed
  38651. */
  38652. onCameraRemovedObservable: Observable<Camera>;
  38653. /**
  38654. * An event triggered when a light is created
  38655. */
  38656. onNewLightAddedObservable: Observable<Light>;
  38657. /**
  38658. * An event triggered when a light is removed
  38659. */
  38660. onLightRemovedObservable: Observable<Light>;
  38661. /**
  38662. * An event triggered when a geometry is created
  38663. */
  38664. onNewGeometryAddedObservable: Observable<Geometry>;
  38665. /**
  38666. * An event triggered when a geometry is removed
  38667. */
  38668. onGeometryRemovedObservable: Observable<Geometry>;
  38669. /**
  38670. * An event triggered when a transform node is created
  38671. */
  38672. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38673. /**
  38674. * An event triggered when a transform node is removed
  38675. */
  38676. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38677. /**
  38678. * An event triggered when a mesh is created
  38679. */
  38680. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38681. /**
  38682. * An event triggered when a mesh is removed
  38683. */
  38684. onMeshRemovedObservable: Observable<AbstractMesh>;
  38685. /**
  38686. * An event triggered when a skeleton is created
  38687. */
  38688. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38689. /**
  38690. * An event triggered when a skeleton is removed
  38691. */
  38692. onSkeletonRemovedObservable: Observable<Skeleton>;
  38693. /**
  38694. * An event triggered when a material is created
  38695. */
  38696. onNewMaterialAddedObservable: Observable<Material>;
  38697. /**
  38698. * An event triggered when a material is removed
  38699. */
  38700. onMaterialRemovedObservable: Observable<Material>;
  38701. /**
  38702. * An event triggered when a texture is created
  38703. */
  38704. onNewTextureAddedObservable: Observable<BaseTexture>;
  38705. /**
  38706. * An event triggered when a texture is removed
  38707. */
  38708. onTextureRemovedObservable: Observable<BaseTexture>;
  38709. /**
  38710. * An event triggered when render targets are about to be rendered
  38711. * Can happen multiple times per frame.
  38712. */
  38713. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38714. /**
  38715. * An event triggered when render targets were rendered.
  38716. * Can happen multiple times per frame.
  38717. */
  38718. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38719. /**
  38720. * An event triggered before calculating deterministic simulation step
  38721. */
  38722. onBeforeStepObservable: Observable<Scene>;
  38723. /**
  38724. * An event triggered after calculating deterministic simulation step
  38725. */
  38726. onAfterStepObservable: Observable<Scene>;
  38727. /**
  38728. * An event triggered when the activeCamera property is updated
  38729. */
  38730. onActiveCameraChanged: Observable<Scene>;
  38731. /**
  38732. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38733. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38734. * 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)
  38735. */
  38736. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38737. /**
  38738. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38739. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38740. * 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)
  38741. */
  38742. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38743. /**
  38744. * This Observable will when a mesh has been imported into the scene.
  38745. */
  38746. onMeshImportedObservable: Observable<AbstractMesh>;
  38747. /**
  38748. * This Observable will when an animation file has been imported into the scene.
  38749. */
  38750. onAnimationFileImportedObservable: Observable<Scene>;
  38751. /**
  38752. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38753. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38754. */
  38755. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38756. /** @hidden */
  38757. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38758. /**
  38759. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38760. */
  38761. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38762. /**
  38763. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38764. */
  38765. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38766. /**
  38767. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38768. */
  38769. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38770. /** Callback called when a pointer move is detected */
  38771. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38772. /** Callback called when a pointer down is detected */
  38773. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38774. /** Callback called when a pointer up is detected */
  38775. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38776. /** Callback called when a pointer pick is detected */
  38777. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38778. /**
  38779. * 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).
  38780. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38781. */
  38782. onPrePointerObservable: Observable<PointerInfoPre>;
  38783. /**
  38784. * Observable event triggered each time an input event is received from the rendering canvas
  38785. */
  38786. onPointerObservable: Observable<PointerInfo>;
  38787. /**
  38788. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38789. */
  38790. get unTranslatedPointer(): Vector2;
  38791. /**
  38792. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38793. */
  38794. static get DragMovementThreshold(): number;
  38795. static set DragMovementThreshold(value: number);
  38796. /**
  38797. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38798. */
  38799. static get LongPressDelay(): number;
  38800. static set LongPressDelay(value: number);
  38801. /**
  38802. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38803. */
  38804. static get DoubleClickDelay(): number;
  38805. static set DoubleClickDelay(value: number);
  38806. /** If you need to check double click without raising a single click at first click, enable this flag */
  38807. static get ExclusiveDoubleClickMode(): boolean;
  38808. static set ExclusiveDoubleClickMode(value: boolean);
  38809. /** @hidden */
  38810. _mirroredCameraPosition: Nullable<Vector3>;
  38811. /**
  38812. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38813. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38814. */
  38815. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38816. /**
  38817. * Observable event triggered each time an keyboard event is received from the hosting window
  38818. */
  38819. onKeyboardObservable: Observable<KeyboardInfo>;
  38820. private _useRightHandedSystem;
  38821. /**
  38822. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38823. */
  38824. set useRightHandedSystem(value: boolean);
  38825. get useRightHandedSystem(): boolean;
  38826. private _timeAccumulator;
  38827. private _currentStepId;
  38828. private _currentInternalStep;
  38829. /**
  38830. * Sets the step Id used by deterministic lock step
  38831. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38832. * @param newStepId defines the step Id
  38833. */
  38834. setStepId(newStepId: number): void;
  38835. /**
  38836. * Gets the step Id used by deterministic lock step
  38837. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38838. * @returns the step Id
  38839. */
  38840. getStepId(): number;
  38841. /**
  38842. * Gets the internal step used by deterministic lock step
  38843. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38844. * @returns the internal step
  38845. */
  38846. getInternalStep(): number;
  38847. private _fogEnabled;
  38848. /**
  38849. * Gets or sets a boolean indicating if fog is enabled on this scene
  38850. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38851. * (Default is true)
  38852. */
  38853. set fogEnabled(value: boolean);
  38854. get fogEnabled(): boolean;
  38855. private _fogMode;
  38856. /**
  38857. * Gets or sets the fog mode to use
  38858. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38859. * | mode | value |
  38860. * | --- | --- |
  38861. * | FOGMODE_NONE | 0 |
  38862. * | FOGMODE_EXP | 1 |
  38863. * | FOGMODE_EXP2 | 2 |
  38864. * | FOGMODE_LINEAR | 3 |
  38865. */
  38866. set fogMode(value: number);
  38867. get fogMode(): number;
  38868. /**
  38869. * Gets or sets the fog color to use
  38870. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38871. * (Default is Color3(0.2, 0.2, 0.3))
  38872. */
  38873. fogColor: Color3;
  38874. /**
  38875. * Gets or sets the fog density to use
  38876. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38877. * (Default is 0.1)
  38878. */
  38879. fogDensity: number;
  38880. /**
  38881. * Gets or sets the fog start distance to use
  38882. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38883. * (Default is 0)
  38884. */
  38885. fogStart: number;
  38886. /**
  38887. * Gets or sets the fog end distance to use
  38888. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38889. * (Default is 1000)
  38890. */
  38891. fogEnd: number;
  38892. /**
  38893. * Flag indicating that the frame buffer binding is handled by another component
  38894. */
  38895. prePass: boolean;
  38896. private _shadowsEnabled;
  38897. /**
  38898. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38899. */
  38900. set shadowsEnabled(value: boolean);
  38901. get shadowsEnabled(): boolean;
  38902. private _lightsEnabled;
  38903. /**
  38904. * Gets or sets a boolean indicating if lights are enabled on this scene
  38905. */
  38906. set lightsEnabled(value: boolean);
  38907. get lightsEnabled(): boolean;
  38908. /** All of the active cameras added to this scene. */
  38909. activeCameras: Camera[];
  38910. /** @hidden */
  38911. _activeCamera: Nullable<Camera>;
  38912. /** Gets or sets the current active camera */
  38913. get activeCamera(): Nullable<Camera>;
  38914. set activeCamera(value: Nullable<Camera>);
  38915. private _defaultMaterial;
  38916. /** The default material used on meshes when no material is affected */
  38917. get defaultMaterial(): Material;
  38918. /** The default material used on meshes when no material is affected */
  38919. set defaultMaterial(value: Material);
  38920. private _texturesEnabled;
  38921. /**
  38922. * Gets or sets a boolean indicating if textures are enabled on this scene
  38923. */
  38924. set texturesEnabled(value: boolean);
  38925. get texturesEnabled(): boolean;
  38926. /**
  38927. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38928. */
  38929. physicsEnabled: boolean;
  38930. /**
  38931. * Gets or sets a boolean indicating if particles are enabled on this scene
  38932. */
  38933. particlesEnabled: boolean;
  38934. /**
  38935. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38936. */
  38937. spritesEnabled: boolean;
  38938. private _skeletonsEnabled;
  38939. /**
  38940. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38941. */
  38942. set skeletonsEnabled(value: boolean);
  38943. get skeletonsEnabled(): boolean;
  38944. /**
  38945. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38946. */
  38947. lensFlaresEnabled: boolean;
  38948. /**
  38949. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38950. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38951. */
  38952. collisionsEnabled: boolean;
  38953. private _collisionCoordinator;
  38954. /** @hidden */
  38955. get collisionCoordinator(): ICollisionCoordinator;
  38956. /**
  38957. * Defines the gravity applied to this scene (used only for collisions)
  38958. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38959. */
  38960. gravity: Vector3;
  38961. /**
  38962. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38963. */
  38964. postProcessesEnabled: boolean;
  38965. /**
  38966. * The list of postprocesses added to the scene
  38967. */
  38968. postProcesses: PostProcess[];
  38969. /**
  38970. * Gets the current postprocess manager
  38971. */
  38972. postProcessManager: PostProcessManager;
  38973. /**
  38974. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38975. */
  38976. renderTargetsEnabled: boolean;
  38977. /**
  38978. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38979. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38980. */
  38981. dumpNextRenderTargets: boolean;
  38982. /**
  38983. * The list of user defined render targets added to the scene
  38984. */
  38985. customRenderTargets: RenderTargetTexture[];
  38986. /**
  38987. * Defines if texture loading must be delayed
  38988. * If true, textures will only be loaded when they need to be rendered
  38989. */
  38990. useDelayedTextureLoading: boolean;
  38991. /**
  38992. * Gets the list of meshes imported to the scene through SceneLoader
  38993. */
  38994. importedMeshesFiles: String[];
  38995. /**
  38996. * Gets or sets a boolean indicating if probes are enabled on this scene
  38997. */
  38998. probesEnabled: boolean;
  38999. /**
  39000. * Gets or sets the current offline provider to use to store scene data
  39001. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39002. */
  39003. offlineProvider: IOfflineProvider;
  39004. /**
  39005. * Gets or sets the action manager associated with the scene
  39006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39007. */
  39008. actionManager: AbstractActionManager;
  39009. private _meshesForIntersections;
  39010. /**
  39011. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39012. */
  39013. proceduralTexturesEnabled: boolean;
  39014. private _engine;
  39015. private _totalVertices;
  39016. /** @hidden */
  39017. _activeIndices: PerfCounter;
  39018. /** @hidden */
  39019. _activeParticles: PerfCounter;
  39020. /** @hidden */
  39021. _activeBones: PerfCounter;
  39022. private _animationRatio;
  39023. /** @hidden */
  39024. _animationTimeLast: number;
  39025. /** @hidden */
  39026. _animationTime: number;
  39027. /**
  39028. * Gets or sets a general scale for animation speed
  39029. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39030. */
  39031. animationTimeScale: number;
  39032. /** @hidden */
  39033. _cachedMaterial: Nullable<Material>;
  39034. /** @hidden */
  39035. _cachedEffect: Nullable<Effect>;
  39036. /** @hidden */
  39037. _cachedVisibility: Nullable<number>;
  39038. private _renderId;
  39039. private _frameId;
  39040. private _executeWhenReadyTimeoutId;
  39041. private _intermediateRendering;
  39042. private _viewUpdateFlag;
  39043. private _projectionUpdateFlag;
  39044. /** @hidden */
  39045. _toBeDisposed: Nullable<IDisposable>[];
  39046. private _activeRequests;
  39047. /** @hidden */
  39048. _pendingData: any[];
  39049. private _isDisposed;
  39050. /**
  39051. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39052. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39053. */
  39054. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39055. private _activeMeshes;
  39056. private _processedMaterials;
  39057. private _renderTargets;
  39058. /** @hidden */
  39059. _activeParticleSystems: SmartArray<IParticleSystem>;
  39060. private _activeSkeletons;
  39061. private _softwareSkinnedMeshes;
  39062. private _renderingManager;
  39063. /** @hidden */
  39064. _activeAnimatables: Animatable[];
  39065. private _transformMatrix;
  39066. private _sceneUbo;
  39067. /** @hidden */
  39068. _viewMatrix: Matrix;
  39069. private _projectionMatrix;
  39070. /** @hidden */
  39071. _forcedViewPosition: Nullable<Vector3>;
  39072. /** @hidden */
  39073. _frustumPlanes: Plane[];
  39074. /**
  39075. * Gets the list of frustum planes (built from the active camera)
  39076. */
  39077. get frustumPlanes(): Plane[];
  39078. /**
  39079. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39080. * This is useful if there are more lights that the maximum simulteanous authorized
  39081. */
  39082. requireLightSorting: boolean;
  39083. /** @hidden */
  39084. readonly useMaterialMeshMap: boolean;
  39085. /** @hidden */
  39086. readonly useClonedMeshMap: boolean;
  39087. private _externalData;
  39088. private _uid;
  39089. /**
  39090. * @hidden
  39091. * Backing store of defined scene components.
  39092. */
  39093. _components: ISceneComponent[];
  39094. /**
  39095. * @hidden
  39096. * Backing store of defined scene components.
  39097. */
  39098. _serializableComponents: ISceneSerializableComponent[];
  39099. /**
  39100. * List of components to register on the next registration step.
  39101. */
  39102. private _transientComponents;
  39103. /**
  39104. * Registers the transient components if needed.
  39105. */
  39106. private _registerTransientComponents;
  39107. /**
  39108. * @hidden
  39109. * Add a component to the scene.
  39110. * Note that the ccomponent could be registered on th next frame if this is called after
  39111. * the register component stage.
  39112. * @param component Defines the component to add to the scene
  39113. */
  39114. _addComponent(component: ISceneComponent): void;
  39115. /**
  39116. * @hidden
  39117. * Gets a component from the scene.
  39118. * @param name defines the name of the component to retrieve
  39119. * @returns the component or null if not present
  39120. */
  39121. _getComponent(name: string): Nullable<ISceneComponent>;
  39122. /**
  39123. * @hidden
  39124. * Defines the actions happening before camera updates.
  39125. */
  39126. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39127. /**
  39128. * @hidden
  39129. * Defines the actions happening before clear the canvas.
  39130. */
  39131. _beforeClearStage: Stage<SimpleStageAction>;
  39132. /**
  39133. * @hidden
  39134. * Defines the actions when collecting render targets for the frame.
  39135. */
  39136. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39137. /**
  39138. * @hidden
  39139. * Defines the actions happening for one camera in the frame.
  39140. */
  39141. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39142. /**
  39143. * @hidden
  39144. * Defines the actions happening during the per mesh ready checks.
  39145. */
  39146. _isReadyForMeshStage: Stage<MeshStageAction>;
  39147. /**
  39148. * @hidden
  39149. * Defines the actions happening before evaluate active mesh checks.
  39150. */
  39151. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39152. /**
  39153. * @hidden
  39154. * Defines the actions happening during the evaluate sub mesh checks.
  39155. */
  39156. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39157. /**
  39158. * @hidden
  39159. * Defines the actions happening during the active mesh stage.
  39160. */
  39161. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39162. /**
  39163. * @hidden
  39164. * Defines the actions happening during the per camera render target step.
  39165. */
  39166. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39167. /**
  39168. * @hidden
  39169. * Defines the actions happening just before the active camera is drawing.
  39170. */
  39171. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39172. /**
  39173. * @hidden
  39174. * Defines the actions happening just before a render target is drawing.
  39175. */
  39176. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39177. /**
  39178. * @hidden
  39179. * Defines the actions happening just before a rendering group is drawing.
  39180. */
  39181. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39182. /**
  39183. * @hidden
  39184. * Defines the actions happening just before a mesh is drawing.
  39185. */
  39186. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39187. /**
  39188. * @hidden
  39189. * Defines the actions happening just after a mesh has been drawn.
  39190. */
  39191. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39192. /**
  39193. * @hidden
  39194. * Defines the actions happening just after a rendering group has been drawn.
  39195. */
  39196. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39197. /**
  39198. * @hidden
  39199. * Defines the actions happening just after the active camera has been drawn.
  39200. */
  39201. _afterCameraDrawStage: Stage<CameraStageAction>;
  39202. /**
  39203. * @hidden
  39204. * Defines the actions happening just after a render target has been drawn.
  39205. */
  39206. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39207. /**
  39208. * @hidden
  39209. * Defines the actions happening just after rendering all cameras and computing intersections.
  39210. */
  39211. _afterRenderStage: Stage<SimpleStageAction>;
  39212. /**
  39213. * @hidden
  39214. * Defines the actions happening when a pointer move event happens.
  39215. */
  39216. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39217. /**
  39218. * @hidden
  39219. * Defines the actions happening when a pointer down event happens.
  39220. */
  39221. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39222. /**
  39223. * @hidden
  39224. * Defines the actions happening when a pointer up event happens.
  39225. */
  39226. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39227. /**
  39228. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39229. */
  39230. private geometriesByUniqueId;
  39231. /**
  39232. * Creates a new Scene
  39233. * @param engine defines the engine to use to render this scene
  39234. * @param options defines the scene options
  39235. */
  39236. constructor(engine: Engine, options?: SceneOptions);
  39237. /**
  39238. * Gets a string idenfifying the name of the class
  39239. * @returns "Scene" string
  39240. */
  39241. getClassName(): string;
  39242. private _defaultMeshCandidates;
  39243. /**
  39244. * @hidden
  39245. */
  39246. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39247. private _defaultSubMeshCandidates;
  39248. /**
  39249. * @hidden
  39250. */
  39251. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39252. /**
  39253. * Sets the default candidate providers for the scene.
  39254. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39255. * and getCollidingSubMeshCandidates to their default function
  39256. */
  39257. setDefaultCandidateProviders(): void;
  39258. /**
  39259. * Gets the mesh that is currently under the pointer
  39260. */
  39261. get meshUnderPointer(): Nullable<AbstractMesh>;
  39262. /**
  39263. * Gets or sets the current on-screen X position of the pointer
  39264. */
  39265. get pointerX(): number;
  39266. set pointerX(value: number);
  39267. /**
  39268. * Gets or sets the current on-screen Y position of the pointer
  39269. */
  39270. get pointerY(): number;
  39271. set pointerY(value: number);
  39272. /**
  39273. * Gets the cached material (ie. the latest rendered one)
  39274. * @returns the cached material
  39275. */
  39276. getCachedMaterial(): Nullable<Material>;
  39277. /**
  39278. * Gets the cached effect (ie. the latest rendered one)
  39279. * @returns the cached effect
  39280. */
  39281. getCachedEffect(): Nullable<Effect>;
  39282. /**
  39283. * Gets the cached visibility state (ie. the latest rendered one)
  39284. * @returns the cached visibility state
  39285. */
  39286. getCachedVisibility(): Nullable<number>;
  39287. /**
  39288. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39289. * @param material defines the current material
  39290. * @param effect defines the current effect
  39291. * @param visibility defines the current visibility state
  39292. * @returns true if one parameter is not cached
  39293. */
  39294. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39295. /**
  39296. * Gets the engine associated with the scene
  39297. * @returns an Engine
  39298. */
  39299. getEngine(): Engine;
  39300. /**
  39301. * Gets the total number of vertices rendered per frame
  39302. * @returns the total number of vertices rendered per frame
  39303. */
  39304. getTotalVertices(): number;
  39305. /**
  39306. * Gets the performance counter for total vertices
  39307. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39308. */
  39309. get totalVerticesPerfCounter(): PerfCounter;
  39310. /**
  39311. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39312. * @returns the total number of active indices rendered per frame
  39313. */
  39314. getActiveIndices(): number;
  39315. /**
  39316. * Gets the performance counter for active indices
  39317. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39318. */
  39319. get totalActiveIndicesPerfCounter(): PerfCounter;
  39320. /**
  39321. * Gets the total number of active particles rendered per frame
  39322. * @returns the total number of active particles rendered per frame
  39323. */
  39324. getActiveParticles(): number;
  39325. /**
  39326. * Gets the performance counter for active particles
  39327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39328. */
  39329. get activeParticlesPerfCounter(): PerfCounter;
  39330. /**
  39331. * Gets the total number of active bones rendered per frame
  39332. * @returns the total number of active bones rendered per frame
  39333. */
  39334. getActiveBones(): number;
  39335. /**
  39336. * Gets the performance counter for active bones
  39337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39338. */
  39339. get activeBonesPerfCounter(): PerfCounter;
  39340. /**
  39341. * Gets the array of active meshes
  39342. * @returns an array of AbstractMesh
  39343. */
  39344. getActiveMeshes(): SmartArray<AbstractMesh>;
  39345. /**
  39346. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39347. * @returns a number
  39348. */
  39349. getAnimationRatio(): number;
  39350. /**
  39351. * Gets an unique Id for the current render phase
  39352. * @returns a number
  39353. */
  39354. getRenderId(): number;
  39355. /**
  39356. * Gets an unique Id for the current frame
  39357. * @returns a number
  39358. */
  39359. getFrameId(): number;
  39360. /** Call this function if you want to manually increment the render Id*/
  39361. incrementRenderId(): void;
  39362. private _createUbo;
  39363. /**
  39364. * Use this method to simulate a pointer move on a mesh
  39365. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39366. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39367. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39368. * @returns the current scene
  39369. */
  39370. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39371. /**
  39372. * Use this method to simulate a pointer down on a mesh
  39373. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39374. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39375. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39376. * @returns the current scene
  39377. */
  39378. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39379. /**
  39380. * Use this method to simulate a pointer up on a mesh
  39381. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39382. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39383. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39384. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39385. * @returns the current scene
  39386. */
  39387. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39388. /**
  39389. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39390. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39391. * @returns true if the pointer was captured
  39392. */
  39393. isPointerCaptured(pointerId?: number): boolean;
  39394. /**
  39395. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39396. * @param attachUp defines if you want to attach events to pointerup
  39397. * @param attachDown defines if you want to attach events to pointerdown
  39398. * @param attachMove defines if you want to attach events to pointermove
  39399. */
  39400. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39401. /** Detaches all event handlers*/
  39402. detachControl(): void;
  39403. /**
  39404. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39405. * Delay loaded resources are not taking in account
  39406. * @return true if all required resources are ready
  39407. */
  39408. isReady(): boolean;
  39409. /** Resets all cached information relative to material (including effect and visibility) */
  39410. resetCachedMaterial(): void;
  39411. /**
  39412. * Registers a function to be called before every frame render
  39413. * @param func defines the function to register
  39414. */
  39415. registerBeforeRender(func: () => void): void;
  39416. /**
  39417. * Unregisters a function called before every frame render
  39418. * @param func defines the function to unregister
  39419. */
  39420. unregisterBeforeRender(func: () => void): void;
  39421. /**
  39422. * Registers a function to be called after every frame render
  39423. * @param func defines the function to register
  39424. */
  39425. registerAfterRender(func: () => void): void;
  39426. /**
  39427. * Unregisters a function called after every frame render
  39428. * @param func defines the function to unregister
  39429. */
  39430. unregisterAfterRender(func: () => void): void;
  39431. private _executeOnceBeforeRender;
  39432. /**
  39433. * The provided function will run before render once and will be disposed afterwards.
  39434. * A timeout delay can be provided so that the function will be executed in N ms.
  39435. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39436. * @param func The function to be executed.
  39437. * @param timeout optional delay in ms
  39438. */
  39439. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39440. /** @hidden */
  39441. _addPendingData(data: any): void;
  39442. /** @hidden */
  39443. _removePendingData(data: any): void;
  39444. /**
  39445. * Returns the number of items waiting to be loaded
  39446. * @returns the number of items waiting to be loaded
  39447. */
  39448. getWaitingItemsCount(): number;
  39449. /**
  39450. * Returns a boolean indicating if the scene is still loading data
  39451. */
  39452. get isLoading(): boolean;
  39453. /**
  39454. * Registers a function to be executed when the scene is ready
  39455. * @param {Function} func - the function to be executed
  39456. */
  39457. executeWhenReady(func: () => void): void;
  39458. /**
  39459. * Returns a promise that resolves when the scene is ready
  39460. * @returns A promise that resolves when the scene is ready
  39461. */
  39462. whenReadyAsync(): Promise<void>;
  39463. /** @hidden */
  39464. _checkIsReady(): void;
  39465. /**
  39466. * Gets all animatable attached to the scene
  39467. */
  39468. get animatables(): Animatable[];
  39469. /**
  39470. * Resets the last animation time frame.
  39471. * Useful to override when animations start running when loading a scene for the first time.
  39472. */
  39473. resetLastAnimationTimeFrame(): void;
  39474. /**
  39475. * Gets the current view matrix
  39476. * @returns a Matrix
  39477. */
  39478. getViewMatrix(): Matrix;
  39479. /**
  39480. * Gets the current projection matrix
  39481. * @returns a Matrix
  39482. */
  39483. getProjectionMatrix(): Matrix;
  39484. /**
  39485. * Gets the current transform matrix
  39486. * @returns a Matrix made of View * Projection
  39487. */
  39488. getTransformMatrix(): Matrix;
  39489. /**
  39490. * Sets the current transform matrix
  39491. * @param viewL defines the View matrix to use
  39492. * @param projectionL defines the Projection matrix to use
  39493. * @param viewR defines the right View matrix to use (if provided)
  39494. * @param projectionR defines the right Projection matrix to use (if provided)
  39495. */
  39496. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39497. /**
  39498. * Gets the uniform buffer used to store scene data
  39499. * @returns a UniformBuffer
  39500. */
  39501. getSceneUniformBuffer(): UniformBuffer;
  39502. /**
  39503. * Gets an unique (relatively to the current scene) Id
  39504. * @returns an unique number for the scene
  39505. */
  39506. getUniqueId(): number;
  39507. /**
  39508. * Add a mesh to the list of scene's meshes
  39509. * @param newMesh defines the mesh to add
  39510. * @param recursive if all child meshes should also be added to the scene
  39511. */
  39512. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39513. /**
  39514. * Remove a mesh for the list of scene's meshes
  39515. * @param toRemove defines the mesh to remove
  39516. * @param recursive if all child meshes should also be removed from the scene
  39517. * @returns the index where the mesh was in the mesh list
  39518. */
  39519. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39520. /**
  39521. * Add a transform node to the list of scene's transform nodes
  39522. * @param newTransformNode defines the transform node to add
  39523. */
  39524. addTransformNode(newTransformNode: TransformNode): void;
  39525. /**
  39526. * Remove a transform node for the list of scene's transform nodes
  39527. * @param toRemove defines the transform node to remove
  39528. * @returns the index where the transform node was in the transform node list
  39529. */
  39530. removeTransformNode(toRemove: TransformNode): number;
  39531. /**
  39532. * Remove a skeleton for the list of scene's skeletons
  39533. * @param toRemove defines the skeleton to remove
  39534. * @returns the index where the skeleton was in the skeleton list
  39535. */
  39536. removeSkeleton(toRemove: Skeleton): number;
  39537. /**
  39538. * Remove a morph target for the list of scene's morph targets
  39539. * @param toRemove defines the morph target to remove
  39540. * @returns the index where the morph target was in the morph target list
  39541. */
  39542. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39543. /**
  39544. * Remove a light for the list of scene's lights
  39545. * @param toRemove defines the light to remove
  39546. * @returns the index where the light was in the light list
  39547. */
  39548. removeLight(toRemove: Light): number;
  39549. /**
  39550. * Remove a camera for the list of scene's cameras
  39551. * @param toRemove defines the camera to remove
  39552. * @returns the index where the camera was in the camera list
  39553. */
  39554. removeCamera(toRemove: Camera): number;
  39555. /**
  39556. * Remove a particle system for the list of scene's particle systems
  39557. * @param toRemove defines the particle system to remove
  39558. * @returns the index where the particle system was in the particle system list
  39559. */
  39560. removeParticleSystem(toRemove: IParticleSystem): number;
  39561. /**
  39562. * Remove a animation for the list of scene's animations
  39563. * @param toRemove defines the animation to remove
  39564. * @returns the index where the animation was in the animation list
  39565. */
  39566. removeAnimation(toRemove: Animation): number;
  39567. /**
  39568. * Will stop the animation of the given target
  39569. * @param target - the target
  39570. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39571. * @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)
  39572. */
  39573. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39574. /**
  39575. * Removes the given animation group from this scene.
  39576. * @param toRemove The animation group to remove
  39577. * @returns The index of the removed animation group
  39578. */
  39579. removeAnimationGroup(toRemove: AnimationGroup): number;
  39580. /**
  39581. * Removes the given multi-material from this scene.
  39582. * @param toRemove The multi-material to remove
  39583. * @returns The index of the removed multi-material
  39584. */
  39585. removeMultiMaterial(toRemove: MultiMaterial): number;
  39586. /**
  39587. * Removes the given material from this scene.
  39588. * @param toRemove The material to remove
  39589. * @returns The index of the removed material
  39590. */
  39591. removeMaterial(toRemove: Material): number;
  39592. /**
  39593. * Removes the given action manager from this scene.
  39594. * @param toRemove The action manager to remove
  39595. * @returns The index of the removed action manager
  39596. */
  39597. removeActionManager(toRemove: AbstractActionManager): number;
  39598. /**
  39599. * Removes the given texture from this scene.
  39600. * @param toRemove The texture to remove
  39601. * @returns The index of the removed texture
  39602. */
  39603. removeTexture(toRemove: BaseTexture): number;
  39604. /**
  39605. * Adds the given light to this scene
  39606. * @param newLight The light to add
  39607. */
  39608. addLight(newLight: Light): void;
  39609. /**
  39610. * Sorts the list list based on light priorities
  39611. */
  39612. sortLightsByPriority(): void;
  39613. /**
  39614. * Adds the given camera to this scene
  39615. * @param newCamera The camera to add
  39616. */
  39617. addCamera(newCamera: Camera): void;
  39618. /**
  39619. * Adds the given skeleton to this scene
  39620. * @param newSkeleton The skeleton to add
  39621. */
  39622. addSkeleton(newSkeleton: Skeleton): void;
  39623. /**
  39624. * Adds the given particle system to this scene
  39625. * @param newParticleSystem The particle system to add
  39626. */
  39627. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39628. /**
  39629. * Adds the given animation to this scene
  39630. * @param newAnimation The animation to add
  39631. */
  39632. addAnimation(newAnimation: Animation): void;
  39633. /**
  39634. * Adds the given animation group to this scene.
  39635. * @param newAnimationGroup The animation group to add
  39636. */
  39637. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39638. /**
  39639. * Adds the given multi-material to this scene
  39640. * @param newMultiMaterial The multi-material to add
  39641. */
  39642. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39643. /**
  39644. * Adds the given material to this scene
  39645. * @param newMaterial The material to add
  39646. */
  39647. addMaterial(newMaterial: Material): void;
  39648. /**
  39649. * Adds the given morph target to this scene
  39650. * @param newMorphTargetManager The morph target to add
  39651. */
  39652. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39653. /**
  39654. * Adds the given geometry to this scene
  39655. * @param newGeometry The geometry to add
  39656. */
  39657. addGeometry(newGeometry: Geometry): void;
  39658. /**
  39659. * Adds the given action manager to this scene
  39660. * @param newActionManager The action manager to add
  39661. */
  39662. addActionManager(newActionManager: AbstractActionManager): void;
  39663. /**
  39664. * Adds the given texture to this scene.
  39665. * @param newTexture The texture to add
  39666. */
  39667. addTexture(newTexture: BaseTexture): void;
  39668. /**
  39669. * Switch active camera
  39670. * @param newCamera defines the new active camera
  39671. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39672. */
  39673. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39674. /**
  39675. * sets the active camera of the scene using its ID
  39676. * @param id defines the camera's ID
  39677. * @return the new active camera or null if none found.
  39678. */
  39679. setActiveCameraByID(id: string): Nullable<Camera>;
  39680. /**
  39681. * sets the active camera of the scene using its name
  39682. * @param name defines the camera's name
  39683. * @returns the new active camera or null if none found.
  39684. */
  39685. setActiveCameraByName(name: string): Nullable<Camera>;
  39686. /**
  39687. * get an animation group using its name
  39688. * @param name defines the material's name
  39689. * @return the animation group or null if none found.
  39690. */
  39691. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39692. /**
  39693. * Get a material using its unique id
  39694. * @param uniqueId defines the material's unique id
  39695. * @return the material or null if none found.
  39696. */
  39697. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39698. /**
  39699. * get a material using its id
  39700. * @param id defines the material's ID
  39701. * @return the material or null if none found.
  39702. */
  39703. getMaterialByID(id: string): Nullable<Material>;
  39704. /**
  39705. * Gets a the last added material using a given id
  39706. * @param id defines the material's ID
  39707. * @return the last material with the given id or null if none found.
  39708. */
  39709. getLastMaterialByID(id: string): Nullable<Material>;
  39710. /**
  39711. * Gets a material using its name
  39712. * @param name defines the material's name
  39713. * @return the material or null if none found.
  39714. */
  39715. getMaterialByName(name: string): Nullable<Material>;
  39716. /**
  39717. * Get a texture using its unique id
  39718. * @param uniqueId defines the texture's unique id
  39719. * @return the texture or null if none found.
  39720. */
  39721. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39722. /**
  39723. * Gets a camera using its id
  39724. * @param id defines the id to look for
  39725. * @returns the camera or null if not found
  39726. */
  39727. getCameraByID(id: string): Nullable<Camera>;
  39728. /**
  39729. * Gets a camera using its unique id
  39730. * @param uniqueId defines the unique id to look for
  39731. * @returns the camera or null if not found
  39732. */
  39733. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39734. /**
  39735. * Gets a camera using its name
  39736. * @param name defines the camera's name
  39737. * @return the camera or null if none found.
  39738. */
  39739. getCameraByName(name: string): Nullable<Camera>;
  39740. /**
  39741. * Gets a bone using its id
  39742. * @param id defines the bone's id
  39743. * @return the bone or null if not found
  39744. */
  39745. getBoneByID(id: string): Nullable<Bone>;
  39746. /**
  39747. * Gets a bone using its id
  39748. * @param name defines the bone's name
  39749. * @return the bone or null if not found
  39750. */
  39751. getBoneByName(name: string): Nullable<Bone>;
  39752. /**
  39753. * Gets a light node using its name
  39754. * @param name defines the the light's name
  39755. * @return the light or null if none found.
  39756. */
  39757. getLightByName(name: string): Nullable<Light>;
  39758. /**
  39759. * Gets a light node using its id
  39760. * @param id defines the light's id
  39761. * @return the light or null if none found.
  39762. */
  39763. getLightByID(id: string): Nullable<Light>;
  39764. /**
  39765. * Gets a light node using its scene-generated unique ID
  39766. * @param uniqueId defines the light's unique id
  39767. * @return the light or null if none found.
  39768. */
  39769. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39770. /**
  39771. * Gets a particle system by id
  39772. * @param id defines the particle system id
  39773. * @return the corresponding system or null if none found
  39774. */
  39775. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39776. /**
  39777. * Gets a geometry using its ID
  39778. * @param id defines the geometry's id
  39779. * @return the geometry or null if none found.
  39780. */
  39781. getGeometryByID(id: string): Nullable<Geometry>;
  39782. private _getGeometryByUniqueID;
  39783. /**
  39784. * Add a new geometry to this scene
  39785. * @param geometry defines the geometry to be added to the scene.
  39786. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39787. * @return a boolean defining if the geometry was added or not
  39788. */
  39789. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39790. /**
  39791. * Removes an existing geometry
  39792. * @param geometry defines the geometry to be removed from the scene
  39793. * @return a boolean defining if the geometry was removed or not
  39794. */
  39795. removeGeometry(geometry: Geometry): boolean;
  39796. /**
  39797. * Gets the list of geometries attached to the scene
  39798. * @returns an array of Geometry
  39799. */
  39800. getGeometries(): Geometry[];
  39801. /**
  39802. * Gets the first added mesh found of a given ID
  39803. * @param id defines the id to search for
  39804. * @return the mesh found or null if not found at all
  39805. */
  39806. getMeshByID(id: string): Nullable<AbstractMesh>;
  39807. /**
  39808. * Gets a list of meshes using their id
  39809. * @param id defines the id to search for
  39810. * @returns a list of meshes
  39811. */
  39812. getMeshesByID(id: string): Array<AbstractMesh>;
  39813. /**
  39814. * Gets the first added transform node found of a given ID
  39815. * @param id defines the id to search for
  39816. * @return the found transform node or null if not found at all.
  39817. */
  39818. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39819. /**
  39820. * Gets a transform node with its auto-generated unique id
  39821. * @param uniqueId efines the unique id to search for
  39822. * @return the found transform node or null if not found at all.
  39823. */
  39824. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39825. /**
  39826. * Gets a list of transform nodes using their id
  39827. * @param id defines the id to search for
  39828. * @returns a list of transform nodes
  39829. */
  39830. getTransformNodesByID(id: string): Array<TransformNode>;
  39831. /**
  39832. * Gets a mesh with its auto-generated unique id
  39833. * @param uniqueId defines the unique id to search for
  39834. * @return the found mesh or null if not found at all.
  39835. */
  39836. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39837. /**
  39838. * Gets a the last added mesh using a given id
  39839. * @param id defines the id to search for
  39840. * @return the found mesh or null if not found at all.
  39841. */
  39842. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39843. /**
  39844. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39845. * @param id defines the id to search for
  39846. * @return the found node or null if not found at all
  39847. */
  39848. getLastEntryByID(id: string): Nullable<Node>;
  39849. /**
  39850. * Gets a node (Mesh, Camera, Light) using a given id
  39851. * @param id defines the id to search for
  39852. * @return the found node or null if not found at all
  39853. */
  39854. getNodeByID(id: string): Nullable<Node>;
  39855. /**
  39856. * Gets a node (Mesh, Camera, Light) using a given name
  39857. * @param name defines the name to search for
  39858. * @return the found node or null if not found at all.
  39859. */
  39860. getNodeByName(name: string): Nullable<Node>;
  39861. /**
  39862. * Gets a mesh using a given name
  39863. * @param name defines the name to search for
  39864. * @return the found mesh or null if not found at all.
  39865. */
  39866. getMeshByName(name: string): Nullable<AbstractMesh>;
  39867. /**
  39868. * Gets a transform node using a given name
  39869. * @param name defines the name to search for
  39870. * @return the found transform node or null if not found at all.
  39871. */
  39872. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39873. /**
  39874. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39875. * @param id defines the id to search for
  39876. * @return the found skeleton or null if not found at all.
  39877. */
  39878. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39879. /**
  39880. * Gets a skeleton using a given auto generated unique id
  39881. * @param uniqueId defines the unique id to search for
  39882. * @return the found skeleton or null if not found at all.
  39883. */
  39884. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39885. /**
  39886. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39887. * @param id defines the id to search for
  39888. * @return the found skeleton or null if not found at all.
  39889. */
  39890. getSkeletonById(id: string): Nullable<Skeleton>;
  39891. /**
  39892. * Gets a skeleton using a given name
  39893. * @param name defines the name to search for
  39894. * @return the found skeleton or null if not found at all.
  39895. */
  39896. getSkeletonByName(name: string): Nullable<Skeleton>;
  39897. /**
  39898. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39899. * @param id defines the id to search for
  39900. * @return the found morph target manager or null if not found at all.
  39901. */
  39902. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39903. /**
  39904. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39905. * @param id defines the id to search for
  39906. * @return the found morph target or null if not found at all.
  39907. */
  39908. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39909. /**
  39910. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39911. * @param name defines the name to search for
  39912. * @return the found morph target or null if not found at all.
  39913. */
  39914. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39915. /**
  39916. * Gets a boolean indicating if the given mesh is active
  39917. * @param mesh defines the mesh to look for
  39918. * @returns true if the mesh is in the active list
  39919. */
  39920. isActiveMesh(mesh: AbstractMesh): boolean;
  39921. /**
  39922. * Return a unique id as a string which can serve as an identifier for the scene
  39923. */
  39924. get uid(): string;
  39925. /**
  39926. * Add an externaly attached data from its key.
  39927. * This method call will fail and return false, if such key already exists.
  39928. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39929. * @param key the unique key that identifies the data
  39930. * @param data the data object to associate to the key for this Engine instance
  39931. * @return true if no such key were already present and the data was added successfully, false otherwise
  39932. */
  39933. addExternalData<T>(key: string, data: T): boolean;
  39934. /**
  39935. * Get an externaly attached data from its key
  39936. * @param key the unique key that identifies the data
  39937. * @return the associated data, if present (can be null), or undefined if not present
  39938. */
  39939. getExternalData<T>(key: string): Nullable<T>;
  39940. /**
  39941. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39942. * @param key the unique key that identifies the data
  39943. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39944. * @return the associated data, can be null if the factory returned null.
  39945. */
  39946. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39947. /**
  39948. * Remove an externaly attached data from the Engine instance
  39949. * @param key the unique key that identifies the data
  39950. * @return true if the data was successfully removed, false if it doesn't exist
  39951. */
  39952. removeExternalData(key: string): boolean;
  39953. private _evaluateSubMesh;
  39954. /**
  39955. * Clear the processed materials smart array preventing retention point in material dispose.
  39956. */
  39957. freeProcessedMaterials(): void;
  39958. private _preventFreeActiveMeshesAndRenderingGroups;
  39959. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39960. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39961. * when disposing several meshes in a row or a hierarchy of meshes.
  39962. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39963. */
  39964. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39965. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39966. /**
  39967. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39968. */
  39969. freeActiveMeshes(): void;
  39970. /**
  39971. * Clear the info related to rendering groups preventing retention points during dispose.
  39972. */
  39973. freeRenderingGroups(): void;
  39974. /** @hidden */
  39975. _isInIntermediateRendering(): boolean;
  39976. /**
  39977. * Lambda returning the list of potentially active meshes.
  39978. */
  39979. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39980. /**
  39981. * Lambda returning the list of potentially active sub meshes.
  39982. */
  39983. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39984. /**
  39985. * Lambda returning the list of potentially intersecting sub meshes.
  39986. */
  39987. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39988. /**
  39989. * Lambda returning the list of potentially colliding sub meshes.
  39990. */
  39991. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39992. private _activeMeshesFrozen;
  39993. private _skipEvaluateActiveMeshesCompletely;
  39994. /**
  39995. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39996. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39997. * @returns the current scene
  39998. */
  39999. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40000. /**
  40001. * Use this function to restart evaluating active meshes on every frame
  40002. * @returns the current scene
  40003. */
  40004. unfreezeActiveMeshes(): Scene;
  40005. private _evaluateActiveMeshes;
  40006. private _activeMesh;
  40007. /**
  40008. * Update the transform matrix to update from the current active camera
  40009. * @param force defines a boolean used to force the update even if cache is up to date
  40010. */
  40011. updateTransformMatrix(force?: boolean): void;
  40012. private _bindFrameBuffer;
  40013. /** @hidden */
  40014. _allowPostProcessClearColor: boolean;
  40015. /** @hidden */
  40016. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40017. private _processSubCameras;
  40018. private _checkIntersections;
  40019. /** @hidden */
  40020. _advancePhysicsEngineStep(step: number): void;
  40021. /**
  40022. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40023. */
  40024. getDeterministicFrameTime: () => number;
  40025. /** @hidden */
  40026. _animate(): void;
  40027. /** Execute all animations (for a frame) */
  40028. animate(): void;
  40029. /**
  40030. * Render the scene
  40031. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40032. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40033. */
  40034. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40035. /**
  40036. * Freeze all materials
  40037. * A frozen material will not be updatable but should be faster to render
  40038. */
  40039. freezeMaterials(): void;
  40040. /**
  40041. * Unfreeze all materials
  40042. * A frozen material will not be updatable but should be faster to render
  40043. */
  40044. unfreezeMaterials(): void;
  40045. /**
  40046. * Releases all held ressources
  40047. */
  40048. dispose(): void;
  40049. /**
  40050. * Gets if the scene is already disposed
  40051. */
  40052. get isDisposed(): boolean;
  40053. /**
  40054. * Call this function to reduce memory footprint of the scene.
  40055. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40056. */
  40057. clearCachedVertexData(): void;
  40058. /**
  40059. * This function will remove the local cached buffer data from texture.
  40060. * It will save memory but will prevent the texture from being rebuilt
  40061. */
  40062. cleanCachedTextureBuffer(): void;
  40063. /**
  40064. * Get the world extend vectors with an optional filter
  40065. *
  40066. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40067. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40068. */
  40069. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40070. min: Vector3;
  40071. max: Vector3;
  40072. };
  40073. /**
  40074. * Creates a ray that can be used to pick in the scene
  40075. * @param x defines the x coordinate of the origin (on-screen)
  40076. * @param y defines the y coordinate of the origin (on-screen)
  40077. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40078. * @param camera defines the camera to use for the picking
  40079. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40080. * @returns a Ray
  40081. */
  40082. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40083. /**
  40084. * Creates a ray that can be used to pick in the scene
  40085. * @param x defines the x coordinate of the origin (on-screen)
  40086. * @param y defines the y coordinate of the origin (on-screen)
  40087. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40088. * @param result defines the ray where to store the picking ray
  40089. * @param camera defines the camera to use for the picking
  40090. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40091. * @returns the current scene
  40092. */
  40093. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40094. /**
  40095. * Creates a ray that can be used to pick in the scene
  40096. * @param x defines the x coordinate of the origin (on-screen)
  40097. * @param y defines the y coordinate of the origin (on-screen)
  40098. * @param camera defines the camera to use for the picking
  40099. * @returns a Ray
  40100. */
  40101. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40102. /**
  40103. * Creates a ray that can be used to pick in the scene
  40104. * @param x defines the x coordinate of the origin (on-screen)
  40105. * @param y defines the y coordinate of the origin (on-screen)
  40106. * @param result defines the ray where to store the picking ray
  40107. * @param camera defines the camera to use for the picking
  40108. * @returns the current scene
  40109. */
  40110. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40111. /** Launch a ray to try to pick a mesh in the scene
  40112. * @param x position on screen
  40113. * @param y position on screen
  40114. * @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
  40115. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40116. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40117. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40118. * @returns a PickingInfo
  40119. */
  40120. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40121. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40122. * @param x position on screen
  40123. * @param y position on screen
  40124. * @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
  40125. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40126. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40127. * @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)
  40128. */
  40129. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40130. /** Use the given ray to pick a mesh in the scene
  40131. * @param ray The ray to use to pick meshes
  40132. * @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
  40133. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40134. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40135. * @returns a PickingInfo
  40136. */
  40137. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40138. /**
  40139. * Launch a ray to try to pick a mesh in the scene
  40140. * @param x X position on screen
  40141. * @param y Y position on screen
  40142. * @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
  40143. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40144. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40145. * @returns an array of PickingInfo
  40146. */
  40147. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40148. /**
  40149. * Launch a ray to try to pick a mesh in the scene
  40150. * @param ray Ray to use
  40151. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  40152. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40153. * @returns an array of PickingInfo
  40154. */
  40155. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40156. /**
  40157. * Force the value of meshUnderPointer
  40158. * @param mesh defines the mesh to use
  40159. */
  40160. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40161. /**
  40162. * Gets the mesh under the pointer
  40163. * @returns a Mesh or null if no mesh is under the pointer
  40164. */
  40165. getPointerOverMesh(): Nullable<AbstractMesh>;
  40166. /** @hidden */
  40167. _rebuildGeometries(): void;
  40168. /** @hidden */
  40169. _rebuildTextures(): void;
  40170. private _getByTags;
  40171. /**
  40172. * Get a list of meshes by tags
  40173. * @param tagsQuery defines the tags query to use
  40174. * @param forEach defines a predicate used to filter results
  40175. * @returns an array of Mesh
  40176. */
  40177. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40178. /**
  40179. * Get a list of cameras by tags
  40180. * @param tagsQuery defines the tags query to use
  40181. * @param forEach defines a predicate used to filter results
  40182. * @returns an array of Camera
  40183. */
  40184. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40185. /**
  40186. * Get a list of lights by tags
  40187. * @param tagsQuery defines the tags query to use
  40188. * @param forEach defines a predicate used to filter results
  40189. * @returns an array of Light
  40190. */
  40191. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40192. /**
  40193. * Get a list of materials by tags
  40194. * @param tagsQuery defines the tags query to use
  40195. * @param forEach defines a predicate used to filter results
  40196. * @returns an array of Material
  40197. */
  40198. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40199. /**
  40200. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40201. * This allowed control for front to back rendering or reversly depending of the special needs.
  40202. *
  40203. * @param renderingGroupId The rendering group id corresponding to its index
  40204. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40205. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40206. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40207. */
  40208. 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;
  40209. /**
  40210. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40211. *
  40212. * @param renderingGroupId The rendering group id corresponding to its index
  40213. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40214. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40215. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40216. */
  40217. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40218. /**
  40219. * Gets the current auto clear configuration for one rendering group of the rendering
  40220. * manager.
  40221. * @param index the rendering group index to get the information for
  40222. * @returns The auto clear setup for the requested rendering group
  40223. */
  40224. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40225. private _blockMaterialDirtyMechanism;
  40226. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40227. get blockMaterialDirtyMechanism(): boolean;
  40228. set blockMaterialDirtyMechanism(value: boolean);
  40229. /**
  40230. * Will flag all materials as dirty to trigger new shader compilation
  40231. * @param flag defines the flag used to specify which material part must be marked as dirty
  40232. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40233. */
  40234. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40235. /** @hidden */
  40236. _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;
  40237. /** @hidden */
  40238. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40239. /** @hidden */
  40240. _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;
  40241. /** @hidden */
  40242. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40243. /** @hidden */
  40244. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40245. /** @hidden */
  40246. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40247. }
  40248. }
  40249. declare module BABYLON {
  40250. /**
  40251. * Set of assets to keep when moving a scene into an asset container.
  40252. */
  40253. export class KeepAssets extends AbstractScene {
  40254. }
  40255. /**
  40256. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40257. */
  40258. export class InstantiatedEntries {
  40259. /**
  40260. * List of new root nodes (eg. nodes with no parent)
  40261. */
  40262. rootNodes: TransformNode[];
  40263. /**
  40264. * List of new skeletons
  40265. */
  40266. skeletons: Skeleton[];
  40267. /**
  40268. * List of new animation groups
  40269. */
  40270. animationGroups: AnimationGroup[];
  40271. }
  40272. /**
  40273. * Container with a set of assets that can be added or removed from a scene.
  40274. */
  40275. export class AssetContainer extends AbstractScene {
  40276. private _wasAddedToScene;
  40277. /**
  40278. * The scene the AssetContainer belongs to.
  40279. */
  40280. scene: Scene;
  40281. /**
  40282. * Instantiates an AssetContainer.
  40283. * @param scene The scene the AssetContainer belongs to.
  40284. */
  40285. constructor(scene: Scene);
  40286. /**
  40287. * Instantiate or clone all meshes and add the new ones to the scene.
  40288. * Skeletons and animation groups will all be cloned
  40289. * @param nameFunction defines an optional function used to get new names for clones
  40290. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40291. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40292. */
  40293. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40294. /**
  40295. * Adds all the assets from the container to the scene.
  40296. */
  40297. addAllToScene(): void;
  40298. /**
  40299. * Removes all the assets in the container from the scene
  40300. */
  40301. removeAllFromScene(): void;
  40302. /**
  40303. * Disposes all the assets in the container
  40304. */
  40305. dispose(): void;
  40306. private _moveAssets;
  40307. /**
  40308. * Removes all the assets contained in the scene and adds them to the container.
  40309. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40310. */
  40311. moveAllFromScene(keepAssets?: KeepAssets): void;
  40312. /**
  40313. * 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.
  40314. * @returns the root mesh
  40315. */
  40316. createRootMesh(): Mesh;
  40317. /**
  40318. * Merge animations (direct and animation groups) from this asset container into a scene
  40319. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40320. * @param animatables set of animatables to retarget to a node from the scene
  40321. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40322. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40323. */
  40324. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40325. }
  40326. }
  40327. declare module BABYLON {
  40328. /**
  40329. * Defines how the parser contract is defined.
  40330. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40331. */
  40332. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40333. /**
  40334. * Defines how the individual parser contract is defined.
  40335. * These parser can parse an individual asset
  40336. */
  40337. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40338. /**
  40339. * Base class of the scene acting as a container for the different elements composing a scene.
  40340. * This class is dynamically extended by the different components of the scene increasing
  40341. * flexibility and reducing coupling
  40342. */
  40343. export abstract class AbstractScene {
  40344. /**
  40345. * Stores the list of available parsers in the application.
  40346. */
  40347. private static _BabylonFileParsers;
  40348. /**
  40349. * Stores the list of available individual parsers in the application.
  40350. */
  40351. private static _IndividualBabylonFileParsers;
  40352. /**
  40353. * Adds a parser in the list of available ones
  40354. * @param name Defines the name of the parser
  40355. * @param parser Defines the parser to add
  40356. */
  40357. static AddParser(name: string, parser: BabylonFileParser): void;
  40358. /**
  40359. * Gets a general parser from the list of avaialble ones
  40360. * @param name Defines the name of the parser
  40361. * @returns the requested parser or null
  40362. */
  40363. static GetParser(name: string): Nullable<BabylonFileParser>;
  40364. /**
  40365. * Adds n individual parser in the list of available ones
  40366. * @param name Defines the name of the parser
  40367. * @param parser Defines the parser to add
  40368. */
  40369. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40370. /**
  40371. * Gets an individual parser from the list of avaialble ones
  40372. * @param name Defines the name of the parser
  40373. * @returns the requested parser or null
  40374. */
  40375. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40376. /**
  40377. * Parser json data and populate both a scene and its associated container object
  40378. * @param jsonData Defines the data to parse
  40379. * @param scene Defines the scene to parse the data for
  40380. * @param container Defines the container attached to the parsing sequence
  40381. * @param rootUrl Defines the root url of the data
  40382. */
  40383. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40384. /**
  40385. * Gets the list of root nodes (ie. nodes with no parent)
  40386. */
  40387. rootNodes: Node[];
  40388. /** All of the cameras added to this scene
  40389. * @see https://doc.babylonjs.com/babylon101/cameras
  40390. */
  40391. cameras: Camera[];
  40392. /**
  40393. * All of the lights added to this scene
  40394. * @see https://doc.babylonjs.com/babylon101/lights
  40395. */
  40396. lights: Light[];
  40397. /**
  40398. * All of the (abstract) meshes added to this scene
  40399. */
  40400. meshes: AbstractMesh[];
  40401. /**
  40402. * The list of skeletons added to the scene
  40403. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40404. */
  40405. skeletons: Skeleton[];
  40406. /**
  40407. * All of the particle systems added to this scene
  40408. * @see https://doc.babylonjs.com/babylon101/particles
  40409. */
  40410. particleSystems: IParticleSystem[];
  40411. /**
  40412. * Gets a list of Animations associated with the scene
  40413. */
  40414. animations: Animation[];
  40415. /**
  40416. * All of the animation groups added to this scene
  40417. * @see https://doc.babylonjs.com/how_to/group
  40418. */
  40419. animationGroups: AnimationGroup[];
  40420. /**
  40421. * All of the multi-materials added to this scene
  40422. * @see https://doc.babylonjs.com/how_to/multi_materials
  40423. */
  40424. multiMaterials: MultiMaterial[];
  40425. /**
  40426. * All of the materials added to this scene
  40427. * In the context of a Scene, it is not supposed to be modified manually.
  40428. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40429. * Note also that the order of the Material within the array is not significant and might change.
  40430. * @see https://doc.babylonjs.com/babylon101/materials
  40431. */
  40432. materials: Material[];
  40433. /**
  40434. * The list of morph target managers added to the scene
  40435. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40436. */
  40437. morphTargetManagers: MorphTargetManager[];
  40438. /**
  40439. * The list of geometries used in the scene.
  40440. */
  40441. geometries: Geometry[];
  40442. /**
  40443. * All of the tranform nodes added to this scene
  40444. * In the context of a Scene, it is not supposed to be modified manually.
  40445. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40446. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40447. * @see https://doc.babylonjs.com/how_to/transformnode
  40448. */
  40449. transformNodes: TransformNode[];
  40450. /**
  40451. * ActionManagers available on the scene.
  40452. */
  40453. actionManagers: AbstractActionManager[];
  40454. /**
  40455. * Textures to keep.
  40456. */
  40457. textures: BaseTexture[];
  40458. /**
  40459. * Environment texture for the scene
  40460. */
  40461. environmentTexture: Nullable<BaseTexture>;
  40462. /**
  40463. * @returns all meshes, lights, cameras, transformNodes and bones
  40464. */
  40465. getNodes(): Array<Node>;
  40466. }
  40467. }
  40468. declare module BABYLON {
  40469. /**
  40470. * Interface used to define options for Sound class
  40471. */
  40472. export interface ISoundOptions {
  40473. /**
  40474. * Does the sound autoplay once loaded.
  40475. */
  40476. autoplay?: boolean;
  40477. /**
  40478. * Does the sound loop after it finishes playing once.
  40479. */
  40480. loop?: boolean;
  40481. /**
  40482. * Sound's volume
  40483. */
  40484. volume?: number;
  40485. /**
  40486. * Is it a spatial sound?
  40487. */
  40488. spatialSound?: boolean;
  40489. /**
  40490. * Maximum distance to hear that sound
  40491. */
  40492. maxDistance?: number;
  40493. /**
  40494. * Uses user defined attenuation function
  40495. */
  40496. useCustomAttenuation?: boolean;
  40497. /**
  40498. * Define the roll off factor of spatial sounds.
  40499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40500. */
  40501. rolloffFactor?: number;
  40502. /**
  40503. * Define the reference distance the sound should be heard perfectly.
  40504. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40505. */
  40506. refDistance?: number;
  40507. /**
  40508. * Define the distance attenuation model the sound will follow.
  40509. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40510. */
  40511. distanceModel?: string;
  40512. /**
  40513. * Defines the playback speed (1 by default)
  40514. */
  40515. playbackRate?: number;
  40516. /**
  40517. * Defines if the sound is from a streaming source
  40518. */
  40519. streaming?: boolean;
  40520. /**
  40521. * Defines an optional length (in seconds) inside the sound file
  40522. */
  40523. length?: number;
  40524. /**
  40525. * Defines an optional offset (in seconds) inside the sound file
  40526. */
  40527. offset?: number;
  40528. /**
  40529. * If true, URLs will not be required to state the audio file codec to use.
  40530. */
  40531. skipCodecCheck?: boolean;
  40532. }
  40533. /**
  40534. * Defines a sound that can be played in the application.
  40535. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40537. */
  40538. export class Sound {
  40539. /**
  40540. * The name of the sound in the scene.
  40541. */
  40542. name: string;
  40543. /**
  40544. * Does the sound autoplay once loaded.
  40545. */
  40546. autoplay: boolean;
  40547. /**
  40548. * Does the sound loop after it finishes playing once.
  40549. */
  40550. loop: boolean;
  40551. /**
  40552. * Does the sound use a custom attenuation curve to simulate the falloff
  40553. * happening when the source gets further away from the camera.
  40554. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40555. */
  40556. useCustomAttenuation: boolean;
  40557. /**
  40558. * The sound track id this sound belongs to.
  40559. */
  40560. soundTrackId: number;
  40561. /**
  40562. * Is this sound currently played.
  40563. */
  40564. isPlaying: boolean;
  40565. /**
  40566. * Is this sound currently paused.
  40567. */
  40568. isPaused: boolean;
  40569. /**
  40570. * Does this sound enables spatial sound.
  40571. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40572. */
  40573. spatialSound: boolean;
  40574. /**
  40575. * Define the reference distance the sound should be heard perfectly.
  40576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40577. */
  40578. refDistance: number;
  40579. /**
  40580. * Define the roll off factor of spatial sounds.
  40581. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40582. */
  40583. rolloffFactor: number;
  40584. /**
  40585. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40586. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40587. */
  40588. maxDistance: number;
  40589. /**
  40590. * Define the distance attenuation model the sound will follow.
  40591. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40592. */
  40593. distanceModel: string;
  40594. /**
  40595. * @hidden
  40596. * Back Compat
  40597. **/
  40598. onended: () => any;
  40599. /**
  40600. * Gets or sets an object used to store user defined information for the sound.
  40601. */
  40602. metadata: any;
  40603. /**
  40604. * Observable event when the current playing sound finishes.
  40605. */
  40606. onEndedObservable: Observable<Sound>;
  40607. private _panningModel;
  40608. private _playbackRate;
  40609. private _streaming;
  40610. private _startTime;
  40611. private _startOffset;
  40612. private _position;
  40613. /** @hidden */
  40614. _positionInEmitterSpace: boolean;
  40615. private _localDirection;
  40616. private _volume;
  40617. private _isReadyToPlay;
  40618. private _isDirectional;
  40619. private _readyToPlayCallback;
  40620. private _audioBuffer;
  40621. private _soundSource;
  40622. private _streamingSource;
  40623. private _soundPanner;
  40624. private _soundGain;
  40625. private _inputAudioNode;
  40626. private _outputAudioNode;
  40627. private _coneInnerAngle;
  40628. private _coneOuterAngle;
  40629. private _coneOuterGain;
  40630. private _scene;
  40631. private _connectedTransformNode;
  40632. private _customAttenuationFunction;
  40633. private _registerFunc;
  40634. private _isOutputConnected;
  40635. private _htmlAudioElement;
  40636. private _urlType;
  40637. private _length?;
  40638. private _offset?;
  40639. /** @hidden */
  40640. static _SceneComponentInitialization: (scene: Scene) => void;
  40641. /**
  40642. * Create a sound and attach it to a scene
  40643. * @param name Name of your sound
  40644. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40645. * @param scene defines the scene the sound belongs to
  40646. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40647. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40648. */
  40649. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40650. /**
  40651. * Release the sound and its associated resources
  40652. */
  40653. dispose(): void;
  40654. /**
  40655. * Gets if the sounds is ready to be played or not.
  40656. * @returns true if ready, otherwise false
  40657. */
  40658. isReady(): boolean;
  40659. private _soundLoaded;
  40660. /**
  40661. * Sets the data of the sound from an audiobuffer
  40662. * @param audioBuffer The audioBuffer containing the data
  40663. */
  40664. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40665. /**
  40666. * Updates the current sounds options such as maxdistance, loop...
  40667. * @param options A JSON object containing values named as the object properties
  40668. */
  40669. updateOptions(options: ISoundOptions): void;
  40670. private _createSpatialParameters;
  40671. private _updateSpatialParameters;
  40672. /**
  40673. * Switch the panning model to HRTF:
  40674. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40675. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40676. */
  40677. switchPanningModelToHRTF(): void;
  40678. /**
  40679. * Switch the panning model to Equal Power:
  40680. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40681. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40682. */
  40683. switchPanningModelToEqualPower(): void;
  40684. private _switchPanningModel;
  40685. /**
  40686. * Connect this sound to a sound track audio node like gain...
  40687. * @param soundTrackAudioNode the sound track audio node to connect to
  40688. */
  40689. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40690. /**
  40691. * Transform this sound into a directional source
  40692. * @param coneInnerAngle Size of the inner cone in degree
  40693. * @param coneOuterAngle Size of the outer cone in degree
  40694. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40695. */
  40696. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40697. /**
  40698. * Gets or sets the inner angle for the directional cone.
  40699. */
  40700. get directionalConeInnerAngle(): number;
  40701. /**
  40702. * Gets or sets the inner angle for the directional cone.
  40703. */
  40704. set directionalConeInnerAngle(value: number);
  40705. /**
  40706. * Gets or sets the outer angle for the directional cone.
  40707. */
  40708. get directionalConeOuterAngle(): number;
  40709. /**
  40710. * Gets or sets the outer angle for the directional cone.
  40711. */
  40712. set directionalConeOuterAngle(value: number);
  40713. /**
  40714. * Sets the position of the emitter if spatial sound is enabled
  40715. * @param newPosition Defines the new posisiton
  40716. */
  40717. setPosition(newPosition: Vector3): void;
  40718. /**
  40719. * Sets the local direction of the emitter if spatial sound is enabled
  40720. * @param newLocalDirection Defines the new local direction
  40721. */
  40722. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40723. private _updateDirection;
  40724. /** @hidden */
  40725. updateDistanceFromListener(): void;
  40726. /**
  40727. * Sets a new custom attenuation function for the sound.
  40728. * @param callback Defines the function used for the attenuation
  40729. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40730. */
  40731. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40732. /**
  40733. * Play the sound
  40734. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40735. * @param offset (optional) Start the sound at a specific time in seconds
  40736. * @param length (optional) Sound duration (in seconds)
  40737. */
  40738. play(time?: number, offset?: number, length?: number): void;
  40739. private _onended;
  40740. /**
  40741. * Stop the sound
  40742. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40743. */
  40744. stop(time?: number): void;
  40745. /**
  40746. * Put the sound in pause
  40747. */
  40748. pause(): void;
  40749. /**
  40750. * Sets a dedicated volume for this sounds
  40751. * @param newVolume Define the new volume of the sound
  40752. * @param time Define time for gradual change to new volume
  40753. */
  40754. setVolume(newVolume: number, time?: number): void;
  40755. /**
  40756. * Set the sound play back rate
  40757. * @param newPlaybackRate Define the playback rate the sound should be played at
  40758. */
  40759. setPlaybackRate(newPlaybackRate: number): void;
  40760. /**
  40761. * Gets the volume of the sound.
  40762. * @returns the volume of the sound
  40763. */
  40764. getVolume(): number;
  40765. /**
  40766. * Attach the sound to a dedicated mesh
  40767. * @param transformNode The transform node to connect the sound with
  40768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40769. */
  40770. attachToMesh(transformNode: TransformNode): void;
  40771. /**
  40772. * Detach the sound from the previously attached mesh
  40773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40774. */
  40775. detachFromMesh(): void;
  40776. private _onRegisterAfterWorldMatrixUpdate;
  40777. /**
  40778. * Clone the current sound in the scene.
  40779. * @returns the new sound clone
  40780. */
  40781. clone(): Nullable<Sound>;
  40782. /**
  40783. * Gets the current underlying audio buffer containing the data
  40784. * @returns the audio buffer
  40785. */
  40786. getAudioBuffer(): Nullable<AudioBuffer>;
  40787. /**
  40788. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40789. * @returns the source node
  40790. */
  40791. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40792. /**
  40793. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40794. * @returns the gain node
  40795. */
  40796. getSoundGain(): Nullable<GainNode>;
  40797. /**
  40798. * Serializes the Sound in a JSON representation
  40799. * @returns the JSON representation of the sound
  40800. */
  40801. serialize(): any;
  40802. /**
  40803. * Parse a JSON representation of a sound to innstantiate in a given scene
  40804. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40805. * @param scene Define the scene the new parsed sound should be created in
  40806. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40807. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40808. * @returns the newly parsed sound
  40809. */
  40810. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40811. }
  40812. }
  40813. declare module BABYLON {
  40814. /**
  40815. * This defines an action helpful to play a defined sound on a triggered action.
  40816. */
  40817. export class PlaySoundAction extends Action {
  40818. private _sound;
  40819. /**
  40820. * Instantiate the action
  40821. * @param triggerOptions defines the trigger options
  40822. * @param sound defines the sound to play
  40823. * @param condition defines the trigger related conditions
  40824. */
  40825. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40826. /** @hidden */
  40827. _prepare(): void;
  40828. /**
  40829. * Execute the action and play the sound.
  40830. */
  40831. execute(): void;
  40832. /**
  40833. * Serializes the actions and its related information.
  40834. * @param parent defines the object to serialize in
  40835. * @returns the serialized object
  40836. */
  40837. serialize(parent: any): any;
  40838. }
  40839. /**
  40840. * This defines an action helpful to stop a defined sound on a triggered action.
  40841. */
  40842. export class StopSoundAction extends Action {
  40843. private _sound;
  40844. /**
  40845. * Instantiate the action
  40846. * @param triggerOptions defines the trigger options
  40847. * @param sound defines the sound to stop
  40848. * @param condition defines the trigger related conditions
  40849. */
  40850. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40851. /** @hidden */
  40852. _prepare(): void;
  40853. /**
  40854. * Execute the action and stop the sound.
  40855. */
  40856. execute(): void;
  40857. /**
  40858. * Serializes the actions and its related information.
  40859. * @param parent defines the object to serialize in
  40860. * @returns the serialized object
  40861. */
  40862. serialize(parent: any): any;
  40863. }
  40864. }
  40865. declare module BABYLON {
  40866. /**
  40867. * This defines an action responsible to change the value of a property
  40868. * by interpolating between its current value and the newly set one once triggered.
  40869. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40870. */
  40871. export class InterpolateValueAction extends Action {
  40872. /**
  40873. * Defines the path of the property where the value should be interpolated
  40874. */
  40875. propertyPath: string;
  40876. /**
  40877. * Defines the target value at the end of the interpolation.
  40878. */
  40879. value: any;
  40880. /**
  40881. * Defines the time it will take for the property to interpolate to the value.
  40882. */
  40883. duration: number;
  40884. /**
  40885. * Defines if the other scene animations should be stopped when the action has been triggered
  40886. */
  40887. stopOtherAnimations?: boolean;
  40888. /**
  40889. * Defines a callback raised once the interpolation animation has been done.
  40890. */
  40891. onInterpolationDone?: () => void;
  40892. /**
  40893. * Observable triggered once the interpolation animation has been done.
  40894. */
  40895. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40896. private _target;
  40897. private _effectiveTarget;
  40898. private _property;
  40899. /**
  40900. * Instantiate the action
  40901. * @param triggerOptions defines the trigger options
  40902. * @param target defines the object containing the value to interpolate
  40903. * @param propertyPath defines the path to the property in the target object
  40904. * @param value defines the target value at the end of the interpolation
  40905. * @param duration deines the time it will take for the property to interpolate to the value.
  40906. * @param condition defines the trigger related conditions
  40907. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40908. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40909. */
  40910. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40911. /** @hidden */
  40912. _prepare(): void;
  40913. /**
  40914. * Execute the action starts the value interpolation.
  40915. */
  40916. execute(): void;
  40917. /**
  40918. * Serializes the actions and its related information.
  40919. * @param parent defines the object to serialize in
  40920. * @returns the serialized object
  40921. */
  40922. serialize(parent: any): any;
  40923. }
  40924. }
  40925. declare module BABYLON {
  40926. /**
  40927. * Options allowed during the creation of a sound track.
  40928. */
  40929. export interface ISoundTrackOptions {
  40930. /**
  40931. * The volume the sound track should take during creation
  40932. */
  40933. volume?: number;
  40934. /**
  40935. * Define if the sound track is the main sound track of the scene
  40936. */
  40937. mainTrack?: boolean;
  40938. }
  40939. /**
  40940. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40941. * It will be also used in a future release to apply effects on a specific track.
  40942. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40943. */
  40944. export class SoundTrack {
  40945. /**
  40946. * The unique identifier of the sound track in the scene.
  40947. */
  40948. id: number;
  40949. /**
  40950. * The list of sounds included in the sound track.
  40951. */
  40952. soundCollection: Array<Sound>;
  40953. private _outputAudioNode;
  40954. private _scene;
  40955. private _connectedAnalyser;
  40956. private _options;
  40957. private _isInitialized;
  40958. /**
  40959. * Creates a new sound track.
  40960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40961. * @param scene Define the scene the sound track belongs to
  40962. * @param options
  40963. */
  40964. constructor(scene: Scene, options?: ISoundTrackOptions);
  40965. private _initializeSoundTrackAudioGraph;
  40966. /**
  40967. * Release the sound track and its associated resources
  40968. */
  40969. dispose(): void;
  40970. /**
  40971. * Adds a sound to this sound track
  40972. * @param sound define the cound to add
  40973. * @ignoreNaming
  40974. */
  40975. AddSound(sound: Sound): void;
  40976. /**
  40977. * Removes a sound to this sound track
  40978. * @param sound define the cound to remove
  40979. * @ignoreNaming
  40980. */
  40981. RemoveSound(sound: Sound): void;
  40982. /**
  40983. * Set a global volume for the full sound track.
  40984. * @param newVolume Define the new volume of the sound track
  40985. */
  40986. setVolume(newVolume: number): void;
  40987. /**
  40988. * Switch the panning model to HRTF:
  40989. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40990. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40991. */
  40992. switchPanningModelToHRTF(): void;
  40993. /**
  40994. * Switch the panning model to Equal Power:
  40995. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40996. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40997. */
  40998. switchPanningModelToEqualPower(): void;
  40999. /**
  41000. * Connect the sound track to an audio analyser allowing some amazing
  41001. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41002. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41003. * @param analyser The analyser to connect to the engine
  41004. */
  41005. connectToAnalyser(analyser: Analyser): void;
  41006. }
  41007. }
  41008. declare module BABYLON {
  41009. interface AbstractScene {
  41010. /**
  41011. * The list of sounds used in the scene.
  41012. */
  41013. sounds: Nullable<Array<Sound>>;
  41014. }
  41015. interface Scene {
  41016. /**
  41017. * @hidden
  41018. * Backing field
  41019. */
  41020. _mainSoundTrack: SoundTrack;
  41021. /**
  41022. * The main sound track played by the scene.
  41023. * It cotains your primary collection of sounds.
  41024. */
  41025. mainSoundTrack: SoundTrack;
  41026. /**
  41027. * The list of sound tracks added to the scene
  41028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41029. */
  41030. soundTracks: Nullable<Array<SoundTrack>>;
  41031. /**
  41032. * Gets a sound using a given name
  41033. * @param name defines the name to search for
  41034. * @return the found sound or null if not found at all.
  41035. */
  41036. getSoundByName(name: string): Nullable<Sound>;
  41037. /**
  41038. * Gets or sets if audio support is enabled
  41039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41040. */
  41041. audioEnabled: boolean;
  41042. /**
  41043. * Gets or sets if audio will be output to headphones
  41044. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41045. */
  41046. headphone: boolean;
  41047. /**
  41048. * Gets or sets custom audio listener position provider
  41049. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41050. */
  41051. audioListenerPositionProvider: Nullable<() => Vector3>;
  41052. /**
  41053. * Gets or sets a refresh rate when using 3D audio positioning
  41054. */
  41055. audioPositioningRefreshRate: number;
  41056. }
  41057. /**
  41058. * Defines the sound scene component responsible to manage any sounds
  41059. * in a given scene.
  41060. */
  41061. export class AudioSceneComponent implements ISceneSerializableComponent {
  41062. /**
  41063. * The component name helpfull to identify the component in the list of scene components.
  41064. */
  41065. readonly name: string;
  41066. /**
  41067. * The scene the component belongs to.
  41068. */
  41069. scene: Scene;
  41070. private _audioEnabled;
  41071. /**
  41072. * Gets whether audio is enabled or not.
  41073. * Please use related enable/disable method to switch state.
  41074. */
  41075. get audioEnabled(): boolean;
  41076. private _headphone;
  41077. /**
  41078. * Gets whether audio is outputing to headphone or not.
  41079. * Please use the according Switch methods to change output.
  41080. */
  41081. get headphone(): boolean;
  41082. /**
  41083. * Gets or sets a refresh rate when using 3D audio positioning
  41084. */
  41085. audioPositioningRefreshRate: number;
  41086. private _audioListenerPositionProvider;
  41087. /**
  41088. * Gets the current audio listener position provider
  41089. */
  41090. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41091. /**
  41092. * Sets a custom listener position for all sounds in the scene
  41093. * By default, this is the position of the first active camera
  41094. */
  41095. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41096. /**
  41097. * Creates a new instance of the component for the given scene
  41098. * @param scene Defines the scene to register the component in
  41099. */
  41100. constructor(scene: Scene);
  41101. /**
  41102. * Registers the component in a given scene
  41103. */
  41104. register(): void;
  41105. /**
  41106. * Rebuilds the elements related to this component in case of
  41107. * context lost for instance.
  41108. */
  41109. rebuild(): void;
  41110. /**
  41111. * Serializes the component data to the specified json object
  41112. * @param serializationObject The object to serialize to
  41113. */
  41114. serialize(serializationObject: any): void;
  41115. /**
  41116. * Adds all the elements from the container to the scene
  41117. * @param container the container holding the elements
  41118. */
  41119. addFromContainer(container: AbstractScene): void;
  41120. /**
  41121. * Removes all the elements in the container from the scene
  41122. * @param container contains the elements to remove
  41123. * @param dispose if the removed element should be disposed (default: false)
  41124. */
  41125. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41126. /**
  41127. * Disposes the component and the associated ressources.
  41128. */
  41129. dispose(): void;
  41130. /**
  41131. * Disables audio in the associated scene.
  41132. */
  41133. disableAudio(): void;
  41134. /**
  41135. * Enables audio in the associated scene.
  41136. */
  41137. enableAudio(): void;
  41138. /**
  41139. * Switch audio to headphone output.
  41140. */
  41141. switchAudioModeForHeadphones(): void;
  41142. /**
  41143. * Switch audio to normal speakers.
  41144. */
  41145. switchAudioModeForNormalSpeakers(): void;
  41146. private _cachedCameraDirection;
  41147. private _cachedCameraPosition;
  41148. private _lastCheck;
  41149. private _afterRender;
  41150. }
  41151. }
  41152. declare module BABYLON {
  41153. /**
  41154. * Wraps one or more Sound objects and selects one with random weight for playback.
  41155. */
  41156. export class WeightedSound {
  41157. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41158. loop: boolean;
  41159. private _coneInnerAngle;
  41160. private _coneOuterAngle;
  41161. private _volume;
  41162. /** A Sound is currently playing. */
  41163. isPlaying: boolean;
  41164. /** A Sound is currently paused. */
  41165. isPaused: boolean;
  41166. private _sounds;
  41167. private _weights;
  41168. private _currentIndex?;
  41169. /**
  41170. * Creates a new WeightedSound from the list of sounds given.
  41171. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41172. * @param sounds Array of Sounds that will be selected from.
  41173. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41174. */
  41175. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41176. /**
  41177. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41178. */
  41179. get directionalConeInnerAngle(): number;
  41180. /**
  41181. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41182. */
  41183. set directionalConeInnerAngle(value: number);
  41184. /**
  41185. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41186. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41187. */
  41188. get directionalConeOuterAngle(): 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. set directionalConeOuterAngle(value: number);
  41194. /**
  41195. * Playback volume.
  41196. */
  41197. get volume(): number;
  41198. /**
  41199. * Playback volume.
  41200. */
  41201. set volume(value: number);
  41202. private _onended;
  41203. /**
  41204. * Suspend playback
  41205. */
  41206. pause(): void;
  41207. /**
  41208. * Stop playback
  41209. */
  41210. stop(): void;
  41211. /**
  41212. * Start playback.
  41213. * @param startOffset Position the clip head at a specific time in seconds.
  41214. */
  41215. play(startOffset?: number): void;
  41216. }
  41217. }
  41218. declare module BABYLON {
  41219. /**
  41220. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41221. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41222. */
  41223. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41224. /**
  41225. * Gets the name of the behavior.
  41226. */
  41227. get name(): string;
  41228. /**
  41229. * The easing function used by animations
  41230. */
  41231. static EasingFunction: BackEase;
  41232. /**
  41233. * The easing mode used by animations
  41234. */
  41235. static EasingMode: number;
  41236. /**
  41237. * The duration of the animation, in milliseconds
  41238. */
  41239. transitionDuration: number;
  41240. /**
  41241. * Length of the distance animated by the transition when lower radius is reached
  41242. */
  41243. lowerRadiusTransitionRange: number;
  41244. /**
  41245. * Length of the distance animated by the transition when upper radius is reached
  41246. */
  41247. upperRadiusTransitionRange: number;
  41248. private _autoTransitionRange;
  41249. /**
  41250. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41251. */
  41252. get autoTransitionRange(): boolean;
  41253. /**
  41254. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41255. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41256. */
  41257. set autoTransitionRange(value: boolean);
  41258. private _attachedCamera;
  41259. private _onAfterCheckInputsObserver;
  41260. private _onMeshTargetChangedObserver;
  41261. /**
  41262. * Initializes the behavior.
  41263. */
  41264. init(): void;
  41265. /**
  41266. * Attaches the behavior to its arc rotate camera.
  41267. * @param camera Defines the camera to attach the behavior to
  41268. */
  41269. attach(camera: ArcRotateCamera): void;
  41270. /**
  41271. * Detaches the behavior from its current arc rotate camera.
  41272. */
  41273. detach(): void;
  41274. private _radiusIsAnimating;
  41275. private _radiusBounceTransition;
  41276. private _animatables;
  41277. private _cachedWheelPrecision;
  41278. /**
  41279. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41280. * @param radiusLimit The limit to check against.
  41281. * @return Bool to indicate if at limit.
  41282. */
  41283. private _isRadiusAtLimit;
  41284. /**
  41285. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41286. * @param radiusDelta The delta by which to animate to. Can be negative.
  41287. */
  41288. private _applyBoundRadiusAnimation;
  41289. /**
  41290. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41291. */
  41292. protected _clearAnimationLocks(): void;
  41293. /**
  41294. * Stops and removes all animations that have been applied to the camera
  41295. */
  41296. stopAllAnimations(): void;
  41297. }
  41298. }
  41299. declare module BABYLON {
  41300. /**
  41301. * 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.
  41302. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41303. */
  41304. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41305. /**
  41306. * Gets the name of the behavior.
  41307. */
  41308. get name(): string;
  41309. private _mode;
  41310. private _radiusScale;
  41311. private _positionScale;
  41312. private _defaultElevation;
  41313. private _elevationReturnTime;
  41314. private _elevationReturnWaitTime;
  41315. private _zoomStopsAnimation;
  41316. private _framingTime;
  41317. /**
  41318. * The easing function used by animations
  41319. */
  41320. static EasingFunction: ExponentialEase;
  41321. /**
  41322. * The easing mode used by animations
  41323. */
  41324. static EasingMode: number;
  41325. /**
  41326. * Sets the current mode used by the behavior
  41327. */
  41328. set mode(mode: number);
  41329. /**
  41330. * Gets current mode used by the behavior.
  41331. */
  41332. get mode(): number;
  41333. /**
  41334. * Sets the scale applied to the radius (1 by default)
  41335. */
  41336. set radiusScale(radius: number);
  41337. /**
  41338. * Gets the scale applied to the radius
  41339. */
  41340. get radiusScale(): number;
  41341. /**
  41342. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41343. */
  41344. set positionScale(scale: number);
  41345. /**
  41346. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41347. */
  41348. get positionScale(): number;
  41349. /**
  41350. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41351. * behaviour is triggered, in radians.
  41352. */
  41353. set defaultElevation(elevation: number);
  41354. /**
  41355. * Gets 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. get defaultElevation(): number;
  41359. /**
  41360. * Sets the time (in milliseconds) taken to return to the default beta position.
  41361. * Negative value indicates camera should not return to default.
  41362. */
  41363. set elevationReturnTime(speed: number);
  41364. /**
  41365. * Gets the time (in milliseconds) taken to return to the default beta position.
  41366. * Negative value indicates camera should not return to default.
  41367. */
  41368. get elevationReturnTime(): number;
  41369. /**
  41370. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41371. */
  41372. set elevationReturnWaitTime(time: number);
  41373. /**
  41374. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41375. */
  41376. get elevationReturnWaitTime(): number;
  41377. /**
  41378. * Sets the flag that indicates if user zooming should stop animation.
  41379. */
  41380. set zoomStopsAnimation(flag: boolean);
  41381. /**
  41382. * Gets the flag that indicates if user zooming should stop animation.
  41383. */
  41384. get zoomStopsAnimation(): boolean;
  41385. /**
  41386. * Sets the transition time when framing the mesh, in milliseconds
  41387. */
  41388. set framingTime(time: number);
  41389. /**
  41390. * Gets the transition time when framing the mesh, in milliseconds
  41391. */
  41392. get framingTime(): number;
  41393. /**
  41394. * Define if the behavior should automatically change the configured
  41395. * camera limits and sensibilities.
  41396. */
  41397. autoCorrectCameraLimitsAndSensibility: boolean;
  41398. private _onPrePointerObservableObserver;
  41399. private _onAfterCheckInputsObserver;
  41400. private _onMeshTargetChangedObserver;
  41401. private _attachedCamera;
  41402. private _isPointerDown;
  41403. private _lastInteractionTime;
  41404. /**
  41405. * Initializes the behavior.
  41406. */
  41407. init(): void;
  41408. /**
  41409. * Attaches the behavior to its arc rotate camera.
  41410. * @param camera Defines the camera to attach the behavior to
  41411. */
  41412. attach(camera: ArcRotateCamera): void;
  41413. /**
  41414. * Detaches the behavior from its current arc rotate camera.
  41415. */
  41416. detach(): void;
  41417. private _animatables;
  41418. private _betaIsAnimating;
  41419. private _betaTransition;
  41420. private _radiusTransition;
  41421. private _vectorTransition;
  41422. /**
  41423. * Targets the given mesh and updates zoom level accordingly.
  41424. * @param mesh The mesh to target.
  41425. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41426. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41427. */
  41428. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41429. /**
  41430. * Targets the given mesh with its children and updates zoom level accordingly.
  41431. * @param mesh The mesh to target.
  41432. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41433. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41434. */
  41435. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41436. /**
  41437. * Targets the given meshes with their children and updates zoom level accordingly.
  41438. * @param meshes The mesh to target.
  41439. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41440. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41441. */
  41442. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41443. /**
  41444. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41445. * @param minimumWorld Determines the smaller position of the bounding box extend
  41446. * @param maximumWorld Determines the bigger position of the bounding box extend
  41447. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41448. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41449. */
  41450. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41451. /**
  41452. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41453. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41454. * frustum width.
  41455. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41456. * to fully enclose the mesh in the viewing frustum.
  41457. */
  41458. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41459. /**
  41460. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41461. * is automatically returned to its default position (expected to be above ground plane).
  41462. */
  41463. private _maintainCameraAboveGround;
  41464. /**
  41465. * Returns the frustum slope based on the canvas ratio and camera FOV
  41466. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41467. */
  41468. private _getFrustumSlope;
  41469. /**
  41470. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41471. */
  41472. private _clearAnimationLocks;
  41473. /**
  41474. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41475. */
  41476. private _applyUserInteraction;
  41477. /**
  41478. * Stops and removes all animations that have been applied to the camera
  41479. */
  41480. stopAllAnimations(): void;
  41481. /**
  41482. * Gets a value indicating if the user is moving the camera
  41483. */
  41484. get isUserIsMoving(): boolean;
  41485. /**
  41486. * The camera can move all the way towards the mesh.
  41487. */
  41488. static IgnoreBoundsSizeMode: number;
  41489. /**
  41490. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41491. */
  41492. static FitFrustumSidesMode: number;
  41493. }
  41494. }
  41495. declare module BABYLON {
  41496. /**
  41497. * Base class for Camera Pointer Inputs.
  41498. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41499. * for example usage.
  41500. */
  41501. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41502. /**
  41503. * Defines the camera the input is attached to.
  41504. */
  41505. abstract camera: Camera;
  41506. /**
  41507. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41508. */
  41509. protected _altKey: boolean;
  41510. protected _ctrlKey: boolean;
  41511. protected _metaKey: boolean;
  41512. protected _shiftKey: boolean;
  41513. /**
  41514. * Which mouse buttons were pressed at time of last mouse event.
  41515. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41516. */
  41517. protected _buttonsPressed: number;
  41518. /**
  41519. * Defines the buttons associated with the input to handle camera move.
  41520. */
  41521. buttons: number[];
  41522. /**
  41523. * Attach the input controls to a specific dom element to get the input from.
  41524. * @param element Defines the element the controls should be listened from
  41525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41526. */
  41527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41528. /**
  41529. * Detach the current controls from the specified dom element.
  41530. * @param element Defines the element to stop listening the inputs from
  41531. */
  41532. detachControl(element: Nullable<HTMLElement>): void;
  41533. /**
  41534. * Gets the class name of the current input.
  41535. * @returns the class name
  41536. */
  41537. getClassName(): string;
  41538. /**
  41539. * Get the friendly name associated with the input class.
  41540. * @returns the input friendly name
  41541. */
  41542. getSimpleName(): string;
  41543. /**
  41544. * Called on pointer POINTERDOUBLETAP event.
  41545. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41546. */
  41547. protected onDoubleTap(type: string): void;
  41548. /**
  41549. * Called on pointer POINTERMOVE event if only a single touch is active.
  41550. * Override this method to provide functionality.
  41551. */
  41552. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41553. /**
  41554. * Called on pointer POINTERMOVE event if multiple touches are active.
  41555. * Override this method to provide functionality.
  41556. */
  41557. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41558. /**
  41559. * Called on JS contextmenu event.
  41560. * Override this method to provide functionality.
  41561. */
  41562. protected onContextMenu(evt: PointerEvent): void;
  41563. /**
  41564. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41565. * press.
  41566. * Override this method to provide functionality.
  41567. */
  41568. protected onButtonDown(evt: PointerEvent): void;
  41569. /**
  41570. * Called each time a new POINTERUP event occurs. Ie, for each button
  41571. * release.
  41572. * Override this method to provide functionality.
  41573. */
  41574. protected onButtonUp(evt: PointerEvent): void;
  41575. /**
  41576. * Called when window becomes inactive.
  41577. * Override this method to provide functionality.
  41578. */
  41579. protected onLostFocus(): void;
  41580. private _pointerInput;
  41581. private _observer;
  41582. private _onLostFocus;
  41583. private pointA;
  41584. private pointB;
  41585. }
  41586. }
  41587. declare module BABYLON {
  41588. /**
  41589. * Manage the pointers inputs to control an arc rotate camera.
  41590. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41591. */
  41592. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41593. /**
  41594. * Defines the camera the input is attached to.
  41595. */
  41596. camera: ArcRotateCamera;
  41597. /**
  41598. * Gets the class name of the current input.
  41599. * @returns the class name
  41600. */
  41601. getClassName(): string;
  41602. /**
  41603. * Defines the buttons associated with the input to handle camera move.
  41604. */
  41605. buttons: number[];
  41606. /**
  41607. * Defines the pointer angular sensibility along the X axis or how fast is
  41608. * the camera rotating.
  41609. */
  41610. angularSensibilityX: number;
  41611. /**
  41612. * Defines the pointer angular sensibility along the Y axis or how fast is
  41613. * the camera rotating.
  41614. */
  41615. angularSensibilityY: number;
  41616. /**
  41617. * Defines the pointer pinch precision or how fast is the camera zooming.
  41618. */
  41619. pinchPrecision: number;
  41620. /**
  41621. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41622. * from 0.
  41623. * It defines the percentage of current camera.radius to use as delta when
  41624. * pinch zoom is used.
  41625. */
  41626. pinchDeltaPercentage: number;
  41627. /**
  41628. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41629. * that any object in the plane at the camera's target point will scale
  41630. * perfectly with finger motion.
  41631. * Overrides pinchDeltaPercentage and pinchPrecision.
  41632. */
  41633. useNaturalPinchZoom: boolean;
  41634. /**
  41635. * Defines the pointer panning sensibility or how fast is the camera moving.
  41636. */
  41637. panningSensibility: number;
  41638. /**
  41639. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41640. */
  41641. multiTouchPanning: boolean;
  41642. /**
  41643. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41644. * zoom (pinch) through multitouch.
  41645. */
  41646. multiTouchPanAndZoom: boolean;
  41647. /**
  41648. * Revers pinch action direction.
  41649. */
  41650. pinchInwards: boolean;
  41651. private _isPanClick;
  41652. private _twoFingerActivityCount;
  41653. private _isPinching;
  41654. /**
  41655. * Called on pointer POINTERMOVE event if only a single touch is active.
  41656. */
  41657. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41658. /**
  41659. * Called on pointer POINTERDOUBLETAP event.
  41660. */
  41661. protected onDoubleTap(type: string): void;
  41662. /**
  41663. * Called on pointer POINTERMOVE event if multiple touches are active.
  41664. */
  41665. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41666. /**
  41667. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41668. * press.
  41669. */
  41670. protected onButtonDown(evt: PointerEvent): void;
  41671. /**
  41672. * Called each time a new POINTERUP event occurs. Ie, for each button
  41673. * release.
  41674. */
  41675. protected onButtonUp(evt: PointerEvent): void;
  41676. /**
  41677. * Called when window becomes inactive.
  41678. */
  41679. protected onLostFocus(): void;
  41680. }
  41681. }
  41682. declare module BABYLON {
  41683. /**
  41684. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41685. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41686. */
  41687. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41688. /**
  41689. * Defines the camera the input is attached to.
  41690. */
  41691. camera: ArcRotateCamera;
  41692. /**
  41693. * Defines the list of key codes associated with the up action (increase alpha)
  41694. */
  41695. keysUp: number[];
  41696. /**
  41697. * Defines the list of key codes associated with the down action (decrease alpha)
  41698. */
  41699. keysDown: number[];
  41700. /**
  41701. * Defines the list of key codes associated with the left action (increase beta)
  41702. */
  41703. keysLeft: number[];
  41704. /**
  41705. * Defines the list of key codes associated with the right action (decrease beta)
  41706. */
  41707. keysRight: number[];
  41708. /**
  41709. * Defines the list of key codes associated with the reset action.
  41710. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41711. */
  41712. keysReset: number[];
  41713. /**
  41714. * Defines the panning sensibility of the inputs.
  41715. * (How fast is the camera panning)
  41716. */
  41717. panningSensibility: number;
  41718. /**
  41719. * Defines the zooming sensibility of the inputs.
  41720. * (How fast is the camera zooming)
  41721. */
  41722. zoomingSensibility: number;
  41723. /**
  41724. * Defines whether maintaining the alt key down switch the movement mode from
  41725. * orientation to zoom.
  41726. */
  41727. useAltToZoom: boolean;
  41728. /**
  41729. * Rotation speed of the camera
  41730. */
  41731. angularSpeed: number;
  41732. private _keys;
  41733. private _ctrlPressed;
  41734. private _altPressed;
  41735. private _onCanvasBlurObserver;
  41736. private _onKeyboardObserver;
  41737. private _engine;
  41738. private _scene;
  41739. /**
  41740. * Attach the input controls to a specific dom element to get the input from.
  41741. * @param element Defines the element the controls should be listened from
  41742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41743. */
  41744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41745. /**
  41746. * Detach the current controls from the specified dom element.
  41747. * @param element Defines the element to stop listening the inputs from
  41748. */
  41749. detachControl(element: Nullable<HTMLElement>): void;
  41750. /**
  41751. * Update the current camera state depending on the inputs that have been used this frame.
  41752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41753. */
  41754. checkInputs(): void;
  41755. /**
  41756. * Gets the class name of the current intput.
  41757. * @returns the class name
  41758. */
  41759. getClassName(): string;
  41760. /**
  41761. * Get the friendly name associated with the input class.
  41762. * @returns the input friendly name
  41763. */
  41764. getSimpleName(): string;
  41765. }
  41766. }
  41767. declare module BABYLON {
  41768. /**
  41769. * Manage the mouse wheel inputs to control an arc rotate camera.
  41770. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41771. */
  41772. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41773. /**
  41774. * Defines the camera the input is attached to.
  41775. */
  41776. camera: ArcRotateCamera;
  41777. /**
  41778. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41779. */
  41780. wheelPrecision: number;
  41781. /**
  41782. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41783. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41784. */
  41785. wheelDeltaPercentage: number;
  41786. private _wheel;
  41787. private _observer;
  41788. private computeDeltaFromMouseWheelLegacyEvent;
  41789. /**
  41790. * Attach the input controls to a specific dom element to get the input from.
  41791. * @param element Defines the element the controls should be listened from
  41792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41793. */
  41794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41795. /**
  41796. * Detach the current controls from the specified dom element.
  41797. * @param element Defines the element to stop listening the inputs from
  41798. */
  41799. detachControl(element: Nullable<HTMLElement>): void;
  41800. /**
  41801. * Gets the class name of the current intput.
  41802. * @returns the class name
  41803. */
  41804. getClassName(): string;
  41805. /**
  41806. * Get the friendly name associated with the input class.
  41807. * @returns the input friendly name
  41808. */
  41809. getSimpleName(): string;
  41810. }
  41811. }
  41812. declare module BABYLON {
  41813. /**
  41814. * Default Inputs manager for the ArcRotateCamera.
  41815. * It groups all the default supported inputs for ease of use.
  41816. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41817. */
  41818. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41819. /**
  41820. * Instantiates a new ArcRotateCameraInputsManager.
  41821. * @param camera Defines the camera the inputs belong to
  41822. */
  41823. constructor(camera: ArcRotateCamera);
  41824. /**
  41825. * Add mouse wheel input support to the input manager.
  41826. * @returns the current input manager
  41827. */
  41828. addMouseWheel(): ArcRotateCameraInputsManager;
  41829. /**
  41830. * Add pointers input support to the input manager.
  41831. * @returns the current input manager
  41832. */
  41833. addPointers(): ArcRotateCameraInputsManager;
  41834. /**
  41835. * Add keyboard input support to the input manager.
  41836. * @returns the current input manager
  41837. */
  41838. addKeyboard(): ArcRotateCameraInputsManager;
  41839. }
  41840. }
  41841. declare module BABYLON {
  41842. /**
  41843. * This represents an orbital type of camera.
  41844. *
  41845. * 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.
  41846. * 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.
  41847. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41848. */
  41849. export class ArcRotateCamera extends TargetCamera {
  41850. /**
  41851. * Defines the rotation angle of the camera along the longitudinal axis.
  41852. */
  41853. alpha: number;
  41854. /**
  41855. * Defines the rotation angle of the camera along the latitudinal axis.
  41856. */
  41857. beta: number;
  41858. /**
  41859. * Defines the radius of the camera from it s target point.
  41860. */
  41861. radius: number;
  41862. protected _target: Vector3;
  41863. protected _targetHost: Nullable<AbstractMesh>;
  41864. /**
  41865. * Defines the target point of the camera.
  41866. * The camera looks towards it form the radius distance.
  41867. */
  41868. get target(): Vector3;
  41869. set target(value: Vector3);
  41870. /**
  41871. * Define the current local position of the camera in the scene
  41872. */
  41873. get position(): Vector3;
  41874. set position(newPosition: Vector3);
  41875. protected _upVector: Vector3;
  41876. protected _upToYMatrix: Matrix;
  41877. protected _YToUpMatrix: Matrix;
  41878. /**
  41879. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41880. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41881. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41882. */
  41883. set upVector(vec: Vector3);
  41884. get upVector(): Vector3;
  41885. /**
  41886. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41887. */
  41888. setMatUp(): void;
  41889. /**
  41890. * Current inertia value on the longitudinal axis.
  41891. * The bigger this number the longer it will take for the camera to stop.
  41892. */
  41893. inertialAlphaOffset: number;
  41894. /**
  41895. * Current inertia value on the latitudinal axis.
  41896. * The bigger this number the longer it will take for the camera to stop.
  41897. */
  41898. inertialBetaOffset: number;
  41899. /**
  41900. * Current inertia value on the radius axis.
  41901. * The bigger this number the longer it will take for the camera to stop.
  41902. */
  41903. inertialRadiusOffset: number;
  41904. /**
  41905. * Minimum allowed angle on the longitudinal axis.
  41906. * This can help limiting how the Camera is able to move in the scene.
  41907. */
  41908. lowerAlphaLimit: Nullable<number>;
  41909. /**
  41910. * Maximum allowed angle on the longitudinal axis.
  41911. * This can help limiting how the Camera is able to move in the scene.
  41912. */
  41913. upperAlphaLimit: Nullable<number>;
  41914. /**
  41915. * Minimum allowed angle on the latitudinal axis.
  41916. * This can help limiting how the Camera is able to move in the scene.
  41917. */
  41918. lowerBetaLimit: number;
  41919. /**
  41920. * Maximum allowed angle on the latitudinal axis.
  41921. * This can help limiting how the Camera is able to move in the scene.
  41922. */
  41923. upperBetaLimit: number;
  41924. /**
  41925. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41926. * This can help limiting how the Camera is able to move in the scene.
  41927. */
  41928. lowerRadiusLimit: Nullable<number>;
  41929. /**
  41930. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41931. * This can help limiting how the Camera is able to move in the scene.
  41932. */
  41933. upperRadiusLimit: Nullable<number>;
  41934. /**
  41935. * Defines the current inertia value used during panning of the camera along the X axis.
  41936. */
  41937. inertialPanningX: number;
  41938. /**
  41939. * Defines the current inertia value used during panning of the camera along the Y axis.
  41940. */
  41941. inertialPanningY: number;
  41942. /**
  41943. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41944. * Basically if your fingers moves away from more than this distance you will be considered
  41945. * in pinch mode.
  41946. */
  41947. pinchToPanMaxDistance: number;
  41948. /**
  41949. * Defines the maximum distance the camera can pan.
  41950. * This could help keeping the cammera always in your scene.
  41951. */
  41952. panningDistanceLimit: Nullable<number>;
  41953. /**
  41954. * Defines the target of the camera before paning.
  41955. */
  41956. panningOriginTarget: Vector3;
  41957. /**
  41958. * Defines the value of the inertia used during panning.
  41959. * 0 would mean stop inertia and one would mean no decelleration at all.
  41960. */
  41961. panningInertia: number;
  41962. /**
  41963. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41964. */
  41965. get angularSensibilityX(): number;
  41966. set angularSensibilityX(value: number);
  41967. /**
  41968. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41969. */
  41970. get angularSensibilityY(): number;
  41971. set angularSensibilityY(value: number);
  41972. /**
  41973. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41974. */
  41975. get pinchPrecision(): number;
  41976. set pinchPrecision(value: number);
  41977. /**
  41978. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41979. * It will be used instead of pinchDeltaPrecision if different from 0.
  41980. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41981. */
  41982. get pinchDeltaPercentage(): number;
  41983. set pinchDeltaPercentage(value: number);
  41984. /**
  41985. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41986. * and pinch delta percentage.
  41987. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41988. * that any object in the plane at the camera's target point will scale
  41989. * perfectly with finger motion.
  41990. */
  41991. get useNaturalPinchZoom(): boolean;
  41992. set useNaturalPinchZoom(value: boolean);
  41993. /**
  41994. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41995. */
  41996. get panningSensibility(): number;
  41997. set panningSensibility(value: number);
  41998. /**
  41999. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42000. */
  42001. get keysUp(): number[];
  42002. set keysUp(value: number[]);
  42003. /**
  42004. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42005. */
  42006. get keysDown(): number[];
  42007. set keysDown(value: number[]);
  42008. /**
  42009. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42010. */
  42011. get keysLeft(): number[];
  42012. set keysLeft(value: number[]);
  42013. /**
  42014. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42015. */
  42016. get keysRight(): number[];
  42017. set keysRight(value: number[]);
  42018. /**
  42019. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42020. */
  42021. get wheelPrecision(): number;
  42022. set wheelPrecision(value: number);
  42023. /**
  42024. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42025. * It will be used instead of pinchDeltaPrecision if different from 0.
  42026. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42027. */
  42028. get wheelDeltaPercentage(): number;
  42029. set wheelDeltaPercentage(value: number);
  42030. /**
  42031. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42032. */
  42033. zoomOnFactor: number;
  42034. /**
  42035. * Defines a screen offset for the camera position.
  42036. */
  42037. targetScreenOffset: Vector2;
  42038. /**
  42039. * Allows the camera to be completely reversed.
  42040. * If false the camera can not arrive upside down.
  42041. */
  42042. allowUpsideDown: boolean;
  42043. /**
  42044. * Define if double tap/click is used to restore the previously saved state of the camera.
  42045. */
  42046. useInputToRestoreState: boolean;
  42047. /** @hidden */
  42048. _viewMatrix: Matrix;
  42049. /** @hidden */
  42050. _useCtrlForPanning: boolean;
  42051. /** @hidden */
  42052. _panningMouseButton: number;
  42053. /**
  42054. * Defines the input associated to the camera.
  42055. */
  42056. inputs: ArcRotateCameraInputsManager;
  42057. /** @hidden */
  42058. _reset: () => void;
  42059. /**
  42060. * Defines the allowed panning axis.
  42061. */
  42062. panningAxis: Vector3;
  42063. protected _localDirection: Vector3;
  42064. protected _transformedDirection: Vector3;
  42065. private _bouncingBehavior;
  42066. /**
  42067. * Gets the bouncing behavior of the camera if it has been enabled.
  42068. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42069. */
  42070. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42071. /**
  42072. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42073. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42074. */
  42075. get useBouncingBehavior(): boolean;
  42076. set useBouncingBehavior(value: boolean);
  42077. private _framingBehavior;
  42078. /**
  42079. * Gets the framing behavior of the camera if it has been enabled.
  42080. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42081. */
  42082. get framingBehavior(): Nullable<FramingBehavior>;
  42083. /**
  42084. * Defines if the framing behavior of the camera is enabled on the camera.
  42085. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42086. */
  42087. get useFramingBehavior(): boolean;
  42088. set useFramingBehavior(value: boolean);
  42089. private _autoRotationBehavior;
  42090. /**
  42091. * Gets the auto rotation behavior of the camera if it has been enabled.
  42092. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42093. */
  42094. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42095. /**
  42096. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42097. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42098. */
  42099. get useAutoRotationBehavior(): boolean;
  42100. set useAutoRotationBehavior(value: boolean);
  42101. /**
  42102. * Observable triggered when the mesh target has been changed on the camera.
  42103. */
  42104. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42105. /**
  42106. * Event raised when the camera is colliding with a mesh.
  42107. */
  42108. onCollide: (collidedMesh: AbstractMesh) => void;
  42109. /**
  42110. * Defines whether the camera should check collision with the objects oh the scene.
  42111. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42112. */
  42113. checkCollisions: boolean;
  42114. /**
  42115. * Defines the collision radius of the camera.
  42116. * This simulates a sphere around the camera.
  42117. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42118. */
  42119. collisionRadius: Vector3;
  42120. protected _collider: Collider;
  42121. protected _previousPosition: Vector3;
  42122. protected _collisionVelocity: Vector3;
  42123. protected _newPosition: Vector3;
  42124. protected _previousAlpha: number;
  42125. protected _previousBeta: number;
  42126. protected _previousRadius: number;
  42127. protected _collisionTriggered: boolean;
  42128. protected _targetBoundingCenter: Nullable<Vector3>;
  42129. private _computationVector;
  42130. /**
  42131. * Instantiates a new ArcRotateCamera in a given scene
  42132. * @param name Defines the name of the camera
  42133. * @param alpha Defines the camera rotation along the logitudinal axis
  42134. * @param beta Defines the camera rotation along the latitudinal axis
  42135. * @param radius Defines the camera distance from its target
  42136. * @param target Defines the camera target
  42137. * @param scene Defines the scene the camera belongs to
  42138. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42139. */
  42140. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42141. /** @hidden */
  42142. _initCache(): void;
  42143. /** @hidden */
  42144. _updateCache(ignoreParentClass?: boolean): void;
  42145. protected _getTargetPosition(): Vector3;
  42146. private _storedAlpha;
  42147. private _storedBeta;
  42148. private _storedRadius;
  42149. private _storedTarget;
  42150. private _storedTargetScreenOffset;
  42151. /**
  42152. * Stores the current state of the camera (alpha, beta, radius and target)
  42153. * @returns the camera itself
  42154. */
  42155. storeState(): Camera;
  42156. /**
  42157. * @hidden
  42158. * Restored camera state. You must call storeState() first
  42159. */
  42160. _restoreStateValues(): boolean;
  42161. /** @hidden */
  42162. _isSynchronizedViewMatrix(): boolean;
  42163. /**
  42164. * Attached controls to the current camera.
  42165. * @param element Defines the element the controls should be listened from
  42166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42167. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42168. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42169. */
  42170. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42171. /**
  42172. * Detach the current controls from the camera.
  42173. * The camera will stop reacting to inputs.
  42174. * @param element Defines the element to stop listening the inputs from
  42175. */
  42176. detachControl(element: HTMLElement): void;
  42177. /** @hidden */
  42178. _checkInputs(): void;
  42179. protected _checkLimits(): void;
  42180. /**
  42181. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42182. */
  42183. rebuildAnglesAndRadius(): void;
  42184. /**
  42185. * Use a position to define the current camera related information like alpha, beta and radius
  42186. * @param position Defines the position to set the camera at
  42187. */
  42188. setPosition(position: Vector3): void;
  42189. /**
  42190. * Defines the target the camera should look at.
  42191. * This will automatically adapt alpha beta and radius to fit within the new target.
  42192. * @param target Defines the new target as a Vector or a mesh
  42193. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42194. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42195. */
  42196. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42197. /** @hidden */
  42198. _getViewMatrix(): Matrix;
  42199. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42200. /**
  42201. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42202. * @param meshes Defines the mesh to zoom on
  42203. * @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)
  42204. */
  42205. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42206. /**
  42207. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42208. * The target will be changed but the radius
  42209. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42210. * @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)
  42211. */
  42212. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42213. min: Vector3;
  42214. max: Vector3;
  42215. distance: number;
  42216. }, doNotUpdateMaxZ?: boolean): void;
  42217. /**
  42218. * @override
  42219. * Override Camera.createRigCamera
  42220. */
  42221. createRigCamera(name: string, cameraIndex: number): Camera;
  42222. /**
  42223. * @hidden
  42224. * @override
  42225. * Override Camera._updateRigCameras
  42226. */
  42227. _updateRigCameras(): void;
  42228. /**
  42229. * Destroy the camera and release the current resources hold by it.
  42230. */
  42231. dispose(): void;
  42232. /**
  42233. * Gets the current object class name.
  42234. * @return the class name
  42235. */
  42236. getClassName(): string;
  42237. }
  42238. }
  42239. declare module BABYLON {
  42240. /**
  42241. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42242. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42243. */
  42244. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42245. /**
  42246. * Gets the name of the behavior.
  42247. */
  42248. get name(): string;
  42249. private _zoomStopsAnimation;
  42250. private _idleRotationSpeed;
  42251. private _idleRotationWaitTime;
  42252. private _idleRotationSpinupTime;
  42253. /**
  42254. * Sets the flag that indicates if user zooming should stop animation.
  42255. */
  42256. set zoomStopsAnimation(flag: boolean);
  42257. /**
  42258. * Gets the flag that indicates if user zooming should stop animation.
  42259. */
  42260. get zoomStopsAnimation(): boolean;
  42261. /**
  42262. * Sets the default speed at which the camera rotates around the model.
  42263. */
  42264. set idleRotationSpeed(speed: number);
  42265. /**
  42266. * Gets the default speed at which the camera rotates around the model.
  42267. */
  42268. get idleRotationSpeed(): number;
  42269. /**
  42270. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42271. */
  42272. set idleRotationWaitTime(time: number);
  42273. /**
  42274. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42275. */
  42276. get idleRotationWaitTime(): number;
  42277. /**
  42278. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42279. */
  42280. set idleRotationSpinupTime(time: number);
  42281. /**
  42282. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42283. */
  42284. get idleRotationSpinupTime(): number;
  42285. /**
  42286. * Gets a value indicating if the camera is currently rotating because of this behavior
  42287. */
  42288. get rotationInProgress(): boolean;
  42289. private _onPrePointerObservableObserver;
  42290. private _onAfterCheckInputsObserver;
  42291. private _attachedCamera;
  42292. private _isPointerDown;
  42293. private _lastFrameTime;
  42294. private _lastInteractionTime;
  42295. private _cameraRotationSpeed;
  42296. /**
  42297. * Initializes the behavior.
  42298. */
  42299. init(): void;
  42300. /**
  42301. * Attaches the behavior to its arc rotate camera.
  42302. * @param camera Defines the camera to attach the behavior to
  42303. */
  42304. attach(camera: ArcRotateCamera): void;
  42305. /**
  42306. * Detaches the behavior from its current arc rotate camera.
  42307. */
  42308. detach(): void;
  42309. /**
  42310. * Returns true if user is scrolling.
  42311. * @return true if user is scrolling.
  42312. */
  42313. private _userIsZooming;
  42314. private _lastFrameRadius;
  42315. private _shouldAnimationStopForInteraction;
  42316. /**
  42317. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42318. */
  42319. private _applyUserInteraction;
  42320. private _userIsMoving;
  42321. }
  42322. }
  42323. declare module BABYLON {
  42324. /**
  42325. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42326. */
  42327. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42328. private ui;
  42329. /**
  42330. * The name of the behavior
  42331. */
  42332. name: string;
  42333. /**
  42334. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42335. */
  42336. distanceAwayFromFace: number;
  42337. /**
  42338. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42339. */
  42340. distanceAwayFromBottomOfFace: number;
  42341. private _faceVectors;
  42342. private _target;
  42343. private _scene;
  42344. private _onRenderObserver;
  42345. private _tmpMatrix;
  42346. private _tmpVector;
  42347. /**
  42348. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42349. * @param ui The transform node that should be attched to the mesh
  42350. */
  42351. constructor(ui: TransformNode);
  42352. /**
  42353. * Initializes the behavior
  42354. */
  42355. init(): void;
  42356. private _closestFace;
  42357. private _zeroVector;
  42358. private _lookAtTmpMatrix;
  42359. private _lookAtToRef;
  42360. /**
  42361. * Attaches the AttachToBoxBehavior to the passed in mesh
  42362. * @param target The mesh that the specified node will be attached to
  42363. */
  42364. attach(target: Mesh): void;
  42365. /**
  42366. * Detaches the behavior from the mesh
  42367. */
  42368. detach(): void;
  42369. }
  42370. }
  42371. declare module BABYLON {
  42372. /**
  42373. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42374. */
  42375. export class FadeInOutBehavior implements Behavior<Mesh> {
  42376. /**
  42377. * Time in milliseconds to delay before fading in (Default: 0)
  42378. */
  42379. delay: number;
  42380. /**
  42381. * Time in milliseconds for the mesh to fade in (Default: 300)
  42382. */
  42383. fadeInTime: number;
  42384. private _millisecondsPerFrame;
  42385. private _hovered;
  42386. private _hoverValue;
  42387. private _ownerNode;
  42388. /**
  42389. * Instatiates the FadeInOutBehavior
  42390. */
  42391. constructor();
  42392. /**
  42393. * The name of the behavior
  42394. */
  42395. get name(): string;
  42396. /**
  42397. * Initializes the behavior
  42398. */
  42399. init(): void;
  42400. /**
  42401. * Attaches the fade behavior on the passed in mesh
  42402. * @param ownerNode The mesh that will be faded in/out once attached
  42403. */
  42404. attach(ownerNode: Mesh): void;
  42405. /**
  42406. * Detaches the behavior from the mesh
  42407. */
  42408. detach(): void;
  42409. /**
  42410. * Triggers the mesh to begin fading in or out
  42411. * @param value if the object should fade in or out (true to fade in)
  42412. */
  42413. fadeIn(value: boolean): void;
  42414. private _update;
  42415. private _setAllVisibility;
  42416. }
  42417. }
  42418. declare module BABYLON {
  42419. /**
  42420. * Class containing a set of static utilities functions for managing Pivots
  42421. * @hidden
  42422. */
  42423. export class PivotTools {
  42424. private static _PivotCached;
  42425. private static _OldPivotPoint;
  42426. private static _PivotTranslation;
  42427. private static _PivotTmpVector;
  42428. /** @hidden */
  42429. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42430. /** @hidden */
  42431. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42432. }
  42433. }
  42434. declare module BABYLON {
  42435. /**
  42436. * Class containing static functions to help procedurally build meshes
  42437. */
  42438. export class PlaneBuilder {
  42439. /**
  42440. * Creates a plane mesh
  42441. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42442. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42443. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42445. * * 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
  42446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42447. * @param name defines the name of the mesh
  42448. * @param options defines the options used to create the mesh
  42449. * @param scene defines the hosting scene
  42450. * @returns the plane mesh
  42451. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42452. */
  42453. static CreatePlane(name: string, options: {
  42454. size?: number;
  42455. width?: number;
  42456. height?: number;
  42457. sideOrientation?: number;
  42458. frontUVs?: Vector4;
  42459. backUVs?: Vector4;
  42460. updatable?: boolean;
  42461. sourcePlane?: Plane;
  42462. }, scene?: Nullable<Scene>): Mesh;
  42463. }
  42464. }
  42465. declare module BABYLON {
  42466. /**
  42467. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42468. */
  42469. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42470. private static _AnyMouseID;
  42471. /**
  42472. * Abstract mesh the behavior is set on
  42473. */
  42474. attachedNode: AbstractMesh;
  42475. private _dragPlane;
  42476. private _scene;
  42477. private _pointerObserver;
  42478. private _beforeRenderObserver;
  42479. private static _planeScene;
  42480. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42481. /**
  42482. * 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)
  42483. */
  42484. maxDragAngle: number;
  42485. /**
  42486. * @hidden
  42487. */
  42488. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42489. /**
  42490. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42491. */
  42492. currentDraggingPointerID: number;
  42493. /**
  42494. * The last position where the pointer hit the drag plane in world space
  42495. */
  42496. lastDragPosition: Vector3;
  42497. /**
  42498. * If the behavior is currently in a dragging state
  42499. */
  42500. dragging: boolean;
  42501. /**
  42502. * 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)
  42503. */
  42504. dragDeltaRatio: number;
  42505. /**
  42506. * If the drag plane orientation should be updated during the dragging (Default: true)
  42507. */
  42508. updateDragPlane: boolean;
  42509. private _debugMode;
  42510. private _moving;
  42511. /**
  42512. * Fires each time the attached mesh is dragged with the pointer
  42513. * * delta between last drag position and current drag position in world space
  42514. * * dragDistance along the drag axis
  42515. * * dragPlaneNormal normal of the current drag plane used during the drag
  42516. * * dragPlanePoint in world space where the drag intersects the drag plane
  42517. */
  42518. onDragObservable: Observable<{
  42519. delta: Vector3;
  42520. dragPlanePoint: Vector3;
  42521. dragPlaneNormal: Vector3;
  42522. dragDistance: number;
  42523. pointerId: number;
  42524. }>;
  42525. /**
  42526. * Fires each time a drag begins (eg. mouse down on mesh)
  42527. */
  42528. onDragStartObservable: Observable<{
  42529. dragPlanePoint: Vector3;
  42530. pointerId: number;
  42531. }>;
  42532. /**
  42533. * Fires each time a drag ends (eg. mouse release after drag)
  42534. */
  42535. onDragEndObservable: Observable<{
  42536. dragPlanePoint: Vector3;
  42537. pointerId: number;
  42538. }>;
  42539. /**
  42540. * If the attached mesh should be moved when dragged
  42541. */
  42542. moveAttached: boolean;
  42543. /**
  42544. * If the drag behavior will react to drag events (Default: true)
  42545. */
  42546. enabled: boolean;
  42547. /**
  42548. * If pointer events should start and release the drag (Default: true)
  42549. */
  42550. startAndReleaseDragOnPointerEvents: boolean;
  42551. /**
  42552. * If camera controls should be detached during the drag
  42553. */
  42554. detachCameraControls: boolean;
  42555. /**
  42556. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42557. */
  42558. useObjectOrientationForDragging: boolean;
  42559. private _options;
  42560. /**
  42561. * Gets the options used by the behavior
  42562. */
  42563. get options(): {
  42564. dragAxis?: Vector3;
  42565. dragPlaneNormal?: Vector3;
  42566. };
  42567. /**
  42568. * Sets the options used by the behavior
  42569. */
  42570. set options(options: {
  42571. dragAxis?: Vector3;
  42572. dragPlaneNormal?: Vector3;
  42573. });
  42574. /**
  42575. * Creates a pointer drag behavior that can be attached to a mesh
  42576. * @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)
  42577. */
  42578. constructor(options?: {
  42579. dragAxis?: Vector3;
  42580. dragPlaneNormal?: Vector3;
  42581. });
  42582. /**
  42583. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42584. */
  42585. validateDrag: (targetPosition: Vector3) => boolean;
  42586. /**
  42587. * The name of the behavior
  42588. */
  42589. get name(): string;
  42590. /**
  42591. * Initializes the behavior
  42592. */
  42593. init(): void;
  42594. private _tmpVector;
  42595. private _alternatePickedPoint;
  42596. private _worldDragAxis;
  42597. private _targetPosition;
  42598. private _attachedElement;
  42599. /**
  42600. * Attaches the drag behavior the passed in mesh
  42601. * @param ownerNode The mesh that will be dragged around once attached
  42602. * @param predicate Predicate to use for pick filtering
  42603. */
  42604. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42605. /**
  42606. * Force relase the drag action by code.
  42607. */
  42608. releaseDrag(): void;
  42609. private _startDragRay;
  42610. private _lastPointerRay;
  42611. /**
  42612. * Simulates the start of a pointer drag event on the behavior
  42613. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42614. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42615. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42616. */
  42617. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42618. private _startDrag;
  42619. private _dragDelta;
  42620. private _moveDrag;
  42621. private _pickWithRayOnDragPlane;
  42622. private _pointA;
  42623. private _pointB;
  42624. private _pointC;
  42625. private _lineA;
  42626. private _lineB;
  42627. private _localAxis;
  42628. private _lookAt;
  42629. private _updateDragPlanePosition;
  42630. /**
  42631. * Detaches the behavior from the mesh
  42632. */
  42633. detach(): void;
  42634. }
  42635. }
  42636. declare module BABYLON {
  42637. /**
  42638. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42639. */
  42640. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42641. private _dragBehaviorA;
  42642. private _dragBehaviorB;
  42643. private _startDistance;
  42644. private _initialScale;
  42645. private _targetScale;
  42646. private _ownerNode;
  42647. private _sceneRenderObserver;
  42648. /**
  42649. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42650. */
  42651. constructor();
  42652. /**
  42653. * The name of the behavior
  42654. */
  42655. get name(): string;
  42656. /**
  42657. * Initializes the behavior
  42658. */
  42659. init(): void;
  42660. private _getCurrentDistance;
  42661. /**
  42662. * Attaches the scale behavior the passed in mesh
  42663. * @param ownerNode The mesh that will be scaled around once attached
  42664. */
  42665. attach(ownerNode: Mesh): void;
  42666. /**
  42667. * Detaches the behavior from the mesh
  42668. */
  42669. detach(): void;
  42670. }
  42671. }
  42672. declare module BABYLON {
  42673. /**
  42674. * 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
  42675. */
  42676. export class SixDofDragBehavior implements Behavior<Mesh> {
  42677. private static _virtualScene;
  42678. private _ownerNode;
  42679. private _sceneRenderObserver;
  42680. private _scene;
  42681. private _targetPosition;
  42682. private _virtualOriginMesh;
  42683. private _virtualDragMesh;
  42684. private _pointerObserver;
  42685. private _moving;
  42686. private _startingOrientation;
  42687. private _attachedElement;
  42688. /**
  42689. * 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)
  42690. */
  42691. private zDragFactor;
  42692. /**
  42693. * If the object should rotate to face the drag origin
  42694. */
  42695. rotateDraggedObject: boolean;
  42696. /**
  42697. * If the behavior is currently in a dragging state
  42698. */
  42699. dragging: boolean;
  42700. /**
  42701. * 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)
  42702. */
  42703. dragDeltaRatio: number;
  42704. /**
  42705. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42706. */
  42707. currentDraggingPointerID: number;
  42708. /**
  42709. * If camera controls should be detached during the drag
  42710. */
  42711. detachCameraControls: boolean;
  42712. /**
  42713. * Fires each time a drag starts
  42714. */
  42715. onDragStartObservable: Observable<{}>;
  42716. /**
  42717. * Fires each time a drag ends (eg. mouse release after drag)
  42718. */
  42719. onDragEndObservable: Observable<{}>;
  42720. /**
  42721. * 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
  42722. */
  42723. constructor();
  42724. /**
  42725. * The name of the behavior
  42726. */
  42727. get name(): string;
  42728. /**
  42729. * Initializes the behavior
  42730. */
  42731. init(): void;
  42732. /**
  42733. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42734. */
  42735. private get _pointerCamera();
  42736. /**
  42737. * Attaches the scale behavior the passed in mesh
  42738. * @param ownerNode The mesh that will be scaled around once attached
  42739. */
  42740. attach(ownerNode: Mesh): void;
  42741. /**
  42742. * Detaches the behavior from the mesh
  42743. */
  42744. detach(): void;
  42745. }
  42746. }
  42747. declare module BABYLON {
  42748. /**
  42749. * Class used to apply inverse kinematics to bones
  42750. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42751. */
  42752. export class BoneIKController {
  42753. private static _tmpVecs;
  42754. private static _tmpQuat;
  42755. private static _tmpMats;
  42756. /**
  42757. * Gets or sets the target mesh
  42758. */
  42759. targetMesh: AbstractMesh;
  42760. /** Gets or sets the mesh used as pole */
  42761. poleTargetMesh: AbstractMesh;
  42762. /**
  42763. * Gets or sets the bone used as pole
  42764. */
  42765. poleTargetBone: Nullable<Bone>;
  42766. /**
  42767. * Gets or sets the target position
  42768. */
  42769. targetPosition: Vector3;
  42770. /**
  42771. * Gets or sets the pole target position
  42772. */
  42773. poleTargetPosition: Vector3;
  42774. /**
  42775. * Gets or sets the pole target local offset
  42776. */
  42777. poleTargetLocalOffset: Vector3;
  42778. /**
  42779. * Gets or sets the pole angle
  42780. */
  42781. poleAngle: number;
  42782. /**
  42783. * Gets or sets the mesh associated with the controller
  42784. */
  42785. mesh: AbstractMesh;
  42786. /**
  42787. * 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)
  42788. */
  42789. slerpAmount: number;
  42790. private _bone1Quat;
  42791. private _bone1Mat;
  42792. private _bone2Ang;
  42793. private _bone1;
  42794. private _bone2;
  42795. private _bone1Length;
  42796. private _bone2Length;
  42797. private _maxAngle;
  42798. private _maxReach;
  42799. private _rightHandedSystem;
  42800. private _bendAxis;
  42801. private _slerping;
  42802. private _adjustRoll;
  42803. /**
  42804. * Gets or sets maximum allowed angle
  42805. */
  42806. get maxAngle(): number;
  42807. set maxAngle(value: number);
  42808. /**
  42809. * Creates a new BoneIKController
  42810. * @param mesh defines the mesh to control
  42811. * @param bone defines the bone to control
  42812. * @param options defines options to set up the controller
  42813. */
  42814. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42815. targetMesh?: AbstractMesh;
  42816. poleTargetMesh?: AbstractMesh;
  42817. poleTargetBone?: Bone;
  42818. poleTargetLocalOffset?: Vector3;
  42819. poleAngle?: number;
  42820. bendAxis?: Vector3;
  42821. maxAngle?: number;
  42822. slerpAmount?: number;
  42823. });
  42824. private _setMaxAngle;
  42825. /**
  42826. * Force the controller to update the bones
  42827. */
  42828. update(): void;
  42829. }
  42830. }
  42831. declare module BABYLON {
  42832. /**
  42833. * Class used to make a bone look toward a point in space
  42834. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42835. */
  42836. export class BoneLookController {
  42837. private static _tmpVecs;
  42838. private static _tmpQuat;
  42839. private static _tmpMats;
  42840. /**
  42841. * The target Vector3 that the bone will look at
  42842. */
  42843. target: Vector3;
  42844. /**
  42845. * The mesh that the bone is attached to
  42846. */
  42847. mesh: AbstractMesh;
  42848. /**
  42849. * The bone that will be looking to the target
  42850. */
  42851. bone: Bone;
  42852. /**
  42853. * The up axis of the coordinate system that is used when the bone is rotated
  42854. */
  42855. upAxis: Vector3;
  42856. /**
  42857. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42858. */
  42859. upAxisSpace: Space;
  42860. /**
  42861. * Used to make an adjustment to the yaw of the bone
  42862. */
  42863. adjustYaw: number;
  42864. /**
  42865. * Used to make an adjustment to the pitch of the bone
  42866. */
  42867. adjustPitch: number;
  42868. /**
  42869. * Used to make an adjustment to the roll of the bone
  42870. */
  42871. adjustRoll: number;
  42872. /**
  42873. * 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)
  42874. */
  42875. slerpAmount: number;
  42876. private _minYaw;
  42877. private _maxYaw;
  42878. private _minPitch;
  42879. private _maxPitch;
  42880. private _minYawSin;
  42881. private _minYawCos;
  42882. private _maxYawSin;
  42883. private _maxYawCos;
  42884. private _midYawConstraint;
  42885. private _minPitchTan;
  42886. private _maxPitchTan;
  42887. private _boneQuat;
  42888. private _slerping;
  42889. private _transformYawPitch;
  42890. private _transformYawPitchInv;
  42891. private _firstFrameSkipped;
  42892. private _yawRange;
  42893. private _fowardAxis;
  42894. /**
  42895. * Gets or sets the minimum yaw angle that the bone can look to
  42896. */
  42897. get minYaw(): number;
  42898. set minYaw(value: number);
  42899. /**
  42900. * Gets or sets the maximum yaw angle that the bone can look to
  42901. */
  42902. get maxYaw(): number;
  42903. set maxYaw(value: number);
  42904. /**
  42905. * Gets or sets the minimum pitch angle that the bone can look to
  42906. */
  42907. get minPitch(): number;
  42908. set minPitch(value: number);
  42909. /**
  42910. * Gets or sets the maximum pitch angle that the bone can look to
  42911. */
  42912. get maxPitch(): number;
  42913. set maxPitch(value: number);
  42914. /**
  42915. * Create a BoneLookController
  42916. * @param mesh the mesh that the bone belongs to
  42917. * @param bone the bone that will be looking to the target
  42918. * @param target the target Vector3 to look at
  42919. * @param options optional settings:
  42920. * * maxYaw: the maximum angle the bone will yaw to
  42921. * * minYaw: the minimum angle the bone will yaw to
  42922. * * maxPitch: the maximum angle the bone will pitch to
  42923. * * minPitch: the minimum angle the bone will yaw to
  42924. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42925. * * upAxis: the up axis of the coordinate system
  42926. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42927. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42928. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42929. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42930. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42931. * * adjustRoll: used to make an adjustment to the roll of the bone
  42932. **/
  42933. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42934. maxYaw?: number;
  42935. minYaw?: number;
  42936. maxPitch?: number;
  42937. minPitch?: number;
  42938. slerpAmount?: number;
  42939. upAxis?: Vector3;
  42940. upAxisSpace?: Space;
  42941. yawAxis?: Vector3;
  42942. pitchAxis?: Vector3;
  42943. adjustYaw?: number;
  42944. adjustPitch?: number;
  42945. adjustRoll?: number;
  42946. });
  42947. /**
  42948. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42949. */
  42950. update(): void;
  42951. private _getAngleDiff;
  42952. private _getAngleBetween;
  42953. private _isAngleBetween;
  42954. }
  42955. }
  42956. declare module BABYLON {
  42957. /**
  42958. * Manage the gamepad inputs to control an arc rotate camera.
  42959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42960. */
  42961. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42962. /**
  42963. * Defines the camera the input is attached to.
  42964. */
  42965. camera: ArcRotateCamera;
  42966. /**
  42967. * Defines the gamepad the input is gathering event from.
  42968. */
  42969. gamepad: Nullable<Gamepad>;
  42970. /**
  42971. * Defines the gamepad rotation sensiblity.
  42972. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42973. */
  42974. gamepadRotationSensibility: number;
  42975. /**
  42976. * Defines the gamepad move sensiblity.
  42977. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42978. */
  42979. gamepadMoveSensibility: number;
  42980. private _yAxisScale;
  42981. /**
  42982. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42983. */
  42984. get invertYAxis(): boolean;
  42985. set invertYAxis(value: boolean);
  42986. private _onGamepadConnectedObserver;
  42987. private _onGamepadDisconnectedObserver;
  42988. /**
  42989. * Attach the input controls to a specific dom element to get the input from.
  42990. * @param element Defines the element the controls should be listened from
  42991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42992. */
  42993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42994. /**
  42995. * Detach the current controls from the specified dom element.
  42996. * @param element Defines the element to stop listening the inputs from
  42997. */
  42998. detachControl(element: Nullable<HTMLElement>): void;
  42999. /**
  43000. * Update the current camera state depending on the inputs that have been used this frame.
  43001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43002. */
  43003. checkInputs(): void;
  43004. /**
  43005. * Gets the class name of the current intput.
  43006. * @returns the class name
  43007. */
  43008. getClassName(): string;
  43009. /**
  43010. * Get the friendly name associated with the input class.
  43011. * @returns the input friendly name
  43012. */
  43013. getSimpleName(): string;
  43014. }
  43015. }
  43016. declare module BABYLON {
  43017. interface ArcRotateCameraInputsManager {
  43018. /**
  43019. * Add orientation input support to the input manager.
  43020. * @returns the current input manager
  43021. */
  43022. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43023. }
  43024. /**
  43025. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43027. */
  43028. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43029. /**
  43030. * Defines the camera the input is attached to.
  43031. */
  43032. camera: ArcRotateCamera;
  43033. /**
  43034. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43035. */
  43036. alphaCorrection: number;
  43037. /**
  43038. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43039. */
  43040. gammaCorrection: number;
  43041. private _alpha;
  43042. private _gamma;
  43043. private _dirty;
  43044. private _deviceOrientationHandler;
  43045. /**
  43046. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43047. */
  43048. constructor();
  43049. /**
  43050. * Attach the input controls to a specific dom element to get the input from.
  43051. * @param element Defines the element the controls should be listened from
  43052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43053. */
  43054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43055. /** @hidden */
  43056. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43057. /**
  43058. * Update the current camera state depending on the inputs that have been used this frame.
  43059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43060. */
  43061. checkInputs(): void;
  43062. /**
  43063. * Detach the current controls from the specified dom element.
  43064. * @param element Defines the element to stop listening the inputs from
  43065. */
  43066. detachControl(element: Nullable<HTMLElement>): void;
  43067. /**
  43068. * Gets the class name of the current intput.
  43069. * @returns the class name
  43070. */
  43071. getClassName(): string;
  43072. /**
  43073. * Get the friendly name associated with the input class.
  43074. * @returns the input friendly name
  43075. */
  43076. getSimpleName(): string;
  43077. }
  43078. }
  43079. declare module BABYLON {
  43080. /**
  43081. * Listen to mouse events to control the camera.
  43082. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43083. */
  43084. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43085. /**
  43086. * Defines the camera the input is attached to.
  43087. */
  43088. camera: FlyCamera;
  43089. /**
  43090. * Defines if touch is enabled. (Default is true.)
  43091. */
  43092. touchEnabled: boolean;
  43093. /**
  43094. * Defines the buttons associated with the input to handle camera rotation.
  43095. */
  43096. buttons: number[];
  43097. /**
  43098. * Assign buttons for Yaw control.
  43099. */
  43100. buttonsYaw: number[];
  43101. /**
  43102. * Assign buttons for Pitch control.
  43103. */
  43104. buttonsPitch: number[];
  43105. /**
  43106. * Assign buttons for Roll control.
  43107. */
  43108. buttonsRoll: number[];
  43109. /**
  43110. * Detect if any button is being pressed while mouse is moved.
  43111. * -1 = Mouse locked.
  43112. * 0 = Left button.
  43113. * 1 = Middle Button.
  43114. * 2 = Right Button.
  43115. */
  43116. activeButton: number;
  43117. /**
  43118. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43119. * Higher values reduce its sensitivity.
  43120. */
  43121. angularSensibility: number;
  43122. private _mousemoveCallback;
  43123. private _observer;
  43124. private _rollObserver;
  43125. private previousPosition;
  43126. private noPreventDefault;
  43127. private element;
  43128. /**
  43129. * Listen to mouse events to control the camera.
  43130. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43131. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43132. */
  43133. constructor(touchEnabled?: boolean);
  43134. /**
  43135. * Attach the mouse control to the HTML DOM element.
  43136. * @param element Defines the element that listens to the input events.
  43137. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43138. */
  43139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43140. /**
  43141. * Detach the current controls from the specified dom element.
  43142. * @param element Defines the element to stop listening the inputs from
  43143. */
  43144. detachControl(element: Nullable<HTMLElement>): void;
  43145. /**
  43146. * Gets the class name of the current input.
  43147. * @returns the class name.
  43148. */
  43149. getClassName(): string;
  43150. /**
  43151. * Get the friendly name associated with the input class.
  43152. * @returns the input's friendly name.
  43153. */
  43154. getSimpleName(): string;
  43155. private _pointerInput;
  43156. private _onMouseMove;
  43157. /**
  43158. * Rotate camera by mouse offset.
  43159. */
  43160. private rotateCamera;
  43161. }
  43162. }
  43163. declare module BABYLON {
  43164. /**
  43165. * Default Inputs manager for the FlyCamera.
  43166. * It groups all the default supported inputs for ease of use.
  43167. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43168. */
  43169. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43170. /**
  43171. * Instantiates a new FlyCameraInputsManager.
  43172. * @param camera Defines the camera the inputs belong to.
  43173. */
  43174. constructor(camera: FlyCamera);
  43175. /**
  43176. * Add keyboard input support to the input manager.
  43177. * @returns the new FlyCameraKeyboardMoveInput().
  43178. */
  43179. addKeyboard(): FlyCameraInputsManager;
  43180. /**
  43181. * Add mouse input support to the input manager.
  43182. * @param touchEnabled Enable touch screen support.
  43183. * @returns the new FlyCameraMouseInput().
  43184. */
  43185. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43186. }
  43187. }
  43188. declare module BABYLON {
  43189. /**
  43190. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43191. * such as in a 3D Space Shooter or a Flight Simulator.
  43192. */
  43193. export class FlyCamera extends TargetCamera {
  43194. /**
  43195. * Define the collision ellipsoid of the camera.
  43196. * This is helpful for simulating a camera body, like a player's body.
  43197. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43198. */
  43199. ellipsoid: Vector3;
  43200. /**
  43201. * Define an offset for the position of the ellipsoid around the camera.
  43202. * This can be helpful if the camera is attached away from the player's body center,
  43203. * such as at its head.
  43204. */
  43205. ellipsoidOffset: Vector3;
  43206. /**
  43207. * Enable or disable collisions of the camera with the rest of the scene objects.
  43208. */
  43209. checkCollisions: boolean;
  43210. /**
  43211. * Enable or disable gravity on the camera.
  43212. */
  43213. applyGravity: boolean;
  43214. /**
  43215. * Define the current direction the camera is moving to.
  43216. */
  43217. cameraDirection: Vector3;
  43218. /**
  43219. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43220. * This overrides and empties cameraRotation.
  43221. */
  43222. rotationQuaternion: Quaternion;
  43223. /**
  43224. * Track Roll to maintain the wanted Rolling when looking around.
  43225. */
  43226. _trackRoll: number;
  43227. /**
  43228. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43229. */
  43230. rollCorrect: number;
  43231. /**
  43232. * Mimic a banked turn, Rolling the camera when Yawing.
  43233. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43234. */
  43235. bankedTurn: boolean;
  43236. /**
  43237. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43238. */
  43239. bankedTurnLimit: number;
  43240. /**
  43241. * Value of 0 disables the banked Roll.
  43242. * Value of 1 is equal to the Yaw angle in radians.
  43243. */
  43244. bankedTurnMultiplier: number;
  43245. /**
  43246. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43247. */
  43248. inputs: FlyCameraInputsManager;
  43249. /**
  43250. * Gets the input sensibility for mouse input.
  43251. * Higher values reduce sensitivity.
  43252. */
  43253. get angularSensibility(): number;
  43254. /**
  43255. * Sets the input sensibility for a mouse input.
  43256. * Higher values reduce sensitivity.
  43257. */
  43258. set angularSensibility(value: number);
  43259. /**
  43260. * Get the keys for camera movement forward.
  43261. */
  43262. get keysForward(): number[];
  43263. /**
  43264. * Set the keys for camera movement forward.
  43265. */
  43266. set keysForward(value: number[]);
  43267. /**
  43268. * Get the keys for camera movement backward.
  43269. */
  43270. get keysBackward(): number[];
  43271. set keysBackward(value: number[]);
  43272. /**
  43273. * Get the keys for camera movement up.
  43274. */
  43275. get keysUp(): number[];
  43276. /**
  43277. * Set the keys for camera movement up.
  43278. */
  43279. set keysUp(value: number[]);
  43280. /**
  43281. * Get the keys for camera movement down.
  43282. */
  43283. get keysDown(): number[];
  43284. /**
  43285. * Set the keys for camera movement down.
  43286. */
  43287. set keysDown(value: number[]);
  43288. /**
  43289. * Get the keys for camera movement left.
  43290. */
  43291. get keysLeft(): number[];
  43292. /**
  43293. * Set the keys for camera movement left.
  43294. */
  43295. set keysLeft(value: number[]);
  43296. /**
  43297. * Set the keys for camera movement right.
  43298. */
  43299. get keysRight(): number[];
  43300. /**
  43301. * Set the keys for camera movement right.
  43302. */
  43303. set keysRight(value: number[]);
  43304. /**
  43305. * Event raised when the camera collides with a mesh in the scene.
  43306. */
  43307. onCollide: (collidedMesh: AbstractMesh) => void;
  43308. private _collider;
  43309. private _needMoveForGravity;
  43310. private _oldPosition;
  43311. private _diffPosition;
  43312. private _newPosition;
  43313. /** @hidden */
  43314. _localDirection: Vector3;
  43315. /** @hidden */
  43316. _transformedDirection: Vector3;
  43317. /**
  43318. * Instantiates a FlyCamera.
  43319. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43320. * such as in a 3D Space Shooter or a Flight Simulator.
  43321. * @param name Define the name of the camera in the scene.
  43322. * @param position Define the starting position of the camera in the scene.
  43323. * @param scene Define the scene the camera belongs to.
  43324. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43325. */
  43326. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43327. /**
  43328. * Attach a control to the HTML DOM element.
  43329. * @param element Defines the element that listens to the input events.
  43330. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43331. */
  43332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43333. /**
  43334. * Detach a control from the HTML DOM element.
  43335. * The camera will stop reacting to that input.
  43336. * @param element Defines the element that listens to the input events.
  43337. */
  43338. detachControl(element: HTMLElement): void;
  43339. private _collisionMask;
  43340. /**
  43341. * Get the mask that the camera ignores in collision events.
  43342. */
  43343. get collisionMask(): number;
  43344. /**
  43345. * Set the mask that the camera ignores in collision events.
  43346. */
  43347. set collisionMask(mask: number);
  43348. /** @hidden */
  43349. _collideWithWorld(displacement: Vector3): void;
  43350. /** @hidden */
  43351. private _onCollisionPositionChange;
  43352. /** @hidden */
  43353. _checkInputs(): void;
  43354. /** @hidden */
  43355. _decideIfNeedsToMove(): boolean;
  43356. /** @hidden */
  43357. _updatePosition(): void;
  43358. /**
  43359. * Restore the Roll to its target value at the rate specified.
  43360. * @param rate - Higher means slower restoring.
  43361. * @hidden
  43362. */
  43363. restoreRoll(rate: number): void;
  43364. /**
  43365. * Destroy the camera and release the current resources held by it.
  43366. */
  43367. dispose(): void;
  43368. /**
  43369. * Get the current object class name.
  43370. * @returns the class name.
  43371. */
  43372. getClassName(): string;
  43373. }
  43374. }
  43375. declare module BABYLON {
  43376. /**
  43377. * Listen to keyboard events to control the camera.
  43378. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43379. */
  43380. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43381. /**
  43382. * Defines the camera the input is attached to.
  43383. */
  43384. camera: FlyCamera;
  43385. /**
  43386. * The list of keyboard keys used to control the forward move of the camera.
  43387. */
  43388. keysForward: number[];
  43389. /**
  43390. * The list of keyboard keys used to control the backward move of the camera.
  43391. */
  43392. keysBackward: number[];
  43393. /**
  43394. * The list of keyboard keys used to control the forward move of the camera.
  43395. */
  43396. keysUp: number[];
  43397. /**
  43398. * The list of keyboard keys used to control the backward move of the camera.
  43399. */
  43400. keysDown: number[];
  43401. /**
  43402. * The list of keyboard keys used to control the right strafe move of the camera.
  43403. */
  43404. keysRight: number[];
  43405. /**
  43406. * The list of keyboard keys used to control the left strafe move of the camera.
  43407. */
  43408. keysLeft: number[];
  43409. private _keys;
  43410. private _onCanvasBlurObserver;
  43411. private _onKeyboardObserver;
  43412. private _engine;
  43413. private _scene;
  43414. /**
  43415. * Attach the input controls to a specific dom element to get the input from.
  43416. * @param element Defines the element the controls should be listened from
  43417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43418. */
  43419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43420. /**
  43421. * Detach the current controls from the specified dom element.
  43422. * @param element Defines the element to stop listening the inputs from
  43423. */
  43424. detachControl(element: Nullable<HTMLElement>): void;
  43425. /**
  43426. * Gets the class name of the current intput.
  43427. * @returns the class name
  43428. */
  43429. getClassName(): string;
  43430. /** @hidden */
  43431. _onLostFocus(e: FocusEvent): void;
  43432. /**
  43433. * Get the friendly name associated with the input class.
  43434. * @returns the input friendly name
  43435. */
  43436. getSimpleName(): string;
  43437. /**
  43438. * Update the current camera state depending on the inputs that have been used this frame.
  43439. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43440. */
  43441. checkInputs(): void;
  43442. }
  43443. }
  43444. declare module BABYLON {
  43445. /**
  43446. * Manage the mouse wheel inputs to control a follow camera.
  43447. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43448. */
  43449. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43450. /**
  43451. * Defines the camera the input is attached to.
  43452. */
  43453. camera: FollowCamera;
  43454. /**
  43455. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43456. */
  43457. axisControlRadius: boolean;
  43458. /**
  43459. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43460. */
  43461. axisControlHeight: boolean;
  43462. /**
  43463. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43464. */
  43465. axisControlRotation: boolean;
  43466. /**
  43467. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43468. * relation to mouseWheel events.
  43469. */
  43470. wheelPrecision: number;
  43471. /**
  43472. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43473. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43474. */
  43475. wheelDeltaPercentage: number;
  43476. private _wheel;
  43477. private _observer;
  43478. /**
  43479. * Attach the input controls to a specific dom element to get the input from.
  43480. * @param element Defines the element the controls should be listened from
  43481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43482. */
  43483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43484. /**
  43485. * Detach the current controls from the specified dom element.
  43486. * @param element Defines the element to stop listening the inputs from
  43487. */
  43488. detachControl(element: Nullable<HTMLElement>): void;
  43489. /**
  43490. * Gets the class name of the current intput.
  43491. * @returns the class name
  43492. */
  43493. getClassName(): string;
  43494. /**
  43495. * Get the friendly name associated with the input class.
  43496. * @returns the input friendly name
  43497. */
  43498. getSimpleName(): string;
  43499. }
  43500. }
  43501. declare module BABYLON {
  43502. /**
  43503. * Manage the pointers inputs to control an follow camera.
  43504. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43505. */
  43506. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43507. /**
  43508. * Defines the camera the input is attached to.
  43509. */
  43510. camera: FollowCamera;
  43511. /**
  43512. * Gets the class name of the current input.
  43513. * @returns the class name
  43514. */
  43515. getClassName(): string;
  43516. /**
  43517. * Defines the pointer angular sensibility along the X axis or how fast is
  43518. * the camera rotating.
  43519. * A negative number will reverse the axis direction.
  43520. */
  43521. angularSensibilityX: number;
  43522. /**
  43523. * Defines the pointer angular sensibility along the Y axis or how fast is
  43524. * the camera rotating.
  43525. * A negative number will reverse the axis direction.
  43526. */
  43527. angularSensibilityY: number;
  43528. /**
  43529. * Defines the pointer pinch precision or how fast is the camera zooming.
  43530. * A negative number will reverse the axis direction.
  43531. */
  43532. pinchPrecision: number;
  43533. /**
  43534. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43535. * from 0.
  43536. * It defines the percentage of current camera.radius to use as delta when
  43537. * pinch zoom is used.
  43538. */
  43539. pinchDeltaPercentage: number;
  43540. /**
  43541. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43542. */
  43543. axisXControlRadius: boolean;
  43544. /**
  43545. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43546. */
  43547. axisXControlHeight: boolean;
  43548. /**
  43549. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43550. */
  43551. axisXControlRotation: boolean;
  43552. /**
  43553. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43554. */
  43555. axisYControlRadius: boolean;
  43556. /**
  43557. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43558. */
  43559. axisYControlHeight: boolean;
  43560. /**
  43561. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43562. */
  43563. axisYControlRotation: boolean;
  43564. /**
  43565. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43566. */
  43567. axisPinchControlRadius: boolean;
  43568. /**
  43569. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43570. */
  43571. axisPinchControlHeight: boolean;
  43572. /**
  43573. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43574. */
  43575. axisPinchControlRotation: boolean;
  43576. /**
  43577. * Log error messages if basic misconfiguration has occurred.
  43578. */
  43579. warningEnable: boolean;
  43580. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43581. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43582. private _warningCounter;
  43583. private _warning;
  43584. }
  43585. }
  43586. declare module BABYLON {
  43587. /**
  43588. * Default Inputs manager for the FollowCamera.
  43589. * It groups all the default supported inputs for ease of use.
  43590. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43591. */
  43592. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43593. /**
  43594. * Instantiates a new FollowCameraInputsManager.
  43595. * @param camera Defines the camera the inputs belong to
  43596. */
  43597. constructor(camera: FollowCamera);
  43598. /**
  43599. * Add keyboard input support to the input manager.
  43600. * @returns the current input manager
  43601. */
  43602. addKeyboard(): FollowCameraInputsManager;
  43603. /**
  43604. * Add mouse wheel input support to the input manager.
  43605. * @returns the current input manager
  43606. */
  43607. addMouseWheel(): FollowCameraInputsManager;
  43608. /**
  43609. * Add pointers input support to the input manager.
  43610. * @returns the current input manager
  43611. */
  43612. addPointers(): FollowCameraInputsManager;
  43613. /**
  43614. * Add orientation input support to the input manager.
  43615. * @returns the current input manager
  43616. */
  43617. addVRDeviceOrientation(): FollowCameraInputsManager;
  43618. }
  43619. }
  43620. declare module BABYLON {
  43621. /**
  43622. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43623. * an arc rotate version arcFollowCamera are available.
  43624. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43625. */
  43626. export class FollowCamera extends TargetCamera {
  43627. /**
  43628. * Distance the follow camera should follow an object at
  43629. */
  43630. radius: number;
  43631. /**
  43632. * Minimum allowed distance of the camera to the axis of rotation
  43633. * (The camera can not get closer).
  43634. * This can help limiting how the Camera is able to move in the scene.
  43635. */
  43636. lowerRadiusLimit: Nullable<number>;
  43637. /**
  43638. * Maximum allowed distance of the camera to the axis of rotation
  43639. * (The camera can not get further).
  43640. * This can help limiting how the Camera is able to move in the scene.
  43641. */
  43642. upperRadiusLimit: Nullable<number>;
  43643. /**
  43644. * Define a rotation offset between the camera and the object it follows
  43645. */
  43646. rotationOffset: number;
  43647. /**
  43648. * Minimum allowed angle to camera position relative to target object.
  43649. * This can help limiting how the Camera is able to move in the scene.
  43650. */
  43651. lowerRotationOffsetLimit: Nullable<number>;
  43652. /**
  43653. * Maximum 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. upperRotationOffsetLimit: Nullable<number>;
  43657. /**
  43658. * Define a height offset between the camera and the object it follows.
  43659. * It can help following an object from the top (like a car chaing a plane)
  43660. */
  43661. heightOffset: number;
  43662. /**
  43663. * Minimum allowed height of camera position relative to target object.
  43664. * This can help limiting how the Camera is able to move in the scene.
  43665. */
  43666. lowerHeightOffsetLimit: Nullable<number>;
  43667. /**
  43668. * Maximum 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. upperHeightOffsetLimit: Nullable<number>;
  43672. /**
  43673. * Define how fast the camera can accelerate to follow it s target.
  43674. */
  43675. cameraAcceleration: number;
  43676. /**
  43677. * Define the speed limit of the camera following an object.
  43678. */
  43679. maxCameraSpeed: number;
  43680. /**
  43681. * Define the target of the camera.
  43682. */
  43683. lockedTarget: Nullable<AbstractMesh>;
  43684. /**
  43685. * Defines the input associated with the camera.
  43686. */
  43687. inputs: FollowCameraInputsManager;
  43688. /**
  43689. * Instantiates the follow camera.
  43690. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43691. * @param name Define the name of the camera in the scene
  43692. * @param position Define the position of the camera
  43693. * @param scene Define the scene the camera belong to
  43694. * @param lockedTarget Define the target of the camera
  43695. */
  43696. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43697. private _follow;
  43698. /**
  43699. * Attached controls to the current camera.
  43700. * @param element Defines the element the controls should be listened from
  43701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43702. */
  43703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43704. /**
  43705. * Detach the current controls from the camera.
  43706. * The camera will stop reacting to inputs.
  43707. * @param element Defines the element to stop listening the inputs from
  43708. */
  43709. detachControl(element: HTMLElement): void;
  43710. /** @hidden */
  43711. _checkInputs(): void;
  43712. private _checkLimits;
  43713. /**
  43714. * Gets the camera class name.
  43715. * @returns the class name
  43716. */
  43717. getClassName(): string;
  43718. }
  43719. /**
  43720. * Arc Rotate version of the follow camera.
  43721. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43722. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43723. */
  43724. export class ArcFollowCamera extends TargetCamera {
  43725. /** The longitudinal angle of the camera */
  43726. alpha: number;
  43727. /** The latitudinal angle of the camera */
  43728. beta: number;
  43729. /** The radius of the camera from its target */
  43730. radius: number;
  43731. /** Define the camera target (the mesh it should follow) */
  43732. target: Nullable<AbstractMesh>;
  43733. private _cartesianCoordinates;
  43734. /**
  43735. * Instantiates a new ArcFollowCamera
  43736. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43737. * @param name Define the name of the camera
  43738. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43739. * @param beta Define the rotation angle of the camera around the elevation axis
  43740. * @param radius Define the radius of the camera from its target point
  43741. * @param target Define the target of the camera
  43742. * @param scene Define the scene the camera belongs to
  43743. */
  43744. constructor(name: string,
  43745. /** The longitudinal angle of the camera */
  43746. alpha: number,
  43747. /** The latitudinal angle of the camera */
  43748. beta: number,
  43749. /** The radius of the camera from its target */
  43750. radius: number,
  43751. /** Define the camera target (the mesh it should follow) */
  43752. target: Nullable<AbstractMesh>, scene: Scene);
  43753. private _follow;
  43754. /** @hidden */
  43755. _checkInputs(): void;
  43756. /**
  43757. * Returns the class name of the object.
  43758. * It is mostly used internally for serialization purposes.
  43759. */
  43760. getClassName(): string;
  43761. }
  43762. }
  43763. declare module BABYLON {
  43764. /**
  43765. * Manage the keyboard inputs to control the movement of a follow camera.
  43766. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43767. */
  43768. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43769. /**
  43770. * Defines the camera the input is attached to.
  43771. */
  43772. camera: FollowCamera;
  43773. /**
  43774. * Defines the list of key codes associated with the up action (increase heightOffset)
  43775. */
  43776. keysHeightOffsetIncr: number[];
  43777. /**
  43778. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43779. */
  43780. keysHeightOffsetDecr: number[];
  43781. /**
  43782. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43783. */
  43784. keysHeightOffsetModifierAlt: boolean;
  43785. /**
  43786. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43787. */
  43788. keysHeightOffsetModifierCtrl: boolean;
  43789. /**
  43790. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43791. */
  43792. keysHeightOffsetModifierShift: boolean;
  43793. /**
  43794. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43795. */
  43796. keysRotationOffsetIncr: number[];
  43797. /**
  43798. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43799. */
  43800. keysRotationOffsetDecr: number[];
  43801. /**
  43802. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43803. */
  43804. keysRotationOffsetModifierAlt: boolean;
  43805. /**
  43806. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43807. */
  43808. keysRotationOffsetModifierCtrl: boolean;
  43809. /**
  43810. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43811. */
  43812. keysRotationOffsetModifierShift: boolean;
  43813. /**
  43814. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43815. */
  43816. keysRadiusIncr: number[];
  43817. /**
  43818. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43819. */
  43820. keysRadiusDecr: number[];
  43821. /**
  43822. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43823. */
  43824. keysRadiusModifierAlt: boolean;
  43825. /**
  43826. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43827. */
  43828. keysRadiusModifierCtrl: boolean;
  43829. /**
  43830. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43831. */
  43832. keysRadiusModifierShift: boolean;
  43833. /**
  43834. * Defines the rate of change of heightOffset.
  43835. */
  43836. heightSensibility: number;
  43837. /**
  43838. * Defines the rate of change of rotationOffset.
  43839. */
  43840. rotationSensibility: number;
  43841. /**
  43842. * Defines the rate of change of radius.
  43843. */
  43844. radiusSensibility: number;
  43845. private _keys;
  43846. private _ctrlPressed;
  43847. private _altPressed;
  43848. private _shiftPressed;
  43849. private _onCanvasBlurObserver;
  43850. private _onKeyboardObserver;
  43851. private _engine;
  43852. private _scene;
  43853. /**
  43854. * Attach the input controls to a specific dom element to get the input from.
  43855. * @param element Defines the element the controls should be listened from
  43856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43857. */
  43858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43859. /**
  43860. * Detach the current controls from the specified dom element.
  43861. * @param element Defines the element to stop listening the inputs from
  43862. */
  43863. detachControl(element: Nullable<HTMLElement>): void;
  43864. /**
  43865. * Update the current camera state depending on the inputs that have been used this frame.
  43866. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43867. */
  43868. checkInputs(): void;
  43869. /**
  43870. * Gets the class name of the current input.
  43871. * @returns the class name
  43872. */
  43873. getClassName(): string;
  43874. /**
  43875. * Get the friendly name associated with the input class.
  43876. * @returns the input friendly name
  43877. */
  43878. getSimpleName(): string;
  43879. /**
  43880. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43881. * allow modification of the heightOffset value.
  43882. */
  43883. private _modifierHeightOffset;
  43884. /**
  43885. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43886. * allow modification of the rotationOffset value.
  43887. */
  43888. private _modifierRotationOffset;
  43889. /**
  43890. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43891. * allow modification of the radius value.
  43892. */
  43893. private _modifierRadius;
  43894. }
  43895. }
  43896. declare module BABYLON {
  43897. interface FreeCameraInputsManager {
  43898. /**
  43899. * @hidden
  43900. */
  43901. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43902. /**
  43903. * Add orientation input support to the input manager.
  43904. * @returns the current input manager
  43905. */
  43906. addDeviceOrientation(): FreeCameraInputsManager;
  43907. }
  43908. /**
  43909. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43910. * Screen rotation is taken into account.
  43911. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43912. */
  43913. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43914. private _camera;
  43915. private _screenOrientationAngle;
  43916. private _constantTranform;
  43917. private _screenQuaternion;
  43918. private _alpha;
  43919. private _beta;
  43920. private _gamma;
  43921. /**
  43922. * Can be used to detect if a device orientation sensor is available on a device
  43923. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43924. * @returns a promise that will resolve on orientation change
  43925. */
  43926. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43927. /**
  43928. * @hidden
  43929. */
  43930. _onDeviceOrientationChangedObservable: Observable<void>;
  43931. /**
  43932. * Instantiates a new input
  43933. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43934. */
  43935. constructor();
  43936. /**
  43937. * Define the camera controlled by the input.
  43938. */
  43939. get camera(): FreeCamera;
  43940. set camera(camera: FreeCamera);
  43941. /**
  43942. * Attach the input controls to a specific dom element to get the input from.
  43943. * @param element Defines the element the controls should be listened from
  43944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43945. */
  43946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43947. private _orientationChanged;
  43948. private _deviceOrientation;
  43949. /**
  43950. * Detach the current controls from the specified dom element.
  43951. * @param element Defines the element to stop listening the inputs from
  43952. */
  43953. detachControl(element: Nullable<HTMLElement>): void;
  43954. /**
  43955. * Update the current camera state depending on the inputs that have been used this frame.
  43956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43957. */
  43958. checkInputs(): void;
  43959. /**
  43960. * Gets the class name of the current intput.
  43961. * @returns the class name
  43962. */
  43963. getClassName(): string;
  43964. /**
  43965. * Get the friendly name associated with the input class.
  43966. * @returns the input friendly name
  43967. */
  43968. getSimpleName(): string;
  43969. }
  43970. }
  43971. declare module BABYLON {
  43972. /**
  43973. * Manage the gamepad inputs to control a free camera.
  43974. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43975. */
  43976. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43977. /**
  43978. * Define the camera the input is attached to.
  43979. */
  43980. camera: FreeCamera;
  43981. /**
  43982. * Define the Gamepad controlling the input
  43983. */
  43984. gamepad: Nullable<Gamepad>;
  43985. /**
  43986. * Defines the gamepad rotation sensiblity.
  43987. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43988. */
  43989. gamepadAngularSensibility: number;
  43990. /**
  43991. * Defines the gamepad move sensiblity.
  43992. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43993. */
  43994. gamepadMoveSensibility: number;
  43995. private _yAxisScale;
  43996. /**
  43997. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43998. */
  43999. get invertYAxis(): boolean;
  44000. set invertYAxis(value: boolean);
  44001. private _onGamepadConnectedObserver;
  44002. private _onGamepadDisconnectedObserver;
  44003. private _cameraTransform;
  44004. private _deltaTransform;
  44005. private _vector3;
  44006. private _vector2;
  44007. /**
  44008. * Attach the input controls to a specific dom element to get the input from.
  44009. * @param element Defines the element the controls should be listened from
  44010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44011. */
  44012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44013. /**
  44014. * Detach the current controls from the specified dom element.
  44015. * @param element Defines the element to stop listening the inputs from
  44016. */
  44017. detachControl(element: Nullable<HTMLElement>): void;
  44018. /**
  44019. * Update the current camera state depending on the inputs that have been used this frame.
  44020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44021. */
  44022. checkInputs(): void;
  44023. /**
  44024. * Gets the class name of the current intput.
  44025. * @returns the class name
  44026. */
  44027. getClassName(): string;
  44028. /**
  44029. * Get the friendly name associated with the input class.
  44030. * @returns the input friendly name
  44031. */
  44032. getSimpleName(): string;
  44033. }
  44034. }
  44035. declare module BABYLON {
  44036. /**
  44037. * Defines the potential axis of a Joystick
  44038. */
  44039. export enum JoystickAxis {
  44040. /** X axis */
  44041. X = 0,
  44042. /** Y axis */
  44043. Y = 1,
  44044. /** Z axis */
  44045. Z = 2
  44046. }
  44047. /**
  44048. * Represents the different customization options available
  44049. * for VirtualJoystick
  44050. */
  44051. interface VirtualJoystickCustomizations {
  44052. /**
  44053. * Size of the joystick's puck
  44054. */
  44055. puckSize: number;
  44056. /**
  44057. * Size of the joystick's container
  44058. */
  44059. containerSize: number;
  44060. /**
  44061. * Color of the joystick && puck
  44062. */
  44063. color: string;
  44064. /**
  44065. * Image URL for the joystick's puck
  44066. */
  44067. puckImage?: string;
  44068. /**
  44069. * Image URL for the joystick's container
  44070. */
  44071. containerImage?: string;
  44072. /**
  44073. * Defines the unmoving position of the joystick container
  44074. */
  44075. position?: {
  44076. x: number;
  44077. y: number;
  44078. };
  44079. /**
  44080. * Defines whether or not the joystick container is always visible
  44081. */
  44082. alwaysVisible: boolean;
  44083. /**
  44084. * Defines whether or not to limit the movement of the puck to the joystick's container
  44085. */
  44086. limitToContainer: boolean;
  44087. }
  44088. /**
  44089. * Class used to define virtual joystick (used in touch mode)
  44090. */
  44091. export class VirtualJoystick {
  44092. /**
  44093. * Gets or sets a boolean indicating that left and right values must be inverted
  44094. */
  44095. reverseLeftRight: boolean;
  44096. /**
  44097. * Gets or sets a boolean indicating that up and down values must be inverted
  44098. */
  44099. reverseUpDown: boolean;
  44100. /**
  44101. * Gets the offset value for the position (ie. the change of the position value)
  44102. */
  44103. deltaPosition: Vector3;
  44104. /**
  44105. * Gets a boolean indicating if the virtual joystick was pressed
  44106. */
  44107. pressed: boolean;
  44108. /**
  44109. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44110. */
  44111. static Canvas: Nullable<HTMLCanvasElement>;
  44112. /**
  44113. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44114. */
  44115. limitToContainer: boolean;
  44116. private static _globalJoystickIndex;
  44117. private static _alwaysVisibleSticks;
  44118. private static vjCanvasContext;
  44119. private static vjCanvasWidth;
  44120. private static vjCanvasHeight;
  44121. private static halfWidth;
  44122. private static _GetDefaultOptions;
  44123. private _action;
  44124. private _axisTargetedByLeftAndRight;
  44125. private _axisTargetedByUpAndDown;
  44126. private _joystickSensibility;
  44127. private _inversedSensibility;
  44128. private _joystickPointerID;
  44129. private _joystickColor;
  44130. private _joystickPointerPos;
  44131. private _joystickPreviousPointerPos;
  44132. private _joystickPointerStartPos;
  44133. private _deltaJoystickVector;
  44134. private _leftJoystick;
  44135. private _touches;
  44136. private _joystickPosition;
  44137. private _alwaysVisible;
  44138. private _puckImage;
  44139. private _containerImage;
  44140. private _joystickPuckSize;
  44141. private _joystickContainerSize;
  44142. private _clearPuckSize;
  44143. private _clearContainerSize;
  44144. private _clearPuckSizeOffset;
  44145. private _clearContainerSizeOffset;
  44146. private _onPointerDownHandlerRef;
  44147. private _onPointerMoveHandlerRef;
  44148. private _onPointerUpHandlerRef;
  44149. private _onResize;
  44150. /**
  44151. * Creates a new virtual joystick
  44152. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44153. * @param customizations Defines the options we want to customize the VirtualJoystick
  44154. */
  44155. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44156. /**
  44157. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44158. * @param newJoystickSensibility defines the new sensibility
  44159. */
  44160. setJoystickSensibility(newJoystickSensibility: number): void;
  44161. private _onPointerDown;
  44162. private _onPointerMove;
  44163. private _onPointerUp;
  44164. /**
  44165. * Change the color of the virtual joystick
  44166. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44167. */
  44168. setJoystickColor(newColor: string): void;
  44169. /**
  44170. * Size of the joystick's container
  44171. */
  44172. set containerSize(newSize: number);
  44173. get containerSize(): number;
  44174. /**
  44175. * Size of the joystick's puck
  44176. */
  44177. set puckSize(newSize: number);
  44178. get puckSize(): number;
  44179. /**
  44180. * Clears the set position of the joystick
  44181. */
  44182. clearPosition(): void;
  44183. /**
  44184. * Defines whether or not the joystick container is always visible
  44185. */
  44186. set alwaysVisible(value: boolean);
  44187. get alwaysVisible(): boolean;
  44188. /**
  44189. * Sets the constant position of the Joystick container
  44190. * @param x X axis coordinate
  44191. * @param y Y axis coordinate
  44192. */
  44193. setPosition(x: number, y: number): void;
  44194. /**
  44195. * Defines a callback to call when the joystick is touched
  44196. * @param action defines the callback
  44197. */
  44198. setActionOnTouch(action: () => any): void;
  44199. /**
  44200. * Defines which axis you'd like to control for left & right
  44201. * @param axis defines the axis to use
  44202. */
  44203. setAxisForLeftRight(axis: JoystickAxis): void;
  44204. /**
  44205. * Defines which axis you'd like to control for up & down
  44206. * @param axis defines the axis to use
  44207. */
  44208. setAxisForUpDown(axis: JoystickAxis): void;
  44209. /**
  44210. * Clears the canvas from the previous puck / container draw
  44211. */
  44212. private _clearPreviousDraw;
  44213. /**
  44214. * Loads `urlPath` to be used for the container's image
  44215. * @param urlPath defines the urlPath of an image to use
  44216. */
  44217. setContainerImage(urlPath: string): void;
  44218. /**
  44219. * Loads `urlPath` to be used for the puck's image
  44220. * @param urlPath defines the urlPath of an image to use
  44221. */
  44222. setPuckImage(urlPath: string): void;
  44223. /**
  44224. * Draws the Virtual Joystick's container
  44225. */
  44226. private _drawContainer;
  44227. /**
  44228. * Draws the Virtual Joystick's puck
  44229. */
  44230. private _drawPuck;
  44231. private _drawVirtualJoystick;
  44232. /**
  44233. * Release internal HTML canvas
  44234. */
  44235. releaseCanvas(): void;
  44236. }
  44237. }
  44238. declare module BABYLON {
  44239. interface FreeCameraInputsManager {
  44240. /**
  44241. * Add virtual joystick input support to the input manager.
  44242. * @returns the current input manager
  44243. */
  44244. addVirtualJoystick(): FreeCameraInputsManager;
  44245. }
  44246. /**
  44247. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44248. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44249. */
  44250. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44251. /**
  44252. * Defines the camera the input is attached to.
  44253. */
  44254. camera: FreeCamera;
  44255. private _leftjoystick;
  44256. private _rightjoystick;
  44257. /**
  44258. * Gets the left stick of the virtual joystick.
  44259. * @returns The virtual Joystick
  44260. */
  44261. getLeftJoystick(): VirtualJoystick;
  44262. /**
  44263. * Gets the right stick of the virtual joystick.
  44264. * @returns The virtual Joystick
  44265. */
  44266. getRightJoystick(): VirtualJoystick;
  44267. /**
  44268. * Update the current camera state depending on the inputs that have been used this frame.
  44269. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44270. */
  44271. checkInputs(): void;
  44272. /**
  44273. * Attach the input controls to a specific dom element to get the input from.
  44274. * @param element Defines the element the controls should be listened from
  44275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44276. */
  44277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44278. /**
  44279. * Detach the current controls from the specified dom element.
  44280. * @param element Defines the element to stop listening the inputs from
  44281. */
  44282. detachControl(element: Nullable<HTMLElement>): void;
  44283. /**
  44284. * Gets the class name of the current intput.
  44285. * @returns the class name
  44286. */
  44287. getClassName(): string;
  44288. /**
  44289. * Get the friendly name associated with the input class.
  44290. * @returns the input friendly name
  44291. */
  44292. getSimpleName(): string;
  44293. }
  44294. }
  44295. declare module BABYLON {
  44296. /**
  44297. * This represents a FPS type of camera controlled by touch.
  44298. * This is like a universal camera minus the Gamepad controls.
  44299. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44300. */
  44301. export class TouchCamera extends FreeCamera {
  44302. /**
  44303. * Defines the touch sensibility for rotation.
  44304. * The higher the faster.
  44305. */
  44306. get touchAngularSensibility(): number;
  44307. set touchAngularSensibility(value: number);
  44308. /**
  44309. * Defines the touch sensibility for move.
  44310. * The higher the faster.
  44311. */
  44312. get touchMoveSensibility(): number;
  44313. set touchMoveSensibility(value: number);
  44314. /**
  44315. * Instantiates a new touch camera.
  44316. * This represents a FPS type of camera controlled by touch.
  44317. * This is like a universal camera minus the Gamepad controls.
  44318. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44319. * @param name Define the name of the camera in the scene
  44320. * @param position Define the start position of the camera in the scene
  44321. * @param scene Define the scene the camera belongs to
  44322. */
  44323. constructor(name: string, position: Vector3, scene: Scene);
  44324. /**
  44325. * Gets the current object class name.
  44326. * @return the class name
  44327. */
  44328. getClassName(): string;
  44329. /** @hidden */
  44330. _setupInputs(): void;
  44331. }
  44332. }
  44333. declare module BABYLON {
  44334. /**
  44335. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44336. * being tilted forward or back and left or right.
  44337. */
  44338. export class DeviceOrientationCamera extends FreeCamera {
  44339. private _initialQuaternion;
  44340. private _quaternionCache;
  44341. private _tmpDragQuaternion;
  44342. private _disablePointerInputWhenUsingDeviceOrientation;
  44343. /**
  44344. * Creates a new device orientation camera
  44345. * @param name The name of the camera
  44346. * @param position The start position camera
  44347. * @param scene The scene the camera belongs to
  44348. */
  44349. constructor(name: string, position: Vector3, scene: Scene);
  44350. /**
  44351. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44352. */
  44353. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44354. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44355. private _dragFactor;
  44356. /**
  44357. * Enabled turning on the y axis when the orientation sensor is active
  44358. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44359. */
  44360. enableHorizontalDragging(dragFactor?: number): void;
  44361. /**
  44362. * Gets the current instance class name ("DeviceOrientationCamera").
  44363. * This helps avoiding instanceof at run time.
  44364. * @returns the class name
  44365. */
  44366. getClassName(): string;
  44367. /**
  44368. * @hidden
  44369. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44370. */
  44371. _checkInputs(): void;
  44372. /**
  44373. * Reset the camera to its default orientation on the specified axis only.
  44374. * @param axis The axis to reset
  44375. */
  44376. resetToCurrentRotation(axis?: Axis): void;
  44377. }
  44378. }
  44379. declare module BABYLON {
  44380. /**
  44381. * Defines supported buttons for XBox360 compatible gamepads
  44382. */
  44383. export enum Xbox360Button {
  44384. /** A */
  44385. A = 0,
  44386. /** B */
  44387. B = 1,
  44388. /** X */
  44389. X = 2,
  44390. /** Y */
  44391. Y = 3,
  44392. /** Left button */
  44393. LB = 4,
  44394. /** Right button */
  44395. RB = 5,
  44396. /** Back */
  44397. Back = 8,
  44398. /** Start */
  44399. Start = 9,
  44400. /** Left stick */
  44401. LeftStick = 10,
  44402. /** Right stick */
  44403. RightStick = 11
  44404. }
  44405. /** Defines values for XBox360 DPad */
  44406. export enum Xbox360Dpad {
  44407. /** Up */
  44408. Up = 12,
  44409. /** Down */
  44410. Down = 13,
  44411. /** Left */
  44412. Left = 14,
  44413. /** Right */
  44414. Right = 15
  44415. }
  44416. /**
  44417. * Defines a XBox360 gamepad
  44418. */
  44419. export class Xbox360Pad extends Gamepad {
  44420. private _leftTrigger;
  44421. private _rightTrigger;
  44422. private _onlefttriggerchanged;
  44423. private _onrighttriggerchanged;
  44424. private _onbuttondown;
  44425. private _onbuttonup;
  44426. private _ondpaddown;
  44427. private _ondpadup;
  44428. /** Observable raised when a button is pressed */
  44429. onButtonDownObservable: Observable<Xbox360Button>;
  44430. /** Observable raised when a button is released */
  44431. onButtonUpObservable: Observable<Xbox360Button>;
  44432. /** Observable raised when a pad is pressed */
  44433. onPadDownObservable: Observable<Xbox360Dpad>;
  44434. /** Observable raised when a pad is released */
  44435. onPadUpObservable: Observable<Xbox360Dpad>;
  44436. private _buttonA;
  44437. private _buttonB;
  44438. private _buttonX;
  44439. private _buttonY;
  44440. private _buttonBack;
  44441. private _buttonStart;
  44442. private _buttonLB;
  44443. private _buttonRB;
  44444. private _buttonLeftStick;
  44445. private _buttonRightStick;
  44446. private _dPadUp;
  44447. private _dPadDown;
  44448. private _dPadLeft;
  44449. private _dPadRight;
  44450. private _isXboxOnePad;
  44451. /**
  44452. * Creates a new XBox360 gamepad object
  44453. * @param id defines the id of this gamepad
  44454. * @param index defines its index
  44455. * @param gamepad defines the internal HTML gamepad object
  44456. * @param xboxOne defines if it is a XBox One gamepad
  44457. */
  44458. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44459. /**
  44460. * Defines the callback to call when left trigger is pressed
  44461. * @param callback defines the callback to use
  44462. */
  44463. onlefttriggerchanged(callback: (value: number) => void): void;
  44464. /**
  44465. * Defines the callback to call when right trigger is pressed
  44466. * @param callback defines the callback to use
  44467. */
  44468. onrighttriggerchanged(callback: (value: number) => void): void;
  44469. /**
  44470. * Gets the left trigger value
  44471. */
  44472. get leftTrigger(): number;
  44473. /**
  44474. * Sets the left trigger value
  44475. */
  44476. set leftTrigger(newValue: number);
  44477. /**
  44478. * Gets the right trigger value
  44479. */
  44480. get rightTrigger(): number;
  44481. /**
  44482. * Sets the right trigger value
  44483. */
  44484. set rightTrigger(newValue: number);
  44485. /**
  44486. * Defines the callback to call when a button is pressed
  44487. * @param callback defines the callback to use
  44488. */
  44489. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44490. /**
  44491. * Defines the callback to call when a button is released
  44492. * @param callback defines the callback to use
  44493. */
  44494. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44495. /**
  44496. * Defines the callback to call when a pad is pressed
  44497. * @param callback defines the callback to use
  44498. */
  44499. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44500. /**
  44501. * Defines the callback to call when a pad is released
  44502. * @param callback defines the callback to use
  44503. */
  44504. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44505. private _setButtonValue;
  44506. private _setDPadValue;
  44507. /**
  44508. * Gets the value of the `A` button
  44509. */
  44510. get buttonA(): number;
  44511. /**
  44512. * Sets the value of the `A` button
  44513. */
  44514. set buttonA(value: number);
  44515. /**
  44516. * Gets the value of the `B` button
  44517. */
  44518. get buttonB(): number;
  44519. /**
  44520. * Sets the value of the `B` button
  44521. */
  44522. set buttonB(value: number);
  44523. /**
  44524. * Gets the value of the `X` button
  44525. */
  44526. get buttonX(): number;
  44527. /**
  44528. * Sets the value of the `X` button
  44529. */
  44530. set buttonX(value: number);
  44531. /**
  44532. * Gets the value of the `Y` button
  44533. */
  44534. get buttonY(): number;
  44535. /**
  44536. * Sets the value of the `Y` button
  44537. */
  44538. set buttonY(value: number);
  44539. /**
  44540. * Gets the value of the `Start` button
  44541. */
  44542. get buttonStart(): number;
  44543. /**
  44544. * Sets the value of the `Start` button
  44545. */
  44546. set buttonStart(value: number);
  44547. /**
  44548. * Gets the value of the `Back` button
  44549. */
  44550. get buttonBack(): number;
  44551. /**
  44552. * Sets the value of the `Back` button
  44553. */
  44554. set buttonBack(value: number);
  44555. /**
  44556. * Gets the value of the `Left` button
  44557. */
  44558. get buttonLB(): number;
  44559. /**
  44560. * Sets the value of the `Left` button
  44561. */
  44562. set buttonLB(value: number);
  44563. /**
  44564. * Gets the value of the `Right` button
  44565. */
  44566. get buttonRB(): number;
  44567. /**
  44568. * Sets the value of the `Right` button
  44569. */
  44570. set buttonRB(value: number);
  44571. /**
  44572. * Gets the value of the Left joystick
  44573. */
  44574. get buttonLeftStick(): number;
  44575. /**
  44576. * Sets the value of the Left joystick
  44577. */
  44578. set buttonLeftStick(value: number);
  44579. /**
  44580. * Gets the value of the Right joystick
  44581. */
  44582. get buttonRightStick(): number;
  44583. /**
  44584. * Sets the value of the Right joystick
  44585. */
  44586. set buttonRightStick(value: number);
  44587. /**
  44588. * Gets the value of D-pad up
  44589. */
  44590. get dPadUp(): number;
  44591. /**
  44592. * Sets the value of D-pad up
  44593. */
  44594. set dPadUp(value: number);
  44595. /**
  44596. * Gets the value of D-pad down
  44597. */
  44598. get dPadDown(): number;
  44599. /**
  44600. * Sets the value of D-pad down
  44601. */
  44602. set dPadDown(value: number);
  44603. /**
  44604. * Gets the value of D-pad left
  44605. */
  44606. get dPadLeft(): number;
  44607. /**
  44608. * Sets the value of D-pad left
  44609. */
  44610. set dPadLeft(value: number);
  44611. /**
  44612. * Gets the value of D-pad right
  44613. */
  44614. get dPadRight(): number;
  44615. /**
  44616. * Sets the value of D-pad right
  44617. */
  44618. set dPadRight(value: number);
  44619. /**
  44620. * Force the gamepad to synchronize with device values
  44621. */
  44622. update(): void;
  44623. /**
  44624. * Disposes the gamepad
  44625. */
  44626. dispose(): void;
  44627. }
  44628. }
  44629. declare module BABYLON {
  44630. /**
  44631. * Defines supported buttons for DualShock compatible gamepads
  44632. */
  44633. export enum DualShockButton {
  44634. /** Cross */
  44635. Cross = 0,
  44636. /** Circle */
  44637. Circle = 1,
  44638. /** Square */
  44639. Square = 2,
  44640. /** Triangle */
  44641. Triangle = 3,
  44642. /** L1 */
  44643. L1 = 4,
  44644. /** R1 */
  44645. R1 = 5,
  44646. /** Share */
  44647. Share = 8,
  44648. /** Options */
  44649. Options = 9,
  44650. /** Left stick */
  44651. LeftStick = 10,
  44652. /** Right stick */
  44653. RightStick = 11
  44654. }
  44655. /** Defines values for DualShock DPad */
  44656. export enum DualShockDpad {
  44657. /** Up */
  44658. Up = 12,
  44659. /** Down */
  44660. Down = 13,
  44661. /** Left */
  44662. Left = 14,
  44663. /** Right */
  44664. Right = 15
  44665. }
  44666. /**
  44667. * Defines a DualShock gamepad
  44668. */
  44669. export class DualShockPad extends Gamepad {
  44670. private _leftTrigger;
  44671. private _rightTrigger;
  44672. private _onlefttriggerchanged;
  44673. private _onrighttriggerchanged;
  44674. private _onbuttondown;
  44675. private _onbuttonup;
  44676. private _ondpaddown;
  44677. private _ondpadup;
  44678. /** Observable raised when a button is pressed */
  44679. onButtonDownObservable: Observable<DualShockButton>;
  44680. /** Observable raised when a button is released */
  44681. onButtonUpObservable: Observable<DualShockButton>;
  44682. /** Observable raised when a pad is pressed */
  44683. onPadDownObservable: Observable<DualShockDpad>;
  44684. /** Observable raised when a pad is released */
  44685. onPadUpObservable: Observable<DualShockDpad>;
  44686. private _buttonCross;
  44687. private _buttonCircle;
  44688. private _buttonSquare;
  44689. private _buttonTriangle;
  44690. private _buttonShare;
  44691. private _buttonOptions;
  44692. private _buttonL1;
  44693. private _buttonR1;
  44694. private _buttonLeftStick;
  44695. private _buttonRightStick;
  44696. private _dPadUp;
  44697. private _dPadDown;
  44698. private _dPadLeft;
  44699. private _dPadRight;
  44700. /**
  44701. * Creates a new DualShock gamepad object
  44702. * @param id defines the id of this gamepad
  44703. * @param index defines its index
  44704. * @param gamepad defines the internal HTML gamepad object
  44705. */
  44706. constructor(id: string, index: number, gamepad: any);
  44707. /**
  44708. * Defines the callback to call when left trigger is pressed
  44709. * @param callback defines the callback to use
  44710. */
  44711. onlefttriggerchanged(callback: (value: number) => void): void;
  44712. /**
  44713. * Defines the callback to call when right trigger is pressed
  44714. * @param callback defines the callback to use
  44715. */
  44716. onrighttriggerchanged(callback: (value: number) => void): void;
  44717. /**
  44718. * Gets the left trigger value
  44719. */
  44720. get leftTrigger(): number;
  44721. /**
  44722. * Sets the left trigger value
  44723. */
  44724. set leftTrigger(newValue: number);
  44725. /**
  44726. * Gets the right trigger value
  44727. */
  44728. get rightTrigger(): number;
  44729. /**
  44730. * Sets the right trigger value
  44731. */
  44732. set rightTrigger(newValue: number);
  44733. /**
  44734. * Defines the callback to call when a button is pressed
  44735. * @param callback defines the callback to use
  44736. */
  44737. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44738. /**
  44739. * Defines the callback to call when a button is released
  44740. * @param callback defines the callback to use
  44741. */
  44742. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44743. /**
  44744. * Defines the callback to call when a pad is pressed
  44745. * @param callback defines the callback to use
  44746. */
  44747. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44748. /**
  44749. * Defines the callback to call when a pad is released
  44750. * @param callback defines the callback to use
  44751. */
  44752. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44753. private _setButtonValue;
  44754. private _setDPadValue;
  44755. /**
  44756. * Gets the value of the `Cross` button
  44757. */
  44758. get buttonCross(): number;
  44759. /**
  44760. * Sets the value of the `Cross` button
  44761. */
  44762. set buttonCross(value: number);
  44763. /**
  44764. * Gets the value of the `Circle` button
  44765. */
  44766. get buttonCircle(): number;
  44767. /**
  44768. * Sets the value of the `Circle` button
  44769. */
  44770. set buttonCircle(value: number);
  44771. /**
  44772. * Gets the value of the `Square` button
  44773. */
  44774. get buttonSquare(): number;
  44775. /**
  44776. * Sets the value of the `Square` button
  44777. */
  44778. set buttonSquare(value: number);
  44779. /**
  44780. * Gets the value of the `Triangle` button
  44781. */
  44782. get buttonTriangle(): number;
  44783. /**
  44784. * Sets the value of the `Triangle` button
  44785. */
  44786. set buttonTriangle(value: number);
  44787. /**
  44788. * Gets the value of the `Options` button
  44789. */
  44790. get buttonOptions(): number;
  44791. /**
  44792. * Sets the value of the `Options` button
  44793. */
  44794. set buttonOptions(value: number);
  44795. /**
  44796. * Gets the value of the `Share` button
  44797. */
  44798. get buttonShare(): number;
  44799. /**
  44800. * Sets the value of the `Share` button
  44801. */
  44802. set buttonShare(value: number);
  44803. /**
  44804. * Gets the value of the `L1` button
  44805. */
  44806. get buttonL1(): number;
  44807. /**
  44808. * Sets the value of the `L1` button
  44809. */
  44810. set buttonL1(value: number);
  44811. /**
  44812. * Gets the value of the `R1` button
  44813. */
  44814. get buttonR1(): number;
  44815. /**
  44816. * Sets the value of the `R1` button
  44817. */
  44818. set buttonR1(value: number);
  44819. /**
  44820. * Gets the value of the Left joystick
  44821. */
  44822. get buttonLeftStick(): number;
  44823. /**
  44824. * Sets the value of the Left joystick
  44825. */
  44826. set buttonLeftStick(value: number);
  44827. /**
  44828. * Gets the value of the Right joystick
  44829. */
  44830. get buttonRightStick(): number;
  44831. /**
  44832. * Sets the value of the Right joystick
  44833. */
  44834. set buttonRightStick(value: number);
  44835. /**
  44836. * Gets the value of D-pad up
  44837. */
  44838. get dPadUp(): number;
  44839. /**
  44840. * Sets the value of D-pad up
  44841. */
  44842. set dPadUp(value: number);
  44843. /**
  44844. * Gets the value of D-pad down
  44845. */
  44846. get dPadDown(): number;
  44847. /**
  44848. * Sets the value of D-pad down
  44849. */
  44850. set dPadDown(value: number);
  44851. /**
  44852. * Gets the value of D-pad left
  44853. */
  44854. get dPadLeft(): number;
  44855. /**
  44856. * Sets the value of D-pad left
  44857. */
  44858. set dPadLeft(value: number);
  44859. /**
  44860. * Gets the value of D-pad right
  44861. */
  44862. get dPadRight(): number;
  44863. /**
  44864. * Sets the value of D-pad right
  44865. */
  44866. set dPadRight(value: number);
  44867. /**
  44868. * Force the gamepad to synchronize with device values
  44869. */
  44870. update(): void;
  44871. /**
  44872. * Disposes the gamepad
  44873. */
  44874. dispose(): void;
  44875. }
  44876. }
  44877. declare module BABYLON {
  44878. /**
  44879. * Manager for handling gamepads
  44880. */
  44881. export class GamepadManager {
  44882. private _scene?;
  44883. private _babylonGamepads;
  44884. private _oneGamepadConnected;
  44885. /** @hidden */
  44886. _isMonitoring: boolean;
  44887. private _gamepadEventSupported;
  44888. private _gamepadSupport?;
  44889. /**
  44890. * observable to be triggered when the gamepad controller has been connected
  44891. */
  44892. onGamepadConnectedObservable: Observable<Gamepad>;
  44893. /**
  44894. * observable to be triggered when the gamepad controller has been disconnected
  44895. */
  44896. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44897. private _onGamepadConnectedEvent;
  44898. private _onGamepadDisconnectedEvent;
  44899. /**
  44900. * Initializes the gamepad manager
  44901. * @param _scene BabylonJS scene
  44902. */
  44903. constructor(_scene?: Scene | undefined);
  44904. /**
  44905. * The gamepads in the game pad manager
  44906. */
  44907. get gamepads(): Gamepad[];
  44908. /**
  44909. * Get the gamepad controllers based on type
  44910. * @param type The type of gamepad controller
  44911. * @returns Nullable gamepad
  44912. */
  44913. getGamepadByType(type?: number): Nullable<Gamepad>;
  44914. /**
  44915. * Disposes the gamepad manager
  44916. */
  44917. dispose(): void;
  44918. private _addNewGamepad;
  44919. private _startMonitoringGamepads;
  44920. private _stopMonitoringGamepads;
  44921. /** @hidden */
  44922. _checkGamepadsStatus(): void;
  44923. private _updateGamepadObjects;
  44924. }
  44925. }
  44926. declare module BABYLON {
  44927. interface Scene {
  44928. /** @hidden */
  44929. _gamepadManager: Nullable<GamepadManager>;
  44930. /**
  44931. * Gets the gamepad manager associated with the scene
  44932. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  44933. */
  44934. gamepadManager: GamepadManager;
  44935. }
  44936. /**
  44937. * Interface representing a free camera inputs manager
  44938. */
  44939. interface FreeCameraInputsManager {
  44940. /**
  44941. * Adds gamepad input support to the FreeCameraInputsManager.
  44942. * @returns the FreeCameraInputsManager
  44943. */
  44944. addGamepad(): FreeCameraInputsManager;
  44945. }
  44946. /**
  44947. * Interface representing an arc rotate camera inputs manager
  44948. */
  44949. interface ArcRotateCameraInputsManager {
  44950. /**
  44951. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44952. * @returns the camera inputs manager
  44953. */
  44954. addGamepad(): ArcRotateCameraInputsManager;
  44955. }
  44956. /**
  44957. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44958. */
  44959. export class GamepadSystemSceneComponent implements ISceneComponent {
  44960. /**
  44961. * The component name helpfull to identify the component in the list of scene components.
  44962. */
  44963. readonly name: string;
  44964. /**
  44965. * The scene the component belongs to.
  44966. */
  44967. scene: Scene;
  44968. /**
  44969. * Creates a new instance of the component for the given scene
  44970. * @param scene Defines the scene to register the component in
  44971. */
  44972. constructor(scene: Scene);
  44973. /**
  44974. * Registers the component in a given scene
  44975. */
  44976. register(): void;
  44977. /**
  44978. * Rebuilds the elements related to this component in case of
  44979. * context lost for instance.
  44980. */
  44981. rebuild(): void;
  44982. /**
  44983. * Disposes the component and the associated ressources
  44984. */
  44985. dispose(): void;
  44986. private _beforeCameraUpdate;
  44987. }
  44988. }
  44989. declare module BABYLON {
  44990. /**
  44991. * 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,
  44992. * which still works and will still be found in many Playgrounds.
  44993. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44994. */
  44995. export class UniversalCamera extends TouchCamera {
  44996. /**
  44997. * Defines the gamepad rotation sensiblity.
  44998. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44999. */
  45000. get gamepadAngularSensibility(): number;
  45001. set gamepadAngularSensibility(value: number);
  45002. /**
  45003. * Defines the gamepad move sensiblity.
  45004. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45005. */
  45006. get gamepadMoveSensibility(): number;
  45007. set gamepadMoveSensibility(value: number);
  45008. /**
  45009. * 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,
  45010. * which still works and will still be found in many Playgrounds.
  45011. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45012. * @param name Define the name of the camera in the scene
  45013. * @param position Define the start position of the camera in the scene
  45014. * @param scene Define the scene the camera belongs to
  45015. */
  45016. constructor(name: string, position: Vector3, scene: Scene);
  45017. /**
  45018. * Gets the current object class name.
  45019. * @return the class name
  45020. */
  45021. getClassName(): string;
  45022. }
  45023. }
  45024. declare module BABYLON {
  45025. /**
  45026. * This represents a FPS type of camera. This is only here for back compat purpose.
  45027. * Please use the UniversalCamera instead as both are identical.
  45028. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45029. */
  45030. export class GamepadCamera extends UniversalCamera {
  45031. /**
  45032. * Instantiates a new Gamepad Camera
  45033. * This represents a FPS type of camera. This is only here for back compat purpose.
  45034. * Please use the UniversalCamera instead as both are identical.
  45035. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45036. * @param name Define the name of the camera in the scene
  45037. * @param position Define the start position of the camera in the scene
  45038. * @param scene Define the scene the camera belongs to
  45039. */
  45040. constructor(name: string, position: Vector3, scene: Scene);
  45041. /**
  45042. * Gets the current object class name.
  45043. * @return the class name
  45044. */
  45045. getClassName(): string;
  45046. }
  45047. }
  45048. declare module BABYLON {
  45049. /** @hidden */
  45050. export var passPixelShader: {
  45051. name: string;
  45052. shader: string;
  45053. };
  45054. }
  45055. declare module BABYLON {
  45056. /** @hidden */
  45057. export var passCubePixelShader: {
  45058. name: string;
  45059. shader: string;
  45060. };
  45061. }
  45062. declare module BABYLON {
  45063. /**
  45064. * PassPostProcess which produces an output the same as it's input
  45065. */
  45066. export class PassPostProcess extends PostProcess {
  45067. /**
  45068. * Creates the PassPostProcess
  45069. * @param name The name of the effect.
  45070. * @param options The required width/height ratio to downsize to before computing the render pass.
  45071. * @param camera The camera to apply the render pass to.
  45072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45073. * @param engine The engine which the post process will be applied. (default: current engine)
  45074. * @param reusable If the post process can be reused on the same frame. (default: false)
  45075. * @param textureType The type of texture to be used when performing the post processing.
  45076. * @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)
  45077. */
  45078. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45079. }
  45080. /**
  45081. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45082. */
  45083. export class PassCubePostProcess extends PostProcess {
  45084. private _face;
  45085. /**
  45086. * Gets or sets the cube face to display.
  45087. * * 0 is +X
  45088. * * 1 is -X
  45089. * * 2 is +Y
  45090. * * 3 is -Y
  45091. * * 4 is +Z
  45092. * * 5 is -Z
  45093. */
  45094. get face(): number;
  45095. set face(value: number);
  45096. /**
  45097. * Creates the PassCubePostProcess
  45098. * @param name The name of the effect.
  45099. * @param options The required width/height ratio to downsize to before computing the render pass.
  45100. * @param camera The camera to apply the render pass to.
  45101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45102. * @param engine The engine which the post process will be applied. (default: current engine)
  45103. * @param reusable If the post process can be reused on the same frame. (default: false)
  45104. * @param textureType The type of texture to be used when performing the post processing.
  45105. * @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)
  45106. */
  45107. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45108. }
  45109. }
  45110. declare module BABYLON {
  45111. /** @hidden */
  45112. export var anaglyphPixelShader: {
  45113. name: string;
  45114. shader: string;
  45115. };
  45116. }
  45117. declare module BABYLON {
  45118. /**
  45119. * Postprocess used to generate anaglyphic rendering
  45120. */
  45121. export class AnaglyphPostProcess extends PostProcess {
  45122. private _passedProcess;
  45123. /**
  45124. * Creates a new AnaglyphPostProcess
  45125. * @param name defines postprocess name
  45126. * @param options defines creation options or target ratio scale
  45127. * @param rigCameras defines cameras using this postprocess
  45128. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45129. * @param engine defines hosting engine
  45130. * @param reusable defines if the postprocess will be reused multiple times per frame
  45131. */
  45132. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45133. }
  45134. }
  45135. declare module BABYLON {
  45136. /**
  45137. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45138. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45139. */
  45140. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45141. /**
  45142. * Creates a new AnaglyphArcRotateCamera
  45143. * @param name defines camera name
  45144. * @param alpha defines alpha angle (in radians)
  45145. * @param beta defines beta angle (in radians)
  45146. * @param radius defines radius
  45147. * @param target defines camera target
  45148. * @param interaxialDistance defines distance between each color axis
  45149. * @param scene defines the hosting scene
  45150. */
  45151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45152. /**
  45153. * Gets camera class name
  45154. * @returns AnaglyphArcRotateCamera
  45155. */
  45156. getClassName(): string;
  45157. }
  45158. }
  45159. declare module BABYLON {
  45160. /**
  45161. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45162. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45163. */
  45164. export class AnaglyphFreeCamera extends FreeCamera {
  45165. /**
  45166. * Creates a new AnaglyphFreeCamera
  45167. * @param name defines camera name
  45168. * @param position defines initial position
  45169. * @param interaxialDistance defines distance between each color axis
  45170. * @param scene defines the hosting scene
  45171. */
  45172. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45173. /**
  45174. * Gets camera class name
  45175. * @returns AnaglyphFreeCamera
  45176. */
  45177. getClassName(): string;
  45178. }
  45179. }
  45180. declare module BABYLON {
  45181. /**
  45182. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45183. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45184. */
  45185. export class AnaglyphGamepadCamera extends GamepadCamera {
  45186. /**
  45187. * Creates a new AnaglyphGamepadCamera
  45188. * @param name defines camera name
  45189. * @param position defines initial position
  45190. * @param interaxialDistance defines distance between each color axis
  45191. * @param scene defines the hosting scene
  45192. */
  45193. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45194. /**
  45195. * Gets camera class name
  45196. * @returns AnaglyphGamepadCamera
  45197. */
  45198. getClassName(): string;
  45199. }
  45200. }
  45201. declare module BABYLON {
  45202. /**
  45203. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45204. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45205. */
  45206. export class AnaglyphUniversalCamera extends UniversalCamera {
  45207. /**
  45208. * Creates a new AnaglyphUniversalCamera
  45209. * @param name defines camera name
  45210. * @param position defines initial position
  45211. * @param interaxialDistance defines distance between each color axis
  45212. * @param scene defines the hosting scene
  45213. */
  45214. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45215. /**
  45216. * Gets camera class name
  45217. * @returns AnaglyphUniversalCamera
  45218. */
  45219. getClassName(): string;
  45220. }
  45221. }
  45222. declare module BABYLON {
  45223. /**
  45224. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45225. * @see https://doc.babylonjs.com/features/cameras
  45226. */
  45227. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45228. /**
  45229. * Creates a new StereoscopicArcRotateCamera
  45230. * @param name defines camera name
  45231. * @param alpha defines alpha angle (in radians)
  45232. * @param beta defines beta angle (in radians)
  45233. * @param radius defines radius
  45234. * @param target defines camera target
  45235. * @param interaxialDistance defines distance between each color axis
  45236. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45237. * @param scene defines the hosting scene
  45238. */
  45239. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45240. /**
  45241. * Gets camera class name
  45242. * @returns StereoscopicArcRotateCamera
  45243. */
  45244. getClassName(): string;
  45245. }
  45246. }
  45247. declare module BABYLON {
  45248. /**
  45249. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45250. * @see https://doc.babylonjs.com/features/cameras
  45251. */
  45252. export class StereoscopicFreeCamera extends FreeCamera {
  45253. /**
  45254. * Creates a new StereoscopicFreeCamera
  45255. * @param name defines camera name
  45256. * @param position defines initial position
  45257. * @param interaxialDistance defines distance between each color axis
  45258. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45259. * @param scene defines the hosting scene
  45260. */
  45261. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45262. /**
  45263. * Gets camera class name
  45264. * @returns StereoscopicFreeCamera
  45265. */
  45266. getClassName(): string;
  45267. }
  45268. }
  45269. declare module BABYLON {
  45270. /**
  45271. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45272. * @see https://doc.babylonjs.com/features/cameras
  45273. */
  45274. export class StereoscopicGamepadCamera extends GamepadCamera {
  45275. /**
  45276. * Creates a new StereoscopicGamepadCamera
  45277. * @param name defines camera name
  45278. * @param position defines initial position
  45279. * @param interaxialDistance defines distance between each color axis
  45280. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45281. * @param scene defines the hosting scene
  45282. */
  45283. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45284. /**
  45285. * Gets camera class name
  45286. * @returns StereoscopicGamepadCamera
  45287. */
  45288. getClassName(): string;
  45289. }
  45290. }
  45291. declare module BABYLON {
  45292. /**
  45293. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45294. * @see https://doc.babylonjs.com/features/cameras
  45295. */
  45296. export class StereoscopicUniversalCamera extends UniversalCamera {
  45297. /**
  45298. * Creates a new StereoscopicUniversalCamera
  45299. * @param name defines camera name
  45300. * @param position defines initial position
  45301. * @param interaxialDistance defines distance between each color axis
  45302. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45303. * @param scene defines the hosting scene
  45304. */
  45305. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45306. /**
  45307. * Gets camera class name
  45308. * @returns StereoscopicUniversalCamera
  45309. */
  45310. getClassName(): string;
  45311. }
  45312. }
  45313. declare module BABYLON {
  45314. /**
  45315. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45316. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45317. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45318. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45319. */
  45320. export class VirtualJoysticksCamera extends FreeCamera {
  45321. /**
  45322. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45323. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45324. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45325. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45326. * @param name Define the name of the camera in the scene
  45327. * @param position Define the start position of the camera in the scene
  45328. * @param scene Define the scene the camera belongs to
  45329. */
  45330. constructor(name: string, position: Vector3, scene: Scene);
  45331. /**
  45332. * Gets the current object class name.
  45333. * @return the class name
  45334. */
  45335. getClassName(): string;
  45336. }
  45337. }
  45338. declare module BABYLON {
  45339. /**
  45340. * This represents all the required metrics to create a VR camera.
  45341. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45342. */
  45343. export class VRCameraMetrics {
  45344. /**
  45345. * Define the horizontal resolution off the screen.
  45346. */
  45347. hResolution: number;
  45348. /**
  45349. * Define the vertical resolution off the screen.
  45350. */
  45351. vResolution: number;
  45352. /**
  45353. * Define the horizontal screen size.
  45354. */
  45355. hScreenSize: number;
  45356. /**
  45357. * Define the vertical screen size.
  45358. */
  45359. vScreenSize: number;
  45360. /**
  45361. * Define the vertical screen center position.
  45362. */
  45363. vScreenCenter: number;
  45364. /**
  45365. * Define the distance of the eyes to the screen.
  45366. */
  45367. eyeToScreenDistance: number;
  45368. /**
  45369. * Define the distance between both lenses
  45370. */
  45371. lensSeparationDistance: number;
  45372. /**
  45373. * Define the distance between both viewer's eyes.
  45374. */
  45375. interpupillaryDistance: number;
  45376. /**
  45377. * Define the distortion factor of the VR postprocess.
  45378. * Please, touch with care.
  45379. */
  45380. distortionK: number[];
  45381. /**
  45382. * Define the chromatic aberration correction factors for the VR post process.
  45383. */
  45384. chromaAbCorrection: number[];
  45385. /**
  45386. * Define the scale factor of the post process.
  45387. * The smaller the better but the slower.
  45388. */
  45389. postProcessScaleFactor: number;
  45390. /**
  45391. * Define an offset for the lens center.
  45392. */
  45393. lensCenterOffset: number;
  45394. /**
  45395. * Define if the current vr camera should compensate the distortion of the lense or not.
  45396. */
  45397. compensateDistortion: boolean;
  45398. /**
  45399. * Defines if multiview should be enabled when rendering (Default: false)
  45400. */
  45401. multiviewEnabled: boolean;
  45402. /**
  45403. * Gets the rendering aspect ratio based on the provided resolutions.
  45404. */
  45405. get aspectRatio(): number;
  45406. /**
  45407. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45408. */
  45409. get aspectRatioFov(): number;
  45410. /**
  45411. * @hidden
  45412. */
  45413. get leftHMatrix(): Matrix;
  45414. /**
  45415. * @hidden
  45416. */
  45417. get rightHMatrix(): Matrix;
  45418. /**
  45419. * @hidden
  45420. */
  45421. get leftPreViewMatrix(): Matrix;
  45422. /**
  45423. * @hidden
  45424. */
  45425. get rightPreViewMatrix(): Matrix;
  45426. /**
  45427. * Get the default VRMetrics based on the most generic setup.
  45428. * @returns the default vr metrics
  45429. */
  45430. static GetDefault(): VRCameraMetrics;
  45431. }
  45432. }
  45433. declare module BABYLON {
  45434. /** @hidden */
  45435. export var vrDistortionCorrectionPixelShader: {
  45436. name: string;
  45437. shader: string;
  45438. };
  45439. }
  45440. declare module BABYLON {
  45441. /**
  45442. * VRDistortionCorrectionPostProcess used for mobile VR
  45443. */
  45444. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45445. private _isRightEye;
  45446. private _distortionFactors;
  45447. private _postProcessScaleFactor;
  45448. private _lensCenterOffset;
  45449. private _scaleIn;
  45450. private _scaleFactor;
  45451. private _lensCenter;
  45452. /**
  45453. * Initializes the VRDistortionCorrectionPostProcess
  45454. * @param name The name of the effect.
  45455. * @param camera The camera to apply the render pass to.
  45456. * @param isRightEye If this is for the right eye distortion
  45457. * @param vrMetrics All the required metrics for the VR camera
  45458. */
  45459. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45460. }
  45461. }
  45462. declare module BABYLON {
  45463. /**
  45464. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45465. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45466. */
  45467. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45468. /**
  45469. * Creates a new VRDeviceOrientationArcRotateCamera
  45470. * @param name defines camera name
  45471. * @param alpha defines the camera rotation along the logitudinal axis
  45472. * @param beta defines the camera rotation along the latitudinal axis
  45473. * @param radius defines the camera distance from its target
  45474. * @param target defines the camera target
  45475. * @param scene defines the scene the camera belongs to
  45476. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45477. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45478. */
  45479. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45480. /**
  45481. * Gets camera class name
  45482. * @returns VRDeviceOrientationArcRotateCamera
  45483. */
  45484. getClassName(): string;
  45485. }
  45486. }
  45487. declare module BABYLON {
  45488. /**
  45489. * Camera used to simulate VR rendering (based on FreeCamera)
  45490. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45491. */
  45492. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45493. /**
  45494. * Creates a new VRDeviceOrientationFreeCamera
  45495. * @param name defines camera name
  45496. * @param position defines the start position of the camera
  45497. * @param scene defines the scene the camera belongs to
  45498. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45499. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45500. */
  45501. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45502. /**
  45503. * Gets camera class name
  45504. * @returns VRDeviceOrientationFreeCamera
  45505. */
  45506. getClassName(): string;
  45507. }
  45508. }
  45509. declare module BABYLON {
  45510. /**
  45511. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45512. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45513. */
  45514. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45515. /**
  45516. * Creates a new VRDeviceOrientationGamepadCamera
  45517. * @param name defines camera name
  45518. * @param position defines the start position of the camera
  45519. * @param scene defines the scene the camera belongs to
  45520. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45521. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45522. */
  45523. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45524. /**
  45525. * Gets camera class name
  45526. * @returns VRDeviceOrientationGamepadCamera
  45527. */
  45528. getClassName(): string;
  45529. }
  45530. }
  45531. declare module BABYLON {
  45532. /**
  45533. * A class extending Texture allowing drawing on a texture
  45534. * @see https://doc.babylonjs.com/how_to/dynamictexture
  45535. */
  45536. export class DynamicTexture extends Texture {
  45537. private _generateMipMaps;
  45538. private _canvas;
  45539. private _context;
  45540. /**
  45541. * Creates a DynamicTexture
  45542. * @param name defines the name of the texture
  45543. * @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
  45544. * @param scene defines the scene where you want the texture
  45545. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45546. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  45547. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  45548. */
  45549. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45550. /**
  45551. * Get the current class name of the texture useful for serialization or dynamic coding.
  45552. * @returns "DynamicTexture"
  45553. */
  45554. getClassName(): string;
  45555. /**
  45556. * Gets the current state of canRescale
  45557. */
  45558. get canRescale(): boolean;
  45559. private _recreate;
  45560. /**
  45561. * Scales the texture
  45562. * @param ratio the scale factor to apply to both width and height
  45563. */
  45564. scale(ratio: number): void;
  45565. /**
  45566. * Resizes the texture
  45567. * @param width the new width
  45568. * @param height the new height
  45569. */
  45570. scaleTo(width: number, height: number): void;
  45571. /**
  45572. * Gets the context of the canvas used by the texture
  45573. * @returns the canvas context of the dynamic texture
  45574. */
  45575. getContext(): CanvasRenderingContext2D;
  45576. /**
  45577. * Clears the texture
  45578. */
  45579. clear(): void;
  45580. /**
  45581. * Updates the texture
  45582. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45583. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45584. */
  45585. update(invertY?: boolean, premulAlpha?: boolean): void;
  45586. /**
  45587. * Draws text onto the texture
  45588. * @param text defines the text to be drawn
  45589. * @param x defines the placement of the text from the left
  45590. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45591. * @param font defines the font to be used with font-style, font-size, font-name
  45592. * @param color defines the color used for the text
  45593. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45594. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45595. * @param update defines whether texture is immediately update (default is true)
  45596. */
  45597. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  45598. /**
  45599. * Clones the texture
  45600. * @returns the clone of the texture.
  45601. */
  45602. clone(): DynamicTexture;
  45603. /**
  45604. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45605. * @returns a serialized dynamic texture object
  45606. */
  45607. serialize(): any;
  45608. private _IsCanvasElement;
  45609. /** @hidden */
  45610. _rebuild(): void;
  45611. }
  45612. }
  45613. declare module BABYLON {
  45614. /** @hidden */
  45615. export var imageProcessingPixelShader: {
  45616. name: string;
  45617. shader: string;
  45618. };
  45619. }
  45620. declare module BABYLON {
  45621. /**
  45622. * ImageProcessingPostProcess
  45623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45624. */
  45625. export class ImageProcessingPostProcess extends PostProcess {
  45626. /**
  45627. * Default configuration related to image processing available in the PBR Material.
  45628. */
  45629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45630. /**
  45631. * Gets the image processing configuration used either in this material.
  45632. */
  45633. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45634. /**
  45635. * Sets the Default image processing configuration used either in the this material.
  45636. *
  45637. * If sets to null, the scene one is in use.
  45638. */
  45639. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45640. /**
  45641. * Keep track of the image processing observer to allow dispose and replace.
  45642. */
  45643. private _imageProcessingObserver;
  45644. /**
  45645. * Attaches a new image processing configuration to the PBR Material.
  45646. * @param configuration
  45647. */
  45648. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45649. /**
  45650. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45651. */
  45652. get colorCurves(): Nullable<ColorCurves>;
  45653. /**
  45654. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45655. */
  45656. set colorCurves(value: Nullable<ColorCurves>);
  45657. /**
  45658. * Gets wether the color curves effect is enabled.
  45659. */
  45660. get colorCurvesEnabled(): boolean;
  45661. /**
  45662. * Sets wether the color curves effect is enabled.
  45663. */
  45664. set colorCurvesEnabled(value: boolean);
  45665. /**
  45666. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45667. */
  45668. get colorGradingTexture(): Nullable<BaseTexture>;
  45669. /**
  45670. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45671. */
  45672. set colorGradingTexture(value: Nullable<BaseTexture>);
  45673. /**
  45674. * Gets wether the color grading effect is enabled.
  45675. */
  45676. get colorGradingEnabled(): boolean;
  45677. /**
  45678. * Gets wether the color grading effect is enabled.
  45679. */
  45680. set colorGradingEnabled(value: boolean);
  45681. /**
  45682. * Gets exposure used in the effect.
  45683. */
  45684. get exposure(): number;
  45685. /**
  45686. * Sets exposure used in the effect.
  45687. */
  45688. set exposure(value: number);
  45689. /**
  45690. * Gets wether tonemapping is enabled or not.
  45691. */
  45692. get toneMappingEnabled(): boolean;
  45693. /**
  45694. * Sets wether tonemapping is enabled or not
  45695. */
  45696. set toneMappingEnabled(value: boolean);
  45697. /**
  45698. * Gets the type of tone mapping effect.
  45699. */
  45700. get toneMappingType(): number;
  45701. /**
  45702. * Sets the type of tone mapping effect.
  45703. */
  45704. set toneMappingType(value: number);
  45705. /**
  45706. * Gets contrast used in the effect.
  45707. */
  45708. get contrast(): number;
  45709. /**
  45710. * Sets contrast used in the effect.
  45711. */
  45712. set contrast(value: number);
  45713. /**
  45714. * Gets Vignette stretch size.
  45715. */
  45716. get vignetteStretch(): number;
  45717. /**
  45718. * Sets Vignette stretch size.
  45719. */
  45720. set vignetteStretch(value: number);
  45721. /**
  45722. * Gets Vignette centre X Offset.
  45723. */
  45724. get vignetteCentreX(): number;
  45725. /**
  45726. * Sets Vignette centre X Offset.
  45727. */
  45728. set vignetteCentreX(value: number);
  45729. /**
  45730. * Gets Vignette centre Y Offset.
  45731. */
  45732. get vignetteCentreY(): number;
  45733. /**
  45734. * Sets Vignette centre Y Offset.
  45735. */
  45736. set vignetteCentreY(value: number);
  45737. /**
  45738. * Gets Vignette weight or intensity of the vignette effect.
  45739. */
  45740. get vignetteWeight(): number;
  45741. /**
  45742. * Sets Vignette weight or intensity of the vignette effect.
  45743. */
  45744. set vignetteWeight(value: number);
  45745. /**
  45746. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45747. * if vignetteEnabled is set to true.
  45748. */
  45749. get vignetteColor(): Color4;
  45750. /**
  45751. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45752. * if vignetteEnabled is set to true.
  45753. */
  45754. set vignetteColor(value: Color4);
  45755. /**
  45756. * Gets Camera field of view used by the Vignette effect.
  45757. */
  45758. get vignetteCameraFov(): number;
  45759. /**
  45760. * Sets Camera field of view used by the Vignette effect.
  45761. */
  45762. set vignetteCameraFov(value: number);
  45763. /**
  45764. * Gets the vignette blend mode allowing different kind of effect.
  45765. */
  45766. get vignetteBlendMode(): number;
  45767. /**
  45768. * Sets the vignette blend mode allowing different kind of effect.
  45769. */
  45770. set vignetteBlendMode(value: number);
  45771. /**
  45772. * Gets wether the vignette effect is enabled.
  45773. */
  45774. get vignetteEnabled(): boolean;
  45775. /**
  45776. * Sets wether the vignette effect is enabled.
  45777. */
  45778. set vignetteEnabled(value: boolean);
  45779. private _fromLinearSpace;
  45780. /**
  45781. * Gets wether the input of the processing is in Gamma or Linear Space.
  45782. */
  45783. get fromLinearSpace(): boolean;
  45784. /**
  45785. * Sets wether the input of the processing is in Gamma or Linear Space.
  45786. */
  45787. set fromLinearSpace(value: boolean);
  45788. /**
  45789. * Defines cache preventing GC.
  45790. */
  45791. private _defines;
  45792. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45793. /**
  45794. * "ImageProcessingPostProcess"
  45795. * @returns "ImageProcessingPostProcess"
  45796. */
  45797. getClassName(): string;
  45798. protected _updateParameters(): void;
  45799. dispose(camera?: Camera): void;
  45800. }
  45801. }
  45802. declare module BABYLON {
  45803. /**
  45804. * Class containing static functions to help procedurally build meshes
  45805. */
  45806. export class GroundBuilder {
  45807. /**
  45808. * Creates a ground mesh
  45809. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45810. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45812. * @param name defines the name of the mesh
  45813. * @param options defines the options used to create the mesh
  45814. * @param scene defines the hosting scene
  45815. * @returns the ground mesh
  45816. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45817. */
  45818. static CreateGround(name: string, options: {
  45819. width?: number;
  45820. height?: number;
  45821. subdivisions?: number;
  45822. subdivisionsX?: number;
  45823. subdivisionsY?: number;
  45824. updatable?: boolean;
  45825. }, scene: any): Mesh;
  45826. /**
  45827. * Creates a tiled ground mesh
  45828. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45829. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45830. * * 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
  45831. * * 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
  45832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45833. * @param name defines the name of the mesh
  45834. * @param options defines the options used to create the mesh
  45835. * @param scene defines the hosting scene
  45836. * @returns the tiled ground mesh
  45837. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45838. */
  45839. static CreateTiledGround(name: string, options: {
  45840. xmin: number;
  45841. zmin: number;
  45842. xmax: number;
  45843. zmax: number;
  45844. subdivisions?: {
  45845. w: number;
  45846. h: number;
  45847. };
  45848. precision?: {
  45849. w: number;
  45850. h: number;
  45851. };
  45852. updatable?: boolean;
  45853. }, scene?: Nullable<Scene>): Mesh;
  45854. /**
  45855. * Creates a ground mesh from a height map
  45856. * * The parameter `url` sets the URL of the height map image resource.
  45857. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45858. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45859. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45860. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45861. * * 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.
  45862. * * 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).
  45863. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45865. * @param name defines the name of the mesh
  45866. * @param url defines the url to the height map
  45867. * @param options defines the options used to create the mesh
  45868. * @param scene defines the hosting scene
  45869. * @returns the ground mesh
  45870. * @see https://doc.babylonjs.com/babylon101/height_map
  45871. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45872. */
  45873. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45874. width?: number;
  45875. height?: number;
  45876. subdivisions?: number;
  45877. minHeight?: number;
  45878. maxHeight?: number;
  45879. colorFilter?: Color3;
  45880. alphaFilter?: number;
  45881. updatable?: boolean;
  45882. onReady?: (mesh: GroundMesh) => void;
  45883. }, scene?: Nullable<Scene>): GroundMesh;
  45884. }
  45885. }
  45886. declare module BABYLON {
  45887. /**
  45888. * Class containing static functions to help procedurally build meshes
  45889. */
  45890. export class TorusBuilder {
  45891. /**
  45892. * Creates a torus mesh
  45893. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45894. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45895. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45897. * * 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
  45898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45899. * @param name defines the name of the mesh
  45900. * @param options defines the options used to create the mesh
  45901. * @param scene defines the hosting scene
  45902. * @returns the torus mesh
  45903. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45904. */
  45905. static CreateTorus(name: string, options: {
  45906. diameter?: number;
  45907. thickness?: number;
  45908. tessellation?: number;
  45909. updatable?: boolean;
  45910. sideOrientation?: number;
  45911. frontUVs?: Vector4;
  45912. backUVs?: Vector4;
  45913. }, scene: any): Mesh;
  45914. }
  45915. }
  45916. declare module BABYLON {
  45917. /**
  45918. * Class containing static functions to help procedurally build meshes
  45919. */
  45920. export class CylinderBuilder {
  45921. /**
  45922. * Creates a cylinder or a cone mesh
  45923. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45924. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45925. * * 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.
  45926. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45927. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45928. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45929. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45930. * * 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).
  45931. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45932. * * 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).
  45933. * * 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
  45934. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45935. * * 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
  45936. * * 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.
  45937. * * If `enclose` is false, a ring surface is one element.
  45938. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45939. * * 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
  45940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45941. * * 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
  45942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45943. * @param name defines the name of the mesh
  45944. * @param options defines the options used to create the mesh
  45945. * @param scene defines the hosting scene
  45946. * @returns the cylinder mesh
  45947. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45948. */
  45949. static CreateCylinder(name: string, options: {
  45950. height?: number;
  45951. diameterTop?: number;
  45952. diameterBottom?: number;
  45953. diameter?: number;
  45954. tessellation?: number;
  45955. subdivisions?: number;
  45956. arc?: number;
  45957. faceColors?: Color4[];
  45958. faceUV?: Vector4[];
  45959. updatable?: boolean;
  45960. hasRings?: boolean;
  45961. enclose?: boolean;
  45962. cap?: number;
  45963. sideOrientation?: number;
  45964. frontUVs?: Vector4;
  45965. backUVs?: Vector4;
  45966. }, scene: any): Mesh;
  45967. }
  45968. }
  45969. declare module BABYLON {
  45970. /**
  45971. * States of the webXR experience
  45972. */
  45973. export enum WebXRState {
  45974. /**
  45975. * Transitioning to being in XR mode
  45976. */
  45977. ENTERING_XR = 0,
  45978. /**
  45979. * Transitioning to non XR mode
  45980. */
  45981. EXITING_XR = 1,
  45982. /**
  45983. * In XR mode and presenting
  45984. */
  45985. IN_XR = 2,
  45986. /**
  45987. * Not entered XR mode
  45988. */
  45989. NOT_IN_XR = 3
  45990. }
  45991. /**
  45992. * Abstraction of the XR render target
  45993. */
  45994. export interface WebXRRenderTarget extends IDisposable {
  45995. /**
  45996. * xrpresent context of the canvas which can be used to display/mirror xr content
  45997. */
  45998. canvasContext: WebGLRenderingContext;
  45999. /**
  46000. * xr layer for the canvas
  46001. */
  46002. xrLayer: Nullable<XRWebGLLayer>;
  46003. /**
  46004. * Initializes the xr layer for the session
  46005. * @param xrSession xr session
  46006. * @returns a promise that will resolve once the XR Layer has been created
  46007. */
  46008. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46009. }
  46010. }
  46011. declare module BABYLON {
  46012. /**
  46013. * COnfiguration object for WebXR output canvas
  46014. */
  46015. export class WebXRManagedOutputCanvasOptions {
  46016. /**
  46017. * An optional canvas in case you wish to create it yourself and provide it here.
  46018. * If not provided, a new canvas will be created
  46019. */
  46020. canvasElement?: HTMLCanvasElement;
  46021. /**
  46022. * Options for this XR Layer output
  46023. */
  46024. canvasOptions?: XRWebGLLayerOptions;
  46025. /**
  46026. * CSS styling for a newly created canvas (if not provided)
  46027. */
  46028. newCanvasCssStyle?: string;
  46029. /**
  46030. * Get the default values of the configuration object
  46031. * @returns default values of this configuration object
  46032. */
  46033. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46034. }
  46035. /**
  46036. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46037. */
  46038. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46039. private _options;
  46040. private _canvas;
  46041. private _engine;
  46042. /**
  46043. * Rendering context of the canvas which can be used to display/mirror xr content
  46044. */
  46045. canvasContext: WebGLRenderingContext;
  46046. /**
  46047. * xr layer for the canvas
  46048. */
  46049. xrLayer: Nullable<XRWebGLLayer>;
  46050. /**
  46051. * Initializes the canvas to be added/removed upon entering/exiting xr
  46052. * @param _xrSessionManager The XR Session manager
  46053. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46054. */
  46055. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46056. /**
  46057. * Disposes of the object
  46058. */
  46059. dispose(): void;
  46060. /**
  46061. * Initializes the xr layer for the session
  46062. * @param xrSession xr session
  46063. * @returns a promise that will resolve once the XR Layer has been created
  46064. */
  46065. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46066. private _addCanvas;
  46067. private _removeCanvas;
  46068. private _setManagedOutputCanvas;
  46069. }
  46070. }
  46071. declare module BABYLON {
  46072. /**
  46073. * Manages an XRSession to work with Babylon's engine
  46074. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46075. */
  46076. export class WebXRSessionManager implements IDisposable {
  46077. /** The scene which the session should be created for */
  46078. scene: Scene;
  46079. private _referenceSpace;
  46080. private _rttProvider;
  46081. private _sessionEnded;
  46082. private _xrNavigator;
  46083. private baseLayer;
  46084. /**
  46085. * The base reference space from which the session started. good if you want to reset your
  46086. * reference space
  46087. */
  46088. baseReferenceSpace: XRReferenceSpace;
  46089. /**
  46090. * Current XR frame
  46091. */
  46092. currentFrame: Nullable<XRFrame>;
  46093. /** WebXR timestamp updated every frame */
  46094. currentTimestamp: number;
  46095. /**
  46096. * Used just in case of a failure to initialize an immersive session.
  46097. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46098. */
  46099. defaultHeightCompensation: number;
  46100. /**
  46101. * Fires every time a new xrFrame arrives which can be used to update the camera
  46102. */
  46103. onXRFrameObservable: Observable<XRFrame>;
  46104. /**
  46105. * Fires when the reference space changed
  46106. */
  46107. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46108. /**
  46109. * Fires when the xr session is ended either by the device or manually done
  46110. */
  46111. onXRSessionEnded: Observable<any>;
  46112. /**
  46113. * Fires when the xr session is ended either by the device or manually done
  46114. */
  46115. onXRSessionInit: Observable<XRSession>;
  46116. /**
  46117. * Underlying xr session
  46118. */
  46119. session: XRSession;
  46120. /**
  46121. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46122. * or get the offset the player is currently at.
  46123. */
  46124. viewerReferenceSpace: XRReferenceSpace;
  46125. /**
  46126. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46127. * @param scene The scene which the session should be created for
  46128. */
  46129. constructor(
  46130. /** The scene which the session should be created for */
  46131. scene: Scene);
  46132. /**
  46133. * The current reference space used in this session. This reference space can constantly change!
  46134. * It is mainly used to offset the camera's position.
  46135. */
  46136. get referenceSpace(): XRReferenceSpace;
  46137. /**
  46138. * Set a new reference space and triggers the observable
  46139. */
  46140. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46141. /**
  46142. * Disposes of the session manager
  46143. */
  46144. dispose(): void;
  46145. /**
  46146. * Stops the xrSession and restores the render loop
  46147. * @returns Promise which resolves after it exits XR
  46148. */
  46149. exitXRAsync(): Promise<void>;
  46150. /**
  46151. * Gets the correct render target texture to be rendered this frame for this eye
  46152. * @param eye the eye for which to get the render target
  46153. * @returns the render target for the specified eye
  46154. */
  46155. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46156. /**
  46157. * Creates a WebXRRenderTarget object for the XR session
  46158. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46159. * @param options optional options to provide when creating a new render target
  46160. * @returns a WebXR render target to which the session can render
  46161. */
  46162. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46163. /**
  46164. * Initializes the manager
  46165. * After initialization enterXR can be called to start an XR session
  46166. * @returns Promise which resolves after it is initialized
  46167. */
  46168. initializeAsync(): Promise<void>;
  46169. /**
  46170. * Initializes an xr session
  46171. * @param xrSessionMode mode to initialize
  46172. * @param xrSessionInit defines optional and required values to pass to the session builder
  46173. * @returns a promise which will resolve once the session has been initialized
  46174. */
  46175. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46176. /**
  46177. * Checks if a session would be supported for the creation options specified
  46178. * @param sessionMode session mode to check if supported eg. immersive-vr
  46179. * @returns A Promise that resolves to true if supported and false if not
  46180. */
  46181. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46182. /**
  46183. * Resets the reference space to the one started the session
  46184. */
  46185. resetReferenceSpace(): void;
  46186. /**
  46187. * Starts rendering to the xr layer
  46188. */
  46189. runXRRenderLoop(): void;
  46190. /**
  46191. * Sets the reference space on the xr session
  46192. * @param referenceSpaceType space to set
  46193. * @returns a promise that will resolve once the reference space has been set
  46194. */
  46195. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46196. /**
  46197. * Updates the render state of the session
  46198. * @param state state to set
  46199. * @returns a promise that resolves once the render state has been updated
  46200. */
  46201. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46202. /**
  46203. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46204. * @param sessionMode defines the session to test
  46205. * @returns a promise with boolean as final value
  46206. */
  46207. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46208. private _createRenderTargetTexture;
  46209. }
  46210. }
  46211. declare module BABYLON {
  46212. /**
  46213. * WebXR Camera which holds the views for the xrSession
  46214. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46215. */
  46216. export class WebXRCamera extends FreeCamera {
  46217. private _xrSessionManager;
  46218. private _firstFrame;
  46219. private _referenceQuaternion;
  46220. private _referencedPosition;
  46221. private _xrInvPositionCache;
  46222. private _xrInvQuaternionCache;
  46223. /**
  46224. * Should position compensation execute on first frame.
  46225. * This is used when copying the position from a native (non XR) camera
  46226. */
  46227. compensateOnFirstFrame: boolean;
  46228. /**
  46229. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46230. * @param name the name of the camera
  46231. * @param scene the scene to add the camera to
  46232. * @param _xrSessionManager a constructed xr session manager
  46233. */
  46234. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46235. /**
  46236. * Return the user's height, unrelated to the current ground.
  46237. * This will be the y position of this camera, when ground level is 0.
  46238. */
  46239. get realWorldHeight(): number;
  46240. /** @hidden */
  46241. _updateForDualEyeDebugging(): void;
  46242. /**
  46243. * Sets this camera's transformation based on a non-vr camera
  46244. * @param otherCamera the non-vr camera to copy the transformation from
  46245. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46246. */
  46247. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46248. /**
  46249. * Gets the current instance class name ("WebXRCamera").
  46250. * @returns the class name
  46251. */
  46252. getClassName(): string;
  46253. /**
  46254. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46255. */
  46256. _getViewMatrix(): Matrix;
  46257. private _updateFromXRSession;
  46258. private _updateNumberOfRigCameras;
  46259. private _updateReferenceSpace;
  46260. private _updateReferenceSpaceOffset;
  46261. }
  46262. }
  46263. declare module BABYLON {
  46264. /**
  46265. * Defining the interface required for a (webxr) feature
  46266. */
  46267. export interface IWebXRFeature extends IDisposable {
  46268. /**
  46269. * Is this feature attached
  46270. */
  46271. attached: boolean;
  46272. /**
  46273. * Should auto-attach be disabled?
  46274. */
  46275. disableAutoAttach: boolean;
  46276. /**
  46277. * Attach the feature to the session
  46278. * Will usually be called by the features manager
  46279. *
  46280. * @param force should attachment be forced (even when already attached)
  46281. * @returns true if successful.
  46282. */
  46283. attach(force?: boolean): boolean;
  46284. /**
  46285. * Detach the feature from the session
  46286. * Will usually be called by the features manager
  46287. *
  46288. * @returns true if successful.
  46289. */
  46290. detach(): boolean;
  46291. }
  46292. /**
  46293. * A list of the currently available features without referencing them
  46294. */
  46295. export class WebXRFeatureName {
  46296. /**
  46297. * The name of the anchor system feature
  46298. */
  46299. static ANCHOR_SYSTEM: string;
  46300. /**
  46301. * The name of the background remover feature
  46302. */
  46303. static BACKGROUND_REMOVER: string;
  46304. /**
  46305. * The name of the hit test feature
  46306. */
  46307. static HIT_TEST: string;
  46308. /**
  46309. * physics impostors for xr controllers feature
  46310. */
  46311. static PHYSICS_CONTROLLERS: string;
  46312. /**
  46313. * The name of the plane detection feature
  46314. */
  46315. static PLANE_DETECTION: string;
  46316. /**
  46317. * The name of the pointer selection feature
  46318. */
  46319. static POINTER_SELECTION: string;
  46320. /**
  46321. * The name of the teleportation feature
  46322. */
  46323. static TELEPORTATION: string;
  46324. }
  46325. /**
  46326. * Defining the constructor of a feature. Used to register the modules.
  46327. */
  46328. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46329. /**
  46330. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46331. * It is mainly used in AR sessions.
  46332. *
  46333. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46334. */
  46335. export class WebXRFeaturesManager implements IDisposable {
  46336. private _xrSessionManager;
  46337. private static readonly _AvailableFeatures;
  46338. private _features;
  46339. /**
  46340. * constructs a new features manages.
  46341. *
  46342. * @param _xrSessionManager an instance of WebXRSessionManager
  46343. */
  46344. constructor(_xrSessionManager: WebXRSessionManager);
  46345. /**
  46346. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46347. * Mainly used internally.
  46348. *
  46349. * @param featureName the name of the feature to register
  46350. * @param constructorFunction the function used to construct the module
  46351. * @param version the (babylon) version of the module
  46352. * @param stable is that a stable version of this module
  46353. */
  46354. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46355. /**
  46356. * Returns a constructor of a specific feature.
  46357. *
  46358. * @param featureName the name of the feature to construct
  46359. * @param version the version of the feature to load
  46360. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46361. * @param options optional options provided to the module.
  46362. * @returns a function that, when called, will return a new instance of this feature
  46363. */
  46364. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46365. /**
  46366. * Can be used to return the list of features currently registered
  46367. *
  46368. * @returns an Array of available features
  46369. */
  46370. static GetAvailableFeatures(): string[];
  46371. /**
  46372. * Gets the versions available for a specific feature
  46373. * @param featureName the name of the feature
  46374. * @returns an array with the available versions
  46375. */
  46376. static GetAvailableVersions(featureName: string): string[];
  46377. /**
  46378. * Return the latest unstable version of this feature
  46379. * @param featureName the name of the feature to search
  46380. * @returns the version number. if not found will return -1
  46381. */
  46382. static GetLatestVersionOfFeature(featureName: string): number;
  46383. /**
  46384. * Return the latest stable 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 GetStableVersionOfFeature(featureName: string): number;
  46389. /**
  46390. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46391. * Can be used during a session to start a feature
  46392. * @param featureName the name of feature to attach
  46393. */
  46394. attachFeature(featureName: string): void;
  46395. /**
  46396. * Can be used inside a session or when the session ends to detach a specific feature
  46397. * @param featureName the name of the feature to detach
  46398. */
  46399. detachFeature(featureName: string): void;
  46400. /**
  46401. * Used to disable an already-enabled feature
  46402. * The feature will be disposed and will be recreated once enabled.
  46403. * @param featureName the feature to disable
  46404. * @returns true if disable was successful
  46405. */
  46406. disableFeature(featureName: string | {
  46407. Name: string;
  46408. }): boolean;
  46409. /**
  46410. * dispose this features manager
  46411. */
  46412. dispose(): void;
  46413. /**
  46414. * 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.
  46415. * 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.
  46416. *
  46417. * @param featureName the name of the feature to load or the class of the feature
  46418. * @param version optional version to load. if not provided the latest version will be enabled
  46419. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46420. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46421. * @returns a new constructed feature or throws an error if feature not found.
  46422. */
  46423. enableFeature(featureName: string | {
  46424. Name: string;
  46425. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46426. /**
  46427. * get the implementation of an enabled feature.
  46428. * @param featureName the name of the feature to load
  46429. * @returns the feature class, if found
  46430. */
  46431. getEnabledFeature(featureName: string): IWebXRFeature;
  46432. /**
  46433. * Get the list of enabled features
  46434. * @returns an array of enabled features
  46435. */
  46436. getEnabledFeatures(): string[];
  46437. }
  46438. }
  46439. declare module BABYLON {
  46440. /**
  46441. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46442. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  46443. */
  46444. export class WebXRExperienceHelper implements IDisposable {
  46445. private scene;
  46446. private _nonVRCamera;
  46447. private _originalSceneAutoClear;
  46448. private _supported;
  46449. /**
  46450. * Camera used to render xr content
  46451. */
  46452. camera: WebXRCamera;
  46453. /** A features manager for this xr session */
  46454. featuresManager: WebXRFeaturesManager;
  46455. /**
  46456. * Observers registered here will be triggered after the camera's initial transformation is set
  46457. * This can be used to set a different ground level or an extra rotation.
  46458. *
  46459. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46460. * to the position set after this observable is done executing.
  46461. */
  46462. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46463. /**
  46464. * Fires when the state of the experience helper has changed
  46465. */
  46466. onStateChangedObservable: Observable<WebXRState>;
  46467. /** Session manager used to keep track of xr session */
  46468. sessionManager: WebXRSessionManager;
  46469. /**
  46470. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46471. */
  46472. state: WebXRState;
  46473. /**
  46474. * Creates a WebXRExperienceHelper
  46475. * @param scene The scene the helper should be created in
  46476. */
  46477. private constructor();
  46478. /**
  46479. * Creates the experience helper
  46480. * @param scene the scene to attach the experience helper to
  46481. * @returns a promise for the experience helper
  46482. */
  46483. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46484. /**
  46485. * Disposes of the experience helper
  46486. */
  46487. dispose(): void;
  46488. /**
  46489. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46490. * @param sessionMode options for the XR session
  46491. * @param referenceSpaceType frame of reference of the XR session
  46492. * @param renderTarget the output canvas that will be used to enter XR mode
  46493. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46494. * @returns promise that resolves after xr mode has entered
  46495. */
  46496. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46497. /**
  46498. * Exits XR mode and returns the scene to its original state
  46499. * @returns promise that resolves after xr mode has exited
  46500. */
  46501. exitXRAsync(): Promise<void>;
  46502. private _nonXRToXRCamera;
  46503. private _setState;
  46504. }
  46505. }
  46506. declare module BABYLON {
  46507. /**
  46508. * X-Y values for axes in WebXR
  46509. */
  46510. export interface IWebXRMotionControllerAxesValue {
  46511. /**
  46512. * The value of the x axis
  46513. */
  46514. x: number;
  46515. /**
  46516. * The value of the y-axis
  46517. */
  46518. y: number;
  46519. }
  46520. /**
  46521. * changed / previous values for the values of this component
  46522. */
  46523. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46524. /**
  46525. * current (this frame) value
  46526. */
  46527. current: T;
  46528. /**
  46529. * previous (last change) value
  46530. */
  46531. previous: T;
  46532. }
  46533. /**
  46534. * Represents changes in the component between current frame and last values recorded
  46535. */
  46536. export interface IWebXRMotionControllerComponentChanges {
  46537. /**
  46538. * will be populated with previous and current values if axes changed
  46539. */
  46540. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46541. /**
  46542. * will be populated with previous and current values if pressed changed
  46543. */
  46544. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46545. /**
  46546. * will be populated with previous and current values if touched changed
  46547. */
  46548. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46549. /**
  46550. * will be populated with previous and current values if value changed
  46551. */
  46552. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46553. }
  46554. /**
  46555. * This class represents a single component (for example button or thumbstick) of a motion controller
  46556. */
  46557. export class WebXRControllerComponent implements IDisposable {
  46558. /**
  46559. * the id of this component
  46560. */
  46561. id: string;
  46562. /**
  46563. * the type of the component
  46564. */
  46565. type: MotionControllerComponentType;
  46566. private _buttonIndex;
  46567. private _axesIndices;
  46568. private _axes;
  46569. private _changes;
  46570. private _currentValue;
  46571. private _hasChanges;
  46572. private _pressed;
  46573. private _touched;
  46574. /**
  46575. * button component type
  46576. */
  46577. static BUTTON_TYPE: MotionControllerComponentType;
  46578. /**
  46579. * squeeze component type
  46580. */
  46581. static SQUEEZE_TYPE: MotionControllerComponentType;
  46582. /**
  46583. * Thumbstick component type
  46584. */
  46585. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46586. /**
  46587. * Touchpad component type
  46588. */
  46589. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46590. /**
  46591. * trigger component type
  46592. */
  46593. static TRIGGER_TYPE: MotionControllerComponentType;
  46594. /**
  46595. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46596. * the axes data changes
  46597. */
  46598. onAxisValueChangedObservable: Observable<{
  46599. x: number;
  46600. y: number;
  46601. }>;
  46602. /**
  46603. * Observers registered here will be triggered when the state of a button changes
  46604. * State change is either pressed / touched / value
  46605. */
  46606. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46607. /**
  46608. * Creates a new component for a motion controller.
  46609. * It is created by the motion controller itself
  46610. *
  46611. * @param id the id of this component
  46612. * @param type the type of the component
  46613. * @param _buttonIndex index in the buttons array of the gamepad
  46614. * @param _axesIndices indices of the values in the axes array of the gamepad
  46615. */
  46616. constructor(
  46617. /**
  46618. * the id of this component
  46619. */
  46620. id: string,
  46621. /**
  46622. * the type of the component
  46623. */
  46624. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46625. /**
  46626. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46627. */
  46628. get axes(): IWebXRMotionControllerAxesValue;
  46629. /**
  46630. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46631. */
  46632. get changes(): IWebXRMotionControllerComponentChanges;
  46633. /**
  46634. * Return whether or not the component changed the last frame
  46635. */
  46636. get hasChanges(): boolean;
  46637. /**
  46638. * is the button currently pressed
  46639. */
  46640. get pressed(): boolean;
  46641. /**
  46642. * is the button currently touched
  46643. */
  46644. get touched(): boolean;
  46645. /**
  46646. * Get the current value of this component
  46647. */
  46648. get value(): number;
  46649. /**
  46650. * Dispose this component
  46651. */
  46652. dispose(): void;
  46653. /**
  46654. * Are there axes correlating to this component
  46655. * @return true is axes data is available
  46656. */
  46657. isAxes(): boolean;
  46658. /**
  46659. * Is this component a button (hence - pressable)
  46660. * @returns true if can be pressed
  46661. */
  46662. isButton(): boolean;
  46663. /**
  46664. * update this component using the gamepad object it is in. Called on every frame
  46665. * @param nativeController the native gamepad controller object
  46666. */
  46667. update(nativeController: IMinimalMotionControllerObject): void;
  46668. }
  46669. }
  46670. declare module BABYLON {
  46671. /**
  46672. * Interface used to represent data loading progression
  46673. */
  46674. export interface ISceneLoaderProgressEvent {
  46675. /**
  46676. * Defines if data length to load can be evaluated
  46677. */
  46678. readonly lengthComputable: boolean;
  46679. /**
  46680. * Defines the loaded data length
  46681. */
  46682. readonly loaded: number;
  46683. /**
  46684. * Defines the data length to load
  46685. */
  46686. readonly total: number;
  46687. }
  46688. /**
  46689. * Interface used by SceneLoader plugins to define supported file extensions
  46690. */
  46691. export interface ISceneLoaderPluginExtensions {
  46692. /**
  46693. * Defines the list of supported extensions
  46694. */
  46695. [extension: string]: {
  46696. isBinary: boolean;
  46697. };
  46698. }
  46699. /**
  46700. * Interface used by SceneLoader plugin factory
  46701. */
  46702. export interface ISceneLoaderPluginFactory {
  46703. /**
  46704. * Defines the name of the factory
  46705. */
  46706. name: string;
  46707. /**
  46708. * Function called to create a new plugin
  46709. * @return the new plugin
  46710. */
  46711. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46712. /**
  46713. * The callback that returns true if the data can be directly loaded.
  46714. * @param data string containing the file data
  46715. * @returns if the data can be loaded directly
  46716. */
  46717. canDirectLoad?(data: string): boolean;
  46718. }
  46719. /**
  46720. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46721. */
  46722. export interface ISceneLoaderPluginBase {
  46723. /**
  46724. * The friendly name of this plugin.
  46725. */
  46726. name: string;
  46727. /**
  46728. * The file extensions supported by this plugin.
  46729. */
  46730. extensions: string | ISceneLoaderPluginExtensions;
  46731. /**
  46732. * The callback called when loading from a url.
  46733. * @param scene scene loading this url
  46734. * @param url url to load
  46735. * @param onSuccess callback called when the file successfully loads
  46736. * @param onProgress callback called while file is loading (if the server supports this mode)
  46737. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46738. * @param onError callback called when the file fails to load
  46739. * @returns a file request object
  46740. */
  46741. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46742. /**
  46743. * The callback called when loading from a file object.
  46744. * @param scene scene loading this file
  46745. * @param file defines the file to load
  46746. * @param onSuccess defines the callback to call when data is loaded
  46747. * @param onProgress defines the callback to call during loading process
  46748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46749. * @param onError defines the callback to call when an error occurs
  46750. * @returns a file request object
  46751. */
  46752. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46753. /**
  46754. * The callback that returns true if the data can be directly loaded.
  46755. * @param data string containing the file data
  46756. * @returns if the data can be loaded directly
  46757. */
  46758. canDirectLoad?(data: string): boolean;
  46759. /**
  46760. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46761. * @param scene scene loading this data
  46762. * @param data string containing the data
  46763. * @returns data to pass to the plugin
  46764. */
  46765. directLoad?(scene: Scene, data: string): any;
  46766. /**
  46767. * The callback that allows custom handling of the root url based on the response url.
  46768. * @param rootUrl the original root url
  46769. * @param responseURL the response url if available
  46770. * @returns the new root url
  46771. */
  46772. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46773. }
  46774. /**
  46775. * Interface used to define a SceneLoader plugin
  46776. */
  46777. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46778. /**
  46779. * Import meshes into a scene.
  46780. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46781. * @param scene The scene to import into
  46782. * @param data The data to import
  46783. * @param rootUrl The root url for scene and resources
  46784. * @param meshes The meshes array to import into
  46785. * @param particleSystems The particle systems array to import into
  46786. * @param skeletons The skeletons array to import into
  46787. * @param onError The callback when import fails
  46788. * @returns True if successful or false otherwise
  46789. */
  46790. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46791. /**
  46792. * Load into a scene.
  46793. * @param scene The scene to load into
  46794. * @param data The data to import
  46795. * @param rootUrl The root url for scene and resources
  46796. * @param onError The callback when import fails
  46797. * @returns True if successful or false otherwise
  46798. */
  46799. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46800. /**
  46801. * Load into an asset container.
  46802. * @param scene The scene to load into
  46803. * @param data The data to import
  46804. * @param rootUrl The root url for scene and resources
  46805. * @param onError The callback when import fails
  46806. * @returns The loaded asset container
  46807. */
  46808. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46809. }
  46810. /**
  46811. * Interface used to define an async SceneLoader plugin
  46812. */
  46813. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46814. /**
  46815. * Import meshes into a scene.
  46816. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46817. * @param scene The scene to import into
  46818. * @param data The data to import
  46819. * @param rootUrl The root url for scene and resources
  46820. * @param onProgress The callback when the load progresses
  46821. * @param fileName Defines the name of the file to load
  46822. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46823. */
  46824. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46825. meshes: AbstractMesh[];
  46826. particleSystems: IParticleSystem[];
  46827. skeletons: Skeleton[];
  46828. animationGroups: AnimationGroup[];
  46829. }>;
  46830. /**
  46831. * Load into a scene.
  46832. * @param scene The scene to load into
  46833. * @param data The data to import
  46834. * @param rootUrl The root url for scene and resources
  46835. * @param onProgress The callback when the load progresses
  46836. * @param fileName Defines the name of the file to load
  46837. * @returns Nothing
  46838. */
  46839. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46840. /**
  46841. * Load into an asset container.
  46842. * @param scene The scene to load into
  46843. * @param data The data to import
  46844. * @param rootUrl The root url for scene and resources
  46845. * @param onProgress The callback when the load progresses
  46846. * @param fileName Defines the name of the file to load
  46847. * @returns The loaded asset container
  46848. */
  46849. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46850. }
  46851. /**
  46852. * Mode that determines how to handle old animation groups before loading new ones.
  46853. */
  46854. export enum SceneLoaderAnimationGroupLoadingMode {
  46855. /**
  46856. * Reset all old animations to initial state then dispose them.
  46857. */
  46858. Clean = 0,
  46859. /**
  46860. * Stop all old animations.
  46861. */
  46862. Stop = 1,
  46863. /**
  46864. * Restart old animations from first frame.
  46865. */
  46866. Sync = 2,
  46867. /**
  46868. * Old animations remains untouched.
  46869. */
  46870. NoSync = 3
  46871. }
  46872. /**
  46873. * Class used to load scene from various file formats using registered plugins
  46874. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  46875. */
  46876. export class SceneLoader {
  46877. /**
  46878. * No logging while loading
  46879. */
  46880. static readonly NO_LOGGING: number;
  46881. /**
  46882. * Minimal logging while loading
  46883. */
  46884. static readonly MINIMAL_LOGGING: number;
  46885. /**
  46886. * Summary logging while loading
  46887. */
  46888. static readonly SUMMARY_LOGGING: number;
  46889. /**
  46890. * Detailled logging while loading
  46891. */
  46892. static readonly DETAILED_LOGGING: number;
  46893. /**
  46894. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46895. */
  46896. static get ForceFullSceneLoadingForIncremental(): boolean;
  46897. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46898. /**
  46899. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46900. */
  46901. static get ShowLoadingScreen(): boolean;
  46902. static set ShowLoadingScreen(value: boolean);
  46903. /**
  46904. * Defines the current logging level (while loading the scene)
  46905. * @ignorenaming
  46906. */
  46907. static get loggingLevel(): number;
  46908. static set loggingLevel(value: number);
  46909. /**
  46910. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46911. */
  46912. static get CleanBoneMatrixWeights(): boolean;
  46913. static set CleanBoneMatrixWeights(value: boolean);
  46914. /**
  46915. * Event raised when a plugin is used to load a scene
  46916. */
  46917. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46918. private static _registeredPlugins;
  46919. private static _getDefaultPlugin;
  46920. private static _getPluginForExtension;
  46921. private static _getPluginForDirectLoad;
  46922. private static _getPluginForFilename;
  46923. private static _getDirectLoad;
  46924. private static _loadData;
  46925. private static _getFileInfo;
  46926. /**
  46927. * Gets a plugin that can load the given extension
  46928. * @param extension defines the extension to load
  46929. * @returns a plugin or null if none works
  46930. */
  46931. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46932. /**
  46933. * Gets a boolean indicating that the given extension can be loaded
  46934. * @param extension defines the extension to load
  46935. * @returns true if the extension is supported
  46936. */
  46937. static IsPluginForExtensionAvailable(extension: string): boolean;
  46938. /**
  46939. * Adds a new plugin to the list of registered plugins
  46940. * @param plugin defines the plugin to add
  46941. */
  46942. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46943. /**
  46944. * Import meshes into a scene
  46945. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46946. * @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)
  46947. * @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)
  46948. * @param scene the instance of BABYLON.Scene to append to
  46949. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46950. * @param onProgress a callback with a progress event for each file being loaded
  46951. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46952. * @param pluginExtension the extension used to determine the plugin
  46953. * @returns The loaded plugin
  46954. */
  46955. 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>;
  46956. /**
  46957. * Import meshes into a scene
  46958. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46959. * @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)
  46960. * @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)
  46961. * @param scene the instance of BABYLON.Scene to append to
  46962. * @param onProgress a callback with a progress event for each file being loaded
  46963. * @param pluginExtension the extension used to determine the plugin
  46964. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46965. */
  46966. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46967. meshes: AbstractMesh[];
  46968. particleSystems: IParticleSystem[];
  46969. skeletons: Skeleton[];
  46970. animationGroups: AnimationGroup[];
  46971. }>;
  46972. /**
  46973. * Load a scene
  46974. * @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)
  46975. * @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)
  46976. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46977. * @param onSuccess a callback with the scene when import succeeds
  46978. * @param onProgress a callback with a progress event for each file being loaded
  46979. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46980. * @param pluginExtension the extension used to determine the plugin
  46981. * @returns The loaded plugin
  46982. */
  46983. 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>;
  46984. /**
  46985. * Load a scene
  46986. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  46987. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  46988. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46989. * @param onProgress a callback with a progress event for each file being loaded
  46990. * @param pluginExtension the extension used to determine the plugin
  46991. * @returns The loaded scene
  46992. */
  46993. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46994. /**
  46995. * Append a scene
  46996. * @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)
  46997. * @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)
  46998. * @param scene is the instance of BABYLON.Scene to append to
  46999. * @param onSuccess a callback with the scene when import succeeds
  47000. * @param onProgress a callback with a progress event for each file being loaded
  47001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47002. * @param pluginExtension the extension used to determine the plugin
  47003. * @returns The loaded plugin
  47004. */
  47005. 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>;
  47006. /**
  47007. * Append a scene
  47008. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47009. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  47010. * @param scene is the instance of BABYLON.Scene to append to
  47011. * @param onProgress a callback with a progress event for each file being loaded
  47012. * @param pluginExtension the extension used to determine the plugin
  47013. * @returns The given scene
  47014. */
  47015. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47016. /**
  47017. * Load a scene into an asset container
  47018. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47019. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  47020. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47021. * @param onSuccess a callback with the scene when import succeeds
  47022. * @param onProgress a callback with a progress event for each file being loaded
  47023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47024. * @param pluginExtension the extension used to determine the plugin
  47025. * @returns The loaded plugin
  47026. */
  47027. static 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>;
  47028. /**
  47029. * Load a scene into an asset container
  47030. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47031. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  47032. * @param scene is the instance of Scene to append to
  47033. * @param onProgress a callback with a progress event for each file being loaded
  47034. * @param pluginExtension the extension used to determine the plugin
  47035. * @returns The loaded asset container
  47036. */
  47037. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47038. /**
  47039. * Import animations from a file into a scene
  47040. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47041. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  47042. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47043. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47044. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47045. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47046. * @param onSuccess a callback with the scene when import succeeds
  47047. * @param onProgress a callback with a progress event for each file being loaded
  47048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47049. * @param pluginExtension the extension used to determine the plugin
  47050. */
  47051. 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;
  47052. /**
  47053. * Import animations from a file into a scene
  47054. * @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)
  47055. * @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)
  47056. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47057. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47058. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47059. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47060. * @param onSuccess a callback with the scene when import succeeds
  47061. * @param onProgress a callback with a progress event for each file being loaded
  47062. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47063. * @param pluginExtension the extension used to determine the plugin
  47064. * @returns the updated scene with imported animations
  47065. */
  47066. 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>;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47072. */
  47073. export type MotionControllerHandedness = "none" | "left" | "right";
  47074. /**
  47075. * The type of components available in motion controllers.
  47076. * This is not the name of the component.
  47077. */
  47078. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47079. /**
  47080. * The state of a controller component
  47081. */
  47082. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47083. /**
  47084. * The schema of motion controller layout.
  47085. * No object will be initialized using this interface
  47086. * This is used just to define the profile.
  47087. */
  47088. export interface IMotionControllerLayout {
  47089. /**
  47090. * Path to load the assets. Usually relative to the base path
  47091. */
  47092. assetPath: string;
  47093. /**
  47094. * Available components (unsorted)
  47095. */
  47096. components: {
  47097. /**
  47098. * A map of component Ids
  47099. */
  47100. [componentId: string]: {
  47101. /**
  47102. * The type of input the component outputs
  47103. */
  47104. type: MotionControllerComponentType;
  47105. /**
  47106. * The indices of this component in the gamepad object
  47107. */
  47108. gamepadIndices: {
  47109. /**
  47110. * Index of button
  47111. */
  47112. button?: number;
  47113. /**
  47114. * If available, index of x-axis
  47115. */
  47116. xAxis?: number;
  47117. /**
  47118. * If available, index of y-axis
  47119. */
  47120. yAxis?: number;
  47121. };
  47122. /**
  47123. * The mesh's root node name
  47124. */
  47125. rootNodeName: string;
  47126. /**
  47127. * Animation definitions for this model
  47128. */
  47129. visualResponses: {
  47130. [stateKey: string]: {
  47131. /**
  47132. * What property will be animated
  47133. */
  47134. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47135. /**
  47136. * What states influence this visual response
  47137. */
  47138. states: MotionControllerComponentStateType[];
  47139. /**
  47140. * Type of animation - movement or visibility
  47141. */
  47142. valueNodeProperty: "transform" | "visibility";
  47143. /**
  47144. * Base node name to move. Its position will be calculated according to the min and max nodes
  47145. */
  47146. valueNodeName?: string;
  47147. /**
  47148. * Minimum movement node
  47149. */
  47150. minNodeName?: string;
  47151. /**
  47152. * Max movement node
  47153. */
  47154. maxNodeName?: string;
  47155. };
  47156. };
  47157. /**
  47158. * If touch enabled, what is the name of node to display user feedback
  47159. */
  47160. touchPointNodeName?: string;
  47161. };
  47162. };
  47163. /**
  47164. * Is it xr standard mapping or not
  47165. */
  47166. gamepadMapping: "" | "xr-standard";
  47167. /**
  47168. * Base root node of this entire model
  47169. */
  47170. rootNodeName: string;
  47171. /**
  47172. * Defines the main button component id
  47173. */
  47174. selectComponentId: string;
  47175. }
  47176. /**
  47177. * A definition for the layout map in the input profile
  47178. */
  47179. export interface IMotionControllerLayoutMap {
  47180. /**
  47181. * Layouts with handedness type as a key
  47182. */
  47183. [handedness: string]: IMotionControllerLayout;
  47184. }
  47185. /**
  47186. * The XR Input profile schema
  47187. * Profiles can be found here:
  47188. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47189. */
  47190. export interface IMotionControllerProfile {
  47191. /**
  47192. * fallback profiles for this profileId
  47193. */
  47194. fallbackProfileIds: string[];
  47195. /**
  47196. * The layout map, with handedness as key
  47197. */
  47198. layouts: IMotionControllerLayoutMap;
  47199. /**
  47200. * The id of this profile
  47201. * correlates to the profile(s) in the xrInput.profiles array
  47202. */
  47203. profileId: string;
  47204. }
  47205. /**
  47206. * A helper-interface for the 3 meshes needed for controller button animation
  47207. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47208. */
  47209. export interface IMotionControllerButtonMeshMap {
  47210. /**
  47211. * the mesh that defines the pressed value mesh position.
  47212. * This is used to find the max-position of this button
  47213. */
  47214. pressedMesh: AbstractMesh;
  47215. /**
  47216. * the mesh that defines the unpressed value mesh position.
  47217. * This is used to find the min (or initial) position of this button
  47218. */
  47219. unpressedMesh: AbstractMesh;
  47220. /**
  47221. * The mesh that will be changed when value changes
  47222. */
  47223. valueMesh: AbstractMesh;
  47224. }
  47225. /**
  47226. * A helper-interface for the 3 meshes needed for controller axis animation.
  47227. * This will be expanded when touchpad animations are fully supported
  47228. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47229. */
  47230. export interface IMotionControllerMeshMap {
  47231. /**
  47232. * the mesh that defines the maximum value mesh position.
  47233. */
  47234. maxMesh?: AbstractMesh;
  47235. /**
  47236. * the mesh that defines the minimum value mesh position.
  47237. */
  47238. minMesh?: AbstractMesh;
  47239. /**
  47240. * The mesh that will be changed when axis value changes
  47241. */
  47242. valueMesh: AbstractMesh;
  47243. }
  47244. /**
  47245. * The elements needed for change-detection of the gamepad objects in motion controllers
  47246. */
  47247. export interface IMinimalMotionControllerObject {
  47248. /**
  47249. * Available axes of this controller
  47250. */
  47251. axes: number[];
  47252. /**
  47253. * An array of available buttons
  47254. */
  47255. buttons: Array<{
  47256. /**
  47257. * Value of the button/trigger
  47258. */
  47259. value: number;
  47260. /**
  47261. * If the button/trigger is currently touched
  47262. */
  47263. touched: boolean;
  47264. /**
  47265. * If the button/trigger is currently pressed
  47266. */
  47267. pressed: boolean;
  47268. }>;
  47269. /**
  47270. * EXPERIMENTAL haptic support.
  47271. */
  47272. hapticActuators?: Array<{
  47273. pulse: (value: number, duration: number) => Promise<boolean>;
  47274. }>;
  47275. }
  47276. /**
  47277. * An Abstract Motion controller
  47278. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47279. * Each component has an observable to check for changes in value and state
  47280. */
  47281. export abstract class WebXRAbstractMotionController implements IDisposable {
  47282. protected scene: Scene;
  47283. protected layout: IMotionControllerLayout;
  47284. /**
  47285. * The gamepad object correlating to this controller
  47286. */
  47287. gamepadObject: IMinimalMotionControllerObject;
  47288. /**
  47289. * handedness (left/right/none) of this controller
  47290. */
  47291. handedness: MotionControllerHandedness;
  47292. private _initComponent;
  47293. private _modelReady;
  47294. /**
  47295. * A map of components (WebXRControllerComponent) in this motion controller
  47296. * Components have a ComponentType and can also have both button and axis definitions
  47297. */
  47298. readonly components: {
  47299. [id: string]: WebXRControllerComponent;
  47300. };
  47301. /**
  47302. * Disable the model's animation. Can be set at any time.
  47303. */
  47304. disableAnimation: boolean;
  47305. /**
  47306. * Observers registered here will be triggered when the model of this controller is done loading
  47307. */
  47308. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47309. /**
  47310. * The profile id of this motion controller
  47311. */
  47312. abstract profileId: string;
  47313. /**
  47314. * The root mesh of the model. It is null if the model was not yet initialized
  47315. */
  47316. rootMesh: Nullable<AbstractMesh>;
  47317. /**
  47318. * constructs a new abstract motion controller
  47319. * @param scene the scene to which the model of the controller will be added
  47320. * @param layout The profile layout to load
  47321. * @param gamepadObject The gamepad object correlating to this controller
  47322. * @param handedness handedness (left/right/none) of this controller
  47323. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47324. */
  47325. constructor(scene: Scene, layout: IMotionControllerLayout,
  47326. /**
  47327. * The gamepad object correlating to this controller
  47328. */
  47329. gamepadObject: IMinimalMotionControllerObject,
  47330. /**
  47331. * handedness (left/right/none) of this controller
  47332. */
  47333. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47334. /**
  47335. * Dispose this controller, the model mesh and all its components
  47336. */
  47337. dispose(): void;
  47338. /**
  47339. * Returns all components of specific type
  47340. * @param type the type to search for
  47341. * @return an array of components with this type
  47342. */
  47343. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47344. /**
  47345. * get a component based an its component id as defined in layout.components
  47346. * @param id the id of the component
  47347. * @returns the component correlates to the id or undefined if not found
  47348. */
  47349. getComponent(id: string): WebXRControllerComponent;
  47350. /**
  47351. * Get the list of components available in this motion controller
  47352. * @returns an array of strings correlating to available components
  47353. */
  47354. getComponentIds(): string[];
  47355. /**
  47356. * Get the first component of specific type
  47357. * @param type type of component to find
  47358. * @return a controller component or null if not found
  47359. */
  47360. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47361. /**
  47362. * Get the main (Select) component of this controller as defined in the layout
  47363. * @returns the main component of this controller
  47364. */
  47365. getMainComponent(): WebXRControllerComponent;
  47366. /**
  47367. * Loads the model correlating to this controller
  47368. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47369. * @returns A promise fulfilled with the result of the model loading
  47370. */
  47371. loadModel(): Promise<boolean>;
  47372. /**
  47373. * Update this model using the current XRFrame
  47374. * @param xrFrame the current xr frame to use and update the model
  47375. */
  47376. updateFromXRFrame(xrFrame: XRFrame): void;
  47377. /**
  47378. * Backwards compatibility due to a deeply-integrated typo
  47379. */
  47380. get handness(): XREye;
  47381. /**
  47382. * Pulse (vibrate) this controller
  47383. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47384. * Consecutive calls to this function will cancel the last pulse call
  47385. *
  47386. * @param value the strength of the pulse in 0.0...1.0 range
  47387. * @param duration Duration of the pulse in milliseconds
  47388. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47389. * @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
  47390. */
  47391. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47392. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47393. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47394. /**
  47395. * Moves the axis on the controller mesh based on its current state
  47396. * @param axis the index of the axis
  47397. * @param axisValue the value of the axis which determines the meshes new position
  47398. * @hidden
  47399. */
  47400. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47401. /**
  47402. * Update the model itself with the current frame data
  47403. * @param xrFrame the frame to use for updating the model mesh
  47404. */
  47405. protected updateModel(xrFrame: XRFrame): void;
  47406. /**
  47407. * Get the filename and path for this controller's model
  47408. * @returns a map of filename and path
  47409. */
  47410. protected abstract _getFilenameAndPath(): {
  47411. filename: string;
  47412. path: string;
  47413. };
  47414. /**
  47415. * This function is called before the mesh is loaded. It checks for loading constraints.
  47416. * For example, this function can check if the GLB loader is available
  47417. * If this function returns false, the generic controller will be loaded instead
  47418. * @returns Is the client ready to load the mesh
  47419. */
  47420. protected abstract _getModelLoadingConstraints(): boolean;
  47421. /**
  47422. * This function will be called after the model was successfully loaded and can be used
  47423. * for mesh transformations before it is available for the user
  47424. * @param meshes the loaded meshes
  47425. */
  47426. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47427. /**
  47428. * Set the root mesh for this controller. Important for the WebXR controller class
  47429. * @param meshes the loaded meshes
  47430. */
  47431. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47432. /**
  47433. * A function executed each frame that updates the mesh (if needed)
  47434. * @param xrFrame the current xrFrame
  47435. */
  47436. protected abstract _updateModel(xrFrame: XRFrame): void;
  47437. private _getGenericFilenameAndPath;
  47438. private _getGenericParentMesh;
  47439. }
  47440. }
  47441. declare module BABYLON {
  47442. /**
  47443. * A generic trigger-only motion controller for WebXR
  47444. */
  47445. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47446. /**
  47447. * Static version of the profile id of this controller
  47448. */
  47449. static ProfileId: string;
  47450. profileId: string;
  47451. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47452. protected _getFilenameAndPath(): {
  47453. filename: string;
  47454. path: string;
  47455. };
  47456. protected _getModelLoadingConstraints(): boolean;
  47457. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47458. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47459. protected _updateModel(): void;
  47460. }
  47461. }
  47462. declare module BABYLON {
  47463. /**
  47464. * Class containing static functions to help procedurally build meshes
  47465. */
  47466. export class SphereBuilder {
  47467. /**
  47468. * Creates a sphere mesh
  47469. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47470. * * 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`)
  47471. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47472. * * 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
  47473. * * 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)
  47474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47475. * * 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
  47476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47477. * @param name defines the name of the mesh
  47478. * @param options defines the options used to create the mesh
  47479. * @param scene defines the hosting scene
  47480. * @returns the sphere mesh
  47481. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47482. */
  47483. static CreateSphere(name: string, options: {
  47484. segments?: number;
  47485. diameter?: number;
  47486. diameterX?: number;
  47487. diameterY?: number;
  47488. diameterZ?: number;
  47489. arc?: number;
  47490. slice?: number;
  47491. sideOrientation?: number;
  47492. frontUVs?: Vector4;
  47493. backUVs?: Vector4;
  47494. updatable?: boolean;
  47495. }, scene?: Nullable<Scene>): Mesh;
  47496. }
  47497. }
  47498. declare module BABYLON {
  47499. /**
  47500. * A profiled motion controller has its profile loaded from an online repository.
  47501. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47502. */
  47503. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47504. private _repositoryUrl;
  47505. private _buttonMeshMapping;
  47506. private _touchDots;
  47507. /**
  47508. * The profile ID of this controller. Will be populated when the controller initializes.
  47509. */
  47510. profileId: string;
  47511. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47512. dispose(): void;
  47513. protected _getFilenameAndPath(): {
  47514. filename: string;
  47515. path: string;
  47516. };
  47517. protected _getModelLoadingConstraints(): boolean;
  47518. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47519. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47520. protected _updateModel(_xrFrame: XRFrame): void;
  47521. }
  47522. }
  47523. declare module BABYLON {
  47524. /**
  47525. * A construction function type to create a new controller based on an xrInput object
  47526. */
  47527. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47528. /**
  47529. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47530. *
  47531. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47532. * it should be replaced with auto-loaded controllers.
  47533. *
  47534. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47535. */
  47536. export class WebXRMotionControllerManager {
  47537. private static _AvailableControllers;
  47538. private static _Fallbacks;
  47539. private static _ProfileLoadingPromises;
  47540. private static _ProfilesList;
  47541. /**
  47542. * The base URL of the online controller repository. Can be changed at any time.
  47543. */
  47544. static BaseRepositoryUrl: string;
  47545. /**
  47546. * Which repository gets priority - local or online
  47547. */
  47548. static PrioritizeOnlineRepository: boolean;
  47549. /**
  47550. * Use the online repository, or use only locally-defined controllers
  47551. */
  47552. static UseOnlineRepository: boolean;
  47553. /**
  47554. * Clear the cache used for profile loading and reload when requested again
  47555. */
  47556. static ClearProfilesCache(): void;
  47557. /**
  47558. * Register the default fallbacks.
  47559. * This function is called automatically when this file is imported.
  47560. */
  47561. static DefaultFallbacks(): void;
  47562. /**
  47563. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47564. * @param profileId the profile to which a fallback needs to be found
  47565. * @return an array with corresponding fallback profiles
  47566. */
  47567. static FindFallbackWithProfileId(profileId: string): string[];
  47568. /**
  47569. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47570. * The order of search:
  47571. *
  47572. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47573. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47574. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47575. * 4) return the generic trigger controller if none were found
  47576. *
  47577. * @param xrInput the xrInput to which a new controller is initialized
  47578. * @param scene the scene to which the model will be added
  47579. * @param forceProfile force a certain profile for this controller
  47580. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47581. */
  47582. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47583. /**
  47584. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47585. *
  47586. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47587. *
  47588. * @param type the profile type to register
  47589. * @param constructFunction the function to be called when loading this profile
  47590. */
  47591. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47592. /**
  47593. * Register a fallback to a specific profile.
  47594. * @param profileId the profileId that will receive the fallbacks
  47595. * @param fallbacks A list of fallback profiles
  47596. */
  47597. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47598. /**
  47599. * Will update the list of profiles available in the repository
  47600. * @return a promise that resolves to a map of profiles available online
  47601. */
  47602. static UpdateProfilesList(): Promise<{
  47603. [profile: string]: string;
  47604. }>;
  47605. private static _LoadProfileFromRepository;
  47606. private static _LoadProfilesFromAvailableControllers;
  47607. }
  47608. }
  47609. declare module BABYLON {
  47610. /**
  47611. * Configuration options for the WebXR controller creation
  47612. */
  47613. export interface IWebXRControllerOptions {
  47614. /**
  47615. * Should the controller mesh be animated when a user interacts with it
  47616. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47617. */
  47618. disableMotionControllerAnimation?: boolean;
  47619. /**
  47620. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47621. */
  47622. doNotLoadControllerMesh?: boolean;
  47623. /**
  47624. * Force a specific controller type for this controller.
  47625. * This can be used when creating your own profile or when testing different controllers
  47626. */
  47627. forceControllerProfile?: string;
  47628. /**
  47629. * Defines a rendering group ID for meshes that will be loaded.
  47630. * This is for the default controllers only.
  47631. */
  47632. renderingGroupId?: number;
  47633. }
  47634. /**
  47635. * Represents an XR controller
  47636. */
  47637. export class WebXRInputSource {
  47638. private _scene;
  47639. /** The underlying input source for the controller */
  47640. inputSource: XRInputSource;
  47641. private _options;
  47642. private _tmpVector;
  47643. private _uniqueId;
  47644. /**
  47645. * 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
  47646. */
  47647. grip?: AbstractMesh;
  47648. /**
  47649. * If available, this is the gamepad object related to this controller.
  47650. * Using this object it is possible to get click events and trackpad changes of the
  47651. * webxr controller that is currently being used.
  47652. */
  47653. motionController?: WebXRAbstractMotionController;
  47654. /**
  47655. * Event that fires when the controller is removed/disposed.
  47656. * The object provided as event data is this controller, after associated assets were disposed.
  47657. * uniqueId is still available.
  47658. */
  47659. onDisposeObservable: Observable<WebXRInputSource>;
  47660. /**
  47661. * Will be triggered when the mesh associated with the motion controller is done loading.
  47662. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47663. * A shortened version of controller -> motion controller -> on mesh loaded.
  47664. */
  47665. onMeshLoadedObservable: Observable<AbstractMesh>;
  47666. /**
  47667. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47668. */
  47669. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47670. /**
  47671. * Pointer which can be used to select objects or attach a visible laser to
  47672. */
  47673. pointer: AbstractMesh;
  47674. /**
  47675. * Creates the input source object
  47676. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  47677. * @param _scene the scene which the controller should be associated to
  47678. * @param inputSource the underlying input source for the controller
  47679. * @param _options options for this controller creation
  47680. */
  47681. constructor(_scene: Scene,
  47682. /** The underlying input source for the controller */
  47683. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47684. /**
  47685. * Get this controllers unique id
  47686. */
  47687. get uniqueId(): string;
  47688. /**
  47689. * Disposes of the object
  47690. */
  47691. dispose(): void;
  47692. /**
  47693. * Gets a world space ray coming from the pointer or grip
  47694. * @param result the resulting ray
  47695. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47696. */
  47697. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47698. /**
  47699. * Updates the controller pose based on the given XRFrame
  47700. * @param xrFrame xr frame to update the pose with
  47701. * @param referenceSpace reference space to use
  47702. */
  47703. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47704. }
  47705. }
  47706. declare module BABYLON {
  47707. /**
  47708. * The schema for initialization options of the XR Input class
  47709. */
  47710. export interface IWebXRInputOptions {
  47711. /**
  47712. * If set to true no model will be automatically loaded
  47713. */
  47714. doNotLoadControllerMeshes?: boolean;
  47715. /**
  47716. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47717. * If not found, the xr input profile data will be used.
  47718. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47719. */
  47720. forceInputProfile?: string;
  47721. /**
  47722. * Do not send a request to the controller repository to load the profile.
  47723. *
  47724. * Instead, use the controllers available in babylon itself.
  47725. */
  47726. disableOnlineControllerRepository?: boolean;
  47727. /**
  47728. * A custom URL for the controllers repository
  47729. */
  47730. customControllersRepositoryURL?: string;
  47731. /**
  47732. * Should the controller model's components not move according to the user input
  47733. */
  47734. disableControllerAnimation?: boolean;
  47735. /**
  47736. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47737. */
  47738. controllerOptions?: IWebXRControllerOptions;
  47739. }
  47740. /**
  47741. * XR input used to track XR inputs such as controllers/rays
  47742. */
  47743. export class WebXRInput implements IDisposable {
  47744. /**
  47745. * the xr session manager for this session
  47746. */
  47747. xrSessionManager: WebXRSessionManager;
  47748. /**
  47749. * the WebXR camera for this session. Mainly used for teleportation
  47750. */
  47751. xrCamera: WebXRCamera;
  47752. private readonly options;
  47753. /**
  47754. * XR controllers being tracked
  47755. */
  47756. controllers: Array<WebXRInputSource>;
  47757. private _frameObserver;
  47758. private _sessionEndedObserver;
  47759. private _sessionInitObserver;
  47760. /**
  47761. * Event when a controller has been connected/added
  47762. */
  47763. onControllerAddedObservable: Observable<WebXRInputSource>;
  47764. /**
  47765. * Event when a controller has been removed/disconnected
  47766. */
  47767. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47768. /**
  47769. * Initializes the WebXRInput
  47770. * @param xrSessionManager the xr session manager for this session
  47771. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47772. * @param options = initialization options for this xr input
  47773. */
  47774. constructor(
  47775. /**
  47776. * the xr session manager for this session
  47777. */
  47778. xrSessionManager: WebXRSessionManager,
  47779. /**
  47780. * the WebXR camera for this session. Mainly used for teleportation
  47781. */
  47782. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47783. private _onInputSourcesChange;
  47784. private _addAndRemoveControllers;
  47785. /**
  47786. * Disposes of the object
  47787. */
  47788. dispose(): void;
  47789. }
  47790. }
  47791. declare module BABYLON {
  47792. /**
  47793. * This is the base class for all WebXR features.
  47794. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47795. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47796. */
  47797. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47798. protected _xrSessionManager: WebXRSessionManager;
  47799. private _attached;
  47800. private _removeOnDetach;
  47801. /**
  47802. * Should auto-attach be disabled?
  47803. */
  47804. disableAutoAttach: boolean;
  47805. /**
  47806. * Construct a new (abstract) WebXR feature
  47807. * @param _xrSessionManager the xr session manager for this feature
  47808. */
  47809. constructor(_xrSessionManager: WebXRSessionManager);
  47810. /**
  47811. * Is this feature attached
  47812. */
  47813. get attached(): boolean;
  47814. /**
  47815. * attach this feature
  47816. *
  47817. * @param force should attachment be forced (even when already attached)
  47818. * @returns true if successful, false is failed or already attached
  47819. */
  47820. attach(force?: boolean): boolean;
  47821. /**
  47822. * detach this feature.
  47823. *
  47824. * @returns true if successful, false if failed or already detached
  47825. */
  47826. detach(): boolean;
  47827. /**
  47828. * Dispose this feature and all of the resources attached
  47829. */
  47830. dispose(): void;
  47831. /**
  47832. * This is used to register callbacks that will automatically be removed when detach is called.
  47833. * @param observable the observable to which the observer will be attached
  47834. * @param callback the callback to register
  47835. */
  47836. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47837. /**
  47838. * Code in this function will be executed on each xrFrame received from the browser.
  47839. * This function will not execute after the feature is detached.
  47840. * @param _xrFrame the current frame
  47841. */
  47842. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47843. }
  47844. }
  47845. declare module BABYLON {
  47846. /**
  47847. * Renders a layer on top of an existing scene
  47848. */
  47849. export class UtilityLayerRenderer implements IDisposable {
  47850. /** the original scene that will be rendered on top of */
  47851. originalScene: Scene;
  47852. private _pointerCaptures;
  47853. private _lastPointerEvents;
  47854. private static _DefaultUtilityLayer;
  47855. private static _DefaultKeepDepthUtilityLayer;
  47856. private _sharedGizmoLight;
  47857. private _renderCamera;
  47858. /**
  47859. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47860. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47861. * @returns the camera that is used when rendering the utility layer
  47862. */
  47863. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47864. /**
  47865. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47866. * @param cam the camera that should be used when rendering the utility layer
  47867. */
  47868. setRenderCamera(cam: Nullable<Camera>): void;
  47869. /**
  47870. * @hidden
  47871. * Light which used by gizmos to get light shading
  47872. */
  47873. _getSharedGizmoLight(): HemisphericLight;
  47874. /**
  47875. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47876. */
  47877. pickUtilitySceneFirst: boolean;
  47878. /**
  47879. * 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)
  47880. */
  47881. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47882. /**
  47883. * 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)
  47884. */
  47885. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47886. /**
  47887. * The scene that is rendered on top of the original scene
  47888. */
  47889. utilityLayerScene: Scene;
  47890. /**
  47891. * If the utility layer should automatically be rendered on top of existing scene
  47892. */
  47893. shouldRender: boolean;
  47894. /**
  47895. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47896. */
  47897. onlyCheckPointerDownEvents: boolean;
  47898. /**
  47899. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47900. */
  47901. processAllEvents: boolean;
  47902. /**
  47903. * Observable raised when the pointer move from the utility layer scene to the main scene
  47904. */
  47905. onPointerOutObservable: Observable<number>;
  47906. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47907. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47908. private _afterRenderObserver;
  47909. private _sceneDisposeObserver;
  47910. private _originalPointerObserver;
  47911. /**
  47912. * Instantiates a UtilityLayerRenderer
  47913. * @param originalScene the original scene that will be rendered on top of
  47914. * @param handleEvents boolean indicating if the utility layer should handle events
  47915. */
  47916. constructor(
  47917. /** the original scene that will be rendered on top of */
  47918. originalScene: Scene, handleEvents?: boolean);
  47919. private _notifyObservers;
  47920. /**
  47921. * Renders the utility layers scene on top of the original scene
  47922. */
  47923. render(): void;
  47924. /**
  47925. * Disposes of the renderer
  47926. */
  47927. dispose(): void;
  47928. private _updateCamera;
  47929. }
  47930. }
  47931. declare module BABYLON {
  47932. /**
  47933. * Options interface for the pointer selection module
  47934. */
  47935. export interface IWebXRControllerPointerSelectionOptions {
  47936. /**
  47937. * if provided, this scene will be used to render meshes.
  47938. */
  47939. customUtilityLayerScene?: Scene;
  47940. /**
  47941. * 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)
  47942. * If not disabled, the last picked point will be used to execute a pointer up event
  47943. * If disabled, pointer up event will be triggered right after the pointer down event.
  47944. * Used in screen and gaze target ray mode only
  47945. */
  47946. disablePointerUpOnTouchOut: boolean;
  47947. /**
  47948. * For gaze mode (time to select instead of press)
  47949. */
  47950. forceGazeMode: boolean;
  47951. /**
  47952. * 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
  47953. * to start a new countdown to the pointer down event.
  47954. * Defaults to 1.
  47955. */
  47956. gazeModePointerMovedFactor?: number;
  47957. /**
  47958. * Different button type to use instead of the main component
  47959. */
  47960. overrideButtonId?: string;
  47961. /**
  47962. * use this rendering group id for the meshes (optional)
  47963. */
  47964. renderingGroupId?: number;
  47965. /**
  47966. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47967. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47968. * 3000 means 3 seconds between pointing at something and selecting it
  47969. */
  47970. timeToSelect?: number;
  47971. /**
  47972. * Should meshes created here be added to a utility layer or the main scene
  47973. */
  47974. useUtilityLayer?: boolean;
  47975. /**
  47976. * the xr input to use with this pointer selection
  47977. */
  47978. xrInput: WebXRInput;
  47979. }
  47980. /**
  47981. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47982. */
  47983. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47984. private readonly _options;
  47985. private static _idCounter;
  47986. private _attachController;
  47987. private _controllers;
  47988. private _scene;
  47989. private _tmpVectorForPickCompare;
  47990. /**
  47991. * The module's name
  47992. */
  47993. static readonly Name: string;
  47994. /**
  47995. * The (Babylon) version of this module.
  47996. * This is an integer representing the implementation version.
  47997. * This number does not correspond to the WebXR specs version
  47998. */
  47999. static readonly Version: number;
  48000. /**
  48001. * Disable lighting on the laser pointer (so it will always be visible)
  48002. */
  48003. disablePointerLighting: boolean;
  48004. /**
  48005. * Disable lighting on the selection mesh (so it will always be visible)
  48006. */
  48007. disableSelectionMeshLighting: boolean;
  48008. /**
  48009. * Should the laser pointer be displayed
  48010. */
  48011. displayLaserPointer: boolean;
  48012. /**
  48013. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48014. */
  48015. displaySelectionMesh: boolean;
  48016. /**
  48017. * This color will be set to the laser pointer when selection is triggered
  48018. */
  48019. laserPointerPickedColor: Color3;
  48020. /**
  48021. * Default color of the laser pointer
  48022. */
  48023. laserPointerDefaultColor: Color3;
  48024. /**
  48025. * default color of the selection ring
  48026. */
  48027. selectionMeshDefaultColor: Color3;
  48028. /**
  48029. * This color will be applied to the selection ring when selection is triggered
  48030. */
  48031. selectionMeshPickedColor: Color3;
  48032. /**
  48033. * Optional filter to be used for ray selection. This predicate shares behavior with
  48034. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48035. */
  48036. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48037. /**
  48038. * constructs a new background remover module
  48039. * @param _xrSessionManager the session manager for this module
  48040. * @param _options read-only options to be used in this module
  48041. */
  48042. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48043. /**
  48044. * attach this feature
  48045. * Will usually be called by the features manager
  48046. *
  48047. * @returns true if successful.
  48048. */
  48049. attach(): boolean;
  48050. /**
  48051. * detach this feature.
  48052. * Will usually be called by the features manager
  48053. *
  48054. * @returns true if successful.
  48055. */
  48056. detach(): boolean;
  48057. /**
  48058. * Will get the mesh under a specific pointer.
  48059. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48060. * @param controllerId the controllerId to check
  48061. * @returns The mesh under pointer or null if no mesh is under the pointer
  48062. */
  48063. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48064. /**
  48065. * Get the xr controller that correlates to the pointer id in the pointer event
  48066. *
  48067. * @param id the pointer id to search for
  48068. * @returns the controller that correlates to this id or null if not found
  48069. */
  48070. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48071. protected _onXRFrame(_xrFrame: XRFrame): void;
  48072. private _attachGazeMode;
  48073. private _attachScreenRayMode;
  48074. private _attachTrackedPointerRayMode;
  48075. private _convertNormalToDirectionOfRay;
  48076. private _detachController;
  48077. private _generateNewMeshPair;
  48078. private _pickingMoved;
  48079. private _updatePointerDistance;
  48080. /** @hidden */
  48081. get lasterPointerDefaultColor(): Color3;
  48082. }
  48083. }
  48084. declare module BABYLON {
  48085. /**
  48086. * Button which can be used to enter a different mode of XR
  48087. */
  48088. export class WebXREnterExitUIButton {
  48089. /** button element */
  48090. element: HTMLElement;
  48091. /** XR initialization options for the button */
  48092. sessionMode: XRSessionMode;
  48093. /** Reference space type */
  48094. referenceSpaceType: XRReferenceSpaceType;
  48095. /**
  48096. * Creates a WebXREnterExitUIButton
  48097. * @param element button element
  48098. * @param sessionMode XR initialization session mode
  48099. * @param referenceSpaceType the type of reference space to be used
  48100. */
  48101. constructor(
  48102. /** button element */
  48103. element: HTMLElement,
  48104. /** XR initialization options for the button */
  48105. sessionMode: XRSessionMode,
  48106. /** Reference space type */
  48107. referenceSpaceType: XRReferenceSpaceType);
  48108. /**
  48109. * Extendable function which can be used to update the button's visuals when the state changes
  48110. * @param activeButton the current active button in the UI
  48111. */
  48112. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48113. }
  48114. /**
  48115. * Options to create the webXR UI
  48116. */
  48117. export class WebXREnterExitUIOptions {
  48118. /**
  48119. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48120. */
  48121. customButtons?: Array<WebXREnterExitUIButton>;
  48122. /**
  48123. * A reference space type to use when creating the default button.
  48124. * Default is local-floor
  48125. */
  48126. referenceSpaceType?: XRReferenceSpaceType;
  48127. /**
  48128. * Context to enter xr with
  48129. */
  48130. renderTarget?: Nullable<WebXRRenderTarget>;
  48131. /**
  48132. * A session mode to use when creating the default button.
  48133. * Default is immersive-vr
  48134. */
  48135. sessionMode?: XRSessionMode;
  48136. /**
  48137. * A list of optional features to init the session with
  48138. */
  48139. optionalFeatures?: string[];
  48140. }
  48141. /**
  48142. * UI to allow the user to enter/exit XR mode
  48143. */
  48144. export class WebXREnterExitUI implements IDisposable {
  48145. private scene;
  48146. /** version of the options passed to this UI */
  48147. options: WebXREnterExitUIOptions;
  48148. private _activeButton;
  48149. private _buttons;
  48150. private _overlay;
  48151. /**
  48152. * Fired every time the active button is changed.
  48153. *
  48154. * When xr is entered via a button that launches xr that button will be the callback parameter
  48155. *
  48156. * When exiting xr the callback parameter will be null)
  48157. */
  48158. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48159. /**
  48160. *
  48161. * @param scene babylon scene object to use
  48162. * @param options (read-only) version of the options passed to this UI
  48163. */
  48164. private constructor();
  48165. /**
  48166. * Creates UI to allow the user to enter/exit XR mode
  48167. * @param scene the scene to add the ui to
  48168. * @param helper the xr experience helper to enter/exit xr with
  48169. * @param options options to configure the UI
  48170. * @returns the created ui
  48171. */
  48172. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48173. /**
  48174. * Disposes of the XR UI component
  48175. */
  48176. dispose(): void;
  48177. private _updateButtons;
  48178. }
  48179. }
  48180. declare module BABYLON {
  48181. /**
  48182. * Class containing static functions to help procedurally build meshes
  48183. */
  48184. export class LinesBuilder {
  48185. /**
  48186. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48187. * * 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
  48188. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48189. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48190. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48191. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48192. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48193. * * 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
  48194. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48197. * @param name defines the name of the new line system
  48198. * @param options defines the options used to create the line system
  48199. * @param scene defines the hosting scene
  48200. * @returns a new line system mesh
  48201. */
  48202. static CreateLineSystem(name: string, options: {
  48203. lines: Vector3[][];
  48204. updatable?: boolean;
  48205. instance?: Nullable<LinesMesh>;
  48206. colors?: Nullable<Color4[][]>;
  48207. useVertexAlpha?: boolean;
  48208. }, scene: Nullable<Scene>): LinesMesh;
  48209. /**
  48210. * Creates a line mesh
  48211. * 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
  48212. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48213. * * The parameter `points` is an array successive Vector3
  48214. * * 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
  48215. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48216. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48217. * * When updating an instance, remember that only point positions can change, not the number of points
  48218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48219. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48220. * @param name defines the name of the new line system
  48221. * @param options defines the options used to create the line system
  48222. * @param scene defines the hosting scene
  48223. * @returns a new line mesh
  48224. */
  48225. static CreateLines(name: string, options: {
  48226. points: Vector3[];
  48227. updatable?: boolean;
  48228. instance?: Nullable<LinesMesh>;
  48229. colors?: Color4[];
  48230. useVertexAlpha?: boolean;
  48231. }, scene?: Nullable<Scene>): LinesMesh;
  48232. /**
  48233. * Creates a dashed line mesh
  48234. * * 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
  48235. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48236. * * The parameter `points` is an array successive Vector3
  48237. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48238. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48239. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48240. * * 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
  48241. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48242. * * When updating an instance, remember that only point positions can change, not the number of points
  48243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48244. * @param name defines the name of the mesh
  48245. * @param options defines the options used to create the mesh
  48246. * @param scene defines the hosting scene
  48247. * @returns the dashed line mesh
  48248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48249. */
  48250. static CreateDashedLines(name: string, options: {
  48251. points: Vector3[];
  48252. dashSize?: number;
  48253. gapSize?: number;
  48254. dashNb?: number;
  48255. updatable?: boolean;
  48256. instance?: LinesMesh;
  48257. useVertexAlpha?: boolean;
  48258. }, scene?: Nullable<Scene>): LinesMesh;
  48259. }
  48260. }
  48261. declare module BABYLON {
  48262. /**
  48263. * Construction options for a timer
  48264. */
  48265. export interface ITimerOptions<T> {
  48266. /**
  48267. * Time-to-end
  48268. */
  48269. timeout: number;
  48270. /**
  48271. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48272. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48273. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48274. */
  48275. contextObservable: Observable<T>;
  48276. /**
  48277. * Optional parameters when adding an observer to the observable
  48278. */
  48279. observableParameters?: {
  48280. mask?: number;
  48281. insertFirst?: boolean;
  48282. scope?: any;
  48283. };
  48284. /**
  48285. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48286. */
  48287. breakCondition?: (data?: ITimerData<T>) => boolean;
  48288. /**
  48289. * Will be triggered when the time condition has met
  48290. */
  48291. onEnded?: (data: ITimerData<any>) => void;
  48292. /**
  48293. * Will be triggered when the break condition has met (prematurely ended)
  48294. */
  48295. onAborted?: (data: ITimerData<any>) => void;
  48296. /**
  48297. * Optional function to execute on each tick (or count)
  48298. */
  48299. onTick?: (data: ITimerData<any>) => void;
  48300. }
  48301. /**
  48302. * An interface defining the data sent by the timer
  48303. */
  48304. export interface ITimerData<T> {
  48305. /**
  48306. * When did it start
  48307. */
  48308. startTime: number;
  48309. /**
  48310. * Time now
  48311. */
  48312. currentTime: number;
  48313. /**
  48314. * Time passed since started
  48315. */
  48316. deltaTime: number;
  48317. /**
  48318. * How much is completed, in [0.0...1.0].
  48319. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48320. */
  48321. completeRate: number;
  48322. /**
  48323. * What the registered observable sent in the last count
  48324. */
  48325. payload: T;
  48326. }
  48327. /**
  48328. * The current state of the timer
  48329. */
  48330. export enum TimerState {
  48331. /**
  48332. * Timer initialized, not yet started
  48333. */
  48334. INIT = 0,
  48335. /**
  48336. * Timer started and counting
  48337. */
  48338. STARTED = 1,
  48339. /**
  48340. * Timer ended (whether aborted or time reached)
  48341. */
  48342. ENDED = 2
  48343. }
  48344. /**
  48345. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48346. *
  48347. * @param options options with which to initialize this timer
  48348. */
  48349. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48350. /**
  48351. * An advanced implementation of a timer class
  48352. */
  48353. export class AdvancedTimer<T = any> implements IDisposable {
  48354. /**
  48355. * Will notify each time the timer calculates the remaining time
  48356. */
  48357. onEachCountObservable: Observable<ITimerData<T>>;
  48358. /**
  48359. * Will trigger when the timer was aborted due to the break condition
  48360. */
  48361. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48362. /**
  48363. * Will trigger when the timer ended successfully
  48364. */
  48365. onTimerEndedObservable: Observable<ITimerData<T>>;
  48366. /**
  48367. * Will trigger when the timer state has changed
  48368. */
  48369. onStateChangedObservable: Observable<TimerState>;
  48370. private _observer;
  48371. private _contextObservable;
  48372. private _observableParameters;
  48373. private _startTime;
  48374. private _timer;
  48375. private _state;
  48376. private _breakCondition;
  48377. private _timeToEnd;
  48378. private _breakOnNextTick;
  48379. /**
  48380. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48381. * @param options construction options for this advanced timer
  48382. */
  48383. constructor(options: ITimerOptions<T>);
  48384. /**
  48385. * set a breaking condition for this timer. Default is to never break during count
  48386. * @param predicate the new break condition. Returns true to break, false otherwise
  48387. */
  48388. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48389. /**
  48390. * Reset ALL associated observables in this advanced timer
  48391. */
  48392. clearObservables(): void;
  48393. /**
  48394. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48395. *
  48396. * @param timeToEnd how much time to measure until timer ended
  48397. */
  48398. start(timeToEnd?: number): void;
  48399. /**
  48400. * Will force a stop on the next tick.
  48401. */
  48402. stop(): void;
  48403. /**
  48404. * Dispose this timer, clearing all resources
  48405. */
  48406. dispose(): void;
  48407. private _setState;
  48408. private _tick;
  48409. private _stop;
  48410. }
  48411. }
  48412. declare module BABYLON {
  48413. /**
  48414. * The options container for the teleportation module
  48415. */
  48416. export interface IWebXRTeleportationOptions {
  48417. /**
  48418. * if provided, this scene will be used to render meshes.
  48419. */
  48420. customUtilityLayerScene?: Scene;
  48421. /**
  48422. * Values to configure the default target mesh
  48423. */
  48424. defaultTargetMeshOptions?: {
  48425. /**
  48426. * Fill color of the teleportation area
  48427. */
  48428. teleportationFillColor?: string;
  48429. /**
  48430. * Border color for the teleportation area
  48431. */
  48432. teleportationBorderColor?: string;
  48433. /**
  48434. * Disable the mesh's animation sequence
  48435. */
  48436. disableAnimation?: boolean;
  48437. /**
  48438. * Disable lighting on the material or the ring and arrow
  48439. */
  48440. disableLighting?: boolean;
  48441. /**
  48442. * Override the default material of the torus and arrow
  48443. */
  48444. torusArrowMaterial?: Material;
  48445. };
  48446. /**
  48447. * A list of meshes to use as floor meshes.
  48448. * Meshes can be added and removed after initializing the feature using the
  48449. * addFloorMesh and removeFloorMesh functions
  48450. * If empty, rotation will still work
  48451. */
  48452. floorMeshes?: AbstractMesh[];
  48453. /**
  48454. * use this rendering group id for the meshes (optional)
  48455. */
  48456. renderingGroupId?: number;
  48457. /**
  48458. * Should teleportation move only to snap points
  48459. */
  48460. snapPointsOnly?: boolean;
  48461. /**
  48462. * An array of points to which the teleportation will snap to.
  48463. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48464. */
  48465. snapPositions?: Vector3[];
  48466. /**
  48467. * How close should the teleportation ray be in order to snap to position.
  48468. * Default to 0.8 units (meters)
  48469. */
  48470. snapToPositionRadius?: number;
  48471. /**
  48472. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48473. * If you want to support rotation, make sure your mesh has a direction indicator.
  48474. *
  48475. * When left untouched, the default mesh will be initialized.
  48476. */
  48477. teleportationTargetMesh?: AbstractMesh;
  48478. /**
  48479. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48480. */
  48481. timeToTeleport?: number;
  48482. /**
  48483. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48484. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48485. */
  48486. useMainComponentOnly?: boolean;
  48487. /**
  48488. * Should meshes created here be added to a utility layer or the main scene
  48489. */
  48490. useUtilityLayer?: boolean;
  48491. /**
  48492. * Babylon XR Input class for controller
  48493. */
  48494. xrInput: WebXRInput;
  48495. }
  48496. /**
  48497. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48498. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48499. * the input of the attached controllers.
  48500. */
  48501. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48502. private _options;
  48503. private _controllers;
  48504. private _currentTeleportationControllerId;
  48505. private _floorMeshes;
  48506. private _quadraticBezierCurve;
  48507. private _selectionFeature;
  48508. private _snapToPositions;
  48509. private _snappedToPoint;
  48510. private _teleportationRingMaterial?;
  48511. private _tmpRay;
  48512. private _tmpVector;
  48513. /**
  48514. * The module's name
  48515. */
  48516. static readonly Name: string;
  48517. /**
  48518. * The (Babylon) version of this module.
  48519. * This is an integer representing the implementation version.
  48520. * This number does not correspond to the webxr specs version
  48521. */
  48522. static readonly Version: number;
  48523. /**
  48524. * Is movement backwards enabled
  48525. */
  48526. backwardsMovementEnabled: boolean;
  48527. /**
  48528. * Distance to travel when moving backwards
  48529. */
  48530. backwardsTeleportationDistance: number;
  48531. /**
  48532. * The distance from the user to the inspection point in the direction of the controller
  48533. * A higher number will allow the user to move further
  48534. * defaults to 5 (meters, in xr units)
  48535. */
  48536. parabolicCheckRadius: number;
  48537. /**
  48538. * Should the module support parabolic ray on top of direct ray
  48539. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48540. * Very helpful when moving between floors / different heights
  48541. */
  48542. parabolicRayEnabled: boolean;
  48543. /**
  48544. * How much rotation should be applied when rotating right and left
  48545. */
  48546. rotationAngle: number;
  48547. /**
  48548. * Is rotation enabled when moving forward?
  48549. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48550. */
  48551. rotationEnabled: boolean;
  48552. /**
  48553. * constructs a new anchor system
  48554. * @param _xrSessionManager an instance of WebXRSessionManager
  48555. * @param _options configuration object for this feature
  48556. */
  48557. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48558. /**
  48559. * Get the snapPointsOnly flag
  48560. */
  48561. get snapPointsOnly(): boolean;
  48562. /**
  48563. * Sets the snapPointsOnly flag
  48564. * @param snapToPoints should teleportation be exclusively to snap points
  48565. */
  48566. set snapPointsOnly(snapToPoints: boolean);
  48567. /**
  48568. * Add a new mesh to the floor meshes array
  48569. * @param mesh the mesh to use as floor mesh
  48570. */
  48571. addFloorMesh(mesh: AbstractMesh): void;
  48572. /**
  48573. * Add a new snap-to point to fix teleportation to this position
  48574. * @param newSnapPoint The new Snap-To point
  48575. */
  48576. addSnapPoint(newSnapPoint: Vector3): void;
  48577. attach(): boolean;
  48578. detach(): boolean;
  48579. dispose(): void;
  48580. /**
  48581. * Remove a mesh from the floor meshes array
  48582. * @param mesh the mesh to remove
  48583. */
  48584. removeFloorMesh(mesh: AbstractMesh): void;
  48585. /**
  48586. * Remove a mesh from the floor meshes array using its name
  48587. * @param name the mesh name to remove
  48588. */
  48589. removeFloorMeshByName(name: string): void;
  48590. /**
  48591. * 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
  48592. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48593. * @returns was the point found and removed or not
  48594. */
  48595. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48596. /**
  48597. * This function sets a selection feature that will be disabled when
  48598. * the forward ray is shown and will be reattached when hidden.
  48599. * This is used to remove the selection rays when moving.
  48600. * @param selectionFeature the feature to disable when forward movement is enabled
  48601. */
  48602. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48603. protected _onXRFrame(_xrFrame: XRFrame): void;
  48604. private _attachController;
  48605. private _createDefaultTargetMesh;
  48606. private _detachController;
  48607. private _findClosestSnapPointWithRadius;
  48608. private _setTargetMeshPosition;
  48609. private _setTargetMeshVisibility;
  48610. private _showParabolicPath;
  48611. private _teleportForward;
  48612. }
  48613. }
  48614. declare module BABYLON {
  48615. /**
  48616. * Options for the default xr helper
  48617. */
  48618. export class WebXRDefaultExperienceOptions {
  48619. /**
  48620. * Enable or disable default UI to enter XR
  48621. */
  48622. disableDefaultUI?: boolean;
  48623. /**
  48624. * Should teleportation not initialize. defaults to false.
  48625. */
  48626. disableTeleportation?: boolean;
  48627. /**
  48628. * Floor meshes that will be used for teleport
  48629. */
  48630. floorMeshes?: Array<AbstractMesh>;
  48631. /**
  48632. * If set to true, the first frame will not be used to reset position
  48633. * The first frame is mainly used when copying transformation from the old camera
  48634. * Mainly used in AR
  48635. */
  48636. ignoreNativeCameraTransformation?: boolean;
  48637. /**
  48638. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48639. */
  48640. inputOptions?: IWebXRInputOptions;
  48641. /**
  48642. * optional configuration for the output canvas
  48643. */
  48644. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48645. /**
  48646. * optional UI options. This can be used among other to change session mode and reference space type
  48647. */
  48648. uiOptions?: WebXREnterExitUIOptions;
  48649. /**
  48650. * When loading teleportation and pointer select, use stable versions instead of latest.
  48651. */
  48652. useStablePlugins?: boolean;
  48653. /**
  48654. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48655. */
  48656. renderingGroupId?: number;
  48657. /**
  48658. * A list of optional features to init the session with
  48659. * If set to true, all features we support will be added
  48660. */
  48661. optionalFeatures?: boolean | string[];
  48662. }
  48663. /**
  48664. * Default experience which provides a similar setup to the previous webVRExperience
  48665. */
  48666. export class WebXRDefaultExperience {
  48667. /**
  48668. * Base experience
  48669. */
  48670. baseExperience: WebXRExperienceHelper;
  48671. /**
  48672. * Enables ui for entering/exiting xr
  48673. */
  48674. enterExitUI: WebXREnterExitUI;
  48675. /**
  48676. * Input experience extension
  48677. */
  48678. input: WebXRInput;
  48679. /**
  48680. * Enables laser pointer and selection
  48681. */
  48682. pointerSelection: WebXRControllerPointerSelection;
  48683. /**
  48684. * Default target xr should render to
  48685. */
  48686. renderTarget: WebXRRenderTarget;
  48687. /**
  48688. * Enables teleportation
  48689. */
  48690. teleportation: WebXRMotionControllerTeleportation;
  48691. private constructor();
  48692. /**
  48693. * Creates the default xr experience
  48694. * @param scene scene
  48695. * @param options options for basic configuration
  48696. * @returns resulting WebXRDefaultExperience
  48697. */
  48698. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48699. /**
  48700. * DIsposes of the experience helper
  48701. */
  48702. dispose(): void;
  48703. }
  48704. }
  48705. declare module BABYLON {
  48706. /**
  48707. * Options to modify the vr teleportation behavior.
  48708. */
  48709. export interface VRTeleportationOptions {
  48710. /**
  48711. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48712. */
  48713. floorMeshName?: string;
  48714. /**
  48715. * A list of meshes to be used as the teleportation floor. (default: empty)
  48716. */
  48717. floorMeshes?: Mesh[];
  48718. /**
  48719. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48720. */
  48721. teleportationMode?: number;
  48722. /**
  48723. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48724. */
  48725. teleportationTime?: number;
  48726. /**
  48727. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48728. */
  48729. teleportationSpeed?: number;
  48730. /**
  48731. * The easing function used in the animation or null for Linear. (default CircleEase)
  48732. */
  48733. easingFunction?: EasingFunction;
  48734. }
  48735. /**
  48736. * Options to modify the vr experience helper's behavior.
  48737. */
  48738. export interface VRExperienceHelperOptions extends WebVROptions {
  48739. /**
  48740. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48741. */
  48742. createDeviceOrientationCamera?: boolean;
  48743. /**
  48744. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48745. */
  48746. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48747. /**
  48748. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48749. */
  48750. laserToggle?: boolean;
  48751. /**
  48752. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48753. */
  48754. floorMeshes?: Mesh[];
  48755. /**
  48756. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48757. */
  48758. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48759. /**
  48760. * Defines if WebXR should be used instead of WebVR (if available)
  48761. */
  48762. useXR?: boolean;
  48763. }
  48764. /**
  48765. * Event containing information after VR has been entered
  48766. */
  48767. export class OnAfterEnteringVRObservableEvent {
  48768. /**
  48769. * If entering vr was successful
  48770. */
  48771. success: boolean;
  48772. }
  48773. /**
  48774. * Helps to quickly add VR support to an existing scene.
  48775. * See https://doc.babylonjs.com/how_to/webvr_helper
  48776. */
  48777. export class VRExperienceHelper {
  48778. /** Options to modify the vr experience helper's behavior. */
  48779. webVROptions: VRExperienceHelperOptions;
  48780. private _scene;
  48781. private _position;
  48782. private _btnVR;
  48783. private _btnVRDisplayed;
  48784. private _webVRsupported;
  48785. private _webVRready;
  48786. private _webVRrequesting;
  48787. private _webVRpresenting;
  48788. private _hasEnteredVR;
  48789. private _fullscreenVRpresenting;
  48790. private _inputElement;
  48791. private _webVRCamera;
  48792. private _vrDeviceOrientationCamera;
  48793. private _deviceOrientationCamera;
  48794. private _existingCamera;
  48795. private _onKeyDown;
  48796. private _onVrDisplayPresentChange;
  48797. private _onVRDisplayChanged;
  48798. private _onVRRequestPresentStart;
  48799. private _onVRRequestPresentComplete;
  48800. /**
  48801. * 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)
  48802. */
  48803. enableGazeEvenWhenNoPointerLock: boolean;
  48804. /**
  48805. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48806. */
  48807. exitVROnDoubleTap: boolean;
  48808. /**
  48809. * Observable raised right before entering VR.
  48810. */
  48811. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48812. /**
  48813. * Observable raised when entering VR has completed.
  48814. */
  48815. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48816. /**
  48817. * Observable raised when exiting VR.
  48818. */
  48819. onExitingVRObservable: Observable<VRExperienceHelper>;
  48820. /**
  48821. * Observable raised when controller mesh is loaded.
  48822. */
  48823. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48824. /** Return this.onEnteringVRObservable
  48825. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48826. */
  48827. get onEnteringVR(): Observable<VRExperienceHelper>;
  48828. /** Return this.onExitingVRObservable
  48829. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48830. */
  48831. get onExitingVR(): Observable<VRExperienceHelper>;
  48832. /** Return this.onControllerMeshLoadedObservable
  48833. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48834. */
  48835. get onControllerMeshLoaded(): Observable<WebVRController>;
  48836. private _rayLength;
  48837. private _useCustomVRButton;
  48838. private _teleportationRequested;
  48839. private _teleportActive;
  48840. private _floorMeshName;
  48841. private _floorMeshesCollection;
  48842. private _teleportationMode;
  48843. private _teleportationTime;
  48844. private _teleportationSpeed;
  48845. private _teleportationEasing;
  48846. private _rotationAllowed;
  48847. private _teleportBackwardsVector;
  48848. private _teleportationTarget;
  48849. private _isDefaultTeleportationTarget;
  48850. private _postProcessMove;
  48851. private _teleportationFillColor;
  48852. private _teleportationBorderColor;
  48853. private _rotationAngle;
  48854. private _haloCenter;
  48855. private _cameraGazer;
  48856. private _padSensibilityUp;
  48857. private _padSensibilityDown;
  48858. private _leftController;
  48859. private _rightController;
  48860. private _gazeColor;
  48861. private _laserColor;
  48862. private _pickedLaserColor;
  48863. private _pickedGazeColor;
  48864. /**
  48865. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48866. */
  48867. onNewMeshSelected: Observable<AbstractMesh>;
  48868. /**
  48869. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48870. * This observable will provide the mesh and the controller used to select the mesh
  48871. */
  48872. onMeshSelectedWithController: Observable<{
  48873. mesh: AbstractMesh;
  48874. controller: WebVRController;
  48875. }>;
  48876. /**
  48877. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48878. */
  48879. onNewMeshPicked: Observable<PickingInfo>;
  48880. private _circleEase;
  48881. /**
  48882. * Observable raised before camera teleportation
  48883. */
  48884. onBeforeCameraTeleport: Observable<Vector3>;
  48885. /**
  48886. * Observable raised after camera teleportation
  48887. */
  48888. onAfterCameraTeleport: Observable<Vector3>;
  48889. /**
  48890. * Observable raised when current selected mesh gets unselected
  48891. */
  48892. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48893. private _raySelectionPredicate;
  48894. /**
  48895. * To be optionaly changed by user to define custom ray selection
  48896. */
  48897. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48898. /**
  48899. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48900. */
  48901. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48902. /**
  48903. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48904. */
  48905. teleportationEnabled: boolean;
  48906. private _defaultHeight;
  48907. private _teleportationInitialized;
  48908. private _interactionsEnabled;
  48909. private _interactionsRequested;
  48910. private _displayGaze;
  48911. private _displayLaserPointer;
  48912. /**
  48913. * The mesh used to display where the user is going to teleport.
  48914. */
  48915. get teleportationTarget(): Mesh;
  48916. /**
  48917. * Sets the mesh to be used to display where the user is going to teleport.
  48918. */
  48919. set teleportationTarget(value: Mesh);
  48920. /**
  48921. * 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
  48922. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48923. * See https://doc.babylonjs.com/resources/baking_transformations
  48924. */
  48925. get gazeTrackerMesh(): Mesh;
  48926. set gazeTrackerMesh(value: Mesh);
  48927. /**
  48928. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48929. */
  48930. updateGazeTrackerScale: boolean;
  48931. /**
  48932. * If the gaze trackers color should be updated when selecting meshes
  48933. */
  48934. updateGazeTrackerColor: boolean;
  48935. /**
  48936. * If the controller laser color should be updated when selecting meshes
  48937. */
  48938. updateControllerLaserColor: boolean;
  48939. /**
  48940. * The gaze tracking mesh corresponding to the left controller
  48941. */
  48942. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48943. /**
  48944. * The gaze tracking mesh corresponding to the right controller
  48945. */
  48946. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48947. /**
  48948. * If the ray of the gaze should be displayed.
  48949. */
  48950. get displayGaze(): boolean;
  48951. /**
  48952. * Sets if the ray of the gaze should be displayed.
  48953. */
  48954. set displayGaze(value: boolean);
  48955. /**
  48956. * If the ray of the LaserPointer should be displayed.
  48957. */
  48958. get displayLaserPointer(): boolean;
  48959. /**
  48960. * Sets if the ray of the LaserPointer should be displayed.
  48961. */
  48962. set displayLaserPointer(value: boolean);
  48963. /**
  48964. * The deviceOrientationCamera used as the camera when not in VR.
  48965. */
  48966. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48967. /**
  48968. * Based on the current WebVR support, returns the current VR camera used.
  48969. */
  48970. get currentVRCamera(): Nullable<Camera>;
  48971. /**
  48972. * The webVRCamera which is used when in VR.
  48973. */
  48974. get webVRCamera(): WebVRFreeCamera;
  48975. /**
  48976. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48977. */
  48978. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48979. /**
  48980. * The html button that is used to trigger entering into VR.
  48981. */
  48982. get vrButton(): Nullable<HTMLButtonElement>;
  48983. private get _teleportationRequestInitiated();
  48984. /**
  48985. * Defines whether or not Pointer lock should be requested when switching to
  48986. * full screen.
  48987. */
  48988. requestPointerLockOnFullScreen: boolean;
  48989. /**
  48990. * If asking to force XR, this will be populated with the default xr experience
  48991. */
  48992. xr: WebXRDefaultExperience;
  48993. /**
  48994. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48995. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48996. */
  48997. xrTestDone: boolean;
  48998. /**
  48999. * Instantiates a VRExperienceHelper.
  49000. * Helps to quickly add VR support to an existing scene.
  49001. * @param scene The scene the VRExperienceHelper belongs to.
  49002. * @param webVROptions Options to modify the vr experience helper's behavior.
  49003. */
  49004. constructor(scene: Scene,
  49005. /** Options to modify the vr experience helper's behavior. */
  49006. webVROptions?: VRExperienceHelperOptions);
  49007. private completeVRInit;
  49008. private _onDefaultMeshLoaded;
  49009. private _onResize;
  49010. private _onFullscreenChange;
  49011. /**
  49012. * Gets a value indicating if we are currently in VR mode.
  49013. */
  49014. get isInVRMode(): boolean;
  49015. private onVrDisplayPresentChange;
  49016. private onVRDisplayChanged;
  49017. private moveButtonToBottomRight;
  49018. private displayVRButton;
  49019. private updateButtonVisibility;
  49020. private _cachedAngularSensibility;
  49021. /**
  49022. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49023. * Otherwise, will use the fullscreen API.
  49024. */
  49025. enterVR(): void;
  49026. /**
  49027. * Attempt to exit VR, or fullscreen.
  49028. */
  49029. exitVR(): void;
  49030. /**
  49031. * The position of the vr experience helper.
  49032. */
  49033. get position(): Vector3;
  49034. /**
  49035. * Sets the position of the vr experience helper.
  49036. */
  49037. set position(value: Vector3);
  49038. /**
  49039. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49040. */
  49041. enableInteractions(): void;
  49042. private get _noControllerIsActive();
  49043. private beforeRender;
  49044. private _isTeleportationFloor;
  49045. /**
  49046. * Adds a floor mesh to be used for teleportation.
  49047. * @param floorMesh the mesh to be used for teleportation.
  49048. */
  49049. addFloorMesh(floorMesh: Mesh): void;
  49050. /**
  49051. * Removes a floor mesh from being used for teleportation.
  49052. * @param floorMesh the mesh to be removed.
  49053. */
  49054. removeFloorMesh(floorMesh: Mesh): void;
  49055. /**
  49056. * Enables interactions and teleportation using the VR controllers and gaze.
  49057. * @param vrTeleportationOptions options to modify teleportation behavior.
  49058. */
  49059. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49060. private _onNewGamepadConnected;
  49061. private _tryEnableInteractionOnController;
  49062. private _onNewGamepadDisconnected;
  49063. private _enableInteractionOnController;
  49064. private _checkTeleportWithRay;
  49065. private _checkRotate;
  49066. private _checkTeleportBackwards;
  49067. private _enableTeleportationOnController;
  49068. private _createTeleportationCircles;
  49069. private _displayTeleportationTarget;
  49070. private _hideTeleportationTarget;
  49071. private _rotateCamera;
  49072. private _moveTeleportationSelectorTo;
  49073. private _workingVector;
  49074. private _workingQuaternion;
  49075. private _workingMatrix;
  49076. /**
  49077. * Time Constant Teleportation Mode
  49078. */
  49079. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49080. /**
  49081. * Speed Constant Teleportation Mode
  49082. */
  49083. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49084. /**
  49085. * Teleports the users feet to the desired location
  49086. * @param location The location where the user's feet should be placed
  49087. */
  49088. teleportCamera(location: Vector3): void;
  49089. private _convertNormalToDirectionOfRay;
  49090. private _castRayAndSelectObject;
  49091. private _notifySelectedMeshUnselected;
  49092. /**
  49093. * Permanently set new colors for the laser pointer
  49094. * @param color the new laser color
  49095. * @param pickedColor the new laser color when picked mesh detected
  49096. */
  49097. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49098. /**
  49099. * Set lighting enabled / disabled on the laser pointer of both controllers
  49100. * @param enabled should the lighting be enabled on the laser pointer
  49101. */
  49102. setLaserLightingState(enabled?: boolean): void;
  49103. /**
  49104. * Permanently set new colors for the gaze pointer
  49105. * @param color the new gaze color
  49106. * @param pickedColor the new gaze color when picked mesh detected
  49107. */
  49108. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49109. /**
  49110. * Sets the color of the laser ray from the vr controllers.
  49111. * @param color new color for the ray.
  49112. */
  49113. changeLaserColor(color: Color3): void;
  49114. /**
  49115. * Sets the color of the ray from the vr headsets gaze.
  49116. * @param color new color for the ray.
  49117. */
  49118. changeGazeColor(color: Color3): void;
  49119. /**
  49120. * Exits VR and disposes of the vr experience helper
  49121. */
  49122. dispose(): void;
  49123. /**
  49124. * Gets the name of the VRExperienceHelper class
  49125. * @returns "VRExperienceHelper"
  49126. */
  49127. getClassName(): string;
  49128. }
  49129. }
  49130. declare module BABYLON {
  49131. /**
  49132. * Contains an array of blocks representing the octree
  49133. */
  49134. export interface IOctreeContainer<T> {
  49135. /**
  49136. * Blocks within the octree
  49137. */
  49138. blocks: Array<OctreeBlock<T>>;
  49139. }
  49140. /**
  49141. * Class used to store a cell in an octree
  49142. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49143. */
  49144. export class OctreeBlock<T> {
  49145. /**
  49146. * Gets the content of the current block
  49147. */
  49148. entries: T[];
  49149. /**
  49150. * Gets the list of block children
  49151. */
  49152. blocks: Array<OctreeBlock<T>>;
  49153. private _depth;
  49154. private _maxDepth;
  49155. private _capacity;
  49156. private _minPoint;
  49157. private _maxPoint;
  49158. private _boundingVectors;
  49159. private _creationFunc;
  49160. /**
  49161. * Creates a new block
  49162. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49163. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49164. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49165. * @param depth defines the current depth of this block in the octree
  49166. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49167. * @param creationFunc defines a callback to call when an element is added to the block
  49168. */
  49169. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49170. /**
  49171. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49172. */
  49173. get capacity(): number;
  49174. /**
  49175. * Gets the minimum vector (in world space) of the block's bounding box
  49176. */
  49177. get minPoint(): Vector3;
  49178. /**
  49179. * Gets the maximum vector (in world space) of the block's bounding box
  49180. */
  49181. get maxPoint(): Vector3;
  49182. /**
  49183. * Add a new element to this block
  49184. * @param entry defines the element to add
  49185. */
  49186. addEntry(entry: T): void;
  49187. /**
  49188. * Remove an element from this block
  49189. * @param entry defines the element to remove
  49190. */
  49191. removeEntry(entry: T): void;
  49192. /**
  49193. * Add an array of elements to this block
  49194. * @param entries defines the array of elements to add
  49195. */
  49196. addEntries(entries: T[]): void;
  49197. /**
  49198. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49199. * @param frustumPlanes defines the frustum planes to test
  49200. * @param selection defines the array to store current content if selection is positive
  49201. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49202. */
  49203. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49204. /**
  49205. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49206. * @param sphereCenter defines the bounding sphere center
  49207. * @param sphereRadius defines the bounding sphere radius
  49208. * @param selection defines the array to store current content if selection is positive
  49209. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49210. */
  49211. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49212. /**
  49213. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49214. * @param ray defines the ray to test with
  49215. * @param selection defines the array to store current content if selection is positive
  49216. */
  49217. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49218. /**
  49219. * Subdivide the content into child blocks (this block will then be empty)
  49220. */
  49221. createInnerBlocks(): void;
  49222. /**
  49223. * @hidden
  49224. */
  49225. 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;
  49226. }
  49227. }
  49228. declare module BABYLON {
  49229. /**
  49230. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49231. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49232. */
  49233. export class Octree<T> {
  49234. /** 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.) */
  49235. maxDepth: number;
  49236. /**
  49237. * Blocks within the octree containing objects
  49238. */
  49239. blocks: Array<OctreeBlock<T>>;
  49240. /**
  49241. * Content stored in the octree
  49242. */
  49243. dynamicContent: T[];
  49244. private _maxBlockCapacity;
  49245. private _selectionContent;
  49246. private _creationFunc;
  49247. /**
  49248. * Creates a octree
  49249. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49250. * @param creationFunc function to be used to instatiate the octree
  49251. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49252. * @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.)
  49253. */
  49254. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49255. /** 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.) */
  49256. maxDepth?: number);
  49257. /**
  49258. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49259. * @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);
  49260. * @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);
  49261. * @param entries meshes to be added to the octree blocks
  49262. */
  49263. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49264. /**
  49265. * Adds a mesh to the octree
  49266. * @param entry Mesh to add to the octree
  49267. */
  49268. addMesh(entry: T): void;
  49269. /**
  49270. * Remove an element from the octree
  49271. * @param entry defines the element to remove
  49272. */
  49273. removeMesh(entry: T): void;
  49274. /**
  49275. * Selects an array of meshes within the frustum
  49276. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49277. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49278. * @returns array of meshes within the frustum
  49279. */
  49280. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49281. /**
  49282. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49283. * @param sphereCenter defines the bounding sphere center
  49284. * @param sphereRadius defines the bounding sphere radius
  49285. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49286. * @returns an array of objects that intersect the sphere
  49287. */
  49288. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49289. /**
  49290. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49291. * @param ray defines the ray to test with
  49292. * @returns array of intersected objects
  49293. */
  49294. intersectsRay(ray: Ray): SmartArray<T>;
  49295. /**
  49296. * Adds a mesh into the octree block if it intersects the block
  49297. */
  49298. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49299. /**
  49300. * Adds a submesh into the octree block if it intersects the block
  49301. */
  49302. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49303. }
  49304. }
  49305. declare module BABYLON {
  49306. interface Scene {
  49307. /**
  49308. * @hidden
  49309. * Backing Filed
  49310. */
  49311. _selectionOctree: Octree<AbstractMesh>;
  49312. /**
  49313. * Gets the octree used to boost mesh selection (picking)
  49314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49315. */
  49316. selectionOctree: Octree<AbstractMesh>;
  49317. /**
  49318. * Creates or updates the octree used to boost selection (picking)
  49319. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49320. * @param maxCapacity defines the maximum capacity per leaf
  49321. * @param maxDepth defines the maximum depth of the octree
  49322. * @returns an octree of AbstractMesh
  49323. */
  49324. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49325. }
  49326. interface AbstractMesh {
  49327. /**
  49328. * @hidden
  49329. * Backing Field
  49330. */
  49331. _submeshesOctree: Octree<SubMesh>;
  49332. /**
  49333. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49334. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49335. * @param maxCapacity defines the maximum size of each block (64 by default)
  49336. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49337. * @returns the new octree
  49338. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49339. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49340. */
  49341. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49342. }
  49343. /**
  49344. * Defines the octree scene component responsible to manage any octrees
  49345. * in a given scene.
  49346. */
  49347. export class OctreeSceneComponent {
  49348. /**
  49349. * The component name help to identify the component in the list of scene components.
  49350. */
  49351. readonly name: string;
  49352. /**
  49353. * The scene the component belongs to.
  49354. */
  49355. scene: Scene;
  49356. /**
  49357. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49358. */
  49359. readonly checksIsEnabled: boolean;
  49360. /**
  49361. * Creates a new instance of the component for the given scene
  49362. * @param scene Defines the scene to register the component in
  49363. */
  49364. constructor(scene: Scene);
  49365. /**
  49366. * Registers the component in a given scene
  49367. */
  49368. register(): void;
  49369. /**
  49370. * Return the list of active meshes
  49371. * @returns the list of active meshes
  49372. */
  49373. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49374. /**
  49375. * Return the list of active sub meshes
  49376. * @param mesh The mesh to get the candidates sub meshes from
  49377. * @returns the list of active sub meshes
  49378. */
  49379. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49380. private _tempRay;
  49381. /**
  49382. * Return the list of sub meshes intersecting with a given local ray
  49383. * @param mesh defines the mesh to find the submesh for
  49384. * @param localRay defines the ray in local space
  49385. * @returns the list of intersecting sub meshes
  49386. */
  49387. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49388. /**
  49389. * Return the list of sub meshes colliding with a collider
  49390. * @param mesh defines the mesh to find the submesh for
  49391. * @param collider defines the collider to evaluate the collision against
  49392. * @returns the list of colliding sub meshes
  49393. */
  49394. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49395. /**
  49396. * Rebuilds the elements related to this component in case of
  49397. * context lost for instance.
  49398. */
  49399. rebuild(): void;
  49400. /**
  49401. * Disposes the component and the associated ressources.
  49402. */
  49403. dispose(): void;
  49404. }
  49405. }
  49406. declare module BABYLON {
  49407. /**
  49408. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49409. */
  49410. export class Gizmo implements IDisposable {
  49411. /** The utility layer the gizmo will be added to */
  49412. gizmoLayer: UtilityLayerRenderer;
  49413. /**
  49414. * The root mesh of the gizmo
  49415. */
  49416. _rootMesh: Mesh;
  49417. private _attachedMesh;
  49418. /**
  49419. * Ratio for the scale of the gizmo (Default: 1)
  49420. */
  49421. scaleRatio: number;
  49422. /**
  49423. * If a custom mesh has been set (Default: false)
  49424. */
  49425. protected _customMeshSet: boolean;
  49426. /**
  49427. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49428. * * When set, interactions will be enabled
  49429. */
  49430. get attachedMesh(): Nullable<AbstractMesh>;
  49431. set attachedMesh(value: Nullable<AbstractMesh>);
  49432. /**
  49433. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49434. * @param mesh The mesh to replace the default mesh of the gizmo
  49435. */
  49436. setCustomMesh(mesh: Mesh): void;
  49437. /**
  49438. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49439. */
  49440. updateGizmoRotationToMatchAttachedMesh: boolean;
  49441. /**
  49442. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49443. */
  49444. updateGizmoPositionToMatchAttachedMesh: boolean;
  49445. /**
  49446. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49447. */
  49448. updateScale: boolean;
  49449. protected _interactionsEnabled: boolean;
  49450. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49451. private _beforeRenderObserver;
  49452. private _tempVector;
  49453. /**
  49454. * Creates a gizmo
  49455. * @param gizmoLayer The utility layer the gizmo will be added to
  49456. */
  49457. constructor(
  49458. /** The utility layer the gizmo will be added to */
  49459. gizmoLayer?: UtilityLayerRenderer);
  49460. /**
  49461. * Updates the gizmo to match the attached mesh's position/rotation
  49462. */
  49463. protected _update(): void;
  49464. /**
  49465. * Disposes of the gizmo
  49466. */
  49467. dispose(): void;
  49468. }
  49469. }
  49470. declare module BABYLON {
  49471. /**
  49472. * Single plane drag gizmo
  49473. */
  49474. export class PlaneDragGizmo extends Gizmo {
  49475. /**
  49476. * Drag behavior responsible for the gizmos dragging interactions
  49477. */
  49478. dragBehavior: PointerDragBehavior;
  49479. private _pointerObserver;
  49480. /**
  49481. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49482. */
  49483. snapDistance: number;
  49484. /**
  49485. * Event that fires each time the gizmo snaps to a new location.
  49486. * * snapDistance is the the change in distance
  49487. */
  49488. onSnapObservable: Observable<{
  49489. snapDistance: number;
  49490. }>;
  49491. private _plane;
  49492. private _coloredMaterial;
  49493. private _hoverMaterial;
  49494. private _isEnabled;
  49495. private _parent;
  49496. /** @hidden */
  49497. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49498. /** @hidden */
  49499. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49500. /**
  49501. * Creates a PlaneDragGizmo
  49502. * @param gizmoLayer The utility layer the gizmo will be added to
  49503. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49504. * @param color The color of the gizmo
  49505. */
  49506. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49507. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49508. /**
  49509. * If the gizmo is enabled
  49510. */
  49511. set isEnabled(value: boolean);
  49512. get isEnabled(): boolean;
  49513. /**
  49514. * Disposes of the gizmo
  49515. */
  49516. dispose(): void;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * Gizmo that enables dragging a mesh along 3 axis
  49522. */
  49523. export class PositionGizmo extends Gizmo {
  49524. /**
  49525. * Internal gizmo used for interactions on the x axis
  49526. */
  49527. xGizmo: AxisDragGizmo;
  49528. /**
  49529. * Internal gizmo used for interactions on the y axis
  49530. */
  49531. yGizmo: AxisDragGizmo;
  49532. /**
  49533. * Internal gizmo used for interactions on the z axis
  49534. */
  49535. zGizmo: AxisDragGizmo;
  49536. /**
  49537. * Internal gizmo used for interactions on the yz plane
  49538. */
  49539. xPlaneGizmo: PlaneDragGizmo;
  49540. /**
  49541. * Internal gizmo used for interactions on the xz plane
  49542. */
  49543. yPlaneGizmo: PlaneDragGizmo;
  49544. /**
  49545. * Internal gizmo used for interactions on the xy plane
  49546. */
  49547. zPlaneGizmo: PlaneDragGizmo;
  49548. /**
  49549. * private variables
  49550. */
  49551. private _meshAttached;
  49552. private _updateGizmoRotationToMatchAttachedMesh;
  49553. private _snapDistance;
  49554. private _scaleRatio;
  49555. /** Fires an event when any of it's sub gizmos are dragged */
  49556. onDragStartObservable: Observable<unknown>;
  49557. /** Fires an event when any of it's sub gizmos are released from dragging */
  49558. onDragEndObservable: Observable<unknown>;
  49559. /**
  49560. * If set to true, planar drag is enabled
  49561. */
  49562. private _planarGizmoEnabled;
  49563. get attachedMesh(): Nullable<AbstractMesh>;
  49564. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49565. /**
  49566. * Creates a PositionGizmo
  49567. * @param gizmoLayer The utility layer the gizmo will be added to
  49568. */
  49569. constructor(gizmoLayer?: UtilityLayerRenderer);
  49570. /**
  49571. * If the planar drag gizmo is enabled
  49572. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49573. */
  49574. set planarGizmoEnabled(value: boolean);
  49575. get planarGizmoEnabled(): boolean;
  49576. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49577. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49578. /**
  49579. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49580. */
  49581. set snapDistance(value: number);
  49582. get snapDistance(): number;
  49583. /**
  49584. * Ratio for the scale of the gizmo (Default: 1)
  49585. */
  49586. set scaleRatio(value: number);
  49587. get scaleRatio(): number;
  49588. /**
  49589. * Disposes of the gizmo
  49590. */
  49591. dispose(): void;
  49592. /**
  49593. * CustomMeshes are not supported by this gizmo
  49594. * @param mesh The mesh to replace the default mesh of the gizmo
  49595. */
  49596. setCustomMesh(mesh: Mesh): void;
  49597. }
  49598. }
  49599. declare module BABYLON {
  49600. /**
  49601. * Single axis drag gizmo
  49602. */
  49603. export class AxisDragGizmo extends Gizmo {
  49604. /**
  49605. * Drag behavior responsible for the gizmos dragging interactions
  49606. */
  49607. dragBehavior: PointerDragBehavior;
  49608. private _pointerObserver;
  49609. /**
  49610. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49611. */
  49612. snapDistance: number;
  49613. /**
  49614. * Event that fires each time the gizmo snaps to a new location.
  49615. * * snapDistance is the the change in distance
  49616. */
  49617. onSnapObservable: Observable<{
  49618. snapDistance: number;
  49619. }>;
  49620. private _isEnabled;
  49621. private _parent;
  49622. private _arrow;
  49623. private _coloredMaterial;
  49624. private _hoverMaterial;
  49625. /** @hidden */
  49626. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49627. /** @hidden */
  49628. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49629. /**
  49630. * Creates an AxisDragGizmo
  49631. * @param gizmoLayer The utility layer the gizmo will be added to
  49632. * @param dragAxis The axis which the gizmo will be able to drag on
  49633. * @param color The color of the gizmo
  49634. */
  49635. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49637. /**
  49638. * If the gizmo is enabled
  49639. */
  49640. set isEnabled(value: boolean);
  49641. get isEnabled(): boolean;
  49642. /**
  49643. * Disposes of the gizmo
  49644. */
  49645. dispose(): void;
  49646. }
  49647. }
  49648. declare module BABYLON.Debug {
  49649. /**
  49650. * The Axes viewer will show 3 axes in a specific point in space
  49651. */
  49652. export class AxesViewer {
  49653. private _xAxis;
  49654. private _yAxis;
  49655. private _zAxis;
  49656. private _scaleLinesFactor;
  49657. private _instanced;
  49658. /**
  49659. * Gets the hosting scene
  49660. */
  49661. scene: Scene;
  49662. /**
  49663. * Gets or sets a number used to scale line length
  49664. */
  49665. scaleLines: number;
  49666. /** Gets the node hierarchy used to render x-axis */
  49667. get xAxis(): TransformNode;
  49668. /** Gets the node hierarchy used to render y-axis */
  49669. get yAxis(): TransformNode;
  49670. /** Gets the node hierarchy used to render z-axis */
  49671. get zAxis(): TransformNode;
  49672. /**
  49673. * Creates a new AxesViewer
  49674. * @param scene defines the hosting scene
  49675. * @param scaleLines defines a number used to scale line length (1 by default)
  49676. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49677. * @param xAxis defines the node hierarchy used to render the x-axis
  49678. * @param yAxis defines the node hierarchy used to render the y-axis
  49679. * @param zAxis defines the node hierarchy used to render the z-axis
  49680. */
  49681. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49682. /**
  49683. * Force the viewer to update
  49684. * @param position defines the position of the viewer
  49685. * @param xaxis defines the x axis of the viewer
  49686. * @param yaxis defines the y axis of the viewer
  49687. * @param zaxis defines the z axis of the viewer
  49688. */
  49689. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49690. /**
  49691. * Creates an instance of this axes viewer.
  49692. * @returns a new axes viewer with instanced meshes
  49693. */
  49694. createInstance(): AxesViewer;
  49695. /** Releases resources */
  49696. dispose(): void;
  49697. private static _SetRenderingGroupId;
  49698. }
  49699. }
  49700. declare module BABYLON.Debug {
  49701. /**
  49702. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49703. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49704. */
  49705. export class BoneAxesViewer extends AxesViewer {
  49706. /**
  49707. * Gets or sets the target mesh where to display the axes viewer
  49708. */
  49709. mesh: Nullable<Mesh>;
  49710. /**
  49711. * Gets or sets the target bone where to display the axes viewer
  49712. */
  49713. bone: Nullable<Bone>;
  49714. /** Gets current position */
  49715. pos: Vector3;
  49716. /** Gets direction of X axis */
  49717. xaxis: Vector3;
  49718. /** Gets direction of Y axis */
  49719. yaxis: Vector3;
  49720. /** Gets direction of Z axis */
  49721. zaxis: Vector3;
  49722. /**
  49723. * Creates a new BoneAxesViewer
  49724. * @param scene defines the hosting scene
  49725. * @param bone defines the target bone
  49726. * @param mesh defines the target mesh
  49727. * @param scaleLines defines a scaling factor for line length (1 by default)
  49728. */
  49729. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49730. /**
  49731. * Force the viewer to update
  49732. */
  49733. update(): void;
  49734. /** Releases resources */
  49735. dispose(): void;
  49736. }
  49737. }
  49738. declare module BABYLON {
  49739. /**
  49740. * Interface used to define scene explorer extensibility option
  49741. */
  49742. export interface IExplorerExtensibilityOption {
  49743. /**
  49744. * Define the option label
  49745. */
  49746. label: string;
  49747. /**
  49748. * Defines the action to execute on click
  49749. */
  49750. action: (entity: any) => void;
  49751. }
  49752. /**
  49753. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49754. */
  49755. export interface IExplorerExtensibilityGroup {
  49756. /**
  49757. * Defines a predicate to test if a given type mut be extended
  49758. */
  49759. predicate: (entity: any) => boolean;
  49760. /**
  49761. * Gets the list of options added to a type
  49762. */
  49763. entries: IExplorerExtensibilityOption[];
  49764. }
  49765. /**
  49766. * Interface used to define the options to use to create the Inspector
  49767. */
  49768. export interface IInspectorOptions {
  49769. /**
  49770. * Display in overlay mode (default: false)
  49771. */
  49772. overlay?: boolean;
  49773. /**
  49774. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49775. */
  49776. globalRoot?: HTMLElement;
  49777. /**
  49778. * Display the Scene explorer
  49779. */
  49780. showExplorer?: boolean;
  49781. /**
  49782. * Display the property inspector
  49783. */
  49784. showInspector?: boolean;
  49785. /**
  49786. * Display in embed mode (both panes on the right)
  49787. */
  49788. embedMode?: boolean;
  49789. /**
  49790. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49791. */
  49792. handleResize?: boolean;
  49793. /**
  49794. * Allow the panes to popup (default: true)
  49795. */
  49796. enablePopup?: boolean;
  49797. /**
  49798. * Allow the panes to be closed by users (default: true)
  49799. */
  49800. enableClose?: boolean;
  49801. /**
  49802. * Optional list of extensibility entries
  49803. */
  49804. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49805. /**
  49806. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49807. */
  49808. inspectorURL?: string;
  49809. /**
  49810. * Optional initial tab (default to DebugLayerTab.Properties)
  49811. */
  49812. initialTab?: DebugLayerTab;
  49813. }
  49814. interface Scene {
  49815. /**
  49816. * @hidden
  49817. * Backing field
  49818. */
  49819. _debugLayer: DebugLayer;
  49820. /**
  49821. * Gets the debug layer (aka Inspector) associated with the scene
  49822. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49823. */
  49824. debugLayer: DebugLayer;
  49825. }
  49826. /**
  49827. * Enum of inspector action tab
  49828. */
  49829. export enum DebugLayerTab {
  49830. /**
  49831. * Properties tag (default)
  49832. */
  49833. Properties = 0,
  49834. /**
  49835. * Debug tab
  49836. */
  49837. Debug = 1,
  49838. /**
  49839. * Statistics tab
  49840. */
  49841. Statistics = 2,
  49842. /**
  49843. * Tools tab
  49844. */
  49845. Tools = 3,
  49846. /**
  49847. * Settings tab
  49848. */
  49849. Settings = 4
  49850. }
  49851. /**
  49852. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49853. * what is happening in your scene
  49854. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49855. */
  49856. export class DebugLayer {
  49857. /**
  49858. * Define the url to get the inspector script from.
  49859. * By default it uses the babylonjs CDN.
  49860. * @ignoreNaming
  49861. */
  49862. static InspectorURL: string;
  49863. private _scene;
  49864. private BJSINSPECTOR;
  49865. private _onPropertyChangedObservable?;
  49866. /**
  49867. * Observable triggered when a property is changed through the inspector.
  49868. */
  49869. get onPropertyChangedObservable(): any;
  49870. /**
  49871. * Instantiates a new debug layer.
  49872. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49873. * what is happening in your scene
  49874. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49875. * @param scene Defines the scene to inspect
  49876. */
  49877. constructor(scene: Scene);
  49878. /** Creates the inspector window. */
  49879. private _createInspector;
  49880. /**
  49881. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49882. * @param entity defines the entity to select
  49883. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49884. */
  49885. select(entity: any, lineContainerTitles?: string | string[]): void;
  49886. /** Get the inspector from bundle or global */
  49887. private _getGlobalInspector;
  49888. /**
  49889. * Get if the inspector is visible or not.
  49890. * @returns true if visible otherwise, false
  49891. */
  49892. isVisible(): boolean;
  49893. /**
  49894. * Hide the inspector and close its window.
  49895. */
  49896. hide(): void;
  49897. /**
  49898. * Update the scene in the inspector
  49899. */
  49900. setAsActiveScene(): void;
  49901. /**
  49902. * Launch the debugLayer.
  49903. * @param config Define the configuration of the inspector
  49904. * @return a promise fulfilled when the debug layer is visible
  49905. */
  49906. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49907. }
  49908. }
  49909. declare module BABYLON {
  49910. /**
  49911. * Class containing static functions to help procedurally build meshes
  49912. */
  49913. export class BoxBuilder {
  49914. /**
  49915. * Creates a box mesh
  49916. * * The parameter `size` sets the size (float) of each box side (default 1)
  49917. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49918. * * 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)
  49919. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49921. * * 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
  49922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49923. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49924. * @param name defines the name of the mesh
  49925. * @param options defines the options used to create the mesh
  49926. * @param scene defines the hosting scene
  49927. * @returns the box mesh
  49928. */
  49929. static CreateBox(name: string, options: {
  49930. size?: number;
  49931. width?: number;
  49932. height?: number;
  49933. depth?: number;
  49934. faceUV?: Vector4[];
  49935. faceColors?: Color4[];
  49936. sideOrientation?: number;
  49937. frontUVs?: Vector4;
  49938. backUVs?: Vector4;
  49939. wrap?: boolean;
  49940. topBaseAt?: number;
  49941. bottomBaseAt?: number;
  49942. updatable?: boolean;
  49943. }, scene?: Nullable<Scene>): Mesh;
  49944. }
  49945. }
  49946. declare module BABYLON.Debug {
  49947. /**
  49948. * Used to show the physics impostor around the specific mesh
  49949. */
  49950. export class PhysicsViewer {
  49951. /** @hidden */
  49952. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49953. /** @hidden */
  49954. protected _meshes: Array<Nullable<AbstractMesh>>;
  49955. /** @hidden */
  49956. protected _scene: Nullable<Scene>;
  49957. /** @hidden */
  49958. protected _numMeshes: number;
  49959. /** @hidden */
  49960. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49961. private _renderFunction;
  49962. private _utilityLayer;
  49963. private _debugBoxMesh;
  49964. private _debugSphereMesh;
  49965. private _debugCylinderMesh;
  49966. private _debugMaterial;
  49967. private _debugMeshMeshes;
  49968. /**
  49969. * Creates a new PhysicsViewer
  49970. * @param scene defines the hosting scene
  49971. */
  49972. constructor(scene: Scene);
  49973. /** @hidden */
  49974. protected _updateDebugMeshes(): void;
  49975. /**
  49976. * Renders a specified physic impostor
  49977. * @param impostor defines the impostor to render
  49978. * @param targetMesh defines the mesh represented by the impostor
  49979. * @returns the new debug mesh used to render the impostor
  49980. */
  49981. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49982. /**
  49983. * Hides a specified physic impostor
  49984. * @param impostor defines the impostor to hide
  49985. */
  49986. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49987. private _getDebugMaterial;
  49988. private _getDebugBoxMesh;
  49989. private _getDebugSphereMesh;
  49990. private _getDebugCylinderMesh;
  49991. private _getDebugMeshMesh;
  49992. private _getDebugMesh;
  49993. /** Releases all resources */
  49994. dispose(): void;
  49995. }
  49996. }
  49997. declare module BABYLON {
  49998. /**
  49999. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50000. * in order to better appreciate the issue one might have.
  50001. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50002. */
  50003. export class RayHelper {
  50004. /**
  50005. * Defines the ray we are currently tryin to visualize.
  50006. */
  50007. ray: Nullable<Ray>;
  50008. private _renderPoints;
  50009. private _renderLine;
  50010. private _renderFunction;
  50011. private _scene;
  50012. private _updateToMeshFunction;
  50013. private _attachedToMesh;
  50014. private _meshSpaceDirection;
  50015. private _meshSpaceOrigin;
  50016. /**
  50017. * Helper function to create a colored helper in a scene in one line.
  50018. * @param ray Defines the ray we are currently tryin to visualize
  50019. * @param scene Defines the scene the ray is used in
  50020. * @param color Defines the color we want to see the ray in
  50021. * @returns The newly created ray helper.
  50022. */
  50023. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50024. /**
  50025. * Instantiate a new ray helper.
  50026. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50027. * in order to better appreciate the issue one might have.
  50028. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50029. * @param ray Defines the ray we are currently tryin to visualize
  50030. */
  50031. constructor(ray: Ray);
  50032. /**
  50033. * Shows the ray we are willing to debug.
  50034. * @param scene Defines the scene the ray needs to be rendered in
  50035. * @param color Defines the color the ray needs to be rendered in
  50036. */
  50037. show(scene: Scene, color?: Color3): void;
  50038. /**
  50039. * Hides the ray we are debugging.
  50040. */
  50041. hide(): void;
  50042. private _render;
  50043. /**
  50044. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50045. * @param mesh Defines the mesh we want the helper attached to
  50046. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50047. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50048. * @param length Defines the length of the ray
  50049. */
  50050. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50051. /**
  50052. * Detach the ray helper from the mesh it has previously been attached to.
  50053. */
  50054. detachFromMesh(): void;
  50055. private _updateToMesh;
  50056. /**
  50057. * Dispose the helper and release its associated resources.
  50058. */
  50059. dispose(): void;
  50060. }
  50061. }
  50062. declare module BABYLON.Debug {
  50063. /**
  50064. * Class used to render a debug view of a given skeleton
  50065. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50066. */
  50067. export class SkeletonViewer {
  50068. /** defines the skeleton to render */
  50069. skeleton: Skeleton;
  50070. /** defines the mesh attached to the skeleton */
  50071. mesh: AbstractMesh;
  50072. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50073. autoUpdateBonesMatrices: boolean;
  50074. /** defines the rendering group id to use with the viewer */
  50075. renderingGroupId: number;
  50076. /** Gets or sets the color used to render the skeleton */
  50077. color: Color3;
  50078. private _scene;
  50079. private _debugLines;
  50080. private _debugMesh;
  50081. private _isEnabled;
  50082. private _renderFunction;
  50083. private _utilityLayer;
  50084. /**
  50085. * Returns the mesh used to render the bones
  50086. */
  50087. get debugMesh(): Nullable<LinesMesh>;
  50088. /**
  50089. * Creates a new SkeletonViewer
  50090. * @param skeleton defines the skeleton to render
  50091. * @param mesh defines the mesh attached to the skeleton
  50092. * @param scene defines the hosting scene
  50093. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50094. * @param renderingGroupId defines the rendering group id to use with the viewer
  50095. */
  50096. constructor(
  50097. /** defines the skeleton to render */
  50098. skeleton: Skeleton,
  50099. /** defines the mesh attached to the skeleton */
  50100. mesh: AbstractMesh, scene: Scene,
  50101. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50102. autoUpdateBonesMatrices?: boolean,
  50103. /** defines the rendering group id to use with the viewer */
  50104. renderingGroupId?: number);
  50105. /** Gets or sets a boolean indicating if the viewer is enabled */
  50106. set isEnabled(value: boolean);
  50107. get isEnabled(): boolean;
  50108. private _getBonePosition;
  50109. private _getLinesForBonesWithLength;
  50110. private _getLinesForBonesNoLength;
  50111. /** Update the viewer to sync with current skeleton state */
  50112. update(): void;
  50113. /** Release associated resources */
  50114. dispose(): void;
  50115. }
  50116. }
  50117. declare module BABYLON {
  50118. /**
  50119. * Enum for Device Types
  50120. */
  50121. export enum DeviceType {
  50122. /** Generic */
  50123. Generic = 0,
  50124. /** Keyboard */
  50125. Keyboard = 1,
  50126. /** Mouse */
  50127. Mouse = 2,
  50128. /** Touch Pointers */
  50129. Touch = 3,
  50130. /** PS4 Dual Shock */
  50131. DualShock = 4,
  50132. /** Xbox */
  50133. Xbox = 5,
  50134. /** Switch Controller */
  50135. Switch = 6
  50136. }
  50137. /**
  50138. * Enum for All Pointers (Touch/Mouse)
  50139. */
  50140. export enum PointerInput {
  50141. /** Horizontal Axis */
  50142. Horizontal = 0,
  50143. /** Vertical Axis */
  50144. Vertical = 1,
  50145. /** Left Click or Touch */
  50146. LeftClick = 2,
  50147. /** Middle Click */
  50148. MiddleClick = 3,
  50149. /** Right Click */
  50150. RightClick = 4,
  50151. /** Browser Back */
  50152. BrowserBack = 5,
  50153. /** Browser Forward */
  50154. BrowserForward = 6
  50155. }
  50156. /**
  50157. * Enum for Dual Shock Gamepad
  50158. */
  50159. export enum DualShockInput {
  50160. /** Cross */
  50161. Cross = 0,
  50162. /** Circle */
  50163. Circle = 1,
  50164. /** Square */
  50165. Square = 2,
  50166. /** Triangle */
  50167. Triangle = 3,
  50168. /** L1 */
  50169. L1 = 4,
  50170. /** R1 */
  50171. R1 = 5,
  50172. /** L2 */
  50173. L2 = 6,
  50174. /** R2 */
  50175. R2 = 7,
  50176. /** Share */
  50177. Share = 8,
  50178. /** Options */
  50179. Options = 9,
  50180. /** L3 */
  50181. L3 = 10,
  50182. /** R3 */
  50183. R3 = 11,
  50184. /** DPadUp */
  50185. DPadUp = 12,
  50186. /** DPadDown */
  50187. DPadDown = 13,
  50188. /** DPadLeft */
  50189. DPadLeft = 14,
  50190. /** DRight */
  50191. DPadRight = 15,
  50192. /** Home */
  50193. Home = 16,
  50194. /** TouchPad */
  50195. TouchPad = 17,
  50196. /** LStickXAxis */
  50197. LStickXAxis = 18,
  50198. /** LStickYAxis */
  50199. LStickYAxis = 19,
  50200. /** RStickXAxis */
  50201. RStickXAxis = 20,
  50202. /** RStickYAxis */
  50203. RStickYAxis = 21
  50204. }
  50205. /**
  50206. * Enum for Xbox Gamepad
  50207. */
  50208. export enum XboxInput {
  50209. /** A */
  50210. A = 0,
  50211. /** B */
  50212. B = 1,
  50213. /** X */
  50214. X = 2,
  50215. /** Y */
  50216. Y = 3,
  50217. /** LB */
  50218. LB = 4,
  50219. /** RB */
  50220. RB = 5,
  50221. /** LT */
  50222. LT = 6,
  50223. /** RT */
  50224. RT = 7,
  50225. /** Back */
  50226. Back = 8,
  50227. /** Start */
  50228. Start = 9,
  50229. /** LS */
  50230. LS = 10,
  50231. /** RS */
  50232. RS = 11,
  50233. /** DPadUp */
  50234. DPadUp = 12,
  50235. /** DPadDown */
  50236. DPadDown = 13,
  50237. /** DPadLeft */
  50238. DPadLeft = 14,
  50239. /** DRight */
  50240. DPadRight = 15,
  50241. /** Home */
  50242. Home = 16,
  50243. /** LStickXAxis */
  50244. LStickXAxis = 17,
  50245. /** LStickYAxis */
  50246. LStickYAxis = 18,
  50247. /** RStickXAxis */
  50248. RStickXAxis = 19,
  50249. /** RStickYAxis */
  50250. RStickYAxis = 20
  50251. }
  50252. /**
  50253. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50254. */
  50255. export enum SwitchInput {
  50256. /** B */
  50257. B = 0,
  50258. /** A */
  50259. A = 1,
  50260. /** Y */
  50261. Y = 2,
  50262. /** X */
  50263. X = 3,
  50264. /** L */
  50265. L = 4,
  50266. /** R */
  50267. R = 5,
  50268. /** ZL */
  50269. ZL = 6,
  50270. /** ZR */
  50271. ZR = 7,
  50272. /** Minus */
  50273. Minus = 8,
  50274. /** Plus */
  50275. Plus = 9,
  50276. /** LS */
  50277. LS = 10,
  50278. /** RS */
  50279. RS = 11,
  50280. /** DPadUp */
  50281. DPadUp = 12,
  50282. /** DPadDown */
  50283. DPadDown = 13,
  50284. /** DPadLeft */
  50285. DPadLeft = 14,
  50286. /** DRight */
  50287. DPadRight = 15,
  50288. /** Home */
  50289. Home = 16,
  50290. /** Capture */
  50291. Capture = 17,
  50292. /** LStickXAxis */
  50293. LStickXAxis = 18,
  50294. /** LStickYAxis */
  50295. LStickYAxis = 19,
  50296. /** RStickXAxis */
  50297. RStickXAxis = 20,
  50298. /** RStickYAxis */
  50299. RStickYAxis = 21
  50300. }
  50301. }
  50302. declare module BABYLON {
  50303. /**
  50304. * This class will take all inputs from Keyboard, Pointer, and
  50305. * any Gamepads and provide a polling system that all devices
  50306. * will use. This class assumes that there will only be one
  50307. * pointer device and one keyboard.
  50308. */
  50309. export class DeviceInputSystem implements IDisposable {
  50310. /**
  50311. * Callback to be triggered when a device is connected
  50312. */
  50313. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50314. /**
  50315. * Callback to be triggered when a device is disconnected
  50316. */
  50317. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50318. /**
  50319. * Callback to be triggered when event driven input is updated
  50320. */
  50321. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50322. private _inputs;
  50323. private _gamepads;
  50324. private _keyboardActive;
  50325. private _pointerActive;
  50326. private _elementToAttachTo;
  50327. private _keyboardDownEvent;
  50328. private _keyboardUpEvent;
  50329. private _pointerMoveEvent;
  50330. private _pointerDownEvent;
  50331. private _pointerUpEvent;
  50332. private _gamepadConnectedEvent;
  50333. private _gamepadDisconnectedEvent;
  50334. private static _MAX_KEYCODES;
  50335. private static _MAX_POINTER_INPUTS;
  50336. private constructor();
  50337. /**
  50338. * Creates a new DeviceInputSystem instance
  50339. * @param engine Engine to pull input element from
  50340. * @returns The new instance
  50341. */
  50342. static Create(engine: Engine): DeviceInputSystem;
  50343. /**
  50344. * Checks for current device input value, given an id and input index
  50345. * @param deviceName Id of connected device
  50346. * @param inputIndex Index of device input
  50347. * @returns Current value of input
  50348. */
  50349. /**
  50350. * Checks for current device input value, given an id and input index
  50351. * @param deviceType Enum specifiying device type
  50352. * @param deviceSlot "Slot" or index that device is referenced in
  50353. * @param inputIndex Id of input to be checked
  50354. * @returns Current value of input
  50355. */
  50356. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50357. /**
  50358. * Dispose of all the eventlisteners
  50359. */
  50360. dispose(): void;
  50361. /**
  50362. * Add device and inputs to device array
  50363. * @param deviceType Enum specifiying device type
  50364. * @param deviceSlot "Slot" or index that device is referenced in
  50365. * @param numberOfInputs Number of input entries to create for given device
  50366. */
  50367. private _registerDevice;
  50368. /**
  50369. * Given a specific device name, remove that device from the device map
  50370. * @param deviceType Enum specifiying device type
  50371. * @param deviceSlot "Slot" or index that device is referenced in
  50372. */
  50373. private _unregisterDevice;
  50374. /**
  50375. * Handle all actions that come from keyboard interaction
  50376. */
  50377. private _handleKeyActions;
  50378. /**
  50379. * Handle all actions that come from pointer interaction
  50380. */
  50381. private _handlePointerActions;
  50382. /**
  50383. * Handle all actions that come from gamepad interaction
  50384. */
  50385. private _handleGamepadActions;
  50386. /**
  50387. * Update all non-event based devices with each frame
  50388. * @param deviceType Enum specifiying device type
  50389. * @param deviceSlot "Slot" or index that device is referenced in
  50390. * @param inputIndex Id of input to be checked
  50391. */
  50392. private _updateDevice;
  50393. /**
  50394. * Gets DeviceType from the device name
  50395. * @param deviceName Name of Device from DeviceInputSystem
  50396. * @returns DeviceType enum value
  50397. */
  50398. private _getGamepadDeviceType;
  50399. }
  50400. }
  50401. declare module BABYLON {
  50402. /**
  50403. * Type to handle enforcement of inputs
  50404. */
  50405. 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;
  50406. }
  50407. declare module BABYLON {
  50408. /**
  50409. * Class that handles all input for a specific device
  50410. */
  50411. export class DeviceSource<T extends DeviceType> {
  50412. /** Type of device */
  50413. readonly deviceType: DeviceType;
  50414. /** "Slot" or index that device is referenced in */
  50415. readonly deviceSlot: number;
  50416. /**
  50417. * Observable to handle device input changes per device
  50418. */
  50419. readonly onInputChangedObservable: Observable<{
  50420. inputIndex: DeviceInput<T>;
  50421. previousState: Nullable<number>;
  50422. currentState: Nullable<number>;
  50423. }>;
  50424. private readonly _deviceInputSystem;
  50425. /**
  50426. * Default Constructor
  50427. * @param deviceInputSystem Reference to DeviceInputSystem
  50428. * @param deviceType Type of device
  50429. * @param deviceSlot "Slot" or index that device is referenced in
  50430. */
  50431. constructor(deviceInputSystem: DeviceInputSystem,
  50432. /** Type of device */
  50433. deviceType: DeviceType,
  50434. /** "Slot" or index that device is referenced in */
  50435. deviceSlot?: number);
  50436. /**
  50437. * Get input for specific input
  50438. * @param inputIndex index of specific input on device
  50439. * @returns Input value from DeviceInputSystem
  50440. */
  50441. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50442. }
  50443. /**
  50444. * Class to keep track of devices
  50445. */
  50446. export class DeviceSourceManager implements IDisposable {
  50447. /**
  50448. * Observable to be triggered when before a device is connected
  50449. */
  50450. readonly onBeforeDeviceConnectedObservable: Observable<{
  50451. deviceType: DeviceType;
  50452. deviceSlot: number;
  50453. }>;
  50454. /**
  50455. * Observable to be triggered when before a device is disconnected
  50456. */
  50457. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50458. deviceType: DeviceType;
  50459. deviceSlot: number;
  50460. }>;
  50461. /**
  50462. * Observable to be triggered when after a device is connected
  50463. */
  50464. readonly onAfterDeviceConnectedObservable: Observable<{
  50465. deviceType: DeviceType;
  50466. deviceSlot: number;
  50467. }>;
  50468. /**
  50469. * Observable to be triggered when after a device is disconnected
  50470. */
  50471. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50472. deviceType: DeviceType;
  50473. deviceSlot: number;
  50474. }>;
  50475. private readonly _devices;
  50476. private readonly _firstDevice;
  50477. private readonly _deviceInputSystem;
  50478. /**
  50479. * Default Constructor
  50480. * @param engine engine to pull input element from
  50481. */
  50482. constructor(engine: Engine);
  50483. /**
  50484. * Gets a DeviceSource, given a type and slot
  50485. * @param deviceType Enum specifying device type
  50486. * @param deviceSlot "Slot" or index that device is referenced in
  50487. * @returns DeviceSource object
  50488. */
  50489. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50490. /**
  50491. * Gets an array of DeviceSource objects for a given device type
  50492. * @param deviceType Enum specifying device type
  50493. * @returns Array of DeviceSource objects
  50494. */
  50495. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50496. /**
  50497. * Dispose of DeviceInputSystem and other parts
  50498. */
  50499. dispose(): void;
  50500. /**
  50501. * Function to add device name to device list
  50502. * @param deviceType Enum specifying device type
  50503. * @param deviceSlot "Slot" or index that device is referenced in
  50504. */
  50505. private _addDevice;
  50506. /**
  50507. * Function to remove 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 _removeDevice;
  50512. /**
  50513. * Updates array storing first connected device of each type
  50514. * @param type Type of Device
  50515. */
  50516. private _updateFirstDevices;
  50517. }
  50518. }
  50519. declare module BABYLON {
  50520. /**
  50521. * Options to create the null engine
  50522. */
  50523. export class NullEngineOptions {
  50524. /**
  50525. * Render width (Default: 512)
  50526. */
  50527. renderWidth: number;
  50528. /**
  50529. * Render height (Default: 256)
  50530. */
  50531. renderHeight: number;
  50532. /**
  50533. * Texture size (Default: 512)
  50534. */
  50535. textureSize: number;
  50536. /**
  50537. * If delta time between frames should be constant
  50538. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50539. */
  50540. deterministicLockstep: boolean;
  50541. /**
  50542. * Maximum about of steps between frames (Default: 4)
  50543. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50544. */
  50545. lockstepMaxSteps: number;
  50546. }
  50547. /**
  50548. * The null engine class provides support for headless version of babylon.js.
  50549. * This can be used in server side scenario or for testing purposes
  50550. */
  50551. export class NullEngine extends Engine {
  50552. private _options;
  50553. /**
  50554. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50555. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50556. * @returns true if engine is in deterministic lock step mode
  50557. */
  50558. isDeterministicLockStep(): boolean;
  50559. /**
  50560. * Gets the max steps when engine is running in deterministic lock step
  50561. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50562. * @returns the max steps
  50563. */
  50564. getLockstepMaxSteps(): number;
  50565. /**
  50566. * Gets the current hardware scaling level.
  50567. * By default the hardware scaling level is computed from the window device ratio.
  50568. * 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.
  50569. * @returns a number indicating the current hardware scaling level
  50570. */
  50571. getHardwareScalingLevel(): number;
  50572. constructor(options?: NullEngineOptions);
  50573. /**
  50574. * Creates a vertex buffer
  50575. * @param vertices the data for the vertex buffer
  50576. * @returns the new WebGL static buffer
  50577. */
  50578. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50579. /**
  50580. * Creates a new index buffer
  50581. * @param indices defines the content of the index buffer
  50582. * @param updatable defines if the index buffer must be updatable
  50583. * @returns a new webGL buffer
  50584. */
  50585. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50586. /**
  50587. * Clear the current render buffer or the current render target (if any is set up)
  50588. * @param color defines the color to use
  50589. * @param backBuffer defines if the back buffer must be cleared
  50590. * @param depth defines if the depth buffer must be cleared
  50591. * @param stencil defines if the stencil buffer must be cleared
  50592. */
  50593. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50594. /**
  50595. * Gets the current render width
  50596. * @param useScreen defines if screen size must be used (or the current render target if any)
  50597. * @returns a number defining the current render width
  50598. */
  50599. getRenderWidth(useScreen?: boolean): number;
  50600. /**
  50601. * Gets the current render height
  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 height
  50604. */
  50605. getRenderHeight(useScreen?: boolean): number;
  50606. /**
  50607. * Set the WebGL's viewport
  50608. * @param viewport defines the viewport element to be used
  50609. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50610. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50611. */
  50612. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50613. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50614. /**
  50615. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50616. * @param pipelineContext defines the pipeline context to use
  50617. * @param uniformsNames defines the list of uniform names
  50618. * @returns an array of webGL uniform locations
  50619. */
  50620. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50621. /**
  50622. * Gets the lsit of active attributes for a given webGL program
  50623. * @param pipelineContext defines the pipeline context to use
  50624. * @param attributesNames defines the list of attribute names to get
  50625. * @returns an array of indices indicating the offset of each attribute
  50626. */
  50627. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50628. /**
  50629. * Binds an effect to the webGL context
  50630. * @param effect defines the effect to bind
  50631. */
  50632. bindSamplers(effect: Effect): void;
  50633. /**
  50634. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50635. * @param effect defines the effect to activate
  50636. */
  50637. enableEffect(effect: Effect): void;
  50638. /**
  50639. * Set various states to the webGL context
  50640. * @param culling defines backface culling state
  50641. * @param zOffset defines the value to apply to zOffset (0 by default)
  50642. * @param force defines if states must be applied even if cache is up to date
  50643. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50644. */
  50645. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50646. /**
  50647. * Set the value of an uniform to an array of int32
  50648. * @param uniform defines the webGL uniform location where to store the value
  50649. * @param array defines the array of int32 to store
  50650. */
  50651. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50652. /**
  50653. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50658. /**
  50659. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50664. /**
  50665. * Set the value of an uniform to an array of int32 (stored as vec4)
  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. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50670. /**
  50671. * Set the value of an uniform to an array of float32
  50672. * @param uniform defines the webGL uniform location where to store the value
  50673. * @param array defines the array of float32 to store
  50674. */
  50675. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50676. /**
  50677. * Set the value of an uniform to an array of float32 (stored as vec2)
  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. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50682. /**
  50683. * Set the value of an uniform to an array of float32 (stored as vec3)
  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. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50688. /**
  50689. * Set the value of an uniform to an array of float32 (stored as vec4)
  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. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50694. /**
  50695. * Set the value of an uniform to an array of number
  50696. * @param uniform defines the webGL uniform location where to store the value
  50697. * @param array defines the array of number to store
  50698. */
  50699. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50700. /**
  50701. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50706. /**
  50707. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50712. /**
  50713. * Set the value of an uniform to an array of number (stored as vec4)
  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. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50718. /**
  50719. * Set the value of an uniform to an array of float32 (stored as matrices)
  50720. * @param uniform defines the webGL uniform location where to store the value
  50721. * @param matrices defines the array of float32 to store
  50722. */
  50723. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50724. /**
  50725. * Set the value of an uniform to a matrix (3x3)
  50726. * @param uniform defines the webGL uniform location where to store the value
  50727. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50728. */
  50729. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50730. /**
  50731. * Set the value of an uniform to a matrix (2x2)
  50732. * @param uniform defines the webGL uniform location where to store the value
  50733. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50734. */
  50735. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50736. /**
  50737. * Set the value of an uniform to a number (float)
  50738. * @param uniform defines the webGL uniform location where to store the value
  50739. * @param value defines the float number to store
  50740. */
  50741. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50742. /**
  50743. * Set the value of an uniform to a vec2
  50744. * @param uniform defines the webGL uniform location where to store the value
  50745. * @param x defines the 1st component of the value
  50746. * @param y defines the 2nd component of the value
  50747. */
  50748. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50749. /**
  50750. * Set the value of an uniform to a vec3
  50751. * @param uniform defines the webGL uniform location where to store the value
  50752. * @param x defines the 1st component of the value
  50753. * @param y defines the 2nd component of the value
  50754. * @param z defines the 3rd component of the value
  50755. */
  50756. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50757. /**
  50758. * Set the value of an uniform to a boolean
  50759. * @param uniform defines the webGL uniform location where to store the value
  50760. * @param bool defines the boolean to store
  50761. */
  50762. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50763. /**
  50764. * Set the value of an uniform to a vec4
  50765. * @param uniform defines the webGL uniform location where to store the value
  50766. * @param x defines the 1st component of the value
  50767. * @param y defines the 2nd component of the value
  50768. * @param z defines the 3rd component of the value
  50769. * @param w defines the 4th component of the value
  50770. */
  50771. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50772. /**
  50773. * Sets the current alpha mode
  50774. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50775. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50776. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50777. */
  50778. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50779. /**
  50780. * Bind webGl buffers directly to the webGL context
  50781. * @param vertexBuffers defines the vertex buffer to bind
  50782. * @param indexBuffer defines the index buffer to bind
  50783. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50784. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50785. * @param effect defines the effect associated with the vertex buffer
  50786. */
  50787. bindBuffers(vertexBuffers: {
  50788. [key: string]: VertexBuffer;
  50789. }, indexBuffer: DataBuffer, effect: Effect): void;
  50790. /**
  50791. * Force the entire cache to be cleared
  50792. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50793. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50794. */
  50795. wipeCaches(bruteForce?: boolean): void;
  50796. /**
  50797. * Send a draw order
  50798. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50799. * @param indexStart defines the starting index
  50800. * @param indexCount defines the number of index to draw
  50801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50802. */
  50803. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50804. /**
  50805. * Draw a list of indexed primitives
  50806. * @param fillMode defines the primitive to use
  50807. * @param indexStart defines the starting index
  50808. * @param indexCount defines the number of index to draw
  50809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50810. */
  50811. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50812. /**
  50813. * Draw a list of unindexed primitives
  50814. * @param fillMode defines the primitive to use
  50815. * @param verticesStart defines the index of first vertex to draw
  50816. * @param verticesCount defines the count of vertices to draw
  50817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50818. */
  50819. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50820. /** @hidden */
  50821. _createTexture(): WebGLTexture;
  50822. /** @hidden */
  50823. _releaseTexture(texture: InternalTexture): void;
  50824. /**
  50825. * Usually called from Texture.ts.
  50826. * Passed information to create a WebGLTexture
  50827. * @param urlArg defines a value which contains one of the following:
  50828. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50829. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50830. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50831. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50832. * @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)
  50833. * @param scene needed for loading to the correct scene
  50834. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50835. * @param onLoad optional callback to be called upon successful completion
  50836. * @param onError optional callback to be called upon failure
  50837. * @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
  50838. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50839. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50840. * @param forcedExtension defines the extension to use to pick the right loader
  50841. * @param mimeType defines an optional mime type
  50842. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50843. */
  50844. 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;
  50845. /**
  50846. * Creates a new render target texture
  50847. * @param size defines the size of the texture
  50848. * @param options defines the options used to create the texture
  50849. * @returns a new render target texture stored in an InternalTexture
  50850. */
  50851. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50852. /**
  50853. * Update the sampling mode of a given texture
  50854. * @param samplingMode defines the required sampling mode
  50855. * @param texture defines the texture to update
  50856. */
  50857. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50858. /**
  50859. * Binds the frame buffer to the specified texture.
  50860. * @param texture The texture to render to or null for the default canvas
  50861. * @param faceIndex The face of the texture to render to in case of cube texture
  50862. * @param requiredWidth The width of the target to render to
  50863. * @param requiredHeight The height of the target to render to
  50864. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50865. * @param lodLevel defines le lod level to bind to the frame buffer
  50866. */
  50867. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50868. /**
  50869. * Unbind the current render target texture from the webGL context
  50870. * @param texture defines the render target texture to unbind
  50871. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50872. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50873. */
  50874. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50875. /**
  50876. * Creates a dynamic vertex buffer
  50877. * @param vertices the data for the dynamic vertex buffer
  50878. * @returns the new WebGL dynamic buffer
  50879. */
  50880. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50881. /**
  50882. * Update the content of a dynamic texture
  50883. * @param texture defines the texture to update
  50884. * @param canvas defines the canvas containing the source
  50885. * @param invertY defines if data must be stored with Y axis inverted
  50886. * @param premulAlpha defines if alpha is stored as premultiplied
  50887. * @param format defines the format of the data
  50888. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50889. */
  50890. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50891. /**
  50892. * Gets a boolean indicating if all created effects are ready
  50893. * @returns true if all effects are ready
  50894. */
  50895. areAllEffectsReady(): boolean;
  50896. /**
  50897. * @hidden
  50898. * Get the current error code of the webGL context
  50899. * @returns the error code
  50900. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50901. */
  50902. getError(): number;
  50903. /** @hidden */
  50904. _getUnpackAlignement(): number;
  50905. /** @hidden */
  50906. _unpackFlipY(value: boolean): void;
  50907. /**
  50908. * Update a dynamic index buffer
  50909. * @param indexBuffer defines the target index buffer
  50910. * @param indices defines the data to update
  50911. * @param offset defines the offset in the target index buffer where update should start
  50912. */
  50913. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50914. /**
  50915. * Updates a dynamic vertex buffer.
  50916. * @param vertexBuffer the vertex buffer to update
  50917. * @param vertices the data used to update the vertex buffer
  50918. * @param byteOffset the byte offset of the data (optional)
  50919. * @param byteLength the byte length of the data (optional)
  50920. */
  50921. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50922. /** @hidden */
  50923. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50924. /** @hidden */
  50925. _bindTexture(channel: number, texture: InternalTexture): void;
  50926. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50927. /**
  50928. * 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
  50929. */
  50930. releaseEffects(): void;
  50931. displayLoadingUI(): void;
  50932. hideLoadingUI(): void;
  50933. /** @hidden */
  50934. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50935. /** @hidden */
  50936. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50937. /** @hidden */
  50938. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50939. /** @hidden */
  50940. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50941. }
  50942. }
  50943. declare module BABYLON {
  50944. /**
  50945. * @hidden
  50946. **/
  50947. export class _TimeToken {
  50948. _startTimeQuery: Nullable<WebGLQuery>;
  50949. _endTimeQuery: Nullable<WebGLQuery>;
  50950. _timeElapsedQuery: Nullable<WebGLQuery>;
  50951. _timeElapsedQueryEnded: boolean;
  50952. }
  50953. }
  50954. declare module BABYLON {
  50955. /** @hidden */
  50956. export class _OcclusionDataStorage {
  50957. /** @hidden */
  50958. occlusionInternalRetryCounter: number;
  50959. /** @hidden */
  50960. isOcclusionQueryInProgress: boolean;
  50961. /** @hidden */
  50962. isOccluded: boolean;
  50963. /** @hidden */
  50964. occlusionRetryCount: number;
  50965. /** @hidden */
  50966. occlusionType: number;
  50967. /** @hidden */
  50968. occlusionQueryAlgorithmType: number;
  50969. }
  50970. interface Engine {
  50971. /**
  50972. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50973. * @return the new query
  50974. */
  50975. createQuery(): WebGLQuery;
  50976. /**
  50977. * Delete and release a webGL query
  50978. * @param query defines the query to delete
  50979. * @return the current engine
  50980. */
  50981. deleteQuery(query: WebGLQuery): Engine;
  50982. /**
  50983. * Check if a given query has resolved and got its value
  50984. * @param query defines the query to check
  50985. * @returns true if the query got its value
  50986. */
  50987. isQueryResultAvailable(query: WebGLQuery): boolean;
  50988. /**
  50989. * Gets the value of a given query
  50990. * @param query defines the query to check
  50991. * @returns the value of the query
  50992. */
  50993. getQueryResult(query: WebGLQuery): number;
  50994. /**
  50995. * Initiates an occlusion query
  50996. * @param algorithmType defines the algorithm to use
  50997. * @param query defines the query to use
  50998. * @returns the current engine
  50999. * @see https://doc.babylonjs.com/features/occlusionquery
  51000. */
  51001. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51002. /**
  51003. * Ends an occlusion query
  51004. * @see https://doc.babylonjs.com/features/occlusionquery
  51005. * @param algorithmType defines the algorithm to use
  51006. * @returns the current engine
  51007. */
  51008. endOcclusionQuery(algorithmType: number): Engine;
  51009. /**
  51010. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51011. * Please note that only one query can be issued at a time
  51012. * @returns a time token used to track the time span
  51013. */
  51014. startTimeQuery(): Nullable<_TimeToken>;
  51015. /**
  51016. * Ends a time query
  51017. * @param token defines the token used to measure the time span
  51018. * @returns the time spent (in ns)
  51019. */
  51020. endTimeQuery(token: _TimeToken): int;
  51021. /** @hidden */
  51022. _currentNonTimestampToken: Nullable<_TimeToken>;
  51023. /** @hidden */
  51024. _createTimeQuery(): WebGLQuery;
  51025. /** @hidden */
  51026. _deleteTimeQuery(query: WebGLQuery): void;
  51027. /** @hidden */
  51028. _getGlAlgorithmType(algorithmType: number): number;
  51029. /** @hidden */
  51030. _getTimeQueryResult(query: WebGLQuery): any;
  51031. /** @hidden */
  51032. _getTimeQueryAvailability(query: WebGLQuery): any;
  51033. }
  51034. interface AbstractMesh {
  51035. /**
  51036. * Backing filed
  51037. * @hidden
  51038. */
  51039. __occlusionDataStorage: _OcclusionDataStorage;
  51040. /**
  51041. * Access property
  51042. * @hidden
  51043. */
  51044. _occlusionDataStorage: _OcclusionDataStorage;
  51045. /**
  51046. * 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.
  51047. * The default value is -1 which means don't break the query and wait till the result
  51048. * @see https://doc.babylonjs.com/features/occlusionquery
  51049. */
  51050. occlusionRetryCount: number;
  51051. /**
  51052. * 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:
  51053. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51054. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51055. * * 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.
  51056. * @see https://doc.babylonjs.com/features/occlusionquery
  51057. */
  51058. occlusionType: number;
  51059. /**
  51060. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51061. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51062. * * 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.
  51063. * @see https://doc.babylonjs.com/features/occlusionquery
  51064. */
  51065. occlusionQueryAlgorithmType: number;
  51066. /**
  51067. * 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
  51068. * @see https://doc.babylonjs.com/features/occlusionquery
  51069. */
  51070. isOccluded: boolean;
  51071. /**
  51072. * Flag to check the progress status of the query
  51073. * @see https://doc.babylonjs.com/features/occlusionquery
  51074. */
  51075. isOcclusionQueryInProgress: boolean;
  51076. }
  51077. }
  51078. declare module BABYLON {
  51079. /** @hidden */
  51080. export var _forceTransformFeedbackToBundle: boolean;
  51081. interface Engine {
  51082. /**
  51083. * Creates a webGL transform feedback object
  51084. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51085. * @returns the webGL transform feedback object
  51086. */
  51087. createTransformFeedback(): WebGLTransformFeedback;
  51088. /**
  51089. * Delete a webGL transform feedback object
  51090. * @param value defines the webGL transform feedback object to delete
  51091. */
  51092. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51093. /**
  51094. * Bind a webGL transform feedback object to the webgl context
  51095. * @param value defines the webGL transform feedback object to bind
  51096. */
  51097. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51098. /**
  51099. * Begins a transform feedback operation
  51100. * @param usePoints defines if points or triangles must be used
  51101. */
  51102. beginTransformFeedback(usePoints: boolean): void;
  51103. /**
  51104. * Ends a transform feedback operation
  51105. */
  51106. endTransformFeedback(): void;
  51107. /**
  51108. * Specify the varyings to use with transform feedback
  51109. * @param program defines the associated webGL program
  51110. * @param value defines the list of strings representing the varying names
  51111. */
  51112. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51113. /**
  51114. * Bind a webGL buffer for a transform feedback operation
  51115. * @param value defines the webGL buffer to bind
  51116. */
  51117. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51118. }
  51119. }
  51120. declare module BABYLON {
  51121. /**
  51122. * Creation options of the multi render target texture.
  51123. */
  51124. export interface IMultiRenderTargetOptions {
  51125. /**
  51126. * Define if the texture needs to create mip maps after render.
  51127. */
  51128. generateMipMaps?: boolean;
  51129. /**
  51130. * Define the types of all the draw buffers we want to create
  51131. */
  51132. types?: number[];
  51133. /**
  51134. * Define the sampling modes of all the draw buffers we want to create
  51135. */
  51136. samplingModes?: number[];
  51137. /**
  51138. * Define if a depth buffer is required
  51139. */
  51140. generateDepthBuffer?: boolean;
  51141. /**
  51142. * Define if a stencil buffer is required
  51143. */
  51144. generateStencilBuffer?: boolean;
  51145. /**
  51146. * Define if a depth texture is required instead of a depth buffer
  51147. */
  51148. generateDepthTexture?: boolean;
  51149. /**
  51150. * Define the number of desired draw buffers
  51151. */
  51152. textureCount?: number;
  51153. /**
  51154. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51155. */
  51156. doNotChangeAspectRatio?: boolean;
  51157. /**
  51158. * Define the default type of the buffers we are creating
  51159. */
  51160. defaultType?: number;
  51161. }
  51162. /**
  51163. * A multi render target, like a render target provides the ability to render to a texture.
  51164. * Unlike the render target, it can render to several draw buffers in one draw.
  51165. * This is specially interesting in deferred rendering or for any effects requiring more than
  51166. * just one color from a single pass.
  51167. */
  51168. export class MultiRenderTarget extends RenderTargetTexture {
  51169. private _internalTextures;
  51170. private _textures;
  51171. private _multiRenderTargetOptions;
  51172. private _count;
  51173. /**
  51174. * Get if draw buffers are currently supported by the used hardware and browser.
  51175. */
  51176. get isSupported(): boolean;
  51177. /**
  51178. * Get the list of textures generated by the multi render target.
  51179. */
  51180. get textures(): Texture[];
  51181. /**
  51182. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  51183. */
  51184. get count(): number;
  51185. /**
  51186. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51187. */
  51188. get depthTexture(): Texture;
  51189. /**
  51190. * Set the wrapping mode on U of all the textures we are rendering to.
  51191. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51192. */
  51193. set wrapU(wrap: number);
  51194. /**
  51195. * Set the wrapping mode on V of all the textures we are rendering to.
  51196. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51197. */
  51198. set wrapV(wrap: number);
  51199. /**
  51200. * Instantiate a new multi render target texture.
  51201. * A multi render target, like a render target provides the ability to render to a texture.
  51202. * Unlike the render target, it can render to several draw buffers in one draw.
  51203. * This is specially interesting in deferred rendering or for any effects requiring more than
  51204. * just one color from a single pass.
  51205. * @param name Define the name of the texture
  51206. * @param size Define the size of the buffers to render to
  51207. * @param count Define the number of target we are rendering into
  51208. * @param scene Define the scene the texture belongs to
  51209. * @param options Define the options used to create the multi render target
  51210. */
  51211. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51212. /** @hidden */
  51213. _rebuild(): void;
  51214. private _createInternalTextures;
  51215. private _createTextures;
  51216. /**
  51217. * Define the number of samples used if MSAA is enabled.
  51218. */
  51219. get samples(): number;
  51220. set samples(value: number);
  51221. /**
  51222. * Resize all the textures in the multi render target.
  51223. * Be carrefull as it will recreate all the data in the new texture.
  51224. * @param size Define the new size
  51225. */
  51226. resize(size: any): void;
  51227. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51228. /**
  51229. * Dispose the render targets and their associated resources
  51230. */
  51231. dispose(): void;
  51232. /**
  51233. * Release all the underlying texture used as draw buffers.
  51234. */
  51235. releaseInternalTextures(): void;
  51236. }
  51237. }
  51238. declare module BABYLON {
  51239. interface ThinEngine {
  51240. /**
  51241. * Unbind a list of render target textures from the webGL context
  51242. * This is used only when drawBuffer extension or webGL2 are active
  51243. * @param textures defines the render target textures to unbind
  51244. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51245. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51246. */
  51247. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51248. /**
  51249. * Create a multi render target texture
  51250. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  51251. * @param size defines the size of the texture
  51252. * @param options defines the creation options
  51253. * @returns the cube texture as an InternalTexture
  51254. */
  51255. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51256. /**
  51257. * Update the sample count for a given multiple render target texture
  51258. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51259. * @param textures defines the textures to update
  51260. * @param samples defines the sample count to set
  51261. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51262. */
  51263. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51264. /**
  51265. * Select a subsets of attachments to draw to.
  51266. * @param attachments gl attachments
  51267. */
  51268. bindAttachments(attachments: number[]): void;
  51269. }
  51270. }
  51271. declare module BABYLON {
  51272. /**
  51273. * Class used to define an additional view for the engine
  51274. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51275. */
  51276. export class EngineView {
  51277. /** Defines the canvas where to render the view */
  51278. target: HTMLCanvasElement;
  51279. /** Defines an optional camera used to render the view (will use active camera else) */
  51280. camera?: Camera;
  51281. }
  51282. interface Engine {
  51283. /**
  51284. * Gets or sets the HTML element to use for attaching events
  51285. */
  51286. inputElement: Nullable<HTMLElement>;
  51287. /**
  51288. * Gets the current engine view
  51289. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51290. */
  51291. activeView: Nullable<EngineView>;
  51292. /** Gets or sets the list of views */
  51293. views: EngineView[];
  51294. /**
  51295. * Register a new child canvas
  51296. * @param canvas defines the canvas to register
  51297. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51298. * @returns the associated view
  51299. */
  51300. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51301. /**
  51302. * Remove a registered child canvas
  51303. * @param canvas defines the canvas to remove
  51304. * @returns the current engine
  51305. */
  51306. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51307. }
  51308. }
  51309. declare module BABYLON {
  51310. interface Engine {
  51311. /** @hidden */
  51312. _excludedCompressedTextures: string[];
  51313. /** @hidden */
  51314. _textureFormatInUse: string;
  51315. /**
  51316. * Gets the list of texture formats supported
  51317. */
  51318. readonly texturesSupported: Array<string>;
  51319. /**
  51320. * Gets the texture format in use
  51321. */
  51322. readonly textureFormatInUse: Nullable<string>;
  51323. /**
  51324. * Set the compressed texture extensions or file names to skip.
  51325. *
  51326. * @param skippedFiles defines the list of those texture files you want to skip
  51327. * Example: [".dds", ".env", "myfile.png"]
  51328. */
  51329. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51330. /**
  51331. * Set the compressed texture format to use, based on the formats you have, and the formats
  51332. * supported by the hardware / browser.
  51333. *
  51334. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51335. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51336. * to API arguments needed to compressed textures. This puts the burden on the container
  51337. * generator to house the arcane code for determining these for current & future formats.
  51338. *
  51339. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51340. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51341. *
  51342. * Note: The result of this call is not taken into account when a texture is base64.
  51343. *
  51344. * @param formatsAvailable defines the list of those format families you have created
  51345. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51346. *
  51347. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51348. * @returns The extension selected.
  51349. */
  51350. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51351. }
  51352. }
  51353. declare module BABYLON {
  51354. /**
  51355. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51356. */
  51357. export interface CubeMapInfo {
  51358. /**
  51359. * The pixel array for the front face.
  51360. * This is stored in format, left to right, up to down format.
  51361. */
  51362. front: Nullable<ArrayBufferView>;
  51363. /**
  51364. * The pixel array for the back face.
  51365. * This is stored in format, left to right, up to down format.
  51366. */
  51367. back: Nullable<ArrayBufferView>;
  51368. /**
  51369. * The pixel array for the left face.
  51370. * This is stored in format, left to right, up to down format.
  51371. */
  51372. left: Nullable<ArrayBufferView>;
  51373. /**
  51374. * The pixel array for the right face.
  51375. * This is stored in format, left to right, up to down format.
  51376. */
  51377. right: Nullable<ArrayBufferView>;
  51378. /**
  51379. * The pixel array for the up face.
  51380. * This is stored in format, left to right, up to down format.
  51381. */
  51382. up: Nullable<ArrayBufferView>;
  51383. /**
  51384. * The pixel array for the down face.
  51385. * This is stored in format, left to right, up to down format.
  51386. */
  51387. down: Nullable<ArrayBufferView>;
  51388. /**
  51389. * The size of the cubemap stored.
  51390. *
  51391. * Each faces will be size * size pixels.
  51392. */
  51393. size: number;
  51394. /**
  51395. * The format of the texture.
  51396. *
  51397. * RGBA, RGB.
  51398. */
  51399. format: number;
  51400. /**
  51401. * The type of the texture data.
  51402. *
  51403. * UNSIGNED_INT, FLOAT.
  51404. */
  51405. type: number;
  51406. /**
  51407. * Specifies whether the texture is in gamma space.
  51408. */
  51409. gammaSpace: boolean;
  51410. }
  51411. /**
  51412. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51413. */
  51414. export class PanoramaToCubeMapTools {
  51415. private static FACE_LEFT;
  51416. private static FACE_RIGHT;
  51417. private static FACE_FRONT;
  51418. private static FACE_BACK;
  51419. private static FACE_DOWN;
  51420. private static FACE_UP;
  51421. /**
  51422. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51423. *
  51424. * @param float32Array The source data.
  51425. * @param inputWidth The width of the input panorama.
  51426. * @param inputHeight The height of the input panorama.
  51427. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51428. * @return The cubemap data
  51429. */
  51430. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51431. private static CreateCubemapTexture;
  51432. private static CalcProjectionSpherical;
  51433. }
  51434. }
  51435. declare module BABYLON {
  51436. /**
  51437. * Helper class dealing with the extraction of spherical polynomial dataArray
  51438. * from a cube map.
  51439. */
  51440. export class CubeMapToSphericalPolynomialTools {
  51441. private static FileFaces;
  51442. /**
  51443. * Converts a texture to the according Spherical Polynomial data.
  51444. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51445. *
  51446. * @param texture The texture to extract the information from.
  51447. * @return The Spherical Polynomial data.
  51448. */
  51449. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51450. /**
  51451. * Converts a cubemap to the according Spherical Polynomial data.
  51452. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51453. *
  51454. * @param cubeInfo The Cube map to extract the information from.
  51455. * @return The Spherical Polynomial data.
  51456. */
  51457. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51458. }
  51459. }
  51460. declare module BABYLON {
  51461. interface BaseTexture {
  51462. /**
  51463. * Get the polynomial representation of the texture data.
  51464. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51465. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51466. */
  51467. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /** @hidden */
  51472. export var rgbdEncodePixelShader: {
  51473. name: string;
  51474. shader: string;
  51475. };
  51476. }
  51477. declare module BABYLON {
  51478. /** @hidden */
  51479. export var rgbdDecodePixelShader: {
  51480. name: string;
  51481. shader: string;
  51482. };
  51483. }
  51484. declare module BABYLON {
  51485. /**
  51486. * Raw texture data and descriptor sufficient for WebGL texture upload
  51487. */
  51488. export interface EnvironmentTextureInfo {
  51489. /**
  51490. * Version of the environment map
  51491. */
  51492. version: number;
  51493. /**
  51494. * Width of image
  51495. */
  51496. width: number;
  51497. /**
  51498. * Irradiance information stored in the file.
  51499. */
  51500. irradiance: any;
  51501. /**
  51502. * Specular information stored in the file.
  51503. */
  51504. specular: any;
  51505. }
  51506. /**
  51507. * Defines One Image in the file. It requires only the position in the file
  51508. * as well as the length.
  51509. */
  51510. interface BufferImageData {
  51511. /**
  51512. * Length of the image data.
  51513. */
  51514. length: number;
  51515. /**
  51516. * Position of the data from the null terminator delimiting the end of the JSON.
  51517. */
  51518. position: number;
  51519. }
  51520. /**
  51521. * Defines the specular data enclosed in the file.
  51522. * This corresponds to the version 1 of the data.
  51523. */
  51524. export interface EnvironmentTextureSpecularInfoV1 {
  51525. /**
  51526. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51527. */
  51528. specularDataPosition?: number;
  51529. /**
  51530. * This contains all the images data needed to reconstruct the cubemap.
  51531. */
  51532. mipmaps: Array<BufferImageData>;
  51533. /**
  51534. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51535. */
  51536. lodGenerationScale: number;
  51537. }
  51538. /**
  51539. * Sets of helpers addressing the serialization and deserialization of environment texture
  51540. * stored in a BabylonJS env file.
  51541. * Those files are usually stored as .env files.
  51542. */
  51543. export class EnvironmentTextureTools {
  51544. /**
  51545. * Magic number identifying the env file.
  51546. */
  51547. private static _MagicBytes;
  51548. /**
  51549. * Gets the environment info from an env file.
  51550. * @param data The array buffer containing the .env bytes.
  51551. * @returns the environment file info (the json header) if successfully parsed.
  51552. */
  51553. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51554. /**
  51555. * Creates an environment texture from a loaded cube texture.
  51556. * @param texture defines the cube texture to convert in env file
  51557. * @return a promise containing the environment data if succesfull.
  51558. */
  51559. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51560. /**
  51561. * Creates a JSON representation of the spherical data.
  51562. * @param texture defines the texture containing the polynomials
  51563. * @return the JSON representation of the spherical info
  51564. */
  51565. private static _CreateEnvTextureIrradiance;
  51566. /**
  51567. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51568. * @param data the image data
  51569. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51570. * @return the views described by info providing access to the underlying buffer
  51571. */
  51572. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51573. /**
  51574. * Uploads the texture info contained in the env file to the GPU.
  51575. * @param texture defines the internal texture to upload to
  51576. * @param data defines the data to load
  51577. * @param info defines the texture info retrieved through the GetEnvInfo method
  51578. * @returns a promise
  51579. */
  51580. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51581. private static _OnImageReadyAsync;
  51582. /**
  51583. * Uploads the levels of image data to the GPU.
  51584. * @param texture defines the internal texture to upload to
  51585. * @param imageData defines the array buffer views of image data [mipmap][face]
  51586. * @returns a promise
  51587. */
  51588. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51589. /**
  51590. * Uploads spherical polynomials information to the texture.
  51591. * @param texture defines the texture we are trying to upload the information to
  51592. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51593. */
  51594. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51595. /** @hidden */
  51596. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51597. }
  51598. }
  51599. declare module BABYLON {
  51600. /**
  51601. * Class used to inline functions in shader code
  51602. */
  51603. export class ShaderCodeInliner {
  51604. private static readonly _RegexpFindFunctionNameAndType;
  51605. private _sourceCode;
  51606. private _functionDescr;
  51607. private _numMaxIterations;
  51608. /** Gets or sets the token used to mark the functions to inline */
  51609. inlineToken: string;
  51610. /** Gets or sets the debug mode */
  51611. debug: boolean;
  51612. /** Gets the code after the inlining process */
  51613. get code(): string;
  51614. /**
  51615. * Initializes the inliner
  51616. * @param sourceCode shader code source to inline
  51617. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51618. */
  51619. constructor(sourceCode: string, numMaxIterations?: number);
  51620. /**
  51621. * Start the processing of the shader code
  51622. */
  51623. processCode(): void;
  51624. private _collectFunctions;
  51625. private _processInlining;
  51626. private _extractBetweenMarkers;
  51627. private _skipWhitespaces;
  51628. private _removeComments;
  51629. private _replaceFunctionCallsByCode;
  51630. private _findBackward;
  51631. private _escapeRegExp;
  51632. private _replaceNames;
  51633. }
  51634. }
  51635. declare module BABYLON {
  51636. /**
  51637. * Container for accessors for natively-stored mesh data buffers.
  51638. */
  51639. class NativeDataBuffer extends DataBuffer {
  51640. /**
  51641. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51642. */
  51643. nativeIndexBuffer?: any;
  51644. /**
  51645. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51646. */
  51647. nativeVertexBuffer?: any;
  51648. }
  51649. /** @hidden */
  51650. class NativeTexture extends InternalTexture {
  51651. getInternalTexture(): InternalTexture;
  51652. getViewCount(): number;
  51653. }
  51654. /** @hidden */
  51655. export class NativeEngine extends Engine {
  51656. private readonly _native;
  51657. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51658. private readonly INVALID_HANDLE;
  51659. getHardwareScalingLevel(): number;
  51660. constructor();
  51661. dispose(): void;
  51662. /**
  51663. * Can be used to override the current requestAnimationFrame requester.
  51664. * @hidden
  51665. */
  51666. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51667. /**
  51668. * Override default engine behavior.
  51669. * @param color
  51670. * @param backBuffer
  51671. * @param depth
  51672. * @param stencil
  51673. */
  51674. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51675. /**
  51676. * Gets host document
  51677. * @returns the host document object
  51678. */
  51679. getHostDocument(): Nullable<Document>;
  51680. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51681. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51682. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51683. recordVertexArrayObject(vertexBuffers: {
  51684. [key: string]: VertexBuffer;
  51685. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51686. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51687. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51688. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51689. /**
  51690. * Draw a list of indexed primitives
  51691. * @param fillMode defines the primitive to use
  51692. * @param indexStart defines the starting index
  51693. * @param indexCount defines the number of index to draw
  51694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51695. */
  51696. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51697. /**
  51698. * Draw a list of unindexed primitives
  51699. * @param fillMode defines the primitive to use
  51700. * @param verticesStart defines the index of first vertex to draw
  51701. * @param verticesCount defines the count of vertices to draw
  51702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51703. */
  51704. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51705. createPipelineContext(): IPipelineContext;
  51706. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51707. /** @hidden */
  51708. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51709. /** @hidden */
  51710. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51711. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51712. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51713. protected _setProgram(program: WebGLProgram): void;
  51714. _releaseEffect(effect: Effect): void;
  51715. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51716. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51717. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51718. bindSamplers(effect: Effect): void;
  51719. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51720. getRenderWidth(useScreen?: boolean): number;
  51721. getRenderHeight(useScreen?: boolean): number;
  51722. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51723. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51724. /**
  51725. * Set the z offset to apply to current rendering
  51726. * @param value defines the offset to apply
  51727. */
  51728. setZOffset(value: number): void;
  51729. /**
  51730. * Gets the current value of the zOffset
  51731. * @returns the current zOffset state
  51732. */
  51733. getZOffset(): number;
  51734. /**
  51735. * Enable or disable depth buffering
  51736. * @param enable defines the state to set
  51737. */
  51738. setDepthBuffer(enable: boolean): void;
  51739. /**
  51740. * Gets a boolean indicating if depth writing is enabled
  51741. * @returns the current depth writing state
  51742. */
  51743. getDepthWrite(): boolean;
  51744. /**
  51745. * Enable or disable depth writing
  51746. * @param enable defines the state to set
  51747. */
  51748. setDepthWrite(enable: boolean): void;
  51749. /**
  51750. * Enable or disable color writing
  51751. * @param enable defines the state to set
  51752. */
  51753. setColorWrite(enable: boolean): void;
  51754. /**
  51755. * Gets a boolean indicating if color writing is enabled
  51756. * @returns the current color writing state
  51757. */
  51758. getColorWrite(): boolean;
  51759. /**
  51760. * Sets alpha constants used by some alpha blending modes
  51761. * @param r defines the red component
  51762. * @param g defines the green component
  51763. * @param b defines the blue component
  51764. * @param a defines the alpha component
  51765. */
  51766. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51767. /**
  51768. * Sets the current alpha mode
  51769. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51770. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51771. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51772. */
  51773. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51774. /**
  51775. * Gets the current alpha mode
  51776. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51777. * @returns the current alpha mode
  51778. */
  51779. getAlphaMode(): number;
  51780. setInt(uniform: WebGLUniformLocation, int: number): void;
  51781. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51782. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51783. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51784. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51785. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51786. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51787. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51788. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51789. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51790. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51791. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51792. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51793. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51794. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51795. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51796. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51797. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51798. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51799. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51800. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51801. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51802. wipeCaches(bruteForce?: boolean): void;
  51803. _createTexture(): WebGLTexture;
  51804. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51805. /**
  51806. * Usually called from Texture.ts.
  51807. * Passed information to create a WebGLTexture
  51808. * @param url defines a value which contains one of the following:
  51809. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51810. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51811. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51813. * @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)
  51814. * @param scene needed for loading to the correct scene
  51815. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51816. * @param onLoad optional callback to be called upon successful completion
  51817. * @param onError optional callback to be called upon failure
  51818. * @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
  51819. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51820. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51821. * @param forcedExtension defines the extension to use to pick the right loader
  51822. * @param mimeType defines an optional mime type
  51823. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51824. */
  51825. 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;
  51826. /**
  51827. * Creates a cube texture
  51828. * @param rootUrl defines the url where the files to load is located
  51829. * @param scene defines the current scene
  51830. * @param files defines the list of files to load (1 per face)
  51831. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51832. * @param onLoad defines an optional callback raised when the texture is loaded
  51833. * @param onError defines an optional callback raised if there is an issue to load the texture
  51834. * @param format defines the format of the data
  51835. * @param forcedExtension defines the extension to use to pick the right loader
  51836. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51837. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51838. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51839. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51840. * @returns the cube texture as an InternalTexture
  51841. */
  51842. 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;
  51843. private _getSamplingFilter;
  51844. private static _GetNativeTextureFormat;
  51845. createRenderTargetTexture(size: number | {
  51846. width: number;
  51847. height: number;
  51848. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51849. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51850. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51851. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51852. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51853. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51854. /**
  51855. * Updates a dynamic vertex buffer.
  51856. * @param vertexBuffer the vertex buffer to update
  51857. * @param data the data used to update the vertex buffer
  51858. * @param byteOffset the byte offset of the data (optional)
  51859. * @param byteLength the byte length of the data (optional)
  51860. */
  51861. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51862. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51863. private _updateAnisotropicLevel;
  51864. private _getAddressMode;
  51865. /** @hidden */
  51866. _bindTexture(channel: number, texture: InternalTexture): void;
  51867. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51868. releaseEffects(): void;
  51869. /** @hidden */
  51870. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51871. /** @hidden */
  51872. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51873. /** @hidden */
  51874. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51875. /** @hidden */
  51876. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51877. }
  51878. }
  51879. declare module BABYLON {
  51880. /**
  51881. * Gather the list of clipboard event types as constants.
  51882. */
  51883. export class ClipboardEventTypes {
  51884. /**
  51885. * The clipboard event is fired when a copy command is active (pressed).
  51886. */
  51887. static readonly COPY: number;
  51888. /**
  51889. * The clipboard event is fired when a cut command is active (pressed).
  51890. */
  51891. static readonly CUT: number;
  51892. /**
  51893. * The clipboard event is fired when a paste command is active (pressed).
  51894. */
  51895. static readonly PASTE: number;
  51896. }
  51897. /**
  51898. * This class is used to store clipboard related info for the onClipboardObservable event.
  51899. */
  51900. export class ClipboardInfo {
  51901. /**
  51902. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51903. */
  51904. type: number;
  51905. /**
  51906. * Defines the related dom event
  51907. */
  51908. event: ClipboardEvent;
  51909. /**
  51910. *Creates an instance of ClipboardInfo.
  51911. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51912. * @param event Defines the related dom event
  51913. */
  51914. constructor(
  51915. /**
  51916. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51917. */
  51918. type: number,
  51919. /**
  51920. * Defines the related dom event
  51921. */
  51922. event: ClipboardEvent);
  51923. /**
  51924. * Get the clipboard event's type from the keycode.
  51925. * @param keyCode Defines the keyCode for the current keyboard event.
  51926. * @return {number}
  51927. */
  51928. static GetTypeFromCharacter(keyCode: number): number;
  51929. }
  51930. }
  51931. declare module BABYLON {
  51932. /**
  51933. * Google Daydream controller
  51934. */
  51935. export class DaydreamController extends WebVRController {
  51936. /**
  51937. * Base Url for the controller model.
  51938. */
  51939. static MODEL_BASE_URL: string;
  51940. /**
  51941. * File name for the controller model.
  51942. */
  51943. static MODEL_FILENAME: string;
  51944. /**
  51945. * Gamepad Id prefix used to identify Daydream Controller.
  51946. */
  51947. static readonly GAMEPAD_ID_PREFIX: string;
  51948. /**
  51949. * Creates a new DaydreamController from a gamepad
  51950. * @param vrGamepad the gamepad that the controller should be created from
  51951. */
  51952. constructor(vrGamepad: any);
  51953. /**
  51954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51955. * @param scene scene in which to add meshes
  51956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51957. */
  51958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51959. /**
  51960. * Called once for each button that changed state since the last frame
  51961. * @param buttonIdx Which button index changed
  51962. * @param state New state of the button
  51963. * @param changes Which properties on the state changed since last frame
  51964. */
  51965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51966. }
  51967. }
  51968. declare module BABYLON {
  51969. /**
  51970. * Gear VR Controller
  51971. */
  51972. export class GearVRController extends WebVRController {
  51973. /**
  51974. * Base Url for the controller model.
  51975. */
  51976. static MODEL_BASE_URL: string;
  51977. /**
  51978. * File name for the controller model.
  51979. */
  51980. static MODEL_FILENAME: string;
  51981. /**
  51982. * Gamepad Id prefix used to identify this controller.
  51983. */
  51984. static readonly GAMEPAD_ID_PREFIX: string;
  51985. private readonly _buttonIndexToObservableNameMap;
  51986. /**
  51987. * Creates a new GearVRController from a gamepad
  51988. * @param vrGamepad the gamepad that the controller should be created from
  51989. */
  51990. constructor(vrGamepad: any);
  51991. /**
  51992. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51993. * @param scene scene in which to add meshes
  51994. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51995. */
  51996. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51997. /**
  51998. * Called once for each button that changed state since the last frame
  51999. * @param buttonIdx Which button index changed
  52000. * @param state New state of the button
  52001. * @param changes Which properties on the state changed since last frame
  52002. */
  52003. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /**
  52008. * Generic Controller
  52009. */
  52010. export class GenericController extends WebVRController {
  52011. /**
  52012. * Base Url for the controller model.
  52013. */
  52014. static readonly MODEL_BASE_URL: string;
  52015. /**
  52016. * File name for the controller model.
  52017. */
  52018. static readonly MODEL_FILENAME: string;
  52019. /**
  52020. * Creates a new GenericController from a gamepad
  52021. * @param vrGamepad the gamepad that the controller should be created from
  52022. */
  52023. constructor(vrGamepad: any);
  52024. /**
  52025. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52026. * @param scene scene in which to add meshes
  52027. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52028. */
  52029. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52030. /**
  52031. * Called once for each button that changed state since the last frame
  52032. * @param buttonIdx Which button index changed
  52033. * @param state New state of the button
  52034. * @param changes Which properties on the state changed since last frame
  52035. */
  52036. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52037. }
  52038. }
  52039. declare module BABYLON {
  52040. /**
  52041. * Oculus Touch Controller
  52042. */
  52043. export class OculusTouchController extends WebVRController {
  52044. /**
  52045. * Base Url for the controller model.
  52046. */
  52047. static MODEL_BASE_URL: string;
  52048. /**
  52049. * File name for the left controller model.
  52050. */
  52051. static MODEL_LEFT_FILENAME: string;
  52052. /**
  52053. * File name for the right controller model.
  52054. */
  52055. static MODEL_RIGHT_FILENAME: string;
  52056. /**
  52057. * Base Url for the Quest controller model.
  52058. */
  52059. static QUEST_MODEL_BASE_URL: string;
  52060. /**
  52061. * @hidden
  52062. * If the controllers are running on a device that needs the updated Quest controller models
  52063. */
  52064. static _IsQuest: boolean;
  52065. /**
  52066. * Fired when the secondary trigger on this controller is modified
  52067. */
  52068. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52069. /**
  52070. * Fired when the thumb rest on this controller is modified
  52071. */
  52072. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52073. /**
  52074. * Creates a new OculusTouchController from a gamepad
  52075. * @param vrGamepad the gamepad that the controller should be created from
  52076. */
  52077. constructor(vrGamepad: any);
  52078. /**
  52079. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52080. * @param scene scene in which to add meshes
  52081. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52082. */
  52083. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52084. /**
  52085. * Fired when the A button on this controller is modified
  52086. */
  52087. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52088. /**
  52089. * Fired when the B button on this controller is modified
  52090. */
  52091. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52092. /**
  52093. * Fired when the X button on this controller is modified
  52094. */
  52095. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52096. /**
  52097. * Fired when the Y button on this controller is modified
  52098. */
  52099. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52100. /**
  52101. * Called once for each button that changed state since the last frame
  52102. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52103. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52104. * 2) secondary trigger (same)
  52105. * 3) A (right) X (left), touch, pressed = value
  52106. * 4) B / Y
  52107. * 5) thumb rest
  52108. * @param buttonIdx Which button index changed
  52109. * @param state New state of the button
  52110. * @param changes Which properties on the state changed since last frame
  52111. */
  52112. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52113. }
  52114. }
  52115. declare module BABYLON {
  52116. /**
  52117. * Vive Controller
  52118. */
  52119. export class ViveController extends WebVRController {
  52120. /**
  52121. * Base Url for the controller model.
  52122. */
  52123. static MODEL_BASE_URL: string;
  52124. /**
  52125. * File name for the controller model.
  52126. */
  52127. static MODEL_FILENAME: string;
  52128. /**
  52129. * Creates a new ViveController from a gamepad
  52130. * @param vrGamepad the gamepad that the controller should be created from
  52131. */
  52132. constructor(vrGamepad: any);
  52133. /**
  52134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52135. * @param scene scene in which to add meshes
  52136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52137. */
  52138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52139. /**
  52140. * Fired when the left button on this controller is modified
  52141. */
  52142. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52143. /**
  52144. * Fired when the right button on this controller is modified
  52145. */
  52146. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52147. /**
  52148. * Fired when the menu button on this controller is modified
  52149. */
  52150. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52151. /**
  52152. * Called once for each button that changed state since the last frame
  52153. * Vive mapping:
  52154. * 0: touchpad
  52155. * 1: trigger
  52156. * 2: left AND right buttons
  52157. * 3: menu button
  52158. * @param buttonIdx Which button index changed
  52159. * @param state New state of the button
  52160. * @param changes Which properties on the state changed since last frame
  52161. */
  52162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52163. }
  52164. }
  52165. declare module BABYLON {
  52166. /**
  52167. * Defines the WindowsMotionController object that the state of the windows motion controller
  52168. */
  52169. export class WindowsMotionController extends WebVRController {
  52170. /**
  52171. * The base url used to load the left and right controller models
  52172. */
  52173. static MODEL_BASE_URL: string;
  52174. /**
  52175. * The name of the left controller model file
  52176. */
  52177. static MODEL_LEFT_FILENAME: string;
  52178. /**
  52179. * The name of the right controller model file
  52180. */
  52181. static MODEL_RIGHT_FILENAME: string;
  52182. /**
  52183. * The controller name prefix for this controller type
  52184. */
  52185. static readonly GAMEPAD_ID_PREFIX: string;
  52186. /**
  52187. * The controller id pattern for this controller type
  52188. */
  52189. private static readonly GAMEPAD_ID_PATTERN;
  52190. private _loadedMeshInfo;
  52191. protected readonly _mapping: {
  52192. buttons: string[];
  52193. buttonMeshNames: {
  52194. trigger: string;
  52195. menu: string;
  52196. grip: string;
  52197. thumbstick: string;
  52198. trackpad: string;
  52199. };
  52200. buttonObservableNames: {
  52201. trigger: string;
  52202. menu: string;
  52203. grip: string;
  52204. thumbstick: string;
  52205. trackpad: string;
  52206. };
  52207. axisMeshNames: string[];
  52208. pointingPoseMeshName: string;
  52209. };
  52210. /**
  52211. * Fired when the trackpad on this controller is clicked
  52212. */
  52213. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52214. /**
  52215. * Fired when the trackpad on this controller is modified
  52216. */
  52217. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52218. /**
  52219. * The current x and y values of this controller's trackpad
  52220. */
  52221. trackpad: StickValues;
  52222. /**
  52223. * Creates a new WindowsMotionController from a gamepad
  52224. * @param vrGamepad the gamepad that the controller should be created from
  52225. */
  52226. constructor(vrGamepad: any);
  52227. /**
  52228. * Fired when the trigger on this controller is modified
  52229. */
  52230. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52231. /**
  52232. * Fired when the menu button on this controller is modified
  52233. */
  52234. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52235. /**
  52236. * Fired when the grip button on this controller is modified
  52237. */
  52238. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52239. /**
  52240. * Fired when the thumbstick button on this controller is modified
  52241. */
  52242. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52243. /**
  52244. * Fired when the touchpad button on this controller is modified
  52245. */
  52246. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52247. /**
  52248. * Fired when the touchpad values on this controller are modified
  52249. */
  52250. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52251. protected _updateTrackpad(): void;
  52252. /**
  52253. * Called once per frame by the engine.
  52254. */
  52255. update(): void;
  52256. /**
  52257. * Called once for each button that changed state since the last frame
  52258. * @param buttonIdx Which button index changed
  52259. * @param state New state of the button
  52260. * @param changes Which properties on the state changed since last frame
  52261. */
  52262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52263. /**
  52264. * Moves the buttons on the controller mesh based on their current state
  52265. * @param buttonName the name of the button to move
  52266. * @param buttonValue the value of the button which determines the buttons new position
  52267. */
  52268. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52269. /**
  52270. * Moves the axis on the controller mesh based on its current state
  52271. * @param axis the index of the axis
  52272. * @param axisValue the value of the axis which determines the meshes new position
  52273. * @hidden
  52274. */
  52275. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52276. /**
  52277. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52278. * @param scene scene in which to add meshes
  52279. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52280. */
  52281. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52282. /**
  52283. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52284. * can be transformed by button presses and axes values, based on this._mapping.
  52285. *
  52286. * @param scene scene in which the meshes exist
  52287. * @param meshes list of meshes that make up the controller model to process
  52288. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52289. */
  52290. private processModel;
  52291. private createMeshInfo;
  52292. /**
  52293. * Gets the ray of the controller in the direction the controller is pointing
  52294. * @param length the length the resulting ray should be
  52295. * @returns a ray in the direction the controller is pointing
  52296. */
  52297. getForwardRay(length?: number): Ray;
  52298. /**
  52299. * Disposes of the controller
  52300. */
  52301. dispose(): void;
  52302. }
  52303. /**
  52304. * This class represents a new windows motion controller in XR.
  52305. */
  52306. export class XRWindowsMotionController extends WindowsMotionController {
  52307. /**
  52308. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52309. */
  52310. protected readonly _mapping: {
  52311. buttons: string[];
  52312. buttonMeshNames: {
  52313. trigger: string;
  52314. menu: string;
  52315. grip: string;
  52316. thumbstick: string;
  52317. trackpad: string;
  52318. };
  52319. buttonObservableNames: {
  52320. trigger: string;
  52321. menu: string;
  52322. grip: string;
  52323. thumbstick: string;
  52324. trackpad: string;
  52325. };
  52326. axisMeshNames: string[];
  52327. pointingPoseMeshName: string;
  52328. };
  52329. /**
  52330. * Construct a new XR-Based windows motion controller
  52331. *
  52332. * @param gamepadInfo the gamepad object from the browser
  52333. */
  52334. constructor(gamepadInfo: any);
  52335. /**
  52336. * holds the thumbstick values (X,Y)
  52337. */
  52338. thumbstickValues: StickValues;
  52339. /**
  52340. * Fired when the thumbstick on this controller is clicked
  52341. */
  52342. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52343. /**
  52344. * Fired when the thumbstick on this controller is modified
  52345. */
  52346. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52347. /**
  52348. * Fired when the touchpad button on this controller is modified
  52349. */
  52350. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52351. /**
  52352. * Fired when the touchpad values on this controller are modified
  52353. */
  52354. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52355. /**
  52356. * Fired when the thumbstick button on this controller is modified
  52357. * here to prevent breaking changes
  52358. */
  52359. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52360. /**
  52361. * updating the thumbstick(!) and not the trackpad.
  52362. * This is named this way due to the difference between WebVR and XR and to avoid
  52363. * changing the parent class.
  52364. */
  52365. protected _updateTrackpad(): void;
  52366. /**
  52367. * Disposes the class with joy
  52368. */
  52369. dispose(): void;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * Class containing static functions to help procedurally build meshes
  52375. */
  52376. export class PolyhedronBuilder {
  52377. /**
  52378. * Creates a polyhedron mesh
  52379. * * 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
  52380. * * The parameter `size` (positive float, default 1) sets the polygon size
  52381. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52382. * * 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`
  52383. * * 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
  52384. * * 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)`)
  52385. * * 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
  52386. * * 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
  52387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52388. * * 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
  52389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52390. * @param name defines the name of the mesh
  52391. * @param options defines the options used to create the mesh
  52392. * @param scene defines the hosting scene
  52393. * @returns the polyhedron mesh
  52394. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52395. */
  52396. static CreatePolyhedron(name: string, options: {
  52397. type?: number;
  52398. size?: number;
  52399. sizeX?: number;
  52400. sizeY?: number;
  52401. sizeZ?: number;
  52402. custom?: any;
  52403. faceUV?: Vector4[];
  52404. faceColors?: Color4[];
  52405. flat?: boolean;
  52406. updatable?: boolean;
  52407. sideOrientation?: number;
  52408. frontUVs?: Vector4;
  52409. backUVs?: Vector4;
  52410. }, scene?: Nullable<Scene>): Mesh;
  52411. }
  52412. }
  52413. declare module BABYLON {
  52414. /**
  52415. * Gizmo that enables scaling a mesh along 3 axis
  52416. */
  52417. export class ScaleGizmo extends Gizmo {
  52418. /**
  52419. * Internal gizmo used for interactions on the x axis
  52420. */
  52421. xGizmo: AxisScaleGizmo;
  52422. /**
  52423. * Internal gizmo used for interactions on the y axis
  52424. */
  52425. yGizmo: AxisScaleGizmo;
  52426. /**
  52427. * Internal gizmo used for interactions on the z axis
  52428. */
  52429. zGizmo: AxisScaleGizmo;
  52430. /**
  52431. * Internal gizmo used to scale all axis equally
  52432. */
  52433. uniformScaleGizmo: AxisScaleGizmo;
  52434. private _meshAttached;
  52435. private _updateGizmoRotationToMatchAttachedMesh;
  52436. private _snapDistance;
  52437. private _scaleRatio;
  52438. private _uniformScalingMesh;
  52439. private _octahedron;
  52440. private _sensitivity;
  52441. /** Fires an event when any of it's sub gizmos are dragged */
  52442. onDragStartObservable: Observable<unknown>;
  52443. /** Fires an event when any of it's sub gizmos are released from dragging */
  52444. onDragEndObservable: Observable<unknown>;
  52445. get attachedMesh(): Nullable<AbstractMesh>;
  52446. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52447. /**
  52448. * Creates a ScaleGizmo
  52449. * @param gizmoLayer The utility layer the gizmo will be added to
  52450. */
  52451. constructor(gizmoLayer?: UtilityLayerRenderer);
  52452. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52453. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52454. /**
  52455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52456. */
  52457. set snapDistance(value: number);
  52458. get snapDistance(): number;
  52459. /**
  52460. * Ratio for the scale of the gizmo (Default: 1)
  52461. */
  52462. set scaleRatio(value: number);
  52463. get scaleRatio(): number;
  52464. /**
  52465. * Sensitivity factor for dragging (Default: 1)
  52466. */
  52467. set sensitivity(value: number);
  52468. get sensitivity(): number;
  52469. /**
  52470. * Disposes of the gizmo
  52471. */
  52472. dispose(): void;
  52473. }
  52474. }
  52475. declare module BABYLON {
  52476. /**
  52477. * Single axis scale gizmo
  52478. */
  52479. export class AxisScaleGizmo extends Gizmo {
  52480. /**
  52481. * Drag behavior responsible for the gizmos dragging interactions
  52482. */
  52483. dragBehavior: PointerDragBehavior;
  52484. private _pointerObserver;
  52485. /**
  52486. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52487. */
  52488. snapDistance: number;
  52489. /**
  52490. * Event that fires each time the gizmo snaps to a new location.
  52491. * * snapDistance is the the change in distance
  52492. */
  52493. onSnapObservable: Observable<{
  52494. snapDistance: number;
  52495. }>;
  52496. /**
  52497. * If the scaling operation should be done on all axis (default: false)
  52498. */
  52499. uniformScaling: boolean;
  52500. /**
  52501. * Custom sensitivity value for the drag strength
  52502. */
  52503. sensitivity: number;
  52504. private _isEnabled;
  52505. private _parent;
  52506. private _arrow;
  52507. private _coloredMaterial;
  52508. private _hoverMaterial;
  52509. /**
  52510. * Creates an AxisScaleGizmo
  52511. * @param gizmoLayer The utility layer the gizmo will be added to
  52512. * @param dragAxis The axis which the gizmo will be able to scale on
  52513. * @param color The color of the gizmo
  52514. */
  52515. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52516. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52517. /**
  52518. * If the gizmo is enabled
  52519. */
  52520. set isEnabled(value: boolean);
  52521. get isEnabled(): boolean;
  52522. /**
  52523. * Disposes of the gizmo
  52524. */
  52525. dispose(): void;
  52526. /**
  52527. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52528. * @param mesh The mesh to replace the default mesh of the gizmo
  52529. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52530. */
  52531. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52532. }
  52533. }
  52534. declare module BABYLON {
  52535. /**
  52536. * Bounding box gizmo
  52537. */
  52538. export class BoundingBoxGizmo extends Gizmo {
  52539. private _lineBoundingBox;
  52540. private _rotateSpheresParent;
  52541. private _scaleBoxesParent;
  52542. private _boundingDimensions;
  52543. private _renderObserver;
  52544. private _pointerObserver;
  52545. private _scaleDragSpeed;
  52546. private _tmpQuaternion;
  52547. private _tmpVector;
  52548. private _tmpRotationMatrix;
  52549. /**
  52550. * 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)
  52551. */
  52552. ignoreChildren: boolean;
  52553. /**
  52554. * 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)
  52555. */
  52556. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52557. /**
  52558. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52559. */
  52560. rotationSphereSize: number;
  52561. /**
  52562. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52563. */
  52564. scaleBoxSize: number;
  52565. /**
  52566. * 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)
  52567. */
  52568. fixedDragMeshScreenSize: boolean;
  52569. /**
  52570. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52571. */
  52572. fixedDragMeshScreenSizeDistanceFactor: number;
  52573. /**
  52574. * Fired when a rotation sphere or scale box is dragged
  52575. */
  52576. onDragStartObservable: Observable<{}>;
  52577. /**
  52578. * Fired when a scale box is dragged
  52579. */
  52580. onScaleBoxDragObservable: Observable<{}>;
  52581. /**
  52582. * Fired when a scale box drag is ended
  52583. */
  52584. onScaleBoxDragEndObservable: Observable<{}>;
  52585. /**
  52586. * Fired when a rotation sphere is dragged
  52587. */
  52588. onRotationSphereDragObservable: Observable<{}>;
  52589. /**
  52590. * Fired when a rotation sphere drag is ended
  52591. */
  52592. onRotationSphereDragEndObservable: Observable<{}>;
  52593. /**
  52594. * 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)
  52595. */
  52596. scalePivot: Nullable<Vector3>;
  52597. /**
  52598. * Mesh used as a pivot to rotate the attached mesh
  52599. */
  52600. private _anchorMesh;
  52601. private _existingMeshScale;
  52602. private _dragMesh;
  52603. private pointerDragBehavior;
  52604. private coloredMaterial;
  52605. private hoverColoredMaterial;
  52606. /**
  52607. * Sets the color of the bounding box gizmo
  52608. * @param color the color to set
  52609. */
  52610. setColor(color: Color3): void;
  52611. /**
  52612. * Creates an BoundingBoxGizmo
  52613. * @param gizmoLayer The utility layer the gizmo will be added to
  52614. * @param color The color of the gizmo
  52615. */
  52616. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52617. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52618. private _selectNode;
  52619. /**
  52620. * Updates the bounding box information for the Gizmo
  52621. */
  52622. updateBoundingBox(): void;
  52623. private _updateRotationSpheres;
  52624. private _updateScaleBoxes;
  52625. /**
  52626. * Enables rotation on the specified axis and disables rotation on the others
  52627. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52628. */
  52629. setEnabledRotationAxis(axis: string): void;
  52630. /**
  52631. * Enables/disables scaling
  52632. * @param enable if scaling should be enabled
  52633. * @param homogeneousScaling defines if scaling should only be homogeneous
  52634. */
  52635. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52636. private _updateDummy;
  52637. /**
  52638. * Enables a pointer drag behavior on the bounding box of the gizmo
  52639. */
  52640. enableDragBehavior(): void;
  52641. /**
  52642. * Disposes of the gizmo
  52643. */
  52644. dispose(): void;
  52645. /**
  52646. * 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)
  52647. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52648. * @returns the bounding box mesh with the passed in mesh as a child
  52649. */
  52650. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52651. /**
  52652. * CustomMeshes are not supported by this gizmo
  52653. * @param mesh The mesh to replace the default mesh of the gizmo
  52654. */
  52655. setCustomMesh(mesh: Mesh): void;
  52656. }
  52657. }
  52658. declare module BABYLON {
  52659. /**
  52660. * Single plane rotation gizmo
  52661. */
  52662. export class PlaneRotationGizmo extends Gizmo {
  52663. /**
  52664. * Drag behavior responsible for the gizmos dragging interactions
  52665. */
  52666. dragBehavior: PointerDragBehavior;
  52667. private _pointerObserver;
  52668. /**
  52669. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52670. */
  52671. snapDistance: number;
  52672. /**
  52673. * Event that fires each time the gizmo snaps to a new location.
  52674. * * snapDistance is the the change in distance
  52675. */
  52676. onSnapObservable: Observable<{
  52677. snapDistance: number;
  52678. }>;
  52679. private _isEnabled;
  52680. private _parent;
  52681. /**
  52682. * Creates a PlaneRotationGizmo
  52683. * @param gizmoLayer The utility layer the gizmo will be added to
  52684. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52685. * @param color The color of the gizmo
  52686. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52687. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52688. */
  52689. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52690. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52691. /**
  52692. * If the gizmo is enabled
  52693. */
  52694. set isEnabled(value: boolean);
  52695. get isEnabled(): boolean;
  52696. /**
  52697. * Disposes of the gizmo
  52698. */
  52699. dispose(): void;
  52700. }
  52701. }
  52702. declare module BABYLON {
  52703. /**
  52704. * Gizmo that enables rotating a mesh along 3 axis
  52705. */
  52706. export class RotationGizmo extends Gizmo {
  52707. /**
  52708. * Internal gizmo used for interactions on the x axis
  52709. */
  52710. xGizmo: PlaneRotationGizmo;
  52711. /**
  52712. * Internal gizmo used for interactions on the y axis
  52713. */
  52714. yGizmo: PlaneRotationGizmo;
  52715. /**
  52716. * Internal gizmo used for interactions on the z axis
  52717. */
  52718. zGizmo: PlaneRotationGizmo;
  52719. /** Fires an event when any of it's sub gizmos are dragged */
  52720. onDragStartObservable: Observable<unknown>;
  52721. /** Fires an event when any of it's sub gizmos are released from dragging */
  52722. onDragEndObservable: Observable<unknown>;
  52723. private _meshAttached;
  52724. get attachedMesh(): Nullable<AbstractMesh>;
  52725. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52726. /**
  52727. * Creates a RotationGizmo
  52728. * @param gizmoLayer The utility layer the gizmo will be added to
  52729. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52730. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52731. */
  52732. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52733. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52734. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52735. /**
  52736. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52737. */
  52738. set snapDistance(value: number);
  52739. get snapDistance(): number;
  52740. /**
  52741. * Ratio for the scale of the gizmo (Default: 1)
  52742. */
  52743. set scaleRatio(value: number);
  52744. get scaleRatio(): number;
  52745. /**
  52746. * Disposes of the gizmo
  52747. */
  52748. dispose(): void;
  52749. /**
  52750. * CustomMeshes are not supported by this gizmo
  52751. * @param mesh The mesh to replace the default mesh of the gizmo
  52752. */
  52753. setCustomMesh(mesh: Mesh): void;
  52754. }
  52755. }
  52756. declare module BABYLON {
  52757. /**
  52758. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52759. */
  52760. export class GizmoManager implements IDisposable {
  52761. private scene;
  52762. /**
  52763. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52764. */
  52765. gizmos: {
  52766. positionGizmo: Nullable<PositionGizmo>;
  52767. rotationGizmo: Nullable<RotationGizmo>;
  52768. scaleGizmo: Nullable<ScaleGizmo>;
  52769. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52770. };
  52771. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52772. clearGizmoOnEmptyPointerEvent: boolean;
  52773. /** Fires an event when the manager is attached to a mesh */
  52774. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52775. private _gizmosEnabled;
  52776. private _pointerObserver;
  52777. private _attachedMesh;
  52778. private _boundingBoxColor;
  52779. private _defaultUtilityLayer;
  52780. private _defaultKeepDepthUtilityLayer;
  52781. /**
  52782. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52783. */
  52784. boundingBoxDragBehavior: SixDofDragBehavior;
  52785. /**
  52786. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52787. */
  52788. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52789. /**
  52790. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52791. */
  52792. usePointerToAttachGizmos: boolean;
  52793. /**
  52794. * Utility layer that the bounding box gizmo belongs to
  52795. */
  52796. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52797. /**
  52798. * Utility layer that all gizmos besides bounding box belong to
  52799. */
  52800. get utilityLayer(): UtilityLayerRenderer;
  52801. /**
  52802. * Instatiates a gizmo manager
  52803. * @param scene the scene to overlay the gizmos on top of
  52804. */
  52805. constructor(scene: Scene);
  52806. /**
  52807. * Attaches a set of gizmos to the specified mesh
  52808. * @param mesh The mesh the gizmo's should be attached to
  52809. */
  52810. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52811. /**
  52812. * If the position gizmo is enabled
  52813. */
  52814. set positionGizmoEnabled(value: boolean);
  52815. get positionGizmoEnabled(): boolean;
  52816. /**
  52817. * If the rotation gizmo is enabled
  52818. */
  52819. set rotationGizmoEnabled(value: boolean);
  52820. get rotationGizmoEnabled(): boolean;
  52821. /**
  52822. * If the scale gizmo is enabled
  52823. */
  52824. set scaleGizmoEnabled(value: boolean);
  52825. get scaleGizmoEnabled(): boolean;
  52826. /**
  52827. * If the boundingBox gizmo is enabled
  52828. */
  52829. set boundingBoxGizmoEnabled(value: boolean);
  52830. get boundingBoxGizmoEnabled(): boolean;
  52831. /**
  52832. * Disposes of the gizmo manager
  52833. */
  52834. dispose(): void;
  52835. }
  52836. }
  52837. declare module BABYLON {
  52838. /**
  52839. * A directional light is defined by a direction (what a surprise!).
  52840. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52841. * 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.
  52842. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52843. */
  52844. export class DirectionalLight extends ShadowLight {
  52845. private _shadowFrustumSize;
  52846. /**
  52847. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52848. */
  52849. get shadowFrustumSize(): number;
  52850. /**
  52851. * Specifies a fix frustum size for the shadow generation.
  52852. */
  52853. set shadowFrustumSize(value: number);
  52854. private _shadowOrthoScale;
  52855. /**
  52856. * Gets the shadow projection scale against the optimal computed one.
  52857. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52858. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52859. */
  52860. get shadowOrthoScale(): number;
  52861. /**
  52862. * Sets 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. set shadowOrthoScale(value: number);
  52867. /**
  52868. * Automatically compute the projection matrix to best fit (including all the casters)
  52869. * on each frame.
  52870. */
  52871. autoUpdateExtends: boolean;
  52872. /**
  52873. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52874. * on each frame. autoUpdateExtends must be set to true for this to work
  52875. */
  52876. autoCalcShadowZBounds: boolean;
  52877. private _orthoLeft;
  52878. private _orthoRight;
  52879. private _orthoTop;
  52880. private _orthoBottom;
  52881. /**
  52882. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52883. * The directional light is emitted from everywhere in the given direction.
  52884. * It can cast shadows.
  52885. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52886. * @param name The friendly name of the light
  52887. * @param direction The direction of the light
  52888. * @param scene The scene the light belongs to
  52889. */
  52890. constructor(name: string, direction: Vector3, scene: Scene);
  52891. /**
  52892. * Returns the string "DirectionalLight".
  52893. * @return The class name
  52894. */
  52895. getClassName(): string;
  52896. /**
  52897. * Returns the integer 1.
  52898. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52899. */
  52900. getTypeID(): number;
  52901. /**
  52902. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52903. * Returns the DirectionalLight Shadow projection matrix.
  52904. */
  52905. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52906. /**
  52907. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52908. * Returns the DirectionalLight Shadow projection matrix.
  52909. */
  52910. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52911. /**
  52912. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52913. * Returns the DirectionalLight Shadow projection matrix.
  52914. */
  52915. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52916. protected _buildUniformLayout(): void;
  52917. /**
  52918. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52919. * @param effect The effect to update
  52920. * @param lightIndex The index of the light in the effect to update
  52921. * @returns The directional light
  52922. */
  52923. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52924. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52925. /**
  52926. * Gets the minZ used for shadow according to both the scene and the light.
  52927. *
  52928. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52929. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52930. * @param activeCamera The camera we are returning the min for
  52931. * @returns the depth min z
  52932. */
  52933. getDepthMinZ(activeCamera: Camera): number;
  52934. /**
  52935. * Gets the maxZ used for shadow according to both the scene and the light.
  52936. *
  52937. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52938. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52939. * @param activeCamera The camera we are returning the max for
  52940. * @returns the depth max z
  52941. */
  52942. getDepthMaxZ(activeCamera: Camera): number;
  52943. /**
  52944. * Prepares the list of defines specific to the light type.
  52945. * @param defines the list of defines
  52946. * @param lightIndex defines the index of the light for the effect
  52947. */
  52948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52949. }
  52950. }
  52951. declare module BABYLON {
  52952. /**
  52953. * Class containing static functions to help procedurally build meshes
  52954. */
  52955. export class HemisphereBuilder {
  52956. /**
  52957. * Creates a hemisphere mesh
  52958. * @param name defines the name of the mesh
  52959. * @param options defines the options used to create the mesh
  52960. * @param scene defines the hosting scene
  52961. * @returns the hemisphere mesh
  52962. */
  52963. static CreateHemisphere(name: string, options: {
  52964. segments?: number;
  52965. diameter?: number;
  52966. sideOrientation?: number;
  52967. }, scene: any): Mesh;
  52968. }
  52969. }
  52970. declare module BABYLON {
  52971. /**
  52972. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52973. * These values define a cone of light starting from the position, emitting toward the direction.
  52974. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52975. * and the exponent defines the speed of the decay of the light with distance (reach).
  52976. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52977. */
  52978. export class SpotLight extends ShadowLight {
  52979. private _angle;
  52980. private _innerAngle;
  52981. private _cosHalfAngle;
  52982. private _lightAngleScale;
  52983. private _lightAngleOffset;
  52984. /**
  52985. * Gets the cone angle of the spot light in Radians.
  52986. */
  52987. get angle(): number;
  52988. /**
  52989. * Sets the cone angle of the spot light in Radians.
  52990. */
  52991. set angle(value: number);
  52992. /**
  52993. * Only used in gltf falloff mode, this defines the angle where
  52994. * the directional falloff will start before cutting at angle which could be seen
  52995. * as outer angle.
  52996. */
  52997. get innerAngle(): 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. set innerAngle(value: number);
  53004. private _shadowAngleScale;
  53005. /**
  53006. * Allows scaling the angle of the light for shadow generation only.
  53007. */
  53008. get shadowAngleScale(): number;
  53009. /**
  53010. * Allows scaling the angle of the light for shadow generation only.
  53011. */
  53012. set shadowAngleScale(value: number);
  53013. /**
  53014. * The light decay speed with the distance from the emission spot.
  53015. */
  53016. exponent: number;
  53017. private _projectionTextureMatrix;
  53018. /**
  53019. * Allows reading the projecton texture
  53020. */
  53021. get projectionTextureMatrix(): Matrix;
  53022. protected _projectionTextureLightNear: number;
  53023. /**
  53024. * Gets the near clip of the Spotlight for texture projection.
  53025. */
  53026. get projectionTextureLightNear(): number;
  53027. /**
  53028. * Sets the near clip of the Spotlight for texture projection.
  53029. */
  53030. set projectionTextureLightNear(value: number);
  53031. protected _projectionTextureLightFar: number;
  53032. /**
  53033. * Gets the far clip of the Spotlight for texture projection.
  53034. */
  53035. get projectionTextureLightFar(): number;
  53036. /**
  53037. * Sets the far clip of the Spotlight for texture projection.
  53038. */
  53039. set projectionTextureLightFar(value: number);
  53040. protected _projectionTextureUpDirection: Vector3;
  53041. /**
  53042. * Gets the Up vector of the Spotlight for texture projection.
  53043. */
  53044. get projectionTextureUpDirection(): Vector3;
  53045. /**
  53046. * Sets the Up vector of the Spotlight for texture projection.
  53047. */
  53048. set projectionTextureUpDirection(value: Vector3);
  53049. private _projectionTexture;
  53050. /**
  53051. * Gets the projection texture of the light.
  53052. */
  53053. get projectionTexture(): Nullable<BaseTexture>;
  53054. /**
  53055. * Sets the projection texture of the light.
  53056. */
  53057. set projectionTexture(value: Nullable<BaseTexture>);
  53058. private _projectionTextureViewLightDirty;
  53059. private _projectionTextureProjectionLightDirty;
  53060. private _projectionTextureDirty;
  53061. private _projectionTextureViewTargetVector;
  53062. private _projectionTextureViewLightMatrix;
  53063. private _projectionTextureProjectionLightMatrix;
  53064. private _projectionTextureScalingMatrix;
  53065. /**
  53066. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53067. * It can cast shadows.
  53068. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53069. * @param name The light friendly name
  53070. * @param position The position of the spot light in the scene
  53071. * @param direction The direction of the light in the scene
  53072. * @param angle The cone angle of the light in Radians
  53073. * @param exponent The light decay speed with the distance from the emission spot
  53074. * @param scene The scene the lights belongs to
  53075. */
  53076. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53077. /**
  53078. * Returns the string "SpotLight".
  53079. * @returns the class name
  53080. */
  53081. getClassName(): string;
  53082. /**
  53083. * Returns the integer 2.
  53084. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53085. */
  53086. getTypeID(): number;
  53087. /**
  53088. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53089. */
  53090. protected _setDirection(value: Vector3): void;
  53091. /**
  53092. * Overrides the position setter to recompute the projection texture view light Matrix.
  53093. */
  53094. protected _setPosition(value: Vector3): void;
  53095. /**
  53096. * 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.
  53097. * Returns the SpotLight.
  53098. */
  53099. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53100. protected _computeProjectionTextureViewLightMatrix(): void;
  53101. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53102. /**
  53103. * Main function for light texture projection matrix computing.
  53104. */
  53105. protected _computeProjectionTextureMatrix(): void;
  53106. protected _buildUniformLayout(): void;
  53107. private _computeAngleValues;
  53108. /**
  53109. * Sets the passed Effect "effect" with the Light textures.
  53110. * @param effect The effect to update
  53111. * @param lightIndex The index of the light in the effect to update
  53112. * @returns The light
  53113. */
  53114. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53115. /**
  53116. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53117. * @param effect The effect to update
  53118. * @param lightIndex The index of the light in the effect to update
  53119. * @returns The spot light
  53120. */
  53121. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53122. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53123. /**
  53124. * Disposes the light and the associated resources.
  53125. */
  53126. dispose(): void;
  53127. /**
  53128. * Prepares the list of defines specific to the light type.
  53129. * @param defines the list of defines
  53130. * @param lightIndex defines the index of the light for the effect
  53131. */
  53132. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53133. }
  53134. }
  53135. declare module BABYLON {
  53136. /**
  53137. * Gizmo that enables viewing a light
  53138. */
  53139. export class LightGizmo extends Gizmo {
  53140. private _lightMesh;
  53141. private _material;
  53142. private _cachedPosition;
  53143. private _cachedForward;
  53144. private _attachedMeshParent;
  53145. /**
  53146. * Creates a LightGizmo
  53147. * @param gizmoLayer The utility layer the gizmo will be added to
  53148. */
  53149. constructor(gizmoLayer?: UtilityLayerRenderer);
  53150. private _light;
  53151. /**
  53152. * The light that the gizmo is attached to
  53153. */
  53154. set light(light: Nullable<Light>);
  53155. get light(): Nullable<Light>;
  53156. /**
  53157. * Gets the material used to render the light gizmo
  53158. */
  53159. get material(): StandardMaterial;
  53160. /**
  53161. * @hidden
  53162. * Updates the gizmo to match the attached mesh's position/rotation
  53163. */
  53164. protected _update(): void;
  53165. private static _Scale;
  53166. /**
  53167. * Creates the lines for a light mesh
  53168. */
  53169. private static _CreateLightLines;
  53170. /**
  53171. * Disposes of the light gizmo
  53172. */
  53173. dispose(): void;
  53174. private static _CreateHemisphericLightMesh;
  53175. private static _CreatePointLightMesh;
  53176. private static _CreateSpotLightMesh;
  53177. private static _CreateDirectionalLightMesh;
  53178. }
  53179. }
  53180. declare module BABYLON {
  53181. /** @hidden */
  53182. export var backgroundFragmentDeclaration: {
  53183. name: string;
  53184. shader: string;
  53185. };
  53186. }
  53187. declare module BABYLON {
  53188. /** @hidden */
  53189. export var backgroundUboDeclaration: {
  53190. name: string;
  53191. shader: string;
  53192. };
  53193. }
  53194. declare module BABYLON {
  53195. /** @hidden */
  53196. export var backgroundPixelShader: {
  53197. name: string;
  53198. shader: string;
  53199. };
  53200. }
  53201. declare module BABYLON {
  53202. /** @hidden */
  53203. export var backgroundVertexDeclaration: {
  53204. name: string;
  53205. shader: string;
  53206. };
  53207. }
  53208. declare module BABYLON {
  53209. /** @hidden */
  53210. export var backgroundVertexShader: {
  53211. name: string;
  53212. shader: string;
  53213. };
  53214. }
  53215. declare module BABYLON {
  53216. /**
  53217. * Background material used to create an efficient environement around your scene.
  53218. */
  53219. export class BackgroundMaterial extends PushMaterial {
  53220. /**
  53221. * Standard reflectance value at parallel view angle.
  53222. */
  53223. static StandardReflectance0: number;
  53224. /**
  53225. * Standard reflectance value at grazing angle.
  53226. */
  53227. static StandardReflectance90: number;
  53228. protected _primaryColor: Color3;
  53229. /**
  53230. * Key light Color (multiply against the environement texture)
  53231. */
  53232. primaryColor: Color3;
  53233. protected __perceptualColor: Nullable<Color3>;
  53234. /**
  53235. * Experimental Internal Use Only.
  53236. *
  53237. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53238. * This acts as a helper to set the primary color to a more "human friendly" value.
  53239. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53240. * output color as close as possible from the chosen value.
  53241. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53242. * part of lighting setup.)
  53243. */
  53244. get _perceptualColor(): Nullable<Color3>;
  53245. set _perceptualColor(value: Nullable<Color3>);
  53246. protected _primaryColorShadowLevel: float;
  53247. /**
  53248. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53249. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53250. */
  53251. get primaryColorShadowLevel(): float;
  53252. set primaryColorShadowLevel(value: float);
  53253. protected _primaryColorHighlightLevel: float;
  53254. /**
  53255. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53256. * The primary color is used at the level chosen to define what the white area would look.
  53257. */
  53258. get primaryColorHighlightLevel(): float;
  53259. set primaryColorHighlightLevel(value: float);
  53260. protected _reflectionTexture: Nullable<BaseTexture>;
  53261. /**
  53262. * Reflection Texture used in the material.
  53263. * Should be author in a specific way for the best result (refer to the documentation).
  53264. */
  53265. reflectionTexture: Nullable<BaseTexture>;
  53266. protected _reflectionBlur: float;
  53267. /**
  53268. * Reflection Texture level of blur.
  53269. *
  53270. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53271. * texture twice.
  53272. */
  53273. reflectionBlur: float;
  53274. protected _diffuseTexture: Nullable<BaseTexture>;
  53275. /**
  53276. * Diffuse Texture used in the material.
  53277. * Should be author in a specific way for the best result (refer to the documentation).
  53278. */
  53279. diffuseTexture: Nullable<BaseTexture>;
  53280. protected _shadowLights: Nullable<IShadowLight[]>;
  53281. /**
  53282. * Specify the list of lights casting shadow on the material.
  53283. * All scene shadow lights will be included if null.
  53284. */
  53285. shadowLights: Nullable<IShadowLight[]>;
  53286. protected _shadowLevel: float;
  53287. /**
  53288. * Helps adjusting the shadow to a softer level if required.
  53289. * 0 means black shadows and 1 means no shadows.
  53290. */
  53291. shadowLevel: float;
  53292. protected _sceneCenter: Vector3;
  53293. /**
  53294. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53295. * It is usually zero but might be interesting to modify according to your setup.
  53296. */
  53297. sceneCenter: Vector3;
  53298. protected _opacityFresnel: boolean;
  53299. /**
  53300. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53301. * This helps ensuring a nice transition when the camera goes under the ground.
  53302. */
  53303. opacityFresnel: boolean;
  53304. protected _reflectionFresnel: boolean;
  53305. /**
  53306. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53307. * This helps adding a mirror texture on the ground.
  53308. */
  53309. reflectionFresnel: boolean;
  53310. protected _reflectionFalloffDistance: number;
  53311. /**
  53312. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53313. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53314. */
  53315. reflectionFalloffDistance: number;
  53316. protected _reflectionAmount: number;
  53317. /**
  53318. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53319. */
  53320. reflectionAmount: number;
  53321. protected _reflectionReflectance0: number;
  53322. /**
  53323. * This specifies the weight of the reflection at grazing angle.
  53324. */
  53325. reflectionReflectance0: number;
  53326. protected _reflectionReflectance90: number;
  53327. /**
  53328. * This specifies the weight of the reflection at a perpendicular point of view.
  53329. */
  53330. reflectionReflectance90: number;
  53331. /**
  53332. * Sets the reflection reflectance fresnel values according to the default standard
  53333. * empirically know to work well :-)
  53334. */
  53335. set reflectionStandardFresnelWeight(value: number);
  53336. protected _useRGBColor: boolean;
  53337. /**
  53338. * Helps to directly use the maps channels instead of their level.
  53339. */
  53340. useRGBColor: boolean;
  53341. protected _enableNoise: boolean;
  53342. /**
  53343. * This helps reducing the banding effect that could occur on the background.
  53344. */
  53345. enableNoise: boolean;
  53346. /**
  53347. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53348. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53349. * Recommended to be keep at 1.0 except for special cases.
  53350. */
  53351. get fovMultiplier(): number;
  53352. set fovMultiplier(value: number);
  53353. private _fovMultiplier;
  53354. /**
  53355. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53356. */
  53357. useEquirectangularFOV: boolean;
  53358. private _maxSimultaneousLights;
  53359. /**
  53360. * Number of Simultaneous lights allowed on the material.
  53361. */
  53362. maxSimultaneousLights: int;
  53363. private _shadowOnly;
  53364. /**
  53365. * Make the material only render shadows
  53366. */
  53367. shadowOnly: boolean;
  53368. /**
  53369. * Default configuration related to image processing available in the Background Material.
  53370. */
  53371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53372. /**
  53373. * Keep track of the image processing observer to allow dispose and replace.
  53374. */
  53375. private _imageProcessingObserver;
  53376. /**
  53377. * Attaches a new image processing configuration to the PBR Material.
  53378. * @param configuration (if null the scene configuration will be use)
  53379. */
  53380. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53381. /**
  53382. * Gets the image processing configuration used either in this material.
  53383. */
  53384. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53385. /**
  53386. * Sets the Default image processing configuration used either in the this material.
  53387. *
  53388. * If sets to null, the scene one is in use.
  53389. */
  53390. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53391. /**
  53392. * Gets wether the color curves effect is enabled.
  53393. */
  53394. get cameraColorCurvesEnabled(): boolean;
  53395. /**
  53396. * Sets wether the color curves effect is enabled.
  53397. */
  53398. set cameraColorCurvesEnabled(value: boolean);
  53399. /**
  53400. * Gets wether the color grading effect is enabled.
  53401. */
  53402. get cameraColorGradingEnabled(): boolean;
  53403. /**
  53404. * Gets wether the color grading effect is enabled.
  53405. */
  53406. set cameraColorGradingEnabled(value: boolean);
  53407. /**
  53408. * Gets wether tonemapping is enabled or not.
  53409. */
  53410. get cameraToneMappingEnabled(): boolean;
  53411. /**
  53412. * Sets wether tonemapping is enabled or not
  53413. */
  53414. set cameraToneMappingEnabled(value: boolean);
  53415. /**
  53416. * The camera exposure used on this material.
  53417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53418. * This corresponds to a photographic exposure.
  53419. */
  53420. get cameraExposure(): float;
  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. set cameraExposure(value: float);
  53427. /**
  53428. * Gets The camera contrast used on this material.
  53429. */
  53430. get cameraContrast(): float;
  53431. /**
  53432. * Sets The camera contrast used on this material.
  53433. */
  53434. set cameraContrast(value: float);
  53435. /**
  53436. * Gets the Color Grading 2D Lookup Texture.
  53437. */
  53438. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53439. /**
  53440. * Sets the Color Grading 2D Lookup Texture.
  53441. */
  53442. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53443. /**
  53444. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53445. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53446. * 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;
  53447. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53448. */
  53449. get cameraColorCurves(): Nullable<ColorCurves>;
  53450. /**
  53451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53453. * 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;
  53454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53455. */
  53456. set cameraColorCurves(value: Nullable<ColorCurves>);
  53457. /**
  53458. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53459. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53460. */
  53461. switchToBGR: boolean;
  53462. private _renderTargets;
  53463. private _reflectionControls;
  53464. private _white;
  53465. private _primaryShadowColor;
  53466. private _primaryHighlightColor;
  53467. /**
  53468. * Instantiates a Background Material in the given scene
  53469. * @param name The friendly name of the material
  53470. * @param scene The scene to add the material to
  53471. */
  53472. constructor(name: string, scene: Scene);
  53473. /**
  53474. * Gets a boolean indicating that current material needs to register RTT
  53475. */
  53476. get hasRenderTargetTextures(): boolean;
  53477. /**
  53478. * The entire material has been created in order to prevent overdraw.
  53479. * @returns false
  53480. */
  53481. needAlphaTesting(): boolean;
  53482. /**
  53483. * The entire material has been created in order to prevent overdraw.
  53484. * @returns true if blending is enable
  53485. */
  53486. needAlphaBlending(): boolean;
  53487. /**
  53488. * Checks wether the material is ready to be rendered for a given mesh.
  53489. * @param mesh The mesh to render
  53490. * @param subMesh The submesh to check against
  53491. * @param useInstances Specify wether or not the material is used with instances
  53492. * @returns true if all the dependencies are ready (Textures, Effects...)
  53493. */
  53494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53495. /**
  53496. * Compute the primary color according to the chosen perceptual color.
  53497. */
  53498. private _computePrimaryColorFromPerceptualColor;
  53499. /**
  53500. * Compute the highlights and shadow colors according to their chosen levels.
  53501. */
  53502. private _computePrimaryColors;
  53503. /**
  53504. * Build the uniform buffer used in the material.
  53505. */
  53506. buildUniformLayout(): void;
  53507. /**
  53508. * Unbind the material.
  53509. */
  53510. unbind(): void;
  53511. /**
  53512. * Bind only the world matrix to the material.
  53513. * @param world The world matrix to bind.
  53514. */
  53515. bindOnlyWorldMatrix(world: Matrix): void;
  53516. /**
  53517. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53518. * @param world The world matrix to bind.
  53519. * @param subMesh The submesh to bind for.
  53520. */
  53521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53522. /**
  53523. * Checks to see if a texture is used in the material.
  53524. * @param texture - Base texture to use.
  53525. * @returns - Boolean specifying if a texture is used in the material.
  53526. */
  53527. hasTexture(texture: BaseTexture): boolean;
  53528. /**
  53529. * Dispose the material.
  53530. * @param forceDisposeEffect Force disposal of the associated effect.
  53531. * @param forceDisposeTextures Force disposal of the associated textures.
  53532. */
  53533. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53534. /**
  53535. * Clones the material.
  53536. * @param name The cloned name.
  53537. * @returns The cloned material.
  53538. */
  53539. clone(name: string): BackgroundMaterial;
  53540. /**
  53541. * Serializes the current material to its JSON representation.
  53542. * @returns The JSON representation.
  53543. */
  53544. serialize(): any;
  53545. /**
  53546. * Gets the class name of the material
  53547. * @returns "BackgroundMaterial"
  53548. */
  53549. getClassName(): string;
  53550. /**
  53551. * Parse a JSON input to create back a background material.
  53552. * @param source The JSON data to parse
  53553. * @param scene The scene to create the parsed material in
  53554. * @param rootUrl The root url of the assets the material depends upon
  53555. * @returns the instantiated BackgroundMaterial.
  53556. */
  53557. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53558. }
  53559. }
  53560. declare module BABYLON {
  53561. /**
  53562. * Represents the different options available during the creation of
  53563. * a Environment helper.
  53564. *
  53565. * This can control the default ground, skybox and image processing setup of your scene.
  53566. */
  53567. export interface IEnvironmentHelperOptions {
  53568. /**
  53569. * Specifies whether or not to create a ground.
  53570. * True by default.
  53571. */
  53572. createGround: boolean;
  53573. /**
  53574. * Specifies the ground size.
  53575. * 15 by default.
  53576. */
  53577. groundSize: number;
  53578. /**
  53579. * The texture used on the ground for the main color.
  53580. * Comes from the BabylonJS CDN by default.
  53581. *
  53582. * Remarks: Can be either a texture or a url.
  53583. */
  53584. groundTexture: string | BaseTexture;
  53585. /**
  53586. * The color mixed in the ground texture by default.
  53587. * BabylonJS clearColor by default.
  53588. */
  53589. groundColor: Color3;
  53590. /**
  53591. * Specifies the ground opacity.
  53592. * 1 by default.
  53593. */
  53594. groundOpacity: number;
  53595. /**
  53596. * Enables the ground to receive shadows.
  53597. * True by default.
  53598. */
  53599. enableGroundShadow: boolean;
  53600. /**
  53601. * Helps preventing the shadow to be fully black on the ground.
  53602. * 0.5 by default.
  53603. */
  53604. groundShadowLevel: number;
  53605. /**
  53606. * Creates a mirror texture attach to the ground.
  53607. * false by default.
  53608. */
  53609. enableGroundMirror: boolean;
  53610. /**
  53611. * Specifies the ground mirror size ratio.
  53612. * 0.3 by default as the default kernel is 64.
  53613. */
  53614. groundMirrorSizeRatio: number;
  53615. /**
  53616. * Specifies the ground mirror blur kernel size.
  53617. * 64 by default.
  53618. */
  53619. groundMirrorBlurKernel: number;
  53620. /**
  53621. * Specifies the ground mirror visibility amount.
  53622. * 1 by default
  53623. */
  53624. groundMirrorAmount: number;
  53625. /**
  53626. * Specifies the ground mirror reflectance weight.
  53627. * This uses the standard weight of the background material to setup the fresnel effect
  53628. * of the mirror.
  53629. * 1 by default.
  53630. */
  53631. groundMirrorFresnelWeight: number;
  53632. /**
  53633. * Specifies the ground mirror Falloff distance.
  53634. * This can helps reducing the size of the reflection.
  53635. * 0 by Default.
  53636. */
  53637. groundMirrorFallOffDistance: number;
  53638. /**
  53639. * Specifies the ground mirror texture type.
  53640. * Unsigned Int by Default.
  53641. */
  53642. groundMirrorTextureType: number;
  53643. /**
  53644. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53645. * the shown objects.
  53646. */
  53647. groundYBias: number;
  53648. /**
  53649. * Specifies whether or not to create a skybox.
  53650. * True by default.
  53651. */
  53652. createSkybox: boolean;
  53653. /**
  53654. * Specifies the skybox size.
  53655. * 20 by default.
  53656. */
  53657. skyboxSize: number;
  53658. /**
  53659. * The texture used on the skybox for the main color.
  53660. * Comes from the BabylonJS CDN by default.
  53661. *
  53662. * Remarks: Can be either a texture or a url.
  53663. */
  53664. skyboxTexture: string | BaseTexture;
  53665. /**
  53666. * The color mixed in the skybox texture by default.
  53667. * BabylonJS clearColor by default.
  53668. */
  53669. skyboxColor: Color3;
  53670. /**
  53671. * The background rotation around the Y axis of the scene.
  53672. * This helps aligning the key lights of your scene with the background.
  53673. * 0 by default.
  53674. */
  53675. backgroundYRotation: number;
  53676. /**
  53677. * Compute automatically the size of the elements to best fit with the scene.
  53678. */
  53679. sizeAuto: boolean;
  53680. /**
  53681. * Default position of the rootMesh if autoSize is not true.
  53682. */
  53683. rootPosition: Vector3;
  53684. /**
  53685. * Sets up the image processing in the scene.
  53686. * true by default.
  53687. */
  53688. setupImageProcessing: boolean;
  53689. /**
  53690. * The texture used as your environment texture in the scene.
  53691. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53692. *
  53693. * Remarks: Can be either a texture or a url.
  53694. */
  53695. environmentTexture: string | BaseTexture;
  53696. /**
  53697. * The value of the exposure to apply to the scene.
  53698. * 0.6 by default if setupImageProcessing is true.
  53699. */
  53700. cameraExposure: number;
  53701. /**
  53702. * The value of the contrast to apply to the scene.
  53703. * 1.6 by default if setupImageProcessing is true.
  53704. */
  53705. cameraContrast: number;
  53706. /**
  53707. * Specifies whether or not tonemapping should be enabled in the scene.
  53708. * true by default if setupImageProcessing is true.
  53709. */
  53710. toneMappingEnabled: boolean;
  53711. }
  53712. /**
  53713. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53714. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53715. * It also helps with the default setup of your imageProcessing configuration.
  53716. */
  53717. export class EnvironmentHelper {
  53718. /**
  53719. * Default ground texture URL.
  53720. */
  53721. private static _groundTextureCDNUrl;
  53722. /**
  53723. * Default skybox texture URL.
  53724. */
  53725. private static _skyboxTextureCDNUrl;
  53726. /**
  53727. * Default environment texture URL.
  53728. */
  53729. private static _environmentTextureCDNUrl;
  53730. /**
  53731. * Creates the default options for the helper.
  53732. */
  53733. private static _getDefaultOptions;
  53734. private _rootMesh;
  53735. /**
  53736. * Gets the root mesh created by the helper.
  53737. */
  53738. get rootMesh(): Mesh;
  53739. private _skybox;
  53740. /**
  53741. * Gets the skybox created by the helper.
  53742. */
  53743. get skybox(): Nullable<Mesh>;
  53744. private _skyboxTexture;
  53745. /**
  53746. * Gets the skybox texture created by the helper.
  53747. */
  53748. get skyboxTexture(): Nullable<BaseTexture>;
  53749. private _skyboxMaterial;
  53750. /**
  53751. * Gets the skybox material created by the helper.
  53752. */
  53753. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53754. private _ground;
  53755. /**
  53756. * Gets the ground mesh created by the helper.
  53757. */
  53758. get ground(): Nullable<Mesh>;
  53759. private _groundTexture;
  53760. /**
  53761. * Gets the ground texture created by the helper.
  53762. */
  53763. get groundTexture(): Nullable<BaseTexture>;
  53764. private _groundMirror;
  53765. /**
  53766. * Gets the ground mirror created by the helper.
  53767. */
  53768. get groundMirror(): Nullable<MirrorTexture>;
  53769. /**
  53770. * Gets the ground mirror render list to helps pushing the meshes
  53771. * you wish in the ground reflection.
  53772. */
  53773. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53774. private _groundMaterial;
  53775. /**
  53776. * Gets the ground material created by the helper.
  53777. */
  53778. get groundMaterial(): Nullable<BackgroundMaterial>;
  53779. /**
  53780. * Stores the creation options.
  53781. */
  53782. private readonly _scene;
  53783. private _options;
  53784. /**
  53785. * This observable will be notified with any error during the creation of the environment,
  53786. * mainly texture creation errors.
  53787. */
  53788. onErrorObservable: Observable<{
  53789. message?: string;
  53790. exception?: any;
  53791. }>;
  53792. /**
  53793. * constructor
  53794. * @param options Defines the options we want to customize the helper
  53795. * @param scene The scene to add the material to
  53796. */
  53797. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53798. /**
  53799. * Updates the background according to the new options
  53800. * @param options
  53801. */
  53802. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53803. /**
  53804. * Sets the primary color of all the available elements.
  53805. * @param color the main color to affect to the ground and the background
  53806. */
  53807. setMainColor(color: Color3): void;
  53808. /**
  53809. * Setup the image processing according to the specified options.
  53810. */
  53811. private _setupImageProcessing;
  53812. /**
  53813. * Setup the environment texture according to the specified options.
  53814. */
  53815. private _setupEnvironmentTexture;
  53816. /**
  53817. * Setup the background according to the specified options.
  53818. */
  53819. private _setupBackground;
  53820. /**
  53821. * Get the scene sizes according to the setup.
  53822. */
  53823. private _getSceneSize;
  53824. /**
  53825. * Setup the ground according to the specified options.
  53826. */
  53827. private _setupGround;
  53828. /**
  53829. * Setup the ground material according to the specified options.
  53830. */
  53831. private _setupGroundMaterial;
  53832. /**
  53833. * Setup the ground diffuse texture according to the specified options.
  53834. */
  53835. private _setupGroundDiffuseTexture;
  53836. /**
  53837. * Setup the ground mirror texture according to the specified options.
  53838. */
  53839. private _setupGroundMirrorTexture;
  53840. /**
  53841. * Setup the ground to receive the mirror texture.
  53842. */
  53843. private _setupMirrorInGroundMaterial;
  53844. /**
  53845. * Setup the skybox according to the specified options.
  53846. */
  53847. private _setupSkybox;
  53848. /**
  53849. * Setup the skybox material according to the specified options.
  53850. */
  53851. private _setupSkyboxMaterial;
  53852. /**
  53853. * Setup the skybox reflection texture according to the specified options.
  53854. */
  53855. private _setupSkyboxReflectionTexture;
  53856. private _errorHandler;
  53857. /**
  53858. * Dispose all the elements created by the Helper.
  53859. */
  53860. dispose(): void;
  53861. }
  53862. }
  53863. declare module BABYLON {
  53864. /**
  53865. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53866. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53867. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53868. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53869. */
  53870. export class PhotoDome extends TransformNode {
  53871. /**
  53872. * Define the image as a Monoscopic panoramic 360 image.
  53873. */
  53874. static readonly MODE_MONOSCOPIC: number;
  53875. /**
  53876. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53877. */
  53878. static readonly MODE_TOPBOTTOM: number;
  53879. /**
  53880. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53881. */
  53882. static readonly MODE_SIDEBYSIDE: number;
  53883. private _useDirectMapping;
  53884. /**
  53885. * The texture being displayed on the sphere
  53886. */
  53887. protected _photoTexture: Texture;
  53888. /**
  53889. * Gets or sets the texture being displayed on the sphere
  53890. */
  53891. get photoTexture(): Texture;
  53892. set photoTexture(value: Texture);
  53893. /**
  53894. * Observable raised when an error occured while loading the 360 image
  53895. */
  53896. onLoadErrorObservable: Observable<string>;
  53897. /**
  53898. * The skybox material
  53899. */
  53900. protected _material: BackgroundMaterial;
  53901. /**
  53902. * The surface used for the skybox
  53903. */
  53904. protected _mesh: Mesh;
  53905. /**
  53906. * Gets the mesh used for the skybox.
  53907. */
  53908. get mesh(): Mesh;
  53909. /**
  53910. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53911. * Also see the options.resolution property.
  53912. */
  53913. get fovMultiplier(): number;
  53914. set fovMultiplier(value: number);
  53915. private _imageMode;
  53916. /**
  53917. * Gets or set the current video mode for the video. It can be:
  53918. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53919. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53920. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53921. */
  53922. get imageMode(): number;
  53923. set imageMode(value: number);
  53924. /**
  53925. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53926. * @param name Element's name, child elements will append suffixes for their own names.
  53927. * @param urlsOfPhoto defines the url of the photo to display
  53928. * @param options defines an object containing optional or exposed sub element properties
  53929. * @param onError defines a callback called when an error occured while loading the texture
  53930. */
  53931. constructor(name: string, urlOfPhoto: string, options: {
  53932. resolution?: number;
  53933. size?: number;
  53934. useDirectMapping?: boolean;
  53935. faceForward?: boolean;
  53936. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53937. private _onBeforeCameraRenderObserver;
  53938. private _changeImageMode;
  53939. /**
  53940. * Releases resources associated with this node.
  53941. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53942. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53943. */
  53944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53945. }
  53946. }
  53947. declare module BABYLON {
  53948. /**
  53949. * Class used to host RGBD texture specific utilities
  53950. */
  53951. export class RGBDTextureTools {
  53952. /**
  53953. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53954. * @param texture the texture to expand.
  53955. */
  53956. static ExpandRGBDTexture(texture: Texture): void;
  53957. }
  53958. }
  53959. declare module BABYLON {
  53960. /**
  53961. * Class used to host texture specific utilities
  53962. */
  53963. export class BRDFTextureTools {
  53964. /**
  53965. * Prevents texture cache collision
  53966. */
  53967. private static _instanceNumber;
  53968. /**
  53969. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53970. * @param scene defines the hosting scene
  53971. * @returns the environment BRDF texture
  53972. */
  53973. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53974. private static _environmentBRDFBase64Texture;
  53975. }
  53976. }
  53977. declare module BABYLON {
  53978. /**
  53979. * @hidden
  53980. */
  53981. export interface IMaterialClearCoatDefines {
  53982. CLEARCOAT: boolean;
  53983. CLEARCOAT_DEFAULTIOR: boolean;
  53984. CLEARCOAT_TEXTURE: boolean;
  53985. CLEARCOAT_TEXTUREDIRECTUV: number;
  53986. CLEARCOAT_BUMP: boolean;
  53987. CLEARCOAT_BUMPDIRECTUV: number;
  53988. CLEARCOAT_TINT: boolean;
  53989. CLEARCOAT_TINT_TEXTURE: boolean;
  53990. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53991. /** @hidden */
  53992. _areTexturesDirty: boolean;
  53993. }
  53994. /**
  53995. * Define the code related to the clear coat parameters of the pbr material.
  53996. */
  53997. export class PBRClearCoatConfiguration {
  53998. /**
  53999. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54000. * The default fits with a polyurethane material.
  54001. */
  54002. private static readonly _DefaultIndexOfRefraction;
  54003. private _isEnabled;
  54004. /**
  54005. * Defines if the clear coat is enabled in the material.
  54006. */
  54007. isEnabled: boolean;
  54008. /**
  54009. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54010. */
  54011. intensity: number;
  54012. /**
  54013. * Defines the clear coat layer roughness.
  54014. */
  54015. roughness: number;
  54016. private _indexOfRefraction;
  54017. /**
  54018. * Defines the index of refraction of the clear coat.
  54019. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54020. * The default fits with a polyurethane material.
  54021. * Changing the default value is more performance intensive.
  54022. */
  54023. indexOfRefraction: number;
  54024. private _texture;
  54025. /**
  54026. * Stores the clear coat values in a texture.
  54027. */
  54028. texture: Nullable<BaseTexture>;
  54029. private _bumpTexture;
  54030. /**
  54031. * Define the clear coat specific bump texture.
  54032. */
  54033. bumpTexture: Nullable<BaseTexture>;
  54034. private _isTintEnabled;
  54035. /**
  54036. * Defines if the clear coat tint is enabled in the material.
  54037. */
  54038. isTintEnabled: boolean;
  54039. /**
  54040. * Defines the clear coat tint of the material.
  54041. * This is only use if tint is enabled
  54042. */
  54043. tintColor: Color3;
  54044. /**
  54045. * Defines the distance at which the tint color should be found in the
  54046. * clear coat media.
  54047. * This is only use if tint is enabled
  54048. */
  54049. tintColorAtDistance: number;
  54050. /**
  54051. * Defines the clear coat layer thickness.
  54052. * This is only use if tint is enabled
  54053. */
  54054. tintThickness: number;
  54055. private _tintTexture;
  54056. /**
  54057. * Stores the clear tint values in a texture.
  54058. * rgb is tint
  54059. * a is a thickness factor
  54060. */
  54061. tintTexture: Nullable<BaseTexture>;
  54062. /** @hidden */
  54063. private _internalMarkAllSubMeshesAsTexturesDirty;
  54064. /** @hidden */
  54065. _markAllSubMeshesAsTexturesDirty(): void;
  54066. /**
  54067. * Instantiate a new istance of clear coat configuration.
  54068. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54069. */
  54070. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54071. /**
  54072. * Gets wehter the submesh is ready to be used or not.
  54073. * @param defines the list of "defines" to update.
  54074. * @param scene defines the scene the material belongs to.
  54075. * @param engine defines the engine the material belongs to.
  54076. * @param disableBumpMap defines wether the material disables bump or not.
  54077. * @returns - boolean indicating that the submesh is ready or not.
  54078. */
  54079. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54080. /**
  54081. * Checks to see if a texture is used in the material.
  54082. * @param defines the list of "defines" to update.
  54083. * @param scene defines the scene to the material belongs to.
  54084. */
  54085. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54086. /**
  54087. * Binds the material data.
  54088. * @param uniformBuffer defines the Uniform buffer to fill in.
  54089. * @param scene defines the scene the material belongs to.
  54090. * @param engine defines the engine the material belongs to.
  54091. * @param disableBumpMap defines wether the material disables bump or not.
  54092. * @param isFrozen defines wether the material is frozen or not.
  54093. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54094. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54095. */
  54096. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54097. /**
  54098. * Checks to see if a texture is used in the material.
  54099. * @param texture - Base texture to use.
  54100. * @returns - Boolean specifying if a texture is used in the material.
  54101. */
  54102. hasTexture(texture: BaseTexture): boolean;
  54103. /**
  54104. * Returns an array of the actively used textures.
  54105. * @param activeTextures Array of BaseTextures
  54106. */
  54107. getActiveTextures(activeTextures: BaseTexture[]): void;
  54108. /**
  54109. * Returns the animatable textures.
  54110. * @param animatables Array of animatable textures.
  54111. */
  54112. getAnimatables(animatables: IAnimatable[]): void;
  54113. /**
  54114. * Disposes the resources of the material.
  54115. * @param forceDisposeTextures - Forces the disposal of all textures.
  54116. */
  54117. dispose(forceDisposeTextures?: boolean): void;
  54118. /**
  54119. * Get the current class name of the texture useful for serialization or dynamic coding.
  54120. * @returns "PBRClearCoatConfiguration"
  54121. */
  54122. getClassName(): string;
  54123. /**
  54124. * Add fallbacks to the effect fallbacks list.
  54125. * @param defines defines the Base texture to use.
  54126. * @param fallbacks defines the current fallback list.
  54127. * @param currentRank defines the current fallback rank.
  54128. * @returns the new fallback rank.
  54129. */
  54130. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54131. /**
  54132. * Add the required uniforms to the current list.
  54133. * @param uniforms defines the current uniform list.
  54134. */
  54135. static AddUniforms(uniforms: string[]): void;
  54136. /**
  54137. * Add the required samplers to the current list.
  54138. * @param samplers defines the current sampler list.
  54139. */
  54140. static AddSamplers(samplers: string[]): void;
  54141. /**
  54142. * Add the required uniforms to the current buffer.
  54143. * @param uniformBuffer defines the current uniform buffer.
  54144. */
  54145. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54146. /**
  54147. * Makes a duplicate of the current configuration into another one.
  54148. * @param clearCoatConfiguration define the config where to copy the info
  54149. */
  54150. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54151. /**
  54152. * Serializes this clear coat configuration.
  54153. * @returns - An object with the serialized config.
  54154. */
  54155. serialize(): any;
  54156. /**
  54157. * Parses a anisotropy Configuration from a serialized object.
  54158. * @param source - Serialized object.
  54159. * @param scene Defines the scene we are parsing for
  54160. * @param rootUrl Defines the rootUrl to load from
  54161. */
  54162. parse(source: any, scene: Scene, rootUrl: string): void;
  54163. }
  54164. }
  54165. declare module BABYLON {
  54166. /**
  54167. * @hidden
  54168. */
  54169. export interface IMaterialAnisotropicDefines {
  54170. ANISOTROPIC: boolean;
  54171. ANISOTROPIC_TEXTURE: boolean;
  54172. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54173. MAINUV1: boolean;
  54174. _areTexturesDirty: boolean;
  54175. _needUVs: boolean;
  54176. }
  54177. /**
  54178. * Define the code related to the anisotropic parameters of the pbr material.
  54179. */
  54180. export class PBRAnisotropicConfiguration {
  54181. private _isEnabled;
  54182. /**
  54183. * Defines if the anisotropy is enabled in the material.
  54184. */
  54185. isEnabled: boolean;
  54186. /**
  54187. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54188. */
  54189. intensity: number;
  54190. /**
  54191. * Defines if the effect is along the tangents, bitangents or in between.
  54192. * By default, the effect is "strectching" the highlights along the tangents.
  54193. */
  54194. direction: Vector2;
  54195. private _texture;
  54196. /**
  54197. * Stores the anisotropy values in a texture.
  54198. * rg is direction (like normal from -1 to 1)
  54199. * b is a intensity
  54200. */
  54201. texture: Nullable<BaseTexture>;
  54202. /** @hidden */
  54203. private _internalMarkAllSubMeshesAsTexturesDirty;
  54204. /** @hidden */
  54205. _markAllSubMeshesAsTexturesDirty(): void;
  54206. /**
  54207. * Instantiate a new istance of anisotropy configuration.
  54208. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54209. */
  54210. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54211. /**
  54212. * Specifies that the submesh is ready to be used.
  54213. * @param defines the list of "defines" to update.
  54214. * @param scene defines the scene the material belongs to.
  54215. * @returns - boolean indicating that the submesh is ready or not.
  54216. */
  54217. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54218. /**
  54219. * Checks to see if a texture is used in the material.
  54220. * @param defines the list of "defines" to update.
  54221. * @param mesh the mesh we are preparing the defines for.
  54222. * @param scene defines the scene the material belongs to.
  54223. */
  54224. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54225. /**
  54226. * Binds the material data.
  54227. * @param uniformBuffer defines the Uniform buffer to fill in.
  54228. * @param scene defines the scene the material belongs to.
  54229. * @param isFrozen defines wether the material is frozen or not.
  54230. */
  54231. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54232. /**
  54233. * Checks to see if a texture is used in the material.
  54234. * @param texture - Base texture to use.
  54235. * @returns - Boolean specifying if a texture is used in the material.
  54236. */
  54237. hasTexture(texture: BaseTexture): boolean;
  54238. /**
  54239. * Returns an array of the actively used textures.
  54240. * @param activeTextures Array of BaseTextures
  54241. */
  54242. getActiveTextures(activeTextures: BaseTexture[]): void;
  54243. /**
  54244. * Returns the animatable textures.
  54245. * @param animatables Array of animatable textures.
  54246. */
  54247. getAnimatables(animatables: IAnimatable[]): void;
  54248. /**
  54249. * Disposes the resources of the material.
  54250. * @param forceDisposeTextures - Forces the disposal of all textures.
  54251. */
  54252. dispose(forceDisposeTextures?: boolean): void;
  54253. /**
  54254. * Get the current class name of the texture useful for serialization or dynamic coding.
  54255. * @returns "PBRAnisotropicConfiguration"
  54256. */
  54257. getClassName(): string;
  54258. /**
  54259. * Add fallbacks to the effect fallbacks list.
  54260. * @param defines defines the Base texture to use.
  54261. * @param fallbacks defines the current fallback list.
  54262. * @param currentRank defines the current fallback rank.
  54263. * @returns the new fallback rank.
  54264. */
  54265. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54266. /**
  54267. * Add the required uniforms to the current list.
  54268. * @param uniforms defines the current uniform list.
  54269. */
  54270. static AddUniforms(uniforms: string[]): void;
  54271. /**
  54272. * Add the required uniforms to the current buffer.
  54273. * @param uniformBuffer defines the current uniform buffer.
  54274. */
  54275. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54276. /**
  54277. * Add the required samplers to the current list.
  54278. * @param samplers defines the current sampler list.
  54279. */
  54280. static AddSamplers(samplers: string[]): void;
  54281. /**
  54282. * Makes a duplicate of the current configuration into another one.
  54283. * @param anisotropicConfiguration define the config where to copy the info
  54284. */
  54285. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54286. /**
  54287. * Serializes this anisotropy configuration.
  54288. * @returns - An object with the serialized config.
  54289. */
  54290. serialize(): any;
  54291. /**
  54292. * Parses a anisotropy Configuration from a serialized object.
  54293. * @param source - Serialized object.
  54294. * @param scene Defines the scene we are parsing for
  54295. * @param rootUrl Defines the rootUrl to load from
  54296. */
  54297. parse(source: any, scene: Scene, rootUrl: string): void;
  54298. }
  54299. }
  54300. declare module BABYLON {
  54301. /**
  54302. * @hidden
  54303. */
  54304. export interface IMaterialBRDFDefines {
  54305. BRDF_V_HEIGHT_CORRELATED: boolean;
  54306. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54307. SPHERICAL_HARMONICS: boolean;
  54308. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54309. /** @hidden */
  54310. _areMiscDirty: boolean;
  54311. }
  54312. /**
  54313. * Define the code related to the BRDF parameters of the pbr material.
  54314. */
  54315. export class PBRBRDFConfiguration {
  54316. /**
  54317. * Default value used for the energy conservation.
  54318. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54319. */
  54320. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54321. /**
  54322. * Default value used for the Smith Visibility Height Correlated mode.
  54323. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54324. */
  54325. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54326. /**
  54327. * Default value used for the IBL diffuse part.
  54328. * This can help switching back to the polynomials mode globally which is a tiny bit
  54329. * less GPU intensive at the drawback of a lower quality.
  54330. */
  54331. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54332. /**
  54333. * Default value used for activating energy conservation for the specular workflow.
  54334. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54335. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54336. */
  54337. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54338. private _useEnergyConservation;
  54339. /**
  54340. * Defines if the material uses energy conservation.
  54341. */
  54342. useEnergyConservation: boolean;
  54343. private _useSmithVisibilityHeightCorrelated;
  54344. /**
  54345. * LEGACY Mode set to false
  54346. * Defines if the material uses height smith correlated visibility term.
  54347. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54348. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54349. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54350. * Not relying on height correlated will also disable energy conservation.
  54351. */
  54352. useSmithVisibilityHeightCorrelated: boolean;
  54353. private _useSphericalHarmonics;
  54354. /**
  54355. * LEGACY Mode set to false
  54356. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54357. * diffuse part of the IBL.
  54358. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54359. * to the ground truth.
  54360. */
  54361. useSphericalHarmonics: boolean;
  54362. private _useSpecularGlossinessInputEnergyConservation;
  54363. /**
  54364. * Defines if the material uses energy conservation, when the specular workflow is active.
  54365. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54366. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54367. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54368. */
  54369. useSpecularGlossinessInputEnergyConservation: boolean;
  54370. /** @hidden */
  54371. private _internalMarkAllSubMeshesAsMiscDirty;
  54372. /** @hidden */
  54373. _markAllSubMeshesAsMiscDirty(): void;
  54374. /**
  54375. * Instantiate a new istance of clear coat configuration.
  54376. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54377. */
  54378. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54379. /**
  54380. * Checks to see if a texture is used in the material.
  54381. * @param defines the list of "defines" to update.
  54382. */
  54383. prepareDefines(defines: IMaterialBRDFDefines): void;
  54384. /**
  54385. * Get the current class name of the texture useful for serialization or dynamic coding.
  54386. * @returns "PBRClearCoatConfiguration"
  54387. */
  54388. getClassName(): string;
  54389. /**
  54390. * Makes a duplicate of the current configuration into another one.
  54391. * @param brdfConfiguration define the config where to copy the info
  54392. */
  54393. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54394. /**
  54395. * Serializes this BRDF configuration.
  54396. * @returns - An object with the serialized config.
  54397. */
  54398. serialize(): any;
  54399. /**
  54400. * Parses a anisotropy Configuration from a serialized object.
  54401. * @param source - Serialized object.
  54402. * @param scene Defines the scene we are parsing for
  54403. * @param rootUrl Defines the rootUrl to load from
  54404. */
  54405. parse(source: any, scene: Scene, rootUrl: string): void;
  54406. }
  54407. }
  54408. declare module BABYLON {
  54409. /**
  54410. * @hidden
  54411. */
  54412. export interface IMaterialSheenDefines {
  54413. SHEEN: boolean;
  54414. SHEEN_TEXTURE: boolean;
  54415. SHEEN_TEXTUREDIRECTUV: number;
  54416. SHEEN_LINKWITHALBEDO: boolean;
  54417. SHEEN_ROUGHNESS: boolean;
  54418. SHEEN_ALBEDOSCALING: boolean;
  54419. /** @hidden */
  54420. _areTexturesDirty: boolean;
  54421. }
  54422. /**
  54423. * Define the code related to the Sheen parameters of the pbr material.
  54424. */
  54425. export class PBRSheenConfiguration {
  54426. private _isEnabled;
  54427. /**
  54428. * Defines if the material uses sheen.
  54429. */
  54430. isEnabled: boolean;
  54431. private _linkSheenWithAlbedo;
  54432. /**
  54433. * Defines if the sheen is linked to the sheen color.
  54434. */
  54435. linkSheenWithAlbedo: boolean;
  54436. /**
  54437. * Defines the sheen intensity.
  54438. */
  54439. intensity: number;
  54440. /**
  54441. * Defines the sheen color.
  54442. */
  54443. color: Color3;
  54444. private _texture;
  54445. /**
  54446. * Stores the sheen tint values in a texture.
  54447. * rgb is tint
  54448. * a is a intensity or roughness if roughness has been defined
  54449. */
  54450. texture: Nullable<BaseTexture>;
  54451. private _roughness;
  54452. /**
  54453. * Defines the sheen roughness.
  54454. * It is not taken into account if linkSheenWithAlbedo is true.
  54455. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54456. */
  54457. roughness: Nullable<number>;
  54458. private _albedoScaling;
  54459. /**
  54460. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54461. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54462. * making it easier to setup and tweak the effect
  54463. */
  54464. albedoScaling: boolean;
  54465. /** @hidden */
  54466. private _internalMarkAllSubMeshesAsTexturesDirty;
  54467. /** @hidden */
  54468. _markAllSubMeshesAsTexturesDirty(): void;
  54469. /**
  54470. * Instantiate a new istance of clear coat configuration.
  54471. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54472. */
  54473. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54474. /**
  54475. * Specifies that the submesh is ready to be used.
  54476. * @param defines the list of "defines" to update.
  54477. * @param scene defines the scene the material belongs to.
  54478. * @returns - boolean indicating that the submesh is ready or not.
  54479. */
  54480. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54481. /**
  54482. * Checks to see if a texture is used in the material.
  54483. * @param defines the list of "defines" to update.
  54484. * @param scene defines the scene the material belongs to.
  54485. */
  54486. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54487. /**
  54488. * Binds the material data.
  54489. * @param uniformBuffer defines the Uniform buffer to fill in.
  54490. * @param scene defines the scene the material belongs to.
  54491. * @param isFrozen defines wether the material is frozen or not.
  54492. */
  54493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54494. /**
  54495. * Checks to see if a texture is used in the material.
  54496. * @param texture - Base texture to use.
  54497. * @returns - Boolean specifying if a texture is used in the material.
  54498. */
  54499. hasTexture(texture: BaseTexture): boolean;
  54500. /**
  54501. * Returns an array of the actively used textures.
  54502. * @param activeTextures Array of BaseTextures
  54503. */
  54504. getActiveTextures(activeTextures: BaseTexture[]): void;
  54505. /**
  54506. * Returns the animatable textures.
  54507. * @param animatables Array of animatable textures.
  54508. */
  54509. getAnimatables(animatables: IAnimatable[]): void;
  54510. /**
  54511. * Disposes the resources of the material.
  54512. * @param forceDisposeTextures - Forces the disposal of all textures.
  54513. */
  54514. dispose(forceDisposeTextures?: boolean): void;
  54515. /**
  54516. * Get the current class name of the texture useful for serialization or dynamic coding.
  54517. * @returns "PBRSheenConfiguration"
  54518. */
  54519. getClassName(): string;
  54520. /**
  54521. * Add fallbacks to the effect fallbacks list.
  54522. * @param defines defines the Base texture to use.
  54523. * @param fallbacks defines the current fallback list.
  54524. * @param currentRank defines the current fallback rank.
  54525. * @returns the new fallback rank.
  54526. */
  54527. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54528. /**
  54529. * Add the required uniforms to the current list.
  54530. * @param uniforms defines the current uniform list.
  54531. */
  54532. static AddUniforms(uniforms: string[]): void;
  54533. /**
  54534. * Add the required uniforms to the current buffer.
  54535. * @param uniformBuffer defines the current uniform buffer.
  54536. */
  54537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54538. /**
  54539. * Add the required samplers to the current list.
  54540. * @param samplers defines the current sampler list.
  54541. */
  54542. static AddSamplers(samplers: string[]): void;
  54543. /**
  54544. * Makes a duplicate of the current configuration into another one.
  54545. * @param sheenConfiguration define the config where to copy the info
  54546. */
  54547. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54548. /**
  54549. * Serializes this BRDF configuration.
  54550. * @returns - An object with the serialized config.
  54551. */
  54552. serialize(): any;
  54553. /**
  54554. * Parses a anisotropy Configuration from a serialized object.
  54555. * @param source - Serialized object.
  54556. * @param scene Defines the scene we are parsing for
  54557. * @param rootUrl Defines the rootUrl to load from
  54558. */
  54559. parse(source: any, scene: Scene, rootUrl: string): void;
  54560. }
  54561. }
  54562. declare module BABYLON {
  54563. /**
  54564. * @hidden
  54565. */
  54566. export interface IMaterialSubSurfaceDefines {
  54567. SUBSURFACE: boolean;
  54568. SS_REFRACTION: boolean;
  54569. SS_TRANSLUCENCY: boolean;
  54570. SS_SCATTERING: boolean;
  54571. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54572. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54573. SS_REFRACTIONMAP_3D: boolean;
  54574. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54575. SS_LODINREFRACTIONALPHA: boolean;
  54576. SS_GAMMAREFRACTION: boolean;
  54577. SS_RGBDREFRACTION: boolean;
  54578. SS_LINEARSPECULARREFRACTION: boolean;
  54579. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54580. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54581. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54582. /** @hidden */
  54583. _areTexturesDirty: boolean;
  54584. }
  54585. /**
  54586. * Define the code related to the sub surface parameters of the pbr material.
  54587. */
  54588. export class PBRSubSurfaceConfiguration {
  54589. private _isRefractionEnabled;
  54590. /**
  54591. * Defines if the refraction is enabled in the material.
  54592. */
  54593. isRefractionEnabled: boolean;
  54594. private _isTranslucencyEnabled;
  54595. /**
  54596. * Defines if the translucency is enabled in the material.
  54597. */
  54598. isTranslucencyEnabled: boolean;
  54599. private _isScatteringEnabled;
  54600. /**
  54601. * Defines if the sub surface scattering is enabled in the material.
  54602. */
  54603. isScatteringEnabled: boolean;
  54604. private _scatteringDiffusionProfileIndex;
  54605. /**
  54606. * Diffusion profile for subsurface scattering.
  54607. * Useful for better scattering in the skins or foliages.
  54608. */
  54609. get scatteringDiffusionProfile(): Nullable<Color3>;
  54610. set scatteringDiffusionProfile(c: Nullable<Color3>);
  54611. /**
  54612. * Defines the refraction intensity of the material.
  54613. * The refraction when enabled replaces the Diffuse part of the material.
  54614. * The intensity helps transitionning between diffuse and refraction.
  54615. */
  54616. refractionIntensity: number;
  54617. /**
  54618. * Defines the translucency intensity of the material.
  54619. * When translucency has been enabled, this defines how much of the "translucency"
  54620. * is addded to the diffuse part of the material.
  54621. */
  54622. translucencyIntensity: number;
  54623. /**
  54624. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54625. */
  54626. useAlbedoToTintRefraction: boolean;
  54627. private _thicknessTexture;
  54628. /**
  54629. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54630. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54631. * 0 would mean minimumThickness
  54632. * 1 would mean maximumThickness
  54633. * The other channels might be use as a mask to vary the different effects intensity.
  54634. */
  54635. thicknessTexture: Nullable<BaseTexture>;
  54636. private _refractionTexture;
  54637. /**
  54638. * Defines the texture to use for refraction.
  54639. */
  54640. refractionTexture: Nullable<BaseTexture>;
  54641. private _indexOfRefraction;
  54642. /**
  54643. * Index of refraction of the material base layer.
  54644. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54645. *
  54646. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54647. *
  54648. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54649. */
  54650. indexOfRefraction: number;
  54651. private _volumeIndexOfRefraction;
  54652. /**
  54653. * Index of refraction of the material's volume.
  54654. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54655. *
  54656. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54657. * the volume will use the same IOR as the surface.
  54658. */
  54659. get volumeIndexOfRefraction(): number;
  54660. set volumeIndexOfRefraction(value: number);
  54661. private _invertRefractionY;
  54662. /**
  54663. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54664. */
  54665. invertRefractionY: boolean;
  54666. private _linkRefractionWithTransparency;
  54667. /**
  54668. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54669. * Materials half opaque for instance using refraction could benefit from this control.
  54670. */
  54671. linkRefractionWithTransparency: boolean;
  54672. /**
  54673. * Defines the minimum thickness stored in the thickness map.
  54674. * If no thickness map is defined, this value will be used to simulate thickness.
  54675. */
  54676. minimumThickness: number;
  54677. /**
  54678. * Defines the maximum thickness stored in the thickness map.
  54679. */
  54680. maximumThickness: number;
  54681. /**
  54682. * Defines the volume tint of the material.
  54683. * This is used for both translucency and scattering.
  54684. */
  54685. tintColor: Color3;
  54686. /**
  54687. * Defines the distance at which the tint color should be found in the media.
  54688. * This is used for refraction only.
  54689. */
  54690. tintColorAtDistance: number;
  54691. /**
  54692. * Defines how far each channel transmit through the media.
  54693. * It is defined as a color to simplify it selection.
  54694. */
  54695. diffusionDistance: Color3;
  54696. private _useMaskFromThicknessTexture;
  54697. /**
  54698. * Stores the intensity of the different subsurface effects in the thickness texture.
  54699. * * the green channel is the translucency intensity.
  54700. * * the blue channel is the scattering intensity.
  54701. * * the alpha channel is the refraction intensity.
  54702. */
  54703. useMaskFromThicknessTexture: boolean;
  54704. private _scene;
  54705. /** @hidden */
  54706. private _internalMarkAllSubMeshesAsTexturesDirty;
  54707. private _internalMarkScenePrePassDirty;
  54708. /** @hidden */
  54709. _markAllSubMeshesAsTexturesDirty(): void;
  54710. /** @hidden */
  54711. _markScenePrePassDirty(): void;
  54712. /**
  54713. * Instantiate a new istance of sub surface configuration.
  54714. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54715. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  54716. * @param scene The scene
  54717. */
  54718. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  54719. /**
  54720. * Gets wehter the submesh is ready to be used or not.
  54721. * @param defines the list of "defines" to update.
  54722. * @param scene defines the scene the material belongs to.
  54723. * @returns - boolean indicating that the submesh is ready or not.
  54724. */
  54725. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54726. /**
  54727. * Checks to see if a texture is used in the material.
  54728. * @param defines the list of "defines" to update.
  54729. * @param scene defines the scene to the material belongs to.
  54730. */
  54731. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54732. /**
  54733. * Binds the material data.
  54734. * @param uniformBuffer defines the Uniform buffer to fill in.
  54735. * @param scene defines the scene the material belongs to.
  54736. * @param engine defines the engine the material belongs to.
  54737. * @param isFrozen defines whether the material is frozen or not.
  54738. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54739. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54740. */
  54741. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54742. /**
  54743. * Unbinds the material from the mesh.
  54744. * @param activeEffect defines the effect that should be unbound from.
  54745. * @returns true if unbound, otherwise false
  54746. */
  54747. unbind(activeEffect: Effect): boolean;
  54748. /**
  54749. * Returns the texture used for refraction or null if none is used.
  54750. * @param scene defines the scene the material belongs to.
  54751. * @returns - Refraction texture if present. If no refraction texture and refraction
  54752. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54753. */
  54754. private _getRefractionTexture;
  54755. /**
  54756. * Returns true if alpha blending should be disabled.
  54757. */
  54758. get disableAlphaBlending(): boolean;
  54759. /**
  54760. * Fills the list of render target textures.
  54761. * @param renderTargets the list of render targets to update
  54762. */
  54763. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54764. /**
  54765. * Checks to see if a texture is used in the material.
  54766. * @param texture - Base texture to use.
  54767. * @returns - Boolean specifying if a texture is used in the material.
  54768. */
  54769. hasTexture(texture: BaseTexture): boolean;
  54770. /**
  54771. * Gets a boolean indicating that current material needs to register RTT
  54772. * @returns true if this uses a render target otherwise false.
  54773. */
  54774. hasRenderTargetTextures(): boolean;
  54775. /**
  54776. * Returns an array of the actively used textures.
  54777. * @param activeTextures Array of BaseTextures
  54778. */
  54779. getActiveTextures(activeTextures: BaseTexture[]): void;
  54780. /**
  54781. * Returns the animatable textures.
  54782. * @param animatables Array of animatable textures.
  54783. */
  54784. getAnimatables(animatables: IAnimatable[]): void;
  54785. /**
  54786. * Disposes the resources of the material.
  54787. * @param forceDisposeTextures - Forces the disposal of all textures.
  54788. */
  54789. dispose(forceDisposeTextures?: boolean): void;
  54790. /**
  54791. * Get the current class name of the texture useful for serialization or dynamic coding.
  54792. * @returns "PBRSubSurfaceConfiguration"
  54793. */
  54794. getClassName(): string;
  54795. /**
  54796. * Add fallbacks to the effect fallbacks list.
  54797. * @param defines defines the Base texture to use.
  54798. * @param fallbacks defines the current fallback list.
  54799. * @param currentRank defines the current fallback rank.
  54800. * @returns the new fallback rank.
  54801. */
  54802. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54803. /**
  54804. * Add the required uniforms to the current list.
  54805. * @param uniforms defines the current uniform list.
  54806. */
  54807. static AddUniforms(uniforms: string[]): void;
  54808. /**
  54809. * Add the required samplers to the current list.
  54810. * @param samplers defines the current sampler list.
  54811. */
  54812. static AddSamplers(samplers: string[]): void;
  54813. /**
  54814. * Add the required uniforms to the current buffer.
  54815. * @param uniformBuffer defines the current uniform buffer.
  54816. */
  54817. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54818. /**
  54819. * Makes a duplicate of the current configuration into another one.
  54820. * @param configuration define the config where to copy the info
  54821. */
  54822. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54823. /**
  54824. * Serializes this Sub Surface configuration.
  54825. * @returns - An object with the serialized config.
  54826. */
  54827. serialize(): any;
  54828. /**
  54829. * Parses a anisotropy Configuration from a serialized object.
  54830. * @param source - Serialized object.
  54831. * @param scene Defines the scene we are parsing for
  54832. * @param rootUrl Defines the rootUrl to load from
  54833. */
  54834. parse(source: any, scene: Scene, rootUrl: string): void;
  54835. }
  54836. }
  54837. declare module BABYLON {
  54838. /** @hidden */
  54839. export var prePassDeclaration: {
  54840. name: string;
  54841. shader: string;
  54842. };
  54843. }
  54844. declare module BABYLON {
  54845. /** @hidden */
  54846. export var pbrFragmentDeclaration: {
  54847. name: string;
  54848. shader: string;
  54849. };
  54850. }
  54851. declare module BABYLON {
  54852. /** @hidden */
  54853. export var pbrUboDeclaration: {
  54854. name: string;
  54855. shader: string;
  54856. };
  54857. }
  54858. declare module BABYLON {
  54859. /** @hidden */
  54860. export var pbrFragmentExtraDeclaration: {
  54861. name: string;
  54862. shader: string;
  54863. };
  54864. }
  54865. declare module BABYLON {
  54866. /** @hidden */
  54867. export var pbrFragmentSamplersDeclaration: {
  54868. name: string;
  54869. shader: string;
  54870. };
  54871. }
  54872. declare module BABYLON {
  54873. /** @hidden */
  54874. export var subSurfaceScatteringFunctions: {
  54875. name: string;
  54876. shader: string;
  54877. };
  54878. }
  54879. declare module BABYLON {
  54880. /** @hidden */
  54881. export var importanceSampling: {
  54882. name: string;
  54883. shader: string;
  54884. };
  54885. }
  54886. declare module BABYLON {
  54887. /** @hidden */
  54888. export var pbrHelperFunctions: {
  54889. name: string;
  54890. shader: string;
  54891. };
  54892. }
  54893. declare module BABYLON {
  54894. /** @hidden */
  54895. export var harmonicsFunctions: {
  54896. name: string;
  54897. shader: string;
  54898. };
  54899. }
  54900. declare module BABYLON {
  54901. /** @hidden */
  54902. export var pbrDirectLightingSetupFunctions: {
  54903. name: string;
  54904. shader: string;
  54905. };
  54906. }
  54907. declare module BABYLON {
  54908. /** @hidden */
  54909. export var pbrDirectLightingFalloffFunctions: {
  54910. name: string;
  54911. shader: string;
  54912. };
  54913. }
  54914. declare module BABYLON {
  54915. /** @hidden */
  54916. export var pbrBRDFFunctions: {
  54917. name: string;
  54918. shader: string;
  54919. };
  54920. }
  54921. declare module BABYLON {
  54922. /** @hidden */
  54923. export var hdrFilteringFunctions: {
  54924. name: string;
  54925. shader: string;
  54926. };
  54927. }
  54928. declare module BABYLON {
  54929. /** @hidden */
  54930. export var pbrDirectLightingFunctions: {
  54931. name: string;
  54932. shader: string;
  54933. };
  54934. }
  54935. declare module BABYLON {
  54936. /** @hidden */
  54937. export var pbrIBLFunctions: {
  54938. name: string;
  54939. shader: string;
  54940. };
  54941. }
  54942. declare module BABYLON {
  54943. /** @hidden */
  54944. export var pbrBlockAlbedoOpacity: {
  54945. name: string;
  54946. shader: string;
  54947. };
  54948. }
  54949. declare module BABYLON {
  54950. /** @hidden */
  54951. export var pbrBlockReflectivity: {
  54952. name: string;
  54953. shader: string;
  54954. };
  54955. }
  54956. declare module BABYLON {
  54957. /** @hidden */
  54958. export var pbrBlockAmbientOcclusion: {
  54959. name: string;
  54960. shader: string;
  54961. };
  54962. }
  54963. declare module BABYLON {
  54964. /** @hidden */
  54965. export var pbrBlockAlphaFresnel: {
  54966. name: string;
  54967. shader: string;
  54968. };
  54969. }
  54970. declare module BABYLON {
  54971. /** @hidden */
  54972. export var pbrBlockAnisotropic: {
  54973. name: string;
  54974. shader: string;
  54975. };
  54976. }
  54977. declare module BABYLON {
  54978. /** @hidden */
  54979. export var pbrBlockReflection: {
  54980. name: string;
  54981. shader: string;
  54982. };
  54983. }
  54984. declare module BABYLON {
  54985. /** @hidden */
  54986. export var pbrBlockSheen: {
  54987. name: string;
  54988. shader: string;
  54989. };
  54990. }
  54991. declare module BABYLON {
  54992. /** @hidden */
  54993. export var pbrBlockClearcoat: {
  54994. name: string;
  54995. shader: string;
  54996. };
  54997. }
  54998. declare module BABYLON {
  54999. /** @hidden */
  55000. export var pbrBlockSubSurface: {
  55001. name: string;
  55002. shader: string;
  55003. };
  55004. }
  55005. declare module BABYLON {
  55006. /** @hidden */
  55007. export var pbrBlockNormalGeometric: {
  55008. name: string;
  55009. shader: string;
  55010. };
  55011. }
  55012. declare module BABYLON {
  55013. /** @hidden */
  55014. export var pbrBlockNormalFinal: {
  55015. name: string;
  55016. shader: string;
  55017. };
  55018. }
  55019. declare module BABYLON {
  55020. /** @hidden */
  55021. export var pbrBlockGeometryInfo: {
  55022. name: string;
  55023. shader: string;
  55024. };
  55025. }
  55026. declare module BABYLON {
  55027. /** @hidden */
  55028. export var pbrBlockReflectance0: {
  55029. name: string;
  55030. shader: string;
  55031. };
  55032. }
  55033. declare module BABYLON {
  55034. /** @hidden */
  55035. export var pbrBlockReflectance: {
  55036. name: string;
  55037. shader: string;
  55038. };
  55039. }
  55040. declare module BABYLON {
  55041. /** @hidden */
  55042. export var pbrBlockDirectLighting: {
  55043. name: string;
  55044. shader: string;
  55045. };
  55046. }
  55047. declare module BABYLON {
  55048. /** @hidden */
  55049. export var pbrBlockFinalLitComponents: {
  55050. name: string;
  55051. shader: string;
  55052. };
  55053. }
  55054. declare module BABYLON {
  55055. /** @hidden */
  55056. export var pbrBlockFinalUnlitComponents: {
  55057. name: string;
  55058. shader: string;
  55059. };
  55060. }
  55061. declare module BABYLON {
  55062. /** @hidden */
  55063. export var pbrBlockFinalColorComposition: {
  55064. name: string;
  55065. shader: string;
  55066. };
  55067. }
  55068. declare module BABYLON {
  55069. /** @hidden */
  55070. export var pbrBlockImageProcessing: {
  55071. name: string;
  55072. shader: string;
  55073. };
  55074. }
  55075. declare module BABYLON {
  55076. /** @hidden */
  55077. export var pbrDebug: {
  55078. name: string;
  55079. shader: string;
  55080. };
  55081. }
  55082. declare module BABYLON {
  55083. /** @hidden */
  55084. export var pbrPixelShader: {
  55085. name: string;
  55086. shader: string;
  55087. };
  55088. }
  55089. declare module BABYLON {
  55090. /** @hidden */
  55091. export var pbrVertexDeclaration: {
  55092. name: string;
  55093. shader: string;
  55094. };
  55095. }
  55096. declare module BABYLON {
  55097. /** @hidden */
  55098. export var pbrVertexShader: {
  55099. name: string;
  55100. shader: string;
  55101. };
  55102. }
  55103. declare module BABYLON {
  55104. /**
  55105. * Manages the defines for the PBR Material.
  55106. * @hidden
  55107. */
  55108. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55109. PBR: boolean;
  55110. NUM_SAMPLES: string;
  55111. REALTIME_FILTERING: boolean;
  55112. MAINUV1: boolean;
  55113. MAINUV2: boolean;
  55114. UV1: boolean;
  55115. UV2: boolean;
  55116. ALBEDO: boolean;
  55117. GAMMAALBEDO: boolean;
  55118. ALBEDODIRECTUV: number;
  55119. VERTEXCOLOR: boolean;
  55120. DETAIL: boolean;
  55121. DETAILDIRECTUV: number;
  55122. DETAIL_NORMALBLENDMETHOD: number;
  55123. AMBIENT: boolean;
  55124. AMBIENTDIRECTUV: number;
  55125. AMBIENTINGRAYSCALE: boolean;
  55126. OPACITY: boolean;
  55127. VERTEXALPHA: boolean;
  55128. OPACITYDIRECTUV: number;
  55129. OPACITYRGB: boolean;
  55130. ALPHATEST: boolean;
  55131. DEPTHPREPASS: boolean;
  55132. ALPHABLEND: boolean;
  55133. ALPHAFROMALBEDO: boolean;
  55134. ALPHATESTVALUE: string;
  55135. SPECULAROVERALPHA: boolean;
  55136. RADIANCEOVERALPHA: boolean;
  55137. ALPHAFRESNEL: boolean;
  55138. LINEARALPHAFRESNEL: boolean;
  55139. PREMULTIPLYALPHA: boolean;
  55140. EMISSIVE: boolean;
  55141. EMISSIVEDIRECTUV: number;
  55142. REFLECTIVITY: boolean;
  55143. REFLECTIVITYDIRECTUV: number;
  55144. SPECULARTERM: boolean;
  55145. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55146. MICROSURFACEAUTOMATIC: boolean;
  55147. LODBASEDMICROSFURACE: boolean;
  55148. MICROSURFACEMAP: boolean;
  55149. MICROSURFACEMAPDIRECTUV: number;
  55150. METALLICWORKFLOW: boolean;
  55151. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55152. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55153. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55154. AOSTOREINMETALMAPRED: boolean;
  55155. METALLIC_REFLECTANCE: boolean;
  55156. METALLIC_REFLECTANCEDIRECTUV: number;
  55157. ENVIRONMENTBRDF: boolean;
  55158. ENVIRONMENTBRDF_RGBD: boolean;
  55159. NORMAL: boolean;
  55160. TANGENT: boolean;
  55161. BUMP: boolean;
  55162. BUMPDIRECTUV: number;
  55163. OBJECTSPACE_NORMALMAP: boolean;
  55164. PARALLAX: boolean;
  55165. PARALLAXOCCLUSION: boolean;
  55166. NORMALXYSCALE: boolean;
  55167. LIGHTMAP: boolean;
  55168. LIGHTMAPDIRECTUV: number;
  55169. USELIGHTMAPASSHADOWMAP: boolean;
  55170. GAMMALIGHTMAP: boolean;
  55171. RGBDLIGHTMAP: boolean;
  55172. REFLECTION: boolean;
  55173. REFLECTIONMAP_3D: boolean;
  55174. REFLECTIONMAP_SPHERICAL: boolean;
  55175. REFLECTIONMAP_PLANAR: boolean;
  55176. REFLECTIONMAP_CUBIC: boolean;
  55177. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55178. REFLECTIONMAP_PROJECTION: boolean;
  55179. REFLECTIONMAP_SKYBOX: boolean;
  55180. REFLECTIONMAP_EXPLICIT: boolean;
  55181. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55182. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55183. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55184. INVERTCUBICMAP: boolean;
  55185. USESPHERICALFROMREFLECTIONMAP: boolean;
  55186. USEIRRADIANCEMAP: boolean;
  55187. SPHERICAL_HARMONICS: boolean;
  55188. USESPHERICALINVERTEX: boolean;
  55189. REFLECTIONMAP_OPPOSITEZ: boolean;
  55190. LODINREFLECTIONALPHA: boolean;
  55191. GAMMAREFLECTION: boolean;
  55192. RGBDREFLECTION: boolean;
  55193. LINEARSPECULARREFLECTION: boolean;
  55194. RADIANCEOCCLUSION: boolean;
  55195. HORIZONOCCLUSION: boolean;
  55196. INSTANCES: boolean;
  55197. THIN_INSTANCES: boolean;
  55198. PREPASS: boolean;
  55199. SCENE_MRT_COUNT: number;
  55200. NUM_BONE_INFLUENCERS: number;
  55201. BonesPerMesh: number;
  55202. BONETEXTURE: boolean;
  55203. NONUNIFORMSCALING: boolean;
  55204. MORPHTARGETS: boolean;
  55205. MORPHTARGETS_NORMAL: boolean;
  55206. MORPHTARGETS_TANGENT: boolean;
  55207. MORPHTARGETS_UV: boolean;
  55208. NUM_MORPH_INFLUENCERS: number;
  55209. IMAGEPROCESSING: boolean;
  55210. VIGNETTE: boolean;
  55211. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55212. VIGNETTEBLENDMODEOPAQUE: boolean;
  55213. TONEMAPPING: boolean;
  55214. TONEMAPPING_ACES: boolean;
  55215. CONTRAST: boolean;
  55216. COLORCURVES: boolean;
  55217. COLORGRADING: boolean;
  55218. COLORGRADING3D: boolean;
  55219. SAMPLER3DGREENDEPTH: boolean;
  55220. SAMPLER3DBGRMAP: boolean;
  55221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55222. EXPOSURE: boolean;
  55223. MULTIVIEW: boolean;
  55224. USEPHYSICALLIGHTFALLOFF: boolean;
  55225. USEGLTFLIGHTFALLOFF: boolean;
  55226. TWOSIDEDLIGHTING: boolean;
  55227. SHADOWFLOAT: boolean;
  55228. CLIPPLANE: boolean;
  55229. CLIPPLANE2: boolean;
  55230. CLIPPLANE3: boolean;
  55231. CLIPPLANE4: boolean;
  55232. CLIPPLANE5: boolean;
  55233. CLIPPLANE6: boolean;
  55234. POINTSIZE: boolean;
  55235. FOG: boolean;
  55236. LOGARITHMICDEPTH: boolean;
  55237. FORCENORMALFORWARD: boolean;
  55238. SPECULARAA: boolean;
  55239. CLEARCOAT: boolean;
  55240. CLEARCOAT_DEFAULTIOR: boolean;
  55241. CLEARCOAT_TEXTURE: boolean;
  55242. CLEARCOAT_TEXTUREDIRECTUV: number;
  55243. CLEARCOAT_BUMP: boolean;
  55244. CLEARCOAT_BUMPDIRECTUV: number;
  55245. CLEARCOAT_TINT: boolean;
  55246. CLEARCOAT_TINT_TEXTURE: boolean;
  55247. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55248. ANISOTROPIC: boolean;
  55249. ANISOTROPIC_TEXTURE: boolean;
  55250. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55251. BRDF_V_HEIGHT_CORRELATED: boolean;
  55252. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55253. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55254. SHEEN: boolean;
  55255. SHEEN_TEXTURE: boolean;
  55256. SHEEN_TEXTUREDIRECTUV: number;
  55257. SHEEN_LINKWITHALBEDO: boolean;
  55258. SHEEN_ROUGHNESS: boolean;
  55259. SHEEN_ALBEDOSCALING: boolean;
  55260. SUBSURFACE: boolean;
  55261. SS_REFRACTION: boolean;
  55262. SS_TRANSLUCENCY: boolean;
  55263. SS_SCATTERING: boolean;
  55264. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55265. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55266. SS_REFRACTIONMAP_3D: boolean;
  55267. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55268. SS_LODINREFRACTIONALPHA: boolean;
  55269. SS_GAMMAREFRACTION: boolean;
  55270. SS_RGBDREFRACTION: boolean;
  55271. SS_LINEARSPECULARREFRACTION: boolean;
  55272. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55273. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55274. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55275. UNLIT: boolean;
  55276. DEBUGMODE: number;
  55277. /**
  55278. * Initializes the PBR Material defines.
  55279. */
  55280. constructor();
  55281. /**
  55282. * Resets the PBR Material defines.
  55283. */
  55284. reset(): void;
  55285. }
  55286. /**
  55287. * The Physically based material base class of BJS.
  55288. *
  55289. * This offers the main features of a standard PBR material.
  55290. * For more information, please refer to the documentation :
  55291. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55292. */
  55293. export abstract class PBRBaseMaterial extends PushMaterial {
  55294. /**
  55295. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55296. */
  55297. static readonly PBRMATERIAL_OPAQUE: number;
  55298. /**
  55299. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55300. */
  55301. static readonly PBRMATERIAL_ALPHATEST: number;
  55302. /**
  55303. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55304. */
  55305. static readonly PBRMATERIAL_ALPHABLEND: number;
  55306. /**
  55307. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55308. * They are also discarded below the alpha cutoff threshold to improve performances.
  55309. */
  55310. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55311. /**
  55312. * Defines the default value of how much AO map is occluding the analytical lights
  55313. * (point spot...).
  55314. */
  55315. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55316. /**
  55317. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55318. */
  55319. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55320. /**
  55321. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55322. * to enhance interoperability with other engines.
  55323. */
  55324. static readonly LIGHTFALLOFF_GLTF: number;
  55325. /**
  55326. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55327. * to enhance interoperability with other materials.
  55328. */
  55329. static readonly LIGHTFALLOFF_STANDARD: number;
  55330. /**
  55331. * Intensity of the direct lights e.g. the four lights available in your scene.
  55332. * This impacts both the direct diffuse and specular highlights.
  55333. */
  55334. protected _directIntensity: number;
  55335. /**
  55336. * Intensity of the emissive part of the material.
  55337. * This helps controlling the emissive effect without modifying the emissive color.
  55338. */
  55339. protected _emissiveIntensity: number;
  55340. /**
  55341. * Intensity of the environment e.g. how much the environment will light the object
  55342. * either through harmonics for rough material or through the refelction for shiny ones.
  55343. */
  55344. protected _environmentIntensity: number;
  55345. /**
  55346. * This is a special control allowing the reduction of the specular highlights coming from the
  55347. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55348. */
  55349. protected _specularIntensity: number;
  55350. /**
  55351. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55352. */
  55353. private _lightingInfos;
  55354. /**
  55355. * Debug Control allowing disabling the bump map on this material.
  55356. */
  55357. protected _disableBumpMap: boolean;
  55358. /**
  55359. * AKA Diffuse Texture in standard nomenclature.
  55360. */
  55361. protected _albedoTexture: Nullable<BaseTexture>;
  55362. /**
  55363. * AKA Occlusion Texture in other nomenclature.
  55364. */
  55365. protected _ambientTexture: Nullable<BaseTexture>;
  55366. /**
  55367. * AKA Occlusion Texture Intensity in other nomenclature.
  55368. */
  55369. protected _ambientTextureStrength: number;
  55370. /**
  55371. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55372. * 1 means it completely occludes it
  55373. * 0 mean it has no impact
  55374. */
  55375. protected _ambientTextureImpactOnAnalyticalLights: number;
  55376. /**
  55377. * Stores the alpha values in a texture.
  55378. */
  55379. protected _opacityTexture: Nullable<BaseTexture>;
  55380. /**
  55381. * Stores the reflection values in a texture.
  55382. */
  55383. protected _reflectionTexture: Nullable<BaseTexture>;
  55384. /**
  55385. * Stores the emissive values in a texture.
  55386. */
  55387. protected _emissiveTexture: Nullable<BaseTexture>;
  55388. /**
  55389. * AKA Specular texture in other nomenclature.
  55390. */
  55391. protected _reflectivityTexture: Nullable<BaseTexture>;
  55392. /**
  55393. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55394. */
  55395. protected _metallicTexture: Nullable<BaseTexture>;
  55396. /**
  55397. * Specifies the metallic scalar of the metallic/roughness workflow.
  55398. * Can also be used to scale the metalness values of the metallic texture.
  55399. */
  55400. protected _metallic: Nullable<number>;
  55401. /**
  55402. * Specifies the roughness scalar of the metallic/roughness workflow.
  55403. * Can also be used to scale the roughness values of the metallic texture.
  55404. */
  55405. protected _roughness: Nullable<number>;
  55406. /**
  55407. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55408. * By default the indexOfrefraction is used to compute F0;
  55409. *
  55410. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55411. *
  55412. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55413. * F90 = metallicReflectanceColor;
  55414. */
  55415. protected _metallicF0Factor: number;
  55416. /**
  55417. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55418. * By default the F90 is always 1;
  55419. *
  55420. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55421. *
  55422. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55423. * F90 = metallicReflectanceColor;
  55424. */
  55425. protected _metallicReflectanceColor: Color3;
  55426. /**
  55427. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55428. * This is multiply against the scalar values defined in the material.
  55429. */
  55430. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55431. /**
  55432. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55433. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55434. */
  55435. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55436. /**
  55437. * Stores surface normal data used to displace a mesh in a texture.
  55438. */
  55439. protected _bumpTexture: Nullable<BaseTexture>;
  55440. /**
  55441. * Stores the pre-calculated light information of a mesh in a texture.
  55442. */
  55443. protected _lightmapTexture: Nullable<BaseTexture>;
  55444. /**
  55445. * The color of a material in ambient lighting.
  55446. */
  55447. protected _ambientColor: Color3;
  55448. /**
  55449. * AKA Diffuse Color in other nomenclature.
  55450. */
  55451. protected _albedoColor: Color3;
  55452. /**
  55453. * AKA Specular Color in other nomenclature.
  55454. */
  55455. protected _reflectivityColor: Color3;
  55456. /**
  55457. * The color applied when light is reflected from a material.
  55458. */
  55459. protected _reflectionColor: Color3;
  55460. /**
  55461. * The color applied when light is emitted from a material.
  55462. */
  55463. protected _emissiveColor: Color3;
  55464. /**
  55465. * AKA Glossiness in other nomenclature.
  55466. */
  55467. protected _microSurface: number;
  55468. /**
  55469. * Specifies that the material will use the light map as a show map.
  55470. */
  55471. protected _useLightmapAsShadowmap: boolean;
  55472. /**
  55473. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55474. * makes the reflect vector face the model (under horizon).
  55475. */
  55476. protected _useHorizonOcclusion: boolean;
  55477. /**
  55478. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55479. * too much the area relying on ambient texture to define their ambient occlusion.
  55480. */
  55481. protected _useRadianceOcclusion: boolean;
  55482. /**
  55483. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55484. */
  55485. protected _useAlphaFromAlbedoTexture: boolean;
  55486. /**
  55487. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55488. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55489. */
  55490. protected _useSpecularOverAlpha: boolean;
  55491. /**
  55492. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55493. */
  55494. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55495. /**
  55496. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55497. */
  55498. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55499. /**
  55500. * Specifies if the metallic texture contains the roughness information in its green channel.
  55501. */
  55502. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55503. /**
  55504. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55505. */
  55506. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55507. /**
  55508. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55509. */
  55510. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55511. /**
  55512. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55513. */
  55514. protected _useAmbientInGrayScale: boolean;
  55515. /**
  55516. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55517. * The material will try to infer what glossiness each pixel should be.
  55518. */
  55519. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55520. /**
  55521. * Defines the falloff type used in this material.
  55522. * It by default is Physical.
  55523. */
  55524. protected _lightFalloff: number;
  55525. /**
  55526. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55527. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55528. */
  55529. protected _useRadianceOverAlpha: boolean;
  55530. /**
  55531. * Allows using an object space normal map (instead of tangent space).
  55532. */
  55533. protected _useObjectSpaceNormalMap: boolean;
  55534. /**
  55535. * Allows using the bump map in parallax mode.
  55536. */
  55537. protected _useParallax: boolean;
  55538. /**
  55539. * Allows using the bump map in parallax occlusion mode.
  55540. */
  55541. protected _useParallaxOcclusion: boolean;
  55542. /**
  55543. * Controls the scale bias of the parallax mode.
  55544. */
  55545. protected _parallaxScaleBias: number;
  55546. /**
  55547. * If sets to true, disables all the lights affecting the material.
  55548. */
  55549. protected _disableLighting: boolean;
  55550. /**
  55551. * Number of Simultaneous lights allowed on the material.
  55552. */
  55553. protected _maxSimultaneousLights: number;
  55554. /**
  55555. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55556. */
  55557. protected _invertNormalMapX: boolean;
  55558. /**
  55559. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55560. */
  55561. protected _invertNormalMapY: boolean;
  55562. /**
  55563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55564. */
  55565. protected _twoSidedLighting: boolean;
  55566. /**
  55567. * Defines the alpha limits in alpha test mode.
  55568. */
  55569. protected _alphaCutOff: number;
  55570. /**
  55571. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55572. */
  55573. protected _forceAlphaTest: boolean;
  55574. /**
  55575. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55576. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55577. */
  55578. protected _useAlphaFresnel: boolean;
  55579. /**
  55580. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55581. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55582. */
  55583. protected _useLinearAlphaFresnel: boolean;
  55584. /**
  55585. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55586. * from cos thetav and roughness:
  55587. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55588. */
  55589. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55590. /**
  55591. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55592. */
  55593. protected _forceIrradianceInFragment: boolean;
  55594. private _realTimeFiltering;
  55595. /**
  55596. * Enables realtime filtering on the texture.
  55597. */
  55598. get realTimeFiltering(): boolean;
  55599. set realTimeFiltering(b: boolean);
  55600. private _realTimeFilteringQuality;
  55601. /**
  55602. * Quality switch for realtime filtering
  55603. */
  55604. get realTimeFilteringQuality(): number;
  55605. set realTimeFilteringQuality(n: number);
  55606. /**
  55607. * Should this material render to several textures at once
  55608. */
  55609. get shouldRenderToMRT(): boolean;
  55610. /**
  55611. * Force normal to face away from face.
  55612. */
  55613. protected _forceNormalForward: boolean;
  55614. /**
  55615. * Enables specular anti aliasing in the PBR shader.
  55616. * It will both interacts on the Geometry for analytical and IBL lighting.
  55617. * It also prefilter the roughness map based on the bump values.
  55618. */
  55619. protected _enableSpecularAntiAliasing: boolean;
  55620. /**
  55621. * Default configuration related to image processing available in the PBR Material.
  55622. */
  55623. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55624. /**
  55625. * Keep track of the image processing observer to allow dispose and replace.
  55626. */
  55627. private _imageProcessingObserver;
  55628. /**
  55629. * Attaches a new image processing configuration to the PBR Material.
  55630. * @param configuration
  55631. */
  55632. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55633. /**
  55634. * Stores the available render targets.
  55635. */
  55636. private _renderTargets;
  55637. /**
  55638. * Sets the global ambient color for the material used in lighting calculations.
  55639. */
  55640. private _globalAmbientColor;
  55641. /**
  55642. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55643. */
  55644. private _useLogarithmicDepth;
  55645. /**
  55646. * If set to true, no lighting calculations will be applied.
  55647. */
  55648. private _unlit;
  55649. private _debugMode;
  55650. /**
  55651. * @hidden
  55652. * This is reserved for the inspector.
  55653. * Defines the material debug mode.
  55654. * It helps seeing only some components of the material while troubleshooting.
  55655. */
  55656. debugMode: number;
  55657. /**
  55658. * @hidden
  55659. * This is reserved for the inspector.
  55660. * Specify from where on screen the debug mode should start.
  55661. * The value goes from -1 (full screen) to 1 (not visible)
  55662. * It helps with side by side comparison against the final render
  55663. * This defaults to -1
  55664. */
  55665. private debugLimit;
  55666. /**
  55667. * @hidden
  55668. * This is reserved for the inspector.
  55669. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55670. * You can use the factor to better multiply the final value.
  55671. */
  55672. private debugFactor;
  55673. /**
  55674. * Defines the clear coat layer parameters for the material.
  55675. */
  55676. readonly clearCoat: PBRClearCoatConfiguration;
  55677. /**
  55678. * Defines the anisotropic parameters for the material.
  55679. */
  55680. readonly anisotropy: PBRAnisotropicConfiguration;
  55681. /**
  55682. * Defines the BRDF parameters for the material.
  55683. */
  55684. readonly brdf: PBRBRDFConfiguration;
  55685. /**
  55686. * Defines the Sheen parameters for the material.
  55687. */
  55688. readonly sheen: PBRSheenConfiguration;
  55689. /**
  55690. * Defines the SubSurface parameters for the material.
  55691. */
  55692. readonly subSurface: PBRSubSurfaceConfiguration;
  55693. /**
  55694. * Defines the detail map parameters for the material.
  55695. */
  55696. readonly detailMap: DetailMapConfiguration;
  55697. protected _rebuildInParallel: boolean;
  55698. /**
  55699. * Instantiates a new PBRMaterial instance.
  55700. *
  55701. * @param name The material name
  55702. * @param scene The scene the material will be use in.
  55703. */
  55704. constructor(name: string, scene: Scene);
  55705. /**
  55706. * Gets a boolean indicating that current material needs to register RTT
  55707. */
  55708. get hasRenderTargetTextures(): boolean;
  55709. /**
  55710. * Gets the name of the material class.
  55711. */
  55712. getClassName(): string;
  55713. /**
  55714. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55715. */
  55716. get useLogarithmicDepth(): boolean;
  55717. /**
  55718. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55719. */
  55720. set useLogarithmicDepth(value: boolean);
  55721. /**
  55722. * Returns true if alpha blending should be disabled.
  55723. */
  55724. protected get _disableAlphaBlending(): boolean;
  55725. /**
  55726. * Specifies whether or not this material should be rendered in alpha blend mode.
  55727. */
  55728. needAlphaBlending(): boolean;
  55729. /**
  55730. * Specifies whether or not this material should be rendered in alpha test mode.
  55731. */
  55732. needAlphaTesting(): boolean;
  55733. /**
  55734. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55735. */
  55736. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55737. /**
  55738. * Gets the texture used for the alpha test.
  55739. */
  55740. getAlphaTestTexture(): Nullable<BaseTexture>;
  55741. /**
  55742. * Specifies that the submesh is ready to be used.
  55743. * @param mesh - BJS mesh.
  55744. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55745. * @param useInstances - Specifies that instances should be used.
  55746. * @returns - boolean indicating that the submesh is ready or not.
  55747. */
  55748. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55749. /**
  55750. * Specifies if the material uses metallic roughness workflow.
  55751. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55752. */
  55753. isMetallicWorkflow(): boolean;
  55754. private _prepareEffect;
  55755. private _prepareDefines;
  55756. /**
  55757. * Force shader compilation
  55758. */
  55759. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55760. /**
  55761. * Initializes the uniform buffer layout for the shader.
  55762. */
  55763. buildUniformLayout(): void;
  55764. /**
  55765. * Unbinds the material from the mesh
  55766. */
  55767. unbind(): void;
  55768. /**
  55769. * Binds the submesh data.
  55770. * @param world - The world matrix.
  55771. * @param mesh - The BJS mesh.
  55772. * @param subMesh - A submesh of the BJS mesh.
  55773. */
  55774. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55775. /**
  55776. * Returns the animatable textures.
  55777. * @returns - Array of animatable textures.
  55778. */
  55779. getAnimatables(): IAnimatable[];
  55780. /**
  55781. * Returns the texture used for reflections.
  55782. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55783. */
  55784. private _getReflectionTexture;
  55785. /**
  55786. * Returns an array of the actively used textures.
  55787. * @returns - Array of BaseTextures
  55788. */
  55789. getActiveTextures(): BaseTexture[];
  55790. /**
  55791. * Checks to see if a texture is used in the material.
  55792. * @param texture - Base texture to use.
  55793. * @returns - Boolean specifying if a texture is used in the material.
  55794. */
  55795. hasTexture(texture: BaseTexture): boolean;
  55796. /**
  55797. * Disposes the resources of the material.
  55798. * @param forceDisposeEffect - Forces the disposal of effects.
  55799. * @param forceDisposeTextures - Forces the disposal of all textures.
  55800. */
  55801. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55802. }
  55803. }
  55804. declare module BABYLON {
  55805. /**
  55806. * The Physically based material of BJS.
  55807. *
  55808. * This offers the main features of a standard PBR material.
  55809. * For more information, please refer to the documentation :
  55810. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55811. */
  55812. export class PBRMaterial extends PBRBaseMaterial {
  55813. /**
  55814. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55815. */
  55816. static readonly PBRMATERIAL_OPAQUE: number;
  55817. /**
  55818. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55819. */
  55820. static readonly PBRMATERIAL_ALPHATEST: number;
  55821. /**
  55822. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55823. */
  55824. static readonly PBRMATERIAL_ALPHABLEND: number;
  55825. /**
  55826. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55827. * They are also discarded below the alpha cutoff threshold to improve performances.
  55828. */
  55829. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55830. /**
  55831. * Defines the default value of how much AO map is occluding the analytical lights
  55832. * (point spot...).
  55833. */
  55834. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55835. /**
  55836. * Intensity of the direct lights e.g. the four lights available in your scene.
  55837. * This impacts both the direct diffuse and specular highlights.
  55838. */
  55839. directIntensity: number;
  55840. /**
  55841. * Intensity of the emissive part of the material.
  55842. * This helps controlling the emissive effect without modifying the emissive color.
  55843. */
  55844. emissiveIntensity: number;
  55845. /**
  55846. * Intensity of the environment e.g. how much the environment will light the object
  55847. * either through harmonics for rough material or through the refelction for shiny ones.
  55848. */
  55849. environmentIntensity: number;
  55850. /**
  55851. * This is a special control allowing the reduction of the specular highlights coming from the
  55852. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55853. */
  55854. specularIntensity: number;
  55855. /**
  55856. * Debug Control allowing disabling the bump map on this material.
  55857. */
  55858. disableBumpMap: boolean;
  55859. /**
  55860. * AKA Diffuse Texture in standard nomenclature.
  55861. */
  55862. albedoTexture: BaseTexture;
  55863. /**
  55864. * AKA Occlusion Texture in other nomenclature.
  55865. */
  55866. ambientTexture: BaseTexture;
  55867. /**
  55868. * AKA Occlusion Texture Intensity in other nomenclature.
  55869. */
  55870. ambientTextureStrength: number;
  55871. /**
  55872. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55873. * 1 means it completely occludes it
  55874. * 0 mean it has no impact
  55875. */
  55876. ambientTextureImpactOnAnalyticalLights: number;
  55877. /**
  55878. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55879. */
  55880. opacityTexture: BaseTexture;
  55881. /**
  55882. * Stores the reflection values in a texture.
  55883. */
  55884. reflectionTexture: Nullable<BaseTexture>;
  55885. /**
  55886. * Stores the emissive values in a texture.
  55887. */
  55888. emissiveTexture: BaseTexture;
  55889. /**
  55890. * AKA Specular texture in other nomenclature.
  55891. */
  55892. reflectivityTexture: BaseTexture;
  55893. /**
  55894. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55895. */
  55896. metallicTexture: BaseTexture;
  55897. /**
  55898. * Specifies the metallic scalar of the metallic/roughness workflow.
  55899. * Can also be used to scale the metalness values of the metallic texture.
  55900. */
  55901. metallic: Nullable<number>;
  55902. /**
  55903. * Specifies the roughness scalar of the metallic/roughness workflow.
  55904. * Can also be used to scale the roughness values of the metallic texture.
  55905. */
  55906. roughness: Nullable<number>;
  55907. /**
  55908. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55909. * By default the indexOfrefraction is used to compute F0;
  55910. *
  55911. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55912. *
  55913. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55914. * F90 = metallicReflectanceColor;
  55915. */
  55916. metallicF0Factor: number;
  55917. /**
  55918. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55919. * By default the F90 is always 1;
  55920. *
  55921. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55922. *
  55923. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55924. * F90 = metallicReflectanceColor;
  55925. */
  55926. metallicReflectanceColor: Color3;
  55927. /**
  55928. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55929. * This is multiply against the scalar values defined in the material.
  55930. */
  55931. metallicReflectanceTexture: Nullable<BaseTexture>;
  55932. /**
  55933. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55934. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55935. */
  55936. microSurfaceTexture: BaseTexture;
  55937. /**
  55938. * Stores surface normal data used to displace a mesh in a texture.
  55939. */
  55940. bumpTexture: BaseTexture;
  55941. /**
  55942. * Stores the pre-calculated light information of a mesh in a texture.
  55943. */
  55944. lightmapTexture: BaseTexture;
  55945. /**
  55946. * Stores the refracted light information in a texture.
  55947. */
  55948. get refractionTexture(): Nullable<BaseTexture>;
  55949. set refractionTexture(value: Nullable<BaseTexture>);
  55950. /**
  55951. * The color of a material in ambient lighting.
  55952. */
  55953. ambientColor: Color3;
  55954. /**
  55955. * AKA Diffuse Color in other nomenclature.
  55956. */
  55957. albedoColor: Color3;
  55958. /**
  55959. * AKA Specular Color in other nomenclature.
  55960. */
  55961. reflectivityColor: Color3;
  55962. /**
  55963. * The color reflected from the material.
  55964. */
  55965. reflectionColor: Color3;
  55966. /**
  55967. * The color emitted from the material.
  55968. */
  55969. emissiveColor: Color3;
  55970. /**
  55971. * AKA Glossiness in other nomenclature.
  55972. */
  55973. microSurface: number;
  55974. /**
  55975. * Index of refraction of the material base layer.
  55976. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55977. *
  55978. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55979. *
  55980. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55981. */
  55982. get indexOfRefraction(): number;
  55983. set indexOfRefraction(value: number);
  55984. /**
  55985. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55986. */
  55987. get invertRefractionY(): boolean;
  55988. set invertRefractionY(value: boolean);
  55989. /**
  55990. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55991. * Materials half opaque for instance using refraction could benefit from this control.
  55992. */
  55993. get linkRefractionWithTransparency(): boolean;
  55994. set linkRefractionWithTransparency(value: boolean);
  55995. /**
  55996. * If true, the light map contains occlusion information instead of lighting info.
  55997. */
  55998. useLightmapAsShadowmap: boolean;
  55999. /**
  56000. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56001. */
  56002. useAlphaFromAlbedoTexture: boolean;
  56003. /**
  56004. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56005. */
  56006. forceAlphaTest: boolean;
  56007. /**
  56008. * Defines the alpha limits in alpha test mode.
  56009. */
  56010. alphaCutOff: number;
  56011. /**
  56012. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56013. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56014. */
  56015. useSpecularOverAlpha: boolean;
  56016. /**
  56017. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56018. */
  56019. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56020. /**
  56021. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56022. */
  56023. useRoughnessFromMetallicTextureAlpha: boolean;
  56024. /**
  56025. * Specifies if the metallic texture contains the roughness information in its green channel.
  56026. */
  56027. useRoughnessFromMetallicTextureGreen: boolean;
  56028. /**
  56029. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56030. */
  56031. useMetallnessFromMetallicTextureBlue: boolean;
  56032. /**
  56033. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56034. */
  56035. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56036. /**
  56037. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56038. */
  56039. useAmbientInGrayScale: boolean;
  56040. /**
  56041. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56042. * The material will try to infer what glossiness each pixel should be.
  56043. */
  56044. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56045. /**
  56046. * BJS is using an harcoded light falloff based on a manually sets up range.
  56047. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56048. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56049. */
  56050. get usePhysicalLightFalloff(): 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. set usePhysicalLightFalloff(value: boolean);
  56057. /**
  56058. * In order to support the falloff compatibility with gltf, a special mode has been added
  56059. * to reproduce the gltf light falloff.
  56060. */
  56061. get useGLTFLightFalloff(): boolean;
  56062. /**
  56063. * In order to support the falloff compatibility with gltf, a special mode has been added
  56064. * to reproduce the gltf light falloff.
  56065. */
  56066. set useGLTFLightFalloff(value: boolean);
  56067. /**
  56068. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56069. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56070. */
  56071. useRadianceOverAlpha: boolean;
  56072. /**
  56073. * Allows using an object space normal map (instead of tangent space).
  56074. */
  56075. useObjectSpaceNormalMap: boolean;
  56076. /**
  56077. * Allows using the bump map in parallax mode.
  56078. */
  56079. useParallax: boolean;
  56080. /**
  56081. * Allows using the bump map in parallax occlusion mode.
  56082. */
  56083. useParallaxOcclusion: boolean;
  56084. /**
  56085. * Controls the scale bias of the parallax mode.
  56086. */
  56087. parallaxScaleBias: number;
  56088. /**
  56089. * If sets to true, disables all the lights affecting the material.
  56090. */
  56091. disableLighting: boolean;
  56092. /**
  56093. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56094. */
  56095. forceIrradianceInFragment: boolean;
  56096. /**
  56097. * Number of Simultaneous lights allowed on the material.
  56098. */
  56099. maxSimultaneousLights: number;
  56100. /**
  56101. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56102. */
  56103. invertNormalMapX: boolean;
  56104. /**
  56105. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56106. */
  56107. invertNormalMapY: boolean;
  56108. /**
  56109. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56110. */
  56111. twoSidedLighting: boolean;
  56112. /**
  56113. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56114. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56115. */
  56116. useAlphaFresnel: boolean;
  56117. /**
  56118. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56119. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56120. */
  56121. useLinearAlphaFresnel: boolean;
  56122. /**
  56123. * Let user defines the brdf lookup texture used for IBL.
  56124. * A default 8bit version is embedded but you could point at :
  56125. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56126. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56127. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56128. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56129. */
  56130. environmentBRDFTexture: Nullable<BaseTexture>;
  56131. /**
  56132. * Force normal to face away from face.
  56133. */
  56134. forceNormalForward: boolean;
  56135. /**
  56136. * Enables specular anti aliasing in the PBR shader.
  56137. * It will both interacts on the Geometry for analytical and IBL lighting.
  56138. * It also prefilter the roughness map based on the bump values.
  56139. */
  56140. enableSpecularAntiAliasing: boolean;
  56141. /**
  56142. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56143. * makes the reflect vector face the model (under horizon).
  56144. */
  56145. useHorizonOcclusion: boolean;
  56146. /**
  56147. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56148. * too much the area relying on ambient texture to define their ambient occlusion.
  56149. */
  56150. useRadianceOcclusion: boolean;
  56151. /**
  56152. * If set to true, no lighting calculations will be applied.
  56153. */
  56154. unlit: boolean;
  56155. /**
  56156. * Gets the image processing configuration used either in this material.
  56157. */
  56158. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56159. /**
  56160. * Sets the Default image processing configuration used either in the this material.
  56161. *
  56162. * If sets to null, the scene one is in use.
  56163. */
  56164. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56165. /**
  56166. * Gets wether the color curves effect is enabled.
  56167. */
  56168. get cameraColorCurvesEnabled(): boolean;
  56169. /**
  56170. * Sets wether the color curves effect is enabled.
  56171. */
  56172. set cameraColorCurvesEnabled(value: boolean);
  56173. /**
  56174. * Gets wether the color grading effect is enabled.
  56175. */
  56176. get cameraColorGradingEnabled(): boolean;
  56177. /**
  56178. * Gets wether the color grading effect is enabled.
  56179. */
  56180. set cameraColorGradingEnabled(value: boolean);
  56181. /**
  56182. * Gets wether tonemapping is enabled or not.
  56183. */
  56184. get cameraToneMappingEnabled(): boolean;
  56185. /**
  56186. * Sets wether tonemapping is enabled or not
  56187. */
  56188. set cameraToneMappingEnabled(value: boolean);
  56189. /**
  56190. * The camera exposure used on this material.
  56191. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56192. * This corresponds to a photographic exposure.
  56193. */
  56194. get cameraExposure(): number;
  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. set cameraExposure(value: number);
  56201. /**
  56202. * Gets The camera contrast used on this material.
  56203. */
  56204. get cameraContrast(): number;
  56205. /**
  56206. * Sets The camera contrast used on this material.
  56207. */
  56208. set cameraContrast(value: number);
  56209. /**
  56210. * Gets the Color Grading 2D Lookup Texture.
  56211. */
  56212. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56213. /**
  56214. * Sets the Color Grading 2D Lookup Texture.
  56215. */
  56216. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56217. /**
  56218. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56219. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56220. * 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;
  56221. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56222. */
  56223. get cameraColorCurves(): Nullable<ColorCurves>;
  56224. /**
  56225. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56226. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56227. * 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;
  56228. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56229. */
  56230. set cameraColorCurves(value: Nullable<ColorCurves>);
  56231. /**
  56232. * Instantiates a new PBRMaterial instance.
  56233. *
  56234. * @param name The material name
  56235. * @param scene The scene the material will be use in.
  56236. */
  56237. constructor(name: string, scene: Scene);
  56238. /**
  56239. * Returns the name of this material class.
  56240. */
  56241. getClassName(): string;
  56242. /**
  56243. * Makes a duplicate of the current material.
  56244. * @param name - name to use for the new material.
  56245. */
  56246. clone(name: string): PBRMaterial;
  56247. /**
  56248. * Serializes this PBR Material.
  56249. * @returns - An object with the serialized material.
  56250. */
  56251. serialize(): any;
  56252. /**
  56253. * Parses a PBR Material from a serialized object.
  56254. * @param source - Serialized object.
  56255. * @param scene - BJS scene instance.
  56256. * @param rootUrl - url for the scene object
  56257. * @returns - PBRMaterial
  56258. */
  56259. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56260. }
  56261. }
  56262. declare module BABYLON {
  56263. /**
  56264. * Direct draw surface info
  56265. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56266. */
  56267. export interface DDSInfo {
  56268. /**
  56269. * Width of the texture
  56270. */
  56271. width: number;
  56272. /**
  56273. * Width of the texture
  56274. */
  56275. height: number;
  56276. /**
  56277. * Number of Mipmaps for the texture
  56278. * @see https://en.wikipedia.org/wiki/Mipmap
  56279. */
  56280. mipmapCount: number;
  56281. /**
  56282. * If the textures format is a known fourCC format
  56283. * @see https://www.fourcc.org/
  56284. */
  56285. isFourCC: boolean;
  56286. /**
  56287. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56288. */
  56289. isRGB: boolean;
  56290. /**
  56291. * If the texture is a lumincance format
  56292. */
  56293. isLuminance: boolean;
  56294. /**
  56295. * If this is a cube texture
  56296. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56297. */
  56298. isCube: boolean;
  56299. /**
  56300. * If the texture is a compressed format eg. FOURCC_DXT1
  56301. */
  56302. isCompressed: boolean;
  56303. /**
  56304. * The dxgiFormat of the texture
  56305. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56306. */
  56307. dxgiFormat: number;
  56308. /**
  56309. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56310. */
  56311. textureType: number;
  56312. /**
  56313. * Sphericle polynomial created for the dds texture
  56314. */
  56315. sphericalPolynomial?: SphericalPolynomial;
  56316. }
  56317. /**
  56318. * Class used to provide DDS decompression tools
  56319. */
  56320. export class DDSTools {
  56321. /**
  56322. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56323. */
  56324. static StoreLODInAlphaChannel: boolean;
  56325. /**
  56326. * Gets DDS information from an array buffer
  56327. * @param data defines the array buffer view to read data from
  56328. * @returns the DDS information
  56329. */
  56330. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56331. private static _FloatView;
  56332. private static _Int32View;
  56333. private static _ToHalfFloat;
  56334. private static _FromHalfFloat;
  56335. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56336. private static _GetHalfFloatRGBAArrayBuffer;
  56337. private static _GetFloatRGBAArrayBuffer;
  56338. private static _GetFloatAsUIntRGBAArrayBuffer;
  56339. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56340. private static _GetRGBAArrayBuffer;
  56341. private static _ExtractLongWordOrder;
  56342. private static _GetRGBArrayBuffer;
  56343. private static _GetLuminanceArrayBuffer;
  56344. /**
  56345. * Uploads DDS Levels to a Babylon Texture
  56346. * @hidden
  56347. */
  56348. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56349. }
  56350. interface ThinEngine {
  56351. /**
  56352. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56353. * @param rootUrl defines the url where the file to load is located
  56354. * @param scene defines the current scene
  56355. * @param lodScale defines scale to apply to the mip map selection
  56356. * @param lodOffset defines offset to apply to the mip map selection
  56357. * @param onLoad defines an optional callback raised when the texture is loaded
  56358. * @param onError defines an optional callback raised if there is an issue to load the texture
  56359. * @param format defines the format of the data
  56360. * @param forcedExtension defines the extension to use to pick the right loader
  56361. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56362. * @returns the cube texture as an InternalTexture
  56363. */
  56364. 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;
  56365. }
  56366. }
  56367. declare module BABYLON {
  56368. /**
  56369. * Implementation of the DDS Texture Loader.
  56370. * @hidden
  56371. */
  56372. export class _DDSTextureLoader implements IInternalTextureLoader {
  56373. /**
  56374. * Defines wether the loader supports cascade loading the different faces.
  56375. */
  56376. readonly supportCascades: boolean;
  56377. /**
  56378. * This returns if the loader support the current file information.
  56379. * @param extension defines the file extension of the file being loaded
  56380. * @returns true if the loader can load the specified file
  56381. */
  56382. canLoad(extension: string): boolean;
  56383. /**
  56384. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56385. * @param data contains the texture data
  56386. * @param texture defines the BabylonJS internal texture
  56387. * @param createPolynomials will be true if polynomials have been requested
  56388. * @param onLoad defines the callback to trigger once the texture is ready
  56389. * @param onError defines the callback to trigger in case of error
  56390. */
  56391. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56392. /**
  56393. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56394. * @param data contains the texture data
  56395. * @param texture defines the BabylonJS internal texture
  56396. * @param callback defines the method to call once ready to upload
  56397. */
  56398. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56399. }
  56400. }
  56401. declare module BABYLON {
  56402. /**
  56403. * Implementation of the ENV Texture Loader.
  56404. * @hidden
  56405. */
  56406. export class _ENVTextureLoader implements IInternalTextureLoader {
  56407. /**
  56408. * Defines wether the loader supports cascade loading the different faces.
  56409. */
  56410. readonly supportCascades: boolean;
  56411. /**
  56412. * This returns if the loader support the current file information.
  56413. * @param extension defines the file extension of the file being loaded
  56414. * @returns true if the loader can load the specified file
  56415. */
  56416. canLoad(extension: string): boolean;
  56417. /**
  56418. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56419. * @param data contains the texture data
  56420. * @param texture defines the BabylonJS internal texture
  56421. * @param createPolynomials will be true if polynomials have been requested
  56422. * @param onLoad defines the callback to trigger once the texture is ready
  56423. * @param onError defines the callback to trigger in case of error
  56424. */
  56425. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56426. /**
  56427. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56428. * @param data contains the texture data
  56429. * @param texture defines the BabylonJS internal texture
  56430. * @param callback defines the method to call once ready to upload
  56431. */
  56432. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56433. }
  56434. }
  56435. declare module BABYLON {
  56436. /**
  56437. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56438. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56439. */
  56440. export class KhronosTextureContainer {
  56441. /** contents of the KTX container file */
  56442. data: ArrayBufferView;
  56443. private static HEADER_LEN;
  56444. private static COMPRESSED_2D;
  56445. private static COMPRESSED_3D;
  56446. private static TEX_2D;
  56447. private static TEX_3D;
  56448. /**
  56449. * Gets the openGL type
  56450. */
  56451. glType: number;
  56452. /**
  56453. * Gets the openGL type size
  56454. */
  56455. glTypeSize: number;
  56456. /**
  56457. * Gets the openGL format
  56458. */
  56459. glFormat: number;
  56460. /**
  56461. * Gets the openGL internal format
  56462. */
  56463. glInternalFormat: number;
  56464. /**
  56465. * Gets the base internal format
  56466. */
  56467. glBaseInternalFormat: number;
  56468. /**
  56469. * Gets image width in pixel
  56470. */
  56471. pixelWidth: number;
  56472. /**
  56473. * Gets image height in pixel
  56474. */
  56475. pixelHeight: number;
  56476. /**
  56477. * Gets image depth in pixels
  56478. */
  56479. pixelDepth: number;
  56480. /**
  56481. * Gets the number of array elements
  56482. */
  56483. numberOfArrayElements: number;
  56484. /**
  56485. * Gets the number of faces
  56486. */
  56487. numberOfFaces: number;
  56488. /**
  56489. * Gets the number of mipmap levels
  56490. */
  56491. numberOfMipmapLevels: number;
  56492. /**
  56493. * Gets the bytes of key value data
  56494. */
  56495. bytesOfKeyValueData: number;
  56496. /**
  56497. * Gets the load type
  56498. */
  56499. loadType: number;
  56500. /**
  56501. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56502. */
  56503. isInvalid: boolean;
  56504. /**
  56505. * Creates a new KhronosTextureContainer
  56506. * @param data contents of the KTX container file
  56507. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56508. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56509. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56510. */
  56511. constructor(
  56512. /** contents of the KTX container file */
  56513. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56514. /**
  56515. * Uploads KTX content to a Babylon Texture.
  56516. * It is assumed that the texture has already been created & is currently bound
  56517. * @hidden
  56518. */
  56519. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56520. private _upload2DCompressedLevels;
  56521. /**
  56522. * Checks if the given data starts with a KTX file identifier.
  56523. * @param data the data to check
  56524. * @returns true if the data is a KTX file or false otherwise
  56525. */
  56526. static IsValid(data: ArrayBufferView): boolean;
  56527. }
  56528. }
  56529. declare module BABYLON {
  56530. /**
  56531. * Class for loading KTX2 files
  56532. * !!! Experimental Extension Subject to Changes !!!
  56533. * @hidden
  56534. */
  56535. export class KhronosTextureContainer2 {
  56536. private static _ModulePromise;
  56537. private static _TranscodeFormat;
  56538. constructor(engine: ThinEngine);
  56539. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56540. private _determineTranscodeFormat;
  56541. /**
  56542. * Checks if the given data starts with a KTX2 file identifier.
  56543. * @param data the data to check
  56544. * @returns true if the data is a KTX2 file or false otherwise
  56545. */
  56546. static IsValid(data: ArrayBufferView): boolean;
  56547. }
  56548. }
  56549. declare module BABYLON {
  56550. /**
  56551. * Implementation of the KTX Texture Loader.
  56552. * @hidden
  56553. */
  56554. export class _KTXTextureLoader implements IInternalTextureLoader {
  56555. /**
  56556. * Defines wether the loader supports cascade loading the different faces.
  56557. */
  56558. readonly supportCascades: boolean;
  56559. /**
  56560. * This returns if the loader support the current file information.
  56561. * @param extension defines the file extension of the file being loaded
  56562. * @param mimeType defines the optional mime type of the file being loaded
  56563. * @returns true if the loader can load the specified file
  56564. */
  56565. canLoad(extension: string, mimeType?: string): boolean;
  56566. /**
  56567. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56568. * @param data contains the texture data
  56569. * @param texture defines the BabylonJS internal texture
  56570. * @param createPolynomials will be true if polynomials have been requested
  56571. * @param onLoad defines the callback to trigger once the texture is ready
  56572. * @param onError defines the callback to trigger in case of error
  56573. */
  56574. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56575. /**
  56576. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56577. * @param data contains the texture data
  56578. * @param texture defines the BabylonJS internal texture
  56579. * @param callback defines the method to call once ready to upload
  56580. */
  56581. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56582. }
  56583. }
  56584. declare module BABYLON {
  56585. /** @hidden */
  56586. export var _forceSceneHelpersToBundle: boolean;
  56587. interface Scene {
  56588. /**
  56589. * Creates a default light for the scene.
  56590. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56591. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56592. */
  56593. createDefaultLight(replace?: boolean): void;
  56594. /**
  56595. * Creates a default camera for the scene.
  56596. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56597. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56598. * @param replace has default false, when true replaces the active camera in the scene
  56599. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56600. */
  56601. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56602. /**
  56603. * Creates a default camera and a default light.
  56604. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56605. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56606. * @param replace has the default false, when true replaces the active camera/light in the scene
  56607. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56608. */
  56609. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56610. /**
  56611. * Creates a new sky box
  56612. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56613. * @param environmentTexture defines the texture to use as environment texture
  56614. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56615. * @param scale defines the overall scale of the skybox
  56616. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56617. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56618. * @returns a new mesh holding the sky box
  56619. */
  56620. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56621. /**
  56622. * Creates a new environment
  56623. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56624. * @param options defines the options you can use to configure the environment
  56625. * @returns the new EnvironmentHelper
  56626. */
  56627. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56628. /**
  56629. * Creates a new VREXperienceHelper
  56630. * @see https://doc.babylonjs.com/how_to/webvr_helper
  56631. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56632. * @returns a new VREXperienceHelper
  56633. */
  56634. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56635. /**
  56636. * Creates a new WebXRDefaultExperience
  56637. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  56638. * @param options experience options
  56639. * @returns a promise for a new WebXRDefaultExperience
  56640. */
  56641. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56642. }
  56643. }
  56644. declare module BABYLON {
  56645. /**
  56646. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56647. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56648. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56649. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56650. */
  56651. export class VideoDome extends TransformNode {
  56652. /**
  56653. * Define the video source as a Monoscopic panoramic 360 video.
  56654. */
  56655. static readonly MODE_MONOSCOPIC: number;
  56656. /**
  56657. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56658. */
  56659. static readonly MODE_TOPBOTTOM: number;
  56660. /**
  56661. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56662. */
  56663. static readonly MODE_SIDEBYSIDE: number;
  56664. private _halfDome;
  56665. private _useDirectMapping;
  56666. /**
  56667. * The video texture being displayed on the sphere
  56668. */
  56669. protected _videoTexture: VideoTexture;
  56670. /**
  56671. * Gets the video texture being displayed on the sphere
  56672. */
  56673. get videoTexture(): VideoTexture;
  56674. /**
  56675. * The skybox material
  56676. */
  56677. protected _material: BackgroundMaterial;
  56678. /**
  56679. * The surface used for the skybox
  56680. */
  56681. protected _mesh: Mesh;
  56682. /**
  56683. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56684. */
  56685. private _halfDomeMask;
  56686. /**
  56687. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56688. * Also see the options.resolution property.
  56689. */
  56690. get fovMultiplier(): number;
  56691. set fovMultiplier(value: number);
  56692. private _videoMode;
  56693. /**
  56694. * Gets or set the current video mode for the video. It can be:
  56695. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56696. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56697. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56698. */
  56699. get videoMode(): number;
  56700. set videoMode(value: number);
  56701. /**
  56702. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56703. *
  56704. */
  56705. get halfDome(): boolean;
  56706. /**
  56707. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56708. */
  56709. set halfDome(enabled: boolean);
  56710. /**
  56711. * Oberserver used in Stereoscopic VR Mode.
  56712. */
  56713. private _onBeforeCameraRenderObserver;
  56714. /**
  56715. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56716. * @param name Element's name, child elements will append suffixes for their own names.
  56717. * @param urlsOrVideo defines the url(s) or the video element to use
  56718. * @param options An object containing optional or exposed sub element properties
  56719. */
  56720. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56721. resolution?: number;
  56722. clickToPlay?: boolean;
  56723. autoPlay?: boolean;
  56724. loop?: boolean;
  56725. size?: number;
  56726. poster?: string;
  56727. faceForward?: boolean;
  56728. useDirectMapping?: boolean;
  56729. halfDomeMode?: boolean;
  56730. }, scene: Scene);
  56731. private _changeVideoMode;
  56732. /**
  56733. * Releases resources associated with this node.
  56734. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56735. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56736. */
  56737. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56738. }
  56739. }
  56740. declare module BABYLON {
  56741. /**
  56742. * This class can be used to get instrumentation data from a Babylon engine
  56743. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56744. */
  56745. export class EngineInstrumentation implements IDisposable {
  56746. /**
  56747. * Define the instrumented engine.
  56748. */
  56749. engine: Engine;
  56750. private _captureGPUFrameTime;
  56751. private _gpuFrameTimeToken;
  56752. private _gpuFrameTime;
  56753. private _captureShaderCompilationTime;
  56754. private _shaderCompilationTime;
  56755. private _onBeginFrameObserver;
  56756. private _onEndFrameObserver;
  56757. private _onBeforeShaderCompilationObserver;
  56758. private _onAfterShaderCompilationObserver;
  56759. /**
  56760. * Gets the perf counter used for GPU frame time
  56761. */
  56762. get gpuFrameTimeCounter(): PerfCounter;
  56763. /**
  56764. * Gets the GPU frame time capture status
  56765. */
  56766. get captureGPUFrameTime(): boolean;
  56767. /**
  56768. * Enable or disable the GPU frame time capture
  56769. */
  56770. set captureGPUFrameTime(value: boolean);
  56771. /**
  56772. * Gets the perf counter used for shader compilation time
  56773. */
  56774. get shaderCompilationTimeCounter(): PerfCounter;
  56775. /**
  56776. * Gets the shader compilation time capture status
  56777. */
  56778. get captureShaderCompilationTime(): boolean;
  56779. /**
  56780. * Enable or disable the shader compilation time capture
  56781. */
  56782. set captureShaderCompilationTime(value: boolean);
  56783. /**
  56784. * Instantiates a new engine instrumentation.
  56785. * This class can be used to get instrumentation data from a Babylon engine
  56786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56787. * @param engine Defines the engine to instrument
  56788. */
  56789. constructor(
  56790. /**
  56791. * Define the instrumented engine.
  56792. */
  56793. engine: Engine);
  56794. /**
  56795. * Dispose and release associated resources.
  56796. */
  56797. dispose(): void;
  56798. }
  56799. }
  56800. declare module BABYLON {
  56801. /**
  56802. * This class can be used to get instrumentation data from a Babylon engine
  56803. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56804. */
  56805. export class SceneInstrumentation implements IDisposable {
  56806. /**
  56807. * Defines the scene to instrument
  56808. */
  56809. scene: Scene;
  56810. private _captureActiveMeshesEvaluationTime;
  56811. private _activeMeshesEvaluationTime;
  56812. private _captureRenderTargetsRenderTime;
  56813. private _renderTargetsRenderTime;
  56814. private _captureFrameTime;
  56815. private _frameTime;
  56816. private _captureRenderTime;
  56817. private _renderTime;
  56818. private _captureInterFrameTime;
  56819. private _interFrameTime;
  56820. private _captureParticlesRenderTime;
  56821. private _particlesRenderTime;
  56822. private _captureSpritesRenderTime;
  56823. private _spritesRenderTime;
  56824. private _capturePhysicsTime;
  56825. private _physicsTime;
  56826. private _captureAnimationsTime;
  56827. private _animationsTime;
  56828. private _captureCameraRenderTime;
  56829. private _cameraRenderTime;
  56830. private _onBeforeActiveMeshesEvaluationObserver;
  56831. private _onAfterActiveMeshesEvaluationObserver;
  56832. private _onBeforeRenderTargetsRenderObserver;
  56833. private _onAfterRenderTargetsRenderObserver;
  56834. private _onAfterRenderObserver;
  56835. private _onBeforeDrawPhaseObserver;
  56836. private _onAfterDrawPhaseObserver;
  56837. private _onBeforeAnimationsObserver;
  56838. private _onBeforeParticlesRenderingObserver;
  56839. private _onAfterParticlesRenderingObserver;
  56840. private _onBeforeSpritesRenderingObserver;
  56841. private _onAfterSpritesRenderingObserver;
  56842. private _onBeforePhysicsObserver;
  56843. private _onAfterPhysicsObserver;
  56844. private _onAfterAnimationsObserver;
  56845. private _onBeforeCameraRenderObserver;
  56846. private _onAfterCameraRenderObserver;
  56847. /**
  56848. * Gets the perf counter used for active meshes evaluation time
  56849. */
  56850. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56851. /**
  56852. * Gets the active meshes evaluation time capture status
  56853. */
  56854. get captureActiveMeshesEvaluationTime(): boolean;
  56855. /**
  56856. * Enable or disable the active meshes evaluation time capture
  56857. */
  56858. set captureActiveMeshesEvaluationTime(value: boolean);
  56859. /**
  56860. * Gets the perf counter used for render targets render time
  56861. */
  56862. get renderTargetsRenderTimeCounter(): PerfCounter;
  56863. /**
  56864. * Gets the render targets render time capture status
  56865. */
  56866. get captureRenderTargetsRenderTime(): boolean;
  56867. /**
  56868. * Enable or disable the render targets render time capture
  56869. */
  56870. set captureRenderTargetsRenderTime(value: boolean);
  56871. /**
  56872. * Gets the perf counter used for particles render time
  56873. */
  56874. get particlesRenderTimeCounter(): PerfCounter;
  56875. /**
  56876. * Gets the particles render time capture status
  56877. */
  56878. get captureParticlesRenderTime(): boolean;
  56879. /**
  56880. * Enable or disable the particles render time capture
  56881. */
  56882. set captureParticlesRenderTime(value: boolean);
  56883. /**
  56884. * Gets the perf counter used for sprites render time
  56885. */
  56886. get spritesRenderTimeCounter(): PerfCounter;
  56887. /**
  56888. * Gets the sprites render time capture status
  56889. */
  56890. get captureSpritesRenderTime(): boolean;
  56891. /**
  56892. * Enable or disable the sprites render time capture
  56893. */
  56894. set captureSpritesRenderTime(value: boolean);
  56895. /**
  56896. * Gets the perf counter used for physics time
  56897. */
  56898. get physicsTimeCounter(): PerfCounter;
  56899. /**
  56900. * Gets the physics time capture status
  56901. */
  56902. get capturePhysicsTime(): boolean;
  56903. /**
  56904. * Enable or disable the physics time capture
  56905. */
  56906. set capturePhysicsTime(value: boolean);
  56907. /**
  56908. * Gets the perf counter used for animations time
  56909. */
  56910. get animationsTimeCounter(): PerfCounter;
  56911. /**
  56912. * Gets the animations time capture status
  56913. */
  56914. get captureAnimationsTime(): boolean;
  56915. /**
  56916. * Enable or disable the animations time capture
  56917. */
  56918. set captureAnimationsTime(value: boolean);
  56919. /**
  56920. * Gets the perf counter used for frame time capture
  56921. */
  56922. get frameTimeCounter(): PerfCounter;
  56923. /**
  56924. * Gets the frame time capture status
  56925. */
  56926. get captureFrameTime(): boolean;
  56927. /**
  56928. * Enable or disable the frame time capture
  56929. */
  56930. set captureFrameTime(value: boolean);
  56931. /**
  56932. * Gets the perf counter used for inter-frames time capture
  56933. */
  56934. get interFrameTimeCounter(): PerfCounter;
  56935. /**
  56936. * Gets the inter-frames time capture status
  56937. */
  56938. get captureInterFrameTime(): boolean;
  56939. /**
  56940. * Enable or disable the inter-frames time capture
  56941. */
  56942. set captureInterFrameTime(value: boolean);
  56943. /**
  56944. * Gets the perf counter used for render time capture
  56945. */
  56946. get renderTimeCounter(): PerfCounter;
  56947. /**
  56948. * Gets the render time capture status
  56949. */
  56950. get captureRenderTime(): boolean;
  56951. /**
  56952. * Enable or disable the render time capture
  56953. */
  56954. set captureRenderTime(value: boolean);
  56955. /**
  56956. * Gets the perf counter used for camera render time capture
  56957. */
  56958. get cameraRenderTimeCounter(): PerfCounter;
  56959. /**
  56960. * Gets the camera render time capture status
  56961. */
  56962. get captureCameraRenderTime(): boolean;
  56963. /**
  56964. * Enable or disable the camera render time capture
  56965. */
  56966. set captureCameraRenderTime(value: boolean);
  56967. /**
  56968. * Gets the perf counter used for draw calls
  56969. */
  56970. get drawCallsCounter(): PerfCounter;
  56971. /**
  56972. * Instantiates a new scene instrumentation.
  56973. * This class can be used to get instrumentation data from a Babylon engine
  56974. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56975. * @param scene Defines the scene to instrument
  56976. */
  56977. constructor(
  56978. /**
  56979. * Defines the scene to instrument
  56980. */
  56981. scene: Scene);
  56982. /**
  56983. * Dispose and release associated resources.
  56984. */
  56985. dispose(): void;
  56986. }
  56987. }
  56988. declare module BABYLON {
  56989. /** @hidden */
  56990. export var glowMapGenerationPixelShader: {
  56991. name: string;
  56992. shader: string;
  56993. };
  56994. }
  56995. declare module BABYLON {
  56996. /** @hidden */
  56997. export var glowMapGenerationVertexShader: {
  56998. name: string;
  56999. shader: string;
  57000. };
  57001. }
  57002. declare module BABYLON {
  57003. /**
  57004. * Effect layer options. This helps customizing the behaviour
  57005. * of the effect layer.
  57006. */
  57007. export interface IEffectLayerOptions {
  57008. /**
  57009. * Multiplication factor apply to the canvas size to compute the render target size
  57010. * used to generated the objects (the smaller the faster).
  57011. */
  57012. mainTextureRatio: number;
  57013. /**
  57014. * Enforces a fixed size texture to ensure effect stability across devices.
  57015. */
  57016. mainTextureFixedSize?: number;
  57017. /**
  57018. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57019. */
  57020. alphaBlendingMode: number;
  57021. /**
  57022. * The camera attached to the layer.
  57023. */
  57024. camera: Nullable<Camera>;
  57025. /**
  57026. * The rendering group to draw the layer in.
  57027. */
  57028. renderingGroupId: number;
  57029. }
  57030. /**
  57031. * The effect layer Helps adding post process effect blended with the main pass.
  57032. *
  57033. * This can be for instance use to generate glow or higlight effects on the scene.
  57034. *
  57035. * The effect layer class can not be used directly and is intented to inherited from to be
  57036. * customized per effects.
  57037. */
  57038. export abstract class EffectLayer {
  57039. private _vertexBuffers;
  57040. private _indexBuffer;
  57041. private _cachedDefines;
  57042. private _effectLayerMapGenerationEffect;
  57043. private _effectLayerOptions;
  57044. private _mergeEffect;
  57045. protected _scene: Scene;
  57046. protected _engine: Engine;
  57047. protected _maxSize: number;
  57048. protected _mainTextureDesiredSize: ISize;
  57049. protected _mainTexture: RenderTargetTexture;
  57050. protected _shouldRender: boolean;
  57051. protected _postProcesses: PostProcess[];
  57052. protected _textures: BaseTexture[];
  57053. protected _emissiveTextureAndColor: {
  57054. texture: Nullable<BaseTexture>;
  57055. color: Color4;
  57056. };
  57057. /**
  57058. * The name of the layer
  57059. */
  57060. name: string;
  57061. /**
  57062. * The clear color of the texture used to generate the glow map.
  57063. */
  57064. neutralColor: Color4;
  57065. /**
  57066. * Specifies whether the highlight layer is enabled or not.
  57067. */
  57068. isEnabled: boolean;
  57069. /**
  57070. * Gets the camera attached to the layer.
  57071. */
  57072. get camera(): Nullable<Camera>;
  57073. /**
  57074. * Gets the rendering group id the layer should render in.
  57075. */
  57076. get renderingGroupId(): number;
  57077. set renderingGroupId(renderingGroupId: number);
  57078. /**
  57079. * An event triggered when the effect layer has been disposed.
  57080. */
  57081. onDisposeObservable: Observable<EffectLayer>;
  57082. /**
  57083. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57084. */
  57085. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57086. /**
  57087. * An event triggered when the generated texture is being merged in the scene.
  57088. */
  57089. onBeforeComposeObservable: Observable<EffectLayer>;
  57090. /**
  57091. * An event triggered when the mesh is rendered into the effect render target.
  57092. */
  57093. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57094. /**
  57095. * An event triggered after the mesh has been rendered into the effect render target.
  57096. */
  57097. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57098. /**
  57099. * An event triggered when the generated texture has been merged in the scene.
  57100. */
  57101. onAfterComposeObservable: Observable<EffectLayer>;
  57102. /**
  57103. * An event triggered when the efffect layer changes its size.
  57104. */
  57105. onSizeChangedObservable: Observable<EffectLayer>;
  57106. /** @hidden */
  57107. static _SceneComponentInitialization: (scene: Scene) => void;
  57108. /**
  57109. * Instantiates a new effect Layer and references it in the scene.
  57110. * @param name The name of the layer
  57111. * @param scene The scene to use the layer in
  57112. */
  57113. constructor(
  57114. /** The Friendly of the effect in the scene */
  57115. name: string, scene: Scene);
  57116. /**
  57117. * Get the effect name of the layer.
  57118. * @return The effect name
  57119. */
  57120. abstract getEffectName(): string;
  57121. /**
  57122. * Checks for the readiness of the element composing the layer.
  57123. * @param subMesh the mesh to check for
  57124. * @param useInstances specify whether or not to use instances to render the mesh
  57125. * @return true if ready otherwise, false
  57126. */
  57127. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57128. /**
  57129. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57130. * @returns true if the effect requires stencil during the main canvas render pass.
  57131. */
  57132. abstract needStencil(): boolean;
  57133. /**
  57134. * Create the merge effect. This is the shader use to blit the information back
  57135. * to the main canvas at the end of the scene rendering.
  57136. * @returns The effect containing the shader used to merge the effect on the main canvas
  57137. */
  57138. protected abstract _createMergeEffect(): Effect;
  57139. /**
  57140. * Creates the render target textures and post processes used in the effect layer.
  57141. */
  57142. protected abstract _createTextureAndPostProcesses(): void;
  57143. /**
  57144. * Implementation specific of rendering the generating effect on the main canvas.
  57145. * @param effect The effect used to render through
  57146. */
  57147. protected abstract _internalRender(effect: Effect): void;
  57148. /**
  57149. * Sets the required values for both the emissive texture and and the main color.
  57150. */
  57151. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57152. /**
  57153. * Free any resources and references associated to a mesh.
  57154. * Internal use
  57155. * @param mesh The mesh to free.
  57156. */
  57157. abstract _disposeMesh(mesh: Mesh): void;
  57158. /**
  57159. * Serializes this layer (Glow or Highlight for example)
  57160. * @returns a serialized layer object
  57161. */
  57162. abstract serialize?(): any;
  57163. /**
  57164. * Initializes the effect layer with the required options.
  57165. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57166. */
  57167. protected _init(options: Partial<IEffectLayerOptions>): void;
  57168. /**
  57169. * Generates the index buffer of the full screen quad blending to the main canvas.
  57170. */
  57171. private _generateIndexBuffer;
  57172. /**
  57173. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57174. */
  57175. private _generateVertexBuffer;
  57176. /**
  57177. * Sets the main texture desired size which is the closest power of two
  57178. * of the engine canvas size.
  57179. */
  57180. private _setMainTextureSize;
  57181. /**
  57182. * Creates the main texture for the effect layer.
  57183. */
  57184. protected _createMainTexture(): void;
  57185. /**
  57186. * Adds specific effects defines.
  57187. * @param defines The defines to add specifics to.
  57188. */
  57189. protected _addCustomEffectDefines(defines: string[]): void;
  57190. /**
  57191. * Checks for the readiness of the element composing the layer.
  57192. * @param subMesh the mesh to check for
  57193. * @param useInstances specify whether or not to use instances to render the mesh
  57194. * @param emissiveTexture the associated emissive texture used to generate the glow
  57195. * @return true if ready otherwise, false
  57196. */
  57197. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57198. /**
  57199. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57200. */
  57201. render(): void;
  57202. /**
  57203. * Determine if a given mesh will be used in the current effect.
  57204. * @param mesh mesh to test
  57205. * @returns true if the mesh will be used
  57206. */
  57207. hasMesh(mesh: AbstractMesh): boolean;
  57208. /**
  57209. * Returns true if the layer contains information to display, otherwise false.
  57210. * @returns true if the glow layer should be rendered
  57211. */
  57212. shouldRender(): boolean;
  57213. /**
  57214. * Returns true if the mesh should render, otherwise false.
  57215. * @param mesh The mesh to render
  57216. * @returns true if it should render otherwise false
  57217. */
  57218. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57219. /**
  57220. * Returns true if the mesh can be rendered, otherwise false.
  57221. * @param mesh The mesh to render
  57222. * @param material The material used on the mesh
  57223. * @returns true if it can be rendered otherwise false
  57224. */
  57225. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57226. /**
  57227. * Returns true if the mesh should render, otherwise false.
  57228. * @param mesh The mesh to render
  57229. * @returns true if it should render otherwise false
  57230. */
  57231. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57232. /**
  57233. * Renders the submesh passed in parameter to the generation map.
  57234. */
  57235. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57236. /**
  57237. * Defines whether the current material of the mesh should be use to render the effect.
  57238. * @param mesh defines the current mesh to render
  57239. */
  57240. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57241. /**
  57242. * Rebuild the required buffers.
  57243. * @hidden Internal use only.
  57244. */
  57245. _rebuild(): void;
  57246. /**
  57247. * Dispose only the render target textures and post process.
  57248. */
  57249. private _disposeTextureAndPostProcesses;
  57250. /**
  57251. * Dispose the highlight layer and free resources.
  57252. */
  57253. dispose(): void;
  57254. /**
  57255. * Gets the class name of the effect layer
  57256. * @returns the string with the class name of the effect layer
  57257. */
  57258. getClassName(): string;
  57259. /**
  57260. * Creates an effect layer from parsed effect layer data
  57261. * @param parsedEffectLayer defines effect layer data
  57262. * @param scene defines the current scene
  57263. * @param rootUrl defines the root URL containing the effect layer information
  57264. * @returns a parsed effect Layer
  57265. */
  57266. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57267. }
  57268. }
  57269. declare module BABYLON {
  57270. interface AbstractScene {
  57271. /**
  57272. * The list of effect layers (highlights/glow) added to the scene
  57273. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57274. * @see https://doc.babylonjs.com/how_to/glow_layer
  57275. */
  57276. effectLayers: Array<EffectLayer>;
  57277. /**
  57278. * Removes the given effect layer from this scene.
  57279. * @param toRemove defines the effect layer to remove
  57280. * @returns the index of the removed effect layer
  57281. */
  57282. removeEffectLayer(toRemove: EffectLayer): number;
  57283. /**
  57284. * Adds the given effect layer to this scene
  57285. * @param newEffectLayer defines the effect layer to add
  57286. */
  57287. addEffectLayer(newEffectLayer: EffectLayer): void;
  57288. }
  57289. /**
  57290. * Defines the layer scene component responsible to manage any effect layers
  57291. * in a given scene.
  57292. */
  57293. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57294. /**
  57295. * The component name helpfull to identify the component in the list of scene components.
  57296. */
  57297. readonly name: string;
  57298. /**
  57299. * The scene the component belongs to.
  57300. */
  57301. scene: Scene;
  57302. private _engine;
  57303. private _renderEffects;
  57304. private _needStencil;
  57305. private _previousStencilState;
  57306. /**
  57307. * Creates a new instance of the component for the given scene
  57308. * @param scene Defines the scene to register the component in
  57309. */
  57310. constructor(scene: Scene);
  57311. /**
  57312. * Registers the component in a given scene
  57313. */
  57314. register(): void;
  57315. /**
  57316. * Rebuilds the elements related to this component in case of
  57317. * context lost for instance.
  57318. */
  57319. rebuild(): void;
  57320. /**
  57321. * Serializes the component data to the specified json object
  57322. * @param serializationObject The object to serialize to
  57323. */
  57324. serialize(serializationObject: any): void;
  57325. /**
  57326. * Adds all the elements from the container to the scene
  57327. * @param container the container holding the elements
  57328. */
  57329. addFromContainer(container: AbstractScene): void;
  57330. /**
  57331. * Removes all the elements in the container from the scene
  57332. * @param container contains the elements to remove
  57333. * @param dispose if the removed element should be disposed (default: false)
  57334. */
  57335. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57336. /**
  57337. * Disposes the component and the associated ressources.
  57338. */
  57339. dispose(): void;
  57340. private _isReadyForMesh;
  57341. private _renderMainTexture;
  57342. private _setStencil;
  57343. private _setStencilBack;
  57344. private _draw;
  57345. private _drawCamera;
  57346. private _drawRenderingGroup;
  57347. }
  57348. }
  57349. declare module BABYLON {
  57350. /** @hidden */
  57351. export var glowMapMergePixelShader: {
  57352. name: string;
  57353. shader: string;
  57354. };
  57355. }
  57356. declare module BABYLON {
  57357. /** @hidden */
  57358. export var glowMapMergeVertexShader: {
  57359. name: string;
  57360. shader: string;
  57361. };
  57362. }
  57363. declare module BABYLON {
  57364. interface AbstractScene {
  57365. /**
  57366. * Return a the first highlight layer of the scene with a given name.
  57367. * @param name The name of the highlight layer to look for.
  57368. * @return The highlight layer if found otherwise null.
  57369. */
  57370. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57371. }
  57372. /**
  57373. * Glow layer options. This helps customizing the behaviour
  57374. * of the glow layer.
  57375. */
  57376. export interface IGlowLayerOptions {
  57377. /**
  57378. * Multiplication factor apply to the canvas size to compute the render target size
  57379. * used to generated the glowing objects (the smaller the faster).
  57380. */
  57381. mainTextureRatio: number;
  57382. /**
  57383. * Enforces a fixed size texture to ensure resize independant blur.
  57384. */
  57385. mainTextureFixedSize?: number;
  57386. /**
  57387. * How big is the kernel of the blur texture.
  57388. */
  57389. blurKernelSize: number;
  57390. /**
  57391. * The camera attached to the layer.
  57392. */
  57393. camera: Nullable<Camera>;
  57394. /**
  57395. * Enable MSAA by chosing the number of samples.
  57396. */
  57397. mainTextureSamples?: number;
  57398. /**
  57399. * The rendering group to draw the layer in.
  57400. */
  57401. renderingGroupId: number;
  57402. }
  57403. /**
  57404. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57405. *
  57406. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57407. *
  57408. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57409. */
  57410. export class GlowLayer extends EffectLayer {
  57411. /**
  57412. * Effect Name of the layer.
  57413. */
  57414. static readonly EffectName: string;
  57415. /**
  57416. * The default blur kernel size used for the glow.
  57417. */
  57418. static DefaultBlurKernelSize: number;
  57419. /**
  57420. * The default texture size ratio used for the glow.
  57421. */
  57422. static DefaultTextureRatio: number;
  57423. /**
  57424. * Sets the kernel size of the blur.
  57425. */
  57426. set blurKernelSize(value: number);
  57427. /**
  57428. * Gets the kernel size of the blur.
  57429. */
  57430. get blurKernelSize(): number;
  57431. /**
  57432. * Sets the glow intensity.
  57433. */
  57434. set intensity(value: number);
  57435. /**
  57436. * Gets the glow intensity.
  57437. */
  57438. get intensity(): number;
  57439. private _options;
  57440. private _intensity;
  57441. private _horizontalBlurPostprocess1;
  57442. private _verticalBlurPostprocess1;
  57443. private _horizontalBlurPostprocess2;
  57444. private _verticalBlurPostprocess2;
  57445. private _blurTexture1;
  57446. private _blurTexture2;
  57447. private _postProcesses1;
  57448. private _postProcesses2;
  57449. private _includedOnlyMeshes;
  57450. private _excludedMeshes;
  57451. private _meshesUsingTheirOwnMaterials;
  57452. /**
  57453. * Callback used to let the user override the color selection on a per mesh basis
  57454. */
  57455. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57456. /**
  57457. * Callback used to let the user override the texture selection on a per mesh basis
  57458. */
  57459. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57460. /**
  57461. * Instantiates a new glow Layer and references it to the scene.
  57462. * @param name The name of the layer
  57463. * @param scene The scene to use the layer in
  57464. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57465. */
  57466. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57467. /**
  57468. * Get the effect name of the layer.
  57469. * @return The effect name
  57470. */
  57471. getEffectName(): string;
  57472. /**
  57473. * Create the merge effect. This is the shader use to blit the information back
  57474. * to the main canvas at the end of the scene rendering.
  57475. */
  57476. protected _createMergeEffect(): Effect;
  57477. /**
  57478. * Creates the render target textures and post processes used in the glow layer.
  57479. */
  57480. protected _createTextureAndPostProcesses(): void;
  57481. /**
  57482. * Checks for the readiness of the element composing the layer.
  57483. * @param subMesh the mesh to check for
  57484. * @param useInstances specify wether or not to use instances to render the mesh
  57485. * @param emissiveTexture the associated emissive texture used to generate the glow
  57486. * @return true if ready otherwise, false
  57487. */
  57488. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57489. /**
  57490. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57491. */
  57492. needStencil(): boolean;
  57493. /**
  57494. * Returns true if the mesh can be rendered, otherwise false.
  57495. * @param mesh The mesh to render
  57496. * @param material The material used on the mesh
  57497. * @returns true if it can be rendered otherwise false
  57498. */
  57499. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57500. /**
  57501. * Implementation specific of rendering the generating effect on the main canvas.
  57502. * @param effect The effect used to render through
  57503. */
  57504. protected _internalRender(effect: Effect): void;
  57505. /**
  57506. * Sets the required values for both the emissive texture and and the main color.
  57507. */
  57508. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57509. /**
  57510. * Returns true if the mesh should render, otherwise false.
  57511. * @param mesh The mesh to render
  57512. * @returns true if it should render otherwise false
  57513. */
  57514. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57515. /**
  57516. * Adds specific effects defines.
  57517. * @param defines The defines to add specifics to.
  57518. */
  57519. protected _addCustomEffectDefines(defines: string[]): void;
  57520. /**
  57521. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57522. * @param mesh The mesh to exclude from the glow layer
  57523. */
  57524. addExcludedMesh(mesh: Mesh): void;
  57525. /**
  57526. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57527. * @param mesh The mesh to remove
  57528. */
  57529. removeExcludedMesh(mesh: Mesh): void;
  57530. /**
  57531. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57532. * @param mesh The mesh to include in the glow layer
  57533. */
  57534. addIncludedOnlyMesh(mesh: Mesh): void;
  57535. /**
  57536. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57537. * @param mesh The mesh to remove
  57538. */
  57539. removeIncludedOnlyMesh(mesh: Mesh): void;
  57540. /**
  57541. * Determine if a given mesh will be used in the glow layer
  57542. * @param mesh The mesh to test
  57543. * @returns true if the mesh will be highlighted by the current glow layer
  57544. */
  57545. hasMesh(mesh: AbstractMesh): boolean;
  57546. /**
  57547. * Defines whether the current material of the mesh should be use to render the effect.
  57548. * @param mesh defines the current mesh to render
  57549. */
  57550. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57551. /**
  57552. * Add a mesh to be rendered through its own material and not with emissive only.
  57553. * @param mesh The mesh for which we need to use its material
  57554. */
  57555. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57556. /**
  57557. * Remove a mesh from being rendered through its own material and not with emissive only.
  57558. * @param mesh The mesh for which we need to not use its material
  57559. */
  57560. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57561. /**
  57562. * Free any resources and references associated to a mesh.
  57563. * Internal use
  57564. * @param mesh The mesh to free.
  57565. * @hidden
  57566. */
  57567. _disposeMesh(mesh: Mesh): void;
  57568. /**
  57569. * Gets the class name of the effect layer
  57570. * @returns the string with the class name of the effect layer
  57571. */
  57572. getClassName(): string;
  57573. /**
  57574. * Serializes this glow layer
  57575. * @returns a serialized glow layer object
  57576. */
  57577. serialize(): any;
  57578. /**
  57579. * Creates a Glow Layer from parsed glow layer data
  57580. * @param parsedGlowLayer defines glow layer data
  57581. * @param scene defines the current scene
  57582. * @param rootUrl defines the root URL containing the glow layer information
  57583. * @returns a parsed Glow Layer
  57584. */
  57585. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57586. }
  57587. }
  57588. declare module BABYLON {
  57589. /** @hidden */
  57590. export var glowBlurPostProcessPixelShader: {
  57591. name: string;
  57592. shader: string;
  57593. };
  57594. }
  57595. declare module BABYLON {
  57596. interface AbstractScene {
  57597. /**
  57598. * Return a the first highlight layer of the scene with a given name.
  57599. * @param name The name of the highlight layer to look for.
  57600. * @return The highlight layer if found otherwise null.
  57601. */
  57602. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57603. }
  57604. /**
  57605. * Highlight layer options. This helps customizing the behaviour
  57606. * of the highlight layer.
  57607. */
  57608. export interface IHighlightLayerOptions {
  57609. /**
  57610. * Multiplication factor apply to the canvas size to compute the render target size
  57611. * used to generated the glowing objects (the smaller the faster).
  57612. */
  57613. mainTextureRatio: number;
  57614. /**
  57615. * Enforces a fixed size texture to ensure resize independant blur.
  57616. */
  57617. mainTextureFixedSize?: number;
  57618. /**
  57619. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57620. * of the picture to blur (the smaller the faster).
  57621. */
  57622. blurTextureSizeRatio: number;
  57623. /**
  57624. * How big in texel of the blur texture is the vertical blur.
  57625. */
  57626. blurVerticalSize: number;
  57627. /**
  57628. * How big in texel of the blur texture is the horizontal blur.
  57629. */
  57630. blurHorizontalSize: number;
  57631. /**
  57632. * Alpha blending mode used to apply the blur. Default is combine.
  57633. */
  57634. alphaBlendingMode: number;
  57635. /**
  57636. * The camera attached to the layer.
  57637. */
  57638. camera: Nullable<Camera>;
  57639. /**
  57640. * Should we display highlight as a solid stroke?
  57641. */
  57642. isStroke?: boolean;
  57643. /**
  57644. * The rendering group to draw the layer in.
  57645. */
  57646. renderingGroupId: number;
  57647. }
  57648. /**
  57649. * The highlight layer Helps adding a glow effect around a mesh.
  57650. *
  57651. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57652. * glowy meshes to your scene.
  57653. *
  57654. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57655. */
  57656. export class HighlightLayer extends EffectLayer {
  57657. name: string;
  57658. /**
  57659. * Effect Name of the highlight layer.
  57660. */
  57661. static readonly EffectName: string;
  57662. /**
  57663. * The neutral color used during the preparation of the glow effect.
  57664. * This is black by default as the blend operation is a blend operation.
  57665. */
  57666. static NeutralColor: Color4;
  57667. /**
  57668. * Stencil value used for glowing meshes.
  57669. */
  57670. static GlowingMeshStencilReference: number;
  57671. /**
  57672. * Stencil value used for the other meshes in the scene.
  57673. */
  57674. static NormalMeshStencilReference: number;
  57675. /**
  57676. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57677. */
  57678. innerGlow: boolean;
  57679. /**
  57680. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57681. */
  57682. outerGlow: boolean;
  57683. /**
  57684. * Specifies the horizontal size of the blur.
  57685. */
  57686. set blurHorizontalSize(value: number);
  57687. /**
  57688. * Specifies the vertical size of the blur.
  57689. */
  57690. set blurVerticalSize(value: number);
  57691. /**
  57692. * Gets the horizontal size of the blur.
  57693. */
  57694. get blurHorizontalSize(): number;
  57695. /**
  57696. * Gets the vertical size of the blur.
  57697. */
  57698. get blurVerticalSize(): number;
  57699. /**
  57700. * An event triggered when the highlight layer is being blurred.
  57701. */
  57702. onBeforeBlurObservable: Observable<HighlightLayer>;
  57703. /**
  57704. * An event triggered when the highlight layer has been blurred.
  57705. */
  57706. onAfterBlurObservable: Observable<HighlightLayer>;
  57707. private _instanceGlowingMeshStencilReference;
  57708. private _options;
  57709. private _downSamplePostprocess;
  57710. private _horizontalBlurPostprocess;
  57711. private _verticalBlurPostprocess;
  57712. private _blurTexture;
  57713. private _meshes;
  57714. private _excludedMeshes;
  57715. /**
  57716. * Instantiates a new highlight Layer and references it to the scene..
  57717. * @param name The name of the layer
  57718. * @param scene The scene to use the layer in
  57719. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57720. */
  57721. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57722. /**
  57723. * Get the effect name of the layer.
  57724. * @return The effect name
  57725. */
  57726. getEffectName(): string;
  57727. /**
  57728. * Create the merge effect. This is the shader use to blit the information back
  57729. * to the main canvas at the end of the scene rendering.
  57730. */
  57731. protected _createMergeEffect(): Effect;
  57732. /**
  57733. * Creates the render target textures and post processes used in the highlight layer.
  57734. */
  57735. protected _createTextureAndPostProcesses(): void;
  57736. /**
  57737. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57738. */
  57739. needStencil(): boolean;
  57740. /**
  57741. * Checks for the readiness of the element composing the layer.
  57742. * @param subMesh the mesh to check for
  57743. * @param useInstances specify wether or not to use instances to render the mesh
  57744. * @param emissiveTexture the associated emissive texture used to generate the glow
  57745. * @return true if ready otherwise, false
  57746. */
  57747. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57748. /**
  57749. * Implementation specific of rendering the generating effect on the main canvas.
  57750. * @param effect The effect used to render through
  57751. */
  57752. protected _internalRender(effect: Effect): void;
  57753. /**
  57754. * Returns true if the layer contains information to display, otherwise false.
  57755. */
  57756. shouldRender(): boolean;
  57757. /**
  57758. * Returns true if the mesh should render, otherwise false.
  57759. * @param mesh The mesh to render
  57760. * @returns true if it should render otherwise false
  57761. */
  57762. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57763. /**
  57764. * Returns true if the mesh can be rendered, otherwise false.
  57765. * @param mesh The mesh to render
  57766. * @param material The material used on the mesh
  57767. * @returns true if it can be rendered otherwise false
  57768. */
  57769. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57770. /**
  57771. * Adds specific effects defines.
  57772. * @param defines The defines to add specifics to.
  57773. */
  57774. protected _addCustomEffectDefines(defines: string[]): void;
  57775. /**
  57776. * Sets the required values for both the emissive texture and and the main color.
  57777. */
  57778. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57779. /**
  57780. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57781. * @param mesh The mesh to exclude from the highlight layer
  57782. */
  57783. addExcludedMesh(mesh: Mesh): void;
  57784. /**
  57785. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57786. * @param mesh The mesh to highlight
  57787. */
  57788. removeExcludedMesh(mesh: Mesh): void;
  57789. /**
  57790. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57791. * @param mesh mesh to test
  57792. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57793. */
  57794. hasMesh(mesh: AbstractMesh): boolean;
  57795. /**
  57796. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57797. * @param mesh The mesh to highlight
  57798. * @param color The color of the highlight
  57799. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57800. */
  57801. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57802. /**
  57803. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57804. * @param mesh The mesh to highlight
  57805. */
  57806. removeMesh(mesh: Mesh): void;
  57807. /**
  57808. * Remove all the meshes currently referenced in the highlight layer
  57809. */
  57810. removeAllMeshes(): void;
  57811. /**
  57812. * Force the stencil to the normal expected value for none glowing parts
  57813. */
  57814. private _defaultStencilReference;
  57815. /**
  57816. * Free any resources and references associated to a mesh.
  57817. * Internal use
  57818. * @param mesh The mesh to free.
  57819. * @hidden
  57820. */
  57821. _disposeMesh(mesh: Mesh): void;
  57822. /**
  57823. * Dispose the highlight layer and free resources.
  57824. */
  57825. dispose(): void;
  57826. /**
  57827. * Gets the class name of the effect layer
  57828. * @returns the string with the class name of the effect layer
  57829. */
  57830. getClassName(): string;
  57831. /**
  57832. * Serializes this Highlight layer
  57833. * @returns a serialized Highlight layer object
  57834. */
  57835. serialize(): any;
  57836. /**
  57837. * Creates a Highlight layer from parsed Highlight layer data
  57838. * @param parsedHightlightLayer defines the Highlight layer data
  57839. * @param scene defines the current scene
  57840. * @param rootUrl defines the root URL containing the Highlight layer information
  57841. * @returns a parsed Highlight layer
  57842. */
  57843. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57844. }
  57845. }
  57846. declare module BABYLON {
  57847. interface AbstractScene {
  57848. /**
  57849. * The list of layers (background and foreground) of the scene
  57850. */
  57851. layers: Array<Layer>;
  57852. }
  57853. /**
  57854. * Defines the layer scene component responsible to manage any layers
  57855. * in a given scene.
  57856. */
  57857. export class LayerSceneComponent implements ISceneComponent {
  57858. /**
  57859. * The component name helpfull to identify the component in the list of scene components.
  57860. */
  57861. readonly name: string;
  57862. /**
  57863. * The scene the component belongs to.
  57864. */
  57865. scene: Scene;
  57866. private _engine;
  57867. /**
  57868. * Creates a new instance of the component for the given scene
  57869. * @param scene Defines the scene to register the component in
  57870. */
  57871. constructor(scene: Scene);
  57872. /**
  57873. * Registers the component in a given scene
  57874. */
  57875. register(): void;
  57876. /**
  57877. * Rebuilds the elements related to this component in case of
  57878. * context lost for instance.
  57879. */
  57880. rebuild(): void;
  57881. /**
  57882. * Disposes the component and the associated ressources.
  57883. */
  57884. dispose(): void;
  57885. private _draw;
  57886. private _drawCameraPredicate;
  57887. private _drawCameraBackground;
  57888. private _drawCameraForeground;
  57889. private _drawRenderTargetPredicate;
  57890. private _drawRenderTargetBackground;
  57891. private _drawRenderTargetForeground;
  57892. /**
  57893. * Adds all the elements from the container to the scene
  57894. * @param container the container holding the elements
  57895. */
  57896. addFromContainer(container: AbstractScene): void;
  57897. /**
  57898. * Removes all the elements in the container from the scene
  57899. * @param container contains the elements to remove
  57900. * @param dispose if the removed element should be disposed (default: false)
  57901. */
  57902. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57903. }
  57904. }
  57905. declare module BABYLON {
  57906. /** @hidden */
  57907. export var layerPixelShader: {
  57908. name: string;
  57909. shader: string;
  57910. };
  57911. }
  57912. declare module BABYLON {
  57913. /** @hidden */
  57914. export var layerVertexShader: {
  57915. name: string;
  57916. shader: string;
  57917. };
  57918. }
  57919. declare module BABYLON {
  57920. /**
  57921. * This represents a full screen 2d layer.
  57922. * This can be useful to display a picture in the background of your scene for instance.
  57923. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57924. */
  57925. export class Layer {
  57926. /**
  57927. * Define the name of the layer.
  57928. */
  57929. name: string;
  57930. /**
  57931. * Define the texture the layer should display.
  57932. */
  57933. texture: Nullable<Texture>;
  57934. /**
  57935. * Is the layer in background or foreground.
  57936. */
  57937. isBackground: boolean;
  57938. /**
  57939. * Define the color of the layer (instead of texture).
  57940. */
  57941. color: Color4;
  57942. /**
  57943. * Define the scale of the layer in order to zoom in out of the texture.
  57944. */
  57945. scale: Vector2;
  57946. /**
  57947. * Define an offset for the layer in order to shift the texture.
  57948. */
  57949. offset: Vector2;
  57950. /**
  57951. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57952. */
  57953. alphaBlendingMode: number;
  57954. /**
  57955. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57956. * Alpha test will not mix with the background color in case of transparency.
  57957. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57958. */
  57959. alphaTest: boolean;
  57960. /**
  57961. * Define a mask to restrict the layer to only some of the scene cameras.
  57962. */
  57963. layerMask: number;
  57964. /**
  57965. * Define the list of render target the layer is visible into.
  57966. */
  57967. renderTargetTextures: RenderTargetTexture[];
  57968. /**
  57969. * Define if the layer is only used in renderTarget or if it also
  57970. * renders in the main frame buffer of the canvas.
  57971. */
  57972. renderOnlyInRenderTargetTextures: boolean;
  57973. private _scene;
  57974. private _vertexBuffers;
  57975. private _indexBuffer;
  57976. private _effect;
  57977. private _previousDefines;
  57978. /**
  57979. * An event triggered when the layer is disposed.
  57980. */
  57981. onDisposeObservable: Observable<Layer>;
  57982. private _onDisposeObserver;
  57983. /**
  57984. * Back compatibility with callback before the onDisposeObservable existed.
  57985. * The set callback will be triggered when the layer has been disposed.
  57986. */
  57987. set onDispose(callback: () => void);
  57988. /**
  57989. * An event triggered before rendering the scene
  57990. */
  57991. onBeforeRenderObservable: Observable<Layer>;
  57992. private _onBeforeRenderObserver;
  57993. /**
  57994. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57995. * The set callback will be triggered just before rendering the layer.
  57996. */
  57997. set onBeforeRender(callback: () => void);
  57998. /**
  57999. * An event triggered after rendering the scene
  58000. */
  58001. onAfterRenderObservable: Observable<Layer>;
  58002. private _onAfterRenderObserver;
  58003. /**
  58004. * Back compatibility with callback before the onAfterRenderObservable existed.
  58005. * The set callback will be triggered just after rendering the layer.
  58006. */
  58007. set onAfterRender(callback: () => void);
  58008. /**
  58009. * Instantiates a new layer.
  58010. * This represents a full screen 2d layer.
  58011. * This can be useful to display a picture in the background of your scene for instance.
  58012. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58013. * @param name Define the name of the layer in the scene
  58014. * @param imgUrl Define the url of the texture to display in the layer
  58015. * @param scene Define the scene the layer belongs to
  58016. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58017. * @param color Defines a color for the layer
  58018. */
  58019. constructor(
  58020. /**
  58021. * Define the name of the layer.
  58022. */
  58023. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58024. private _createIndexBuffer;
  58025. /** @hidden */
  58026. _rebuild(): void;
  58027. /**
  58028. * Renders the layer in the scene.
  58029. */
  58030. render(): void;
  58031. /**
  58032. * Disposes and releases the associated ressources.
  58033. */
  58034. dispose(): void;
  58035. }
  58036. }
  58037. declare module BABYLON {
  58038. /** @hidden */
  58039. export var lensFlarePixelShader: {
  58040. name: string;
  58041. shader: string;
  58042. };
  58043. }
  58044. declare module BABYLON {
  58045. /** @hidden */
  58046. export var lensFlareVertexShader: {
  58047. name: string;
  58048. shader: string;
  58049. };
  58050. }
  58051. declare module BABYLON {
  58052. /**
  58053. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58054. * It is usually composed of several `lensFlare`.
  58055. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58056. */
  58057. export class LensFlareSystem {
  58058. /**
  58059. * Define the name of the lens flare system
  58060. */
  58061. name: string;
  58062. /**
  58063. * List of lens flares used in this system.
  58064. */
  58065. lensFlares: LensFlare[];
  58066. /**
  58067. * Define a limit from the border the lens flare can be visible.
  58068. */
  58069. borderLimit: number;
  58070. /**
  58071. * Define a viewport border we do not want to see the lens flare in.
  58072. */
  58073. viewportBorder: number;
  58074. /**
  58075. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58076. */
  58077. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58078. /**
  58079. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58080. */
  58081. layerMask: number;
  58082. /**
  58083. * Define the id of the lens flare system in the scene.
  58084. * (equal to name by default)
  58085. */
  58086. id: string;
  58087. private _scene;
  58088. private _emitter;
  58089. private _vertexBuffers;
  58090. private _indexBuffer;
  58091. private _effect;
  58092. private _positionX;
  58093. private _positionY;
  58094. private _isEnabled;
  58095. /** @hidden */
  58096. static _SceneComponentInitialization: (scene: Scene) => void;
  58097. /**
  58098. * Instantiates a lens flare system.
  58099. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58100. * It is usually composed of several `lensFlare`.
  58101. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58102. * @param name Define the name of the lens flare system in the scene
  58103. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58104. * @param scene Define the scene the lens flare system belongs to
  58105. */
  58106. constructor(
  58107. /**
  58108. * Define the name of the lens flare system
  58109. */
  58110. name: string, emitter: any, scene: Scene);
  58111. /**
  58112. * Define if the lens flare system is enabled.
  58113. */
  58114. get isEnabled(): boolean;
  58115. set isEnabled(value: boolean);
  58116. /**
  58117. * Get the scene the effects belongs to.
  58118. * @returns the scene holding the lens flare system
  58119. */
  58120. getScene(): Scene;
  58121. /**
  58122. * Get the emitter of the lens flare system.
  58123. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58124. * @returns the emitter of the lens flare system
  58125. */
  58126. getEmitter(): any;
  58127. /**
  58128. * Set 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. * @param newEmitter Define the new emitter of the system
  58131. */
  58132. setEmitter(newEmitter: any): void;
  58133. /**
  58134. * Get the lens flare system emitter position.
  58135. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58136. * @returns the position
  58137. */
  58138. getEmitterPosition(): Vector3;
  58139. /**
  58140. * @hidden
  58141. */
  58142. computeEffectivePosition(globalViewport: Viewport): boolean;
  58143. /** @hidden */
  58144. _isVisible(): boolean;
  58145. /**
  58146. * @hidden
  58147. */
  58148. render(): boolean;
  58149. /**
  58150. * Dispose and release the lens flare with its associated resources.
  58151. */
  58152. dispose(): void;
  58153. /**
  58154. * Parse a lens flare system from a JSON repressentation
  58155. * @param parsedLensFlareSystem Define the JSON to parse
  58156. * @param scene Define the scene the parsed system should be instantiated in
  58157. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58158. * @returns the parsed system
  58159. */
  58160. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58161. /**
  58162. * Serialize the current Lens Flare System into a JSON representation.
  58163. * @returns the serialized JSON
  58164. */
  58165. serialize(): any;
  58166. }
  58167. }
  58168. declare module BABYLON {
  58169. /**
  58170. * This represents one of the lens effect in a `lensFlareSystem`.
  58171. * It controls one of the indiviual texture used in the effect.
  58172. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58173. */
  58174. export class LensFlare {
  58175. /**
  58176. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58177. */
  58178. size: number;
  58179. /**
  58180. * 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.
  58181. */
  58182. position: number;
  58183. /**
  58184. * Define the lens color.
  58185. */
  58186. color: Color3;
  58187. /**
  58188. * Define the lens texture.
  58189. */
  58190. texture: Nullable<Texture>;
  58191. /**
  58192. * Define the alpha mode to render this particular lens.
  58193. */
  58194. alphaMode: number;
  58195. private _system;
  58196. /**
  58197. * Creates a new Lens Flare.
  58198. * This represents one of the lens effect in a `lensFlareSystem`.
  58199. * It controls one of the indiviual texture used in the effect.
  58200. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58201. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58202. * @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.
  58203. * @param color Define the lens color
  58204. * @param imgUrl Define the lens texture url
  58205. * @param system Define the `lensFlareSystem` this flare is part of
  58206. * @returns The newly created Lens Flare
  58207. */
  58208. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58209. /**
  58210. * Instantiates a new Lens Flare.
  58211. * This represents one of the lens effect in a `lensFlareSystem`.
  58212. * It controls one of the indiviual texture used in the effect.
  58213. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58214. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58215. * @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.
  58216. * @param color Define the lens color
  58217. * @param imgUrl Define the lens texture url
  58218. * @param system Define the `lensFlareSystem` this flare is part of
  58219. */
  58220. constructor(
  58221. /**
  58222. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58223. */
  58224. size: number,
  58225. /**
  58226. * 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.
  58227. */
  58228. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58229. /**
  58230. * Dispose and release the lens flare with its associated resources.
  58231. */
  58232. dispose(): void;
  58233. }
  58234. }
  58235. declare module BABYLON {
  58236. interface AbstractScene {
  58237. /**
  58238. * The list of lens flare system added to the scene
  58239. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58240. */
  58241. lensFlareSystems: Array<LensFlareSystem>;
  58242. /**
  58243. * Removes the given lens flare system from this scene.
  58244. * @param toRemove The lens flare system to remove
  58245. * @returns The index of the removed lens flare system
  58246. */
  58247. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58248. /**
  58249. * Adds the given lens flare system to this scene
  58250. * @param newLensFlareSystem The lens flare system to add
  58251. */
  58252. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58253. /**
  58254. * Gets a lens flare system using its name
  58255. * @param name defines the name to look for
  58256. * @returns the lens flare system or null if not found
  58257. */
  58258. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58259. /**
  58260. * Gets a lens flare system using its id
  58261. * @param id defines the id to look for
  58262. * @returns the lens flare system or null if not found
  58263. */
  58264. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58265. }
  58266. /**
  58267. * Defines the lens flare scene component responsible to manage any lens flares
  58268. * in a given scene.
  58269. */
  58270. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58271. /**
  58272. * The component name helpfull to identify the component in the list of scene components.
  58273. */
  58274. readonly name: string;
  58275. /**
  58276. * The scene the component belongs to.
  58277. */
  58278. scene: Scene;
  58279. /**
  58280. * Creates a new instance of the component for the given scene
  58281. * @param scene Defines the scene to register the component in
  58282. */
  58283. constructor(scene: Scene);
  58284. /**
  58285. * Registers the component in a given scene
  58286. */
  58287. register(): void;
  58288. /**
  58289. * Rebuilds the elements related to this component in case of
  58290. * context lost for instance.
  58291. */
  58292. rebuild(): void;
  58293. /**
  58294. * Adds all the elements from the container to the scene
  58295. * @param container the container holding the elements
  58296. */
  58297. addFromContainer(container: AbstractScene): void;
  58298. /**
  58299. * Removes all the elements in the container from the scene
  58300. * @param container contains the elements to remove
  58301. * @param dispose if the removed element should be disposed (default: false)
  58302. */
  58303. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58304. /**
  58305. * Serializes the component data to the specified json object
  58306. * @param serializationObject The object to serialize to
  58307. */
  58308. serialize(serializationObject: any): void;
  58309. /**
  58310. * Disposes the component and the associated ressources.
  58311. */
  58312. dispose(): void;
  58313. private _draw;
  58314. }
  58315. }
  58316. declare module BABYLON {
  58317. /** @hidden */
  58318. export var depthPixelShader: {
  58319. name: string;
  58320. shader: string;
  58321. };
  58322. }
  58323. declare module BABYLON {
  58324. /** @hidden */
  58325. export var depthVertexShader: {
  58326. name: string;
  58327. shader: string;
  58328. };
  58329. }
  58330. declare module BABYLON {
  58331. /**
  58332. * This represents a depth renderer in Babylon.
  58333. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58334. */
  58335. export class DepthRenderer {
  58336. private _scene;
  58337. private _depthMap;
  58338. private _effect;
  58339. private readonly _storeNonLinearDepth;
  58340. private readonly _clearColor;
  58341. /** Get if the depth renderer is using packed depth or not */
  58342. readonly isPacked: boolean;
  58343. private _cachedDefines;
  58344. private _camera;
  58345. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58346. enabled: boolean;
  58347. /**
  58348. * Specifiess that the depth renderer will only be used within
  58349. * the camera it is created for.
  58350. * This can help forcing its rendering during the camera processing.
  58351. */
  58352. useOnlyInActiveCamera: boolean;
  58353. /** @hidden */
  58354. static _SceneComponentInitialization: (scene: Scene) => void;
  58355. /**
  58356. * Instantiates a depth renderer
  58357. * @param scene The scene the renderer belongs to
  58358. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58359. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58360. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58361. */
  58362. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58363. /**
  58364. * Creates the depth rendering effect and checks if the effect is ready.
  58365. * @param subMesh The submesh to be used to render the depth map of
  58366. * @param useInstances If multiple world instances should be used
  58367. * @returns if the depth renderer is ready to render the depth map
  58368. */
  58369. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58370. /**
  58371. * Gets the texture which the depth map will be written to.
  58372. * @returns The depth map texture
  58373. */
  58374. getDepthMap(): RenderTargetTexture;
  58375. /**
  58376. * Disposes of the depth renderer.
  58377. */
  58378. dispose(): void;
  58379. }
  58380. }
  58381. declare module BABYLON {
  58382. /** @hidden */
  58383. export var minmaxReduxPixelShader: {
  58384. name: string;
  58385. shader: string;
  58386. };
  58387. }
  58388. declare module BABYLON {
  58389. /**
  58390. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58391. * and maximum values from all values of the texture.
  58392. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58393. * The source values are read from the red channel of the texture.
  58394. */
  58395. export class MinMaxReducer {
  58396. /**
  58397. * Observable triggered when the computation has been performed
  58398. */
  58399. onAfterReductionPerformed: Observable<{
  58400. min: number;
  58401. max: number;
  58402. }>;
  58403. protected _camera: Camera;
  58404. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58405. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58406. protected _postProcessManager: PostProcessManager;
  58407. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58408. protected _forceFullscreenViewport: boolean;
  58409. /**
  58410. * Creates a min/max reducer
  58411. * @param camera The camera to use for the post processes
  58412. */
  58413. constructor(camera: Camera);
  58414. /**
  58415. * Gets the texture used to read the values from.
  58416. */
  58417. get sourceTexture(): Nullable<RenderTargetTexture>;
  58418. /**
  58419. * Sets the source texture to read the values from.
  58420. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58421. * because in such textures '1' value must not be taken into account to compute the maximum
  58422. * as this value is used to clear the texture.
  58423. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58424. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58425. * @param depthRedux Indicates if the texture is a depth texture or not
  58426. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58427. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58428. */
  58429. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58430. /**
  58431. * Defines the refresh rate of the computation.
  58432. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58433. */
  58434. get refreshRate(): number;
  58435. set refreshRate(value: number);
  58436. protected _activated: boolean;
  58437. /**
  58438. * Gets the activation status of the reducer
  58439. */
  58440. get activated(): boolean;
  58441. /**
  58442. * Activates the reduction computation.
  58443. * When activated, the observers registered in onAfterReductionPerformed are
  58444. * called after the compuation is performed
  58445. */
  58446. activate(): void;
  58447. /**
  58448. * Deactivates the reduction computation.
  58449. */
  58450. deactivate(): void;
  58451. /**
  58452. * Disposes the min/max reducer
  58453. * @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.
  58454. */
  58455. dispose(disposeAll?: boolean): void;
  58456. }
  58457. }
  58458. declare module BABYLON {
  58459. /**
  58460. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58461. */
  58462. export class DepthReducer extends MinMaxReducer {
  58463. private _depthRenderer;
  58464. private _depthRendererId;
  58465. /**
  58466. * Gets the depth renderer used for the computation.
  58467. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58468. */
  58469. get depthRenderer(): Nullable<DepthRenderer>;
  58470. /**
  58471. * Creates a depth reducer
  58472. * @param camera The camera used to render the depth texture
  58473. */
  58474. constructor(camera: Camera);
  58475. /**
  58476. * Sets the depth renderer to use to generate the depth map
  58477. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58478. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58479. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58480. */
  58481. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58482. /** @hidden */
  58483. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58484. /**
  58485. * Activates the reduction computation.
  58486. * When activated, the observers registered in onAfterReductionPerformed are
  58487. * called after the compuation is performed
  58488. */
  58489. activate(): void;
  58490. /**
  58491. * Deactivates the reduction computation.
  58492. */
  58493. deactivate(): void;
  58494. /**
  58495. * Disposes the depth reducer
  58496. * @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.
  58497. */
  58498. dispose(disposeAll?: boolean): void;
  58499. }
  58500. }
  58501. declare module BABYLON {
  58502. /**
  58503. * A CSM implementation allowing casting shadows on large scenes.
  58504. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58505. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58506. */
  58507. export class CascadedShadowGenerator extends ShadowGenerator {
  58508. private static readonly frustumCornersNDCSpace;
  58509. /**
  58510. * Name of the CSM class
  58511. */
  58512. static CLASSNAME: string;
  58513. /**
  58514. * Defines the default number of cascades used by the CSM.
  58515. */
  58516. static readonly DEFAULT_CASCADES_COUNT: number;
  58517. /**
  58518. * Defines the minimum number of cascades used by the CSM.
  58519. */
  58520. static readonly MIN_CASCADES_COUNT: number;
  58521. /**
  58522. * Defines the maximum number of cascades used by the CSM.
  58523. */
  58524. static readonly MAX_CASCADES_COUNT: number;
  58525. protected _validateFilter(filter: number): number;
  58526. /**
  58527. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58528. */
  58529. penumbraDarkness: number;
  58530. private _numCascades;
  58531. /**
  58532. * Gets or set the number of cascades used by the CSM.
  58533. */
  58534. get numCascades(): number;
  58535. set numCascades(value: number);
  58536. /**
  58537. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58538. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58539. */
  58540. stabilizeCascades: boolean;
  58541. private _freezeShadowCastersBoundingInfo;
  58542. private _freezeShadowCastersBoundingInfoObservable;
  58543. /**
  58544. * Enables or disables the shadow casters bounding info computation.
  58545. * If your shadow casters don't move, you can disable this feature.
  58546. * If it is enabled, the bounding box computation is done every frame.
  58547. */
  58548. get freezeShadowCastersBoundingInfo(): boolean;
  58549. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58550. private _scbiMin;
  58551. private _scbiMax;
  58552. protected _computeShadowCastersBoundingInfo(): void;
  58553. protected _shadowCastersBoundingInfo: BoundingInfo;
  58554. /**
  58555. * Gets or sets the shadow casters bounding info.
  58556. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58557. * so that the system won't overwrite the bounds you provide
  58558. */
  58559. get shadowCastersBoundingInfo(): BoundingInfo;
  58560. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58561. protected _breaksAreDirty: boolean;
  58562. protected _minDistance: number;
  58563. protected _maxDistance: number;
  58564. /**
  58565. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58566. *
  58567. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58568. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58569. * @param min minimal distance for the breaks (default to 0.)
  58570. * @param max maximal distance for the breaks (default to 1.)
  58571. */
  58572. setMinMaxDistance(min: number, max: number): void;
  58573. /** Gets the minimal distance used in the cascade break computation */
  58574. get minDistance(): number;
  58575. /** Gets the maximal distance used in the cascade break computation */
  58576. get maxDistance(): number;
  58577. /**
  58578. * Gets the class name of that object
  58579. * @returns "CascadedShadowGenerator"
  58580. */
  58581. getClassName(): string;
  58582. private _cascadeMinExtents;
  58583. private _cascadeMaxExtents;
  58584. /**
  58585. * Gets a cascade minimum extents
  58586. * @param cascadeIndex index of the cascade
  58587. * @returns the minimum cascade extents
  58588. */
  58589. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58590. /**
  58591. * Gets a cascade maximum extents
  58592. * @param cascadeIndex index of the cascade
  58593. * @returns the maximum cascade extents
  58594. */
  58595. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58596. private _cascades;
  58597. private _currentLayer;
  58598. private _viewSpaceFrustumsZ;
  58599. private _viewMatrices;
  58600. private _projectionMatrices;
  58601. private _transformMatrices;
  58602. private _transformMatricesAsArray;
  58603. private _frustumLengths;
  58604. private _lightSizeUVCorrection;
  58605. private _depthCorrection;
  58606. private _frustumCornersWorldSpace;
  58607. private _frustumCenter;
  58608. private _shadowCameraPos;
  58609. private _shadowMaxZ;
  58610. /**
  58611. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58612. * It defaults to camera.maxZ
  58613. */
  58614. get shadowMaxZ(): number;
  58615. /**
  58616. * Sets the shadow max z distance.
  58617. */
  58618. set shadowMaxZ(value: number);
  58619. protected _debug: boolean;
  58620. /**
  58621. * Gets or sets the debug flag.
  58622. * When enabled, the cascades are materialized by different colors on the screen.
  58623. */
  58624. get debug(): boolean;
  58625. set debug(dbg: boolean);
  58626. private _depthClamp;
  58627. /**
  58628. * Gets or sets the depth clamping value.
  58629. *
  58630. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58631. * to account for the shadow casters far away.
  58632. *
  58633. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58634. */
  58635. get depthClamp(): boolean;
  58636. set depthClamp(value: boolean);
  58637. private _cascadeBlendPercentage;
  58638. /**
  58639. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58640. * It defaults to 0.1 (10% blending).
  58641. */
  58642. get cascadeBlendPercentage(): number;
  58643. set cascadeBlendPercentage(value: number);
  58644. private _lambda;
  58645. /**
  58646. * Gets or set the lambda parameter.
  58647. * This parameter is used to split the camera frustum and create the cascades.
  58648. * 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.
  58649. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58650. */
  58651. get lambda(): number;
  58652. set lambda(value: number);
  58653. /**
  58654. * Gets the view matrix corresponding to a given cascade
  58655. * @param cascadeNum cascade to retrieve the view matrix from
  58656. * @returns the cascade view matrix
  58657. */
  58658. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58659. /**
  58660. * Gets the projection matrix corresponding to a given cascade
  58661. * @param cascadeNum cascade to retrieve the projection matrix from
  58662. * @returns the cascade projection matrix
  58663. */
  58664. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58665. /**
  58666. * Gets the transformation matrix corresponding to a given cascade
  58667. * @param cascadeNum cascade to retrieve the transformation matrix from
  58668. * @returns the cascade transformation matrix
  58669. */
  58670. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58671. private _depthRenderer;
  58672. /**
  58673. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58674. *
  58675. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58676. *
  58677. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58678. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58679. * @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
  58680. */
  58681. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58682. private _depthReducer;
  58683. private _autoCalcDepthBounds;
  58684. /**
  58685. * Gets or sets the autoCalcDepthBounds property.
  58686. *
  58687. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58688. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58689. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58690. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58691. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58692. */
  58693. get autoCalcDepthBounds(): boolean;
  58694. set autoCalcDepthBounds(value: boolean);
  58695. /**
  58696. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58697. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58698. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58699. * for setting the refresh rate on the renderer yourself!
  58700. */
  58701. get autoCalcDepthBoundsRefreshRate(): number;
  58702. set autoCalcDepthBoundsRefreshRate(value: number);
  58703. /**
  58704. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58705. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58706. * you change the camera near/far planes!
  58707. */
  58708. splitFrustum(): void;
  58709. private _splitFrustum;
  58710. private _computeMatrices;
  58711. private _computeFrustumInWorldSpace;
  58712. private _computeCascadeFrustum;
  58713. /**
  58714. * Support test.
  58715. */
  58716. static get IsSupported(): boolean;
  58717. /** @hidden */
  58718. static _SceneComponentInitialization: (scene: Scene) => void;
  58719. /**
  58720. * Creates a Cascaded Shadow Generator object.
  58721. * A ShadowGenerator is the required tool to use the shadows.
  58722. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58723. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58724. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58725. * @param light The directional light object generating the shadows.
  58726. * @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.
  58727. */
  58728. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58729. protected _initializeGenerator(): void;
  58730. protected _createTargetRenderTexture(): void;
  58731. protected _initializeShadowMap(): void;
  58732. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58733. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58734. /**
  58735. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58736. * @param defines Defines of the material we want to update
  58737. * @param lightIndex Index of the light in the enabled light list of the material
  58738. */
  58739. prepareDefines(defines: any, lightIndex: number): void;
  58740. /**
  58741. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58742. * defined in the generator but impacting the effect).
  58743. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58744. * @param effect The effect we are binfing the information for
  58745. */
  58746. bindShadowLight(lightIndex: string, effect: Effect): void;
  58747. /**
  58748. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58749. * (eq to view projection * shadow projection matrices)
  58750. * @returns The transform matrix used to create the shadow map
  58751. */
  58752. getTransformMatrix(): Matrix;
  58753. /**
  58754. * Disposes the ShadowGenerator.
  58755. * Returns nothing.
  58756. */
  58757. dispose(): void;
  58758. /**
  58759. * Serializes the shadow generator setup to a json object.
  58760. * @returns The serialized JSON object
  58761. */
  58762. serialize(): any;
  58763. /**
  58764. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58765. * @param parsedShadowGenerator The JSON object to parse
  58766. * @param scene The scene to create the shadow map for
  58767. * @returns The parsed shadow generator
  58768. */
  58769. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58770. }
  58771. }
  58772. declare module BABYLON {
  58773. /**
  58774. * Defines the shadow generator component responsible to manage any shadow generators
  58775. * in a given scene.
  58776. */
  58777. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58778. /**
  58779. * The component name helpfull to identify the component in the list of scene components.
  58780. */
  58781. readonly name: string;
  58782. /**
  58783. * The scene the component belongs to.
  58784. */
  58785. scene: Scene;
  58786. /**
  58787. * Creates a new instance of the component for the given scene
  58788. * @param scene Defines the scene to register the component in
  58789. */
  58790. constructor(scene: Scene);
  58791. /**
  58792. * Registers the component in a given scene
  58793. */
  58794. register(): void;
  58795. /**
  58796. * Rebuilds the elements related to this component in case of
  58797. * context lost for instance.
  58798. */
  58799. rebuild(): void;
  58800. /**
  58801. * Serializes the component data to the specified json object
  58802. * @param serializationObject The object to serialize to
  58803. */
  58804. serialize(serializationObject: any): void;
  58805. /**
  58806. * Adds all the elements from the container to the scene
  58807. * @param container the container holding the elements
  58808. */
  58809. addFromContainer(container: AbstractScene): void;
  58810. /**
  58811. * Removes all the elements in the container from the scene
  58812. * @param container contains the elements to remove
  58813. * @param dispose if the removed element should be disposed (default: false)
  58814. */
  58815. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58816. /**
  58817. * Rebuilds the elements related to this component in case of
  58818. * context lost for instance.
  58819. */
  58820. dispose(): void;
  58821. private _gatherRenderTargets;
  58822. }
  58823. }
  58824. declare module BABYLON {
  58825. /**
  58826. * A point light is a light defined by an unique point in world space.
  58827. * The light is emitted in every direction from this point.
  58828. * A good example of a point light is a standard light bulb.
  58829. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58830. */
  58831. export class PointLight extends ShadowLight {
  58832. private _shadowAngle;
  58833. /**
  58834. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58835. * This specifies what angle the shadow will use to be created.
  58836. *
  58837. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58838. */
  58839. get shadowAngle(): number;
  58840. /**
  58841. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58842. * This specifies what angle the shadow will use to be created.
  58843. *
  58844. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58845. */
  58846. set shadowAngle(value: number);
  58847. /**
  58848. * Gets the direction if it has been set.
  58849. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58850. */
  58851. get direction(): Vector3;
  58852. /**
  58853. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58854. */
  58855. set direction(value: Vector3);
  58856. /**
  58857. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58858. * A PointLight emits the light in every direction.
  58859. * It can cast shadows.
  58860. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58861. * ```javascript
  58862. * var pointLight = new PointLight("pl", camera.position, scene);
  58863. * ```
  58864. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58865. * @param name The light friendly name
  58866. * @param position The position of the point light in the scene
  58867. * @param scene The scene the lights belongs to
  58868. */
  58869. constructor(name: string, position: Vector3, scene: Scene);
  58870. /**
  58871. * Returns the string "PointLight"
  58872. * @returns the class name
  58873. */
  58874. getClassName(): string;
  58875. /**
  58876. * Returns the integer 0.
  58877. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58878. */
  58879. getTypeID(): number;
  58880. /**
  58881. * Specifies wether or not the shadowmap should be a cube texture.
  58882. * @returns true if the shadowmap needs to be a cube texture.
  58883. */
  58884. needCube(): boolean;
  58885. /**
  58886. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58887. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58888. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58889. */
  58890. getShadowDirection(faceIndex?: number): Vector3;
  58891. /**
  58892. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58893. * - fov = PI / 2
  58894. * - aspect ratio : 1.0
  58895. * - z-near and far equal to the active camera minZ and maxZ.
  58896. * Returns the PointLight.
  58897. */
  58898. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58899. protected _buildUniformLayout(): void;
  58900. /**
  58901. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58902. * @param effect The effect to update
  58903. * @param lightIndex The index of the light in the effect to update
  58904. * @returns The point light
  58905. */
  58906. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58907. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58908. /**
  58909. * Prepares the list of defines specific to the light type.
  58910. * @param defines the list of defines
  58911. * @param lightIndex defines the index of the light for the effect
  58912. */
  58913. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58914. }
  58915. }
  58916. declare module BABYLON {
  58917. /**
  58918. * Header information of HDR texture files.
  58919. */
  58920. export interface HDRInfo {
  58921. /**
  58922. * The height of the texture in pixels.
  58923. */
  58924. height: number;
  58925. /**
  58926. * The width of the texture in pixels.
  58927. */
  58928. width: number;
  58929. /**
  58930. * The index of the beginning of the data in the binary file.
  58931. */
  58932. dataPosition: number;
  58933. }
  58934. /**
  58935. * This groups tools to convert HDR texture to native colors array.
  58936. */
  58937. export class HDRTools {
  58938. private static Ldexp;
  58939. private static Rgbe2float;
  58940. private static readStringLine;
  58941. /**
  58942. * Reads header information from an RGBE texture stored in a native array.
  58943. * More information on this format are available here:
  58944. * https://en.wikipedia.org/wiki/RGBE_image_format
  58945. *
  58946. * @param uint8array The binary file stored in native array.
  58947. * @return The header information.
  58948. */
  58949. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58950. /**
  58951. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58952. * This RGBE texture needs to store the information as a panorama.
  58953. *
  58954. * More information on this format are available here:
  58955. * https://en.wikipedia.org/wiki/RGBE_image_format
  58956. *
  58957. * @param buffer The binary file stored in an array buffer.
  58958. * @param size The expected size of the extracted cubemap.
  58959. * @return The Cube Map information.
  58960. */
  58961. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58962. /**
  58963. * Returns the pixels data extracted from an RGBE texture.
  58964. * This pixels will be stored left to right up to down in the R G B order in one array.
  58965. *
  58966. * More information on this format are available here:
  58967. * https://en.wikipedia.org/wiki/RGBE_image_format
  58968. *
  58969. * @param uint8array The binary file stored in an array buffer.
  58970. * @param hdrInfo The header information of the file.
  58971. * @return The pixels data in RGB right to left up to down order.
  58972. */
  58973. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58974. private static RGBE_ReadPixels_RLE;
  58975. }
  58976. }
  58977. declare module BABYLON {
  58978. /**
  58979. * Effect Render Options
  58980. */
  58981. export interface IEffectRendererOptions {
  58982. /**
  58983. * Defines the vertices positions.
  58984. */
  58985. positions?: number[];
  58986. /**
  58987. * Defines the indices.
  58988. */
  58989. indices?: number[];
  58990. }
  58991. /**
  58992. * Helper class to render one or more effects.
  58993. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58994. */
  58995. export class EffectRenderer {
  58996. private engine;
  58997. private static _DefaultOptions;
  58998. private _vertexBuffers;
  58999. private _indexBuffer;
  59000. private _fullscreenViewport;
  59001. /**
  59002. * Creates an effect renderer
  59003. * @param engine the engine to use for rendering
  59004. * @param options defines the options of the effect renderer
  59005. */
  59006. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59007. /**
  59008. * Sets the current viewport in normalized coordinates 0-1
  59009. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59010. */
  59011. setViewport(viewport?: Viewport): void;
  59012. /**
  59013. * Binds the embedded attributes buffer to the effect.
  59014. * @param effect Defines the effect to bind the attributes for
  59015. */
  59016. bindBuffers(effect: Effect): void;
  59017. /**
  59018. * Sets the current effect wrapper to use during draw.
  59019. * The effect needs to be ready before calling this api.
  59020. * This also sets the default full screen position attribute.
  59021. * @param effectWrapper Defines the effect to draw with
  59022. */
  59023. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59024. /**
  59025. * Restores engine states
  59026. */
  59027. restoreStates(): void;
  59028. /**
  59029. * Draws a full screen quad.
  59030. */
  59031. draw(): void;
  59032. private isRenderTargetTexture;
  59033. /**
  59034. * renders one or more effects to a specified texture
  59035. * @param effectWrapper the effect to renderer
  59036. * @param outputTexture texture to draw to, if null it will render to the screen.
  59037. */
  59038. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59039. /**
  59040. * Disposes of the effect renderer
  59041. */
  59042. dispose(): void;
  59043. }
  59044. /**
  59045. * Options to create an EffectWrapper
  59046. */
  59047. interface EffectWrapperCreationOptions {
  59048. /**
  59049. * Engine to use to create the effect
  59050. */
  59051. engine: ThinEngine;
  59052. /**
  59053. * Fragment shader for the effect
  59054. */
  59055. fragmentShader: string;
  59056. /**
  59057. * Use the shader store instead of direct source code
  59058. */
  59059. useShaderStore?: boolean;
  59060. /**
  59061. * Vertex shader for the effect
  59062. */
  59063. vertexShader?: string;
  59064. /**
  59065. * Attributes to use in the shader
  59066. */
  59067. attributeNames?: Array<string>;
  59068. /**
  59069. * Uniforms to use in the shader
  59070. */
  59071. uniformNames?: Array<string>;
  59072. /**
  59073. * Texture sampler names to use in the shader
  59074. */
  59075. samplerNames?: Array<string>;
  59076. /**
  59077. * Defines to use in the shader
  59078. */
  59079. defines?: Array<string>;
  59080. /**
  59081. * Callback when effect is compiled
  59082. */
  59083. onCompiled?: Nullable<(effect: Effect) => void>;
  59084. /**
  59085. * The friendly name of the effect displayed in Spector.
  59086. */
  59087. name?: string;
  59088. }
  59089. /**
  59090. * Wraps an effect to be used for rendering
  59091. */
  59092. export class EffectWrapper {
  59093. /**
  59094. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59095. */
  59096. onApplyObservable: Observable<{}>;
  59097. /**
  59098. * The underlying effect
  59099. */
  59100. effect: Effect;
  59101. /**
  59102. * Creates an effect to be renderer
  59103. * @param creationOptions options to create the effect
  59104. */
  59105. constructor(creationOptions: EffectWrapperCreationOptions);
  59106. /**
  59107. * Disposes of the effect wrapper
  59108. */
  59109. dispose(): void;
  59110. }
  59111. }
  59112. declare module BABYLON {
  59113. /** @hidden */
  59114. export var hdrFilteringVertexShader: {
  59115. name: string;
  59116. shader: string;
  59117. };
  59118. }
  59119. declare module BABYLON {
  59120. /** @hidden */
  59121. export var hdrFilteringPixelShader: {
  59122. name: string;
  59123. shader: string;
  59124. };
  59125. }
  59126. declare module BABYLON {
  59127. /**
  59128. * Options for texture filtering
  59129. */
  59130. interface IHDRFilteringOptions {
  59131. /**
  59132. * Scales pixel intensity for the input HDR map.
  59133. */
  59134. hdrScale?: number;
  59135. /**
  59136. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59137. */
  59138. quality?: number;
  59139. }
  59140. /**
  59141. * Filters HDR maps to get correct renderings of PBR reflections
  59142. */
  59143. export class HDRFiltering {
  59144. private _engine;
  59145. private _effectRenderer;
  59146. private _effectWrapper;
  59147. private _lodGenerationOffset;
  59148. private _lodGenerationScale;
  59149. /**
  59150. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59151. * you care about baking speed.
  59152. */
  59153. quality: number;
  59154. /**
  59155. * Scales pixel intensity for the input HDR map.
  59156. */
  59157. hdrScale: number;
  59158. /**
  59159. * Instantiates HDR filter for reflection maps
  59160. *
  59161. * @param engine Thin engine
  59162. * @param options Options
  59163. */
  59164. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59165. private _createRenderTarget;
  59166. private _prefilterInternal;
  59167. private _createEffect;
  59168. /**
  59169. * Get a value indicating if the filter is ready to be used
  59170. * @param texture Texture to filter
  59171. * @returns true if the filter is ready
  59172. */
  59173. isReady(texture: BaseTexture): boolean;
  59174. /**
  59175. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59176. * Prefiltering will be invoked at the end of next rendering pass.
  59177. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59178. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59179. * @param texture Texture to filter
  59180. * @param onFinished Callback when filtering is done
  59181. * @return Promise called when prefiltering is done
  59182. */
  59183. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59184. }
  59185. }
  59186. declare module BABYLON {
  59187. /**
  59188. * This represents a texture coming from an HDR input.
  59189. *
  59190. * The only supported format is currently panorama picture stored in RGBE format.
  59191. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59192. */
  59193. export class HDRCubeTexture extends BaseTexture {
  59194. private static _facesMapping;
  59195. private _generateHarmonics;
  59196. private _noMipmap;
  59197. private _prefilterOnLoad;
  59198. private _textureMatrix;
  59199. private _size;
  59200. private _onLoad;
  59201. private _onError;
  59202. /**
  59203. * The texture URL.
  59204. */
  59205. url: string;
  59206. /**
  59207. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59208. */
  59209. coordinatesMode: number;
  59210. protected _isBlocking: boolean;
  59211. /**
  59212. * Sets wether or not the texture is blocking during loading.
  59213. */
  59214. set isBlocking(value: boolean);
  59215. /**
  59216. * Gets wether or not the texture is blocking during loading.
  59217. */
  59218. get isBlocking(): boolean;
  59219. protected _rotationY: number;
  59220. /**
  59221. * Sets texture matrix rotation angle around Y axis in radians.
  59222. */
  59223. set rotationY(value: number);
  59224. /**
  59225. * Gets texture matrix rotation angle around Y axis radians.
  59226. */
  59227. get rotationY(): number;
  59228. /**
  59229. * Gets or sets the center of the bounding box associated with the cube texture
  59230. * It must define where the camera used to render the texture was set
  59231. */
  59232. boundingBoxPosition: Vector3;
  59233. private _boundingBoxSize;
  59234. /**
  59235. * Gets or sets the size of the bounding box associated with the cube texture
  59236. * When defined, the cubemap will switch to local mode
  59237. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59238. * @example https://www.babylonjs-playground.com/#RNASML
  59239. */
  59240. set boundingBoxSize(value: Vector3);
  59241. get boundingBoxSize(): Vector3;
  59242. /**
  59243. * Instantiates an HDRTexture from the following parameters.
  59244. *
  59245. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59246. * @param sceneOrEngine The scene or engine the texture will be used in
  59247. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59248. * @param noMipmap Forces to not generate the mipmap if true
  59249. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59250. * @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)
  59251. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59252. */
  59253. 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>);
  59254. /**
  59255. * Get the current class name of the texture useful for serialization or dynamic coding.
  59256. * @returns "HDRCubeTexture"
  59257. */
  59258. getClassName(): string;
  59259. /**
  59260. * Occurs when the file is raw .hdr file.
  59261. */
  59262. private loadTexture;
  59263. clone(): HDRCubeTexture;
  59264. delayLoad(): void;
  59265. /**
  59266. * Get the texture reflection matrix used to rotate/transform the reflection.
  59267. * @returns the reflection matrix
  59268. */
  59269. getReflectionTextureMatrix(): Matrix;
  59270. /**
  59271. * Set the texture reflection matrix used to rotate/transform the reflection.
  59272. * @param value Define the reflection matrix to set
  59273. */
  59274. setReflectionTextureMatrix(value: Matrix): void;
  59275. /**
  59276. * Parses a JSON representation of an HDR Texture in order to create the texture
  59277. * @param parsedTexture Define the JSON representation
  59278. * @param scene Define the scene the texture should be created in
  59279. * @param rootUrl Define the root url in case we need to load relative dependencies
  59280. * @returns the newly created texture after parsing
  59281. */
  59282. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59283. serialize(): any;
  59284. }
  59285. }
  59286. declare module BABYLON {
  59287. /**
  59288. * Class used to control physics engine
  59289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59290. */
  59291. export class PhysicsEngine implements IPhysicsEngine {
  59292. private _physicsPlugin;
  59293. /**
  59294. * Global value used to control the smallest number supported by the simulation
  59295. */
  59296. static Epsilon: number;
  59297. private _impostors;
  59298. private _joints;
  59299. private _subTimeStep;
  59300. /**
  59301. * Gets the gravity vector used by the simulation
  59302. */
  59303. gravity: Vector3;
  59304. /**
  59305. * Factory used to create the default physics plugin.
  59306. * @returns The default physics plugin
  59307. */
  59308. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59309. /**
  59310. * Creates a new Physics Engine
  59311. * @param gravity defines the gravity vector used by the simulation
  59312. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59313. */
  59314. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59315. /**
  59316. * Sets the gravity vector used by the simulation
  59317. * @param gravity defines the gravity vector to use
  59318. */
  59319. setGravity(gravity: Vector3): void;
  59320. /**
  59321. * Set the time step of the physics engine.
  59322. * Default is 1/60.
  59323. * To slow it down, enter 1/600 for example.
  59324. * To speed it up, 1/30
  59325. * @param newTimeStep defines the new timestep to apply to this world.
  59326. */
  59327. setTimeStep(newTimeStep?: number): void;
  59328. /**
  59329. * Get the time step of the physics engine.
  59330. * @returns the current time step
  59331. */
  59332. getTimeStep(): number;
  59333. /**
  59334. * Set the sub time step of the physics engine.
  59335. * Default is 0 meaning there is no sub steps
  59336. * To increase physics resolution precision, set a small value (like 1 ms)
  59337. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59338. */
  59339. setSubTimeStep(subTimeStep?: number): void;
  59340. /**
  59341. * Get the sub time step of the physics engine.
  59342. * @returns the current sub time step
  59343. */
  59344. getSubTimeStep(): number;
  59345. /**
  59346. * Release all resources
  59347. */
  59348. dispose(): void;
  59349. /**
  59350. * Gets the name of the current physics plugin
  59351. * @returns the name of the plugin
  59352. */
  59353. getPhysicsPluginName(): string;
  59354. /**
  59355. * Adding a new impostor for the impostor tracking.
  59356. * This will be done by the impostor itself.
  59357. * @param impostor the impostor to add
  59358. */
  59359. addImpostor(impostor: PhysicsImpostor): void;
  59360. /**
  59361. * Remove an impostor from the engine.
  59362. * This impostor and its mesh will not longer be updated by the physics engine.
  59363. * @param impostor the impostor to remove
  59364. */
  59365. removeImpostor(impostor: PhysicsImpostor): void;
  59366. /**
  59367. * Add a joint to the physics engine
  59368. * @param mainImpostor defines the main impostor to which the joint is added.
  59369. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59370. * @param joint defines the joint that will connect both impostors.
  59371. */
  59372. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59373. /**
  59374. * Removes a joint from the simulation
  59375. * @param mainImpostor defines the impostor used with the joint
  59376. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59377. * @param joint defines the joint to remove
  59378. */
  59379. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59380. /**
  59381. * Called by the scene. No need to call it.
  59382. * @param delta defines the timespam between frames
  59383. */
  59384. _step(delta: number): void;
  59385. /**
  59386. * Gets the current plugin used to run the simulation
  59387. * @returns current plugin
  59388. */
  59389. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59390. /**
  59391. * Gets the list of physic impostors
  59392. * @returns an array of PhysicsImpostor
  59393. */
  59394. getImpostors(): Array<PhysicsImpostor>;
  59395. /**
  59396. * Gets the impostor for a physics enabled object
  59397. * @param object defines the object impersonated by the impostor
  59398. * @returns the PhysicsImpostor or null if not found
  59399. */
  59400. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59401. /**
  59402. * Gets the impostor for a physics body object
  59403. * @param body defines physics body used by the impostor
  59404. * @returns the PhysicsImpostor or null if not found
  59405. */
  59406. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59407. /**
  59408. * Does a raycast in the physics world
  59409. * @param from when should the ray start?
  59410. * @param to when should the ray end?
  59411. * @returns PhysicsRaycastResult
  59412. */
  59413. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59414. }
  59415. }
  59416. declare module BABYLON {
  59417. /** @hidden */
  59418. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59419. private _useDeltaForWorldStep;
  59420. world: any;
  59421. name: string;
  59422. private _physicsMaterials;
  59423. private _fixedTimeStep;
  59424. private _cannonRaycastResult;
  59425. private _raycastResult;
  59426. private _physicsBodysToRemoveAfterStep;
  59427. private _firstFrame;
  59428. BJSCANNON: any;
  59429. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59430. setGravity(gravity: Vector3): void;
  59431. setTimeStep(timeStep: number): void;
  59432. getTimeStep(): number;
  59433. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59434. private _removeMarkedPhysicsBodiesFromWorld;
  59435. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59436. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59437. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59438. private _processChildMeshes;
  59439. removePhysicsBody(impostor: PhysicsImpostor): void;
  59440. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59441. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59442. private _addMaterial;
  59443. private _checkWithEpsilon;
  59444. private _createShape;
  59445. private _createHeightmap;
  59446. private _minus90X;
  59447. private _plus90X;
  59448. private _tmpPosition;
  59449. private _tmpDeltaPosition;
  59450. private _tmpUnityRotation;
  59451. private _updatePhysicsBodyTransformation;
  59452. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59454. isSupported(): boolean;
  59455. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59456. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59457. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59458. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59459. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59460. getBodyMass(impostor: PhysicsImpostor): number;
  59461. getBodyFriction(impostor: PhysicsImpostor): number;
  59462. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59463. getBodyRestitution(impostor: PhysicsImpostor): number;
  59464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59465. sleepBody(impostor: PhysicsImpostor): void;
  59466. wakeUpBody(impostor: PhysicsImpostor): void;
  59467. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59468. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59470. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59471. getRadius(impostor: PhysicsImpostor): number;
  59472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59473. dispose(): void;
  59474. private _extendNamespace;
  59475. /**
  59476. * Does a raycast in the physics world
  59477. * @param from when should the ray start?
  59478. * @param to when should the ray end?
  59479. * @returns PhysicsRaycastResult
  59480. */
  59481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59482. }
  59483. }
  59484. declare module BABYLON {
  59485. /** @hidden */
  59486. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59487. private _useDeltaForWorldStep;
  59488. world: any;
  59489. name: string;
  59490. BJSOIMO: any;
  59491. private _raycastResult;
  59492. private _fixedTimeStep;
  59493. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59494. setGravity(gravity: Vector3): void;
  59495. setTimeStep(timeStep: number): void;
  59496. getTimeStep(): number;
  59497. private _tmpImpostorsArray;
  59498. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59499. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59500. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59501. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59502. private _tmpPositionVector;
  59503. removePhysicsBody(impostor: PhysicsImpostor): void;
  59504. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59505. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59506. isSupported(): boolean;
  59507. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59508. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59509. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59510. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59511. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59513. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59514. getBodyMass(impostor: PhysicsImpostor): number;
  59515. getBodyFriction(impostor: PhysicsImpostor): number;
  59516. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59517. getBodyRestitution(impostor: PhysicsImpostor): number;
  59518. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59519. sleepBody(impostor: PhysicsImpostor): void;
  59520. wakeUpBody(impostor: PhysicsImpostor): void;
  59521. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59522. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59523. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59524. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59525. getRadius(impostor: PhysicsImpostor): number;
  59526. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59527. dispose(): void;
  59528. /**
  59529. * Does a raycast in the physics world
  59530. * @param from when should the ray start?
  59531. * @param to when should the ray end?
  59532. * @returns PhysicsRaycastResult
  59533. */
  59534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59535. }
  59536. }
  59537. declare module BABYLON {
  59538. /**
  59539. * Class containing static functions to help procedurally build meshes
  59540. */
  59541. export class RibbonBuilder {
  59542. /**
  59543. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59544. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59545. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59546. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59547. * * 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
  59548. * * 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
  59549. * * 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
  59550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59551. * * 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
  59552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59553. * * 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
  59554. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59555. * * 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
  59556. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59558. * @param name defines the name of the mesh
  59559. * @param options defines the options used to create the mesh
  59560. * @param scene defines the hosting scene
  59561. * @returns the ribbon mesh
  59562. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59564. */
  59565. static CreateRibbon(name: string, options: {
  59566. pathArray: Vector3[][];
  59567. closeArray?: boolean;
  59568. closePath?: boolean;
  59569. offset?: number;
  59570. updatable?: boolean;
  59571. sideOrientation?: number;
  59572. frontUVs?: Vector4;
  59573. backUVs?: Vector4;
  59574. instance?: Mesh;
  59575. invertUV?: boolean;
  59576. uvs?: Vector2[];
  59577. colors?: Color4[];
  59578. }, scene?: Nullable<Scene>): Mesh;
  59579. }
  59580. }
  59581. declare module BABYLON {
  59582. /**
  59583. * Class containing static functions to help procedurally build meshes
  59584. */
  59585. export class ShapeBuilder {
  59586. /**
  59587. * 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.
  59588. * * 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.
  59589. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59590. * * 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.
  59591. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59592. * * 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
  59593. * * 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
  59594. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59596. * * 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
  59597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59599. * @param name defines the name of the mesh
  59600. * @param options defines the options used to create the mesh
  59601. * @param scene defines the hosting scene
  59602. * @returns the extruded shape mesh
  59603. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59605. */
  59606. static ExtrudeShape(name: string, options: {
  59607. shape: Vector3[];
  59608. path: Vector3[];
  59609. scale?: number;
  59610. rotation?: number;
  59611. cap?: number;
  59612. updatable?: boolean;
  59613. sideOrientation?: number;
  59614. frontUVs?: Vector4;
  59615. backUVs?: Vector4;
  59616. instance?: Mesh;
  59617. invertUV?: boolean;
  59618. }, scene?: Nullable<Scene>): Mesh;
  59619. /**
  59620. * Creates an custom extruded shape mesh.
  59621. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59622. * * 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.
  59623. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59624. * * 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
  59625. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59626. * * 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
  59627. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59628. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59629. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59630. * * 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
  59631. * * 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
  59632. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59634. * * 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
  59635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59637. * @param name defines the name of the mesh
  59638. * @param options defines the options used to create the mesh
  59639. * @param scene defines the hosting scene
  59640. * @returns the custom extruded shape mesh
  59641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59642. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59644. */
  59645. static ExtrudeShapeCustom(name: string, options: {
  59646. shape: Vector3[];
  59647. path: Vector3[];
  59648. scaleFunction?: any;
  59649. rotationFunction?: any;
  59650. ribbonCloseArray?: boolean;
  59651. ribbonClosePath?: boolean;
  59652. cap?: number;
  59653. updatable?: boolean;
  59654. sideOrientation?: number;
  59655. frontUVs?: Vector4;
  59656. backUVs?: Vector4;
  59657. instance?: Mesh;
  59658. invertUV?: boolean;
  59659. }, scene?: Nullable<Scene>): Mesh;
  59660. private static _ExtrudeShapeGeneric;
  59661. }
  59662. }
  59663. declare module BABYLON {
  59664. /**
  59665. * AmmoJS Physics plugin
  59666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59667. * @see https://github.com/kripken/ammo.js/
  59668. */
  59669. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59670. private _useDeltaForWorldStep;
  59671. /**
  59672. * Reference to the Ammo library
  59673. */
  59674. bjsAMMO: any;
  59675. /**
  59676. * Created ammoJS world which physics bodies are added to
  59677. */
  59678. world: any;
  59679. /**
  59680. * Name of the plugin
  59681. */
  59682. name: string;
  59683. private _timeStep;
  59684. private _fixedTimeStep;
  59685. private _maxSteps;
  59686. private _tmpQuaternion;
  59687. private _tmpAmmoTransform;
  59688. private _tmpAmmoQuaternion;
  59689. private _tmpAmmoConcreteContactResultCallback;
  59690. private _collisionConfiguration;
  59691. private _dispatcher;
  59692. private _overlappingPairCache;
  59693. private _solver;
  59694. private _softBodySolver;
  59695. private _tmpAmmoVectorA;
  59696. private _tmpAmmoVectorB;
  59697. private _tmpAmmoVectorC;
  59698. private _tmpAmmoVectorD;
  59699. private _tmpContactCallbackResult;
  59700. private _tmpAmmoVectorRCA;
  59701. private _tmpAmmoVectorRCB;
  59702. private _raycastResult;
  59703. private static readonly DISABLE_COLLISION_FLAG;
  59704. private static readonly KINEMATIC_FLAG;
  59705. private static readonly DISABLE_DEACTIVATION_FLAG;
  59706. /**
  59707. * Initializes the ammoJS plugin
  59708. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59709. * @param ammoInjection can be used to inject your own ammo reference
  59710. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59711. */
  59712. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59713. /**
  59714. * Sets the gravity of the physics world (m/(s^2))
  59715. * @param gravity Gravity to set
  59716. */
  59717. setGravity(gravity: Vector3): void;
  59718. /**
  59719. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59720. * @param timeStep timestep to use in seconds
  59721. */
  59722. setTimeStep(timeStep: number): void;
  59723. /**
  59724. * 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)
  59725. * @param fixedTimeStep fixedTimeStep to use in seconds
  59726. */
  59727. setFixedTimeStep(fixedTimeStep: number): void;
  59728. /**
  59729. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59730. * @param maxSteps the maximum number of steps by the physics engine per frame
  59731. */
  59732. setMaxSteps(maxSteps: number): void;
  59733. /**
  59734. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59735. * @returns the current timestep in seconds
  59736. */
  59737. getTimeStep(): number;
  59738. /**
  59739. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59740. */
  59741. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59742. private _isImpostorInContact;
  59743. private _isImpostorPairInContact;
  59744. private _stepSimulation;
  59745. /**
  59746. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59747. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59748. * After the step the babylon meshes are set to the position of the physics imposters
  59749. * @param delta amount of time to step forward
  59750. * @param impostors array of imposters to update before/after the step
  59751. */
  59752. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59753. /**
  59754. * Update babylon mesh to match physics world object
  59755. * @param impostor imposter to match
  59756. */
  59757. private _afterSoftStep;
  59758. /**
  59759. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59760. * @param impostor imposter to match
  59761. */
  59762. private _ropeStep;
  59763. /**
  59764. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59765. * @param impostor imposter to match
  59766. */
  59767. private _softbodyOrClothStep;
  59768. private _tmpMatrix;
  59769. /**
  59770. * Applies an impulse on the imposter
  59771. * @param impostor imposter to apply impulse to
  59772. * @param force amount of force to be applied to the imposter
  59773. * @param contactPoint the location to apply the impulse on the imposter
  59774. */
  59775. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59776. /**
  59777. * Applies a force on the imposter
  59778. * @param impostor imposter to apply force
  59779. * @param force amount of force to be applied to the imposter
  59780. * @param contactPoint the location to apply the force on the imposter
  59781. */
  59782. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59783. /**
  59784. * Creates a physics body using the plugin
  59785. * @param impostor the imposter to create the physics body on
  59786. */
  59787. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59788. /**
  59789. * Removes the physics body from the imposter and disposes of the body's memory
  59790. * @param impostor imposter to remove the physics body from
  59791. */
  59792. removePhysicsBody(impostor: PhysicsImpostor): void;
  59793. /**
  59794. * Generates a joint
  59795. * @param impostorJoint the imposter joint to create the joint with
  59796. */
  59797. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59798. /**
  59799. * Removes a joint
  59800. * @param impostorJoint the imposter joint to remove the joint from
  59801. */
  59802. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59803. private _addMeshVerts;
  59804. /**
  59805. * Initialise the soft body vertices to match its object's (mesh) vertices
  59806. * Softbody vertices (nodes) are in world space and to match this
  59807. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59808. * @param impostor to create the softbody for
  59809. */
  59810. private _softVertexData;
  59811. /**
  59812. * Create an impostor's soft body
  59813. * @param impostor to create the softbody for
  59814. */
  59815. private _createSoftbody;
  59816. /**
  59817. * Create cloth for an impostor
  59818. * @param impostor to create the softbody for
  59819. */
  59820. private _createCloth;
  59821. /**
  59822. * Create rope for an impostor
  59823. * @param impostor to create the softbody for
  59824. */
  59825. private _createRope;
  59826. /**
  59827. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59828. * @param impostor to create the custom physics shape for
  59829. */
  59830. private _createCustom;
  59831. private _addHullVerts;
  59832. private _createShape;
  59833. /**
  59834. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59835. * @param impostor imposter containing the physics body and babylon object
  59836. */
  59837. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59838. /**
  59839. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59840. * @param impostor imposter containing the physics body and babylon object
  59841. * @param newPosition new position
  59842. * @param newRotation new rotation
  59843. */
  59844. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59845. /**
  59846. * If this plugin is supported
  59847. * @returns true if its supported
  59848. */
  59849. isSupported(): boolean;
  59850. /**
  59851. * Sets the linear velocity of the physics body
  59852. * @param impostor imposter to set the velocity on
  59853. * @param velocity velocity to set
  59854. */
  59855. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59856. /**
  59857. * Sets the angular velocity of the physics body
  59858. * @param impostor imposter to set the velocity on
  59859. * @param velocity velocity to set
  59860. */
  59861. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59862. /**
  59863. * gets the linear velocity
  59864. * @param impostor imposter to get linear velocity from
  59865. * @returns linear velocity
  59866. */
  59867. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59868. /**
  59869. * gets the angular velocity
  59870. * @param impostor imposter to get angular velocity from
  59871. * @returns angular velocity
  59872. */
  59873. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59874. /**
  59875. * Sets the mass of physics body
  59876. * @param impostor imposter to set the mass on
  59877. * @param mass mass to set
  59878. */
  59879. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59880. /**
  59881. * Gets the mass of the physics body
  59882. * @param impostor imposter to get the mass from
  59883. * @returns mass
  59884. */
  59885. getBodyMass(impostor: PhysicsImpostor): number;
  59886. /**
  59887. * Gets friction of the impostor
  59888. * @param impostor impostor to get friction from
  59889. * @returns friction value
  59890. */
  59891. getBodyFriction(impostor: PhysicsImpostor): number;
  59892. /**
  59893. * Sets friction of the impostor
  59894. * @param impostor impostor to set friction on
  59895. * @param friction friction value
  59896. */
  59897. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59898. /**
  59899. * Gets restitution of the impostor
  59900. * @param impostor impostor to get restitution from
  59901. * @returns restitution value
  59902. */
  59903. getBodyRestitution(impostor: PhysicsImpostor): number;
  59904. /**
  59905. * Sets resitution of the impostor
  59906. * @param impostor impostor to set resitution on
  59907. * @param restitution resitution value
  59908. */
  59909. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59910. /**
  59911. * Gets pressure inside the impostor
  59912. * @param impostor impostor to get pressure from
  59913. * @returns pressure value
  59914. */
  59915. getBodyPressure(impostor: PhysicsImpostor): number;
  59916. /**
  59917. * Sets pressure inside a soft body impostor
  59918. * Cloth and rope must remain 0 pressure
  59919. * @param impostor impostor to set pressure on
  59920. * @param pressure pressure value
  59921. */
  59922. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59923. /**
  59924. * Gets stiffness of the impostor
  59925. * @param impostor impostor to get stiffness from
  59926. * @returns pressure value
  59927. */
  59928. getBodyStiffness(impostor: PhysicsImpostor): number;
  59929. /**
  59930. * Sets stiffness of the impostor
  59931. * @param impostor impostor to set stiffness on
  59932. * @param stiffness stiffness value from 0 to 1
  59933. */
  59934. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59935. /**
  59936. * Gets velocityIterations of the impostor
  59937. * @param impostor impostor to get velocity iterations from
  59938. * @returns velocityIterations value
  59939. */
  59940. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59941. /**
  59942. * Sets velocityIterations of the impostor
  59943. * @param impostor impostor to set velocity iterations on
  59944. * @param velocityIterations velocityIterations value
  59945. */
  59946. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59947. /**
  59948. * Gets positionIterations of the impostor
  59949. * @param impostor impostor to get position iterations from
  59950. * @returns positionIterations value
  59951. */
  59952. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59953. /**
  59954. * Sets positionIterations of the impostor
  59955. * @param impostor impostor to set position on
  59956. * @param positionIterations positionIterations value
  59957. */
  59958. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59959. /**
  59960. * Append an anchor to a cloth object
  59961. * @param impostor is the cloth impostor to add anchor to
  59962. * @param otherImpostor is the rigid impostor to anchor to
  59963. * @param width ratio across width from 0 to 1
  59964. * @param height ratio up height from 0 to 1
  59965. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59966. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59967. */
  59968. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59969. /**
  59970. * Append an hook to a rope object
  59971. * @param impostor is the rope impostor to add hook to
  59972. * @param otherImpostor is the rigid impostor to hook to
  59973. * @param length ratio along the rope from 0 to 1
  59974. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59975. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59976. */
  59977. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59978. /**
  59979. * Sleeps the physics body and stops it from being active
  59980. * @param impostor impostor to sleep
  59981. */
  59982. sleepBody(impostor: PhysicsImpostor): void;
  59983. /**
  59984. * Activates the physics body
  59985. * @param impostor impostor to activate
  59986. */
  59987. wakeUpBody(impostor: PhysicsImpostor): void;
  59988. /**
  59989. * Updates the distance parameters of the joint
  59990. * @param joint joint to update
  59991. * @param maxDistance maximum distance of the joint
  59992. * @param minDistance minimum distance of the joint
  59993. */
  59994. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59995. /**
  59996. * Sets a motor on the joint
  59997. * @param joint joint to set motor on
  59998. * @param speed speed of the motor
  59999. * @param maxForce maximum force of the motor
  60000. * @param motorIndex index of the motor
  60001. */
  60002. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60003. /**
  60004. * Sets the motors limit
  60005. * @param joint joint to set limit on
  60006. * @param upperLimit upper limit
  60007. * @param lowerLimit lower limit
  60008. */
  60009. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60010. /**
  60011. * Syncs the position and rotation of a mesh with the impostor
  60012. * @param mesh mesh to sync
  60013. * @param impostor impostor to update the mesh with
  60014. */
  60015. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60016. /**
  60017. * Gets the radius of the impostor
  60018. * @param impostor impostor to get radius from
  60019. * @returns the radius
  60020. */
  60021. getRadius(impostor: PhysicsImpostor): number;
  60022. /**
  60023. * Gets the box size of the impostor
  60024. * @param impostor impostor to get box size from
  60025. * @param result the resulting box size
  60026. */
  60027. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60028. /**
  60029. * Disposes of the impostor
  60030. */
  60031. dispose(): void;
  60032. /**
  60033. * Does a raycast in the physics world
  60034. * @param from when should the ray start?
  60035. * @param to when should the ray end?
  60036. * @returns PhysicsRaycastResult
  60037. */
  60038. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60039. }
  60040. }
  60041. declare module BABYLON {
  60042. interface AbstractScene {
  60043. /**
  60044. * The list of reflection probes added to the scene
  60045. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60046. */
  60047. reflectionProbes: Array<ReflectionProbe>;
  60048. /**
  60049. * Removes the given reflection probe from this scene.
  60050. * @param toRemove The reflection probe to remove
  60051. * @returns The index of the removed reflection probe
  60052. */
  60053. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60054. /**
  60055. * Adds the given reflection probe to this scene.
  60056. * @param newReflectionProbe The reflection probe to add
  60057. */
  60058. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60059. }
  60060. /**
  60061. * Class used to generate realtime reflection / refraction cube textures
  60062. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60063. */
  60064. export class ReflectionProbe {
  60065. /** defines the name of the probe */
  60066. name: string;
  60067. private _scene;
  60068. private _renderTargetTexture;
  60069. private _projectionMatrix;
  60070. private _viewMatrix;
  60071. private _target;
  60072. private _add;
  60073. private _attachedMesh;
  60074. private _invertYAxis;
  60075. /** Gets or sets probe position (center of the cube map) */
  60076. position: Vector3;
  60077. /**
  60078. * Creates a new reflection probe
  60079. * @param name defines the name of the probe
  60080. * @param size defines the texture resolution (for each face)
  60081. * @param scene defines the hosting scene
  60082. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60083. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60084. */
  60085. constructor(
  60086. /** defines the name of the probe */
  60087. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60088. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60089. get samples(): number;
  60090. set samples(value: number);
  60091. /** Gets or sets the refresh rate to use (on every frame by default) */
  60092. get refreshRate(): number;
  60093. set refreshRate(value: number);
  60094. /**
  60095. * Gets the hosting scene
  60096. * @returns a Scene
  60097. */
  60098. getScene(): Scene;
  60099. /** Gets the internal CubeTexture used to render to */
  60100. get cubeTexture(): RenderTargetTexture;
  60101. /** Gets the list of meshes to render */
  60102. get renderList(): Nullable<AbstractMesh[]>;
  60103. /**
  60104. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60105. * @param mesh defines the mesh to attach to
  60106. */
  60107. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60108. /**
  60109. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60110. * @param renderingGroupId The rendering group id corresponding to its index
  60111. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60112. */
  60113. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60114. /**
  60115. * Clean all associated resources
  60116. */
  60117. dispose(): void;
  60118. /**
  60119. * Converts the reflection probe information to a readable string for debug purpose.
  60120. * @param fullDetails Supports for multiple levels of logging within scene loading
  60121. * @returns the human readable reflection probe info
  60122. */
  60123. toString(fullDetails?: boolean): string;
  60124. /**
  60125. * Get the class name of the relfection probe.
  60126. * @returns "ReflectionProbe"
  60127. */
  60128. getClassName(): string;
  60129. /**
  60130. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60131. * @returns The JSON representation of the texture
  60132. */
  60133. serialize(): any;
  60134. /**
  60135. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60136. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60137. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60138. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60139. * @returns The parsed reflection probe if successful
  60140. */
  60141. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60142. }
  60143. }
  60144. declare module BABYLON {
  60145. /** @hidden */
  60146. export var _BabylonLoaderRegistered: boolean;
  60147. /**
  60148. * Helps setting up some configuration for the babylon file loader.
  60149. */
  60150. export class BabylonFileLoaderConfiguration {
  60151. /**
  60152. * The loader does not allow injecting custom physix engine into the plugins.
  60153. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60154. * So you could set this variable to your engine import to make it work.
  60155. */
  60156. static LoaderInjectedPhysicsEngine: any;
  60157. }
  60158. }
  60159. declare module BABYLON {
  60160. /**
  60161. * The Physically based simple base material of BJS.
  60162. *
  60163. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60164. * It is used as the base class for both the specGloss and metalRough conventions.
  60165. */
  60166. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60167. /**
  60168. * Number of Simultaneous lights allowed on the material.
  60169. */
  60170. maxSimultaneousLights: number;
  60171. /**
  60172. * If sets to true, disables all the lights affecting the material.
  60173. */
  60174. disableLighting: boolean;
  60175. /**
  60176. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60177. */
  60178. environmentTexture: BaseTexture;
  60179. /**
  60180. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60181. */
  60182. invertNormalMapX: boolean;
  60183. /**
  60184. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60185. */
  60186. invertNormalMapY: boolean;
  60187. /**
  60188. * Normal map used in the model.
  60189. */
  60190. normalTexture: BaseTexture;
  60191. /**
  60192. * Emissivie color used to self-illuminate the model.
  60193. */
  60194. emissiveColor: Color3;
  60195. /**
  60196. * Emissivie texture used to self-illuminate the model.
  60197. */
  60198. emissiveTexture: BaseTexture;
  60199. /**
  60200. * Occlusion Channel Strenght.
  60201. */
  60202. occlusionStrength: number;
  60203. /**
  60204. * Occlusion Texture of the material (adding extra occlusion effects).
  60205. */
  60206. occlusionTexture: BaseTexture;
  60207. /**
  60208. * Defines the alpha limits in alpha test mode.
  60209. */
  60210. alphaCutOff: number;
  60211. /**
  60212. * Gets the current double sided mode.
  60213. */
  60214. get doubleSided(): boolean;
  60215. /**
  60216. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60217. */
  60218. set doubleSided(value: boolean);
  60219. /**
  60220. * Stores the pre-calculated light information of a mesh in a texture.
  60221. */
  60222. lightmapTexture: BaseTexture;
  60223. /**
  60224. * If true, the light map contains occlusion information instead of lighting info.
  60225. */
  60226. useLightmapAsShadowmap: boolean;
  60227. /**
  60228. * Instantiates a new PBRMaterial instance.
  60229. *
  60230. * @param name The material name
  60231. * @param scene The scene the material will be use in.
  60232. */
  60233. constructor(name: string, scene: Scene);
  60234. getClassName(): string;
  60235. }
  60236. }
  60237. declare module BABYLON {
  60238. /**
  60239. * The PBR material of BJS following the metal roughness convention.
  60240. *
  60241. * This fits to the PBR convention in the GLTF definition:
  60242. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60243. */
  60244. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60245. /**
  60246. * The base color has two different interpretations depending on the value of metalness.
  60247. * When the material is a metal, the base color is the specific measured reflectance value
  60248. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60249. * of the material.
  60250. */
  60251. baseColor: Color3;
  60252. /**
  60253. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60254. * well as opacity information in the alpha channel.
  60255. */
  60256. baseTexture: BaseTexture;
  60257. /**
  60258. * Specifies the metallic scalar value of the material.
  60259. * Can also be used to scale the metalness values of the metallic texture.
  60260. */
  60261. metallic: number;
  60262. /**
  60263. * Specifies the roughness scalar value of the material.
  60264. * Can also be used to scale the roughness values of the metallic texture.
  60265. */
  60266. roughness: number;
  60267. /**
  60268. * Texture containing both the metallic value in the B channel and the
  60269. * roughness value in the G channel to keep better precision.
  60270. */
  60271. metallicRoughnessTexture: BaseTexture;
  60272. /**
  60273. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60274. *
  60275. * @param name The material name
  60276. * @param scene The scene the material will be use in.
  60277. */
  60278. constructor(name: string, scene: Scene);
  60279. /**
  60280. * Return the currrent class name of the material.
  60281. */
  60282. getClassName(): string;
  60283. /**
  60284. * Makes a duplicate of the current material.
  60285. * @param name - name to use for the new material.
  60286. */
  60287. clone(name: string): PBRMetallicRoughnessMaterial;
  60288. /**
  60289. * Serialize the material to a parsable JSON object.
  60290. */
  60291. serialize(): any;
  60292. /**
  60293. * Parses a JSON object correponding to the serialize function.
  60294. */
  60295. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60296. }
  60297. }
  60298. declare module BABYLON {
  60299. /**
  60300. * The PBR material of BJS following the specular glossiness convention.
  60301. *
  60302. * This fits to the PBR convention in the GLTF definition:
  60303. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60304. */
  60305. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60306. /**
  60307. * Specifies the diffuse color of the material.
  60308. */
  60309. diffuseColor: Color3;
  60310. /**
  60311. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60312. * channel.
  60313. */
  60314. diffuseTexture: BaseTexture;
  60315. /**
  60316. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60317. */
  60318. specularColor: Color3;
  60319. /**
  60320. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60321. */
  60322. glossiness: number;
  60323. /**
  60324. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60325. */
  60326. specularGlossinessTexture: BaseTexture;
  60327. /**
  60328. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60329. *
  60330. * @param name The material name
  60331. * @param scene The scene the material will be use in.
  60332. */
  60333. constructor(name: string, scene: Scene);
  60334. /**
  60335. * Return the currrent class name of the material.
  60336. */
  60337. getClassName(): string;
  60338. /**
  60339. * Makes a duplicate of the current material.
  60340. * @param name - name to use for the new material.
  60341. */
  60342. clone(name: string): PBRSpecularGlossinessMaterial;
  60343. /**
  60344. * Serialize the material to a parsable JSON object.
  60345. */
  60346. serialize(): any;
  60347. /**
  60348. * Parses a JSON object correponding to the serialize function.
  60349. */
  60350. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60351. }
  60352. }
  60353. declare module BABYLON {
  60354. /**
  60355. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60356. * It can help converting any input color in a desired output one. This can then be used to create effects
  60357. * from sepia, black and white to sixties or futuristic rendering...
  60358. *
  60359. * The only supported format is currently 3dl.
  60360. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60361. */
  60362. export class ColorGradingTexture extends BaseTexture {
  60363. /**
  60364. * The texture URL.
  60365. */
  60366. url: string;
  60367. /**
  60368. * Empty line regex stored for GC.
  60369. */
  60370. private static _noneEmptyLineRegex;
  60371. private _textureMatrix;
  60372. private _onLoad;
  60373. /**
  60374. * Instantiates a ColorGradingTexture from the following parameters.
  60375. *
  60376. * @param url The location of the color gradind data (currently only supporting 3dl)
  60377. * @param sceneOrEngine The scene or engine the texture will be used in
  60378. * @param onLoad defines a callback triggered when the texture has been loaded
  60379. */
  60380. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60381. /**
  60382. * Fires the onload event from the constructor if requested.
  60383. */
  60384. private _triggerOnLoad;
  60385. /**
  60386. * Returns the texture matrix used in most of the material.
  60387. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60388. */
  60389. getTextureMatrix(): Matrix;
  60390. /**
  60391. * Occurs when the file being loaded is a .3dl LUT file.
  60392. */
  60393. private load3dlTexture;
  60394. /**
  60395. * Starts the loading process of the texture.
  60396. */
  60397. private loadTexture;
  60398. /**
  60399. * Clones the color gradind texture.
  60400. */
  60401. clone(): ColorGradingTexture;
  60402. /**
  60403. * Called during delayed load for textures.
  60404. */
  60405. delayLoad(): void;
  60406. /**
  60407. * Parses a color grading texture serialized by Babylon.
  60408. * @param parsedTexture The texture information being parsedTexture
  60409. * @param scene The scene to load the texture in
  60410. * @param rootUrl The root url of the data assets to load
  60411. * @return A color gradind texture
  60412. */
  60413. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60414. /**
  60415. * Serializes the LUT texture to json format.
  60416. */
  60417. serialize(): any;
  60418. }
  60419. }
  60420. declare module BABYLON {
  60421. /**
  60422. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60423. */
  60424. export class EquiRectangularCubeTexture extends BaseTexture {
  60425. /** The six faces of the cube. */
  60426. private static _FacesMapping;
  60427. private _noMipmap;
  60428. private _onLoad;
  60429. private _onError;
  60430. /** The size of the cubemap. */
  60431. private _size;
  60432. /** The buffer of the image. */
  60433. private _buffer;
  60434. /** The width of the input image. */
  60435. private _width;
  60436. /** The height of the input image. */
  60437. private _height;
  60438. /** The URL to the image. */
  60439. url: string;
  60440. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60441. coordinatesMode: number;
  60442. /**
  60443. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60444. * @param url The location of the image
  60445. * @param scene The scene the texture will be used in
  60446. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60447. * @param noMipmap Forces to not generate the mipmap if true
  60448. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60449. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60450. * @param onLoad — defines a callback called when texture is loaded
  60451. * @param onError — defines a callback called if there is an error
  60452. */
  60453. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60454. /**
  60455. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60456. */
  60457. private loadImage;
  60458. /**
  60459. * Convert the image buffer into a cubemap and create a CubeTexture.
  60460. */
  60461. private loadTexture;
  60462. /**
  60463. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60464. * @param buffer The ArrayBuffer that should be converted.
  60465. * @returns The buffer as Float32Array.
  60466. */
  60467. private getFloat32ArrayFromArrayBuffer;
  60468. /**
  60469. * Get the current class name of the texture useful for serialization or dynamic coding.
  60470. * @returns "EquiRectangularCubeTexture"
  60471. */
  60472. getClassName(): string;
  60473. /**
  60474. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60475. * @returns A clone of the current EquiRectangularCubeTexture.
  60476. */
  60477. clone(): EquiRectangularCubeTexture;
  60478. }
  60479. }
  60480. declare module BABYLON {
  60481. /**
  60482. * Defines the options related to the creation of an HtmlElementTexture
  60483. */
  60484. export interface IHtmlElementTextureOptions {
  60485. /**
  60486. * Defines wether mip maps should be created or not.
  60487. */
  60488. generateMipMaps?: boolean;
  60489. /**
  60490. * Defines the sampling mode of the texture.
  60491. */
  60492. samplingMode?: number;
  60493. /**
  60494. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60495. */
  60496. engine: Nullable<ThinEngine>;
  60497. /**
  60498. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60499. */
  60500. scene: Nullable<Scene>;
  60501. }
  60502. /**
  60503. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60504. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60505. * is automatically managed.
  60506. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60507. * in your application.
  60508. *
  60509. * As the update is not automatic, you need to call them manually.
  60510. */
  60511. export class HtmlElementTexture extends BaseTexture {
  60512. /**
  60513. * The texture URL.
  60514. */
  60515. element: HTMLVideoElement | HTMLCanvasElement;
  60516. private static readonly DefaultOptions;
  60517. private _textureMatrix;
  60518. private _isVideo;
  60519. private _generateMipMaps;
  60520. private _samplingMode;
  60521. /**
  60522. * Instantiates a HtmlElementTexture from the following parameters.
  60523. *
  60524. * @param name Defines the name of the texture
  60525. * @param element Defines the video or canvas the texture is filled with
  60526. * @param options Defines the other none mandatory texture creation options
  60527. */
  60528. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60529. private _createInternalTexture;
  60530. /**
  60531. * Returns the texture matrix used in most of the material.
  60532. */
  60533. getTextureMatrix(): Matrix;
  60534. /**
  60535. * Updates the content of the texture.
  60536. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60537. */
  60538. update(invertY?: Nullable<boolean>): void;
  60539. }
  60540. }
  60541. declare module BABYLON {
  60542. /**
  60543. * Based on jsTGALoader - Javascript loader for TGA file
  60544. * By Vincent Thibault
  60545. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60546. */
  60547. export class TGATools {
  60548. private static _TYPE_INDEXED;
  60549. private static _TYPE_RGB;
  60550. private static _TYPE_GREY;
  60551. private static _TYPE_RLE_INDEXED;
  60552. private static _TYPE_RLE_RGB;
  60553. private static _TYPE_RLE_GREY;
  60554. private static _ORIGIN_MASK;
  60555. private static _ORIGIN_SHIFT;
  60556. private static _ORIGIN_BL;
  60557. private static _ORIGIN_BR;
  60558. private static _ORIGIN_UL;
  60559. private static _ORIGIN_UR;
  60560. /**
  60561. * Gets the header of a TGA file
  60562. * @param data defines the TGA data
  60563. * @returns the header
  60564. */
  60565. static GetTGAHeader(data: Uint8Array): any;
  60566. /**
  60567. * Uploads TGA content to a Babylon Texture
  60568. * @hidden
  60569. */
  60570. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60571. /** @hidden */
  60572. 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;
  60573. /** @hidden */
  60574. 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;
  60575. /** @hidden */
  60576. 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;
  60577. /** @hidden */
  60578. 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;
  60579. /** @hidden */
  60580. 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;
  60581. /** @hidden */
  60582. 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;
  60583. }
  60584. }
  60585. declare module BABYLON {
  60586. /**
  60587. * Implementation of the TGA Texture Loader.
  60588. * @hidden
  60589. */
  60590. export class _TGATextureLoader implements IInternalTextureLoader {
  60591. /**
  60592. * Defines wether the loader supports cascade loading the different faces.
  60593. */
  60594. readonly supportCascades: boolean;
  60595. /**
  60596. * This returns if the loader support the current file information.
  60597. * @param extension defines the file extension of the file being loaded
  60598. * @returns true if the loader can load the specified file
  60599. */
  60600. canLoad(extension: string): boolean;
  60601. /**
  60602. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60603. * @param data contains the texture data
  60604. * @param texture defines the BabylonJS internal texture
  60605. * @param createPolynomials will be true if polynomials have been requested
  60606. * @param onLoad defines the callback to trigger once the texture is ready
  60607. * @param onError defines the callback to trigger in case of error
  60608. */
  60609. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60610. /**
  60611. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60612. * @param data contains the texture data
  60613. * @param texture defines the BabylonJS internal texture
  60614. * @param callback defines the method to call once ready to upload
  60615. */
  60616. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60617. }
  60618. }
  60619. declare module BABYLON {
  60620. /**
  60621. * Info about the .basis files
  60622. */
  60623. class BasisFileInfo {
  60624. /**
  60625. * If the file has alpha
  60626. */
  60627. hasAlpha: boolean;
  60628. /**
  60629. * Info about each image of the basis file
  60630. */
  60631. images: Array<{
  60632. levels: Array<{
  60633. width: number;
  60634. height: number;
  60635. transcodedPixels: ArrayBufferView;
  60636. }>;
  60637. }>;
  60638. }
  60639. /**
  60640. * Result of transcoding a basis file
  60641. */
  60642. class TranscodeResult {
  60643. /**
  60644. * Info about the .basis file
  60645. */
  60646. fileInfo: BasisFileInfo;
  60647. /**
  60648. * Format to use when loading the file
  60649. */
  60650. format: number;
  60651. }
  60652. /**
  60653. * Configuration options for the Basis transcoder
  60654. */
  60655. export class BasisTranscodeConfiguration {
  60656. /**
  60657. * Supported compression formats used to determine the supported output format of the transcoder
  60658. */
  60659. supportedCompressionFormats?: {
  60660. /**
  60661. * etc1 compression format
  60662. */
  60663. etc1?: boolean;
  60664. /**
  60665. * s3tc compression format
  60666. */
  60667. s3tc?: boolean;
  60668. /**
  60669. * pvrtc compression format
  60670. */
  60671. pvrtc?: boolean;
  60672. /**
  60673. * etc2 compression format
  60674. */
  60675. etc2?: boolean;
  60676. };
  60677. /**
  60678. * If mipmap levels should be loaded for transcoded images (Default: true)
  60679. */
  60680. loadMipmapLevels?: boolean;
  60681. /**
  60682. * Index of a single image to load (Default: all images)
  60683. */
  60684. loadSingleImage?: number;
  60685. }
  60686. /**
  60687. * Used to load .Basis files
  60688. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60689. */
  60690. export class BasisTools {
  60691. private static _IgnoreSupportedFormats;
  60692. /**
  60693. * URL to use when loading the basis transcoder
  60694. */
  60695. static JSModuleURL: string;
  60696. /**
  60697. * URL to use when loading the wasm module for the transcoder
  60698. */
  60699. static WasmModuleURL: string;
  60700. /**
  60701. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60702. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60703. * @returns internal format corresponding to the Basis format
  60704. */
  60705. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60706. private static _WorkerPromise;
  60707. private static _Worker;
  60708. private static _actionId;
  60709. private static _CreateWorkerAsync;
  60710. /**
  60711. * Transcodes a loaded image file to compressed pixel data
  60712. * @param data image data to transcode
  60713. * @param config configuration options for the transcoding
  60714. * @returns a promise resulting in the transcoded image
  60715. */
  60716. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60717. /**
  60718. * Loads a texture from the transcode result
  60719. * @param texture texture load to
  60720. * @param transcodeResult the result of transcoding the basis file to load from
  60721. */
  60722. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60723. }
  60724. }
  60725. declare module BABYLON {
  60726. /**
  60727. * Loader for .basis file format
  60728. */
  60729. export class _BasisTextureLoader implements IInternalTextureLoader {
  60730. /**
  60731. * Defines whether the loader supports cascade loading the different faces.
  60732. */
  60733. readonly supportCascades: boolean;
  60734. /**
  60735. * This returns if the loader support the current file information.
  60736. * @param extension defines the file extension of the file being loaded
  60737. * @returns true if the loader can load the specified file
  60738. */
  60739. canLoad(extension: string): boolean;
  60740. /**
  60741. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60742. * @param data contains the texture data
  60743. * @param texture defines the BabylonJS internal texture
  60744. * @param createPolynomials will be true if polynomials have been requested
  60745. * @param onLoad defines the callback to trigger once the texture is ready
  60746. * @param onError defines the callback to trigger in case of error
  60747. */
  60748. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60749. /**
  60750. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60751. * @param data contains the texture data
  60752. * @param texture defines the BabylonJS internal texture
  60753. * @param callback defines the method to call once ready to upload
  60754. */
  60755. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60756. }
  60757. }
  60758. declare module BABYLON {
  60759. /**
  60760. * Defines the basic options interface of a TexturePacker Frame
  60761. */
  60762. export interface ITexturePackerFrame {
  60763. /**
  60764. * The frame ID
  60765. */
  60766. id: number;
  60767. /**
  60768. * The frames Scale
  60769. */
  60770. scale: Vector2;
  60771. /**
  60772. * The Frames offset
  60773. */
  60774. offset: Vector2;
  60775. }
  60776. /**
  60777. * This is a support class for frame Data on texture packer sets.
  60778. */
  60779. export class TexturePackerFrame implements ITexturePackerFrame {
  60780. /**
  60781. * The frame ID
  60782. */
  60783. id: number;
  60784. /**
  60785. * The frames Scale
  60786. */
  60787. scale: Vector2;
  60788. /**
  60789. * The Frames offset
  60790. */
  60791. offset: Vector2;
  60792. /**
  60793. * Initializes a texture package frame.
  60794. * @param id The numerical frame identifier
  60795. * @param scale Scalar Vector2 for UV frame
  60796. * @param offset Vector2 for the frame position in UV units.
  60797. * @returns TexturePackerFrame
  60798. */
  60799. constructor(id: number, scale: Vector2, offset: Vector2);
  60800. }
  60801. }
  60802. declare module BABYLON {
  60803. /**
  60804. * Defines the basic options interface of a TexturePacker
  60805. */
  60806. export interface ITexturePackerOptions {
  60807. /**
  60808. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60809. */
  60810. map?: string[];
  60811. /**
  60812. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60813. */
  60814. uvsIn?: string;
  60815. /**
  60816. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60817. */
  60818. uvsOut?: string;
  60819. /**
  60820. * number representing the layout style. Defaults to LAYOUT_STRIP
  60821. */
  60822. layout?: number;
  60823. /**
  60824. * number of columns if using custom column count layout(2). This defaults to 4.
  60825. */
  60826. colnum?: number;
  60827. /**
  60828. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60829. */
  60830. updateInputMeshes?: boolean;
  60831. /**
  60832. * boolean flag to dispose all the source textures. Defaults to true.
  60833. */
  60834. disposeSources?: boolean;
  60835. /**
  60836. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60837. */
  60838. fillBlanks?: boolean;
  60839. /**
  60840. * string value representing the context fill style color. Defaults to 'black'.
  60841. */
  60842. customFillColor?: string;
  60843. /**
  60844. * Width and Height Value of each Frame in the TexturePacker Sets
  60845. */
  60846. frameSize?: number;
  60847. /**
  60848. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60849. */
  60850. paddingRatio?: number;
  60851. /**
  60852. * Number that declares the fill method for the padding gutter.
  60853. */
  60854. paddingMode?: number;
  60855. /**
  60856. * If in SUBUV_COLOR padding mode what color to use.
  60857. */
  60858. paddingColor?: Color3 | Color4;
  60859. }
  60860. /**
  60861. * Defines the basic interface of a TexturePacker JSON File
  60862. */
  60863. export interface ITexturePackerJSON {
  60864. /**
  60865. * The frame ID
  60866. */
  60867. name: string;
  60868. /**
  60869. * The base64 channel data
  60870. */
  60871. sets: any;
  60872. /**
  60873. * The options of the Packer
  60874. */
  60875. options: ITexturePackerOptions;
  60876. /**
  60877. * The frame data of the Packer
  60878. */
  60879. frames: Array<number>;
  60880. }
  60881. /**
  60882. * This is a support class that generates a series of packed texture sets.
  60883. * @see https://doc.babylonjs.com/babylon101/materials
  60884. */
  60885. export class TexturePacker {
  60886. /** Packer Layout Constant 0 */
  60887. static readonly LAYOUT_STRIP: number;
  60888. /** Packer Layout Constant 1 */
  60889. static readonly LAYOUT_POWER2: number;
  60890. /** Packer Layout Constant 2 */
  60891. static readonly LAYOUT_COLNUM: number;
  60892. /** Packer Layout Constant 0 */
  60893. static readonly SUBUV_WRAP: number;
  60894. /** Packer Layout Constant 1 */
  60895. static readonly SUBUV_EXTEND: number;
  60896. /** Packer Layout Constant 2 */
  60897. static readonly SUBUV_COLOR: number;
  60898. /** The Name of the Texture Package */
  60899. name: string;
  60900. /** The scene scope of the TexturePacker */
  60901. scene: Scene;
  60902. /** The Meshes to target */
  60903. meshes: AbstractMesh[];
  60904. /** Arguments passed with the Constructor */
  60905. options: ITexturePackerOptions;
  60906. /** The promise that is started upon initialization */
  60907. promise: Nullable<Promise<TexturePacker | string>>;
  60908. /** The Container object for the channel sets that are generated */
  60909. sets: object;
  60910. /** The Container array for the frames that are generated */
  60911. frames: TexturePackerFrame[];
  60912. /** The expected number of textures the system is parsing. */
  60913. private _expecting;
  60914. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60915. private _paddingValue;
  60916. /**
  60917. * Initializes a texture package series from an array of meshes or a single mesh.
  60918. * @param name The name of the package
  60919. * @param meshes The target meshes to compose the package from
  60920. * @param options The arguments that texture packer should follow while building.
  60921. * @param scene The scene which the textures are scoped to.
  60922. * @returns TexturePacker
  60923. */
  60924. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60925. /**
  60926. * Starts the package process
  60927. * @param resolve The promises resolution function
  60928. * @returns TexturePacker
  60929. */
  60930. private _createFrames;
  60931. /**
  60932. * Calculates the Size of the Channel Sets
  60933. * @returns Vector2
  60934. */
  60935. private _calculateSize;
  60936. /**
  60937. * Calculates the UV data for the frames.
  60938. * @param baseSize the base frameSize
  60939. * @param padding the base frame padding
  60940. * @param dtSize size of the Dynamic Texture for that channel
  60941. * @param dtUnits is 1/dtSize
  60942. * @param update flag to update the input meshes
  60943. */
  60944. private _calculateMeshUVFrames;
  60945. /**
  60946. * Calculates the frames Offset.
  60947. * @param index of the frame
  60948. * @returns Vector2
  60949. */
  60950. private _getFrameOffset;
  60951. /**
  60952. * Updates a Mesh to the frame data
  60953. * @param mesh that is the target
  60954. * @param frameID or the frame index
  60955. */
  60956. private _updateMeshUV;
  60957. /**
  60958. * Updates a Meshes materials to use the texture packer channels
  60959. * @param m is the mesh to target
  60960. * @param force all channels on the packer to be set.
  60961. */
  60962. private _updateTextureReferences;
  60963. /**
  60964. * Public method to set a Mesh to a frame
  60965. * @param m that is the target
  60966. * @param frameID or the frame index
  60967. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60968. */
  60969. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60970. /**
  60971. * Starts the async promise to compile the texture packer.
  60972. * @returns Promise<void>
  60973. */
  60974. processAsync(): Promise<void>;
  60975. /**
  60976. * Disposes all textures associated with this packer
  60977. */
  60978. dispose(): void;
  60979. /**
  60980. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60981. * @param imageType is the image type to use.
  60982. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60983. */
  60984. download(imageType?: string, quality?: number): void;
  60985. /**
  60986. * Public method to load a texturePacker JSON file.
  60987. * @param data of the JSON file in string format.
  60988. */
  60989. updateFromJSON(data: string): void;
  60990. }
  60991. }
  60992. declare module BABYLON {
  60993. /**
  60994. * 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.
  60995. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60996. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60997. */
  60998. export class CustomProceduralTexture extends ProceduralTexture {
  60999. private _animate;
  61000. private _time;
  61001. private _config;
  61002. private _texturePath;
  61003. /**
  61004. * Instantiates a new Custom Procedural Texture.
  61005. * 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.
  61006. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61007. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61008. * @param name Define the name of the texture
  61009. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61010. * @param size Define the size of the texture to create
  61011. * @param scene Define the scene the texture belongs to
  61012. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61013. * @param generateMipMaps Define if the texture should creates mip maps or not
  61014. */
  61015. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61016. private _loadJson;
  61017. /**
  61018. * Is the texture ready to be used ? (rendered at least once)
  61019. * @returns true if ready, otherwise, false.
  61020. */
  61021. isReady(): boolean;
  61022. /**
  61023. * Render the texture to its associated render target.
  61024. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61025. */
  61026. render(useCameraPostProcess?: boolean): void;
  61027. /**
  61028. * Update the list of dependant textures samplers in the shader.
  61029. */
  61030. updateTextures(): void;
  61031. /**
  61032. * Update the uniform values of the procedural texture in the shader.
  61033. */
  61034. updateShaderUniforms(): void;
  61035. /**
  61036. * Define if the texture animates or not.
  61037. */
  61038. get animate(): boolean;
  61039. set animate(value: boolean);
  61040. }
  61041. }
  61042. declare module BABYLON {
  61043. /** @hidden */
  61044. export var noisePixelShader: {
  61045. name: string;
  61046. shader: string;
  61047. };
  61048. }
  61049. declare module BABYLON {
  61050. /**
  61051. * Class used to generate noise procedural textures
  61052. */
  61053. export class NoiseProceduralTexture extends ProceduralTexture {
  61054. private _time;
  61055. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61056. brightness: number;
  61057. /** Defines the number of octaves to process */
  61058. octaves: number;
  61059. /** Defines the level of persistence (0.8 by default) */
  61060. persistence: number;
  61061. /** Gets or sets animation speed factor (default is 1) */
  61062. animationSpeedFactor: number;
  61063. /**
  61064. * Creates a new NoiseProceduralTexture
  61065. * @param name defines the name fo the texture
  61066. * @param size defines the size of the texture (default is 256)
  61067. * @param scene defines the hosting scene
  61068. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61069. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61070. */
  61071. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61072. private _updateShaderUniforms;
  61073. protected _getDefines(): string;
  61074. /** Generate the current state of the procedural texture */
  61075. render(useCameraPostProcess?: boolean): void;
  61076. /**
  61077. * Serializes this noise procedural texture
  61078. * @returns a serialized noise procedural texture object
  61079. */
  61080. serialize(): any;
  61081. /**
  61082. * Clone the texture.
  61083. * @returns the cloned texture
  61084. */
  61085. clone(): NoiseProceduralTexture;
  61086. /**
  61087. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61088. * @param parsedTexture defines parsed texture data
  61089. * @param scene defines the current scene
  61090. * @param rootUrl defines the root URL containing noise procedural texture information
  61091. * @returns a parsed NoiseProceduralTexture
  61092. */
  61093. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61094. }
  61095. }
  61096. declare module BABYLON {
  61097. /**
  61098. * Raw cube texture where the raw buffers are passed in
  61099. */
  61100. export class RawCubeTexture extends CubeTexture {
  61101. /**
  61102. * Creates a cube texture where the raw buffers are passed in.
  61103. * @param scene defines the scene the texture is attached to
  61104. * @param data defines the array of data to use to create each face
  61105. * @param size defines the size of the textures
  61106. * @param format defines the format of the data
  61107. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61108. * @param generateMipMaps defines if the engine should generate the mip levels
  61109. * @param invertY defines if data must be stored with Y axis inverted
  61110. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61111. * @param compression defines the compression used (null by default)
  61112. */
  61113. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61114. /**
  61115. * Updates the raw cube texture.
  61116. * @param data defines the data to store
  61117. * @param format defines the data format
  61118. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61119. * @param invertY defines if data must be stored with Y axis inverted
  61120. * @param compression defines the compression used (null by default)
  61121. * @param level defines which level of the texture to update
  61122. */
  61123. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61124. /**
  61125. * Updates a raw cube texture with RGBD encoded data.
  61126. * @param data defines the array of data [mipmap][face] to use to create each face
  61127. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61128. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61129. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61130. * @returns a promsie that resolves when the operation is complete
  61131. */
  61132. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61133. /**
  61134. * Clones the raw cube texture.
  61135. * @return a new cube texture
  61136. */
  61137. clone(): CubeTexture;
  61138. /** @hidden */
  61139. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61140. }
  61141. }
  61142. declare module BABYLON {
  61143. /**
  61144. * Class used to store 2D array textures containing user data
  61145. */
  61146. export class RawTexture2DArray extends Texture {
  61147. /** Gets or sets the texture format to use */
  61148. format: number;
  61149. /**
  61150. * Create a new RawTexture2DArray
  61151. * @param data defines the data of the texture
  61152. * @param width defines the width of the texture
  61153. * @param height defines the height of the texture
  61154. * @param depth defines the number of layers of the texture
  61155. * @param format defines the texture format to use
  61156. * @param scene defines the hosting scene
  61157. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61158. * @param invertY defines if texture must be stored with Y axis inverted
  61159. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61160. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61161. */
  61162. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61163. /** Gets or sets the texture format to use */
  61164. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61165. /**
  61166. * Update the texture with new data
  61167. * @param data defines the data to store in the texture
  61168. */
  61169. update(data: ArrayBufferView): void;
  61170. }
  61171. }
  61172. declare module BABYLON {
  61173. /**
  61174. * Class used to store 3D textures containing user data
  61175. */
  61176. export class RawTexture3D extends Texture {
  61177. /** Gets or sets the texture format to use */
  61178. format: number;
  61179. /**
  61180. * Create a new RawTexture3D
  61181. * @param data defines the data of the texture
  61182. * @param width defines the width of the texture
  61183. * @param height defines the height of the texture
  61184. * @param depth defines the depth of the texture
  61185. * @param format defines the texture format to use
  61186. * @param scene defines the hosting scene
  61187. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61188. * @param invertY defines if texture must be stored with Y axis inverted
  61189. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61190. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61191. */
  61192. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61193. /** Gets or sets the texture format to use */
  61194. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61195. /**
  61196. * Update the texture with new data
  61197. * @param data defines the data to store in the texture
  61198. */
  61199. update(data: ArrayBufferView): void;
  61200. }
  61201. }
  61202. declare module BABYLON {
  61203. /**
  61204. * Creates a refraction texture used by refraction channel of the standard material.
  61205. * It is like a mirror but to see through a material.
  61206. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61207. */
  61208. export class RefractionTexture extends RenderTargetTexture {
  61209. /**
  61210. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61211. * 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.
  61212. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61213. */
  61214. refractionPlane: Plane;
  61215. /**
  61216. * Define how deep under the surface we should see.
  61217. */
  61218. depth: number;
  61219. /**
  61220. * Creates a refraction texture used by refraction channel of the standard material.
  61221. * It is like a mirror but to see through a material.
  61222. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61223. * @param name Define the texture name
  61224. * @param size Define the size of the underlying texture
  61225. * @param scene Define the scene the refraction belongs to
  61226. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61227. */
  61228. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61229. /**
  61230. * Clone the refraction texture.
  61231. * @returns the cloned texture
  61232. */
  61233. clone(): RefractionTexture;
  61234. /**
  61235. * Serialize the texture to a JSON representation you could use in Parse later on
  61236. * @returns the serialized JSON representation
  61237. */
  61238. serialize(): any;
  61239. }
  61240. }
  61241. declare module BABYLON {
  61242. /**
  61243. * Block used to add support for vertex skinning (bones)
  61244. */
  61245. export class BonesBlock extends NodeMaterialBlock {
  61246. /**
  61247. * Creates a new BonesBlock
  61248. * @param name defines the block name
  61249. */
  61250. constructor(name: string);
  61251. /**
  61252. * Initialize the block and prepare the context for build
  61253. * @param state defines the state that will be used for the build
  61254. */
  61255. initialize(state: NodeMaterialBuildState): void;
  61256. /**
  61257. * Gets the current class name
  61258. * @returns the class name
  61259. */
  61260. getClassName(): string;
  61261. /**
  61262. * Gets the matrix indices input component
  61263. */
  61264. get matricesIndices(): NodeMaterialConnectionPoint;
  61265. /**
  61266. * Gets the matrix weights input component
  61267. */
  61268. get matricesWeights(): NodeMaterialConnectionPoint;
  61269. /**
  61270. * Gets the extra matrix indices input component
  61271. */
  61272. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61273. /**
  61274. * Gets the extra matrix weights input component
  61275. */
  61276. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61277. /**
  61278. * Gets the world input component
  61279. */
  61280. get world(): NodeMaterialConnectionPoint;
  61281. /**
  61282. * Gets the output component
  61283. */
  61284. get output(): NodeMaterialConnectionPoint;
  61285. autoConfigure(material: NodeMaterial): void;
  61286. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61287. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61289. protected _buildBlock(state: NodeMaterialBuildState): this;
  61290. }
  61291. }
  61292. declare module BABYLON {
  61293. /**
  61294. * Block used to add support for instances
  61295. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61296. */
  61297. export class InstancesBlock extends NodeMaterialBlock {
  61298. /**
  61299. * Creates a new InstancesBlock
  61300. * @param name defines the block name
  61301. */
  61302. constructor(name: string);
  61303. /**
  61304. * Gets the current class name
  61305. * @returns the class name
  61306. */
  61307. getClassName(): string;
  61308. /**
  61309. * Gets the first world row input component
  61310. */
  61311. get world0(): NodeMaterialConnectionPoint;
  61312. /**
  61313. * Gets the second world row input component
  61314. */
  61315. get world1(): NodeMaterialConnectionPoint;
  61316. /**
  61317. * Gets the third world row input component
  61318. */
  61319. get world2(): NodeMaterialConnectionPoint;
  61320. /**
  61321. * Gets the forth world row input component
  61322. */
  61323. get world3(): NodeMaterialConnectionPoint;
  61324. /**
  61325. * Gets the world input component
  61326. */
  61327. get world(): NodeMaterialConnectionPoint;
  61328. /**
  61329. * Gets the output component
  61330. */
  61331. get output(): NodeMaterialConnectionPoint;
  61332. /**
  61333. * Gets the isntanceID component
  61334. */
  61335. get instanceID(): NodeMaterialConnectionPoint;
  61336. autoConfigure(material: NodeMaterial): void;
  61337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61338. protected _buildBlock(state: NodeMaterialBuildState): this;
  61339. }
  61340. }
  61341. declare module BABYLON {
  61342. /**
  61343. * Block used to add morph targets support to vertex shader
  61344. */
  61345. export class MorphTargetsBlock extends NodeMaterialBlock {
  61346. private _repeatableContentAnchor;
  61347. /**
  61348. * Create a new MorphTargetsBlock
  61349. * @param name defines the block name
  61350. */
  61351. constructor(name: string);
  61352. /**
  61353. * Gets the current class name
  61354. * @returns the class name
  61355. */
  61356. getClassName(): string;
  61357. /**
  61358. * Gets the position input component
  61359. */
  61360. get position(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the normal input component
  61363. */
  61364. get normal(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the tangent input component
  61367. */
  61368. get tangent(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the tangent input component
  61371. */
  61372. get uv(): NodeMaterialConnectionPoint;
  61373. /**
  61374. * Gets the position output component
  61375. */
  61376. get positionOutput(): NodeMaterialConnectionPoint;
  61377. /**
  61378. * Gets the normal output component
  61379. */
  61380. get normalOutput(): NodeMaterialConnectionPoint;
  61381. /**
  61382. * Gets the tangent output component
  61383. */
  61384. get tangentOutput(): NodeMaterialConnectionPoint;
  61385. /**
  61386. * Gets the tangent output component
  61387. */
  61388. get uvOutput(): NodeMaterialConnectionPoint;
  61389. initialize(state: NodeMaterialBuildState): void;
  61390. autoConfigure(material: NodeMaterial): void;
  61391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61393. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61394. protected _buildBlock(state: NodeMaterialBuildState): this;
  61395. }
  61396. }
  61397. declare module BABYLON {
  61398. /**
  61399. * Block used to get data information from a light
  61400. */
  61401. export class LightInformationBlock extends NodeMaterialBlock {
  61402. private _lightDataUniformName;
  61403. private _lightColorUniformName;
  61404. private _lightTypeDefineName;
  61405. /**
  61406. * Gets or sets the light associated with this block
  61407. */
  61408. light: Nullable<Light>;
  61409. /**
  61410. * Creates a new LightInformationBlock
  61411. * @param name defines the block name
  61412. */
  61413. constructor(name: string);
  61414. /**
  61415. * Gets the current class name
  61416. * @returns the class name
  61417. */
  61418. getClassName(): string;
  61419. /**
  61420. * Gets the world position input component
  61421. */
  61422. get worldPosition(): NodeMaterialConnectionPoint;
  61423. /**
  61424. * Gets the direction output component
  61425. */
  61426. get direction(): NodeMaterialConnectionPoint;
  61427. /**
  61428. * Gets the direction output component
  61429. */
  61430. get color(): NodeMaterialConnectionPoint;
  61431. /**
  61432. * Gets the direction output component
  61433. */
  61434. get intensity(): NodeMaterialConnectionPoint;
  61435. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61436. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61437. protected _buildBlock(state: NodeMaterialBuildState): this;
  61438. serialize(): any;
  61439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61440. }
  61441. }
  61442. declare module BABYLON {
  61443. /**
  61444. * Block used to add image processing support to fragment shader
  61445. */
  61446. export class ImageProcessingBlock extends NodeMaterialBlock {
  61447. /**
  61448. * Create a new ImageProcessingBlock
  61449. * @param name defines the block name
  61450. */
  61451. constructor(name: string);
  61452. /**
  61453. * Gets the current class name
  61454. * @returns the class name
  61455. */
  61456. getClassName(): string;
  61457. /**
  61458. * Gets the color input component
  61459. */
  61460. get color(): NodeMaterialConnectionPoint;
  61461. /**
  61462. * Gets the output component
  61463. */
  61464. get output(): NodeMaterialConnectionPoint;
  61465. /**
  61466. * Initialize the block and prepare the context for build
  61467. * @param state defines the state that will be used for the build
  61468. */
  61469. initialize(state: NodeMaterialBuildState): void;
  61470. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61473. protected _buildBlock(state: NodeMaterialBuildState): this;
  61474. }
  61475. }
  61476. declare module BABYLON {
  61477. /**
  61478. * Block used to pertub normals based on a normal map
  61479. */
  61480. export class PerturbNormalBlock extends NodeMaterialBlock {
  61481. private _tangentSpaceParameterName;
  61482. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61483. invertX: boolean;
  61484. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61485. invertY: boolean;
  61486. /**
  61487. * Create a new PerturbNormalBlock
  61488. * @param name defines the block name
  61489. */
  61490. constructor(name: string);
  61491. /**
  61492. * Gets the current class name
  61493. * @returns the class name
  61494. */
  61495. getClassName(): string;
  61496. /**
  61497. * Gets the world position input component
  61498. */
  61499. get worldPosition(): NodeMaterialConnectionPoint;
  61500. /**
  61501. * Gets the world normal input component
  61502. */
  61503. get worldNormal(): NodeMaterialConnectionPoint;
  61504. /**
  61505. * Gets the world tangent input component
  61506. */
  61507. get worldTangent(): NodeMaterialConnectionPoint;
  61508. /**
  61509. * Gets the uv input component
  61510. */
  61511. get uv(): NodeMaterialConnectionPoint;
  61512. /**
  61513. * Gets the normal map color input component
  61514. */
  61515. get normalMapColor(): NodeMaterialConnectionPoint;
  61516. /**
  61517. * Gets the strength input component
  61518. */
  61519. get strength(): NodeMaterialConnectionPoint;
  61520. /**
  61521. * Gets the output component
  61522. */
  61523. get output(): NodeMaterialConnectionPoint;
  61524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61526. autoConfigure(material: NodeMaterial): void;
  61527. protected _buildBlock(state: NodeMaterialBuildState): this;
  61528. protected _dumpPropertiesCode(): string;
  61529. serialize(): any;
  61530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61531. }
  61532. }
  61533. declare module BABYLON {
  61534. /**
  61535. * Block used to discard a pixel if a value is smaller than a cutoff
  61536. */
  61537. export class DiscardBlock extends NodeMaterialBlock {
  61538. /**
  61539. * Create a new DiscardBlock
  61540. * @param name defines the block name
  61541. */
  61542. constructor(name: string);
  61543. /**
  61544. * Gets the current class name
  61545. * @returns the class name
  61546. */
  61547. getClassName(): string;
  61548. /**
  61549. * Gets the color input component
  61550. */
  61551. get value(): NodeMaterialConnectionPoint;
  61552. /**
  61553. * Gets the cutoff input component
  61554. */
  61555. get cutoff(): NodeMaterialConnectionPoint;
  61556. protected _buildBlock(state: NodeMaterialBuildState): this;
  61557. }
  61558. }
  61559. declare module BABYLON {
  61560. /**
  61561. * Block used to test if the fragment shader is front facing
  61562. */
  61563. export class FrontFacingBlock extends NodeMaterialBlock {
  61564. /**
  61565. * Creates a new FrontFacingBlock
  61566. * @param name defines the block name
  61567. */
  61568. constructor(name: string);
  61569. /**
  61570. * Gets the current class name
  61571. * @returns the class name
  61572. */
  61573. getClassName(): string;
  61574. /**
  61575. * Gets the output component
  61576. */
  61577. get output(): NodeMaterialConnectionPoint;
  61578. protected _buildBlock(state: NodeMaterialBuildState): this;
  61579. }
  61580. }
  61581. declare module BABYLON {
  61582. /**
  61583. * Block used to get the derivative value on x and y of a given input
  61584. */
  61585. export class DerivativeBlock extends NodeMaterialBlock {
  61586. /**
  61587. * Create a new DerivativeBlock
  61588. * @param name defines the block name
  61589. */
  61590. constructor(name: string);
  61591. /**
  61592. * Gets the current class name
  61593. * @returns the class name
  61594. */
  61595. getClassName(): string;
  61596. /**
  61597. * Gets the input component
  61598. */
  61599. get input(): NodeMaterialConnectionPoint;
  61600. /**
  61601. * Gets the derivative output on x
  61602. */
  61603. get dx(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the derivative output on y
  61606. */
  61607. get dy(): NodeMaterialConnectionPoint;
  61608. protected _buildBlock(state: NodeMaterialBuildState): this;
  61609. }
  61610. }
  61611. declare module BABYLON {
  61612. /**
  61613. * Block used to make gl_FragCoord available
  61614. */
  61615. export class FragCoordBlock extends NodeMaterialBlock {
  61616. /**
  61617. * Creates a new FragCoordBlock
  61618. * @param name defines the block name
  61619. */
  61620. constructor(name: string);
  61621. /**
  61622. * Gets the current class name
  61623. * @returns the class name
  61624. */
  61625. getClassName(): string;
  61626. /**
  61627. * Gets the xy component
  61628. */
  61629. get xy(): NodeMaterialConnectionPoint;
  61630. /**
  61631. * Gets the xyz component
  61632. */
  61633. get xyz(): NodeMaterialConnectionPoint;
  61634. /**
  61635. * Gets the xyzw component
  61636. */
  61637. get xyzw(): NodeMaterialConnectionPoint;
  61638. /**
  61639. * Gets the x component
  61640. */
  61641. get x(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the y component
  61644. */
  61645. get y(): NodeMaterialConnectionPoint;
  61646. /**
  61647. * Gets the z component
  61648. */
  61649. get z(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the w component
  61652. */
  61653. get output(): NodeMaterialConnectionPoint;
  61654. protected writeOutputs(state: NodeMaterialBuildState): string;
  61655. protected _buildBlock(state: NodeMaterialBuildState): this;
  61656. }
  61657. }
  61658. declare module BABYLON {
  61659. /**
  61660. * Block used to get the screen sizes
  61661. */
  61662. export class ScreenSizeBlock extends NodeMaterialBlock {
  61663. private _varName;
  61664. private _scene;
  61665. /**
  61666. * Creates a new ScreenSizeBlock
  61667. * @param name defines the block name
  61668. */
  61669. constructor(name: string);
  61670. /**
  61671. * Gets the current class name
  61672. * @returns the class name
  61673. */
  61674. getClassName(): string;
  61675. /**
  61676. * Gets the xy component
  61677. */
  61678. get xy(): NodeMaterialConnectionPoint;
  61679. /**
  61680. * Gets the x component
  61681. */
  61682. get x(): NodeMaterialConnectionPoint;
  61683. /**
  61684. * Gets the y component
  61685. */
  61686. get y(): NodeMaterialConnectionPoint;
  61687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61688. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61689. protected _buildBlock(state: NodeMaterialBuildState): this;
  61690. }
  61691. }
  61692. declare module BABYLON {
  61693. /**
  61694. * Block used to add support for scene fog
  61695. */
  61696. export class FogBlock extends NodeMaterialBlock {
  61697. private _fogDistanceName;
  61698. private _fogParameters;
  61699. /**
  61700. * Create a new FogBlock
  61701. * @param name defines the block name
  61702. */
  61703. constructor(name: string);
  61704. /**
  61705. * Gets the current class name
  61706. * @returns the class name
  61707. */
  61708. getClassName(): string;
  61709. /**
  61710. * Gets the world position input component
  61711. */
  61712. get worldPosition(): NodeMaterialConnectionPoint;
  61713. /**
  61714. * Gets the view input component
  61715. */
  61716. get view(): NodeMaterialConnectionPoint;
  61717. /**
  61718. * Gets the color input component
  61719. */
  61720. get input(): NodeMaterialConnectionPoint;
  61721. /**
  61722. * Gets the fog color input component
  61723. */
  61724. get fogColor(): NodeMaterialConnectionPoint;
  61725. /**
  61726. * Gets the output component
  61727. */
  61728. get output(): NodeMaterialConnectionPoint;
  61729. autoConfigure(material: NodeMaterial): void;
  61730. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61732. protected _buildBlock(state: NodeMaterialBuildState): this;
  61733. }
  61734. }
  61735. declare module BABYLON {
  61736. /**
  61737. * Block used to add light in the fragment shader
  61738. */
  61739. export class LightBlock extends NodeMaterialBlock {
  61740. private _lightId;
  61741. /**
  61742. * Gets or sets the light associated with this block
  61743. */
  61744. light: Nullable<Light>;
  61745. /**
  61746. * Create a new LightBlock
  61747. * @param name defines the block name
  61748. */
  61749. constructor(name: string);
  61750. /**
  61751. * Gets the current class name
  61752. * @returns the class name
  61753. */
  61754. getClassName(): string;
  61755. /**
  61756. * Gets the world position input component
  61757. */
  61758. get worldPosition(): NodeMaterialConnectionPoint;
  61759. /**
  61760. * Gets the world normal input component
  61761. */
  61762. get worldNormal(): NodeMaterialConnectionPoint;
  61763. /**
  61764. * Gets the camera (or eye) position component
  61765. */
  61766. get cameraPosition(): NodeMaterialConnectionPoint;
  61767. /**
  61768. * Gets the glossiness component
  61769. */
  61770. get glossiness(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the glossinness power component
  61773. */
  61774. get glossPower(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the diffuse color component
  61777. */
  61778. get diffuseColor(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the specular color component
  61781. */
  61782. get specularColor(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the diffuse output component
  61785. */
  61786. get diffuseOutput(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the specular output component
  61789. */
  61790. get specularOutput(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the shadow output component
  61793. */
  61794. get shadow(): NodeMaterialConnectionPoint;
  61795. autoConfigure(material: NodeMaterial): void;
  61796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61797. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61799. private _injectVertexCode;
  61800. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61801. serialize(): any;
  61802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61803. }
  61804. }
  61805. declare module BABYLON {
  61806. /**
  61807. * Block used to read a reflection texture from a sampler
  61808. */
  61809. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61810. /**
  61811. * Create a new ReflectionTextureBlock
  61812. * @param name defines the block name
  61813. */
  61814. constructor(name: string);
  61815. /**
  61816. * Gets the current class name
  61817. * @returns the class name
  61818. */
  61819. getClassName(): string;
  61820. /**
  61821. * Gets the world position input component
  61822. */
  61823. get position(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the world position input component
  61826. */
  61827. get worldPosition(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the world normal input component
  61830. */
  61831. get worldNormal(): NodeMaterialConnectionPoint;
  61832. /**
  61833. * Gets the world input component
  61834. */
  61835. get world(): NodeMaterialConnectionPoint;
  61836. /**
  61837. * Gets the camera (or eye) position component
  61838. */
  61839. get cameraPosition(): NodeMaterialConnectionPoint;
  61840. /**
  61841. * Gets the view input component
  61842. */
  61843. get view(): NodeMaterialConnectionPoint;
  61844. /**
  61845. * Gets the rgb output component
  61846. */
  61847. get rgb(): NodeMaterialConnectionPoint;
  61848. /**
  61849. * Gets the rgba output component
  61850. */
  61851. get rgba(): NodeMaterialConnectionPoint;
  61852. /**
  61853. * Gets the r output component
  61854. */
  61855. get r(): NodeMaterialConnectionPoint;
  61856. /**
  61857. * Gets the g output component
  61858. */
  61859. get g(): NodeMaterialConnectionPoint;
  61860. /**
  61861. * Gets the b output component
  61862. */
  61863. get b(): NodeMaterialConnectionPoint;
  61864. /**
  61865. * Gets the a output component
  61866. */
  61867. get a(): NodeMaterialConnectionPoint;
  61868. autoConfigure(material: NodeMaterial): void;
  61869. protected _buildBlock(state: NodeMaterialBuildState): this;
  61870. }
  61871. }
  61872. declare module BABYLON {
  61873. /**
  61874. * Block used to add 2 vectors
  61875. */
  61876. export class AddBlock extends NodeMaterialBlock {
  61877. /**
  61878. * Creates a new AddBlock
  61879. * @param name defines the block name
  61880. */
  61881. constructor(name: string);
  61882. /**
  61883. * Gets the current class name
  61884. * @returns the class name
  61885. */
  61886. getClassName(): string;
  61887. /**
  61888. * Gets the left operand input component
  61889. */
  61890. get left(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the right operand input component
  61893. */
  61894. get right(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the output component
  61897. */
  61898. get output(): NodeMaterialConnectionPoint;
  61899. protected _buildBlock(state: NodeMaterialBuildState): this;
  61900. }
  61901. }
  61902. declare module BABYLON {
  61903. /**
  61904. * Block used to scale a vector by a float
  61905. */
  61906. export class ScaleBlock extends NodeMaterialBlock {
  61907. /**
  61908. * Creates a new ScaleBlock
  61909. * @param name defines the block name
  61910. */
  61911. constructor(name: string);
  61912. /**
  61913. * Gets the current class name
  61914. * @returns the class name
  61915. */
  61916. getClassName(): string;
  61917. /**
  61918. * Gets the input component
  61919. */
  61920. get input(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the factor input component
  61923. */
  61924. get factor(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the output component
  61927. */
  61928. get output(): NodeMaterialConnectionPoint;
  61929. protected _buildBlock(state: NodeMaterialBuildState): this;
  61930. }
  61931. }
  61932. declare module BABYLON {
  61933. /**
  61934. * Block used to clamp a float
  61935. */
  61936. export class ClampBlock extends NodeMaterialBlock {
  61937. /** Gets or sets the minimum range */
  61938. minimum: number;
  61939. /** Gets or sets the maximum range */
  61940. maximum: number;
  61941. /**
  61942. * Creates a new ClampBlock
  61943. * @param name defines the block name
  61944. */
  61945. constructor(name: string);
  61946. /**
  61947. * Gets the current class name
  61948. * @returns the class name
  61949. */
  61950. getClassName(): string;
  61951. /**
  61952. * Gets the value input component
  61953. */
  61954. get value(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the output component
  61957. */
  61958. get output(): NodeMaterialConnectionPoint;
  61959. protected _buildBlock(state: NodeMaterialBuildState): this;
  61960. protected _dumpPropertiesCode(): string;
  61961. serialize(): any;
  61962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61963. }
  61964. }
  61965. declare module BABYLON {
  61966. /**
  61967. * Block used to apply a cross product between 2 vectors
  61968. */
  61969. export class CrossBlock extends NodeMaterialBlock {
  61970. /**
  61971. * Creates a new CrossBlock
  61972. * @param name defines the block name
  61973. */
  61974. constructor(name: string);
  61975. /**
  61976. * Gets the current class name
  61977. * @returns the class name
  61978. */
  61979. getClassName(): string;
  61980. /**
  61981. * Gets the left operand input component
  61982. */
  61983. get left(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the right operand input component
  61986. */
  61987. get right(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the output component
  61990. */
  61991. get output(): NodeMaterialConnectionPoint;
  61992. protected _buildBlock(state: NodeMaterialBuildState): this;
  61993. }
  61994. }
  61995. declare module BABYLON {
  61996. /**
  61997. * Block used to apply a dot product between 2 vectors
  61998. */
  61999. export class DotBlock extends NodeMaterialBlock {
  62000. /**
  62001. * Creates a new DotBlock
  62002. * @param name defines the block name
  62003. */
  62004. constructor(name: string);
  62005. /**
  62006. * Gets the current class name
  62007. * @returns the class name
  62008. */
  62009. getClassName(): string;
  62010. /**
  62011. * Gets the left operand input component
  62012. */
  62013. get left(): NodeMaterialConnectionPoint;
  62014. /**
  62015. * Gets the right operand input component
  62016. */
  62017. get right(): NodeMaterialConnectionPoint;
  62018. /**
  62019. * Gets the output component
  62020. */
  62021. get output(): NodeMaterialConnectionPoint;
  62022. protected _buildBlock(state: NodeMaterialBuildState): this;
  62023. }
  62024. }
  62025. declare module BABYLON {
  62026. /**
  62027. * Block used to normalize a vector
  62028. */
  62029. export class NormalizeBlock extends NodeMaterialBlock {
  62030. /**
  62031. * Creates a new NormalizeBlock
  62032. * @param name defines the block name
  62033. */
  62034. constructor(name: string);
  62035. /**
  62036. * Gets the current class name
  62037. * @returns the class name
  62038. */
  62039. getClassName(): string;
  62040. /**
  62041. * Gets the input component
  62042. */
  62043. get input(): NodeMaterialConnectionPoint;
  62044. /**
  62045. * Gets the output component
  62046. */
  62047. get output(): NodeMaterialConnectionPoint;
  62048. protected _buildBlock(state: NodeMaterialBuildState): this;
  62049. }
  62050. }
  62051. declare module BABYLON {
  62052. /**
  62053. * Operations supported by the Trigonometry block
  62054. */
  62055. export enum TrigonometryBlockOperations {
  62056. /** Cos */
  62057. Cos = 0,
  62058. /** Sin */
  62059. Sin = 1,
  62060. /** Abs */
  62061. Abs = 2,
  62062. /** Exp */
  62063. Exp = 3,
  62064. /** Exp2 */
  62065. Exp2 = 4,
  62066. /** Round */
  62067. Round = 5,
  62068. /** Floor */
  62069. Floor = 6,
  62070. /** Ceiling */
  62071. Ceiling = 7,
  62072. /** Square root */
  62073. Sqrt = 8,
  62074. /** Log */
  62075. Log = 9,
  62076. /** Tangent */
  62077. Tan = 10,
  62078. /** Arc tangent */
  62079. ArcTan = 11,
  62080. /** Arc cosinus */
  62081. ArcCos = 12,
  62082. /** Arc sinus */
  62083. ArcSin = 13,
  62084. /** Fraction */
  62085. Fract = 14,
  62086. /** Sign */
  62087. Sign = 15,
  62088. /** To radians (from degrees) */
  62089. Radians = 16,
  62090. /** To degrees (from radians) */
  62091. Degrees = 17
  62092. }
  62093. /**
  62094. * Block used to apply trigonometry operation to floats
  62095. */
  62096. export class TrigonometryBlock extends NodeMaterialBlock {
  62097. /**
  62098. * Gets or sets the operation applied by the block
  62099. */
  62100. operation: TrigonometryBlockOperations;
  62101. /**
  62102. * Creates a new TrigonometryBlock
  62103. * @param name defines the block name
  62104. */
  62105. constructor(name: string);
  62106. /**
  62107. * Gets the current class name
  62108. * @returns the class name
  62109. */
  62110. getClassName(): string;
  62111. /**
  62112. * Gets the input component
  62113. */
  62114. get input(): NodeMaterialConnectionPoint;
  62115. /**
  62116. * Gets the output component
  62117. */
  62118. get output(): NodeMaterialConnectionPoint;
  62119. protected _buildBlock(state: NodeMaterialBuildState): this;
  62120. serialize(): any;
  62121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62122. protected _dumpPropertiesCode(): string;
  62123. }
  62124. }
  62125. declare module BABYLON {
  62126. /**
  62127. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62128. */
  62129. export class ColorMergerBlock extends NodeMaterialBlock {
  62130. /**
  62131. * Create a new ColorMergerBlock
  62132. * @param name defines the block name
  62133. */
  62134. constructor(name: string);
  62135. /**
  62136. * Gets the current class name
  62137. * @returns the class name
  62138. */
  62139. getClassName(): string;
  62140. /**
  62141. * Gets the rgb component (input)
  62142. */
  62143. get rgbIn(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the r component (input)
  62146. */
  62147. get r(): NodeMaterialConnectionPoint;
  62148. /**
  62149. * Gets the g component (input)
  62150. */
  62151. get g(): NodeMaterialConnectionPoint;
  62152. /**
  62153. * Gets the b component (input)
  62154. */
  62155. get b(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the a component (input)
  62158. */
  62159. get a(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the rgba component (output)
  62162. */
  62163. get rgba(): NodeMaterialConnectionPoint;
  62164. /**
  62165. * Gets the rgb component (output)
  62166. */
  62167. get rgbOut(): NodeMaterialConnectionPoint;
  62168. /**
  62169. * Gets the rgb component (output)
  62170. * @deprecated Please use rgbOut instead.
  62171. */
  62172. get rgb(): NodeMaterialConnectionPoint;
  62173. protected _buildBlock(state: NodeMaterialBuildState): this;
  62174. }
  62175. }
  62176. declare module BABYLON {
  62177. /**
  62178. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62179. */
  62180. export class VectorSplitterBlock extends NodeMaterialBlock {
  62181. /**
  62182. * Create a new VectorSplitterBlock
  62183. * @param name defines the block name
  62184. */
  62185. constructor(name: string);
  62186. /**
  62187. * Gets the current class name
  62188. * @returns the class name
  62189. */
  62190. getClassName(): string;
  62191. /**
  62192. * Gets the xyzw component (input)
  62193. */
  62194. get xyzw(): NodeMaterialConnectionPoint;
  62195. /**
  62196. * Gets the xyz component (input)
  62197. */
  62198. get xyzIn(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the xy component (input)
  62201. */
  62202. get xyIn(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the xyz component (output)
  62205. */
  62206. get xyzOut(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the xy component (output)
  62209. */
  62210. get xyOut(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the x component (output)
  62213. */
  62214. get x(): NodeMaterialConnectionPoint;
  62215. /**
  62216. * Gets the y component (output)
  62217. */
  62218. get y(): NodeMaterialConnectionPoint;
  62219. /**
  62220. * Gets the z component (output)
  62221. */
  62222. get z(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the w component (output)
  62225. */
  62226. get w(): NodeMaterialConnectionPoint;
  62227. protected _inputRename(name: string): string;
  62228. protected _outputRename(name: string): string;
  62229. protected _buildBlock(state: NodeMaterialBuildState): this;
  62230. }
  62231. }
  62232. declare module BABYLON {
  62233. /**
  62234. * Block used to lerp between 2 values
  62235. */
  62236. export class LerpBlock extends NodeMaterialBlock {
  62237. /**
  62238. * Creates a new LerpBlock
  62239. * @param name defines the block name
  62240. */
  62241. constructor(name: string);
  62242. /**
  62243. * Gets the current class name
  62244. * @returns the class name
  62245. */
  62246. getClassName(): string;
  62247. /**
  62248. * Gets the left operand input component
  62249. */
  62250. get left(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the right operand input component
  62253. */
  62254. get right(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the gradient operand input component
  62257. */
  62258. get gradient(): NodeMaterialConnectionPoint;
  62259. /**
  62260. * Gets the output component
  62261. */
  62262. get output(): NodeMaterialConnectionPoint;
  62263. protected _buildBlock(state: NodeMaterialBuildState): this;
  62264. }
  62265. }
  62266. declare module BABYLON {
  62267. /**
  62268. * Block used to divide 2 vectors
  62269. */
  62270. export class DivideBlock extends NodeMaterialBlock {
  62271. /**
  62272. * Creates a new DivideBlock
  62273. * @param name defines the block name
  62274. */
  62275. constructor(name: string);
  62276. /**
  62277. * Gets the current class name
  62278. * @returns the class name
  62279. */
  62280. getClassName(): string;
  62281. /**
  62282. * Gets the left operand input component
  62283. */
  62284. get left(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the right operand input component
  62287. */
  62288. get right(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the output component
  62291. */
  62292. get output(): NodeMaterialConnectionPoint;
  62293. protected _buildBlock(state: NodeMaterialBuildState): this;
  62294. }
  62295. }
  62296. declare module BABYLON {
  62297. /**
  62298. * Block used to subtract 2 vectors
  62299. */
  62300. export class SubtractBlock extends NodeMaterialBlock {
  62301. /**
  62302. * Creates a new SubtractBlock
  62303. * @param name defines the block name
  62304. */
  62305. constructor(name: string);
  62306. /**
  62307. * Gets the current class name
  62308. * @returns the class name
  62309. */
  62310. getClassName(): string;
  62311. /**
  62312. * Gets the left operand input component
  62313. */
  62314. get left(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the right operand input component
  62317. */
  62318. get right(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the output component
  62321. */
  62322. get output(): NodeMaterialConnectionPoint;
  62323. protected _buildBlock(state: NodeMaterialBuildState): this;
  62324. }
  62325. }
  62326. declare module BABYLON {
  62327. /**
  62328. * Block used to step a value
  62329. */
  62330. export class StepBlock extends NodeMaterialBlock {
  62331. /**
  62332. * Creates a new StepBlock
  62333. * @param name defines the block name
  62334. */
  62335. constructor(name: string);
  62336. /**
  62337. * Gets the current class name
  62338. * @returns the class name
  62339. */
  62340. getClassName(): string;
  62341. /**
  62342. * Gets the value operand input component
  62343. */
  62344. get value(): NodeMaterialConnectionPoint;
  62345. /**
  62346. * Gets the edge operand input component
  62347. */
  62348. get edge(): NodeMaterialConnectionPoint;
  62349. /**
  62350. * Gets the output component
  62351. */
  62352. get output(): NodeMaterialConnectionPoint;
  62353. protected _buildBlock(state: NodeMaterialBuildState): this;
  62354. }
  62355. }
  62356. declare module BABYLON {
  62357. /**
  62358. * Block used to get the opposite (1 - x) of a value
  62359. */
  62360. export class OneMinusBlock extends NodeMaterialBlock {
  62361. /**
  62362. * Creates a new OneMinusBlock
  62363. * @param name defines the block name
  62364. */
  62365. constructor(name: string);
  62366. /**
  62367. * Gets the current class name
  62368. * @returns the class name
  62369. */
  62370. getClassName(): string;
  62371. /**
  62372. * Gets the input component
  62373. */
  62374. get input(): NodeMaterialConnectionPoint;
  62375. /**
  62376. * Gets the output component
  62377. */
  62378. get output(): NodeMaterialConnectionPoint;
  62379. protected _buildBlock(state: NodeMaterialBuildState): this;
  62380. }
  62381. }
  62382. declare module BABYLON {
  62383. /**
  62384. * Block used to get the view direction
  62385. */
  62386. export class ViewDirectionBlock extends NodeMaterialBlock {
  62387. /**
  62388. * Creates a new ViewDirectionBlock
  62389. * @param name defines the block name
  62390. */
  62391. constructor(name: string);
  62392. /**
  62393. * Gets the current class name
  62394. * @returns the class name
  62395. */
  62396. getClassName(): string;
  62397. /**
  62398. * Gets the world position component
  62399. */
  62400. get worldPosition(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the camera position component
  62403. */
  62404. get cameraPosition(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the output component
  62407. */
  62408. get output(): NodeMaterialConnectionPoint;
  62409. autoConfigure(material: NodeMaterial): void;
  62410. protected _buildBlock(state: NodeMaterialBuildState): this;
  62411. }
  62412. }
  62413. declare module BABYLON {
  62414. /**
  62415. * Block used to compute fresnel value
  62416. */
  62417. export class FresnelBlock extends NodeMaterialBlock {
  62418. /**
  62419. * Create a new FresnelBlock
  62420. * @param name defines the block name
  62421. */
  62422. constructor(name: string);
  62423. /**
  62424. * Gets the current class name
  62425. * @returns the class name
  62426. */
  62427. getClassName(): string;
  62428. /**
  62429. * Gets the world normal input component
  62430. */
  62431. get worldNormal(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the view direction input component
  62434. */
  62435. get viewDirection(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the bias input component
  62438. */
  62439. get bias(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the camera (or eye) position component
  62442. */
  62443. get power(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the fresnel output component
  62446. */
  62447. get fresnel(): NodeMaterialConnectionPoint;
  62448. autoConfigure(material: NodeMaterial): void;
  62449. protected _buildBlock(state: NodeMaterialBuildState): this;
  62450. }
  62451. }
  62452. declare module BABYLON {
  62453. /**
  62454. * Block used to get the max of 2 values
  62455. */
  62456. export class MaxBlock extends NodeMaterialBlock {
  62457. /**
  62458. * Creates a new MaxBlock
  62459. * @param name defines the block name
  62460. */
  62461. constructor(name: string);
  62462. /**
  62463. * Gets the current class name
  62464. * @returns the class name
  62465. */
  62466. getClassName(): string;
  62467. /**
  62468. * Gets the left operand input component
  62469. */
  62470. get left(): NodeMaterialConnectionPoint;
  62471. /**
  62472. * Gets the right operand input component
  62473. */
  62474. get right(): NodeMaterialConnectionPoint;
  62475. /**
  62476. * Gets the output component
  62477. */
  62478. get output(): NodeMaterialConnectionPoint;
  62479. protected _buildBlock(state: NodeMaterialBuildState): this;
  62480. }
  62481. }
  62482. declare module BABYLON {
  62483. /**
  62484. * Block used to get the min of 2 values
  62485. */
  62486. export class MinBlock extends NodeMaterialBlock {
  62487. /**
  62488. * Creates a new MinBlock
  62489. * @param name defines the block name
  62490. */
  62491. constructor(name: string);
  62492. /**
  62493. * Gets the current class name
  62494. * @returns the class name
  62495. */
  62496. getClassName(): string;
  62497. /**
  62498. * Gets the left operand input component
  62499. */
  62500. get left(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the right operand input component
  62503. */
  62504. get right(): NodeMaterialConnectionPoint;
  62505. /**
  62506. * Gets the output component
  62507. */
  62508. get output(): NodeMaterialConnectionPoint;
  62509. protected _buildBlock(state: NodeMaterialBuildState): this;
  62510. }
  62511. }
  62512. declare module BABYLON {
  62513. /**
  62514. * Block used to get the distance between 2 values
  62515. */
  62516. export class DistanceBlock extends NodeMaterialBlock {
  62517. /**
  62518. * Creates a new DistanceBlock
  62519. * @param name defines the block name
  62520. */
  62521. constructor(name: string);
  62522. /**
  62523. * Gets the current class name
  62524. * @returns the class name
  62525. */
  62526. getClassName(): string;
  62527. /**
  62528. * Gets the left operand input component
  62529. */
  62530. get left(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the right operand input component
  62533. */
  62534. get right(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the output component
  62537. */
  62538. get output(): NodeMaterialConnectionPoint;
  62539. protected _buildBlock(state: NodeMaterialBuildState): this;
  62540. }
  62541. }
  62542. declare module BABYLON {
  62543. /**
  62544. * Block used to get the length of a vector
  62545. */
  62546. export class LengthBlock extends NodeMaterialBlock {
  62547. /**
  62548. * Creates a new LengthBlock
  62549. * @param name defines the block name
  62550. */
  62551. constructor(name: string);
  62552. /**
  62553. * Gets the current class name
  62554. * @returns the class name
  62555. */
  62556. getClassName(): string;
  62557. /**
  62558. * Gets the value input component
  62559. */
  62560. get value(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the output component
  62563. */
  62564. get output(): NodeMaterialConnectionPoint;
  62565. protected _buildBlock(state: NodeMaterialBuildState): this;
  62566. }
  62567. }
  62568. declare module BABYLON {
  62569. /**
  62570. * Block used to get negative version of a value (i.e. x * -1)
  62571. */
  62572. export class NegateBlock extends NodeMaterialBlock {
  62573. /**
  62574. * Creates a new NegateBlock
  62575. * @param name defines the block name
  62576. */
  62577. constructor(name: string);
  62578. /**
  62579. * Gets the current class name
  62580. * @returns the class name
  62581. */
  62582. getClassName(): string;
  62583. /**
  62584. * Gets the value input component
  62585. */
  62586. get value(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the output component
  62589. */
  62590. get output(): NodeMaterialConnectionPoint;
  62591. protected _buildBlock(state: NodeMaterialBuildState): this;
  62592. }
  62593. }
  62594. declare module BABYLON {
  62595. /**
  62596. * Block used to get the value of the first parameter raised to the power of the second
  62597. */
  62598. export class PowBlock extends NodeMaterialBlock {
  62599. /**
  62600. * Creates a new PowBlock
  62601. * @param name defines the block name
  62602. */
  62603. constructor(name: string);
  62604. /**
  62605. * Gets the current class name
  62606. * @returns the class name
  62607. */
  62608. getClassName(): string;
  62609. /**
  62610. * Gets the value operand input component
  62611. */
  62612. get value(): NodeMaterialConnectionPoint;
  62613. /**
  62614. * Gets the power operand input component
  62615. */
  62616. get power(): NodeMaterialConnectionPoint;
  62617. /**
  62618. * Gets the output component
  62619. */
  62620. get output(): NodeMaterialConnectionPoint;
  62621. protected _buildBlock(state: NodeMaterialBuildState): this;
  62622. }
  62623. }
  62624. declare module BABYLON {
  62625. /**
  62626. * Block used to get a random number
  62627. */
  62628. export class RandomNumberBlock extends NodeMaterialBlock {
  62629. /**
  62630. * Creates a new RandomNumberBlock
  62631. * @param name defines the block name
  62632. */
  62633. constructor(name: string);
  62634. /**
  62635. * Gets the current class name
  62636. * @returns the class name
  62637. */
  62638. getClassName(): string;
  62639. /**
  62640. * Gets the seed input component
  62641. */
  62642. get seed(): NodeMaterialConnectionPoint;
  62643. /**
  62644. * Gets the output component
  62645. */
  62646. get output(): NodeMaterialConnectionPoint;
  62647. protected _buildBlock(state: NodeMaterialBuildState): this;
  62648. }
  62649. }
  62650. declare module BABYLON {
  62651. /**
  62652. * Block used to compute arc tangent of 2 values
  62653. */
  62654. export class ArcTan2Block extends NodeMaterialBlock {
  62655. /**
  62656. * Creates a new ArcTan2Block
  62657. * @param name defines the block name
  62658. */
  62659. constructor(name: string);
  62660. /**
  62661. * Gets the current class name
  62662. * @returns the class name
  62663. */
  62664. getClassName(): string;
  62665. /**
  62666. * Gets the x operand input component
  62667. */
  62668. get x(): NodeMaterialConnectionPoint;
  62669. /**
  62670. * Gets the y operand input component
  62671. */
  62672. get y(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the output component
  62675. */
  62676. get output(): NodeMaterialConnectionPoint;
  62677. protected _buildBlock(state: NodeMaterialBuildState): this;
  62678. }
  62679. }
  62680. declare module BABYLON {
  62681. /**
  62682. * Block used to smooth step a value
  62683. */
  62684. export class SmoothStepBlock extends NodeMaterialBlock {
  62685. /**
  62686. * Creates a new SmoothStepBlock
  62687. * @param name defines the block name
  62688. */
  62689. constructor(name: string);
  62690. /**
  62691. * Gets the current class name
  62692. * @returns the class name
  62693. */
  62694. getClassName(): string;
  62695. /**
  62696. * Gets the value operand input component
  62697. */
  62698. get value(): NodeMaterialConnectionPoint;
  62699. /**
  62700. * Gets the first edge operand input component
  62701. */
  62702. get edge0(): NodeMaterialConnectionPoint;
  62703. /**
  62704. * Gets the second edge operand input component
  62705. */
  62706. get edge1(): NodeMaterialConnectionPoint;
  62707. /**
  62708. * Gets the output component
  62709. */
  62710. get output(): NodeMaterialConnectionPoint;
  62711. protected _buildBlock(state: NodeMaterialBuildState): this;
  62712. }
  62713. }
  62714. declare module BABYLON {
  62715. /**
  62716. * Block used to get the reciprocal (1 / x) of a value
  62717. */
  62718. export class ReciprocalBlock extends NodeMaterialBlock {
  62719. /**
  62720. * Creates a new ReciprocalBlock
  62721. * @param name defines the block name
  62722. */
  62723. constructor(name: string);
  62724. /**
  62725. * Gets the current class name
  62726. * @returns the class name
  62727. */
  62728. getClassName(): string;
  62729. /**
  62730. * Gets the input component
  62731. */
  62732. get input(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the output component
  62735. */
  62736. get output(): NodeMaterialConnectionPoint;
  62737. protected _buildBlock(state: NodeMaterialBuildState): this;
  62738. }
  62739. }
  62740. declare module BABYLON {
  62741. /**
  62742. * Block used to replace a color by another one
  62743. */
  62744. export class ReplaceColorBlock extends NodeMaterialBlock {
  62745. /**
  62746. * Creates a new ReplaceColorBlock
  62747. * @param name defines the block name
  62748. */
  62749. constructor(name: string);
  62750. /**
  62751. * Gets the current class name
  62752. * @returns the class name
  62753. */
  62754. getClassName(): string;
  62755. /**
  62756. * Gets the value input component
  62757. */
  62758. get value(): NodeMaterialConnectionPoint;
  62759. /**
  62760. * Gets the reference input component
  62761. */
  62762. get reference(): NodeMaterialConnectionPoint;
  62763. /**
  62764. * Gets the distance input component
  62765. */
  62766. get distance(): NodeMaterialConnectionPoint;
  62767. /**
  62768. * Gets the replacement input component
  62769. */
  62770. get replacement(): NodeMaterialConnectionPoint;
  62771. /**
  62772. * Gets the output component
  62773. */
  62774. get output(): NodeMaterialConnectionPoint;
  62775. protected _buildBlock(state: NodeMaterialBuildState): this;
  62776. }
  62777. }
  62778. declare module BABYLON {
  62779. /**
  62780. * Block used to posterize a value
  62781. * @see https://en.wikipedia.org/wiki/Posterization
  62782. */
  62783. export class PosterizeBlock extends NodeMaterialBlock {
  62784. /**
  62785. * Creates a new PosterizeBlock
  62786. * @param name defines the block name
  62787. */
  62788. constructor(name: string);
  62789. /**
  62790. * Gets the current class name
  62791. * @returns the class name
  62792. */
  62793. getClassName(): string;
  62794. /**
  62795. * Gets the value input component
  62796. */
  62797. get value(): NodeMaterialConnectionPoint;
  62798. /**
  62799. * Gets the steps input component
  62800. */
  62801. get steps(): NodeMaterialConnectionPoint;
  62802. /**
  62803. * Gets the output component
  62804. */
  62805. get output(): NodeMaterialConnectionPoint;
  62806. protected _buildBlock(state: NodeMaterialBuildState): this;
  62807. }
  62808. }
  62809. declare module BABYLON {
  62810. /**
  62811. * Operations supported by the Wave block
  62812. */
  62813. export enum WaveBlockKind {
  62814. /** SawTooth */
  62815. SawTooth = 0,
  62816. /** Square */
  62817. Square = 1,
  62818. /** Triangle */
  62819. Triangle = 2
  62820. }
  62821. /**
  62822. * Block used to apply wave operation to floats
  62823. */
  62824. export class WaveBlock extends NodeMaterialBlock {
  62825. /**
  62826. * Gets or sets the kibnd of wave to be applied by the block
  62827. */
  62828. kind: WaveBlockKind;
  62829. /**
  62830. * Creates a new WaveBlock
  62831. * @param name defines the block name
  62832. */
  62833. constructor(name: string);
  62834. /**
  62835. * Gets the current class name
  62836. * @returns the class name
  62837. */
  62838. getClassName(): string;
  62839. /**
  62840. * Gets the input component
  62841. */
  62842. get input(): NodeMaterialConnectionPoint;
  62843. /**
  62844. * Gets the output component
  62845. */
  62846. get output(): NodeMaterialConnectionPoint;
  62847. protected _buildBlock(state: NodeMaterialBuildState): this;
  62848. serialize(): any;
  62849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62850. }
  62851. }
  62852. declare module BABYLON {
  62853. /**
  62854. * Class used to store a color step for the GradientBlock
  62855. */
  62856. export class GradientBlockColorStep {
  62857. /**
  62858. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62859. */
  62860. step: number;
  62861. /**
  62862. * Gets or sets the color associated with this step
  62863. */
  62864. color: Color3;
  62865. /**
  62866. * Creates a new GradientBlockColorStep
  62867. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62868. * @param color defines the color associated with this step
  62869. */
  62870. constructor(
  62871. /**
  62872. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62873. */
  62874. step: number,
  62875. /**
  62876. * Gets or sets the color associated with this step
  62877. */
  62878. color: Color3);
  62879. }
  62880. /**
  62881. * Block used to return a color from a gradient based on an input value between 0 and 1
  62882. */
  62883. export class GradientBlock extends NodeMaterialBlock {
  62884. /**
  62885. * Gets or sets the list of color steps
  62886. */
  62887. colorSteps: GradientBlockColorStep[];
  62888. /**
  62889. * Creates a new GradientBlock
  62890. * @param name defines the block name
  62891. */
  62892. constructor(name: string);
  62893. /**
  62894. * Gets the current class name
  62895. * @returns the class name
  62896. */
  62897. getClassName(): string;
  62898. /**
  62899. * Gets the gradient input component
  62900. */
  62901. get gradient(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the output component
  62904. */
  62905. get output(): NodeMaterialConnectionPoint;
  62906. private _writeColorConstant;
  62907. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62908. serialize(): any;
  62909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62910. protected _dumpPropertiesCode(): string;
  62911. }
  62912. }
  62913. declare module BABYLON {
  62914. /**
  62915. * Block used to normalize lerp between 2 values
  62916. */
  62917. export class NLerpBlock extends NodeMaterialBlock {
  62918. /**
  62919. * Creates a new NLerpBlock
  62920. * @param name defines the block name
  62921. */
  62922. constructor(name: string);
  62923. /**
  62924. * Gets the current class name
  62925. * @returns the class name
  62926. */
  62927. getClassName(): string;
  62928. /**
  62929. * Gets the left operand input component
  62930. */
  62931. get left(): NodeMaterialConnectionPoint;
  62932. /**
  62933. * Gets the right operand input component
  62934. */
  62935. get right(): NodeMaterialConnectionPoint;
  62936. /**
  62937. * Gets the gradient operand input component
  62938. */
  62939. get gradient(): NodeMaterialConnectionPoint;
  62940. /**
  62941. * Gets the output component
  62942. */
  62943. get output(): NodeMaterialConnectionPoint;
  62944. protected _buildBlock(state: NodeMaterialBuildState): this;
  62945. }
  62946. }
  62947. declare module BABYLON {
  62948. /**
  62949. * block used to Generate a Worley Noise 3D Noise Pattern
  62950. */
  62951. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62952. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62953. manhattanDistance: boolean;
  62954. /**
  62955. * Creates a new WorleyNoise3DBlock
  62956. * @param name defines the block name
  62957. */
  62958. constructor(name: string);
  62959. /**
  62960. * Gets the current class name
  62961. * @returns the class name
  62962. */
  62963. getClassName(): string;
  62964. /**
  62965. * Gets the seed input component
  62966. */
  62967. get seed(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the jitter input component
  62970. */
  62971. get jitter(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the output component
  62974. */
  62975. get output(): NodeMaterialConnectionPoint;
  62976. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62977. /**
  62978. * Exposes the properties to the UI?
  62979. */
  62980. protected _dumpPropertiesCode(): string;
  62981. /**
  62982. * Exposes the properties to the Seralize?
  62983. */
  62984. serialize(): any;
  62985. /**
  62986. * Exposes the properties to the deseralize?
  62987. */
  62988. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62989. }
  62990. }
  62991. declare module BABYLON {
  62992. /**
  62993. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62994. */
  62995. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62996. /**
  62997. * Creates a new SimplexPerlin3DBlock
  62998. * @param name defines the block name
  62999. */
  63000. constructor(name: string);
  63001. /**
  63002. * Gets the current class name
  63003. * @returns the class name
  63004. */
  63005. getClassName(): string;
  63006. /**
  63007. * Gets the seed operand input component
  63008. */
  63009. get seed(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the output component
  63012. */
  63013. get output(): NodeMaterialConnectionPoint;
  63014. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63015. }
  63016. }
  63017. declare module BABYLON {
  63018. /**
  63019. * Block used to blend normals
  63020. */
  63021. export class NormalBlendBlock extends NodeMaterialBlock {
  63022. /**
  63023. * Creates a new NormalBlendBlock
  63024. * @param name defines the block name
  63025. */
  63026. constructor(name: string);
  63027. /**
  63028. * Gets the current class name
  63029. * @returns the class name
  63030. */
  63031. getClassName(): string;
  63032. /**
  63033. * Gets the first input component
  63034. */
  63035. get normalMap0(): NodeMaterialConnectionPoint;
  63036. /**
  63037. * Gets the second input component
  63038. */
  63039. get normalMap1(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the output component
  63042. */
  63043. get output(): NodeMaterialConnectionPoint;
  63044. protected _buildBlock(state: NodeMaterialBuildState): this;
  63045. }
  63046. }
  63047. declare module BABYLON {
  63048. /**
  63049. * Block used to rotate a 2d vector by a given angle
  63050. */
  63051. export class Rotate2dBlock extends NodeMaterialBlock {
  63052. /**
  63053. * Creates a new Rotate2dBlock
  63054. * @param name defines the block name
  63055. */
  63056. constructor(name: string);
  63057. /**
  63058. * Gets the current class name
  63059. * @returns the class name
  63060. */
  63061. getClassName(): string;
  63062. /**
  63063. * Gets the input vector
  63064. */
  63065. get input(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the input angle
  63068. */
  63069. get angle(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the output component
  63072. */
  63073. get output(): NodeMaterialConnectionPoint;
  63074. autoConfigure(material: NodeMaterial): void;
  63075. protected _buildBlock(state: NodeMaterialBuildState): this;
  63076. }
  63077. }
  63078. declare module BABYLON {
  63079. /**
  63080. * Block used to get the reflected vector from a direction and a normal
  63081. */
  63082. export class ReflectBlock extends NodeMaterialBlock {
  63083. /**
  63084. * Creates a new ReflectBlock
  63085. * @param name defines the block name
  63086. */
  63087. constructor(name: string);
  63088. /**
  63089. * Gets the current class name
  63090. * @returns the class name
  63091. */
  63092. getClassName(): string;
  63093. /**
  63094. * Gets the incident component
  63095. */
  63096. get incident(): NodeMaterialConnectionPoint;
  63097. /**
  63098. * Gets the normal component
  63099. */
  63100. get normal(): NodeMaterialConnectionPoint;
  63101. /**
  63102. * Gets the output component
  63103. */
  63104. get output(): NodeMaterialConnectionPoint;
  63105. protected _buildBlock(state: NodeMaterialBuildState): this;
  63106. }
  63107. }
  63108. declare module BABYLON {
  63109. /**
  63110. * Block used to get the refracted vector from a direction and a normal
  63111. */
  63112. export class RefractBlock extends NodeMaterialBlock {
  63113. /**
  63114. * Creates a new RefractBlock
  63115. * @param name defines the block name
  63116. */
  63117. constructor(name: string);
  63118. /**
  63119. * Gets the current class name
  63120. * @returns the class name
  63121. */
  63122. getClassName(): string;
  63123. /**
  63124. * Gets the incident component
  63125. */
  63126. get incident(): NodeMaterialConnectionPoint;
  63127. /**
  63128. * Gets the normal component
  63129. */
  63130. get normal(): NodeMaterialConnectionPoint;
  63131. /**
  63132. * Gets the index of refraction component
  63133. */
  63134. get ior(): NodeMaterialConnectionPoint;
  63135. /**
  63136. * Gets the output component
  63137. */
  63138. get output(): NodeMaterialConnectionPoint;
  63139. protected _buildBlock(state: NodeMaterialBuildState): this;
  63140. }
  63141. }
  63142. declare module BABYLON {
  63143. /**
  63144. * Block used to desaturate a color
  63145. */
  63146. export class DesaturateBlock extends NodeMaterialBlock {
  63147. /**
  63148. * Creates a new DesaturateBlock
  63149. * @param name defines the block name
  63150. */
  63151. constructor(name: string);
  63152. /**
  63153. * Gets the current class name
  63154. * @returns the class name
  63155. */
  63156. getClassName(): string;
  63157. /**
  63158. * Gets the color operand input component
  63159. */
  63160. get color(): NodeMaterialConnectionPoint;
  63161. /**
  63162. * Gets the level operand input component
  63163. */
  63164. get level(): NodeMaterialConnectionPoint;
  63165. /**
  63166. * Gets the output component
  63167. */
  63168. get output(): NodeMaterialConnectionPoint;
  63169. protected _buildBlock(state: NodeMaterialBuildState): this;
  63170. }
  63171. }
  63172. declare module BABYLON {
  63173. /**
  63174. * Block used to implement the ambient occlusion module of the PBR material
  63175. */
  63176. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63177. /**
  63178. * Create a new AmbientOcclusionBlock
  63179. * @param name defines the block name
  63180. */
  63181. constructor(name: string);
  63182. /**
  63183. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63184. */
  63185. useAmbientInGrayScale: boolean;
  63186. /**
  63187. * Initialize the block and prepare the context for build
  63188. * @param state defines the state that will be used for the build
  63189. */
  63190. initialize(state: NodeMaterialBuildState): void;
  63191. /**
  63192. * Gets the current class name
  63193. * @returns the class name
  63194. */
  63195. getClassName(): string;
  63196. /**
  63197. * Gets the texture input component
  63198. */
  63199. get texture(): NodeMaterialConnectionPoint;
  63200. /**
  63201. * Gets the texture intensity component
  63202. */
  63203. get intensity(): NodeMaterialConnectionPoint;
  63204. /**
  63205. * Gets the direct light intensity input component
  63206. */
  63207. get directLightIntensity(): NodeMaterialConnectionPoint;
  63208. /**
  63209. * Gets the ambient occlusion object output component
  63210. */
  63211. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the main code of the block (fragment side)
  63214. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63215. * @returns the shader code
  63216. */
  63217. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63219. protected _buildBlock(state: NodeMaterialBuildState): this;
  63220. protected _dumpPropertiesCode(): string;
  63221. serialize(): any;
  63222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63223. }
  63224. }
  63225. declare module BABYLON {
  63226. /**
  63227. * Block used to implement the reflection module of the PBR material
  63228. */
  63229. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63230. /** @hidden */
  63231. _defineLODReflectionAlpha: string;
  63232. /** @hidden */
  63233. _defineLinearSpecularReflection: string;
  63234. private _vEnvironmentIrradianceName;
  63235. /** @hidden */
  63236. _vReflectionMicrosurfaceInfosName: string;
  63237. /** @hidden */
  63238. _vReflectionInfosName: string;
  63239. /** @hidden */
  63240. _vReflectionFilteringInfoName: string;
  63241. private _scene;
  63242. /**
  63243. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63244. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63245. * It's less burden on the user side in the editor part.
  63246. */
  63247. /** @hidden */
  63248. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63249. /** @hidden */
  63250. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63251. /** @hidden */
  63252. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63253. /**
  63254. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63255. * diffuse part of the IBL.
  63256. */
  63257. useSphericalHarmonics: boolean;
  63258. /**
  63259. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63260. */
  63261. forceIrradianceInFragment: boolean;
  63262. /**
  63263. * Create a new ReflectionBlock
  63264. * @param name defines the block name
  63265. */
  63266. constructor(name: string);
  63267. /**
  63268. * Gets the current class name
  63269. * @returns the class name
  63270. */
  63271. getClassName(): string;
  63272. /**
  63273. * Gets the position input component
  63274. */
  63275. get position(): NodeMaterialConnectionPoint;
  63276. /**
  63277. * Gets the world position input component
  63278. */
  63279. get worldPosition(): NodeMaterialConnectionPoint;
  63280. /**
  63281. * Gets the world normal input component
  63282. */
  63283. get worldNormal(): NodeMaterialConnectionPoint;
  63284. /**
  63285. * Gets the world input component
  63286. */
  63287. get world(): NodeMaterialConnectionPoint;
  63288. /**
  63289. * Gets the camera (or eye) position component
  63290. */
  63291. get cameraPosition(): NodeMaterialConnectionPoint;
  63292. /**
  63293. * Gets the view input component
  63294. */
  63295. get view(): NodeMaterialConnectionPoint;
  63296. /**
  63297. * Gets the color input component
  63298. */
  63299. get color(): NodeMaterialConnectionPoint;
  63300. /**
  63301. * Gets the reflection object output component
  63302. */
  63303. get reflection(): NodeMaterialConnectionPoint;
  63304. /**
  63305. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63306. */
  63307. get hasTexture(): boolean;
  63308. /**
  63309. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63310. */
  63311. get reflectionColor(): string;
  63312. protected _getTexture(): Nullable<BaseTexture>;
  63313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63315. /**
  63316. * Gets the code to inject in the vertex shader
  63317. * @param state current state of the node material building
  63318. * @returns the shader code
  63319. */
  63320. handleVertexSide(state: NodeMaterialBuildState): string;
  63321. /**
  63322. * Gets the main code of the block (fragment side)
  63323. * @param state current state of the node material building
  63324. * @param normalVarName name of the existing variable corresponding to the normal
  63325. * @returns the shader code
  63326. */
  63327. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63328. protected _buildBlock(state: NodeMaterialBuildState): this;
  63329. protected _dumpPropertiesCode(): string;
  63330. serialize(): any;
  63331. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63332. }
  63333. }
  63334. declare module BABYLON {
  63335. /**
  63336. * Block used to implement the sheen module of the PBR material
  63337. */
  63338. export class SheenBlock extends NodeMaterialBlock {
  63339. /**
  63340. * Create a new SheenBlock
  63341. * @param name defines the block name
  63342. */
  63343. constructor(name: string);
  63344. /**
  63345. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63346. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63347. * making it easier to setup and tweak the effect
  63348. */
  63349. albedoScaling: boolean;
  63350. /**
  63351. * Defines if the sheen is linked to the sheen color.
  63352. */
  63353. linkSheenWithAlbedo: boolean;
  63354. /**
  63355. * Initialize the block and prepare the context for build
  63356. * @param state defines the state that will be used for the build
  63357. */
  63358. initialize(state: NodeMaterialBuildState): void;
  63359. /**
  63360. * Gets the current class name
  63361. * @returns the class name
  63362. */
  63363. getClassName(): string;
  63364. /**
  63365. * Gets the intensity input component
  63366. */
  63367. get intensity(): NodeMaterialConnectionPoint;
  63368. /**
  63369. * Gets the color input component
  63370. */
  63371. get color(): NodeMaterialConnectionPoint;
  63372. /**
  63373. * Gets the roughness input component
  63374. */
  63375. get roughness(): NodeMaterialConnectionPoint;
  63376. /**
  63377. * Gets the sheen object output component
  63378. */
  63379. get sheen(): NodeMaterialConnectionPoint;
  63380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63381. /**
  63382. * Gets the main code of the block (fragment side)
  63383. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63384. * @returns the shader code
  63385. */
  63386. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63387. protected _buildBlock(state: NodeMaterialBuildState): this;
  63388. protected _dumpPropertiesCode(): string;
  63389. serialize(): any;
  63390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63391. }
  63392. }
  63393. declare module BABYLON {
  63394. /**
  63395. * Block used to implement the reflectivity module of the PBR material
  63396. */
  63397. export class ReflectivityBlock extends NodeMaterialBlock {
  63398. private _metallicReflectanceColor;
  63399. private _metallicF0Factor;
  63400. /** @hidden */
  63401. _vMetallicReflectanceFactorsName: string;
  63402. /**
  63403. * The property below is set by the main PBR block prior to calling methods of this class.
  63404. */
  63405. /** @hidden */
  63406. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63407. /**
  63408. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63409. */
  63410. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63411. /**
  63412. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63413. */
  63414. useMetallnessFromMetallicTextureBlue: boolean;
  63415. /**
  63416. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63417. */
  63418. useRoughnessFromMetallicTextureAlpha: boolean;
  63419. /**
  63420. * Specifies if the metallic texture contains the roughness information in its green channel.
  63421. */
  63422. useRoughnessFromMetallicTextureGreen: boolean;
  63423. /**
  63424. * Create a new ReflectivityBlock
  63425. * @param name defines the block name
  63426. */
  63427. constructor(name: string);
  63428. /**
  63429. * Initialize the block and prepare the context for build
  63430. * @param state defines the state that will be used for the build
  63431. */
  63432. initialize(state: NodeMaterialBuildState): void;
  63433. /**
  63434. * Gets the current class name
  63435. * @returns the class name
  63436. */
  63437. getClassName(): string;
  63438. /**
  63439. * Gets the metallic input component
  63440. */
  63441. get metallic(): NodeMaterialConnectionPoint;
  63442. /**
  63443. * Gets the roughness input component
  63444. */
  63445. get roughness(): NodeMaterialConnectionPoint;
  63446. /**
  63447. * Gets the texture input component
  63448. */
  63449. get texture(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the reflectivity object output component
  63452. */
  63453. get reflectivity(): NodeMaterialConnectionPoint;
  63454. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63455. /**
  63456. * Gets the main code of the block (fragment side)
  63457. * @param state current state of the node material building
  63458. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63459. * @returns the shader code
  63460. */
  63461. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63463. protected _buildBlock(state: NodeMaterialBuildState): this;
  63464. protected _dumpPropertiesCode(): string;
  63465. serialize(): any;
  63466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63467. }
  63468. }
  63469. declare module BABYLON {
  63470. /**
  63471. * Block used to implement the anisotropy module of the PBR material
  63472. */
  63473. export class AnisotropyBlock extends NodeMaterialBlock {
  63474. /**
  63475. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63476. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63477. * It's less burden on the user side in the editor part.
  63478. */
  63479. /** @hidden */
  63480. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63481. /** @hidden */
  63482. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63483. /**
  63484. * Create a new AnisotropyBlock
  63485. * @param name defines the block name
  63486. */
  63487. constructor(name: string);
  63488. /**
  63489. * Initialize the block and prepare the context for build
  63490. * @param state defines the state that will be used for the build
  63491. */
  63492. initialize(state: NodeMaterialBuildState): void;
  63493. /**
  63494. * Gets the current class name
  63495. * @returns the class name
  63496. */
  63497. getClassName(): string;
  63498. /**
  63499. * Gets the intensity input component
  63500. */
  63501. get intensity(): NodeMaterialConnectionPoint;
  63502. /**
  63503. * Gets the direction input component
  63504. */
  63505. get direction(): NodeMaterialConnectionPoint;
  63506. /**
  63507. * Gets the texture input component
  63508. */
  63509. get texture(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the uv input component
  63512. */
  63513. get uv(): NodeMaterialConnectionPoint;
  63514. /**
  63515. * Gets the worldTangent input component
  63516. */
  63517. get worldTangent(): NodeMaterialConnectionPoint;
  63518. /**
  63519. * Gets the anisotropy object output component
  63520. */
  63521. get anisotropy(): NodeMaterialConnectionPoint;
  63522. private _generateTBNSpace;
  63523. /**
  63524. * Gets the main code of the block (fragment side)
  63525. * @param state current state of the node material building
  63526. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63527. * @returns the shader code
  63528. */
  63529. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63531. protected _buildBlock(state: NodeMaterialBuildState): this;
  63532. }
  63533. }
  63534. declare module BABYLON {
  63535. /**
  63536. * Block used to implement the clear coat module of the PBR material
  63537. */
  63538. export class ClearCoatBlock extends NodeMaterialBlock {
  63539. private _scene;
  63540. /**
  63541. * Create a new ClearCoatBlock
  63542. * @param name defines the block name
  63543. */
  63544. constructor(name: string);
  63545. /**
  63546. * Initialize the block and prepare the context for build
  63547. * @param state defines the state that will be used for the build
  63548. */
  63549. initialize(state: NodeMaterialBuildState): void;
  63550. /**
  63551. * Gets the current class name
  63552. * @returns the class name
  63553. */
  63554. getClassName(): string;
  63555. /**
  63556. * Gets the intensity input component
  63557. */
  63558. get intensity(): NodeMaterialConnectionPoint;
  63559. /**
  63560. * Gets the roughness input component
  63561. */
  63562. get roughness(): NodeMaterialConnectionPoint;
  63563. /**
  63564. * Gets the ior input component
  63565. */
  63566. get ior(): NodeMaterialConnectionPoint;
  63567. /**
  63568. * Gets the texture input component
  63569. */
  63570. get texture(): NodeMaterialConnectionPoint;
  63571. /**
  63572. * Gets the bump texture input component
  63573. */
  63574. get bumpTexture(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the uv input component
  63577. */
  63578. get uv(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the tint color input component
  63581. */
  63582. get tintColor(): NodeMaterialConnectionPoint;
  63583. /**
  63584. * Gets the tint "at distance" input component
  63585. */
  63586. get tintAtDistance(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the tint thickness input component
  63589. */
  63590. get tintThickness(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the world tangent input component
  63593. */
  63594. get worldTangent(): NodeMaterialConnectionPoint;
  63595. /**
  63596. * Gets the clear coat object output component
  63597. */
  63598. get clearcoat(): NodeMaterialConnectionPoint;
  63599. autoConfigure(material: NodeMaterial): void;
  63600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63601. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63602. private _generateTBNSpace;
  63603. /**
  63604. * Gets the main code of the block (fragment side)
  63605. * @param state current state of the node material building
  63606. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63607. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63608. * @param worldPosVarName name of the variable holding the world position
  63609. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63610. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63611. * @param worldNormalVarName name of the variable holding the world normal
  63612. * @returns the shader code
  63613. */
  63614. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63615. protected _buildBlock(state: NodeMaterialBuildState): this;
  63616. }
  63617. }
  63618. declare module BABYLON {
  63619. /**
  63620. * Block used to implement the sub surface module of the PBR material
  63621. */
  63622. export class SubSurfaceBlock extends NodeMaterialBlock {
  63623. /**
  63624. * Create a new SubSurfaceBlock
  63625. * @param name defines the block name
  63626. */
  63627. constructor(name: string);
  63628. /**
  63629. * Stores the intensity of the different subsurface effects in the thickness texture.
  63630. * * the green channel is the translucency intensity.
  63631. * * the blue channel is the scattering intensity.
  63632. * * the alpha channel is the refraction intensity.
  63633. */
  63634. useMaskFromThicknessTexture: boolean;
  63635. /**
  63636. * Initialize the block and prepare the context for build
  63637. * @param state defines the state that will be used for the build
  63638. */
  63639. initialize(state: NodeMaterialBuildState): void;
  63640. /**
  63641. * Gets the current class name
  63642. * @returns the class name
  63643. */
  63644. getClassName(): string;
  63645. /**
  63646. * Gets the min thickness input component
  63647. */
  63648. get minThickness(): NodeMaterialConnectionPoint;
  63649. /**
  63650. * Gets the max thickness input component
  63651. */
  63652. get maxThickness(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the thickness texture component
  63655. */
  63656. get thicknessTexture(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the tint color input component
  63659. */
  63660. get tintColor(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the translucency intensity input component
  63663. */
  63664. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the translucency diffusion distance input component
  63667. */
  63668. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the refraction object parameters
  63671. */
  63672. get refraction(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the sub surface object output component
  63675. */
  63676. get subsurface(): NodeMaterialConnectionPoint;
  63677. autoConfigure(material: NodeMaterial): void;
  63678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63679. /**
  63680. * Gets the main code of the block (fragment side)
  63681. * @param state current state of the node material building
  63682. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63683. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63684. * @param worldPosVarName name of the variable holding the world position
  63685. * @returns the shader code
  63686. */
  63687. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63688. protected _buildBlock(state: NodeMaterialBuildState): this;
  63689. }
  63690. }
  63691. declare module BABYLON {
  63692. /**
  63693. * Block used to implement the PBR metallic/roughness model
  63694. */
  63695. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63696. /**
  63697. * Gets or sets the light associated with this block
  63698. */
  63699. light: Nullable<Light>;
  63700. private _lightId;
  63701. private _scene;
  63702. private _environmentBRDFTexture;
  63703. private _environmentBrdfSamplerName;
  63704. private _vNormalWName;
  63705. private _invertNormalName;
  63706. /**
  63707. * Create a new ReflectionBlock
  63708. * @param name defines the block name
  63709. */
  63710. constructor(name: string);
  63711. /**
  63712. * Intensity of the direct lights e.g. the four lights available in your scene.
  63713. * This impacts both the direct diffuse and specular highlights.
  63714. */
  63715. directIntensity: number;
  63716. /**
  63717. * Intensity of the environment e.g. how much the environment will light the object
  63718. * either through harmonics for rough material or through the refelction for shiny ones.
  63719. */
  63720. environmentIntensity: number;
  63721. /**
  63722. * This is a special control allowing the reduction of the specular highlights coming from the
  63723. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63724. */
  63725. specularIntensity: number;
  63726. /**
  63727. * Defines the falloff type used in this material.
  63728. * It by default is Physical.
  63729. */
  63730. lightFalloff: number;
  63731. /**
  63732. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63733. */
  63734. useAlphaFromAlbedoTexture: boolean;
  63735. /**
  63736. * Specifies that alpha test should be used
  63737. */
  63738. useAlphaTest: boolean;
  63739. /**
  63740. * Defines the alpha limits in alpha test mode.
  63741. */
  63742. alphaTestCutoff: number;
  63743. /**
  63744. * Specifies that alpha blending should be used
  63745. */
  63746. useAlphaBlending: boolean;
  63747. /**
  63748. * Defines if the alpha value should be determined via the rgb values.
  63749. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63750. */
  63751. opacityRGB: boolean;
  63752. /**
  63753. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63754. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63755. */
  63756. useRadianceOverAlpha: boolean;
  63757. /**
  63758. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63759. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63760. */
  63761. useSpecularOverAlpha: boolean;
  63762. /**
  63763. * Enables specular anti aliasing in the PBR shader.
  63764. * It will both interacts on the Geometry for analytical and IBL lighting.
  63765. * It also prefilter the roughness map based on the bump values.
  63766. */
  63767. enableSpecularAntiAliasing: boolean;
  63768. /**
  63769. * Enables realtime filtering on the texture.
  63770. */
  63771. realTimeFiltering: boolean;
  63772. /**
  63773. * Quality switch for realtime filtering
  63774. */
  63775. realTimeFilteringQuality: number;
  63776. /**
  63777. * Defines if the material uses energy conservation.
  63778. */
  63779. useEnergyConservation: boolean;
  63780. /**
  63781. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63782. * too much the area relying on ambient texture to define their ambient occlusion.
  63783. */
  63784. useRadianceOcclusion: boolean;
  63785. /**
  63786. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63787. * makes the reflect vector face the model (under horizon).
  63788. */
  63789. useHorizonOcclusion: boolean;
  63790. /**
  63791. * If set to true, no lighting calculations will be applied.
  63792. */
  63793. unlit: boolean;
  63794. /**
  63795. * Force normal to face away from face.
  63796. */
  63797. forceNormalForward: boolean;
  63798. /**
  63799. * Defines the material debug mode.
  63800. * It helps seeing only some components of the material while troubleshooting.
  63801. */
  63802. debugMode: number;
  63803. /**
  63804. * Specify from where on screen the debug mode should start.
  63805. * The value goes from -1 (full screen) to 1 (not visible)
  63806. * It helps with side by side comparison against the final render
  63807. * This defaults to 0
  63808. */
  63809. debugLimit: number;
  63810. /**
  63811. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63812. * You can use the factor to better multiply the final value.
  63813. */
  63814. debugFactor: number;
  63815. /**
  63816. * Initialize the block and prepare the context for build
  63817. * @param state defines the state that will be used for the build
  63818. */
  63819. initialize(state: NodeMaterialBuildState): void;
  63820. /**
  63821. * Gets the current class name
  63822. * @returns the class name
  63823. */
  63824. getClassName(): string;
  63825. /**
  63826. * Gets the world position input component
  63827. */
  63828. get worldPosition(): NodeMaterialConnectionPoint;
  63829. /**
  63830. * Gets the world normal input component
  63831. */
  63832. get worldNormal(): NodeMaterialConnectionPoint;
  63833. /**
  63834. * Gets the perturbed normal input component
  63835. */
  63836. get perturbedNormal(): NodeMaterialConnectionPoint;
  63837. /**
  63838. * Gets the camera position input component
  63839. */
  63840. get cameraPosition(): NodeMaterialConnectionPoint;
  63841. /**
  63842. * Gets the base color input component
  63843. */
  63844. get baseColor(): NodeMaterialConnectionPoint;
  63845. /**
  63846. * Gets the opacity texture input component
  63847. */
  63848. get opacityTexture(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Gets the ambient color input component
  63851. */
  63852. get ambientColor(): NodeMaterialConnectionPoint;
  63853. /**
  63854. * Gets the reflectivity object parameters
  63855. */
  63856. get reflectivity(): NodeMaterialConnectionPoint;
  63857. /**
  63858. * Gets the ambient occlusion object parameters
  63859. */
  63860. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the reflection object parameters
  63863. */
  63864. get reflection(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the sheen object parameters
  63867. */
  63868. get sheen(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the clear coat object parameters
  63871. */
  63872. get clearcoat(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the sub surface object parameters
  63875. */
  63876. get subsurface(): NodeMaterialConnectionPoint;
  63877. /**
  63878. * Gets the anisotropy object parameters
  63879. */
  63880. get anisotropy(): NodeMaterialConnectionPoint;
  63881. /**
  63882. * Gets the ambient output component
  63883. */
  63884. get ambient(): NodeMaterialConnectionPoint;
  63885. /**
  63886. * Gets the diffuse output component
  63887. */
  63888. get diffuse(): NodeMaterialConnectionPoint;
  63889. /**
  63890. * Gets the specular output component
  63891. */
  63892. get specular(): NodeMaterialConnectionPoint;
  63893. /**
  63894. * Gets the sheen output component
  63895. */
  63896. get sheenDir(): NodeMaterialConnectionPoint;
  63897. /**
  63898. * Gets the clear coat output component
  63899. */
  63900. get clearcoatDir(): NodeMaterialConnectionPoint;
  63901. /**
  63902. * Gets the indirect diffuse output component
  63903. */
  63904. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63905. /**
  63906. * Gets the indirect specular output component
  63907. */
  63908. get specularIndirect(): NodeMaterialConnectionPoint;
  63909. /**
  63910. * Gets the indirect sheen output component
  63911. */
  63912. get sheenIndirect(): NodeMaterialConnectionPoint;
  63913. /**
  63914. * Gets the indirect clear coat output component
  63915. */
  63916. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63917. /**
  63918. * Gets the refraction output component
  63919. */
  63920. get refraction(): NodeMaterialConnectionPoint;
  63921. /**
  63922. * Gets the global lighting output component
  63923. */
  63924. get lighting(): NodeMaterialConnectionPoint;
  63925. /**
  63926. * Gets the shadow output component
  63927. */
  63928. get shadow(): NodeMaterialConnectionPoint;
  63929. /**
  63930. * Gets the alpha output component
  63931. */
  63932. get alpha(): NodeMaterialConnectionPoint;
  63933. autoConfigure(material: NodeMaterial): void;
  63934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63935. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63937. private _injectVertexCode;
  63938. /**
  63939. * Gets the code corresponding to the albedo/opacity module
  63940. * @returns the shader code
  63941. */
  63942. getAlbedoOpacityCode(): string;
  63943. protected _buildBlock(state: NodeMaterialBuildState): this;
  63944. protected _dumpPropertiesCode(): string;
  63945. serialize(): any;
  63946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63947. }
  63948. }
  63949. declare module BABYLON {
  63950. /**
  63951. * Block used to compute value of one parameter modulo another
  63952. */
  63953. export class ModBlock extends NodeMaterialBlock {
  63954. /**
  63955. * Creates a new ModBlock
  63956. * @param name defines the block name
  63957. */
  63958. constructor(name: string);
  63959. /**
  63960. * Gets the current class name
  63961. * @returns the class name
  63962. */
  63963. getClassName(): string;
  63964. /**
  63965. * Gets the left operand input component
  63966. */
  63967. get left(): NodeMaterialConnectionPoint;
  63968. /**
  63969. * Gets the right operand input component
  63970. */
  63971. get right(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the output component
  63974. */
  63975. get output(): NodeMaterialConnectionPoint;
  63976. protected _buildBlock(state: NodeMaterialBuildState): this;
  63977. }
  63978. }
  63979. declare module BABYLON {
  63980. /**
  63981. * Helper class to push actions to a pool of workers.
  63982. */
  63983. export class WorkerPool implements IDisposable {
  63984. private _workerInfos;
  63985. private _pendingActions;
  63986. /**
  63987. * Constructor
  63988. * @param workers Array of workers to use for actions
  63989. */
  63990. constructor(workers: Array<Worker>);
  63991. /**
  63992. * Terminates all workers and clears any pending actions.
  63993. */
  63994. dispose(): void;
  63995. /**
  63996. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63997. * pended until a worker has completed its action.
  63998. * @param action The action to perform. Call onComplete when the action is complete.
  63999. */
  64000. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64001. private _execute;
  64002. }
  64003. }
  64004. declare module BABYLON {
  64005. /**
  64006. * Configuration for Draco compression
  64007. */
  64008. export interface IDracoCompressionConfiguration {
  64009. /**
  64010. * Configuration for the decoder.
  64011. */
  64012. decoder: {
  64013. /**
  64014. * The url to the WebAssembly module.
  64015. */
  64016. wasmUrl?: string;
  64017. /**
  64018. * The url to the WebAssembly binary.
  64019. */
  64020. wasmBinaryUrl?: string;
  64021. /**
  64022. * The url to the fallback JavaScript module.
  64023. */
  64024. fallbackUrl?: string;
  64025. };
  64026. }
  64027. /**
  64028. * Draco compression (https://google.github.io/draco/)
  64029. *
  64030. * This class wraps the Draco module.
  64031. *
  64032. * **Encoder**
  64033. *
  64034. * The encoder is not currently implemented.
  64035. *
  64036. * **Decoder**
  64037. *
  64038. * 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.
  64039. *
  64040. * To update the configuration, use the following code:
  64041. * ```javascript
  64042. * DracoCompression.Configuration = {
  64043. * decoder: {
  64044. * wasmUrl: "<url to the WebAssembly library>",
  64045. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64046. * fallbackUrl: "<url to the fallback JavaScript library>",
  64047. * }
  64048. * };
  64049. * ```
  64050. *
  64051. * 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.
  64052. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64053. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64054. *
  64055. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64056. * ```javascript
  64057. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64058. * ```
  64059. *
  64060. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64061. */
  64062. export class DracoCompression implements IDisposable {
  64063. private _workerPoolPromise?;
  64064. private _decoderModulePromise?;
  64065. /**
  64066. * The configuration. Defaults to the following urls:
  64067. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64068. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64069. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64070. */
  64071. static Configuration: IDracoCompressionConfiguration;
  64072. /**
  64073. * Returns true if the decoder configuration is available.
  64074. */
  64075. static get DecoderAvailable(): boolean;
  64076. /**
  64077. * Default number of workers to create when creating the draco compression object.
  64078. */
  64079. static DefaultNumWorkers: number;
  64080. private static GetDefaultNumWorkers;
  64081. private static _Default;
  64082. /**
  64083. * Default instance for the draco compression object.
  64084. */
  64085. static get Default(): DracoCompression;
  64086. /**
  64087. * Constructor
  64088. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64089. */
  64090. constructor(numWorkers?: number);
  64091. /**
  64092. * Stop all async operations and release resources.
  64093. */
  64094. dispose(): void;
  64095. /**
  64096. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64097. * @returns a promise that resolves when ready
  64098. */
  64099. whenReadyAsync(): Promise<void>;
  64100. /**
  64101. * Decode Draco compressed mesh data to vertex data.
  64102. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64103. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64104. * @returns A promise that resolves with the decoded vertex data
  64105. */
  64106. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64107. [kind: string]: number;
  64108. }): Promise<VertexData>;
  64109. }
  64110. }
  64111. declare module BABYLON {
  64112. /**
  64113. * Class for building Constructive Solid Geometry
  64114. */
  64115. export class CSG {
  64116. private polygons;
  64117. /**
  64118. * The world matrix
  64119. */
  64120. matrix: Matrix;
  64121. /**
  64122. * Stores the position
  64123. */
  64124. position: Vector3;
  64125. /**
  64126. * Stores the rotation
  64127. */
  64128. rotation: Vector3;
  64129. /**
  64130. * Stores the rotation quaternion
  64131. */
  64132. rotationQuaternion: Nullable<Quaternion>;
  64133. /**
  64134. * Stores the scaling vector
  64135. */
  64136. scaling: Vector3;
  64137. /**
  64138. * Convert the Mesh to CSG
  64139. * @param mesh The Mesh to convert to CSG
  64140. * @returns A new CSG from the Mesh
  64141. */
  64142. static FromMesh(mesh: Mesh): CSG;
  64143. /**
  64144. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64145. * @param polygons Polygons used to construct a CSG solid
  64146. */
  64147. private static FromPolygons;
  64148. /**
  64149. * Clones, or makes a deep copy, of the CSG
  64150. * @returns A new CSG
  64151. */
  64152. clone(): CSG;
  64153. /**
  64154. * Unions this CSG with another CSG
  64155. * @param csg The CSG to union against this CSG
  64156. * @returns The unioned CSG
  64157. */
  64158. union(csg: CSG): CSG;
  64159. /**
  64160. * Unions this CSG with another CSG in place
  64161. * @param csg The CSG to union against this CSG
  64162. */
  64163. unionInPlace(csg: CSG): void;
  64164. /**
  64165. * Subtracts this CSG with another CSG
  64166. * @param csg The CSG to subtract against this CSG
  64167. * @returns A new CSG
  64168. */
  64169. subtract(csg: CSG): CSG;
  64170. /**
  64171. * Subtracts this CSG with another CSG in place
  64172. * @param csg The CSG to subtact against this CSG
  64173. */
  64174. subtractInPlace(csg: CSG): void;
  64175. /**
  64176. * Intersect this CSG with another CSG
  64177. * @param csg The CSG to intersect against this CSG
  64178. * @returns A new CSG
  64179. */
  64180. intersect(csg: CSG): CSG;
  64181. /**
  64182. * Intersects this CSG with another CSG in place
  64183. * @param csg The CSG to intersect against this CSG
  64184. */
  64185. intersectInPlace(csg: CSG): void;
  64186. /**
  64187. * Return a new CSG solid with solid and empty space switched. This solid is
  64188. * not modified.
  64189. * @returns A new CSG solid with solid and empty space switched
  64190. */
  64191. inverse(): CSG;
  64192. /**
  64193. * Inverses the CSG in place
  64194. */
  64195. inverseInPlace(): void;
  64196. /**
  64197. * This is used to keep meshes transformations so they can be restored
  64198. * when we build back a Babylon Mesh
  64199. * NB : All CSG operations are performed in world coordinates
  64200. * @param csg The CSG to copy the transform attributes from
  64201. * @returns This CSG
  64202. */
  64203. copyTransformAttributes(csg: CSG): CSG;
  64204. /**
  64205. * Build Raw mesh from CSG
  64206. * Coordinates here are in world space
  64207. * @param name The name of the mesh geometry
  64208. * @param scene The Scene
  64209. * @param keepSubMeshes Specifies if the submeshes should be kept
  64210. * @returns A new Mesh
  64211. */
  64212. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64213. /**
  64214. * Build Mesh from CSG taking material and transforms into account
  64215. * @param name The name of the Mesh
  64216. * @param material The material of the Mesh
  64217. * @param scene The Scene
  64218. * @param keepSubMeshes Specifies if submeshes should be kept
  64219. * @returns The new Mesh
  64220. */
  64221. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64222. }
  64223. }
  64224. declare module BABYLON {
  64225. /**
  64226. * Class used to create a trail following a mesh
  64227. */
  64228. export class TrailMesh extends Mesh {
  64229. private _generator;
  64230. private _autoStart;
  64231. private _running;
  64232. private _diameter;
  64233. private _length;
  64234. private _sectionPolygonPointsCount;
  64235. private _sectionVectors;
  64236. private _sectionNormalVectors;
  64237. private _beforeRenderObserver;
  64238. /**
  64239. * @constructor
  64240. * @param name The value used by scene.getMeshByName() to do a lookup.
  64241. * @param generator The mesh or transform node to generate a trail.
  64242. * @param scene The scene to add this mesh to.
  64243. * @param diameter Diameter of trailing mesh. Default is 1.
  64244. * @param length Length of trailing mesh. Default is 60.
  64245. * @param autoStart Automatically start trailing mesh. Default true.
  64246. */
  64247. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64248. /**
  64249. * "TrailMesh"
  64250. * @returns "TrailMesh"
  64251. */
  64252. getClassName(): string;
  64253. private _createMesh;
  64254. /**
  64255. * Start trailing mesh.
  64256. */
  64257. start(): void;
  64258. /**
  64259. * Stop trailing mesh.
  64260. */
  64261. stop(): void;
  64262. /**
  64263. * Update trailing mesh geometry.
  64264. */
  64265. update(): void;
  64266. /**
  64267. * Returns a new TrailMesh object.
  64268. * @param name is a string, the name given to the new mesh
  64269. * @param newGenerator use new generator object for cloned trail mesh
  64270. * @returns a new mesh
  64271. */
  64272. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64273. /**
  64274. * Serializes this trail mesh
  64275. * @param serializationObject object to write serialization to
  64276. */
  64277. serialize(serializationObject: any): void;
  64278. /**
  64279. * Parses a serialized trail mesh
  64280. * @param parsedMesh the serialized mesh
  64281. * @param scene the scene to create the trail mesh in
  64282. * @returns the created trail mesh
  64283. */
  64284. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64285. }
  64286. }
  64287. declare module BABYLON {
  64288. /**
  64289. * Class containing static functions to help procedurally build meshes
  64290. */
  64291. export class TiledBoxBuilder {
  64292. /**
  64293. * Creates a box mesh
  64294. * 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)
  64295. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64297. * * 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
  64298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64299. * @param name defines the name of the mesh
  64300. * @param options defines the options used to create the mesh
  64301. * @param scene defines the hosting scene
  64302. * @returns the box mesh
  64303. */
  64304. static CreateTiledBox(name: string, options: {
  64305. pattern?: number;
  64306. width?: number;
  64307. height?: number;
  64308. depth?: number;
  64309. tileSize?: number;
  64310. tileWidth?: number;
  64311. tileHeight?: number;
  64312. alignHorizontal?: number;
  64313. alignVertical?: number;
  64314. faceUV?: Vector4[];
  64315. faceColors?: Color4[];
  64316. sideOrientation?: number;
  64317. updatable?: boolean;
  64318. }, scene?: Nullable<Scene>): Mesh;
  64319. }
  64320. }
  64321. declare module BABYLON {
  64322. /**
  64323. * Class containing static functions to help procedurally build meshes
  64324. */
  64325. export class TorusKnotBuilder {
  64326. /**
  64327. * Creates a torus knot mesh
  64328. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64329. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64330. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64331. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64333. * * 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
  64334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64335. * @param name defines the name of the mesh
  64336. * @param options defines the options used to create the mesh
  64337. * @param scene defines the hosting scene
  64338. * @returns the torus knot mesh
  64339. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64340. */
  64341. static CreateTorusKnot(name: string, options: {
  64342. radius?: number;
  64343. tube?: number;
  64344. radialSegments?: number;
  64345. tubularSegments?: number;
  64346. p?: number;
  64347. q?: number;
  64348. updatable?: boolean;
  64349. sideOrientation?: number;
  64350. frontUVs?: Vector4;
  64351. backUVs?: Vector4;
  64352. }, scene: any): Mesh;
  64353. }
  64354. }
  64355. declare module BABYLON {
  64356. /**
  64357. * Polygon
  64358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64359. */
  64360. export class Polygon {
  64361. /**
  64362. * Creates a rectangle
  64363. * @param xmin bottom X coord
  64364. * @param ymin bottom Y coord
  64365. * @param xmax top X coord
  64366. * @param ymax top Y coord
  64367. * @returns points that make the resulting rectation
  64368. */
  64369. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64370. /**
  64371. * Creates a circle
  64372. * @param radius radius of circle
  64373. * @param cx scale in x
  64374. * @param cy scale in y
  64375. * @param numberOfSides number of sides that make up the circle
  64376. * @returns points that make the resulting circle
  64377. */
  64378. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64379. /**
  64380. * Creates a polygon from input string
  64381. * @param input Input polygon data
  64382. * @returns the parsed points
  64383. */
  64384. static Parse(input: string): Vector2[];
  64385. /**
  64386. * Starts building a polygon from x and y coordinates
  64387. * @param x x coordinate
  64388. * @param y y coordinate
  64389. * @returns the started path2
  64390. */
  64391. static StartingAt(x: number, y: number): Path2;
  64392. }
  64393. /**
  64394. * Builds a polygon
  64395. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64396. */
  64397. export class PolygonMeshBuilder {
  64398. private _points;
  64399. private _outlinepoints;
  64400. private _holes;
  64401. private _name;
  64402. private _scene;
  64403. private _epoints;
  64404. private _eholes;
  64405. private _addToepoint;
  64406. /**
  64407. * Babylon reference to the earcut plugin.
  64408. */
  64409. bjsEarcut: any;
  64410. /**
  64411. * Creates a PolygonMeshBuilder
  64412. * @param name name of the builder
  64413. * @param contours Path of the polygon
  64414. * @param scene scene to add to when creating the mesh
  64415. * @param earcutInjection can be used to inject your own earcut reference
  64416. */
  64417. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64418. /**
  64419. * Adds a whole within the polygon
  64420. * @param hole Array of points defining the hole
  64421. * @returns this
  64422. */
  64423. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64424. /**
  64425. * Creates the polygon
  64426. * @param updatable If the mesh should be updatable
  64427. * @param depth The depth of the mesh created
  64428. * @returns the created mesh
  64429. */
  64430. build(updatable?: boolean, depth?: number): Mesh;
  64431. /**
  64432. * Creates the polygon
  64433. * @param depth The depth of the mesh created
  64434. * @returns the created VertexData
  64435. */
  64436. buildVertexData(depth?: number): VertexData;
  64437. /**
  64438. * Adds a side to the polygon
  64439. * @param positions points that make the polygon
  64440. * @param normals normals of the polygon
  64441. * @param uvs uvs of the polygon
  64442. * @param indices indices of the polygon
  64443. * @param bounds bounds of the polygon
  64444. * @param points points of the polygon
  64445. * @param depth depth of the polygon
  64446. * @param flip flip of the polygon
  64447. */
  64448. private addSide;
  64449. }
  64450. }
  64451. declare module BABYLON {
  64452. /**
  64453. * Class containing static functions to help procedurally build meshes
  64454. */
  64455. export class PolygonBuilder {
  64456. /**
  64457. * Creates a polygon mesh
  64458. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64459. * * 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
  64460. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64462. * * 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)
  64463. * * Remember you can only change the shape positions, not their number when updating a polygon
  64464. * @param name defines the name of the mesh
  64465. * @param options defines the options used to create the mesh
  64466. * @param scene defines the hosting scene
  64467. * @param earcutInjection can be used to inject your own earcut reference
  64468. * @returns the polygon mesh
  64469. */
  64470. static CreatePolygon(name: string, options: {
  64471. shape: Vector3[];
  64472. holes?: Vector3[][];
  64473. depth?: number;
  64474. faceUV?: Vector4[];
  64475. faceColors?: Color4[];
  64476. updatable?: boolean;
  64477. sideOrientation?: number;
  64478. frontUVs?: Vector4;
  64479. backUVs?: Vector4;
  64480. wrap?: boolean;
  64481. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64482. /**
  64483. * Creates an extruded polygon mesh, with depth in the Y direction.
  64484. * * 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)
  64485. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64486. * @param name defines the name of the mesh
  64487. * @param options defines the options used to create the mesh
  64488. * @param scene defines the hosting scene
  64489. * @param earcutInjection can be used to inject your own earcut reference
  64490. * @returns the polygon mesh
  64491. */
  64492. static ExtrudePolygon(name: string, options: {
  64493. shape: Vector3[];
  64494. holes?: Vector3[][];
  64495. depth?: number;
  64496. faceUV?: Vector4[];
  64497. faceColors?: Color4[];
  64498. updatable?: boolean;
  64499. sideOrientation?: number;
  64500. frontUVs?: Vector4;
  64501. backUVs?: Vector4;
  64502. wrap?: boolean;
  64503. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64504. }
  64505. }
  64506. declare module BABYLON {
  64507. /**
  64508. * Class containing static functions to help procedurally build meshes
  64509. */
  64510. export class LatheBuilder {
  64511. /**
  64512. * Creates lathe mesh.
  64513. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64514. * * 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
  64515. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64516. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64517. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64518. * * 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
  64519. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64520. * * 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
  64521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64522. * * 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
  64523. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64525. * @param name defines the name of the mesh
  64526. * @param options defines the options used to create the mesh
  64527. * @param scene defines the hosting scene
  64528. * @returns the lathe mesh
  64529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64530. */
  64531. static CreateLathe(name: string, options: {
  64532. shape: Vector3[];
  64533. radius?: number;
  64534. tessellation?: number;
  64535. clip?: number;
  64536. arc?: number;
  64537. closed?: boolean;
  64538. updatable?: boolean;
  64539. sideOrientation?: number;
  64540. frontUVs?: Vector4;
  64541. backUVs?: Vector4;
  64542. cap?: number;
  64543. invertUV?: boolean;
  64544. }, scene?: Nullable<Scene>): Mesh;
  64545. }
  64546. }
  64547. declare module BABYLON {
  64548. /**
  64549. * Class containing static functions to help procedurally build meshes
  64550. */
  64551. export class TiledPlaneBuilder {
  64552. /**
  64553. * Creates a tiled plane mesh
  64554. * * The parameter `pattern` will, depending on value, do nothing or
  64555. * * * flip (reflect about central vertical) alternate tiles across and up
  64556. * * * flip every tile on alternate rows
  64557. * * * rotate (180 degs) alternate tiles across and up
  64558. * * * rotate every tile on alternate rows
  64559. * * * flip and rotate alternate tiles across and up
  64560. * * * flip and rotate every tile on alternate rows
  64561. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64562. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64565. * * 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)
  64566. * * 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)
  64567. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64568. * @param name defines the name of the mesh
  64569. * @param options defines the options used to create the mesh
  64570. * @param scene defines the hosting scene
  64571. * @returns the box mesh
  64572. */
  64573. static CreateTiledPlane(name: string, options: {
  64574. pattern?: number;
  64575. tileSize?: number;
  64576. tileWidth?: number;
  64577. tileHeight?: number;
  64578. size?: number;
  64579. width?: number;
  64580. height?: number;
  64581. alignHorizontal?: number;
  64582. alignVertical?: number;
  64583. sideOrientation?: number;
  64584. frontUVs?: Vector4;
  64585. backUVs?: Vector4;
  64586. updatable?: boolean;
  64587. }, scene?: Nullable<Scene>): Mesh;
  64588. }
  64589. }
  64590. declare module BABYLON {
  64591. /**
  64592. * Class containing static functions to help procedurally build meshes
  64593. */
  64594. export class TubeBuilder {
  64595. /**
  64596. * Creates a tube mesh.
  64597. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64598. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64599. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64600. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64601. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64602. * * 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)
  64603. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64604. * * 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
  64605. * * 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
  64606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64607. * * 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
  64608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64610. * @param name defines the name of the mesh
  64611. * @param options defines the options used to create the mesh
  64612. * @param scene defines the hosting scene
  64613. * @returns the tube mesh
  64614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64615. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64616. */
  64617. static CreateTube(name: string, options: {
  64618. path: Vector3[];
  64619. radius?: number;
  64620. tessellation?: number;
  64621. radiusFunction?: {
  64622. (i: number, distance: number): number;
  64623. };
  64624. cap?: number;
  64625. arc?: number;
  64626. updatable?: boolean;
  64627. sideOrientation?: number;
  64628. frontUVs?: Vector4;
  64629. backUVs?: Vector4;
  64630. instance?: Mesh;
  64631. invertUV?: boolean;
  64632. }, scene?: Nullable<Scene>): Mesh;
  64633. }
  64634. }
  64635. declare module BABYLON {
  64636. /**
  64637. * Class containing static functions to help procedurally build meshes
  64638. */
  64639. export class IcoSphereBuilder {
  64640. /**
  64641. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64642. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64643. * * 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`)
  64644. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64645. * * 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
  64646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64647. * * 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
  64648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64649. * @param name defines the name of the mesh
  64650. * @param options defines the options used to create the mesh
  64651. * @param scene defines the hosting scene
  64652. * @returns the icosahedron mesh
  64653. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64654. */
  64655. static CreateIcoSphere(name: string, options: {
  64656. radius?: number;
  64657. radiusX?: number;
  64658. radiusY?: number;
  64659. radiusZ?: number;
  64660. flat?: boolean;
  64661. subdivisions?: number;
  64662. sideOrientation?: number;
  64663. frontUVs?: Vector4;
  64664. backUVs?: Vector4;
  64665. updatable?: boolean;
  64666. }, scene?: Nullable<Scene>): Mesh;
  64667. }
  64668. }
  64669. declare module BABYLON {
  64670. /**
  64671. * Class containing static functions to help procedurally build meshes
  64672. */
  64673. export class DecalBuilder {
  64674. /**
  64675. * Creates a decal mesh.
  64676. * 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
  64677. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64678. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64679. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64680. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64681. * @param name defines the name of the mesh
  64682. * @param sourceMesh defines the mesh where the decal must be applied
  64683. * @param options defines the options used to create the mesh
  64684. * @param scene defines the hosting scene
  64685. * @returns the decal mesh
  64686. * @see https://doc.babylonjs.com/how_to/decals
  64687. */
  64688. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64689. position?: Vector3;
  64690. normal?: Vector3;
  64691. size?: Vector3;
  64692. angle?: number;
  64693. }): Mesh;
  64694. }
  64695. }
  64696. declare module BABYLON {
  64697. /**
  64698. * Class containing static functions to help procedurally build meshes
  64699. */
  64700. export class MeshBuilder {
  64701. /**
  64702. * Creates a box mesh
  64703. * * The parameter `size` sets the size (float) of each box side (default 1)
  64704. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64705. * * 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)
  64706. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64708. * * 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
  64709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64710. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64711. * @param name defines the name of the mesh
  64712. * @param options defines the options used to create the mesh
  64713. * @param scene defines the hosting scene
  64714. * @returns the box mesh
  64715. */
  64716. static CreateBox(name: string, options: {
  64717. size?: number;
  64718. width?: number;
  64719. height?: number;
  64720. depth?: number;
  64721. faceUV?: Vector4[];
  64722. faceColors?: Color4[];
  64723. sideOrientation?: number;
  64724. frontUVs?: Vector4;
  64725. backUVs?: Vector4;
  64726. wrap?: boolean;
  64727. topBaseAt?: number;
  64728. bottomBaseAt?: number;
  64729. updatable?: boolean;
  64730. }, scene?: Nullable<Scene>): Mesh;
  64731. /**
  64732. * Creates a tiled box mesh
  64733. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64735. * @param name defines the name of the mesh
  64736. * @param options defines the options used to create the mesh
  64737. * @param scene defines the hosting scene
  64738. * @returns the tiled box mesh
  64739. */
  64740. static CreateTiledBox(name: string, options: {
  64741. pattern?: number;
  64742. size?: number;
  64743. width?: number;
  64744. height?: number;
  64745. depth: number;
  64746. tileSize?: number;
  64747. tileWidth?: number;
  64748. tileHeight?: number;
  64749. faceUV?: Vector4[];
  64750. faceColors?: Color4[];
  64751. alignHorizontal?: number;
  64752. alignVertical?: number;
  64753. sideOrientation?: number;
  64754. updatable?: boolean;
  64755. }, scene?: Nullable<Scene>): Mesh;
  64756. /**
  64757. * Creates a sphere mesh
  64758. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64759. * * 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`)
  64760. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64761. * * 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
  64762. * * 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)
  64763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64764. * * 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
  64765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64766. * @param name defines the name of the mesh
  64767. * @param options defines the options used to create the mesh
  64768. * @param scene defines the hosting scene
  64769. * @returns the sphere mesh
  64770. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64771. */
  64772. static CreateSphere(name: string, options: {
  64773. segments?: number;
  64774. diameter?: number;
  64775. diameterX?: number;
  64776. diameterY?: number;
  64777. diameterZ?: number;
  64778. arc?: number;
  64779. slice?: number;
  64780. sideOrientation?: number;
  64781. frontUVs?: Vector4;
  64782. backUVs?: Vector4;
  64783. updatable?: boolean;
  64784. }, scene?: Nullable<Scene>): Mesh;
  64785. /**
  64786. * Creates a plane polygonal mesh. By default, this is a disc
  64787. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64788. * * 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
  64789. * * 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
  64790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64791. * * 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
  64792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64793. * @param name defines the name of the mesh
  64794. * @param options defines the options used to create the mesh
  64795. * @param scene defines the hosting scene
  64796. * @returns the plane polygonal mesh
  64797. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64798. */
  64799. static CreateDisc(name: string, options: {
  64800. radius?: number;
  64801. tessellation?: number;
  64802. arc?: number;
  64803. updatable?: boolean;
  64804. sideOrientation?: number;
  64805. frontUVs?: Vector4;
  64806. backUVs?: Vector4;
  64807. }, scene?: Nullable<Scene>): Mesh;
  64808. /**
  64809. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64810. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64811. * * 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`)
  64812. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64813. * * 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
  64814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64815. * * 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
  64816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64817. * @param name defines the name of the mesh
  64818. * @param options defines the options used to create the mesh
  64819. * @param scene defines the hosting scene
  64820. * @returns the icosahedron mesh
  64821. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64822. */
  64823. static CreateIcoSphere(name: string, options: {
  64824. radius?: number;
  64825. radiusX?: number;
  64826. radiusY?: number;
  64827. radiusZ?: number;
  64828. flat?: boolean;
  64829. subdivisions?: number;
  64830. sideOrientation?: number;
  64831. frontUVs?: Vector4;
  64832. backUVs?: Vector4;
  64833. updatable?: boolean;
  64834. }, scene?: Nullable<Scene>): Mesh;
  64835. /**
  64836. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64837. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64838. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64839. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64840. * * 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
  64841. * * 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
  64842. * * 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
  64843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64844. * * 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
  64845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64846. * * 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
  64847. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64848. * * 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
  64849. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64851. * @param name defines the name of the mesh
  64852. * @param options defines the options used to create the mesh
  64853. * @param scene defines the hosting scene
  64854. * @returns the ribbon mesh
  64855. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64857. */
  64858. static CreateRibbon(name: string, options: {
  64859. pathArray: Vector3[][];
  64860. closeArray?: boolean;
  64861. closePath?: boolean;
  64862. offset?: number;
  64863. updatable?: boolean;
  64864. sideOrientation?: number;
  64865. frontUVs?: Vector4;
  64866. backUVs?: Vector4;
  64867. instance?: Mesh;
  64868. invertUV?: boolean;
  64869. uvs?: Vector2[];
  64870. colors?: Color4[];
  64871. }, scene?: Nullable<Scene>): Mesh;
  64872. /**
  64873. * Creates a cylinder or a cone mesh
  64874. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64875. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64876. * * 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.
  64877. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64878. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64879. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64880. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64881. * * 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).
  64882. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64883. * * 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).
  64884. * * 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
  64885. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64886. * * 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
  64887. * * 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.
  64888. * * If `enclose` is false, a ring surface is one element.
  64889. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64890. * * 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
  64891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64892. * * 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
  64893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64894. * @param name defines the name of the mesh
  64895. * @param options defines the options used to create the mesh
  64896. * @param scene defines the hosting scene
  64897. * @returns the cylinder mesh
  64898. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64899. */
  64900. static CreateCylinder(name: string, options: {
  64901. height?: number;
  64902. diameterTop?: number;
  64903. diameterBottom?: number;
  64904. diameter?: number;
  64905. tessellation?: number;
  64906. subdivisions?: number;
  64907. arc?: number;
  64908. faceColors?: Color4[];
  64909. faceUV?: Vector4[];
  64910. updatable?: boolean;
  64911. hasRings?: boolean;
  64912. enclose?: boolean;
  64913. cap?: number;
  64914. sideOrientation?: number;
  64915. frontUVs?: Vector4;
  64916. backUVs?: Vector4;
  64917. }, scene?: Nullable<Scene>): Mesh;
  64918. /**
  64919. * Creates a torus mesh
  64920. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64921. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64922. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64924. * * 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
  64925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64926. * @param name defines the name of the mesh
  64927. * @param options defines the options used to create the mesh
  64928. * @param scene defines the hosting scene
  64929. * @returns the torus mesh
  64930. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64931. */
  64932. static CreateTorus(name: string, options: {
  64933. diameter?: number;
  64934. thickness?: number;
  64935. tessellation?: number;
  64936. updatable?: boolean;
  64937. sideOrientation?: number;
  64938. frontUVs?: Vector4;
  64939. backUVs?: Vector4;
  64940. }, scene?: Nullable<Scene>): Mesh;
  64941. /**
  64942. * Creates a torus knot mesh
  64943. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64944. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64945. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64946. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64948. * * 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
  64949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64950. * @param name defines the name of the mesh
  64951. * @param options defines the options used to create the mesh
  64952. * @param scene defines the hosting scene
  64953. * @returns the torus knot mesh
  64954. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64955. */
  64956. static CreateTorusKnot(name: string, options: {
  64957. radius?: number;
  64958. tube?: number;
  64959. radialSegments?: number;
  64960. tubularSegments?: number;
  64961. p?: number;
  64962. q?: number;
  64963. updatable?: boolean;
  64964. sideOrientation?: number;
  64965. frontUVs?: Vector4;
  64966. backUVs?: Vector4;
  64967. }, scene?: Nullable<Scene>): Mesh;
  64968. /**
  64969. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64970. * * 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
  64971. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64972. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64973. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64974. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64975. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64976. * * 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
  64977. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64980. * @param name defines the name of the new line system
  64981. * @param options defines the options used to create the line system
  64982. * @param scene defines the hosting scene
  64983. * @returns a new line system mesh
  64984. */
  64985. static CreateLineSystem(name: string, options: {
  64986. lines: Vector3[][];
  64987. updatable?: boolean;
  64988. instance?: Nullable<LinesMesh>;
  64989. colors?: Nullable<Color4[][]>;
  64990. useVertexAlpha?: boolean;
  64991. }, scene: Nullable<Scene>): LinesMesh;
  64992. /**
  64993. * Creates a line mesh
  64994. * 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
  64995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64996. * * The parameter `points` is an array successive Vector3
  64997. * * 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
  64998. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64999. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65000. * * When updating an instance, remember that only point positions can change, not the number of points
  65001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65003. * @param name defines the name of the new line system
  65004. * @param options defines the options used to create the line system
  65005. * @param scene defines the hosting scene
  65006. * @returns a new line mesh
  65007. */
  65008. static CreateLines(name: string, options: {
  65009. points: Vector3[];
  65010. updatable?: boolean;
  65011. instance?: Nullable<LinesMesh>;
  65012. colors?: Color4[];
  65013. useVertexAlpha?: boolean;
  65014. }, scene?: Nullable<Scene>): LinesMesh;
  65015. /**
  65016. * Creates a dashed line mesh
  65017. * * 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
  65018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65019. * * The parameter `points` is an array successive Vector3
  65020. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65021. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65022. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65023. * * 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
  65024. * * When updating an instance, remember that only point positions can change, not the number of points
  65025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65026. * @param name defines the name of the mesh
  65027. * @param options defines the options used to create the mesh
  65028. * @param scene defines the hosting scene
  65029. * @returns the dashed line mesh
  65030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65031. */
  65032. static CreateDashedLines(name: string, options: {
  65033. points: Vector3[];
  65034. dashSize?: number;
  65035. gapSize?: number;
  65036. dashNb?: number;
  65037. updatable?: boolean;
  65038. instance?: LinesMesh;
  65039. }, scene?: Nullable<Scene>): LinesMesh;
  65040. /**
  65041. * 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.
  65042. * * 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.
  65043. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65044. * * 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.
  65045. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65046. * * 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
  65047. * * 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
  65048. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65050. * * 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
  65051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65053. * @param name defines the name of the mesh
  65054. * @param options defines the options used to create the mesh
  65055. * @param scene defines the hosting scene
  65056. * @returns the extruded shape mesh
  65057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65059. */
  65060. static ExtrudeShape(name: string, options: {
  65061. shape: Vector3[];
  65062. path: Vector3[];
  65063. scale?: number;
  65064. rotation?: number;
  65065. cap?: number;
  65066. updatable?: boolean;
  65067. sideOrientation?: number;
  65068. frontUVs?: Vector4;
  65069. backUVs?: Vector4;
  65070. instance?: Mesh;
  65071. invertUV?: boolean;
  65072. }, scene?: Nullable<Scene>): Mesh;
  65073. /**
  65074. * Creates an custom extruded shape mesh.
  65075. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65076. * * 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.
  65077. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65078. * * 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
  65079. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65080. * * 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
  65081. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65082. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65083. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65084. * * 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
  65085. * * 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
  65086. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65088. * * 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
  65089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65091. * @param name defines the name of the mesh
  65092. * @param options defines the options used to create the mesh
  65093. * @param scene defines the hosting scene
  65094. * @returns the custom extruded shape mesh
  65095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65098. */
  65099. static ExtrudeShapeCustom(name: string, options: {
  65100. shape: Vector3[];
  65101. path: Vector3[];
  65102. scaleFunction?: any;
  65103. rotationFunction?: any;
  65104. ribbonCloseArray?: boolean;
  65105. ribbonClosePath?: boolean;
  65106. cap?: number;
  65107. updatable?: boolean;
  65108. sideOrientation?: number;
  65109. frontUVs?: Vector4;
  65110. backUVs?: Vector4;
  65111. instance?: Mesh;
  65112. invertUV?: boolean;
  65113. }, scene?: Nullable<Scene>): Mesh;
  65114. /**
  65115. * Creates lathe mesh.
  65116. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65117. * * 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
  65118. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65119. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65120. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65121. * * 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
  65122. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65123. * * 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
  65124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65125. * * 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
  65126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65128. * @param name defines the name of the mesh
  65129. * @param options defines the options used to create the mesh
  65130. * @param scene defines the hosting scene
  65131. * @returns the lathe mesh
  65132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65133. */
  65134. static CreateLathe(name: string, options: {
  65135. shape: Vector3[];
  65136. radius?: number;
  65137. tessellation?: number;
  65138. clip?: number;
  65139. arc?: number;
  65140. closed?: boolean;
  65141. updatable?: boolean;
  65142. sideOrientation?: number;
  65143. frontUVs?: Vector4;
  65144. backUVs?: Vector4;
  65145. cap?: number;
  65146. invertUV?: boolean;
  65147. }, scene?: Nullable<Scene>): Mesh;
  65148. /**
  65149. * Creates a tiled plane mesh
  65150. * * You can set a limited pattern arrangement with the tiles
  65151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65152. * * 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
  65153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65154. * @param name defines the name of the mesh
  65155. * @param options defines the options used to create the mesh
  65156. * @param scene defines the hosting scene
  65157. * @returns the plane mesh
  65158. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65159. */
  65160. static CreateTiledPlane(name: string, options: {
  65161. pattern?: number;
  65162. tileSize?: number;
  65163. tileWidth?: number;
  65164. tileHeight?: number;
  65165. size?: number;
  65166. width?: number;
  65167. height?: number;
  65168. alignHorizontal?: number;
  65169. alignVertical?: number;
  65170. sideOrientation?: number;
  65171. frontUVs?: Vector4;
  65172. backUVs?: Vector4;
  65173. updatable?: boolean;
  65174. }, scene?: Nullable<Scene>): Mesh;
  65175. /**
  65176. * Creates a plane mesh
  65177. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65178. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65179. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65181. * * 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
  65182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65183. * @param name defines the name of the mesh
  65184. * @param options defines the options used to create the mesh
  65185. * @param scene defines the hosting scene
  65186. * @returns the plane mesh
  65187. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65188. */
  65189. static CreatePlane(name: string, options: {
  65190. size?: number;
  65191. width?: number;
  65192. height?: number;
  65193. sideOrientation?: number;
  65194. frontUVs?: Vector4;
  65195. backUVs?: Vector4;
  65196. updatable?: boolean;
  65197. sourcePlane?: Plane;
  65198. }, scene?: Nullable<Scene>): Mesh;
  65199. /**
  65200. * Creates a ground mesh
  65201. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65202. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65204. * @param name defines the name of the mesh
  65205. * @param options defines the options used to create the mesh
  65206. * @param scene defines the hosting scene
  65207. * @returns the ground mesh
  65208. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65209. */
  65210. static CreateGround(name: string, options: {
  65211. width?: number;
  65212. height?: number;
  65213. subdivisions?: number;
  65214. subdivisionsX?: number;
  65215. subdivisionsY?: number;
  65216. updatable?: boolean;
  65217. }, scene?: Nullable<Scene>): Mesh;
  65218. /**
  65219. * Creates a tiled ground mesh
  65220. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65221. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65222. * * 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
  65223. * * 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
  65224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65225. * @param name defines the name of the mesh
  65226. * @param options defines the options used to create the mesh
  65227. * @param scene defines the hosting scene
  65228. * @returns the tiled ground mesh
  65229. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65230. */
  65231. static CreateTiledGround(name: string, options: {
  65232. xmin: number;
  65233. zmin: number;
  65234. xmax: number;
  65235. zmax: number;
  65236. subdivisions?: {
  65237. w: number;
  65238. h: number;
  65239. };
  65240. precision?: {
  65241. w: number;
  65242. h: number;
  65243. };
  65244. updatable?: boolean;
  65245. }, scene?: Nullable<Scene>): Mesh;
  65246. /**
  65247. * Creates a ground mesh from a height map
  65248. * * The parameter `url` sets the URL of the height map image resource.
  65249. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65250. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65251. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65252. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65253. * * 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.
  65254. * * 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).
  65255. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65257. * @param name defines the name of the mesh
  65258. * @param url defines the url to the height map
  65259. * @param options defines the options used to create the mesh
  65260. * @param scene defines the hosting scene
  65261. * @returns the ground mesh
  65262. * @see https://doc.babylonjs.com/babylon101/height_map
  65263. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65264. */
  65265. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65266. width?: number;
  65267. height?: number;
  65268. subdivisions?: number;
  65269. minHeight?: number;
  65270. maxHeight?: number;
  65271. colorFilter?: Color3;
  65272. alphaFilter?: number;
  65273. updatable?: boolean;
  65274. onReady?: (mesh: GroundMesh) => void;
  65275. }, scene?: Nullable<Scene>): GroundMesh;
  65276. /**
  65277. * Creates a polygon mesh
  65278. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65279. * * 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
  65280. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65282. * * 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)
  65283. * * Remember you can only change the shape positions, not their number when updating a polygon
  65284. * @param name defines the name of the mesh
  65285. * @param options defines the options used to create the mesh
  65286. * @param scene defines the hosting scene
  65287. * @param earcutInjection can be used to inject your own earcut reference
  65288. * @returns the polygon mesh
  65289. */
  65290. static CreatePolygon(name: string, options: {
  65291. shape: Vector3[];
  65292. holes?: Vector3[][];
  65293. depth?: number;
  65294. faceUV?: Vector4[];
  65295. faceColors?: Color4[];
  65296. updatable?: boolean;
  65297. sideOrientation?: number;
  65298. frontUVs?: Vector4;
  65299. backUVs?: Vector4;
  65300. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65301. /**
  65302. * Creates an extruded polygon mesh, with depth in the Y direction.
  65303. * * 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)
  65304. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65305. * @param name defines the name of the mesh
  65306. * @param options defines the options used to create the mesh
  65307. * @param scene defines the hosting scene
  65308. * @param earcutInjection can be used to inject your own earcut reference
  65309. * @returns the polygon mesh
  65310. */
  65311. static ExtrudePolygon(name: string, options: {
  65312. shape: Vector3[];
  65313. holes?: Vector3[][];
  65314. depth?: number;
  65315. faceUV?: Vector4[];
  65316. faceColors?: Color4[];
  65317. updatable?: boolean;
  65318. sideOrientation?: number;
  65319. frontUVs?: Vector4;
  65320. backUVs?: Vector4;
  65321. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65322. /**
  65323. * Creates a tube mesh.
  65324. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65325. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65326. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65327. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65328. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65329. * * 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)
  65330. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65331. * * 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
  65332. * * 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
  65333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65334. * * 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
  65335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65337. * @param name defines the name of the mesh
  65338. * @param options defines the options used to create the mesh
  65339. * @param scene defines the hosting scene
  65340. * @returns the tube mesh
  65341. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65342. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65343. */
  65344. static CreateTube(name: string, options: {
  65345. path: Vector3[];
  65346. radius?: number;
  65347. tessellation?: number;
  65348. radiusFunction?: {
  65349. (i: number, distance: number): number;
  65350. };
  65351. cap?: number;
  65352. arc?: number;
  65353. updatable?: boolean;
  65354. sideOrientation?: number;
  65355. frontUVs?: Vector4;
  65356. backUVs?: Vector4;
  65357. instance?: Mesh;
  65358. invertUV?: boolean;
  65359. }, scene?: Nullable<Scene>): Mesh;
  65360. /**
  65361. * Creates a polyhedron mesh
  65362. * * 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
  65363. * * The parameter `size` (positive float, default 1) sets the polygon size
  65364. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65365. * * 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`
  65366. * * 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
  65367. * * 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)`)
  65368. * * 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
  65369. * * 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
  65370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65371. * * 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
  65372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65373. * @param name defines the name of the mesh
  65374. * @param options defines the options used to create the mesh
  65375. * @param scene defines the hosting scene
  65376. * @returns the polyhedron mesh
  65377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65378. */
  65379. static CreatePolyhedron(name: string, options: {
  65380. type?: number;
  65381. size?: number;
  65382. sizeX?: number;
  65383. sizeY?: number;
  65384. sizeZ?: number;
  65385. custom?: any;
  65386. faceUV?: Vector4[];
  65387. faceColors?: Color4[];
  65388. flat?: boolean;
  65389. updatable?: boolean;
  65390. sideOrientation?: number;
  65391. frontUVs?: Vector4;
  65392. backUVs?: Vector4;
  65393. }, scene?: Nullable<Scene>): Mesh;
  65394. /**
  65395. * Creates a decal mesh.
  65396. * 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
  65397. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65398. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65399. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65400. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65401. * @param name defines the name of the mesh
  65402. * @param sourceMesh defines the mesh where the decal must be applied
  65403. * @param options defines the options used to create the mesh
  65404. * @param scene defines the hosting scene
  65405. * @returns the decal mesh
  65406. * @see https://doc.babylonjs.com/how_to/decals
  65407. */
  65408. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65409. position?: Vector3;
  65410. normal?: Vector3;
  65411. size?: Vector3;
  65412. angle?: number;
  65413. }): Mesh;
  65414. }
  65415. }
  65416. declare module BABYLON {
  65417. /**
  65418. * A simplifier interface for future simplification implementations
  65419. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65420. */
  65421. export interface ISimplifier {
  65422. /**
  65423. * Simplification of a given mesh according to the given settings.
  65424. * Since this requires computation, it is assumed that the function runs async.
  65425. * @param settings The settings of the simplification, including quality and distance
  65426. * @param successCallback A callback that will be called after the mesh was simplified.
  65427. * @param errorCallback in case of an error, this callback will be called. optional.
  65428. */
  65429. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65430. }
  65431. /**
  65432. * Expected simplification settings.
  65433. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65434. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65435. */
  65436. export interface ISimplificationSettings {
  65437. /**
  65438. * Gets or sets the expected quality
  65439. */
  65440. quality: number;
  65441. /**
  65442. * Gets or sets the distance when this optimized version should be used
  65443. */
  65444. distance: number;
  65445. /**
  65446. * Gets an already optimized mesh
  65447. */
  65448. optimizeMesh?: boolean;
  65449. }
  65450. /**
  65451. * Class used to specify simplification options
  65452. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65453. */
  65454. export class SimplificationSettings implements ISimplificationSettings {
  65455. /** expected quality */
  65456. quality: number;
  65457. /** distance when this optimized version should be used */
  65458. distance: number;
  65459. /** already optimized mesh */
  65460. optimizeMesh?: boolean | undefined;
  65461. /**
  65462. * Creates a SimplificationSettings
  65463. * @param quality expected quality
  65464. * @param distance distance when this optimized version should be used
  65465. * @param optimizeMesh already optimized mesh
  65466. */
  65467. constructor(
  65468. /** expected quality */
  65469. quality: number,
  65470. /** distance when this optimized version should be used */
  65471. distance: number,
  65472. /** already optimized mesh */
  65473. optimizeMesh?: boolean | undefined);
  65474. }
  65475. /**
  65476. * Interface used to define a simplification task
  65477. */
  65478. export interface ISimplificationTask {
  65479. /**
  65480. * Array of settings
  65481. */
  65482. settings: Array<ISimplificationSettings>;
  65483. /**
  65484. * Simplification type
  65485. */
  65486. simplificationType: SimplificationType;
  65487. /**
  65488. * Mesh to simplify
  65489. */
  65490. mesh: Mesh;
  65491. /**
  65492. * Callback called on success
  65493. */
  65494. successCallback?: () => void;
  65495. /**
  65496. * Defines if parallel processing can be used
  65497. */
  65498. parallelProcessing: boolean;
  65499. }
  65500. /**
  65501. * Queue used to order the simplification tasks
  65502. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65503. */
  65504. export class SimplificationQueue {
  65505. private _simplificationArray;
  65506. /**
  65507. * Gets a boolean indicating that the process is still running
  65508. */
  65509. running: boolean;
  65510. /**
  65511. * Creates a new queue
  65512. */
  65513. constructor();
  65514. /**
  65515. * Adds a new simplification task
  65516. * @param task defines a task to add
  65517. */
  65518. addTask(task: ISimplificationTask): void;
  65519. /**
  65520. * Execute next task
  65521. */
  65522. executeNext(): void;
  65523. /**
  65524. * Execute a simplification task
  65525. * @param task defines the task to run
  65526. */
  65527. runSimplification(task: ISimplificationTask): void;
  65528. private getSimplifier;
  65529. }
  65530. /**
  65531. * The implemented types of simplification
  65532. * At the moment only Quadratic Error Decimation is implemented
  65533. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65534. */
  65535. export enum SimplificationType {
  65536. /** Quadratic error decimation */
  65537. QUADRATIC = 0
  65538. }
  65539. /**
  65540. * An implementation of the Quadratic Error simplification algorithm.
  65541. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65542. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65543. * @author RaananW
  65544. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65545. */
  65546. export class QuadraticErrorSimplification implements ISimplifier {
  65547. private _mesh;
  65548. private triangles;
  65549. private vertices;
  65550. private references;
  65551. private _reconstructedMesh;
  65552. /** Gets or sets the number pf sync interations */
  65553. syncIterations: number;
  65554. /** Gets or sets the aggressiveness of the simplifier */
  65555. aggressiveness: number;
  65556. /** Gets or sets the number of allowed iterations for decimation */
  65557. decimationIterations: number;
  65558. /** Gets or sets the espilon to use for bounding box computation */
  65559. boundingBoxEpsilon: number;
  65560. /**
  65561. * Creates a new QuadraticErrorSimplification
  65562. * @param _mesh defines the target mesh
  65563. */
  65564. constructor(_mesh: Mesh);
  65565. /**
  65566. * Simplification of a given mesh according to the given settings.
  65567. * Since this requires computation, it is assumed that the function runs async.
  65568. * @param settings The settings of the simplification, including quality and distance
  65569. * @param successCallback A callback that will be called after the mesh was simplified.
  65570. */
  65571. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65572. private runDecimation;
  65573. private initWithMesh;
  65574. private init;
  65575. private reconstructMesh;
  65576. private initDecimatedMesh;
  65577. private isFlipped;
  65578. private updateTriangles;
  65579. private identifyBorder;
  65580. private updateMesh;
  65581. private vertexError;
  65582. private calculateError;
  65583. }
  65584. }
  65585. declare module BABYLON {
  65586. interface Scene {
  65587. /** @hidden (Backing field) */
  65588. _simplificationQueue: SimplificationQueue;
  65589. /**
  65590. * Gets or sets the simplification queue attached to the scene
  65591. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65592. */
  65593. simplificationQueue: SimplificationQueue;
  65594. }
  65595. interface Mesh {
  65596. /**
  65597. * Simplify the mesh according to the given array of settings.
  65598. * Function will return immediately and will simplify async
  65599. * @param settings a collection of simplification settings
  65600. * @param parallelProcessing should all levels calculate parallel or one after the other
  65601. * @param simplificationType the type of simplification to run
  65602. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65603. * @returns the current mesh
  65604. */
  65605. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65606. }
  65607. /**
  65608. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65609. * created in a scene
  65610. */
  65611. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65612. /**
  65613. * The component name helpfull to identify the component in the list of scene components.
  65614. */
  65615. readonly name: string;
  65616. /**
  65617. * The scene the component belongs to.
  65618. */
  65619. scene: Scene;
  65620. /**
  65621. * Creates a new instance of the component for the given scene
  65622. * @param scene Defines the scene to register the component in
  65623. */
  65624. constructor(scene: Scene);
  65625. /**
  65626. * Registers the component in a given scene
  65627. */
  65628. register(): void;
  65629. /**
  65630. * Rebuilds the elements related to this component in case of
  65631. * context lost for instance.
  65632. */
  65633. rebuild(): void;
  65634. /**
  65635. * Disposes the component and the associated ressources
  65636. */
  65637. dispose(): void;
  65638. private _beforeCameraUpdate;
  65639. }
  65640. }
  65641. declare module BABYLON {
  65642. interface Mesh {
  65643. /**
  65644. * Creates a new thin instance
  65645. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65646. * @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
  65647. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65648. */
  65649. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65650. /**
  65651. * Adds the transformation (matrix) of the current mesh as a thin instance
  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
  65654. */
  65655. thinInstanceAddSelf(refresh: boolean): number;
  65656. /**
  65657. * Registers a custom attribute to be used with thin instances
  65658. * @param kind name of the attribute
  65659. * @param stride size in floats of the attribute
  65660. */
  65661. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65662. /**
  65663. * Sets the matrix of a thin instance
  65664. * @param index index of the thin instance
  65665. * @param matrix matrix to set
  65666. * @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
  65667. */
  65668. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65669. /**
  65670. * Sets the value of a custom attribute for a thin instance
  65671. * @param kind name of the attribute
  65672. * @param index index of the thin instance
  65673. * @param value value to set
  65674. * @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
  65675. */
  65676. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65677. /**
  65678. * 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.
  65679. */
  65680. thinInstanceCount: number;
  65681. /**
  65682. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65683. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65684. * @param buffer buffer to set
  65685. * @param stride size in floats of each value of the buffer
  65686. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65687. */
  65688. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65689. /**
  65690. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65691. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65692. */
  65693. thinInstanceBufferUpdated(kind: string): void;
  65694. /**
  65695. * Refreshes the bounding info, taking into account all the thin instances defined
  65696. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65697. */
  65698. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65699. /** @hidden */
  65700. _thinInstanceInitializeUserStorage(): void;
  65701. /** @hidden */
  65702. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65703. /** @hidden */
  65704. _userThinInstanceBuffersStorage: {
  65705. data: {
  65706. [key: string]: Float32Array;
  65707. };
  65708. sizes: {
  65709. [key: string]: number;
  65710. };
  65711. vertexBuffers: {
  65712. [key: string]: Nullable<VertexBuffer>;
  65713. };
  65714. strides: {
  65715. [key: string]: number;
  65716. };
  65717. };
  65718. }
  65719. }
  65720. declare module BABYLON {
  65721. /**
  65722. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65723. */
  65724. export interface INavigationEnginePlugin {
  65725. /**
  65726. * plugin name
  65727. */
  65728. name: string;
  65729. /**
  65730. * Creates a navigation mesh
  65731. * @param meshes array of all the geometry used to compute the navigatio mesh
  65732. * @param parameters bunch of parameters used to filter geometry
  65733. */
  65734. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65735. /**
  65736. * Create a navigation mesh debug mesh
  65737. * @param scene is where the mesh will be added
  65738. * @returns debug display mesh
  65739. */
  65740. createDebugNavMesh(scene: Scene): Mesh;
  65741. /**
  65742. * Get a navigation mesh constrained position, closest to the parameter position
  65743. * @param position world position
  65744. * @returns the closest point to position constrained by the navigation mesh
  65745. */
  65746. getClosestPoint(position: Vector3): Vector3;
  65747. /**
  65748. * Get a navigation mesh constrained position, closest to the parameter position
  65749. * @param position world position
  65750. * @param result output the closest point to position constrained by the navigation mesh
  65751. */
  65752. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65753. /**
  65754. * Get a navigation mesh constrained position, within a particular radius
  65755. * @param position world position
  65756. * @param maxRadius the maximum distance to the constrained world position
  65757. * @returns the closest point to position constrained by the navigation mesh
  65758. */
  65759. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65760. /**
  65761. * Get a navigation mesh constrained position, within a particular radius
  65762. * @param position world position
  65763. * @param maxRadius the maximum distance to the constrained world position
  65764. * @param result output the closest point to position constrained by the navigation mesh
  65765. */
  65766. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65767. /**
  65768. * Compute the final position from a segment made of destination-position
  65769. * @param position world position
  65770. * @param destination world position
  65771. * @returns the resulting point along the navmesh
  65772. */
  65773. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65774. /**
  65775. * Compute the final position from a segment made of destination-position
  65776. * @param position world position
  65777. * @param destination world position
  65778. * @param result output the resulting point along the navmesh
  65779. */
  65780. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65781. /**
  65782. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65783. * @param start world position
  65784. * @param end world position
  65785. * @returns array containing world position composing the path
  65786. */
  65787. computePath(start: Vector3, end: Vector3): Vector3[];
  65788. /**
  65789. * If this plugin is supported
  65790. * @returns true if plugin is supported
  65791. */
  65792. isSupported(): boolean;
  65793. /**
  65794. * Create a new Crowd so you can add agents
  65795. * @param maxAgents the maximum agent count in the crowd
  65796. * @param maxAgentRadius the maximum radius an agent can have
  65797. * @param scene to attach the crowd to
  65798. * @returns the crowd you can add agents to
  65799. */
  65800. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65801. /**
  65802. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65803. * The queries will try to find a solution within those bounds
  65804. * default is (1,1,1)
  65805. * @param extent x,y,z value that define the extent around the queries point of reference
  65806. */
  65807. setDefaultQueryExtent(extent: Vector3): void;
  65808. /**
  65809. * Get the Bounding box extent specified by setDefaultQueryExtent
  65810. * @returns the box extent values
  65811. */
  65812. getDefaultQueryExtent(): Vector3;
  65813. /**
  65814. * build the navmesh from a previously saved state using getNavmeshData
  65815. * @param data the Uint8Array returned by getNavmeshData
  65816. */
  65817. buildFromNavmeshData(data: Uint8Array): void;
  65818. /**
  65819. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65820. * @returns data the Uint8Array that can be saved and reused
  65821. */
  65822. getNavmeshData(): Uint8Array;
  65823. /**
  65824. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65825. * @param result output the box extent values
  65826. */
  65827. getDefaultQueryExtentToRef(result: Vector3): void;
  65828. /**
  65829. * Release all resources
  65830. */
  65831. dispose(): void;
  65832. }
  65833. /**
  65834. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65835. */
  65836. export interface ICrowd {
  65837. /**
  65838. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65839. * You can attach anything to that node. The node position is updated in the scene update tick.
  65840. * @param pos world position that will be constrained by the navigation mesh
  65841. * @param parameters agent parameters
  65842. * @param transform hooked to the agent that will be update by the scene
  65843. * @returns agent index
  65844. */
  65845. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65846. /**
  65847. * Returns the agent position in world space
  65848. * @param index agent index returned by addAgent
  65849. * @returns world space position
  65850. */
  65851. getAgentPosition(index: number): Vector3;
  65852. /**
  65853. * Gets the agent position result in world space
  65854. * @param index agent index returned by addAgent
  65855. * @param result output world space position
  65856. */
  65857. getAgentPositionToRef(index: number, result: Vector3): void;
  65858. /**
  65859. * Gets the agent velocity in world space
  65860. * @param index agent index returned by addAgent
  65861. * @returns world space velocity
  65862. */
  65863. getAgentVelocity(index: number): Vector3;
  65864. /**
  65865. * Gets the agent velocity result in world space
  65866. * @param index agent index returned by addAgent
  65867. * @param result output world space velocity
  65868. */
  65869. getAgentVelocityToRef(index: number, result: Vector3): void;
  65870. /**
  65871. * remove a particular agent previously created
  65872. * @param index agent index returned by addAgent
  65873. */
  65874. removeAgent(index: number): void;
  65875. /**
  65876. * get the list of all agents attached to this crowd
  65877. * @returns list of agent indices
  65878. */
  65879. getAgents(): number[];
  65880. /**
  65881. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65882. * @param deltaTime in seconds
  65883. */
  65884. update(deltaTime: number): void;
  65885. /**
  65886. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65887. * @param index agent index returned by addAgent
  65888. * @param destination targeted world position
  65889. */
  65890. agentGoto(index: number, destination: Vector3): void;
  65891. /**
  65892. * Teleport the agent to a new position
  65893. * @param index agent index returned by addAgent
  65894. * @param destination targeted world position
  65895. */
  65896. agentTeleport(index: number, destination: Vector3): void;
  65897. /**
  65898. * Update agent parameters
  65899. * @param index agent index returned by addAgent
  65900. * @param parameters agent parameters
  65901. */
  65902. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65903. /**
  65904. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65905. * The queries will try to find a solution within those bounds
  65906. * default is (1,1,1)
  65907. * @param extent x,y,z value that define the extent around the queries point of reference
  65908. */
  65909. setDefaultQueryExtent(extent: Vector3): void;
  65910. /**
  65911. * Get the Bounding box extent specified by setDefaultQueryExtent
  65912. * @returns the box extent values
  65913. */
  65914. getDefaultQueryExtent(): Vector3;
  65915. /**
  65916. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65917. * @param result output the box extent values
  65918. */
  65919. getDefaultQueryExtentToRef(result: Vector3): void;
  65920. /**
  65921. * Release all resources
  65922. */
  65923. dispose(): void;
  65924. }
  65925. /**
  65926. * Configures an agent
  65927. */
  65928. export interface IAgentParameters {
  65929. /**
  65930. * Agent radius. [Limit: >= 0]
  65931. */
  65932. radius: number;
  65933. /**
  65934. * Agent height. [Limit: > 0]
  65935. */
  65936. height: number;
  65937. /**
  65938. * Maximum allowed acceleration. [Limit: >= 0]
  65939. */
  65940. maxAcceleration: number;
  65941. /**
  65942. * Maximum allowed speed. [Limit: >= 0]
  65943. */
  65944. maxSpeed: number;
  65945. /**
  65946. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65947. */
  65948. collisionQueryRange: number;
  65949. /**
  65950. * The path visibility optimization range. [Limit: > 0]
  65951. */
  65952. pathOptimizationRange: number;
  65953. /**
  65954. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65955. */
  65956. separationWeight: number;
  65957. }
  65958. /**
  65959. * Configures the navigation mesh creation
  65960. */
  65961. export interface INavMeshParameters {
  65962. /**
  65963. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65964. */
  65965. cs: number;
  65966. /**
  65967. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65968. */
  65969. ch: number;
  65970. /**
  65971. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65972. */
  65973. walkableSlopeAngle: number;
  65974. /**
  65975. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65976. * be considered walkable. [Limit: >= 3] [Units: vx]
  65977. */
  65978. walkableHeight: number;
  65979. /**
  65980. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65981. */
  65982. walkableClimb: number;
  65983. /**
  65984. * The distance to erode/shrink the walkable area of the heightfield away from
  65985. * obstructions. [Limit: >=0] [Units: vx]
  65986. */
  65987. walkableRadius: number;
  65988. /**
  65989. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65990. */
  65991. maxEdgeLen: number;
  65992. /**
  65993. * The maximum distance a simplfied contour's border edges should deviate
  65994. * the original raw contour. [Limit: >=0] [Units: vx]
  65995. */
  65996. maxSimplificationError: number;
  65997. /**
  65998. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65999. */
  66000. minRegionArea: number;
  66001. /**
  66002. * Any regions with a span count smaller than this value will, if possible,
  66003. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66004. */
  66005. mergeRegionArea: number;
  66006. /**
  66007. * The maximum number of vertices allowed for polygons generated during the
  66008. * contour to polygon conversion process. [Limit: >= 3]
  66009. */
  66010. maxVertsPerPoly: number;
  66011. /**
  66012. * Sets the sampling distance to use when generating the detail mesh.
  66013. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66014. */
  66015. detailSampleDist: number;
  66016. /**
  66017. * The maximum distance the detail mesh surface should deviate from heightfield
  66018. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66019. */
  66020. detailSampleMaxError: number;
  66021. }
  66022. }
  66023. declare module BABYLON {
  66024. /**
  66025. * RecastJS navigation plugin
  66026. */
  66027. export class RecastJSPlugin implements INavigationEnginePlugin {
  66028. /**
  66029. * Reference to the Recast library
  66030. */
  66031. bjsRECAST: any;
  66032. /**
  66033. * plugin name
  66034. */
  66035. name: string;
  66036. /**
  66037. * the first navmesh created. We might extend this to support multiple navmeshes
  66038. */
  66039. navMesh: any;
  66040. /**
  66041. * Initializes the recastJS plugin
  66042. * @param recastInjection can be used to inject your own recast reference
  66043. */
  66044. constructor(recastInjection?: any);
  66045. /**
  66046. * Creates a navigation mesh
  66047. * @param meshes array of all the geometry used to compute the navigatio mesh
  66048. * @param parameters bunch of parameters used to filter geometry
  66049. */
  66050. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66051. /**
  66052. * Create a navigation mesh debug mesh
  66053. * @param scene is where the mesh will be added
  66054. * @returns debug display mesh
  66055. */
  66056. createDebugNavMesh(scene: Scene): Mesh;
  66057. /**
  66058. * Get a navigation mesh constrained position, closest to the parameter position
  66059. * @param position world position
  66060. * @returns the closest point to position constrained by the navigation mesh
  66061. */
  66062. getClosestPoint(position: Vector3): Vector3;
  66063. /**
  66064. * Get a navigation mesh constrained position, closest to the parameter position
  66065. * @param position world position
  66066. * @param result output the closest point to position constrained by the navigation mesh
  66067. */
  66068. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66069. /**
  66070. * Get a navigation mesh constrained position, within a particular radius
  66071. * @param position world position
  66072. * @param maxRadius the maximum distance to the constrained world position
  66073. * @returns the closest point to position constrained by the navigation mesh
  66074. */
  66075. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66076. /**
  66077. * Get a navigation mesh constrained position, within a particular radius
  66078. * @param position world position
  66079. * @param maxRadius the maximum distance to the constrained world position
  66080. * @param result output the closest point to position constrained by the navigation mesh
  66081. */
  66082. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66083. /**
  66084. * Compute the final position from a segment made of destination-position
  66085. * @param position world position
  66086. * @param destination world position
  66087. * @returns the resulting point along the navmesh
  66088. */
  66089. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66090. /**
  66091. * Compute the final position from a segment made of destination-position
  66092. * @param position world position
  66093. * @param destination world position
  66094. * @param result output the resulting point along the navmesh
  66095. */
  66096. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66097. /**
  66098. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66099. * @param start world position
  66100. * @param end world position
  66101. * @returns array containing world position composing the path
  66102. */
  66103. computePath(start: Vector3, end: Vector3): Vector3[];
  66104. /**
  66105. * Create a new Crowd so you can add agents
  66106. * @param maxAgents the maximum agent count in the crowd
  66107. * @param maxAgentRadius the maximum radius an agent can have
  66108. * @param scene to attach the crowd to
  66109. * @returns the crowd you can add agents to
  66110. */
  66111. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66112. /**
  66113. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66114. * The queries will try to find a solution within those bounds
  66115. * default is (1,1,1)
  66116. * @param extent x,y,z value that define the extent around the queries point of reference
  66117. */
  66118. setDefaultQueryExtent(extent: Vector3): void;
  66119. /**
  66120. * Get the Bounding box extent specified by setDefaultQueryExtent
  66121. * @returns the box extent values
  66122. */
  66123. getDefaultQueryExtent(): Vector3;
  66124. /**
  66125. * build the navmesh from a previously saved state using getNavmeshData
  66126. * @param data the Uint8Array returned by getNavmeshData
  66127. */
  66128. buildFromNavmeshData(data: Uint8Array): void;
  66129. /**
  66130. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66131. * @returns data the Uint8Array that can be saved and reused
  66132. */
  66133. getNavmeshData(): Uint8Array;
  66134. /**
  66135. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66136. * @param result output the box extent values
  66137. */
  66138. getDefaultQueryExtentToRef(result: Vector3): void;
  66139. /**
  66140. * Disposes
  66141. */
  66142. dispose(): void;
  66143. /**
  66144. * If this plugin is supported
  66145. * @returns true if plugin is supported
  66146. */
  66147. isSupported(): boolean;
  66148. }
  66149. /**
  66150. * Recast detour crowd implementation
  66151. */
  66152. export class RecastJSCrowd implements ICrowd {
  66153. /**
  66154. * Recast/detour plugin
  66155. */
  66156. bjsRECASTPlugin: RecastJSPlugin;
  66157. /**
  66158. * Link to the detour crowd
  66159. */
  66160. recastCrowd: any;
  66161. /**
  66162. * One transform per agent
  66163. */
  66164. transforms: TransformNode[];
  66165. /**
  66166. * All agents created
  66167. */
  66168. agents: number[];
  66169. /**
  66170. * Link to the scene is kept to unregister the crowd from the scene
  66171. */
  66172. private _scene;
  66173. /**
  66174. * Observer for crowd updates
  66175. */
  66176. private _onBeforeAnimationsObserver;
  66177. /**
  66178. * Constructor
  66179. * @param plugin recastJS plugin
  66180. * @param maxAgents the maximum agent count in the crowd
  66181. * @param maxAgentRadius the maximum radius an agent can have
  66182. * @param scene to attach the crowd to
  66183. * @returns the crowd you can add agents to
  66184. */
  66185. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66186. /**
  66187. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66188. * You can attach anything to that node. The node position is updated in the scene update tick.
  66189. * @param pos world position that will be constrained by the navigation mesh
  66190. * @param parameters agent parameters
  66191. * @param transform hooked to the agent that will be update by the scene
  66192. * @returns agent index
  66193. */
  66194. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66195. /**
  66196. * Returns the agent position in world space
  66197. * @param index agent index returned by addAgent
  66198. * @returns world space position
  66199. */
  66200. getAgentPosition(index: number): Vector3;
  66201. /**
  66202. * Returns the agent position result in world space
  66203. * @param index agent index returned by addAgent
  66204. * @param result output world space position
  66205. */
  66206. getAgentPositionToRef(index: number, result: Vector3): void;
  66207. /**
  66208. * Returns the agent velocity in world space
  66209. * @param index agent index returned by addAgent
  66210. * @returns world space velocity
  66211. */
  66212. getAgentVelocity(index: number): Vector3;
  66213. /**
  66214. * Returns the agent velocity result in world space
  66215. * @param index agent index returned by addAgent
  66216. * @param result output world space velocity
  66217. */
  66218. getAgentVelocityToRef(index: number, result: Vector3): void;
  66219. /**
  66220. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66221. * @param index agent index returned by addAgent
  66222. * @param destination targeted world position
  66223. */
  66224. agentGoto(index: number, destination: Vector3): void;
  66225. /**
  66226. * Teleport the agent to a new position
  66227. * @param index agent index returned by addAgent
  66228. * @param destination targeted world position
  66229. */
  66230. agentTeleport(index: number, destination: Vector3): void;
  66231. /**
  66232. * Update agent parameters
  66233. * @param index agent index returned by addAgent
  66234. * @param parameters agent parameters
  66235. */
  66236. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66237. /**
  66238. * remove a particular agent previously created
  66239. * @param index agent index returned by addAgent
  66240. */
  66241. removeAgent(index: number): void;
  66242. /**
  66243. * get the list of all agents attached to this crowd
  66244. * @returns list of agent indices
  66245. */
  66246. getAgents(): number[];
  66247. /**
  66248. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66249. * @param deltaTime in seconds
  66250. */
  66251. update(deltaTime: number): void;
  66252. /**
  66253. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66254. * The queries will try to find a solution within those bounds
  66255. * default is (1,1,1)
  66256. * @param extent x,y,z value that define the extent around the queries point of reference
  66257. */
  66258. setDefaultQueryExtent(extent: Vector3): void;
  66259. /**
  66260. * Get the Bounding box extent specified by setDefaultQueryExtent
  66261. * @returns the box extent values
  66262. */
  66263. getDefaultQueryExtent(): Vector3;
  66264. /**
  66265. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66266. * @param result output the box extent values
  66267. */
  66268. getDefaultQueryExtentToRef(result: Vector3): void;
  66269. /**
  66270. * Release all resources
  66271. */
  66272. dispose(): void;
  66273. }
  66274. }
  66275. declare module BABYLON {
  66276. /**
  66277. * Class used to enable access to IndexedDB
  66278. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66279. */
  66280. export class Database implements IOfflineProvider {
  66281. private _callbackManifestChecked;
  66282. private _currentSceneUrl;
  66283. private _db;
  66284. private _enableSceneOffline;
  66285. private _enableTexturesOffline;
  66286. private _manifestVersionFound;
  66287. private _mustUpdateRessources;
  66288. private _hasReachedQuota;
  66289. private _isSupported;
  66290. private _idbFactory;
  66291. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66292. private static IsUASupportingBlobStorage;
  66293. /**
  66294. * Gets a boolean indicating if Database storate is enabled (off by default)
  66295. */
  66296. static IDBStorageEnabled: boolean;
  66297. /**
  66298. * Gets a boolean indicating if scene must be saved in the database
  66299. */
  66300. get enableSceneOffline(): boolean;
  66301. /**
  66302. * Gets a boolean indicating if textures must be saved in the database
  66303. */
  66304. get enableTexturesOffline(): boolean;
  66305. /**
  66306. * Creates a new Database
  66307. * @param urlToScene defines the url to load the scene
  66308. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66309. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66310. */
  66311. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66312. private static _ParseURL;
  66313. private static _ReturnFullUrlLocation;
  66314. private _checkManifestFile;
  66315. /**
  66316. * Open the database and make it available
  66317. * @param successCallback defines the callback to call on success
  66318. * @param errorCallback defines the callback to call on error
  66319. */
  66320. open(successCallback: () => void, errorCallback: () => void): void;
  66321. /**
  66322. * Loads an image from the database
  66323. * @param url defines the url to load from
  66324. * @param image defines the target DOM image
  66325. */
  66326. loadImage(url: string, image: HTMLImageElement): void;
  66327. private _loadImageFromDBAsync;
  66328. private _saveImageIntoDBAsync;
  66329. private _checkVersionFromDB;
  66330. private _loadVersionFromDBAsync;
  66331. private _saveVersionIntoDBAsync;
  66332. /**
  66333. * Loads a file from database
  66334. * @param url defines the URL to load from
  66335. * @param sceneLoaded defines a callback to call on success
  66336. * @param progressCallBack defines a callback to call when progress changed
  66337. * @param errorCallback defines a callback to call on error
  66338. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66339. */
  66340. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66341. private _loadFileAsync;
  66342. private _saveFileAsync;
  66343. /**
  66344. * Validates if xhr data is correct
  66345. * @param xhr defines the request to validate
  66346. * @param dataType defines the expected data type
  66347. * @returns true if data is correct
  66348. */
  66349. private static _ValidateXHRData;
  66350. }
  66351. }
  66352. declare module BABYLON {
  66353. /** @hidden */
  66354. export var gpuUpdateParticlesPixelShader: {
  66355. name: string;
  66356. shader: string;
  66357. };
  66358. }
  66359. declare module BABYLON {
  66360. /** @hidden */
  66361. export var gpuUpdateParticlesVertexShader: {
  66362. name: string;
  66363. shader: string;
  66364. };
  66365. }
  66366. declare module BABYLON {
  66367. /** @hidden */
  66368. export var clipPlaneFragmentDeclaration2: {
  66369. name: string;
  66370. shader: string;
  66371. };
  66372. }
  66373. declare module BABYLON {
  66374. /** @hidden */
  66375. export var gpuRenderParticlesPixelShader: {
  66376. name: string;
  66377. shader: string;
  66378. };
  66379. }
  66380. declare module BABYLON {
  66381. /** @hidden */
  66382. export var clipPlaneVertexDeclaration2: {
  66383. name: string;
  66384. shader: string;
  66385. };
  66386. }
  66387. declare module BABYLON {
  66388. /** @hidden */
  66389. export var gpuRenderParticlesVertexShader: {
  66390. name: string;
  66391. shader: string;
  66392. };
  66393. }
  66394. declare module BABYLON {
  66395. /**
  66396. * This represents a GPU particle system in Babylon
  66397. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66398. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66399. */
  66400. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66401. /**
  66402. * The layer mask we are rendering the particles through.
  66403. */
  66404. layerMask: number;
  66405. private _capacity;
  66406. private _activeCount;
  66407. private _currentActiveCount;
  66408. private _accumulatedCount;
  66409. private _renderEffect;
  66410. private _updateEffect;
  66411. private _buffer0;
  66412. private _buffer1;
  66413. private _spriteBuffer;
  66414. private _updateVAO;
  66415. private _renderVAO;
  66416. private _targetIndex;
  66417. private _sourceBuffer;
  66418. private _targetBuffer;
  66419. private _engine;
  66420. private _currentRenderId;
  66421. private _started;
  66422. private _stopped;
  66423. private _timeDelta;
  66424. private _randomTexture;
  66425. private _randomTexture2;
  66426. private _attributesStrideSize;
  66427. private _updateEffectOptions;
  66428. private _randomTextureSize;
  66429. private _actualFrame;
  66430. private _customEffect;
  66431. private readonly _rawTextureWidth;
  66432. /**
  66433. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66434. */
  66435. static get IsSupported(): boolean;
  66436. /**
  66437. * An event triggered when the system is disposed.
  66438. */
  66439. onDisposeObservable: Observable<IParticleSystem>;
  66440. /**
  66441. * Gets the maximum number of particles active at the same time.
  66442. * @returns The max number of active particles.
  66443. */
  66444. getCapacity(): number;
  66445. /**
  66446. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66447. * to override the particles.
  66448. */
  66449. forceDepthWrite: boolean;
  66450. /**
  66451. * Gets or set the number of active particles
  66452. */
  66453. get activeParticleCount(): number;
  66454. set activeParticleCount(value: number);
  66455. private _preWarmDone;
  66456. /**
  66457. * Specifies if the particles are updated in emitter local space or world space.
  66458. */
  66459. isLocal: boolean;
  66460. /**
  66461. * Is this system ready to be used/rendered
  66462. * @return true if the system is ready
  66463. */
  66464. isReady(): boolean;
  66465. /**
  66466. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66467. * @returns True if it has been started, otherwise false.
  66468. */
  66469. isStarted(): boolean;
  66470. /**
  66471. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66472. * @returns True if it has been stopped, otherwise false.
  66473. */
  66474. isStopped(): boolean;
  66475. /**
  66476. * Gets a boolean indicating that the system is stopping
  66477. * @returns true if the system is currently stopping
  66478. */
  66479. isStopping(): boolean;
  66480. /**
  66481. * Gets the number of particles active at the same time.
  66482. * @returns The number of active particles.
  66483. */
  66484. getActiveCount(): number;
  66485. /**
  66486. * Starts the particle system and begins to emit
  66487. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66488. */
  66489. start(delay?: number): void;
  66490. /**
  66491. * Stops the particle system.
  66492. */
  66493. stop(): void;
  66494. /**
  66495. * Remove all active particles
  66496. */
  66497. reset(): void;
  66498. /**
  66499. * Returns the string "GPUParticleSystem"
  66500. * @returns a string containing the class name
  66501. */
  66502. getClassName(): string;
  66503. /**
  66504. * Gets the custom effect used to render the particles
  66505. * @param blendMode Blend mode for which the effect should be retrieved
  66506. * @returns The effect
  66507. */
  66508. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66509. /**
  66510. * Sets the custom effect used to render the particles
  66511. * @param effect The effect to set
  66512. * @param blendMode Blend mode for which the effect should be set
  66513. */
  66514. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66515. /** @hidden */
  66516. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66517. /**
  66518. * Observable that will be called just before the particles are drawn
  66519. */
  66520. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66521. /**
  66522. * Gets the name of the particle vertex shader
  66523. */
  66524. get vertexShaderName(): string;
  66525. private _colorGradientsTexture;
  66526. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66527. /**
  66528. * Adds a new color gradient
  66529. * @param gradient defines the gradient to use (between 0 and 1)
  66530. * @param color1 defines the color to affect to the specified gradient
  66531. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66532. * @returns the current particle system
  66533. */
  66534. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66535. private _refreshColorGradient;
  66536. /** Force the system to rebuild all gradients that need to be resync */
  66537. forceRefreshGradients(): void;
  66538. /**
  66539. * Remove a specific color gradient
  66540. * @param gradient defines the gradient to remove
  66541. * @returns the current particle system
  66542. */
  66543. removeColorGradient(gradient: number): GPUParticleSystem;
  66544. private _angularSpeedGradientsTexture;
  66545. private _sizeGradientsTexture;
  66546. private _velocityGradientsTexture;
  66547. private _limitVelocityGradientsTexture;
  66548. private _dragGradientsTexture;
  66549. private _addFactorGradient;
  66550. /**
  66551. * Adds a new size gradient
  66552. * @param gradient defines the gradient to use (between 0 and 1)
  66553. * @param factor defines the size factor to affect to the specified gradient
  66554. * @returns the current particle system
  66555. */
  66556. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66557. /**
  66558. * Remove a specific size gradient
  66559. * @param gradient defines the gradient to remove
  66560. * @returns the current particle system
  66561. */
  66562. removeSizeGradient(gradient: number): GPUParticleSystem;
  66563. private _refreshFactorGradient;
  66564. /**
  66565. * Adds a new angular speed gradient
  66566. * @param gradient defines the gradient to use (between 0 and 1)
  66567. * @param factor defines the angular speed to affect to the specified gradient
  66568. * @returns the current particle system
  66569. */
  66570. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66571. /**
  66572. * Remove a specific angular speed gradient
  66573. * @param gradient defines the gradient to remove
  66574. * @returns the current particle system
  66575. */
  66576. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66577. /**
  66578. * Adds a new velocity gradient
  66579. * @param gradient defines the gradient to use (between 0 and 1)
  66580. * @param factor defines the velocity to affect to the specified gradient
  66581. * @returns the current particle system
  66582. */
  66583. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66584. /**
  66585. * Remove a specific velocity gradient
  66586. * @param gradient defines the gradient to remove
  66587. * @returns the current particle system
  66588. */
  66589. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66590. /**
  66591. * Adds a new limit velocity gradient
  66592. * @param gradient defines the gradient to use (between 0 and 1)
  66593. * @param factor defines the limit velocity value to affect to the specified gradient
  66594. * @returns the current particle system
  66595. */
  66596. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66597. /**
  66598. * Remove a specific limit velocity gradient
  66599. * @param gradient defines the gradient to remove
  66600. * @returns the current particle system
  66601. */
  66602. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66603. /**
  66604. * Adds a new drag gradient
  66605. * @param gradient defines the gradient to use (between 0 and 1)
  66606. * @param factor defines the drag value to affect to the specified gradient
  66607. * @returns the current particle system
  66608. */
  66609. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66610. /**
  66611. * Remove a specific drag gradient
  66612. * @param gradient defines the gradient to remove
  66613. * @returns the current particle system
  66614. */
  66615. removeDragGradient(gradient: number): GPUParticleSystem;
  66616. /**
  66617. * Not supported by GPUParticleSystem
  66618. * @param gradient defines the gradient to use (between 0 and 1)
  66619. * @param factor defines the emit rate value to affect to the specified gradient
  66620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66621. * @returns the current particle system
  66622. */
  66623. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66624. /**
  66625. * Not supported by GPUParticleSystem
  66626. * @param gradient defines the gradient to remove
  66627. * @returns the current particle system
  66628. */
  66629. removeEmitRateGradient(gradient: number): IParticleSystem;
  66630. /**
  66631. * Not supported by GPUParticleSystem
  66632. * @param gradient defines the gradient to use (between 0 and 1)
  66633. * @param factor defines the start size value to affect to the specified gradient
  66634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66635. * @returns the current particle system
  66636. */
  66637. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66638. /**
  66639. * Not supported by GPUParticleSystem
  66640. * @param gradient defines the gradient to remove
  66641. * @returns the current particle system
  66642. */
  66643. removeStartSizeGradient(gradient: number): IParticleSystem;
  66644. /**
  66645. * Not supported by GPUParticleSystem
  66646. * @param gradient defines the gradient to use (between 0 and 1)
  66647. * @param min defines the color remap minimal range
  66648. * @param max defines the color remap maximal range
  66649. * @returns the current particle system
  66650. */
  66651. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66652. /**
  66653. * Not supported by GPUParticleSystem
  66654. * @param gradient defines the gradient to remove
  66655. * @returns the current particle system
  66656. */
  66657. removeColorRemapGradient(): IParticleSystem;
  66658. /**
  66659. * Not supported by GPUParticleSystem
  66660. * @param gradient defines the gradient to use (between 0 and 1)
  66661. * @param min defines the alpha remap minimal range
  66662. * @param max defines the alpha remap maximal range
  66663. * @returns the current particle system
  66664. */
  66665. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66666. /**
  66667. * Not supported by GPUParticleSystem
  66668. * @param gradient defines the gradient to remove
  66669. * @returns the current particle system
  66670. */
  66671. removeAlphaRemapGradient(): IParticleSystem;
  66672. /**
  66673. * Not supported by GPUParticleSystem
  66674. * @param gradient defines the gradient to use (between 0 and 1)
  66675. * @param color defines the color to affect to the specified gradient
  66676. * @returns the current particle system
  66677. */
  66678. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66679. /**
  66680. * Not supported by GPUParticleSystem
  66681. * @param gradient defines the gradient to remove
  66682. * @returns the current particle system
  66683. */
  66684. removeRampGradient(): IParticleSystem;
  66685. /**
  66686. * Not supported by GPUParticleSystem
  66687. * @returns the list of ramp gradients
  66688. */
  66689. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66690. /**
  66691. * Not supported by GPUParticleSystem
  66692. * Gets or sets a boolean indicating that ramp gradients must be used
  66693. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66694. */
  66695. get useRampGradients(): boolean;
  66696. set useRampGradients(value: boolean);
  66697. /**
  66698. * Not supported by GPUParticleSystem
  66699. * @param gradient defines the gradient to use (between 0 and 1)
  66700. * @param factor defines the life time factor to affect to the specified gradient
  66701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66702. * @returns the current particle system
  66703. */
  66704. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66705. /**
  66706. * Not supported by GPUParticleSystem
  66707. * @param gradient defines the gradient to remove
  66708. * @returns the current particle system
  66709. */
  66710. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66711. /**
  66712. * Instantiates a GPU particle system.
  66713. * 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.
  66714. * @param name The name of the particle system
  66715. * @param options The options used to create the system
  66716. * @param scene The scene the particle system belongs to
  66717. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66718. * @param customEffect a custom effect used to change the way particles are rendered by default
  66719. */
  66720. constructor(name: string, options: Partial<{
  66721. capacity: number;
  66722. randomTextureSize: number;
  66723. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66724. protected _reset(): void;
  66725. private _createUpdateVAO;
  66726. private _createRenderVAO;
  66727. private _initialize;
  66728. /** @hidden */
  66729. _recreateUpdateEffect(): void;
  66730. private _getEffect;
  66731. /**
  66732. * Fill the defines array according to the current settings of the particle system
  66733. * @param defines Array to be updated
  66734. * @param blendMode blend mode to take into account when updating the array
  66735. */
  66736. fillDefines(defines: Array<string>, blendMode?: number): void;
  66737. /**
  66738. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66739. * @param uniforms Uniforms array to fill
  66740. * @param attributes Attributes array to fill
  66741. * @param samplers Samplers array to fill
  66742. */
  66743. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66744. /** @hidden */
  66745. _recreateRenderEffect(): Effect;
  66746. /**
  66747. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66748. * @param preWarm defines if we are in the pre-warmimg phase
  66749. */
  66750. animate(preWarm?: boolean): void;
  66751. private _createFactorGradientTexture;
  66752. private _createSizeGradientTexture;
  66753. private _createAngularSpeedGradientTexture;
  66754. private _createVelocityGradientTexture;
  66755. private _createLimitVelocityGradientTexture;
  66756. private _createDragGradientTexture;
  66757. private _createColorGradientTexture;
  66758. /**
  66759. * Renders the particle system in its current state
  66760. * @param preWarm defines if the system should only update the particles but not render them
  66761. * @returns the current number of particles
  66762. */
  66763. render(preWarm?: boolean): number;
  66764. /**
  66765. * Rebuilds the particle system
  66766. */
  66767. rebuild(): void;
  66768. private _releaseBuffers;
  66769. private _releaseVAOs;
  66770. /**
  66771. * Disposes the particle system and free the associated resources
  66772. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66773. */
  66774. dispose(disposeTexture?: boolean): void;
  66775. /**
  66776. * Clones the particle system.
  66777. * @param name The name of the cloned object
  66778. * @param newEmitter The new emitter to use
  66779. * @returns the cloned particle system
  66780. */
  66781. clone(name: string, newEmitter: any): GPUParticleSystem;
  66782. /**
  66783. * Serializes the particle system to a JSON object
  66784. * @param serializeTexture defines if the texture must be serialized as well
  66785. * @returns the JSON object
  66786. */
  66787. serialize(serializeTexture?: boolean): any;
  66788. /**
  66789. * Parses a JSON object to create a GPU particle system.
  66790. * @param parsedParticleSystem The JSON object to parse
  66791. * @param scene The scene to create the particle system in
  66792. * @param rootUrl The root url to use to load external dependencies like texture
  66793. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66794. * @returns the parsed GPU particle system
  66795. */
  66796. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66797. }
  66798. }
  66799. declare module BABYLON {
  66800. /**
  66801. * Represents a set of particle systems working together to create a specific effect
  66802. */
  66803. export class ParticleSystemSet implements IDisposable {
  66804. /**
  66805. * Gets or sets base Assets URL
  66806. */
  66807. static BaseAssetsUrl: string;
  66808. private _emitterCreationOptions;
  66809. private _emitterNode;
  66810. /**
  66811. * Gets the particle system list
  66812. */
  66813. systems: IParticleSystem[];
  66814. /**
  66815. * Gets the emitter node used with this set
  66816. */
  66817. get emitterNode(): Nullable<TransformNode>;
  66818. /**
  66819. * Creates a new emitter mesh as a sphere
  66820. * @param options defines the options used to create the sphere
  66821. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66822. * @param scene defines the hosting scene
  66823. */
  66824. setEmitterAsSphere(options: {
  66825. diameter: number;
  66826. segments: number;
  66827. color: Color3;
  66828. }, renderingGroupId: number, scene: Scene): void;
  66829. /**
  66830. * Starts all particle systems of the set
  66831. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66832. */
  66833. start(emitter?: AbstractMesh): void;
  66834. /**
  66835. * Release all associated resources
  66836. */
  66837. dispose(): void;
  66838. /**
  66839. * Serialize the set into a JSON compatible object
  66840. * @param serializeTexture defines if the texture must be serialized as well
  66841. * @returns a JSON compatible representation of the set
  66842. */
  66843. serialize(serializeTexture?: boolean): any;
  66844. /**
  66845. * Parse a new ParticleSystemSet from a serialized source
  66846. * @param data defines a JSON compatible representation of the set
  66847. * @param scene defines the hosting scene
  66848. * @param gpu defines if we want GPU particles or CPU particles
  66849. * @returns a new ParticleSystemSet
  66850. */
  66851. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66852. }
  66853. }
  66854. declare module BABYLON {
  66855. /**
  66856. * This class is made for on one-liner static method to help creating particle system set.
  66857. */
  66858. export class ParticleHelper {
  66859. /**
  66860. * Gets or sets base Assets URL
  66861. */
  66862. static BaseAssetsUrl: string;
  66863. /** Define the Url to load snippets */
  66864. static SnippetUrl: string;
  66865. /**
  66866. * Create a default particle system that you can tweak
  66867. * @param emitter defines the emitter to use
  66868. * @param capacity defines the system capacity (default is 500 particles)
  66869. * @param scene defines the hosting scene
  66870. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66871. * @returns the new Particle system
  66872. */
  66873. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66874. /**
  66875. * This is the main static method (one-liner) of this helper to create different particle systems
  66876. * @param type This string represents the type to the particle system to create
  66877. * @param scene The scene where the particle system should live
  66878. * @param gpu If the system will use gpu
  66879. * @returns the ParticleSystemSet created
  66880. */
  66881. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66882. /**
  66883. * Static function used to export a particle system to a ParticleSystemSet variable.
  66884. * Please note that the emitter shape is not exported
  66885. * @param systems defines the particle systems to export
  66886. * @returns the created particle system set
  66887. */
  66888. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66889. /**
  66890. * Creates a particle system from a snippet saved in a remote file
  66891. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66892. * @param url defines the url to load from
  66893. * @param scene defines the hosting scene
  66894. * @param gpu If the system will use gpu
  66895. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66896. * @returns a promise that will resolve to the new particle system
  66897. */
  66898. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66899. /**
  66900. * Creates a particle system from a snippet saved by the particle system editor
  66901. * @param snippetId defines the snippet to load
  66902. * @param scene defines the hosting scene
  66903. * @param gpu If the system will use gpu
  66904. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66905. * @returns a promise that will resolve to the new particle system
  66906. */
  66907. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66908. }
  66909. }
  66910. declare module BABYLON {
  66911. interface Engine {
  66912. /**
  66913. * Create an effect to use with particle systems.
  66914. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66915. * the particle system for which you want to create a custom effect in the last parameter
  66916. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66917. * @param uniformsNames defines a list of attribute names
  66918. * @param samplers defines an array of string used to represent textures
  66919. * @param defines defines the string containing the defines to use to compile the shaders
  66920. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66921. * @param onCompiled defines a function to call when the effect creation is successful
  66922. * @param onError defines a function to call when the effect creation has failed
  66923. * @param particleSystem the particle system you want to create the effect for
  66924. * @returns the new Effect
  66925. */
  66926. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66927. }
  66928. interface Mesh {
  66929. /**
  66930. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66931. * @returns an array of IParticleSystem
  66932. */
  66933. getEmittedParticleSystems(): IParticleSystem[];
  66934. /**
  66935. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66936. * @returns an array of IParticleSystem
  66937. */
  66938. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66939. }
  66940. }
  66941. declare module BABYLON {
  66942. /** Defines the 4 color options */
  66943. export enum PointColor {
  66944. /** color value */
  66945. Color = 2,
  66946. /** uv value */
  66947. UV = 1,
  66948. /** random value */
  66949. Random = 0,
  66950. /** stated value */
  66951. Stated = 3
  66952. }
  66953. /**
  66954. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66955. * 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.
  66956. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66957. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66958. *
  66959. * Full documentation here : TO BE ENTERED
  66960. */
  66961. export class PointsCloudSystem implements IDisposable {
  66962. /**
  66963. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66964. * Example : var p = SPS.particles[i];
  66965. */
  66966. particles: CloudPoint[];
  66967. /**
  66968. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66969. */
  66970. nbParticles: number;
  66971. /**
  66972. * This a counter for your own usage. It's not set by any SPS functions.
  66973. */
  66974. counter: number;
  66975. /**
  66976. * The PCS name. This name is also given to the underlying mesh.
  66977. */
  66978. name: string;
  66979. /**
  66980. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66981. */
  66982. mesh: Mesh;
  66983. /**
  66984. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66985. * Please read :
  66986. */
  66987. vars: any;
  66988. /**
  66989. * @hidden
  66990. */
  66991. _size: number;
  66992. private _scene;
  66993. private _promises;
  66994. private _positions;
  66995. private _indices;
  66996. private _normals;
  66997. private _colors;
  66998. private _uvs;
  66999. private _indices32;
  67000. private _positions32;
  67001. private _colors32;
  67002. private _uvs32;
  67003. private _updatable;
  67004. private _isVisibilityBoxLocked;
  67005. private _alwaysVisible;
  67006. private _groups;
  67007. private _groupCounter;
  67008. private _computeParticleColor;
  67009. private _computeParticleTexture;
  67010. private _computeParticleRotation;
  67011. private _computeBoundingBox;
  67012. private _isReady;
  67013. /**
  67014. * Creates a PCS (Points Cloud System) object
  67015. * @param name (String) is the PCS name, this will be the underlying mesh name
  67016. * @param pointSize (number) is the size for each point
  67017. * @param scene (Scene) is the scene in which the PCS is added
  67018. * @param options defines the options of the PCS e.g.
  67019. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67020. */
  67021. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67022. updatable?: boolean;
  67023. });
  67024. /**
  67025. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67026. * If no points were added to the PCS, the returned mesh is just a single point.
  67027. * @returns a promise for the created mesh
  67028. */
  67029. buildMeshAsync(): Promise<Mesh>;
  67030. /**
  67031. * @hidden
  67032. */
  67033. private _buildMesh;
  67034. private _addParticle;
  67035. private _randomUnitVector;
  67036. private _getColorIndicesForCoord;
  67037. private _setPointsColorOrUV;
  67038. private _colorFromTexture;
  67039. private _calculateDensity;
  67040. /**
  67041. * Adds points to the PCS in random positions within a unit sphere
  67042. * @param nb (positive integer) the number of particles to be created from this model
  67043. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67044. * @returns the number of groups in the system
  67045. */
  67046. addPoints(nb: number, pointFunction?: any): number;
  67047. /**
  67048. * Adds points to the PCS from the surface of the model shape
  67049. * @param mesh is any Mesh object that will be used as a surface model for the points
  67050. * @param nb (positive integer) the number of particles to be created from this model
  67051. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67052. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67053. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67054. * @returns the number of groups in the system
  67055. */
  67056. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67057. /**
  67058. * Adds points to the PCS inside the model shape
  67059. * @param mesh is any Mesh object that will be used as a surface model for the points
  67060. * @param nb (positive integer) the number of particles to be created from this model
  67061. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67062. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67063. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67064. * @returns the number of groups in the system
  67065. */
  67066. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67067. /**
  67068. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67069. * This method calls `updateParticle()` for each particle of the SPS.
  67070. * For an animated SPS, it is usually called within the render loop.
  67071. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67072. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67073. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67074. * @returns the PCS.
  67075. */
  67076. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67077. /**
  67078. * Disposes the PCS.
  67079. */
  67080. dispose(): void;
  67081. /**
  67082. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67083. * doc :
  67084. * @returns the PCS.
  67085. */
  67086. refreshVisibleSize(): PointsCloudSystem;
  67087. /**
  67088. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67089. * @param size the size (float) of the visibility box
  67090. * note : this doesn't lock the PCS mesh bounding box.
  67091. * doc :
  67092. */
  67093. setVisibilityBox(size: number): void;
  67094. /**
  67095. * Gets whether the PCS is always visible or not
  67096. * doc :
  67097. */
  67098. get isAlwaysVisible(): boolean;
  67099. /**
  67100. * Sets the PCS as always visible or not
  67101. * doc :
  67102. */
  67103. set isAlwaysVisible(val: boolean);
  67104. /**
  67105. * Tells to `setParticles()` to compute the particle rotations or not
  67106. * Default value : false. The PCS is faster when it's set to false
  67107. * Note : particle rotations are only applied to parent particles
  67108. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67109. */
  67110. set computeParticleRotation(val: boolean);
  67111. /**
  67112. * Tells to `setParticles()` to compute the particle colors or not.
  67113. * Default value : true. The PCS is faster when it's set to false.
  67114. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67115. */
  67116. set computeParticleColor(val: boolean);
  67117. set computeParticleTexture(val: boolean);
  67118. /**
  67119. * Gets if `setParticles()` computes the particle colors or not.
  67120. * Default value : false. The PCS is faster when it's set to false.
  67121. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67122. */
  67123. get computeParticleColor(): boolean;
  67124. /**
  67125. * Gets if `setParticles()` computes the particle textures or not.
  67126. * Default value : false. The PCS is faster when it's set to false.
  67127. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67128. */
  67129. get computeParticleTexture(): boolean;
  67130. /**
  67131. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67132. */
  67133. set computeBoundingBox(val: boolean);
  67134. /**
  67135. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67136. */
  67137. get computeBoundingBox(): boolean;
  67138. /**
  67139. * This function does nothing. It may be overwritten to set all the particle first values.
  67140. * The PCS doesn't call this function, you may have to call it by your own.
  67141. * doc :
  67142. */
  67143. initParticles(): void;
  67144. /**
  67145. * This function does nothing. It may be overwritten to recycle a particle
  67146. * The PCS doesn't call this function, you can to call it
  67147. * doc :
  67148. * @param particle The particle to recycle
  67149. * @returns the recycled particle
  67150. */
  67151. recycleParticle(particle: CloudPoint): CloudPoint;
  67152. /**
  67153. * Updates a particle : this function should be overwritten by the user.
  67154. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67155. * doc :
  67156. * @example : just set a particle position or velocity and recycle conditions
  67157. * @param particle The particle to update
  67158. * @returns the updated particle
  67159. */
  67160. updateParticle(particle: CloudPoint): CloudPoint;
  67161. /**
  67162. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67163. * This does nothing and may be overwritten by the user.
  67164. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67165. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67166. * @param update the boolean update value actually passed to setParticles()
  67167. */
  67168. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67169. /**
  67170. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67171. * This will be passed three parameters.
  67172. * This does nothing and may be overwritten by the user.
  67173. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67174. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67175. * @param update the boolean update value actually passed to setParticles()
  67176. */
  67177. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67178. }
  67179. }
  67180. declare module BABYLON {
  67181. /**
  67182. * Represents one particle of a points cloud system.
  67183. */
  67184. export class CloudPoint {
  67185. /**
  67186. * particle global index
  67187. */
  67188. idx: number;
  67189. /**
  67190. * The color of the particle
  67191. */
  67192. color: Nullable<Color4>;
  67193. /**
  67194. * The world space position of the particle.
  67195. */
  67196. position: Vector3;
  67197. /**
  67198. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67199. */
  67200. rotation: Vector3;
  67201. /**
  67202. * The world space rotation quaternion of the particle.
  67203. */
  67204. rotationQuaternion: Nullable<Quaternion>;
  67205. /**
  67206. * The uv of the particle.
  67207. */
  67208. uv: Nullable<Vector2>;
  67209. /**
  67210. * The current speed of the particle.
  67211. */
  67212. velocity: Vector3;
  67213. /**
  67214. * The pivot point in the particle local space.
  67215. */
  67216. pivot: Vector3;
  67217. /**
  67218. * Must the particle be translated from its pivot point in its local space ?
  67219. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67220. * Default : false
  67221. */
  67222. translateFromPivot: boolean;
  67223. /**
  67224. * Index of this particle in the global "positions" array (Internal use)
  67225. * @hidden
  67226. */
  67227. _pos: number;
  67228. /**
  67229. * @hidden Index of this particle in the global "indices" array (Internal use)
  67230. */
  67231. _ind: number;
  67232. /**
  67233. * Group this particle belongs to
  67234. */
  67235. _group: PointsGroup;
  67236. /**
  67237. * Group id of this particle
  67238. */
  67239. groupId: number;
  67240. /**
  67241. * Index of the particle in its group id (Internal use)
  67242. */
  67243. idxInGroup: number;
  67244. /**
  67245. * @hidden Particle BoundingInfo object (Internal use)
  67246. */
  67247. _boundingInfo: BoundingInfo;
  67248. /**
  67249. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67250. */
  67251. _pcs: PointsCloudSystem;
  67252. /**
  67253. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67254. */
  67255. _stillInvisible: boolean;
  67256. /**
  67257. * @hidden Last computed particle rotation matrix
  67258. */
  67259. _rotationMatrix: number[];
  67260. /**
  67261. * Parent particle Id, if any.
  67262. * Default null.
  67263. */
  67264. parentId: Nullable<number>;
  67265. /**
  67266. * @hidden Internal global position in the PCS.
  67267. */
  67268. _globalPosition: Vector3;
  67269. /**
  67270. * Creates a Point Cloud object.
  67271. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67272. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67273. * @param group (PointsGroup) is the group the particle belongs to
  67274. * @param groupId (integer) is the group identifier in the PCS.
  67275. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67276. * @param pcs defines the PCS it is associated to
  67277. */
  67278. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67279. /**
  67280. * get point size
  67281. */
  67282. get size(): Vector3;
  67283. /**
  67284. * Set point size
  67285. */
  67286. set size(scale: Vector3);
  67287. /**
  67288. * Legacy support, changed quaternion to rotationQuaternion
  67289. */
  67290. get quaternion(): Nullable<Quaternion>;
  67291. /**
  67292. * Legacy support, changed quaternion to rotationQuaternion
  67293. */
  67294. set quaternion(q: Nullable<Quaternion>);
  67295. /**
  67296. * Returns a boolean. True if the particle intersects a mesh, else false
  67297. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67298. * @param target is the object (point or mesh) what the intersection is computed against
  67299. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67300. * @returns true if it intersects
  67301. */
  67302. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67303. /**
  67304. * get the rotation matrix of the particle
  67305. * @hidden
  67306. */
  67307. getRotationMatrix(m: Matrix): void;
  67308. }
  67309. /**
  67310. * Represents a group of points in a points cloud system
  67311. * * PCS internal tool, don't use it manually.
  67312. */
  67313. export class PointsGroup {
  67314. /**
  67315. * The group id
  67316. * @hidden
  67317. */
  67318. groupID: number;
  67319. /**
  67320. * image data for group (internal use)
  67321. * @hidden
  67322. */
  67323. _groupImageData: Nullable<ArrayBufferView>;
  67324. /**
  67325. * Image Width (internal use)
  67326. * @hidden
  67327. */
  67328. _groupImgWidth: number;
  67329. /**
  67330. * Image Height (internal use)
  67331. * @hidden
  67332. */
  67333. _groupImgHeight: number;
  67334. /**
  67335. * Custom position function (internal use)
  67336. * @hidden
  67337. */
  67338. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67339. /**
  67340. * density per facet for surface points
  67341. * @hidden
  67342. */
  67343. _groupDensity: number[];
  67344. /**
  67345. * Only when points are colored by texture carries pointer to texture list array
  67346. * @hidden
  67347. */
  67348. _textureNb: number;
  67349. /**
  67350. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67351. * PCS internal tool, don't use it manually.
  67352. * @hidden
  67353. */
  67354. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67355. }
  67356. }
  67357. declare module BABYLON {
  67358. interface Scene {
  67359. /** @hidden (Backing field) */
  67360. _physicsEngine: Nullable<IPhysicsEngine>;
  67361. /** @hidden */
  67362. _physicsTimeAccumulator: number;
  67363. /**
  67364. * Gets the current physics engine
  67365. * @returns a IPhysicsEngine or null if none attached
  67366. */
  67367. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67368. /**
  67369. * Enables physics to the current scene
  67370. * @param gravity defines the scene's gravity for the physics engine
  67371. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67372. * @return a boolean indicating if the physics engine was initialized
  67373. */
  67374. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67375. /**
  67376. * Disables and disposes the physics engine associated with the scene
  67377. */
  67378. disablePhysicsEngine(): void;
  67379. /**
  67380. * Gets a boolean indicating if there is an active physics engine
  67381. * @returns a boolean indicating if there is an active physics engine
  67382. */
  67383. isPhysicsEnabled(): boolean;
  67384. /**
  67385. * Deletes a physics compound impostor
  67386. * @param compound defines the compound to delete
  67387. */
  67388. deleteCompoundImpostor(compound: any): void;
  67389. /**
  67390. * An event triggered when physic simulation is about to be run
  67391. */
  67392. onBeforePhysicsObservable: Observable<Scene>;
  67393. /**
  67394. * An event triggered when physic simulation has been done
  67395. */
  67396. onAfterPhysicsObservable: Observable<Scene>;
  67397. }
  67398. interface AbstractMesh {
  67399. /** @hidden */
  67400. _physicsImpostor: Nullable<PhysicsImpostor>;
  67401. /**
  67402. * Gets or sets impostor used for physic simulation
  67403. * @see https://doc.babylonjs.com/features/physics_engine
  67404. */
  67405. physicsImpostor: Nullable<PhysicsImpostor>;
  67406. /**
  67407. * Gets the current physics impostor
  67408. * @see https://doc.babylonjs.com/features/physics_engine
  67409. * @returns a physics impostor or null
  67410. */
  67411. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67412. /** Apply a physic impulse to the mesh
  67413. * @param force defines the force to apply
  67414. * @param contactPoint defines where to apply the force
  67415. * @returns the current mesh
  67416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67417. */
  67418. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67419. /**
  67420. * Creates a physic joint between two meshes
  67421. * @param otherMesh defines the other mesh to use
  67422. * @param pivot1 defines the pivot to use on this mesh
  67423. * @param pivot2 defines the pivot to use on the other mesh
  67424. * @param options defines additional options (can be plugin dependent)
  67425. * @returns the current mesh
  67426. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67427. */
  67428. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67429. /** @hidden */
  67430. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67431. }
  67432. /**
  67433. * Defines the physics engine scene component responsible to manage a physics engine
  67434. */
  67435. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67436. /**
  67437. * The component name helpful to identify the component in the list of scene components.
  67438. */
  67439. readonly name: string;
  67440. /**
  67441. * The scene the component belongs to.
  67442. */
  67443. scene: Scene;
  67444. /**
  67445. * Creates a new instance of the component for the given scene
  67446. * @param scene Defines the scene to register the component in
  67447. */
  67448. constructor(scene: Scene);
  67449. /**
  67450. * Registers the component in a given scene
  67451. */
  67452. register(): void;
  67453. /**
  67454. * Rebuilds the elements related to this component in case of
  67455. * context lost for instance.
  67456. */
  67457. rebuild(): void;
  67458. /**
  67459. * Disposes the component and the associated ressources
  67460. */
  67461. dispose(): void;
  67462. }
  67463. }
  67464. declare module BABYLON {
  67465. /**
  67466. * A helper for physics simulations
  67467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67468. */
  67469. export class PhysicsHelper {
  67470. private _scene;
  67471. private _physicsEngine;
  67472. /**
  67473. * Initializes the Physics helper
  67474. * @param scene Babylon.js scene
  67475. */
  67476. constructor(scene: Scene);
  67477. /**
  67478. * Applies a radial explosion impulse
  67479. * @param origin the origin of the explosion
  67480. * @param radiusOrEventOptions the radius or the options of radial explosion
  67481. * @param strength the explosion strength
  67482. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67483. * @returns A physics radial explosion event, or null
  67484. */
  67485. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67486. /**
  67487. * Applies a radial explosion force
  67488. * @param origin the origin of the explosion
  67489. * @param radiusOrEventOptions the radius or the options of radial explosion
  67490. * @param strength the explosion strength
  67491. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67492. * @returns A physics radial explosion event, or null
  67493. */
  67494. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67495. /**
  67496. * Creates a gravitational field
  67497. * @param origin the origin of the explosion
  67498. * @param radiusOrEventOptions the radius or the options of radial explosion
  67499. * @param strength the explosion strength
  67500. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67501. * @returns A physics gravitational field event, or null
  67502. */
  67503. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67504. /**
  67505. * Creates a physics updraft event
  67506. * @param origin the origin of the updraft
  67507. * @param radiusOrEventOptions the radius or the options of the updraft
  67508. * @param strength the strength of the updraft
  67509. * @param height the height of the updraft
  67510. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67511. * @returns A physics updraft event, or null
  67512. */
  67513. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67514. /**
  67515. * Creates a physics vortex event
  67516. * @param origin the of the vortex
  67517. * @param radiusOrEventOptions the radius or the options of the vortex
  67518. * @param strength the strength of the vortex
  67519. * @param height the height of the vortex
  67520. * @returns a Physics vortex event, or null
  67521. * A physics vortex event or null
  67522. */
  67523. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67524. }
  67525. /**
  67526. * Represents a physics radial explosion event
  67527. */
  67528. class PhysicsRadialExplosionEvent {
  67529. private _scene;
  67530. private _options;
  67531. private _sphere;
  67532. private _dataFetched;
  67533. /**
  67534. * Initializes a radial explosioin event
  67535. * @param _scene BabylonJS scene
  67536. * @param _options The options for the vortex event
  67537. */
  67538. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67539. /**
  67540. * Returns the data related to the radial explosion event (sphere).
  67541. * @returns The radial explosion event data
  67542. */
  67543. getData(): PhysicsRadialExplosionEventData;
  67544. /**
  67545. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67546. * @param impostor A physics imposter
  67547. * @param origin the origin of the explosion
  67548. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67549. */
  67550. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67551. /**
  67552. * Triggers affecterd impostors callbacks
  67553. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67554. */
  67555. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67556. /**
  67557. * Disposes the sphere.
  67558. * @param force Specifies if the sphere should be disposed by force
  67559. */
  67560. dispose(force?: boolean): void;
  67561. /*** Helpers ***/
  67562. private _prepareSphere;
  67563. private _intersectsWithSphere;
  67564. }
  67565. /**
  67566. * Represents a gravitational field event
  67567. */
  67568. class PhysicsGravitationalFieldEvent {
  67569. private _physicsHelper;
  67570. private _scene;
  67571. private _origin;
  67572. private _options;
  67573. private _tickCallback;
  67574. private _sphere;
  67575. private _dataFetched;
  67576. /**
  67577. * Initializes the physics gravitational field event
  67578. * @param _physicsHelper A physics helper
  67579. * @param _scene BabylonJS scene
  67580. * @param _origin The origin position of the gravitational field event
  67581. * @param _options The options for the vortex event
  67582. */
  67583. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67584. /**
  67585. * Returns the data related to the gravitational field event (sphere).
  67586. * @returns A gravitational field event
  67587. */
  67588. getData(): PhysicsGravitationalFieldEventData;
  67589. /**
  67590. * Enables the gravitational field.
  67591. */
  67592. enable(): void;
  67593. /**
  67594. * Disables the gravitational field.
  67595. */
  67596. disable(): void;
  67597. /**
  67598. * Disposes the sphere.
  67599. * @param force The force to dispose from the gravitational field event
  67600. */
  67601. dispose(force?: boolean): void;
  67602. private _tick;
  67603. }
  67604. /**
  67605. * Represents a physics updraft event
  67606. */
  67607. class PhysicsUpdraftEvent {
  67608. private _scene;
  67609. private _origin;
  67610. private _options;
  67611. private _physicsEngine;
  67612. private _originTop;
  67613. private _originDirection;
  67614. private _tickCallback;
  67615. private _cylinder;
  67616. private _cylinderPosition;
  67617. private _dataFetched;
  67618. /**
  67619. * Initializes the physics updraft event
  67620. * @param _scene BabylonJS scene
  67621. * @param _origin The origin position of the updraft
  67622. * @param _options The options for the updraft event
  67623. */
  67624. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67625. /**
  67626. * Returns the data related to the updraft event (cylinder).
  67627. * @returns A physics updraft event
  67628. */
  67629. getData(): PhysicsUpdraftEventData;
  67630. /**
  67631. * Enables the updraft.
  67632. */
  67633. enable(): void;
  67634. /**
  67635. * Disables the updraft.
  67636. */
  67637. disable(): void;
  67638. /**
  67639. * Disposes the cylinder.
  67640. * @param force Specifies if the updraft should be disposed by force
  67641. */
  67642. dispose(force?: boolean): void;
  67643. private getImpostorHitData;
  67644. private _tick;
  67645. /*** Helpers ***/
  67646. private _prepareCylinder;
  67647. private _intersectsWithCylinder;
  67648. }
  67649. /**
  67650. * Represents a physics vortex event
  67651. */
  67652. class PhysicsVortexEvent {
  67653. private _scene;
  67654. private _origin;
  67655. private _options;
  67656. private _physicsEngine;
  67657. private _originTop;
  67658. private _tickCallback;
  67659. private _cylinder;
  67660. private _cylinderPosition;
  67661. private _dataFetched;
  67662. /**
  67663. * Initializes the physics vortex event
  67664. * @param _scene The BabylonJS scene
  67665. * @param _origin The origin position of the vortex
  67666. * @param _options The options for the vortex event
  67667. */
  67668. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67669. /**
  67670. * Returns the data related to the vortex event (cylinder).
  67671. * @returns The physics vortex event data
  67672. */
  67673. getData(): PhysicsVortexEventData;
  67674. /**
  67675. * Enables the vortex.
  67676. */
  67677. enable(): void;
  67678. /**
  67679. * Disables the cortex.
  67680. */
  67681. disable(): void;
  67682. /**
  67683. * Disposes the sphere.
  67684. * @param force
  67685. */
  67686. dispose(force?: boolean): void;
  67687. private getImpostorHitData;
  67688. private _tick;
  67689. /*** Helpers ***/
  67690. private _prepareCylinder;
  67691. private _intersectsWithCylinder;
  67692. }
  67693. /**
  67694. * Options fot the radial explosion event
  67695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67696. */
  67697. export class PhysicsRadialExplosionEventOptions {
  67698. /**
  67699. * The radius of the sphere for the radial explosion.
  67700. */
  67701. radius: number;
  67702. /**
  67703. * The strenth of the explosion.
  67704. */
  67705. strength: number;
  67706. /**
  67707. * The strenght of the force in correspondence to the distance of the affected object
  67708. */
  67709. falloff: PhysicsRadialImpulseFalloff;
  67710. /**
  67711. * Sphere options for the radial explosion.
  67712. */
  67713. sphere: {
  67714. segments: number;
  67715. diameter: number;
  67716. };
  67717. /**
  67718. * Sphere options for the radial explosion.
  67719. */
  67720. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67721. }
  67722. /**
  67723. * Options fot the updraft event
  67724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67725. */
  67726. export class PhysicsUpdraftEventOptions {
  67727. /**
  67728. * The radius of the cylinder for the vortex
  67729. */
  67730. radius: number;
  67731. /**
  67732. * The strenth of the updraft.
  67733. */
  67734. strength: number;
  67735. /**
  67736. * The height of the cylinder for the updraft.
  67737. */
  67738. height: number;
  67739. /**
  67740. * The mode for the the updraft.
  67741. */
  67742. updraftMode: PhysicsUpdraftMode;
  67743. }
  67744. /**
  67745. * Options fot the vortex event
  67746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67747. */
  67748. export class PhysicsVortexEventOptions {
  67749. /**
  67750. * The radius of the cylinder for the vortex
  67751. */
  67752. radius: number;
  67753. /**
  67754. * The strenth of the vortex.
  67755. */
  67756. strength: number;
  67757. /**
  67758. * The height of the cylinder for the vortex.
  67759. */
  67760. height: number;
  67761. /**
  67762. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67763. */
  67764. centripetalForceThreshold: number;
  67765. /**
  67766. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67767. */
  67768. centripetalForceMultiplier: number;
  67769. /**
  67770. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67771. */
  67772. centrifugalForceMultiplier: number;
  67773. /**
  67774. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67775. */
  67776. updraftForceMultiplier: number;
  67777. }
  67778. /**
  67779. * The strenght of the force in correspondence to the distance of the affected object
  67780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67781. */
  67782. export enum PhysicsRadialImpulseFalloff {
  67783. /** Defines that impulse is constant in strength across it's whole radius */
  67784. Constant = 0,
  67785. /** Defines that impulse gets weaker if it's further from the origin */
  67786. Linear = 1
  67787. }
  67788. /**
  67789. * The strength of the force in correspondence to the distance of the affected object
  67790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67791. */
  67792. export enum PhysicsUpdraftMode {
  67793. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67794. Center = 0,
  67795. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67796. Perpendicular = 1
  67797. }
  67798. /**
  67799. * Interface for a physics hit data
  67800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67801. */
  67802. export interface PhysicsHitData {
  67803. /**
  67804. * The force applied at the contact point
  67805. */
  67806. force: Vector3;
  67807. /**
  67808. * The contact point
  67809. */
  67810. contactPoint: Vector3;
  67811. /**
  67812. * The distance from the origin to the contact point
  67813. */
  67814. distanceFromOrigin: number;
  67815. }
  67816. /**
  67817. * Interface for radial explosion event data
  67818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67819. */
  67820. export interface PhysicsRadialExplosionEventData {
  67821. /**
  67822. * A sphere used for the radial explosion event
  67823. */
  67824. sphere: Mesh;
  67825. }
  67826. /**
  67827. * Interface for gravitational field event data
  67828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67829. */
  67830. export interface PhysicsGravitationalFieldEventData {
  67831. /**
  67832. * A sphere mesh used for the gravitational field event
  67833. */
  67834. sphere: Mesh;
  67835. }
  67836. /**
  67837. * Interface for updraft event data
  67838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67839. */
  67840. export interface PhysicsUpdraftEventData {
  67841. /**
  67842. * A cylinder used for the updraft event
  67843. */
  67844. cylinder: Mesh;
  67845. }
  67846. /**
  67847. * Interface for vortex event data
  67848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67849. */
  67850. export interface PhysicsVortexEventData {
  67851. /**
  67852. * A cylinder used for the vortex event
  67853. */
  67854. cylinder: Mesh;
  67855. }
  67856. /**
  67857. * Interface for an affected physics impostor
  67858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67859. */
  67860. export interface PhysicsAffectedImpostorWithData {
  67861. /**
  67862. * The impostor affected by the effect
  67863. */
  67864. impostor: PhysicsImpostor;
  67865. /**
  67866. * The data about the hit/horce from the explosion
  67867. */
  67868. hitData: PhysicsHitData;
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. /** @hidden */
  67873. export var blackAndWhitePixelShader: {
  67874. name: string;
  67875. shader: string;
  67876. };
  67877. }
  67878. declare module BABYLON {
  67879. /**
  67880. * Post process used to render in black and white
  67881. */
  67882. export class BlackAndWhitePostProcess extends PostProcess {
  67883. /**
  67884. * Linear about to convert he result to black and white (default: 1)
  67885. */
  67886. degree: number;
  67887. /**
  67888. * Creates a black and white post process
  67889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67890. * @param name The name of the effect.
  67891. * @param options The required width/height ratio to downsize to before computing the render pass.
  67892. * @param camera The camera to apply the render pass to.
  67893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67894. * @param engine The engine which the post process will be applied. (default: current engine)
  67895. * @param reusable If the post process can be reused on the same frame. (default: false)
  67896. */
  67897. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. /**
  67902. * This represents a set of one or more post processes in Babylon.
  67903. * A post process can be used to apply a shader to a texture after it is rendered.
  67904. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67905. */
  67906. export class PostProcessRenderEffect {
  67907. private _postProcesses;
  67908. private _getPostProcesses;
  67909. private _singleInstance;
  67910. private _cameras;
  67911. private _indicesForCamera;
  67912. /**
  67913. * Name of the effect
  67914. * @hidden
  67915. */
  67916. _name: string;
  67917. /**
  67918. * Instantiates a post process render effect.
  67919. * A post process can be used to apply a shader to a texture after it is rendered.
  67920. * @param engine The engine the effect is tied to
  67921. * @param name The name of the effect
  67922. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67923. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67924. */
  67925. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67926. /**
  67927. * Checks if all the post processes in the effect are supported.
  67928. */
  67929. get isSupported(): boolean;
  67930. /**
  67931. * Updates the current state of the effect
  67932. * @hidden
  67933. */
  67934. _update(): void;
  67935. /**
  67936. * Attaches the effect on cameras
  67937. * @param cameras The camera to attach to.
  67938. * @hidden
  67939. */
  67940. _attachCameras(cameras: Camera): 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. * Detaches the effect on cameras
  67949. * @param cameras The camera to detatch from.
  67950. * @hidden
  67951. */
  67952. _detachCameras(cameras: Camera): void;
  67953. /**
  67954. * Detatches the effect on cameras
  67955. * @param cameras The camera to detatch from.
  67956. * @hidden
  67957. */
  67958. _detachCameras(cameras: Camera[]): void;
  67959. /**
  67960. * Enables the effect on given cameras
  67961. * @param cameras The camera to enable.
  67962. * @hidden
  67963. */
  67964. _enable(cameras: Camera): void;
  67965. /**
  67966. * Enables the effect on given cameras
  67967. * @param cameras The camera to enable.
  67968. * @hidden
  67969. */
  67970. _enable(cameras: Nullable<Camera[]>): void;
  67971. /**
  67972. * Disables the effect on the given cameras
  67973. * @param cameras The camera to disable.
  67974. * @hidden
  67975. */
  67976. _disable(cameras: Camera): void;
  67977. /**
  67978. * Disables the effect on the given cameras
  67979. * @param cameras The camera to disable.
  67980. * @hidden
  67981. */
  67982. _disable(cameras: Nullable<Camera[]>): void;
  67983. /**
  67984. * Gets a list of the post processes contained in the effect.
  67985. * @param camera The camera to get the post processes on.
  67986. * @returns The list of the post processes in the effect.
  67987. */
  67988. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67989. }
  67990. }
  67991. declare module BABYLON {
  67992. /** @hidden */
  67993. export var extractHighlightsPixelShader: {
  67994. name: string;
  67995. shader: string;
  67996. };
  67997. }
  67998. declare module BABYLON {
  67999. /**
  68000. * 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.
  68001. */
  68002. export class ExtractHighlightsPostProcess extends PostProcess {
  68003. /**
  68004. * The luminance threshold, pixels below this value will be set to black.
  68005. */
  68006. threshold: number;
  68007. /** @hidden */
  68008. _exposure: number;
  68009. /**
  68010. * Post process which has the input texture to be used when performing highlight extraction
  68011. * @hidden
  68012. */
  68013. _inputPostProcess: Nullable<PostProcess>;
  68014. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68015. }
  68016. }
  68017. declare module BABYLON {
  68018. /** @hidden */
  68019. export var bloomMergePixelShader: {
  68020. name: string;
  68021. shader: string;
  68022. };
  68023. }
  68024. declare module BABYLON {
  68025. /**
  68026. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68027. */
  68028. export class BloomMergePostProcess extends PostProcess {
  68029. /** Weight of the bloom to be added to the original input. */
  68030. weight: number;
  68031. /**
  68032. * Creates a new instance of @see BloomMergePostProcess
  68033. * @param name The name of the effect.
  68034. * @param originalFromInput Post process which's input will be used for the merge.
  68035. * @param blurred Blurred highlights post process which's output will be used.
  68036. * @param weight Weight of the bloom to be added to the original input.
  68037. * @param options The required width/height ratio to downsize to before computing the render pass.
  68038. * @param camera The camera to apply the render pass to.
  68039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68040. * @param engine The engine which the post process will be applied. (default: current engine)
  68041. * @param reusable If the post process can be reused on the same frame. (default: false)
  68042. * @param textureType Type of textures used when performing the post process. (default: 0)
  68043. * @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)
  68044. */
  68045. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68046. /** Weight of the bloom to be added to the original input. */
  68047. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68048. }
  68049. }
  68050. declare module BABYLON {
  68051. /**
  68052. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68053. */
  68054. export class BloomEffect extends PostProcessRenderEffect {
  68055. private bloomScale;
  68056. /**
  68057. * @hidden Internal
  68058. */
  68059. _effects: Array<PostProcess>;
  68060. /**
  68061. * @hidden Internal
  68062. */
  68063. _downscale: ExtractHighlightsPostProcess;
  68064. private _blurX;
  68065. private _blurY;
  68066. private _merge;
  68067. /**
  68068. * The luminance threshold to find bright areas of the image to bloom.
  68069. */
  68070. get threshold(): number;
  68071. set threshold(value: number);
  68072. /**
  68073. * The strength of the bloom.
  68074. */
  68075. get weight(): number;
  68076. set weight(value: number);
  68077. /**
  68078. * Specifies the size of the bloom blur kernel, relative to the final output size
  68079. */
  68080. get kernel(): number;
  68081. set kernel(value: number);
  68082. /**
  68083. * Creates a new instance of @see BloomEffect
  68084. * @param scene The scene the effect belongs to.
  68085. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68086. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68087. * @param bloomWeight The the strength of bloom.
  68088. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68089. * @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)
  68090. */
  68091. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68092. /**
  68093. * Disposes each of the internal effects for a given camera.
  68094. * @param camera The camera to dispose the effect on.
  68095. */
  68096. disposeEffects(camera: Camera): void;
  68097. /**
  68098. * @hidden Internal
  68099. */
  68100. _updateEffects(): void;
  68101. /**
  68102. * Internal
  68103. * @returns if all the contained post processes are ready.
  68104. * @hidden
  68105. */
  68106. _isReady(): boolean;
  68107. }
  68108. }
  68109. declare module BABYLON {
  68110. /** @hidden */
  68111. export var chromaticAberrationPixelShader: {
  68112. name: string;
  68113. shader: string;
  68114. };
  68115. }
  68116. declare module BABYLON {
  68117. /**
  68118. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68119. */
  68120. export class ChromaticAberrationPostProcess extends PostProcess {
  68121. /**
  68122. * The amount of seperation of rgb channels (default: 30)
  68123. */
  68124. aberrationAmount: number;
  68125. /**
  68126. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68127. */
  68128. radialIntensity: number;
  68129. /**
  68130. * 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))
  68131. */
  68132. direction: Vector2;
  68133. /**
  68134. * 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))
  68135. */
  68136. centerPosition: Vector2;
  68137. /**
  68138. * Creates a new instance ChromaticAberrationPostProcess
  68139. * @param name The name of the effect.
  68140. * @param screenWidth The width of the screen to apply the effect on.
  68141. * @param screenHeight The height of the screen to apply the effect on.
  68142. * @param options The required width/height ratio to downsize to before computing the render pass.
  68143. * @param camera The camera to apply the render pass to.
  68144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68145. * @param engine The engine which the post process will be applied. (default: current engine)
  68146. * @param reusable If the post process can be reused on the same frame. (default: false)
  68147. * @param textureType Type of textures used when performing the post process. (default: 0)
  68148. * @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)
  68149. */
  68150. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68151. }
  68152. }
  68153. declare module BABYLON {
  68154. /** @hidden */
  68155. export var circleOfConfusionPixelShader: {
  68156. name: string;
  68157. shader: string;
  68158. };
  68159. }
  68160. declare module BABYLON {
  68161. /**
  68162. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68163. */
  68164. export class CircleOfConfusionPostProcess extends PostProcess {
  68165. /**
  68166. * 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.
  68167. */
  68168. lensSize: number;
  68169. /**
  68170. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68171. */
  68172. fStop: number;
  68173. /**
  68174. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68175. */
  68176. focusDistance: number;
  68177. /**
  68178. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68179. */
  68180. focalLength: number;
  68181. private _depthTexture;
  68182. /**
  68183. * Creates a new instance CircleOfConfusionPostProcess
  68184. * @param name The name of the effect.
  68185. * @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.
  68186. * @param options The required width/height ratio to downsize to before computing the render pass.
  68187. * @param camera The camera to apply the render pass to.
  68188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68189. * @param engine The engine which the post process will be applied. (default: current engine)
  68190. * @param reusable If the post process can be reused on the same frame. (default: false)
  68191. * @param textureType Type of textures used when performing the post process. (default: 0)
  68192. * @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)
  68193. */
  68194. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68195. /**
  68196. * 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.
  68197. */
  68198. set depthTexture(value: RenderTargetTexture);
  68199. }
  68200. }
  68201. declare module BABYLON {
  68202. /** @hidden */
  68203. export var colorCorrectionPixelShader: {
  68204. name: string;
  68205. shader: string;
  68206. };
  68207. }
  68208. declare module BABYLON {
  68209. /**
  68210. *
  68211. * This post-process allows the modification of rendered colors by using
  68212. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68213. *
  68214. * The object needs to be provided an url to a texture containing the color
  68215. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68216. * Use an image editing software to tweak the LUT to match your needs.
  68217. *
  68218. * For an example of a color LUT, see here:
  68219. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68220. * For explanations on color grading, see here:
  68221. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68222. *
  68223. */
  68224. export class ColorCorrectionPostProcess extends PostProcess {
  68225. private _colorTableTexture;
  68226. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68227. }
  68228. }
  68229. declare module BABYLON {
  68230. /** @hidden */
  68231. export var convolutionPixelShader: {
  68232. name: string;
  68233. shader: string;
  68234. };
  68235. }
  68236. declare module BABYLON {
  68237. /**
  68238. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68239. * input texture to perform effects such as edge detection or sharpening
  68240. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68241. */
  68242. export class ConvolutionPostProcess extends PostProcess {
  68243. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68244. kernel: number[];
  68245. /**
  68246. * Creates a new instance ConvolutionPostProcess
  68247. * @param name The name of the effect.
  68248. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68249. * @param options The required width/height ratio to downsize to before computing the render pass.
  68250. * @param camera The camera to apply the render pass to.
  68251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68252. * @param engine The engine which the post process will be applied. (default: current engine)
  68253. * @param reusable If the post process can be reused on the same frame. (default: false)
  68254. * @param textureType Type of textures used when performing the post process. (default: 0)
  68255. */
  68256. constructor(name: string,
  68257. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68258. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68259. /**
  68260. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68261. */
  68262. static EdgeDetect0Kernel: number[];
  68263. /**
  68264. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68265. */
  68266. static EdgeDetect1Kernel: number[];
  68267. /**
  68268. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68269. */
  68270. static EdgeDetect2Kernel: number[];
  68271. /**
  68272. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68273. */
  68274. static SharpenKernel: number[];
  68275. /**
  68276. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68277. */
  68278. static EmbossKernel: number[];
  68279. /**
  68280. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68281. */
  68282. static GaussianKernel: number[];
  68283. }
  68284. }
  68285. declare module BABYLON {
  68286. /**
  68287. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68288. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68289. * based on samples that have a large difference in distance than the center pixel.
  68290. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68291. */
  68292. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68293. direction: Vector2;
  68294. /**
  68295. * Creates a new instance CircleOfConfusionPostProcess
  68296. * @param name The name of the effect.
  68297. * @param scene The scene the effect belongs to.
  68298. * @param direction The direction the blur should be applied.
  68299. * @param kernel The size of the kernel used to blur.
  68300. * @param options The required width/height ratio to downsize to before computing the render pass.
  68301. * @param camera The camera to apply the render pass to.
  68302. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68303. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68305. * @param engine The engine which the post process will be applied. (default: current engine)
  68306. * @param reusable If the post process can be reused on the same frame. (default: false)
  68307. * @param textureType Type of textures used when performing the post process. (default: 0)
  68308. * @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)
  68309. */
  68310. 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);
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /** @hidden */
  68315. export var depthOfFieldMergePixelShader: {
  68316. name: string;
  68317. shader: string;
  68318. };
  68319. }
  68320. declare module BABYLON {
  68321. /**
  68322. * Options to be set when merging outputs from the default pipeline.
  68323. */
  68324. export class DepthOfFieldMergePostProcessOptions {
  68325. /**
  68326. * The original image to merge on top of
  68327. */
  68328. originalFromInput: PostProcess;
  68329. /**
  68330. * Parameters to perform the merge of the depth of field effect
  68331. */
  68332. depthOfField?: {
  68333. circleOfConfusion: PostProcess;
  68334. blurSteps: Array<PostProcess>;
  68335. };
  68336. /**
  68337. * Parameters to perform the merge of bloom effect
  68338. */
  68339. bloom?: {
  68340. blurred: PostProcess;
  68341. weight: number;
  68342. };
  68343. }
  68344. /**
  68345. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68346. */
  68347. export class DepthOfFieldMergePostProcess extends PostProcess {
  68348. private blurSteps;
  68349. /**
  68350. * Creates a new instance of DepthOfFieldMergePostProcess
  68351. * @param name The name of the effect.
  68352. * @param originalFromInput Post process which's input will be used for the merge.
  68353. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68354. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68355. * @param options The required width/height ratio to downsize to before computing the render pass.
  68356. * @param camera The camera to apply the render pass to.
  68357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68358. * @param engine The engine which the post process will be applied. (default: current engine)
  68359. * @param reusable If the post process can be reused on the same frame. (default: false)
  68360. * @param textureType Type of textures used when performing the post process. (default: 0)
  68361. * @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)
  68362. */
  68363. 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);
  68364. /**
  68365. * Updates the effect with the current post process compile time values and recompiles the shader.
  68366. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68367. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68368. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68369. * @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
  68370. * @param onCompiled Called when the shader has been compiled.
  68371. * @param onError Called if there is an error when compiling a shader.
  68372. */
  68373. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68374. }
  68375. }
  68376. declare module BABYLON {
  68377. /**
  68378. * Specifies the level of max blur that should be applied when using the depth of field effect
  68379. */
  68380. export enum DepthOfFieldEffectBlurLevel {
  68381. /**
  68382. * Subtle blur
  68383. */
  68384. Low = 0,
  68385. /**
  68386. * Medium blur
  68387. */
  68388. Medium = 1,
  68389. /**
  68390. * Large blur
  68391. */
  68392. High = 2
  68393. }
  68394. /**
  68395. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68396. */
  68397. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68398. private _circleOfConfusion;
  68399. /**
  68400. * @hidden Internal, blurs from high to low
  68401. */
  68402. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68403. private _depthOfFieldBlurY;
  68404. private _dofMerge;
  68405. /**
  68406. * @hidden Internal post processes in depth of field effect
  68407. */
  68408. _effects: Array<PostProcess>;
  68409. /**
  68410. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68411. */
  68412. set focalLength(value: number);
  68413. get focalLength(): number;
  68414. /**
  68415. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68416. */
  68417. set fStop(value: number);
  68418. get fStop(): number;
  68419. /**
  68420. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68421. */
  68422. set focusDistance(value: number);
  68423. get focusDistance(): number;
  68424. /**
  68425. * 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.
  68426. */
  68427. set lensSize(value: number);
  68428. get lensSize(): number;
  68429. /**
  68430. * Creates a new instance DepthOfFieldEffect
  68431. * @param scene The scene the effect belongs to.
  68432. * @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.
  68433. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68434. * @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)
  68435. */
  68436. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68437. /**
  68438. * Get the current class name of the current effet
  68439. * @returns "DepthOfFieldEffect"
  68440. */
  68441. getClassName(): string;
  68442. /**
  68443. * 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.
  68444. */
  68445. set depthTexture(value: RenderTargetTexture);
  68446. /**
  68447. * Disposes each of the internal effects for a given camera.
  68448. * @param camera The camera to dispose the effect on.
  68449. */
  68450. disposeEffects(camera: Camera): void;
  68451. /**
  68452. * @hidden Internal
  68453. */
  68454. _updateEffects(): void;
  68455. /**
  68456. * Internal
  68457. * @returns if all the contained post processes are ready.
  68458. * @hidden
  68459. */
  68460. _isReady(): boolean;
  68461. }
  68462. }
  68463. declare module BABYLON {
  68464. /** @hidden */
  68465. export var displayPassPixelShader: {
  68466. name: string;
  68467. shader: string;
  68468. };
  68469. }
  68470. declare module BABYLON {
  68471. /**
  68472. * DisplayPassPostProcess which produces an output the same as it's input
  68473. */
  68474. export class DisplayPassPostProcess extends PostProcess {
  68475. /**
  68476. * Creates the DisplayPassPostProcess
  68477. * @param name The name of the effect.
  68478. * @param options The required width/height ratio to downsize to before computing the render pass.
  68479. * @param camera The camera to apply the render pass to.
  68480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68481. * @param engine The engine which the post process will be applied. (default: current engine)
  68482. * @param reusable If the post process can be reused on the same frame. (default: false)
  68483. */
  68484. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68485. }
  68486. }
  68487. declare module BABYLON {
  68488. /** @hidden */
  68489. export var filterPixelShader: {
  68490. name: string;
  68491. shader: string;
  68492. };
  68493. }
  68494. declare module BABYLON {
  68495. /**
  68496. * Applies a kernel filter to the image
  68497. */
  68498. export class FilterPostProcess extends PostProcess {
  68499. /** The matrix to be applied to the image */
  68500. kernelMatrix: Matrix;
  68501. /**
  68502. *
  68503. * @param name The name of the effect.
  68504. * @param kernelMatrix The matrix to be applied to the image
  68505. * @param options The required width/height ratio to downsize to before computing the render pass.
  68506. * @param camera The camera to apply the render pass to.
  68507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68508. * @param engine The engine which the post process will be applied. (default: current engine)
  68509. * @param reusable If the post process can be reused on the same frame. (default: false)
  68510. */
  68511. constructor(name: string,
  68512. /** The matrix to be applied to the image */
  68513. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68514. }
  68515. }
  68516. declare module BABYLON {
  68517. /** @hidden */
  68518. export var fxaaPixelShader: {
  68519. name: string;
  68520. shader: string;
  68521. };
  68522. }
  68523. declare module BABYLON {
  68524. /** @hidden */
  68525. export var fxaaVertexShader: {
  68526. name: string;
  68527. shader: string;
  68528. };
  68529. }
  68530. declare module BABYLON {
  68531. /**
  68532. * Fxaa post process
  68533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68534. */
  68535. export class FxaaPostProcess extends PostProcess {
  68536. /** @hidden */
  68537. texelWidth: number;
  68538. /** @hidden */
  68539. texelHeight: number;
  68540. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68541. private _getDefines;
  68542. }
  68543. }
  68544. declare module BABYLON {
  68545. /** @hidden */
  68546. export var grainPixelShader: {
  68547. name: string;
  68548. shader: string;
  68549. };
  68550. }
  68551. declare module BABYLON {
  68552. /**
  68553. * The GrainPostProcess adds noise to the image at mid luminance levels
  68554. */
  68555. export class GrainPostProcess extends PostProcess {
  68556. /**
  68557. * The intensity of the grain added (default: 30)
  68558. */
  68559. intensity: number;
  68560. /**
  68561. * If the grain should be randomized on every frame
  68562. */
  68563. animated: boolean;
  68564. /**
  68565. * Creates a new instance of @see GrainPostProcess
  68566. * @param name The name of the effect.
  68567. * @param options The required width/height ratio to downsize to before computing the render pass.
  68568. * @param camera The camera to apply the render pass to.
  68569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68570. * @param engine The engine which the post process will be applied. (default: current engine)
  68571. * @param reusable If the post process can be reused on the same frame. (default: false)
  68572. * @param textureType Type of textures used when performing the post process. (default: 0)
  68573. * @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)
  68574. */
  68575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68576. }
  68577. }
  68578. declare module BABYLON {
  68579. /** @hidden */
  68580. export var highlightsPixelShader: {
  68581. name: string;
  68582. shader: string;
  68583. };
  68584. }
  68585. declare module BABYLON {
  68586. /**
  68587. * Extracts highlights from the image
  68588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68589. */
  68590. export class HighlightsPostProcess extends PostProcess {
  68591. /**
  68592. * Extracts highlights from the image
  68593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68594. * @param name The name of the effect.
  68595. * @param options The required width/height ratio to downsize to before computing the render pass.
  68596. * @param camera The camera to apply the render pass to.
  68597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68598. * @param engine The engine which the post process will be applied. (default: current engine)
  68599. * @param reusable If the post process can be reused on the same frame. (default: false)
  68600. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68601. */
  68602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68603. }
  68604. }
  68605. declare module BABYLON {
  68606. /** @hidden */
  68607. export var mrtFragmentDeclaration: {
  68608. name: string;
  68609. shader: string;
  68610. };
  68611. }
  68612. declare module BABYLON {
  68613. /** @hidden */
  68614. export var geometryPixelShader: {
  68615. name: string;
  68616. shader: string;
  68617. };
  68618. }
  68619. declare module BABYLON {
  68620. /** @hidden */
  68621. export var geometryVertexShader: {
  68622. name: string;
  68623. shader: string;
  68624. };
  68625. }
  68626. declare module BABYLON {
  68627. /** @hidden */
  68628. interface ISavedTransformationMatrix {
  68629. world: Matrix;
  68630. viewProjection: Matrix;
  68631. }
  68632. /**
  68633. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68634. */
  68635. export class GeometryBufferRenderer {
  68636. /**
  68637. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68638. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68639. */
  68640. static readonly POSITION_TEXTURE_TYPE: number;
  68641. /**
  68642. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68643. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68644. */
  68645. static readonly VELOCITY_TEXTURE_TYPE: number;
  68646. /**
  68647. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68648. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68649. */
  68650. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68651. /**
  68652. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68653. * in order to compute objects velocities when enableVelocity is set to "true"
  68654. * @hidden
  68655. */
  68656. _previousTransformationMatrices: {
  68657. [index: number]: ISavedTransformationMatrix;
  68658. };
  68659. /**
  68660. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68661. * in order to compute objects velocities when enableVelocity is set to "true"
  68662. * @hidden
  68663. */
  68664. _previousBonesTransformationMatrices: {
  68665. [index: number]: Float32Array;
  68666. };
  68667. /**
  68668. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68669. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68670. */
  68671. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68672. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68673. renderTransparentMeshes: boolean;
  68674. private _scene;
  68675. private _multiRenderTarget;
  68676. private _ratio;
  68677. private _enablePosition;
  68678. private _enableVelocity;
  68679. private _enableReflectivity;
  68680. private _positionIndex;
  68681. private _velocityIndex;
  68682. private _reflectivityIndex;
  68683. protected _effect: Effect;
  68684. protected _cachedDefines: string;
  68685. /**
  68686. * Set the render list (meshes to be rendered) used in the G buffer.
  68687. */
  68688. set renderList(meshes: Mesh[]);
  68689. /**
  68690. * Gets wether or not G buffer are supported by the running hardware.
  68691. * This requires draw buffer supports
  68692. */
  68693. get isSupported(): boolean;
  68694. /**
  68695. * Returns the index of the given texture type in the G-Buffer textures array
  68696. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68697. * @returns the index of the given texture type in the G-Buffer textures array
  68698. */
  68699. getTextureIndex(textureType: number): number;
  68700. /**
  68701. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68702. */
  68703. get enablePosition(): boolean;
  68704. /**
  68705. * Sets whether or not objects positions are enabled for the G buffer.
  68706. */
  68707. set enablePosition(enable: boolean);
  68708. /**
  68709. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68710. */
  68711. get enableVelocity(): boolean;
  68712. /**
  68713. * Sets wether or not objects velocities are enabled for the G buffer.
  68714. */
  68715. set enableVelocity(enable: boolean);
  68716. /**
  68717. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68718. */
  68719. get enableReflectivity(): boolean;
  68720. /**
  68721. * Sets wether or not objects roughness are enabled for the G buffer.
  68722. */
  68723. set enableReflectivity(enable: boolean);
  68724. /**
  68725. * Gets the scene associated with the buffer.
  68726. */
  68727. get scene(): Scene;
  68728. /**
  68729. * Gets the ratio used by the buffer during its creation.
  68730. * How big is the buffer related to the main canvas.
  68731. */
  68732. get ratio(): number;
  68733. /** @hidden */
  68734. static _SceneComponentInitialization: (scene: Scene) => void;
  68735. /**
  68736. * Creates a new G Buffer for the scene
  68737. * @param scene The scene the buffer belongs to
  68738. * @param ratio How big is the buffer related to the main canvas.
  68739. */
  68740. constructor(scene: Scene, ratio?: number);
  68741. /**
  68742. * Checks wether everything is ready to render a submesh to the G buffer.
  68743. * @param subMesh the submesh to check readiness for
  68744. * @param useInstances is the mesh drawn using instance or not
  68745. * @returns true if ready otherwise false
  68746. */
  68747. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68748. /**
  68749. * Gets the current underlying G Buffer.
  68750. * @returns the buffer
  68751. */
  68752. getGBuffer(): MultiRenderTarget;
  68753. /**
  68754. * Gets the number of samples used to render the buffer (anti aliasing).
  68755. */
  68756. get samples(): number;
  68757. /**
  68758. * Sets the number of samples used to render the buffer (anti aliasing).
  68759. */
  68760. set samples(value: number);
  68761. /**
  68762. * Disposes the renderer and frees up associated resources.
  68763. */
  68764. dispose(): void;
  68765. protected _createRenderTargets(): void;
  68766. private _copyBonesTransformationMatrices;
  68767. }
  68768. }
  68769. declare module BABYLON {
  68770. interface Scene {
  68771. /** @hidden (Backing field) */
  68772. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68773. /**
  68774. * Gets or Sets the current geometry buffer associated to the scene.
  68775. */
  68776. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68777. /**
  68778. * Enables a GeometryBufferRender and associates it with the scene
  68779. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68780. * @returns the GeometryBufferRenderer
  68781. */
  68782. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68783. /**
  68784. * Disables the GeometryBufferRender associated with the scene
  68785. */
  68786. disableGeometryBufferRenderer(): void;
  68787. }
  68788. /**
  68789. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68790. * in several rendering techniques.
  68791. */
  68792. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68793. /**
  68794. * The component name helpful to identify the component in the list of scene components.
  68795. */
  68796. readonly name: string;
  68797. /**
  68798. * The scene the component belongs to.
  68799. */
  68800. scene: Scene;
  68801. /**
  68802. * Creates a new instance of the component for the given scene
  68803. * @param scene Defines the scene to register the component in
  68804. */
  68805. constructor(scene: Scene);
  68806. /**
  68807. * Registers the component in a given scene
  68808. */
  68809. register(): void;
  68810. /**
  68811. * Rebuilds the elements related to this component in case of
  68812. * context lost for instance.
  68813. */
  68814. rebuild(): void;
  68815. /**
  68816. * Disposes the component and the associated ressources
  68817. */
  68818. dispose(): void;
  68819. private _gatherRenderTargets;
  68820. }
  68821. }
  68822. declare module BABYLON {
  68823. /** @hidden */
  68824. export var motionBlurPixelShader: {
  68825. name: string;
  68826. shader: string;
  68827. };
  68828. }
  68829. declare module BABYLON {
  68830. /**
  68831. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68832. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68833. * As an example, all you have to do is to create the post-process:
  68834. * var mb = new BABYLON.MotionBlurPostProcess(
  68835. * 'mb', // The name of the effect.
  68836. * scene, // The scene containing the objects to blur according to their velocity.
  68837. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68838. * camera // The camera to apply the render pass to.
  68839. * );
  68840. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68841. */
  68842. export class MotionBlurPostProcess extends PostProcess {
  68843. /**
  68844. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68845. */
  68846. motionStrength: number;
  68847. /**
  68848. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68849. */
  68850. get motionBlurSamples(): number;
  68851. /**
  68852. * Sets the number of iterations to be used for motion blur quality
  68853. */
  68854. set motionBlurSamples(samples: number);
  68855. private _motionBlurSamples;
  68856. private _geometryBufferRenderer;
  68857. /**
  68858. * Creates a new instance MotionBlurPostProcess
  68859. * @param name The name of the effect.
  68860. * @param scene The scene containing the objects to blur according to their velocity.
  68861. * @param options The required width/height ratio to downsize to before computing the render pass.
  68862. * @param camera The camera to apply the render pass to.
  68863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68864. * @param engine The engine which the post process will be applied. (default: current engine)
  68865. * @param reusable If the post process can be reused on the same frame. (default: false)
  68866. * @param textureType Type of textures used when performing the post process. (default: 0)
  68867. * @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)
  68868. */
  68869. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68870. /**
  68871. * Excludes the given skinned mesh from computing bones velocities.
  68872. * 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.
  68873. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68874. */
  68875. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68876. /**
  68877. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68878. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68879. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68880. */
  68881. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68882. /**
  68883. * Disposes the post process.
  68884. * @param camera The camera to dispose the post process on.
  68885. */
  68886. dispose(camera?: Camera): void;
  68887. }
  68888. }
  68889. declare module BABYLON {
  68890. /** @hidden */
  68891. export var refractionPixelShader: {
  68892. name: string;
  68893. shader: string;
  68894. };
  68895. }
  68896. declare module BABYLON {
  68897. /**
  68898. * Post process which applies a refractin texture
  68899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68900. */
  68901. export class RefractionPostProcess extends PostProcess {
  68902. /** the base color of the refraction (used to taint the rendering) */
  68903. color: Color3;
  68904. /** simulated refraction depth */
  68905. depth: number;
  68906. /** the coefficient of the base color (0 to remove base color tainting) */
  68907. colorLevel: number;
  68908. private _refTexture;
  68909. private _ownRefractionTexture;
  68910. /**
  68911. * Gets or sets the refraction texture
  68912. * Please note that you are responsible for disposing the texture if you set it manually
  68913. */
  68914. get refractionTexture(): Texture;
  68915. set refractionTexture(value: Texture);
  68916. /**
  68917. * Initializes the RefractionPostProcess
  68918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68919. * @param name The name of the effect.
  68920. * @param refractionTextureUrl Url of the refraction texture to use
  68921. * @param color the base color of the refraction (used to taint the rendering)
  68922. * @param depth simulated refraction depth
  68923. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68924. * @param camera The camera to apply the render pass to.
  68925. * @param options The required width/height ratio to downsize to before computing the render pass.
  68926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68927. * @param engine The engine which the post process will be applied. (default: current engine)
  68928. * @param reusable If the post process can be reused on the same frame. (default: false)
  68929. */
  68930. constructor(name: string, refractionTextureUrl: string,
  68931. /** the base color of the refraction (used to taint the rendering) */
  68932. color: Color3,
  68933. /** simulated refraction depth */
  68934. depth: number,
  68935. /** the coefficient of the base color (0 to remove base color tainting) */
  68936. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68937. /**
  68938. * Disposes of the post process
  68939. * @param camera Camera to dispose post process on
  68940. */
  68941. dispose(camera: Camera): void;
  68942. }
  68943. }
  68944. declare module BABYLON {
  68945. /** @hidden */
  68946. export var sharpenPixelShader: {
  68947. name: string;
  68948. shader: string;
  68949. };
  68950. }
  68951. declare module BABYLON {
  68952. /**
  68953. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68954. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68955. */
  68956. export class SharpenPostProcess extends PostProcess {
  68957. /**
  68958. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68959. */
  68960. colorAmount: number;
  68961. /**
  68962. * How much sharpness should be applied (default: 0.3)
  68963. */
  68964. edgeAmount: number;
  68965. /**
  68966. * Creates a new instance ConvolutionPostProcess
  68967. * @param name The name of the effect.
  68968. * @param options The required width/height ratio to downsize to before computing the render pass.
  68969. * @param camera The camera to apply the render pass to.
  68970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68971. * @param engine The engine which the post process will be applied. (default: current engine)
  68972. * @param reusable If the post process can be reused on the same frame. (default: false)
  68973. * @param textureType Type of textures used when performing the post process. (default: 0)
  68974. * @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)
  68975. */
  68976. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68977. }
  68978. }
  68979. declare module BABYLON {
  68980. /**
  68981. * PostProcessRenderPipeline
  68982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68983. */
  68984. export class PostProcessRenderPipeline {
  68985. private engine;
  68986. private _renderEffects;
  68987. private _renderEffectsForIsolatedPass;
  68988. /**
  68989. * List of inspectable custom properties (used by the Inspector)
  68990. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68991. */
  68992. inspectableCustomProperties: IInspectable[];
  68993. /**
  68994. * @hidden
  68995. */
  68996. protected _cameras: Camera[];
  68997. /** @hidden */
  68998. _name: string;
  68999. /**
  69000. * Gets pipeline name
  69001. */
  69002. get name(): string;
  69003. /** Gets the list of attached cameras */
  69004. get cameras(): Camera[];
  69005. /**
  69006. * Initializes a PostProcessRenderPipeline
  69007. * @param engine engine to add the pipeline to
  69008. * @param name name of the pipeline
  69009. */
  69010. constructor(engine: Engine, name: string);
  69011. /**
  69012. * Gets the class name
  69013. * @returns "PostProcessRenderPipeline"
  69014. */
  69015. getClassName(): string;
  69016. /**
  69017. * If all the render effects in the pipeline are supported
  69018. */
  69019. get isSupported(): boolean;
  69020. /**
  69021. * Adds an effect to the pipeline
  69022. * @param renderEffect the effect to add
  69023. */
  69024. addEffect(renderEffect: PostProcessRenderEffect): void;
  69025. /** @hidden */
  69026. _rebuild(): void;
  69027. /** @hidden */
  69028. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69029. /** @hidden */
  69030. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69031. /** @hidden */
  69032. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69033. /** @hidden */
  69034. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69035. /** @hidden */
  69036. _attachCameras(cameras: Camera, unique: boolean): void;
  69037. /** @hidden */
  69038. _attachCameras(cameras: Camera[], unique: boolean): void;
  69039. /** @hidden */
  69040. _detachCameras(cameras: Camera): void;
  69041. /** @hidden */
  69042. _detachCameras(cameras: Nullable<Camera[]>): void;
  69043. /** @hidden */
  69044. _update(): void;
  69045. /** @hidden */
  69046. _reset(): void;
  69047. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69048. /**
  69049. * Disposes of the pipeline
  69050. */
  69051. dispose(): void;
  69052. }
  69053. }
  69054. declare module BABYLON {
  69055. /**
  69056. * PostProcessRenderPipelineManager class
  69057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69058. */
  69059. export class PostProcessRenderPipelineManager {
  69060. private _renderPipelines;
  69061. /**
  69062. * Initializes a PostProcessRenderPipelineManager
  69063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69064. */
  69065. constructor();
  69066. /**
  69067. * Gets the list of supported render pipelines
  69068. */
  69069. get supportedPipelines(): PostProcessRenderPipeline[];
  69070. /**
  69071. * Adds a pipeline to the manager
  69072. * @param renderPipeline The pipeline to add
  69073. */
  69074. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69075. /**
  69076. * Attaches a camera to the pipeline
  69077. * @param renderPipelineName The name of the pipeline to attach to
  69078. * @param cameras the camera to attach
  69079. * @param unique if the camera can be attached multiple times to the pipeline
  69080. */
  69081. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69082. /**
  69083. * Detaches a camera from the pipeline
  69084. * @param renderPipelineName The name of the pipeline to detach from
  69085. * @param cameras the camera to detach
  69086. */
  69087. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69088. /**
  69089. * Enables an effect by name on a pipeline
  69090. * @param renderPipelineName the name of the pipeline to enable the effect in
  69091. * @param renderEffectName the name of the effect to enable
  69092. * @param cameras the cameras that the effect should be enabled on
  69093. */
  69094. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69095. /**
  69096. * Disables an effect by name on a pipeline
  69097. * @param renderPipelineName the name of the pipeline to disable the effect in
  69098. * @param renderEffectName the name of the effect to disable
  69099. * @param cameras the cameras that the effect should be disabled on
  69100. */
  69101. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69102. /**
  69103. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69104. */
  69105. update(): void;
  69106. /** @hidden */
  69107. _rebuild(): void;
  69108. /**
  69109. * Disposes of the manager and pipelines
  69110. */
  69111. dispose(): void;
  69112. }
  69113. }
  69114. declare module BABYLON {
  69115. interface Scene {
  69116. /** @hidden (Backing field) */
  69117. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69118. /**
  69119. * Gets the postprocess render pipeline manager
  69120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69121. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69122. */
  69123. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69124. }
  69125. /**
  69126. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69127. */
  69128. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69129. /**
  69130. * The component name helpfull to identify the component in the list of scene components.
  69131. */
  69132. readonly name: string;
  69133. /**
  69134. * The scene the component belongs to.
  69135. */
  69136. scene: Scene;
  69137. /**
  69138. * Creates a new instance of the component for the given scene
  69139. * @param scene Defines the scene to register the component in
  69140. */
  69141. constructor(scene: Scene);
  69142. /**
  69143. * Registers the component in a given scene
  69144. */
  69145. register(): void;
  69146. /**
  69147. * Rebuilds the elements related to this component in case of
  69148. * context lost for instance.
  69149. */
  69150. rebuild(): void;
  69151. /**
  69152. * Disposes the component and the associated ressources
  69153. */
  69154. dispose(): void;
  69155. private _gatherRenderTargets;
  69156. }
  69157. }
  69158. declare module BABYLON {
  69159. /**
  69160. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69161. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69162. */
  69163. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69164. private _scene;
  69165. private _camerasToBeAttached;
  69166. /**
  69167. * ID of the sharpen post process,
  69168. */
  69169. private readonly SharpenPostProcessId;
  69170. /**
  69171. * @ignore
  69172. * ID of the image processing post process;
  69173. */
  69174. readonly ImageProcessingPostProcessId: string;
  69175. /**
  69176. * @ignore
  69177. * ID of the Fast Approximate Anti-Aliasing post process;
  69178. */
  69179. readonly FxaaPostProcessId: string;
  69180. /**
  69181. * ID of the chromatic aberration post process,
  69182. */
  69183. private readonly ChromaticAberrationPostProcessId;
  69184. /**
  69185. * ID of the grain post process
  69186. */
  69187. private readonly GrainPostProcessId;
  69188. /**
  69189. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69190. */
  69191. sharpen: SharpenPostProcess;
  69192. private _sharpenEffect;
  69193. private bloom;
  69194. /**
  69195. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69196. */
  69197. depthOfField: DepthOfFieldEffect;
  69198. /**
  69199. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69200. */
  69201. fxaa: FxaaPostProcess;
  69202. /**
  69203. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69204. */
  69205. imageProcessing: ImageProcessingPostProcess;
  69206. /**
  69207. * Chromatic aberration post process which will shift rgb colors in the image
  69208. */
  69209. chromaticAberration: ChromaticAberrationPostProcess;
  69210. private _chromaticAberrationEffect;
  69211. /**
  69212. * Grain post process which add noise to the image
  69213. */
  69214. grain: GrainPostProcess;
  69215. private _grainEffect;
  69216. /**
  69217. * Glow post process which adds a glow to emissive areas of the image
  69218. */
  69219. private _glowLayer;
  69220. /**
  69221. * Animations which can be used to tweak settings over a period of time
  69222. */
  69223. animations: Animation[];
  69224. private _imageProcessingConfigurationObserver;
  69225. private _sharpenEnabled;
  69226. private _bloomEnabled;
  69227. private _depthOfFieldEnabled;
  69228. private _depthOfFieldBlurLevel;
  69229. private _fxaaEnabled;
  69230. private _imageProcessingEnabled;
  69231. private _defaultPipelineTextureType;
  69232. private _bloomScale;
  69233. private _chromaticAberrationEnabled;
  69234. private _grainEnabled;
  69235. private _buildAllowed;
  69236. /**
  69237. * Gets active scene
  69238. */
  69239. get scene(): Scene;
  69240. /**
  69241. * Enable or disable the sharpen process from the pipeline
  69242. */
  69243. set sharpenEnabled(enabled: boolean);
  69244. get sharpenEnabled(): boolean;
  69245. private _resizeObserver;
  69246. private _hardwareScaleLevel;
  69247. private _bloomKernel;
  69248. /**
  69249. * Specifies the size of the bloom blur kernel, relative to the final output size
  69250. */
  69251. get bloomKernel(): number;
  69252. set bloomKernel(value: number);
  69253. /**
  69254. * Specifies the weight of the bloom in the final rendering
  69255. */
  69256. private _bloomWeight;
  69257. /**
  69258. * Specifies the luma threshold for the area that will be blurred by the bloom
  69259. */
  69260. private _bloomThreshold;
  69261. private _hdr;
  69262. /**
  69263. * The strength of the bloom.
  69264. */
  69265. set bloomWeight(value: number);
  69266. get bloomWeight(): number;
  69267. /**
  69268. * The strength of the bloom.
  69269. */
  69270. set bloomThreshold(value: number);
  69271. get bloomThreshold(): number;
  69272. /**
  69273. * The scale of the bloom, lower value will provide better performance.
  69274. */
  69275. set bloomScale(value: number);
  69276. get bloomScale(): number;
  69277. /**
  69278. * Enable or disable the bloom from the pipeline
  69279. */
  69280. set bloomEnabled(enabled: boolean);
  69281. get bloomEnabled(): boolean;
  69282. private _rebuildBloom;
  69283. /**
  69284. * If the depth of field is enabled.
  69285. */
  69286. get depthOfFieldEnabled(): boolean;
  69287. set depthOfFieldEnabled(enabled: boolean);
  69288. /**
  69289. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69290. */
  69291. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69292. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69293. /**
  69294. * If the anti aliasing is enabled.
  69295. */
  69296. set fxaaEnabled(enabled: boolean);
  69297. get fxaaEnabled(): boolean;
  69298. private _samples;
  69299. /**
  69300. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69301. */
  69302. set samples(sampleCount: number);
  69303. get samples(): number;
  69304. /**
  69305. * If image processing is enabled.
  69306. */
  69307. set imageProcessingEnabled(enabled: boolean);
  69308. get imageProcessingEnabled(): boolean;
  69309. /**
  69310. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69311. */
  69312. set glowLayerEnabled(enabled: boolean);
  69313. get glowLayerEnabled(): boolean;
  69314. /**
  69315. * Gets the glow layer (or null if not defined)
  69316. */
  69317. get glowLayer(): Nullable<GlowLayer>;
  69318. /**
  69319. * Enable or disable the chromaticAberration process from the pipeline
  69320. */
  69321. set chromaticAberrationEnabled(enabled: boolean);
  69322. get chromaticAberrationEnabled(): boolean;
  69323. /**
  69324. * Enable or disable the grain process from the pipeline
  69325. */
  69326. set grainEnabled(enabled: boolean);
  69327. get grainEnabled(): boolean;
  69328. /**
  69329. * @constructor
  69330. * @param name - The rendering pipeline name (default: "")
  69331. * @param hdr - If high dynamic range textures should be used (default: true)
  69332. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69333. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69334. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69335. */
  69336. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69337. /**
  69338. * Get the class name
  69339. * @returns "DefaultRenderingPipeline"
  69340. */
  69341. getClassName(): string;
  69342. /**
  69343. * Force the compilation of the entire pipeline.
  69344. */
  69345. prepare(): void;
  69346. private _hasCleared;
  69347. private _prevPostProcess;
  69348. private _prevPrevPostProcess;
  69349. private _setAutoClearAndTextureSharing;
  69350. private _depthOfFieldSceneObserver;
  69351. private _buildPipeline;
  69352. private _disposePostProcesses;
  69353. /**
  69354. * Adds a camera to the pipeline
  69355. * @param camera the camera to be added
  69356. */
  69357. addCamera(camera: Camera): void;
  69358. /**
  69359. * Removes a camera from the pipeline
  69360. * @param camera the camera to remove
  69361. */
  69362. removeCamera(camera: Camera): void;
  69363. /**
  69364. * Dispose of the pipeline and stop all post processes
  69365. */
  69366. dispose(): void;
  69367. /**
  69368. * Serialize the rendering pipeline (Used when exporting)
  69369. * @returns the serialized object
  69370. */
  69371. serialize(): any;
  69372. /**
  69373. * Parse the serialized pipeline
  69374. * @param source Source pipeline.
  69375. * @param scene The scene to load the pipeline to.
  69376. * @param rootUrl The URL of the serialized pipeline.
  69377. * @returns An instantiated pipeline from the serialized object.
  69378. */
  69379. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69380. }
  69381. }
  69382. declare module BABYLON {
  69383. /** @hidden */
  69384. export var lensHighlightsPixelShader: {
  69385. name: string;
  69386. shader: string;
  69387. };
  69388. }
  69389. declare module BABYLON {
  69390. /** @hidden */
  69391. export var depthOfFieldPixelShader: {
  69392. name: string;
  69393. shader: string;
  69394. };
  69395. }
  69396. declare module BABYLON {
  69397. /**
  69398. * BABYLON.JS Chromatic Aberration GLSL Shader
  69399. * Author: Olivier Guyot
  69400. * Separates very slightly R, G and B colors on the edges of the screen
  69401. * Inspired by Francois Tarlier & Martins Upitis
  69402. */
  69403. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69404. /**
  69405. * @ignore
  69406. * The chromatic aberration PostProcess id in the pipeline
  69407. */
  69408. LensChromaticAberrationEffect: string;
  69409. /**
  69410. * @ignore
  69411. * The highlights enhancing PostProcess id in the pipeline
  69412. */
  69413. HighlightsEnhancingEffect: string;
  69414. /**
  69415. * @ignore
  69416. * The depth-of-field PostProcess id in the pipeline
  69417. */
  69418. LensDepthOfFieldEffect: string;
  69419. private _scene;
  69420. private _depthTexture;
  69421. private _grainTexture;
  69422. private _chromaticAberrationPostProcess;
  69423. private _highlightsPostProcess;
  69424. private _depthOfFieldPostProcess;
  69425. private _edgeBlur;
  69426. private _grainAmount;
  69427. private _chromaticAberration;
  69428. private _distortion;
  69429. private _highlightsGain;
  69430. private _highlightsThreshold;
  69431. private _dofDistance;
  69432. private _dofAperture;
  69433. private _dofDarken;
  69434. private _dofPentagon;
  69435. private _blurNoise;
  69436. /**
  69437. * @constructor
  69438. *
  69439. * Effect parameters are as follow:
  69440. * {
  69441. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69442. * edge_blur: number; // from 0 to x (1 for realism)
  69443. * distortion: number; // from 0 to x (1 for realism)
  69444. * grain_amount: number; // from 0 to 1
  69445. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69446. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69447. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69448. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69449. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69450. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69451. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69452. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69453. * }
  69454. * Note: if an effect parameter is unset, effect is disabled
  69455. *
  69456. * @param name The rendering pipeline name
  69457. * @param parameters - An object containing all parameters (see above)
  69458. * @param scene The scene linked to this pipeline
  69459. * @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)
  69460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69461. */
  69462. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69463. /**
  69464. * Get the class name
  69465. * @returns "LensRenderingPipeline"
  69466. */
  69467. getClassName(): string;
  69468. /**
  69469. * Gets associated scene
  69470. */
  69471. get scene(): Scene;
  69472. /**
  69473. * Gets or sets the edge blur
  69474. */
  69475. get edgeBlur(): number;
  69476. set edgeBlur(value: number);
  69477. /**
  69478. * Gets or sets the grain amount
  69479. */
  69480. get grainAmount(): number;
  69481. set grainAmount(value: number);
  69482. /**
  69483. * Gets or sets the chromatic aberration amount
  69484. */
  69485. get chromaticAberration(): number;
  69486. set chromaticAberration(value: number);
  69487. /**
  69488. * Gets or sets the depth of field aperture
  69489. */
  69490. get dofAperture(): number;
  69491. set dofAperture(value: number);
  69492. /**
  69493. * Gets or sets the edge distortion
  69494. */
  69495. get edgeDistortion(): number;
  69496. set edgeDistortion(value: number);
  69497. /**
  69498. * Gets or sets the depth of field distortion
  69499. */
  69500. get dofDistortion(): number;
  69501. set dofDistortion(value: number);
  69502. /**
  69503. * Gets or sets the darken out of focus amount
  69504. */
  69505. get darkenOutOfFocus(): number;
  69506. set darkenOutOfFocus(value: number);
  69507. /**
  69508. * Gets or sets a boolean indicating if blur noise is enabled
  69509. */
  69510. get blurNoise(): boolean;
  69511. set blurNoise(value: boolean);
  69512. /**
  69513. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69514. */
  69515. get pentagonBokeh(): boolean;
  69516. set pentagonBokeh(value: boolean);
  69517. /**
  69518. * Gets or sets the highlight grain amount
  69519. */
  69520. get highlightsGain(): number;
  69521. set highlightsGain(value: number);
  69522. /**
  69523. * Gets or sets the highlight threshold
  69524. */
  69525. get highlightsThreshold(): number;
  69526. set highlightsThreshold(value: number);
  69527. /**
  69528. * Sets the amount of blur at the edges
  69529. * @param amount blur amount
  69530. */
  69531. setEdgeBlur(amount: number): void;
  69532. /**
  69533. * Sets edge blur to 0
  69534. */
  69535. disableEdgeBlur(): void;
  69536. /**
  69537. * Sets the amout of grain
  69538. * @param amount Amount of grain
  69539. */
  69540. setGrainAmount(amount: number): void;
  69541. /**
  69542. * Set grain amount to 0
  69543. */
  69544. disableGrain(): void;
  69545. /**
  69546. * Sets the chromatic aberration amount
  69547. * @param amount amount of chromatic aberration
  69548. */
  69549. setChromaticAberration(amount: number): void;
  69550. /**
  69551. * Sets chromatic aberration amount to 0
  69552. */
  69553. disableChromaticAberration(): void;
  69554. /**
  69555. * Sets the EdgeDistortion amount
  69556. * @param amount amount of EdgeDistortion
  69557. */
  69558. setEdgeDistortion(amount: number): void;
  69559. /**
  69560. * Sets edge distortion to 0
  69561. */
  69562. disableEdgeDistortion(): void;
  69563. /**
  69564. * Sets the FocusDistance amount
  69565. * @param amount amount of FocusDistance
  69566. */
  69567. setFocusDistance(amount: number): void;
  69568. /**
  69569. * Disables depth of field
  69570. */
  69571. disableDepthOfField(): void;
  69572. /**
  69573. * Sets the Aperture amount
  69574. * @param amount amount of Aperture
  69575. */
  69576. setAperture(amount: number): void;
  69577. /**
  69578. * Sets the DarkenOutOfFocus amount
  69579. * @param amount amount of DarkenOutOfFocus
  69580. */
  69581. setDarkenOutOfFocus(amount: number): void;
  69582. private _pentagonBokehIsEnabled;
  69583. /**
  69584. * Creates a pentagon bokeh effect
  69585. */
  69586. enablePentagonBokeh(): void;
  69587. /**
  69588. * Disables the pentagon bokeh effect
  69589. */
  69590. disablePentagonBokeh(): void;
  69591. /**
  69592. * Enables noise blur
  69593. */
  69594. enableNoiseBlur(): void;
  69595. /**
  69596. * Disables noise blur
  69597. */
  69598. disableNoiseBlur(): void;
  69599. /**
  69600. * Sets the HighlightsGain amount
  69601. * @param amount amount of HighlightsGain
  69602. */
  69603. setHighlightsGain(amount: number): void;
  69604. /**
  69605. * Sets the HighlightsThreshold amount
  69606. * @param amount amount of HighlightsThreshold
  69607. */
  69608. setHighlightsThreshold(amount: number): void;
  69609. /**
  69610. * Disables highlights
  69611. */
  69612. disableHighlights(): void;
  69613. /**
  69614. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69615. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69616. */
  69617. dispose(disableDepthRender?: boolean): void;
  69618. private _createChromaticAberrationPostProcess;
  69619. private _createHighlightsPostProcess;
  69620. private _createDepthOfFieldPostProcess;
  69621. private _createGrainTexture;
  69622. }
  69623. }
  69624. declare module BABYLON {
  69625. /** @hidden */
  69626. export var ssao2PixelShader: {
  69627. name: string;
  69628. shader: string;
  69629. };
  69630. }
  69631. declare module BABYLON {
  69632. /** @hidden */
  69633. export var ssaoCombinePixelShader: {
  69634. name: string;
  69635. shader: string;
  69636. };
  69637. }
  69638. declare module BABYLON {
  69639. /**
  69640. * Render pipeline to produce ssao effect
  69641. */
  69642. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69643. /**
  69644. * @ignore
  69645. * The PassPostProcess id in the pipeline that contains the original scene color
  69646. */
  69647. SSAOOriginalSceneColorEffect: string;
  69648. /**
  69649. * @ignore
  69650. * The SSAO PostProcess id in the pipeline
  69651. */
  69652. SSAORenderEffect: string;
  69653. /**
  69654. * @ignore
  69655. * The horizontal blur PostProcess id in the pipeline
  69656. */
  69657. SSAOBlurHRenderEffect: string;
  69658. /**
  69659. * @ignore
  69660. * The vertical blur PostProcess id in the pipeline
  69661. */
  69662. SSAOBlurVRenderEffect: string;
  69663. /**
  69664. * @ignore
  69665. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69666. */
  69667. SSAOCombineRenderEffect: string;
  69668. /**
  69669. * The output strength of the SSAO post-process. Default value is 1.0.
  69670. */
  69671. totalStrength: number;
  69672. /**
  69673. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69674. */
  69675. maxZ: number;
  69676. /**
  69677. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69678. */
  69679. minZAspect: number;
  69680. private _samples;
  69681. /**
  69682. * Number of samples used for the SSAO calculations. Default value is 8
  69683. */
  69684. set samples(n: number);
  69685. get samples(): number;
  69686. private _textureSamples;
  69687. /**
  69688. * Number of samples to use for antialiasing
  69689. */
  69690. set textureSamples(n: number);
  69691. get textureSamples(): number;
  69692. /**
  69693. * Ratio object used for SSAO ratio and blur ratio
  69694. */
  69695. private _ratio;
  69696. /**
  69697. * Dynamically generated sphere sampler.
  69698. */
  69699. private _sampleSphere;
  69700. /**
  69701. * Blur filter offsets
  69702. */
  69703. private _samplerOffsets;
  69704. private _expensiveBlur;
  69705. /**
  69706. * If bilateral blur should be used
  69707. */
  69708. set expensiveBlur(b: boolean);
  69709. get expensiveBlur(): boolean;
  69710. /**
  69711. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69712. */
  69713. radius: number;
  69714. /**
  69715. * The base color of the SSAO post-process
  69716. * The final result is "base + ssao" between [0, 1]
  69717. */
  69718. base: number;
  69719. /**
  69720. * Support test.
  69721. */
  69722. static get IsSupported(): boolean;
  69723. private _scene;
  69724. private _depthTexture;
  69725. private _normalTexture;
  69726. private _randomTexture;
  69727. private _originalColorPostProcess;
  69728. private _ssaoPostProcess;
  69729. private _blurHPostProcess;
  69730. private _blurVPostProcess;
  69731. private _ssaoCombinePostProcess;
  69732. /**
  69733. * Gets active scene
  69734. */
  69735. get scene(): Scene;
  69736. /**
  69737. * @constructor
  69738. * @param name The rendering pipeline name
  69739. * @param scene The scene linked to this pipeline
  69740. * @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 }
  69741. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69742. */
  69743. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69744. /**
  69745. * Get the class name
  69746. * @returns "SSAO2RenderingPipeline"
  69747. */
  69748. getClassName(): string;
  69749. /**
  69750. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69751. */
  69752. dispose(disableGeometryBufferRenderer?: boolean): void;
  69753. private _createBlurPostProcess;
  69754. /** @hidden */
  69755. _rebuild(): void;
  69756. private _bits;
  69757. private _radicalInverse_VdC;
  69758. private _hammersley;
  69759. private _hemisphereSample_uniform;
  69760. private _generateHemisphere;
  69761. private _createSSAOPostProcess;
  69762. private _createSSAOCombinePostProcess;
  69763. private _createRandomTexture;
  69764. /**
  69765. * Serialize the rendering pipeline (Used when exporting)
  69766. * @returns the serialized object
  69767. */
  69768. serialize(): any;
  69769. /**
  69770. * Parse the serialized pipeline
  69771. * @param source Source pipeline.
  69772. * @param scene The scene to load the pipeline to.
  69773. * @param rootUrl The URL of the serialized pipeline.
  69774. * @returns An instantiated pipeline from the serialized object.
  69775. */
  69776. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69777. }
  69778. }
  69779. declare module BABYLON {
  69780. /** @hidden */
  69781. export var ssaoPixelShader: {
  69782. name: string;
  69783. shader: string;
  69784. };
  69785. }
  69786. declare module BABYLON {
  69787. /**
  69788. * Render pipeline to produce ssao effect
  69789. */
  69790. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69791. /**
  69792. * @ignore
  69793. * The PassPostProcess id in the pipeline that contains the original scene color
  69794. */
  69795. SSAOOriginalSceneColorEffect: string;
  69796. /**
  69797. * @ignore
  69798. * The SSAO PostProcess id in the pipeline
  69799. */
  69800. SSAORenderEffect: string;
  69801. /**
  69802. * @ignore
  69803. * The horizontal blur PostProcess id in the pipeline
  69804. */
  69805. SSAOBlurHRenderEffect: string;
  69806. /**
  69807. * @ignore
  69808. * The vertical blur PostProcess id in the pipeline
  69809. */
  69810. SSAOBlurVRenderEffect: string;
  69811. /**
  69812. * @ignore
  69813. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69814. */
  69815. SSAOCombineRenderEffect: string;
  69816. /**
  69817. * The output strength of the SSAO post-process. Default value is 1.0.
  69818. */
  69819. totalStrength: number;
  69820. /**
  69821. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69822. */
  69823. radius: number;
  69824. /**
  69825. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69826. * Must not be equal to fallOff and superior to fallOff.
  69827. * Default value is 0.0075
  69828. */
  69829. area: number;
  69830. /**
  69831. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69832. * Must not be equal to area and inferior to area.
  69833. * Default value is 0.000001
  69834. */
  69835. fallOff: number;
  69836. /**
  69837. * The base color of the SSAO post-process
  69838. * The final result is "base + ssao" between [0, 1]
  69839. */
  69840. base: number;
  69841. private _scene;
  69842. private _depthTexture;
  69843. private _randomTexture;
  69844. private _originalColorPostProcess;
  69845. private _ssaoPostProcess;
  69846. private _blurHPostProcess;
  69847. private _blurVPostProcess;
  69848. private _ssaoCombinePostProcess;
  69849. private _firstUpdate;
  69850. /**
  69851. * Gets active scene
  69852. */
  69853. get scene(): Scene;
  69854. /**
  69855. * @constructor
  69856. * @param name - The rendering pipeline name
  69857. * @param scene - The scene linked to this pipeline
  69858. * @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 }
  69859. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69860. */
  69861. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69862. /**
  69863. * Get the class name
  69864. * @returns "SSAORenderingPipeline"
  69865. */
  69866. getClassName(): string;
  69867. /**
  69868. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69869. */
  69870. dispose(disableDepthRender?: boolean): void;
  69871. private _createBlurPostProcess;
  69872. /** @hidden */
  69873. _rebuild(): void;
  69874. private _createSSAOPostProcess;
  69875. private _createSSAOCombinePostProcess;
  69876. private _createRandomTexture;
  69877. }
  69878. }
  69879. declare module BABYLON {
  69880. /** @hidden */
  69881. export var screenSpaceReflectionPixelShader: {
  69882. name: string;
  69883. shader: string;
  69884. };
  69885. }
  69886. declare module BABYLON {
  69887. /**
  69888. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69889. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69890. */
  69891. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69892. /**
  69893. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69894. */
  69895. threshold: number;
  69896. /**
  69897. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69898. */
  69899. strength: number;
  69900. /**
  69901. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69902. */
  69903. reflectionSpecularFalloffExponent: number;
  69904. /**
  69905. * 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]
  69906. */
  69907. step: number;
  69908. /**
  69909. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69910. */
  69911. roughnessFactor: number;
  69912. private _geometryBufferRenderer;
  69913. private _enableSmoothReflections;
  69914. private _reflectionSamples;
  69915. private _smoothSteps;
  69916. /**
  69917. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69918. * @param name The name of the effect.
  69919. * @param scene The scene containing the objects to calculate reflections.
  69920. * @param options The required width/height ratio to downsize to before computing the render pass.
  69921. * @param camera The camera to apply the render pass to.
  69922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69923. * @param engine The engine which the post process will be applied. (default: current engine)
  69924. * @param reusable If the post process can be reused on the same frame. (default: false)
  69925. * @param textureType Type of textures used when performing the post process. (default: 0)
  69926. * @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)
  69927. */
  69928. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69929. /**
  69930. * Gets wether or not smoothing reflections is enabled.
  69931. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69932. */
  69933. get enableSmoothReflections(): boolean;
  69934. /**
  69935. * Sets wether or not smoothing reflections is enabled.
  69936. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69937. */
  69938. set enableSmoothReflections(enabled: boolean);
  69939. /**
  69940. * Gets the number of samples taken while computing reflections. More samples count is high,
  69941. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69942. */
  69943. get reflectionSamples(): number;
  69944. /**
  69945. * Sets the number of samples taken while computing reflections. More samples count is high,
  69946. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69947. */
  69948. set reflectionSamples(samples: number);
  69949. /**
  69950. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69951. * more the post-process will require GPU power and can generate a drop in FPS.
  69952. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69953. */
  69954. get smoothSteps(): number;
  69955. set smoothSteps(steps: number);
  69956. private _updateEffectDefines;
  69957. }
  69958. }
  69959. declare module BABYLON {
  69960. /** @hidden */
  69961. export var standardPixelShader: {
  69962. name: string;
  69963. shader: string;
  69964. };
  69965. }
  69966. declare module BABYLON {
  69967. /**
  69968. * Standard rendering pipeline
  69969. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69970. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69971. */
  69972. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69973. /**
  69974. * Public members
  69975. */
  69976. /**
  69977. * Post-process which contains the original scene color before the pipeline applies all the effects
  69978. */
  69979. originalPostProcess: Nullable<PostProcess>;
  69980. /**
  69981. * Post-process used to down scale an image x4
  69982. */
  69983. downSampleX4PostProcess: Nullable<PostProcess>;
  69984. /**
  69985. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69986. */
  69987. brightPassPostProcess: Nullable<PostProcess>;
  69988. /**
  69989. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69990. */
  69991. blurHPostProcesses: PostProcess[];
  69992. /**
  69993. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69994. */
  69995. blurVPostProcesses: PostProcess[];
  69996. /**
  69997. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69998. */
  69999. textureAdderPostProcess: Nullable<PostProcess>;
  70000. /**
  70001. * Post-process used to create volumetric lighting effect
  70002. */
  70003. volumetricLightPostProcess: Nullable<PostProcess>;
  70004. /**
  70005. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70006. */
  70007. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70008. /**
  70009. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70010. */
  70011. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70012. /**
  70013. * Post-process used to merge the volumetric light effect and the real scene color
  70014. */
  70015. volumetricLightMergePostProces: Nullable<PostProcess>;
  70016. /**
  70017. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70018. */
  70019. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70020. /**
  70021. * Base post-process used to calculate the average luminance of the final image for HDR
  70022. */
  70023. luminancePostProcess: Nullable<PostProcess>;
  70024. /**
  70025. * Post-processes used to create down sample post-processes in order to get
  70026. * the average luminance of the final image for HDR
  70027. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70028. */
  70029. luminanceDownSamplePostProcesses: PostProcess[];
  70030. /**
  70031. * Post-process used to create a HDR effect (light adaptation)
  70032. */
  70033. hdrPostProcess: Nullable<PostProcess>;
  70034. /**
  70035. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70036. */
  70037. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70038. /**
  70039. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70040. */
  70041. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70042. /**
  70043. * Post-process used to merge the final HDR post-process and the real scene color
  70044. */
  70045. hdrFinalPostProcess: Nullable<PostProcess>;
  70046. /**
  70047. * Post-process used to create a lens flare effect
  70048. */
  70049. lensFlarePostProcess: Nullable<PostProcess>;
  70050. /**
  70051. * Post-process that merges the result of the lens flare post-process and the real scene color
  70052. */
  70053. lensFlareComposePostProcess: Nullable<PostProcess>;
  70054. /**
  70055. * Post-process used to create a motion blur effect
  70056. */
  70057. motionBlurPostProcess: Nullable<PostProcess>;
  70058. /**
  70059. * Post-process used to create a depth of field effect
  70060. */
  70061. depthOfFieldPostProcess: Nullable<PostProcess>;
  70062. /**
  70063. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70064. */
  70065. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70066. /**
  70067. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70068. */
  70069. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70070. /**
  70071. * Represents the brightness threshold in order to configure the illuminated surfaces
  70072. */
  70073. brightThreshold: number;
  70074. /**
  70075. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70076. */
  70077. blurWidth: number;
  70078. /**
  70079. * Sets if the blur for highlighted surfaces must be only horizontal
  70080. */
  70081. horizontalBlur: boolean;
  70082. /**
  70083. * Gets the overall exposure used by the pipeline
  70084. */
  70085. get exposure(): number;
  70086. /**
  70087. * Sets the overall exposure used by the pipeline
  70088. */
  70089. set exposure(value: number);
  70090. /**
  70091. * Texture used typically to simulate "dirty" on camera lens
  70092. */
  70093. lensTexture: Nullable<Texture>;
  70094. /**
  70095. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70096. */
  70097. volumetricLightCoefficient: number;
  70098. /**
  70099. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70100. */
  70101. volumetricLightPower: number;
  70102. /**
  70103. * Used the set the blur intensity to smooth the volumetric lights
  70104. */
  70105. volumetricLightBlurScale: number;
  70106. /**
  70107. * Light (spot or directional) used to generate the volumetric lights rays
  70108. * The source light must have a shadow generate so the pipeline can get its
  70109. * depth map
  70110. */
  70111. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70112. /**
  70113. * For eye adaptation, represents the minimum luminance the eye can see
  70114. */
  70115. hdrMinimumLuminance: number;
  70116. /**
  70117. * For eye adaptation, represents the decrease luminance speed
  70118. */
  70119. hdrDecreaseRate: number;
  70120. /**
  70121. * For eye adaptation, represents the increase luminance speed
  70122. */
  70123. hdrIncreaseRate: number;
  70124. /**
  70125. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70126. */
  70127. get hdrAutoExposure(): boolean;
  70128. /**
  70129. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70130. */
  70131. set hdrAutoExposure(value: boolean);
  70132. /**
  70133. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70134. */
  70135. lensColorTexture: Nullable<Texture>;
  70136. /**
  70137. * The overall strengh for the lens flare effect
  70138. */
  70139. lensFlareStrength: number;
  70140. /**
  70141. * Dispersion coefficient for lens flare ghosts
  70142. */
  70143. lensFlareGhostDispersal: number;
  70144. /**
  70145. * Main lens flare halo width
  70146. */
  70147. lensFlareHaloWidth: number;
  70148. /**
  70149. * Based on the lens distortion effect, defines how much the lens flare result
  70150. * is distorted
  70151. */
  70152. lensFlareDistortionStrength: number;
  70153. /**
  70154. * Configures the blur intensity used for for lens flare (halo)
  70155. */
  70156. lensFlareBlurWidth: number;
  70157. /**
  70158. * Lens star texture must be used to simulate rays on the flares and is available
  70159. * in the documentation
  70160. */
  70161. lensStarTexture: Nullable<Texture>;
  70162. /**
  70163. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70164. * flare effect by taking account of the dirt texture
  70165. */
  70166. lensFlareDirtTexture: Nullable<Texture>;
  70167. /**
  70168. * Represents the focal length for the depth of field effect
  70169. */
  70170. depthOfFieldDistance: number;
  70171. /**
  70172. * Represents the blur intensity for the blurred part of the depth of field effect
  70173. */
  70174. depthOfFieldBlurWidth: number;
  70175. /**
  70176. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70177. */
  70178. get motionStrength(): number;
  70179. /**
  70180. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70181. */
  70182. set motionStrength(strength: number);
  70183. /**
  70184. * Gets wether or not the motion blur post-process is object based or screen based.
  70185. */
  70186. get objectBasedMotionBlur(): boolean;
  70187. /**
  70188. * Sets wether or not the motion blur post-process should be object based or screen based
  70189. */
  70190. set objectBasedMotionBlur(value: boolean);
  70191. /**
  70192. * List of animations for the pipeline (IAnimatable implementation)
  70193. */
  70194. animations: Animation[];
  70195. /**
  70196. * Private members
  70197. */
  70198. private _scene;
  70199. private _currentDepthOfFieldSource;
  70200. private _basePostProcess;
  70201. private _fixedExposure;
  70202. private _currentExposure;
  70203. private _hdrAutoExposure;
  70204. private _hdrCurrentLuminance;
  70205. private _motionStrength;
  70206. private _isObjectBasedMotionBlur;
  70207. private _floatTextureType;
  70208. private _camerasToBeAttached;
  70209. private _ratio;
  70210. private _bloomEnabled;
  70211. private _depthOfFieldEnabled;
  70212. private _vlsEnabled;
  70213. private _lensFlareEnabled;
  70214. private _hdrEnabled;
  70215. private _motionBlurEnabled;
  70216. private _fxaaEnabled;
  70217. private _screenSpaceReflectionsEnabled;
  70218. private _motionBlurSamples;
  70219. private _volumetricLightStepsCount;
  70220. private _samples;
  70221. /**
  70222. * @ignore
  70223. * Specifies if the bloom pipeline is enabled
  70224. */
  70225. get BloomEnabled(): boolean;
  70226. set BloomEnabled(enabled: boolean);
  70227. /**
  70228. * @ignore
  70229. * Specifies if the depth of field pipeline is enabed
  70230. */
  70231. get DepthOfFieldEnabled(): boolean;
  70232. set DepthOfFieldEnabled(enabled: boolean);
  70233. /**
  70234. * @ignore
  70235. * Specifies if the lens flare pipeline is enabed
  70236. */
  70237. get LensFlareEnabled(): boolean;
  70238. set LensFlareEnabled(enabled: boolean);
  70239. /**
  70240. * @ignore
  70241. * Specifies if the HDR pipeline is enabled
  70242. */
  70243. get HDREnabled(): boolean;
  70244. set HDREnabled(enabled: boolean);
  70245. /**
  70246. * @ignore
  70247. * Specifies if the volumetric lights scattering effect is enabled
  70248. */
  70249. get VLSEnabled(): boolean;
  70250. set VLSEnabled(enabled: boolean);
  70251. /**
  70252. * @ignore
  70253. * Specifies if the motion blur effect is enabled
  70254. */
  70255. get MotionBlurEnabled(): boolean;
  70256. set MotionBlurEnabled(enabled: boolean);
  70257. /**
  70258. * Specifies if anti-aliasing is enabled
  70259. */
  70260. get fxaaEnabled(): boolean;
  70261. set fxaaEnabled(enabled: boolean);
  70262. /**
  70263. * Specifies if screen space reflections are enabled.
  70264. */
  70265. get screenSpaceReflectionsEnabled(): boolean;
  70266. set screenSpaceReflectionsEnabled(enabled: boolean);
  70267. /**
  70268. * Specifies the number of steps used to calculate the volumetric lights
  70269. * Typically in interval [50, 200]
  70270. */
  70271. get volumetricLightStepsCount(): number;
  70272. set volumetricLightStepsCount(count: number);
  70273. /**
  70274. * Specifies the number of samples used for the motion blur effect
  70275. * Typically in interval [16, 64]
  70276. */
  70277. get motionBlurSamples(): number;
  70278. set motionBlurSamples(samples: number);
  70279. /**
  70280. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70281. */
  70282. get samples(): number;
  70283. set samples(sampleCount: number);
  70284. /**
  70285. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70286. * @constructor
  70287. * @param name The rendering pipeline name
  70288. * @param scene The scene linked to this pipeline
  70289. * @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)
  70290. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70291. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70292. */
  70293. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70294. private _buildPipeline;
  70295. private _createDownSampleX4PostProcess;
  70296. private _createBrightPassPostProcess;
  70297. private _createBlurPostProcesses;
  70298. private _createTextureAdderPostProcess;
  70299. private _createVolumetricLightPostProcess;
  70300. private _createLuminancePostProcesses;
  70301. private _createHdrPostProcess;
  70302. private _createLensFlarePostProcess;
  70303. private _createDepthOfFieldPostProcess;
  70304. private _createMotionBlurPostProcess;
  70305. private _getDepthTexture;
  70306. private _disposePostProcesses;
  70307. /**
  70308. * Dispose of the pipeline and stop all post processes
  70309. */
  70310. dispose(): void;
  70311. /**
  70312. * Serialize the rendering pipeline (Used when exporting)
  70313. * @returns the serialized object
  70314. */
  70315. serialize(): any;
  70316. /**
  70317. * Parse the serialized pipeline
  70318. * @param source Source pipeline.
  70319. * @param scene The scene to load the pipeline to.
  70320. * @param rootUrl The URL of the serialized pipeline.
  70321. * @returns An instantiated pipeline from the serialized object.
  70322. */
  70323. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70324. /**
  70325. * Luminance steps
  70326. */
  70327. static LuminanceSteps: number;
  70328. }
  70329. }
  70330. declare module BABYLON {
  70331. /** @hidden */
  70332. export var stereoscopicInterlacePixelShader: {
  70333. name: string;
  70334. shader: string;
  70335. };
  70336. }
  70337. declare module BABYLON {
  70338. /**
  70339. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70340. */
  70341. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70342. private _stepSize;
  70343. private _passedProcess;
  70344. /**
  70345. * Initializes a StereoscopicInterlacePostProcessI
  70346. * @param name The name of the effect.
  70347. * @param rigCameras The rig cameras to be appled to the post process
  70348. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70349. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70351. * @param engine The engine which the post process will be applied. (default: current engine)
  70352. * @param reusable If the post process can be reused on the same frame. (default: false)
  70353. */
  70354. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70355. }
  70356. /**
  70357. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70358. */
  70359. export class StereoscopicInterlacePostProcess extends PostProcess {
  70360. private _stepSize;
  70361. private _passedProcess;
  70362. /**
  70363. * Initializes a StereoscopicInterlacePostProcess
  70364. * @param name The name of the effect.
  70365. * @param rigCameras The rig cameras to be appled to the post process
  70366. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70368. * @param engine The engine which the post process will be applied. (default: current engine)
  70369. * @param reusable If the post process can be reused on the same frame. (default: false)
  70370. */
  70371. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70372. }
  70373. }
  70374. declare module BABYLON {
  70375. /** @hidden */
  70376. export var tonemapPixelShader: {
  70377. name: string;
  70378. shader: string;
  70379. };
  70380. }
  70381. declare module BABYLON {
  70382. /** Defines operator used for tonemapping */
  70383. export enum TonemappingOperator {
  70384. /** Hable */
  70385. Hable = 0,
  70386. /** Reinhard */
  70387. Reinhard = 1,
  70388. /** HejiDawson */
  70389. HejiDawson = 2,
  70390. /** Photographic */
  70391. Photographic = 3
  70392. }
  70393. /**
  70394. * Defines a post process to apply tone mapping
  70395. */
  70396. export class TonemapPostProcess extends PostProcess {
  70397. private _operator;
  70398. /** Defines the required exposure adjustement */
  70399. exposureAdjustment: number;
  70400. /**
  70401. * Creates a new TonemapPostProcess
  70402. * @param name defines the name of the postprocess
  70403. * @param _operator defines the operator to use
  70404. * @param exposureAdjustment defines the required exposure adjustement
  70405. * @param camera defines the camera to use (can be null)
  70406. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70407. * @param engine defines the hosting engine (can be ignore if camera is set)
  70408. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70409. */
  70410. constructor(name: string, _operator: TonemappingOperator,
  70411. /** Defines the required exposure adjustement */
  70412. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70413. }
  70414. }
  70415. declare module BABYLON {
  70416. /** @hidden */
  70417. export var volumetricLightScatteringPixelShader: {
  70418. name: string;
  70419. shader: string;
  70420. };
  70421. }
  70422. declare module BABYLON {
  70423. /** @hidden */
  70424. export var volumetricLightScatteringPassVertexShader: {
  70425. name: string;
  70426. shader: string;
  70427. };
  70428. }
  70429. declare module BABYLON {
  70430. /** @hidden */
  70431. export var volumetricLightScatteringPassPixelShader: {
  70432. name: string;
  70433. shader: string;
  70434. };
  70435. }
  70436. declare module BABYLON {
  70437. /**
  70438. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70439. */
  70440. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70441. private _volumetricLightScatteringPass;
  70442. private _volumetricLightScatteringRTT;
  70443. private _viewPort;
  70444. private _screenCoordinates;
  70445. private _cachedDefines;
  70446. /**
  70447. * If not undefined, the mesh position is computed from the attached node position
  70448. */
  70449. attachedNode: {
  70450. position: Vector3;
  70451. };
  70452. /**
  70453. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70454. */
  70455. customMeshPosition: Vector3;
  70456. /**
  70457. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70458. */
  70459. useCustomMeshPosition: boolean;
  70460. /**
  70461. * If the post-process should inverse the light scattering direction
  70462. */
  70463. invert: boolean;
  70464. /**
  70465. * The internal mesh used by the post-process
  70466. */
  70467. mesh: Mesh;
  70468. /**
  70469. * @hidden
  70470. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70471. */
  70472. get useDiffuseColor(): boolean;
  70473. set useDiffuseColor(useDiffuseColor: boolean);
  70474. /**
  70475. * Array containing the excluded meshes not rendered in the internal pass
  70476. */
  70477. excludedMeshes: AbstractMesh[];
  70478. /**
  70479. * Controls the overall intensity of the post-process
  70480. */
  70481. exposure: number;
  70482. /**
  70483. * Dissipates each sample's contribution in range [0, 1]
  70484. */
  70485. decay: number;
  70486. /**
  70487. * Controls the overall intensity of each sample
  70488. */
  70489. weight: number;
  70490. /**
  70491. * Controls the density of each sample
  70492. */
  70493. density: number;
  70494. /**
  70495. * @constructor
  70496. * @param name The post-process name
  70497. * @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)
  70498. * @param camera The camera that the post-process will be attached to
  70499. * @param mesh The mesh used to create the light scattering
  70500. * @param samples The post-process quality, default 100
  70501. * @param samplingModeThe post-process filtering mode
  70502. * @param engine The babylon engine
  70503. * @param reusable If the post-process is reusable
  70504. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70505. */
  70506. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70507. /**
  70508. * Returns the string "VolumetricLightScatteringPostProcess"
  70509. * @returns "VolumetricLightScatteringPostProcess"
  70510. */
  70511. getClassName(): string;
  70512. private _isReady;
  70513. /**
  70514. * Sets the new light position for light scattering effect
  70515. * @param position The new custom light position
  70516. */
  70517. setCustomMeshPosition(position: Vector3): void;
  70518. /**
  70519. * Returns the light position for light scattering effect
  70520. * @return Vector3 The custom light position
  70521. */
  70522. getCustomMeshPosition(): Vector3;
  70523. /**
  70524. * Disposes the internal assets and detaches the post-process from the camera
  70525. */
  70526. dispose(camera: Camera): void;
  70527. /**
  70528. * Returns the render target texture used by the post-process
  70529. * @return the render target texture used by the post-process
  70530. */
  70531. getPass(): RenderTargetTexture;
  70532. private _meshExcluded;
  70533. private _createPass;
  70534. private _updateMeshScreenCoordinates;
  70535. /**
  70536. * Creates a default mesh for the Volumeric Light Scattering post-process
  70537. * @param name The mesh name
  70538. * @param scene The scene where to create the mesh
  70539. * @return the default mesh
  70540. */
  70541. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70542. }
  70543. }
  70544. declare module BABYLON {
  70545. interface Scene {
  70546. /** @hidden (Backing field) */
  70547. _boundingBoxRenderer: BoundingBoxRenderer;
  70548. /** @hidden (Backing field) */
  70549. _forceShowBoundingBoxes: boolean;
  70550. /**
  70551. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70552. */
  70553. forceShowBoundingBoxes: boolean;
  70554. /**
  70555. * Gets the bounding box renderer associated with the scene
  70556. * @returns a BoundingBoxRenderer
  70557. */
  70558. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70559. }
  70560. interface AbstractMesh {
  70561. /** @hidden (Backing field) */
  70562. _showBoundingBox: boolean;
  70563. /**
  70564. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70565. */
  70566. showBoundingBox: boolean;
  70567. }
  70568. /**
  70569. * Component responsible of rendering the bounding box of the meshes in a scene.
  70570. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70571. */
  70572. export class BoundingBoxRenderer implements ISceneComponent {
  70573. /**
  70574. * The component name helpfull to identify the component in the list of scene components.
  70575. */
  70576. readonly name: string;
  70577. /**
  70578. * The scene the component belongs to.
  70579. */
  70580. scene: Scene;
  70581. /**
  70582. * Color of the bounding box lines placed in front of an object
  70583. */
  70584. frontColor: Color3;
  70585. /**
  70586. * Color of the bounding box lines placed behind an object
  70587. */
  70588. backColor: Color3;
  70589. /**
  70590. * Defines if the renderer should show the back lines or not
  70591. */
  70592. showBackLines: boolean;
  70593. /**
  70594. * Observable raised before rendering a bounding box
  70595. */
  70596. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70597. /**
  70598. * Observable raised after rendering a bounding box
  70599. */
  70600. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70601. /**
  70602. * @hidden
  70603. */
  70604. renderList: SmartArray<BoundingBox>;
  70605. private _colorShader;
  70606. private _vertexBuffers;
  70607. private _indexBuffer;
  70608. private _fillIndexBuffer;
  70609. private _fillIndexData;
  70610. /**
  70611. * Instantiates a new bounding box renderer in a scene.
  70612. * @param scene the scene the renderer renders in
  70613. */
  70614. constructor(scene: Scene);
  70615. /**
  70616. * Registers the component in a given scene
  70617. */
  70618. register(): void;
  70619. private _evaluateSubMesh;
  70620. private _activeMesh;
  70621. private _prepareRessources;
  70622. private _createIndexBuffer;
  70623. /**
  70624. * Rebuilds the elements related to this component in case of
  70625. * context lost for instance.
  70626. */
  70627. rebuild(): void;
  70628. /**
  70629. * @hidden
  70630. */
  70631. reset(): void;
  70632. /**
  70633. * Render the bounding boxes of a specific rendering group
  70634. * @param renderingGroupId defines the rendering group to render
  70635. */
  70636. render(renderingGroupId: number): void;
  70637. /**
  70638. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70639. * @param mesh Define the mesh to render the occlusion bounding box for
  70640. */
  70641. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70642. /**
  70643. * Dispose and release the resources attached to this renderer.
  70644. */
  70645. dispose(): void;
  70646. }
  70647. }
  70648. declare module BABYLON {
  70649. interface Scene {
  70650. /** @hidden (Backing field) */
  70651. _depthRenderer: {
  70652. [id: string]: DepthRenderer;
  70653. };
  70654. /**
  70655. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70656. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70657. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70658. * @returns the created depth renderer
  70659. */
  70660. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70661. /**
  70662. * Disables a depth renderer for a given camera
  70663. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70664. */
  70665. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70666. }
  70667. /**
  70668. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70669. * in several rendering techniques.
  70670. */
  70671. export class DepthRendererSceneComponent implements ISceneComponent {
  70672. /**
  70673. * The component name helpfull to identify the component in the list of scene components.
  70674. */
  70675. readonly name: string;
  70676. /**
  70677. * The scene the component belongs to.
  70678. */
  70679. scene: Scene;
  70680. /**
  70681. * Creates a new instance of the component for the given scene
  70682. * @param scene Defines the scene to register the component in
  70683. */
  70684. constructor(scene: Scene);
  70685. /**
  70686. * Registers the component in a given scene
  70687. */
  70688. register(): void;
  70689. /**
  70690. * Rebuilds the elements related to this component in case of
  70691. * context lost for instance.
  70692. */
  70693. rebuild(): void;
  70694. /**
  70695. * Disposes the component and the associated ressources
  70696. */
  70697. dispose(): void;
  70698. private _gatherRenderTargets;
  70699. private _gatherActiveCameraRenderTargets;
  70700. }
  70701. }
  70702. declare module BABYLON {
  70703. /** @hidden */
  70704. export var fibonacci: {
  70705. name: string;
  70706. shader: string;
  70707. };
  70708. }
  70709. declare module BABYLON {
  70710. /** @hidden */
  70711. export var diffusionProfile: {
  70712. name: string;
  70713. shader: string;
  70714. };
  70715. }
  70716. declare module BABYLON {
  70717. /** @hidden */
  70718. export var subSurfaceScatteringPixelShader: {
  70719. name: string;
  70720. shader: string;
  70721. };
  70722. }
  70723. declare module BABYLON {
  70724. /**
  70725. * Sub surface scattering post process
  70726. */
  70727. export class SubSurfaceScatteringPostProcess extends PostProcess {
  70728. /** @hidden */
  70729. texelWidth: number;
  70730. /** @hidden */
  70731. texelHeight: number;
  70732. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70733. }
  70734. }
  70735. declare module BABYLON {
  70736. /**
  70737. * Contains all parameters needed for the prepass to perform
  70738. * screen space subsurface scattering
  70739. */
  70740. export class SubSurfaceConfiguration {
  70741. private _ssDiffusionS;
  70742. private _ssFilterRadii;
  70743. private _ssDiffusionD;
  70744. /**
  70745. * Diffusion profile color for subsurface scattering
  70746. */
  70747. get ssDiffusionS(): number[];
  70748. /**
  70749. * Diffusion profile max color channel value for subsurface scattering
  70750. */
  70751. get ssDiffusionD(): number[];
  70752. /**
  70753. * Diffusion profile filter radius for subsurface scattering
  70754. */
  70755. get ssFilterRadii(): number[];
  70756. /**
  70757. * Diffusion profile colors for subsurface scattering
  70758. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  70759. * See ...
  70760. * Note that you can only store up to 5 of them
  70761. */
  70762. ssDiffusionProfileColors: Color3[];
  70763. /**
  70764. * Defines the ratio real world => scene units.
  70765. * Used for subsurface scattering
  70766. */
  70767. metersPerUnit: number;
  70768. /**
  70769. * Builds a subsurface configuration object
  70770. * @param scene The scene
  70771. */
  70772. constructor();
  70773. /**
  70774. * Adds a new diffusion profile.
  70775. * Useful for more realistic subsurface scattering on diverse materials.
  70776. * @param color The color of the diffusion profile. Should be the average color of the material.
  70777. * @return The index of the diffusion profile for the material subsurface configuration
  70778. */
  70779. addDiffusionProfile(color: Color3): number;
  70780. /**
  70781. * Deletes all diffusion profiles.
  70782. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  70783. */
  70784. clearAllDiffusionProfiles(): void;
  70785. /**
  70786. * Disposes this object
  70787. */
  70788. dispose(): void;
  70789. /**
  70790. * @hidden
  70791. * https://zero-radiance.github.io/post/sampling-diffusion/
  70792. *
  70793. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  70794. * ------------------------------------------------------------------------------------
  70795. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  70796. * PDF[r, phi, s] = r * R[r, phi, s]
  70797. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  70798. * ------------------------------------------------------------------------------------
  70799. * We importance sample the color channel with the widest scattering distance.
  70800. */
  70801. getDiffusionProfileParameters(color: Color3): number;
  70802. /**
  70803. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  70804. * 'u' is the random number (the value of the CDF): [0, 1).
  70805. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  70806. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  70807. */
  70808. private _sampleBurleyDiffusionProfile;
  70809. }
  70810. }
  70811. declare module BABYLON {
  70812. /**
  70813. * Renders a pre pass of the scene
  70814. * This means every mesh in the scene will be rendered to a render target texture
  70815. * And then this texture will be composited to the rendering canvas with post processes
  70816. * It is necessary for effects like subsurface scattering or deferred shading
  70817. */
  70818. export class PrePassRenderer {
  70819. /** @hidden */
  70820. static _SceneComponentInitialization: (scene: Scene) => void;
  70821. private _scene;
  70822. private _engine;
  70823. private _isDirty;
  70824. /**
  70825. * Number of textures in the multi render target texture where the scene is directly rendered
  70826. */
  70827. readonly mrtCount: number;
  70828. /**
  70829. * The render target where the scene is directly rendered
  70830. */
  70831. prePassRT: MultiRenderTarget;
  70832. private _mrtTypes;
  70833. private _multiRenderAttachments;
  70834. private _defaultAttachments;
  70835. private _clearAttachments;
  70836. private readonly _clearColor;
  70837. /**
  70838. * Image processing post process for composition
  70839. */
  70840. imageProcessingPostProcess: ImageProcessingPostProcess;
  70841. /**
  70842. * Post process for subsurface scattering
  70843. */
  70844. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  70845. /**
  70846. * Configuration for sub surface scattering post process
  70847. */
  70848. subSurfaceConfiguration: SubSurfaceConfiguration;
  70849. private _enabled;
  70850. /**
  70851. * Indicates if the prepass is enabled
  70852. */
  70853. get enabled(): boolean;
  70854. /**
  70855. * How many samples are used for MSAA of the scene render target
  70856. */
  70857. get samples(): number;
  70858. set samples(n: number);
  70859. /**
  70860. * Instanciates a prepass renderer
  70861. * @param scene The scene
  70862. */
  70863. constructor(scene: Scene);
  70864. private _initializeAttachments;
  70865. private _createEffects;
  70866. /**
  70867. * Indicates if rendering a prepass is supported
  70868. */
  70869. get isSupported(): boolean;
  70870. /**
  70871. * Sets the proper output textures to draw in the engine.
  70872. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  70873. */
  70874. bindAttachmentsForEffect(effect: Effect): void;
  70875. /**
  70876. * @hidden
  70877. */
  70878. _beforeCameraDraw(): void;
  70879. /**
  70880. * @hidden
  70881. */
  70882. _afterCameraDraw(): void;
  70883. private _checkRTSize;
  70884. private _bindFrameBuffer;
  70885. /**
  70886. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  70887. */
  70888. clear(): void;
  70889. private _setState;
  70890. private _enable;
  70891. private _disable;
  70892. /**
  70893. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  70894. */
  70895. markAsDirty(): void;
  70896. private _update;
  70897. /**
  70898. * Disposes the prepass renderer.
  70899. */
  70900. dispose(): void;
  70901. }
  70902. }
  70903. declare module BABYLON {
  70904. interface AbstractScene {
  70905. /** @hidden (Backing field) */
  70906. _prePassRenderer: Nullable<PrePassRenderer>;
  70907. /**
  70908. * Gets or Sets the current prepass renderer associated to the scene.
  70909. */
  70910. prePassRenderer: Nullable<PrePassRenderer>;
  70911. /**
  70912. * Enables the prepass and associates it with the scene
  70913. * @returns the PrePassRenderer
  70914. */
  70915. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  70916. /**
  70917. * Disables the prepass associated with the scene
  70918. */
  70919. disablePrePassRenderer(): void;
  70920. }
  70921. /**
  70922. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70923. * in several rendering techniques.
  70924. */
  70925. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  70926. /**
  70927. * The component name helpful to identify the component in the list of scene components.
  70928. */
  70929. readonly name: string;
  70930. /**
  70931. * The scene the component belongs to.
  70932. */
  70933. scene: Scene;
  70934. /**
  70935. * Creates a new instance of the component for the given scene
  70936. * @param scene Defines the scene to register the component in
  70937. */
  70938. constructor(scene: Scene);
  70939. /**
  70940. * Registers the component in a given scene
  70941. */
  70942. register(): void;
  70943. private _beforeCameraDraw;
  70944. private _afterCameraDraw;
  70945. private _beforeClearStage;
  70946. /**
  70947. * Serializes the component data to the specified json object
  70948. * @param serializationObject The object to serialize to
  70949. */
  70950. serialize(serializationObject: any): void;
  70951. /**
  70952. * Adds all the elements from the container to the scene
  70953. * @param container the container holding the elements
  70954. */
  70955. addFromContainer(container: AbstractScene): void;
  70956. /**
  70957. * Removes all the elements in the container from the scene
  70958. * @param container contains the elements to remove
  70959. * @param dispose if the removed element should be disposed (default: false)
  70960. */
  70961. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70962. /**
  70963. * Rebuilds the elements related to this component in case of
  70964. * context lost for instance.
  70965. */
  70966. rebuild(): void;
  70967. /**
  70968. * Disposes the component and the associated ressources
  70969. */
  70970. dispose(): void;
  70971. }
  70972. }
  70973. declare module BABYLON {
  70974. /** @hidden */
  70975. export var outlinePixelShader: {
  70976. name: string;
  70977. shader: string;
  70978. };
  70979. }
  70980. declare module BABYLON {
  70981. /** @hidden */
  70982. export var outlineVertexShader: {
  70983. name: string;
  70984. shader: string;
  70985. };
  70986. }
  70987. declare module BABYLON {
  70988. interface Scene {
  70989. /** @hidden */
  70990. _outlineRenderer: OutlineRenderer;
  70991. /**
  70992. * Gets the outline renderer associated with the scene
  70993. * @returns a OutlineRenderer
  70994. */
  70995. getOutlineRenderer(): OutlineRenderer;
  70996. }
  70997. interface AbstractMesh {
  70998. /** @hidden (Backing field) */
  70999. _renderOutline: boolean;
  71000. /**
  71001. * Gets or sets a boolean indicating if the outline must be rendered as well
  71002. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71003. */
  71004. renderOutline: boolean;
  71005. /** @hidden (Backing field) */
  71006. _renderOverlay: boolean;
  71007. /**
  71008. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71009. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71010. */
  71011. renderOverlay: boolean;
  71012. }
  71013. /**
  71014. * This class is responsible to draw bothe outline/overlay of meshes.
  71015. * It should not be used directly but through the available method on mesh.
  71016. */
  71017. export class OutlineRenderer implements ISceneComponent {
  71018. /**
  71019. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71020. */
  71021. private static _StencilReference;
  71022. /**
  71023. * The name of the component. Each component must have a unique name.
  71024. */
  71025. name: string;
  71026. /**
  71027. * The scene the component belongs to.
  71028. */
  71029. scene: Scene;
  71030. /**
  71031. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71032. */
  71033. zOffset: number;
  71034. private _engine;
  71035. private _effect;
  71036. private _cachedDefines;
  71037. private _savedDepthWrite;
  71038. /**
  71039. * Instantiates a new outline renderer. (There could be only one per scene).
  71040. * @param scene Defines the scene it belongs to
  71041. */
  71042. constructor(scene: Scene);
  71043. /**
  71044. * Register the component to one instance of a scene.
  71045. */
  71046. register(): void;
  71047. /**
  71048. * Rebuilds the elements related to this component in case of
  71049. * context lost for instance.
  71050. */
  71051. rebuild(): void;
  71052. /**
  71053. * Disposes the component and the associated ressources.
  71054. */
  71055. dispose(): void;
  71056. /**
  71057. * Renders the outline in the canvas.
  71058. * @param subMesh Defines the sumesh to render
  71059. * @param batch Defines the batch of meshes in case of instances
  71060. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71061. */
  71062. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71063. /**
  71064. * Returns whether or not the outline renderer is ready for a given submesh.
  71065. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71066. * @param subMesh Defines the submesh to check readyness for
  71067. * @param useInstances Defines wheter wee are trying to render instances or not
  71068. * @returns true if ready otherwise false
  71069. */
  71070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71071. private _beforeRenderingMesh;
  71072. private _afterRenderingMesh;
  71073. }
  71074. }
  71075. declare module BABYLON {
  71076. /**
  71077. * Defines the basic options interface of a Sprite Frame Source Size.
  71078. */
  71079. export interface ISpriteJSONSpriteSourceSize {
  71080. /**
  71081. * number of the original width of the Frame
  71082. */
  71083. w: number;
  71084. /**
  71085. * number of the original height of the Frame
  71086. */
  71087. h: number;
  71088. }
  71089. /**
  71090. * Defines the basic options interface of a Sprite Frame Data.
  71091. */
  71092. export interface ISpriteJSONSpriteFrameData {
  71093. /**
  71094. * number of the x offset of the Frame
  71095. */
  71096. x: number;
  71097. /**
  71098. * number of the y offset of the Frame
  71099. */
  71100. y: number;
  71101. /**
  71102. * number of the width of the Frame
  71103. */
  71104. w: number;
  71105. /**
  71106. * number of the height of the Frame
  71107. */
  71108. h: number;
  71109. }
  71110. /**
  71111. * Defines the basic options interface of a JSON Sprite.
  71112. */
  71113. export interface ISpriteJSONSprite {
  71114. /**
  71115. * string name of the Frame
  71116. */
  71117. filename: string;
  71118. /**
  71119. * ISpriteJSONSpriteFrame basic object of the frame data
  71120. */
  71121. frame: ISpriteJSONSpriteFrameData;
  71122. /**
  71123. * boolean to flag is the frame was rotated.
  71124. */
  71125. rotated: boolean;
  71126. /**
  71127. * boolean to flag is the frame was trimmed.
  71128. */
  71129. trimmed: boolean;
  71130. /**
  71131. * ISpriteJSONSpriteFrame basic object of the source data
  71132. */
  71133. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71134. /**
  71135. * ISpriteJSONSpriteFrame basic object of the source data
  71136. */
  71137. sourceSize: ISpriteJSONSpriteSourceSize;
  71138. }
  71139. /**
  71140. * Defines the basic options interface of a JSON atlas.
  71141. */
  71142. export interface ISpriteJSONAtlas {
  71143. /**
  71144. * Array of objects that contain the frame data.
  71145. */
  71146. frames: Array<ISpriteJSONSprite>;
  71147. /**
  71148. * object basic object containing the sprite meta data.
  71149. */
  71150. meta?: object;
  71151. }
  71152. }
  71153. declare module BABYLON {
  71154. /** @hidden */
  71155. export var spriteMapPixelShader: {
  71156. name: string;
  71157. shader: string;
  71158. };
  71159. }
  71160. declare module BABYLON {
  71161. /** @hidden */
  71162. export var spriteMapVertexShader: {
  71163. name: string;
  71164. shader: string;
  71165. };
  71166. }
  71167. declare module BABYLON {
  71168. /**
  71169. * Defines the basic options interface of a SpriteMap
  71170. */
  71171. export interface ISpriteMapOptions {
  71172. /**
  71173. * Vector2 of the number of cells in the grid.
  71174. */
  71175. stageSize?: Vector2;
  71176. /**
  71177. * Vector2 of the size of the output plane in World Units.
  71178. */
  71179. outputSize?: Vector2;
  71180. /**
  71181. * Vector3 of the position of the output plane in World Units.
  71182. */
  71183. outputPosition?: Vector3;
  71184. /**
  71185. * Vector3 of the rotation of the output plane.
  71186. */
  71187. outputRotation?: Vector3;
  71188. /**
  71189. * number of layers that the system will reserve in resources.
  71190. */
  71191. layerCount?: number;
  71192. /**
  71193. * number of max animation frames a single cell will reserve in resources.
  71194. */
  71195. maxAnimationFrames?: number;
  71196. /**
  71197. * number cell index of the base tile when the system compiles.
  71198. */
  71199. baseTile?: number;
  71200. /**
  71201. * boolean flip the sprite after its been repositioned by the framing data.
  71202. */
  71203. flipU?: boolean;
  71204. /**
  71205. * Vector3 scalar of the global RGB values of the SpriteMap.
  71206. */
  71207. colorMultiply?: Vector3;
  71208. }
  71209. /**
  71210. * Defines the IDisposable interface in order to be cleanable from resources.
  71211. */
  71212. export interface ISpriteMap extends IDisposable {
  71213. /**
  71214. * String name of the SpriteMap.
  71215. */
  71216. name: string;
  71217. /**
  71218. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71219. */
  71220. atlasJSON: ISpriteJSONAtlas;
  71221. /**
  71222. * Texture of the SpriteMap.
  71223. */
  71224. spriteSheet: Texture;
  71225. /**
  71226. * The parameters to initialize the SpriteMap with.
  71227. */
  71228. options: ISpriteMapOptions;
  71229. }
  71230. /**
  71231. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71232. */
  71233. export class SpriteMap implements ISpriteMap {
  71234. /** The Name of the spriteMap */
  71235. name: string;
  71236. /** The JSON file with the frame and meta data */
  71237. atlasJSON: ISpriteJSONAtlas;
  71238. /** The systems Sprite Sheet Texture */
  71239. spriteSheet: Texture;
  71240. /** Arguments passed with the Constructor */
  71241. options: ISpriteMapOptions;
  71242. /** Public Sprite Storage array, parsed from atlasJSON */
  71243. sprites: Array<ISpriteJSONSprite>;
  71244. /** Returns the Number of Sprites in the System */
  71245. get spriteCount(): number;
  71246. /** Returns the Position of Output Plane*/
  71247. get position(): Vector3;
  71248. /** Returns the Position of Output Plane*/
  71249. set position(v: Vector3);
  71250. /** Returns the Rotation of Output Plane*/
  71251. get rotation(): Vector3;
  71252. /** Returns the Rotation of Output Plane*/
  71253. set rotation(v: Vector3);
  71254. /** Sets the AnimationMap*/
  71255. get animationMap(): RawTexture;
  71256. /** Sets the AnimationMap*/
  71257. set animationMap(v: RawTexture);
  71258. /** Scene that the SpriteMap was created in */
  71259. private _scene;
  71260. /** Texture Buffer of Float32 that holds tile frame data*/
  71261. private _frameMap;
  71262. /** Texture Buffers of Float32 that holds tileMap data*/
  71263. private _tileMaps;
  71264. /** Texture Buffer of Float32 that holds Animation Data*/
  71265. private _animationMap;
  71266. /** Custom ShaderMaterial Central to the System*/
  71267. private _material;
  71268. /** Custom ShaderMaterial Central to the System*/
  71269. private _output;
  71270. /** Systems Time Ticker*/
  71271. private _time;
  71272. /**
  71273. * Creates a new SpriteMap
  71274. * @param name defines the SpriteMaps Name
  71275. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71276. * @param spriteSheet is the Texture that the Sprites are on.
  71277. * @param options a basic deployment configuration
  71278. * @param scene The Scene that the map is deployed on
  71279. */
  71280. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71281. /**
  71282. * Returns tileID location
  71283. * @returns Vector2 the cell position ID
  71284. */
  71285. getTileID(): Vector2;
  71286. /**
  71287. * Gets the UV location of the mouse over the SpriteMap.
  71288. * @returns Vector2 the UV position of the mouse interaction
  71289. */
  71290. getMousePosition(): Vector2;
  71291. /**
  71292. * Creates the "frame" texture Buffer
  71293. * -------------------------------------
  71294. * Structure of frames
  71295. * "filename": "Falling-Water-2.png",
  71296. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71297. * "rotated": true,
  71298. * "trimmed": true,
  71299. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71300. * "sourceSize": {"w":32,"h":32}
  71301. * @returns RawTexture of the frameMap
  71302. */
  71303. private _createFrameBuffer;
  71304. /**
  71305. * Creates the tileMap texture Buffer
  71306. * @param buffer normally and array of numbers, or a false to generate from scratch
  71307. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71308. * @returns RawTexture of the tileMap
  71309. */
  71310. private _createTileBuffer;
  71311. /**
  71312. * Modifies the data of the tileMaps
  71313. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71314. * @param pos is the iVector2 Coordinates of the Tile
  71315. * @param tile The SpriteIndex of the new Tile
  71316. */
  71317. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71318. /**
  71319. * Creates the animationMap texture Buffer
  71320. * @param buffer normally and array of numbers, or a false to generate from scratch
  71321. * @returns RawTexture of the animationMap
  71322. */
  71323. private _createTileAnimationBuffer;
  71324. /**
  71325. * Modifies the data of the animationMap
  71326. * @param cellID is the Index of the Sprite
  71327. * @param _frame is the target Animation frame
  71328. * @param toCell is the Target Index of the next frame of the animation
  71329. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71330. * @param speed is a global scalar of the time variable on the map.
  71331. */
  71332. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71333. /**
  71334. * Exports the .tilemaps file
  71335. */
  71336. saveTileMaps(): void;
  71337. /**
  71338. * Imports the .tilemaps file
  71339. * @param url of the .tilemaps file
  71340. */
  71341. loadTileMaps(url: string): void;
  71342. /**
  71343. * Release associated resources
  71344. */
  71345. dispose(): void;
  71346. }
  71347. }
  71348. declare module BABYLON {
  71349. /**
  71350. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71351. * @see https://doc.babylonjs.com/babylon101/sprites
  71352. */
  71353. export class SpritePackedManager extends SpriteManager {
  71354. /** defines the packed manager's name */
  71355. name: string;
  71356. /**
  71357. * Creates a new sprite manager from a packed sprite sheet
  71358. * @param name defines the manager's name
  71359. * @param imgUrl defines the sprite sheet url
  71360. * @param capacity defines the maximum allowed number of sprites
  71361. * @param scene defines the hosting scene
  71362. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71363. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71364. * @param samplingMode defines the smapling mode to use with spritesheet
  71365. * @param fromPacked set to true; do not alter
  71366. */
  71367. constructor(
  71368. /** defines the packed manager's name */
  71369. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71370. }
  71371. }
  71372. declare module BABYLON {
  71373. /**
  71374. * Defines the list of states available for a task inside a AssetsManager
  71375. */
  71376. export enum AssetTaskState {
  71377. /**
  71378. * Initialization
  71379. */
  71380. INIT = 0,
  71381. /**
  71382. * Running
  71383. */
  71384. RUNNING = 1,
  71385. /**
  71386. * Done
  71387. */
  71388. DONE = 2,
  71389. /**
  71390. * Error
  71391. */
  71392. ERROR = 3
  71393. }
  71394. /**
  71395. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71396. */
  71397. export abstract class AbstractAssetTask {
  71398. /**
  71399. * Task name
  71400. */ name: string;
  71401. /**
  71402. * Callback called when the task is successful
  71403. */
  71404. onSuccess: (task: any) => void;
  71405. /**
  71406. * Callback called when the task is not successful
  71407. */
  71408. onError: (task: any, message?: string, exception?: any) => void;
  71409. /**
  71410. * Creates a new AssetsManager
  71411. * @param name defines the name of the task
  71412. */
  71413. constructor(
  71414. /**
  71415. * Task name
  71416. */ name: string);
  71417. private _isCompleted;
  71418. private _taskState;
  71419. private _errorObject;
  71420. /**
  71421. * Get if the task is completed
  71422. */
  71423. get isCompleted(): boolean;
  71424. /**
  71425. * Gets the current state of the task
  71426. */
  71427. get taskState(): AssetTaskState;
  71428. /**
  71429. * Gets the current error object (if task is in error)
  71430. */
  71431. get errorObject(): {
  71432. message?: string;
  71433. exception?: any;
  71434. };
  71435. /**
  71436. * Internal only
  71437. * @hidden
  71438. */
  71439. _setErrorObject(message?: string, exception?: any): void;
  71440. /**
  71441. * Execute the current task
  71442. * @param scene defines the scene where you want your assets to be loaded
  71443. * @param onSuccess is a callback called when the task is successfully executed
  71444. * @param onError is a callback called if an error occurs
  71445. */
  71446. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71447. /**
  71448. * Execute the current task
  71449. * @param scene defines the scene where you want your assets to be loaded
  71450. * @param onSuccess is a callback called when the task is successfully executed
  71451. * @param onError is a callback called if an error occurs
  71452. */
  71453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71454. /**
  71455. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71456. * This can be used with failed tasks that have the reason for failure fixed.
  71457. */
  71458. reset(): void;
  71459. private onErrorCallback;
  71460. private onDoneCallback;
  71461. }
  71462. /**
  71463. * Define the interface used by progress events raised during assets loading
  71464. */
  71465. export interface IAssetsProgressEvent {
  71466. /**
  71467. * Defines the number of remaining tasks to process
  71468. */
  71469. remainingCount: number;
  71470. /**
  71471. * Defines the total number of tasks
  71472. */
  71473. totalCount: number;
  71474. /**
  71475. * Defines the task that was just processed
  71476. */
  71477. task: AbstractAssetTask;
  71478. }
  71479. /**
  71480. * Class used to share progress information about assets loading
  71481. */
  71482. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71483. /**
  71484. * Defines the number of remaining tasks to process
  71485. */
  71486. remainingCount: number;
  71487. /**
  71488. * Defines the total number of tasks
  71489. */
  71490. totalCount: number;
  71491. /**
  71492. * Defines the task that was just processed
  71493. */
  71494. task: AbstractAssetTask;
  71495. /**
  71496. * Creates a AssetsProgressEvent
  71497. * @param remainingCount defines the number of remaining tasks to process
  71498. * @param totalCount defines the total number of tasks
  71499. * @param task defines the task that was just processed
  71500. */
  71501. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71502. }
  71503. /**
  71504. * Define a task used by AssetsManager to load meshes
  71505. */
  71506. export class MeshAssetTask extends AbstractAssetTask {
  71507. /**
  71508. * Defines the name of the task
  71509. */
  71510. name: string;
  71511. /**
  71512. * Defines the list of mesh's names you want to load
  71513. */
  71514. meshesNames: any;
  71515. /**
  71516. * Defines the root url to use as a base to load your meshes and associated resources
  71517. */
  71518. rootUrl: string;
  71519. /**
  71520. * Defines the filename or File of the scene to load from
  71521. */
  71522. sceneFilename: string | File;
  71523. /**
  71524. * Gets the list of loaded meshes
  71525. */
  71526. loadedMeshes: Array<AbstractMesh>;
  71527. /**
  71528. * Gets the list of loaded particle systems
  71529. */
  71530. loadedParticleSystems: Array<IParticleSystem>;
  71531. /**
  71532. * Gets the list of loaded skeletons
  71533. */
  71534. loadedSkeletons: Array<Skeleton>;
  71535. /**
  71536. * Gets the list of loaded animation groups
  71537. */
  71538. loadedAnimationGroups: Array<AnimationGroup>;
  71539. /**
  71540. * Callback called when the task is successful
  71541. */
  71542. onSuccess: (task: MeshAssetTask) => void;
  71543. /**
  71544. * Callback called when the task is successful
  71545. */
  71546. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71547. /**
  71548. * Creates a new MeshAssetTask
  71549. * @param name defines the name of the task
  71550. * @param meshesNames defines the list of mesh's names you want to load
  71551. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71552. * @param sceneFilename defines the filename or File of the scene to load from
  71553. */
  71554. constructor(
  71555. /**
  71556. * Defines the name of the task
  71557. */
  71558. name: string,
  71559. /**
  71560. * Defines the list of mesh's names you want to load
  71561. */
  71562. meshesNames: any,
  71563. /**
  71564. * Defines the root url to use as a base to load your meshes and associated resources
  71565. */
  71566. rootUrl: string,
  71567. /**
  71568. * Defines the filename or File of the scene to load from
  71569. */
  71570. sceneFilename: string | File);
  71571. /**
  71572. * Execute the current task
  71573. * @param scene defines the scene where you want your assets to be loaded
  71574. * @param onSuccess is a callback called when the task is successfully executed
  71575. * @param onError is a callback called if an error occurs
  71576. */
  71577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71578. }
  71579. /**
  71580. * Define a task used by AssetsManager to load text content
  71581. */
  71582. export class TextFileAssetTask extends AbstractAssetTask {
  71583. /**
  71584. * Defines the name of the task
  71585. */
  71586. name: string;
  71587. /**
  71588. * Defines the location of the file to load
  71589. */
  71590. url: string;
  71591. /**
  71592. * Gets the loaded text string
  71593. */
  71594. text: string;
  71595. /**
  71596. * Callback called when the task is successful
  71597. */
  71598. onSuccess: (task: TextFileAssetTask) => void;
  71599. /**
  71600. * Callback called when the task is successful
  71601. */
  71602. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71603. /**
  71604. * Creates a new TextFileAssetTask object
  71605. * @param name defines the name of the task
  71606. * @param url defines the location of the file to load
  71607. */
  71608. constructor(
  71609. /**
  71610. * Defines the name of the task
  71611. */
  71612. name: string,
  71613. /**
  71614. * Defines the location of the file to load
  71615. */
  71616. url: string);
  71617. /**
  71618. * Execute the current task
  71619. * @param scene defines the scene where you want your assets to be loaded
  71620. * @param onSuccess is a callback called when the task is successfully executed
  71621. * @param onError is a callback called if an error occurs
  71622. */
  71623. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71624. }
  71625. /**
  71626. * Define a task used by AssetsManager to load binary data
  71627. */
  71628. export class BinaryFileAssetTask extends AbstractAssetTask {
  71629. /**
  71630. * Defines the name of the task
  71631. */
  71632. name: string;
  71633. /**
  71634. * Defines the location of the file to load
  71635. */
  71636. url: string;
  71637. /**
  71638. * Gets the lodaded data (as an array buffer)
  71639. */
  71640. data: ArrayBuffer;
  71641. /**
  71642. * Callback called when the task is successful
  71643. */
  71644. onSuccess: (task: BinaryFileAssetTask) => void;
  71645. /**
  71646. * Callback called when the task is successful
  71647. */
  71648. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71649. /**
  71650. * Creates a new BinaryFileAssetTask object
  71651. * @param name defines the name of the new task
  71652. * @param url defines the location of the file to load
  71653. */
  71654. constructor(
  71655. /**
  71656. * Defines the name of the task
  71657. */
  71658. name: string,
  71659. /**
  71660. * Defines the location of the file to load
  71661. */
  71662. url: string);
  71663. /**
  71664. * Execute the current task
  71665. * @param scene defines the scene where you want your assets to be loaded
  71666. * @param onSuccess is a callback called when the task is successfully executed
  71667. * @param onError is a callback called if an error occurs
  71668. */
  71669. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71670. }
  71671. /**
  71672. * Define a task used by AssetsManager to load images
  71673. */
  71674. export class ImageAssetTask extends AbstractAssetTask {
  71675. /**
  71676. * Defines the name of the task
  71677. */
  71678. name: string;
  71679. /**
  71680. * Defines the location of the image to load
  71681. */
  71682. url: string;
  71683. /**
  71684. * Gets the loaded images
  71685. */
  71686. image: HTMLImageElement;
  71687. /**
  71688. * Callback called when the task is successful
  71689. */
  71690. onSuccess: (task: ImageAssetTask) => void;
  71691. /**
  71692. * Callback called when the task is successful
  71693. */
  71694. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71695. /**
  71696. * Creates a new ImageAssetTask
  71697. * @param name defines the name of the task
  71698. * @param url defines the location of the image to load
  71699. */
  71700. constructor(
  71701. /**
  71702. * Defines the name of the task
  71703. */
  71704. name: string,
  71705. /**
  71706. * Defines the location of the image to load
  71707. */
  71708. url: string);
  71709. /**
  71710. * Execute the current task
  71711. * @param scene defines the scene where you want your assets to be loaded
  71712. * @param onSuccess is a callback called when the task is successfully executed
  71713. * @param onError is a callback called if an error occurs
  71714. */
  71715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71716. }
  71717. /**
  71718. * Defines the interface used by texture loading tasks
  71719. */
  71720. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71721. /**
  71722. * Gets the loaded texture
  71723. */
  71724. texture: TEX;
  71725. }
  71726. /**
  71727. * Define a task used by AssetsManager to load 2D textures
  71728. */
  71729. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71730. /**
  71731. * Defines the name of the task
  71732. */
  71733. name: string;
  71734. /**
  71735. * Defines the location of the file to load
  71736. */
  71737. url: string;
  71738. /**
  71739. * Defines if mipmap should not be generated (default is false)
  71740. */
  71741. noMipmap?: boolean | undefined;
  71742. /**
  71743. * Defines if texture must be inverted on Y axis (default is true)
  71744. */
  71745. invertY: boolean;
  71746. /**
  71747. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71748. */
  71749. samplingMode: number;
  71750. /**
  71751. * Gets the loaded texture
  71752. */
  71753. texture: Texture;
  71754. /**
  71755. * Callback called when the task is successful
  71756. */
  71757. onSuccess: (task: TextureAssetTask) => void;
  71758. /**
  71759. * Callback called when the task is successful
  71760. */
  71761. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71762. /**
  71763. * Creates a new TextureAssetTask object
  71764. * @param name defines the name of the task
  71765. * @param url defines the location of the file to load
  71766. * @param noMipmap defines if mipmap should not be generated (default is false)
  71767. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71768. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71769. */
  71770. constructor(
  71771. /**
  71772. * Defines the name of the task
  71773. */
  71774. name: string,
  71775. /**
  71776. * Defines the location of the file to load
  71777. */
  71778. url: string,
  71779. /**
  71780. * Defines if mipmap should not be generated (default is false)
  71781. */
  71782. noMipmap?: boolean | undefined,
  71783. /**
  71784. * Defines if texture must be inverted on Y axis (default is true)
  71785. */
  71786. invertY?: boolean,
  71787. /**
  71788. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71789. */
  71790. samplingMode?: number);
  71791. /**
  71792. * Execute the current task
  71793. * @param scene defines the scene where you want your assets to be loaded
  71794. * @param onSuccess is a callback called when the task is successfully executed
  71795. * @param onError is a callback called if an error occurs
  71796. */
  71797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71798. }
  71799. /**
  71800. * Define a task used by AssetsManager to load cube textures
  71801. */
  71802. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71803. /**
  71804. * Defines the name of the task
  71805. */
  71806. name: string;
  71807. /**
  71808. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71809. */
  71810. url: string;
  71811. /**
  71812. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71813. */
  71814. extensions?: string[] | undefined;
  71815. /**
  71816. * Defines if mipmaps should not be generated (default is false)
  71817. */
  71818. noMipmap?: boolean | undefined;
  71819. /**
  71820. * Defines the explicit list of files (undefined by default)
  71821. */
  71822. files?: string[] | undefined;
  71823. /**
  71824. * Gets the loaded texture
  71825. */
  71826. texture: CubeTexture;
  71827. /**
  71828. * Callback called when the task is successful
  71829. */
  71830. onSuccess: (task: CubeTextureAssetTask) => void;
  71831. /**
  71832. * Callback called when the task is successful
  71833. */
  71834. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71835. /**
  71836. * Creates a new CubeTextureAssetTask
  71837. * @param name defines the name of the task
  71838. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71839. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71840. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71841. * @param files defines the explicit list of files (undefined by default)
  71842. */
  71843. constructor(
  71844. /**
  71845. * Defines the name of the task
  71846. */
  71847. name: string,
  71848. /**
  71849. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71850. */
  71851. url: string,
  71852. /**
  71853. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71854. */
  71855. extensions?: string[] | undefined,
  71856. /**
  71857. * Defines if mipmaps should not be generated (default is false)
  71858. */
  71859. noMipmap?: boolean | undefined,
  71860. /**
  71861. * Defines the explicit list of files (undefined by default)
  71862. */
  71863. files?: string[] | undefined);
  71864. /**
  71865. * Execute the current task
  71866. * @param scene defines the scene where you want your assets to be loaded
  71867. * @param onSuccess is a callback called when the task is successfully executed
  71868. * @param onError is a callback called if an error occurs
  71869. */
  71870. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71871. }
  71872. /**
  71873. * Define a task used by AssetsManager to load HDR cube textures
  71874. */
  71875. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71876. /**
  71877. * Defines the name of the task
  71878. */
  71879. name: string;
  71880. /**
  71881. * Defines the location of the file to load
  71882. */
  71883. url: string;
  71884. /**
  71885. * Defines the desired size (the more it increases the longer the generation will be)
  71886. */
  71887. size: number;
  71888. /**
  71889. * Defines if mipmaps should not be generated (default is false)
  71890. */
  71891. noMipmap: boolean;
  71892. /**
  71893. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71894. */
  71895. generateHarmonics: boolean;
  71896. /**
  71897. * 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)
  71898. */
  71899. gammaSpace: boolean;
  71900. /**
  71901. * Internal Use Only
  71902. */
  71903. reserved: boolean;
  71904. /**
  71905. * Gets the loaded texture
  71906. */
  71907. texture: HDRCubeTexture;
  71908. /**
  71909. * Callback called when the task is successful
  71910. */
  71911. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71912. /**
  71913. * Callback called when the task is successful
  71914. */
  71915. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71916. /**
  71917. * Creates a new HDRCubeTextureAssetTask object
  71918. * @param name defines the name of the task
  71919. * @param url defines the location of the file to load
  71920. * @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.
  71921. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71922. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71923. * @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)
  71924. * @param reserved Internal use only
  71925. */
  71926. constructor(
  71927. /**
  71928. * Defines the name of the task
  71929. */
  71930. name: string,
  71931. /**
  71932. * Defines the location of the file to load
  71933. */
  71934. url: string,
  71935. /**
  71936. * Defines the desired size (the more it increases the longer the generation will be)
  71937. */
  71938. size: number,
  71939. /**
  71940. * Defines if mipmaps should not be generated (default is false)
  71941. */
  71942. noMipmap?: boolean,
  71943. /**
  71944. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71945. */
  71946. generateHarmonics?: boolean,
  71947. /**
  71948. * 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)
  71949. */
  71950. gammaSpace?: boolean,
  71951. /**
  71952. * Internal Use Only
  71953. */
  71954. reserved?: boolean);
  71955. /**
  71956. * Execute the current task
  71957. * @param scene defines the scene where you want your assets to be loaded
  71958. * @param onSuccess is a callback called when the task is successfully executed
  71959. * @param onError is a callback called if an error occurs
  71960. */
  71961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71962. }
  71963. /**
  71964. * Define a task used by AssetsManager to load Equirectangular cube textures
  71965. */
  71966. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71967. /**
  71968. * Defines the name of the task
  71969. */
  71970. name: string;
  71971. /**
  71972. * Defines the location of the file to load
  71973. */
  71974. url: string;
  71975. /**
  71976. * Defines the desired size (the more it increases the longer the generation will be)
  71977. */
  71978. size: number;
  71979. /**
  71980. * Defines if mipmaps should not be generated (default is false)
  71981. */
  71982. noMipmap: boolean;
  71983. /**
  71984. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71985. * but the standard material would require them in Gamma space) (default is true)
  71986. */
  71987. gammaSpace: boolean;
  71988. /**
  71989. * Gets the loaded texture
  71990. */
  71991. texture: EquiRectangularCubeTexture;
  71992. /**
  71993. * Callback called when the task is successful
  71994. */
  71995. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71996. /**
  71997. * Callback called when the task is successful
  71998. */
  71999. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72000. /**
  72001. * Creates a new EquiRectangularCubeTextureAssetTask object
  72002. * @param name defines the name of the task
  72003. * @param url defines the location of the file to load
  72004. * @param size defines the desired size (the more it increases the longer the generation will be)
  72005. * If the size is omitted this implies you are using a preprocessed cubemap.
  72006. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72007. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72008. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72009. * (default is true)
  72010. */
  72011. constructor(
  72012. /**
  72013. * Defines the name of the task
  72014. */
  72015. name: string,
  72016. /**
  72017. * Defines the location of the file to load
  72018. */
  72019. url: string,
  72020. /**
  72021. * Defines the desired size (the more it increases the longer the generation will be)
  72022. */
  72023. size: number,
  72024. /**
  72025. * Defines if mipmaps should not be generated (default is false)
  72026. */
  72027. noMipmap?: boolean,
  72028. /**
  72029. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72030. * but the standard material would require them in Gamma space) (default is true)
  72031. */
  72032. gammaSpace?: boolean);
  72033. /**
  72034. * Execute the current task
  72035. * @param scene defines the scene where you want your assets to be loaded
  72036. * @param onSuccess is a callback called when the task is successfully executed
  72037. * @param onError is a callback called if an error occurs
  72038. */
  72039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72040. }
  72041. /**
  72042. * This class can be used to easily import assets into a scene
  72043. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72044. */
  72045. export class AssetsManager {
  72046. private _scene;
  72047. private _isLoading;
  72048. protected _tasks: AbstractAssetTask[];
  72049. protected _waitingTasksCount: number;
  72050. protected _totalTasksCount: number;
  72051. /**
  72052. * Callback called when all tasks are processed
  72053. */
  72054. onFinish: (tasks: AbstractAssetTask[]) => void;
  72055. /**
  72056. * Callback called when a task is successful
  72057. */
  72058. onTaskSuccess: (task: AbstractAssetTask) => void;
  72059. /**
  72060. * Callback called when a task had an error
  72061. */
  72062. onTaskError: (task: AbstractAssetTask) => void;
  72063. /**
  72064. * Callback called when a task is done (whatever the result is)
  72065. */
  72066. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72067. /**
  72068. * Observable called when all tasks are processed
  72069. */
  72070. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72071. /**
  72072. * Observable called when a task had an error
  72073. */
  72074. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72075. /**
  72076. * Observable called when all tasks were executed
  72077. */
  72078. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72079. /**
  72080. * Observable called when a task is done (whatever the result is)
  72081. */
  72082. onProgressObservable: Observable<IAssetsProgressEvent>;
  72083. /**
  72084. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72085. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72086. */
  72087. useDefaultLoadingScreen: boolean;
  72088. /**
  72089. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72090. * when all assets have been downloaded.
  72091. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72092. */
  72093. autoHideLoadingUI: boolean;
  72094. /**
  72095. * Creates a new AssetsManager
  72096. * @param scene defines the scene to work on
  72097. */
  72098. constructor(scene: Scene);
  72099. /**
  72100. * Add a MeshAssetTask to the list of active tasks
  72101. * @param taskName defines the name of the new task
  72102. * @param meshesNames defines the name of meshes to load
  72103. * @param rootUrl defines the root url to use to locate files
  72104. * @param sceneFilename defines the filename of the scene file
  72105. * @returns a new MeshAssetTask object
  72106. */
  72107. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72108. /**
  72109. * Add a TextFileAssetTask to the list of active tasks
  72110. * @param taskName defines the name of the new task
  72111. * @param url defines the url of the file to load
  72112. * @returns a new TextFileAssetTask object
  72113. */
  72114. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72115. /**
  72116. * Add a BinaryFileAssetTask to the list of active tasks
  72117. * @param taskName defines the name of the new task
  72118. * @param url defines the url of the file to load
  72119. * @returns a new BinaryFileAssetTask object
  72120. */
  72121. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72122. /**
  72123. * Add a ImageAssetTask to the list of active tasks
  72124. * @param taskName defines the name of the new task
  72125. * @param url defines the url of the file to load
  72126. * @returns a new ImageAssetTask object
  72127. */
  72128. addImageTask(taskName: string, url: string): ImageAssetTask;
  72129. /**
  72130. * Add a TextureAssetTask to the list of active tasks
  72131. * @param taskName defines the name of the new task
  72132. * @param url defines the url of the file to load
  72133. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72134. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72135. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72136. * @returns a new TextureAssetTask object
  72137. */
  72138. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72139. /**
  72140. * Add a CubeTextureAssetTask to the list of active tasks
  72141. * @param taskName defines the name of the new task
  72142. * @param url defines the url of the file to load
  72143. * @param extensions defines the extension to use to load the cube map (can be null)
  72144. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72145. * @param files defines the list of files to load (can be null)
  72146. * @returns a new CubeTextureAssetTask object
  72147. */
  72148. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72149. /**
  72150. *
  72151. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72152. * @param taskName defines the name of the new task
  72153. * @param url defines the url of the file to load
  72154. * @param size defines the size you want for the cubemap (can be null)
  72155. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72156. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72157. * @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)
  72158. * @param reserved Internal use only
  72159. * @returns a new HDRCubeTextureAssetTask object
  72160. */
  72161. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72162. /**
  72163. *
  72164. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72165. * @param taskName defines the name of the new task
  72166. * @param url defines the url of the file to load
  72167. * @param size defines the size you want for the cubemap (can be null)
  72168. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72169. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72170. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72171. * @returns a new EquiRectangularCubeTextureAssetTask object
  72172. */
  72173. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72174. /**
  72175. * Remove a task from the assets manager.
  72176. * @param task the task to remove
  72177. */
  72178. removeTask(task: AbstractAssetTask): void;
  72179. private _decreaseWaitingTasksCount;
  72180. private _runTask;
  72181. /**
  72182. * Reset the AssetsManager and remove all tasks
  72183. * @return the current instance of the AssetsManager
  72184. */
  72185. reset(): AssetsManager;
  72186. /**
  72187. * Start the loading process
  72188. * @return the current instance of the AssetsManager
  72189. */
  72190. load(): AssetsManager;
  72191. /**
  72192. * Start the loading process as an async operation
  72193. * @return a promise returning the list of failed tasks
  72194. */
  72195. loadAsync(): Promise<void>;
  72196. }
  72197. }
  72198. declare module BABYLON {
  72199. /**
  72200. * Wrapper class for promise with external resolve and reject.
  72201. */
  72202. export class Deferred<T> {
  72203. /**
  72204. * The promise associated with this deferred object.
  72205. */
  72206. readonly promise: Promise<T>;
  72207. private _resolve;
  72208. private _reject;
  72209. /**
  72210. * The resolve method of the promise associated with this deferred object.
  72211. */
  72212. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72213. /**
  72214. * The reject method of the promise associated with this deferred object.
  72215. */
  72216. get reject(): (reason?: any) => void;
  72217. /**
  72218. * Constructor for this deferred object.
  72219. */
  72220. constructor();
  72221. }
  72222. }
  72223. declare module BABYLON {
  72224. /**
  72225. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72226. */
  72227. export class MeshExploder {
  72228. private _centerMesh;
  72229. private _meshes;
  72230. private _meshesOrigins;
  72231. private _toCenterVectors;
  72232. private _scaledDirection;
  72233. private _newPosition;
  72234. private _centerPosition;
  72235. /**
  72236. * Explodes meshes from a center mesh.
  72237. * @param meshes The meshes to explode.
  72238. * @param centerMesh The mesh to be center of explosion.
  72239. */
  72240. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72241. private _setCenterMesh;
  72242. /**
  72243. * Get class name
  72244. * @returns "MeshExploder"
  72245. */
  72246. getClassName(): string;
  72247. /**
  72248. * "Exploded meshes"
  72249. * @returns Array of meshes with the centerMesh at index 0.
  72250. */
  72251. getMeshes(): Array<Mesh>;
  72252. /**
  72253. * Explodes meshes giving a specific direction
  72254. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72255. */
  72256. explode(direction?: number): void;
  72257. }
  72258. }
  72259. declare module BABYLON {
  72260. /**
  72261. * Class used to help managing file picking and drag'n'drop
  72262. */
  72263. export class FilesInput {
  72264. /**
  72265. * List of files ready to be loaded
  72266. */
  72267. static get FilesToLoad(): {
  72268. [key: string]: File;
  72269. };
  72270. /**
  72271. * Callback called when a file is processed
  72272. */
  72273. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72274. private _engine;
  72275. private _currentScene;
  72276. private _sceneLoadedCallback;
  72277. private _progressCallback;
  72278. private _additionalRenderLoopLogicCallback;
  72279. private _textureLoadingCallback;
  72280. private _startingProcessingFilesCallback;
  72281. private _onReloadCallback;
  72282. private _errorCallback;
  72283. private _elementToMonitor;
  72284. private _sceneFileToLoad;
  72285. private _filesToLoad;
  72286. /**
  72287. * Creates a new FilesInput
  72288. * @param engine defines the rendering engine
  72289. * @param scene defines the hosting scene
  72290. * @param sceneLoadedCallback callback called when scene is loaded
  72291. * @param progressCallback callback called to track progress
  72292. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72293. * @param textureLoadingCallback callback called when a texture is loading
  72294. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72295. * @param onReloadCallback callback called when a reload is requested
  72296. * @param errorCallback callback call if an error occurs
  72297. */
  72298. 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>);
  72299. private _dragEnterHandler;
  72300. private _dragOverHandler;
  72301. private _dropHandler;
  72302. /**
  72303. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72304. * @param elementToMonitor defines the DOM element to track
  72305. */
  72306. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72307. /** Gets the current list of files to load */
  72308. get filesToLoad(): File[];
  72309. /**
  72310. * Release all associated resources
  72311. */
  72312. dispose(): void;
  72313. private renderFunction;
  72314. private drag;
  72315. private drop;
  72316. private _traverseFolder;
  72317. private _processFiles;
  72318. /**
  72319. * Load files from a drop event
  72320. * @param event defines the drop event to use as source
  72321. */
  72322. loadFiles(event: any): void;
  72323. private _processReload;
  72324. /**
  72325. * Reload the current scene from the loaded files
  72326. */
  72327. reload(): void;
  72328. }
  72329. }
  72330. declare module BABYLON {
  72331. /**
  72332. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72333. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72334. */
  72335. export class SceneOptimization {
  72336. /**
  72337. * Defines the priority of this optimization (0 by default which means first in the list)
  72338. */
  72339. priority: number;
  72340. /**
  72341. * Gets a string describing the action executed by the current optimization
  72342. * @returns description string
  72343. */
  72344. getDescription(): string;
  72345. /**
  72346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72347. * @param scene defines the current scene where to apply this optimization
  72348. * @param optimizer defines the current optimizer
  72349. * @returns true if everything that can be done was applied
  72350. */
  72351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72352. /**
  72353. * Creates the SceneOptimization object
  72354. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72355. * @param desc defines the description associated with the optimization
  72356. */
  72357. constructor(
  72358. /**
  72359. * Defines the priority of this optimization (0 by default which means first in the list)
  72360. */
  72361. priority?: number);
  72362. }
  72363. /**
  72364. * Defines an optimization used to reduce the size of render target textures
  72365. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72366. */
  72367. export class TextureOptimization extends SceneOptimization {
  72368. /**
  72369. * Defines the priority of this optimization (0 by default which means first in the list)
  72370. */
  72371. priority: number;
  72372. /**
  72373. * 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
  72374. */
  72375. maximumSize: number;
  72376. /**
  72377. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72378. */
  72379. step: number;
  72380. /**
  72381. * Gets a string describing the action executed by the current optimization
  72382. * @returns description string
  72383. */
  72384. getDescription(): string;
  72385. /**
  72386. * Creates the TextureOptimization object
  72387. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72388. * @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
  72389. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72390. */
  72391. constructor(
  72392. /**
  72393. * Defines the priority of this optimization (0 by default which means first in the list)
  72394. */
  72395. priority?: number,
  72396. /**
  72397. * 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
  72398. */
  72399. maximumSize?: number,
  72400. /**
  72401. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72402. */
  72403. step?: number);
  72404. /**
  72405. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72406. * @param scene defines the current scene where to apply this optimization
  72407. * @param optimizer defines the current optimizer
  72408. * @returns true if everything that can be done was applied
  72409. */
  72410. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72411. }
  72412. /**
  72413. * Defines an optimization used to increase or decrease the rendering resolution
  72414. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72415. */
  72416. export class HardwareScalingOptimization extends SceneOptimization {
  72417. /**
  72418. * Defines the priority of this optimization (0 by default which means first in the list)
  72419. */
  72420. priority: number;
  72421. /**
  72422. * Defines the maximum scale to use (2 by default)
  72423. */
  72424. maximumScale: number;
  72425. /**
  72426. * Defines the step to use between two passes (0.5 by default)
  72427. */
  72428. step: number;
  72429. private _currentScale;
  72430. private _directionOffset;
  72431. /**
  72432. * Gets a string describing the action executed by the current optimization
  72433. * @return description string
  72434. */
  72435. getDescription(): string;
  72436. /**
  72437. * Creates the HardwareScalingOptimization object
  72438. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72439. * @param maximumScale defines the maximum scale to use (2 by default)
  72440. * @param step defines the step to use between two passes (0.5 by default)
  72441. */
  72442. constructor(
  72443. /**
  72444. * Defines the priority of this optimization (0 by default which means first in the list)
  72445. */
  72446. priority?: number,
  72447. /**
  72448. * Defines the maximum scale to use (2 by default)
  72449. */
  72450. maximumScale?: number,
  72451. /**
  72452. * Defines the step to use between two passes (0.5 by default)
  72453. */
  72454. step?: number);
  72455. /**
  72456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72457. * @param scene defines the current scene where to apply this optimization
  72458. * @param optimizer defines the current optimizer
  72459. * @returns true if everything that can be done was applied
  72460. */
  72461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72462. }
  72463. /**
  72464. * Defines an optimization used to remove shadows
  72465. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72466. */
  72467. export class ShadowsOptimization extends SceneOptimization {
  72468. /**
  72469. * Gets a string describing the action executed by the current optimization
  72470. * @return description string
  72471. */
  72472. getDescription(): string;
  72473. /**
  72474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72475. * @param scene defines the current scene where to apply this optimization
  72476. * @param optimizer defines the current optimizer
  72477. * @returns true if everything that can be done was applied
  72478. */
  72479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72480. }
  72481. /**
  72482. * Defines an optimization used to turn post-processes off
  72483. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72484. */
  72485. export class PostProcessesOptimization extends SceneOptimization {
  72486. /**
  72487. * Gets a string describing the action executed by the current optimization
  72488. * @return description string
  72489. */
  72490. getDescription(): string;
  72491. /**
  72492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72493. * @param scene defines the current scene where to apply this optimization
  72494. * @param optimizer defines the current optimizer
  72495. * @returns true if everything that can be done was applied
  72496. */
  72497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72498. }
  72499. /**
  72500. * Defines an optimization used to turn lens flares off
  72501. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72502. */
  72503. export class LensFlaresOptimization extends SceneOptimization {
  72504. /**
  72505. * Gets a string describing the action executed by the current optimization
  72506. * @return description string
  72507. */
  72508. getDescription(): string;
  72509. /**
  72510. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72511. * @param scene defines the current scene where to apply this optimization
  72512. * @param optimizer defines the current optimizer
  72513. * @returns true if everything that can be done was applied
  72514. */
  72515. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72516. }
  72517. /**
  72518. * Defines an optimization based on user defined callback.
  72519. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72520. */
  72521. export class CustomOptimization extends SceneOptimization {
  72522. /**
  72523. * Callback called to apply the custom optimization.
  72524. */
  72525. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72526. /**
  72527. * Callback called to get custom description
  72528. */
  72529. onGetDescription: () => string;
  72530. /**
  72531. * Gets a string describing the action executed by the current optimization
  72532. * @returns description string
  72533. */
  72534. getDescription(): string;
  72535. /**
  72536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72537. * @param scene defines the current scene where to apply this optimization
  72538. * @param optimizer defines the current optimizer
  72539. * @returns true if everything that can be done was applied
  72540. */
  72541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72542. }
  72543. /**
  72544. * Defines an optimization used to turn particles off
  72545. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72546. */
  72547. export class ParticlesOptimization extends SceneOptimization {
  72548. /**
  72549. * Gets a string describing the action executed by the current optimization
  72550. * @return description string
  72551. */
  72552. getDescription(): string;
  72553. /**
  72554. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72555. * @param scene defines the current scene where to apply this optimization
  72556. * @param optimizer defines the current optimizer
  72557. * @returns true if everything that can be done was applied
  72558. */
  72559. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72560. }
  72561. /**
  72562. * Defines an optimization used to turn render targets off
  72563. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72564. */
  72565. export class RenderTargetsOptimization extends SceneOptimization {
  72566. /**
  72567. * Gets a string describing the action executed by the current optimization
  72568. * @return description string
  72569. */
  72570. getDescription(): string;
  72571. /**
  72572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72573. * @param scene defines the current scene where to apply this optimization
  72574. * @param optimizer defines the current optimizer
  72575. * @returns true if everything that can be done was applied
  72576. */
  72577. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72578. }
  72579. /**
  72580. * Defines an optimization used to merge meshes with compatible materials
  72581. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72582. */
  72583. export class MergeMeshesOptimization extends SceneOptimization {
  72584. private static _UpdateSelectionTree;
  72585. /**
  72586. * Gets or sets a boolean which defines if optimization octree has to be updated
  72587. */
  72588. static get UpdateSelectionTree(): boolean;
  72589. /**
  72590. * Gets or sets a boolean which defines if optimization octree has to be updated
  72591. */
  72592. static set UpdateSelectionTree(value: boolean);
  72593. /**
  72594. * Gets a string describing the action executed by the current optimization
  72595. * @return description string
  72596. */
  72597. getDescription(): string;
  72598. private _canBeMerged;
  72599. /**
  72600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72601. * @param scene defines the current scene where to apply this optimization
  72602. * @param optimizer defines the current optimizer
  72603. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72604. * @returns true if everything that can be done was applied
  72605. */
  72606. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72607. }
  72608. /**
  72609. * Defines a list of options used by SceneOptimizer
  72610. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72611. */
  72612. export class SceneOptimizerOptions {
  72613. /**
  72614. * Defines the target frame rate to reach (60 by default)
  72615. */
  72616. targetFrameRate: number;
  72617. /**
  72618. * Defines the interval between two checkes (2000ms by default)
  72619. */
  72620. trackerDuration: number;
  72621. /**
  72622. * Gets the list of optimizations to apply
  72623. */
  72624. optimizations: SceneOptimization[];
  72625. /**
  72626. * Creates a new list of options used by SceneOptimizer
  72627. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72628. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72629. */
  72630. constructor(
  72631. /**
  72632. * Defines the target frame rate to reach (60 by default)
  72633. */
  72634. targetFrameRate?: number,
  72635. /**
  72636. * Defines the interval between two checkes (2000ms by default)
  72637. */
  72638. trackerDuration?: number);
  72639. /**
  72640. * Add a new optimization
  72641. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72642. * @returns the current SceneOptimizerOptions
  72643. */
  72644. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72645. /**
  72646. * Add a new custom optimization
  72647. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72648. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72649. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72650. * @returns the current SceneOptimizerOptions
  72651. */
  72652. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72653. /**
  72654. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72655. * @param targetFrameRate defines the target frame rate (60 by default)
  72656. * @returns a SceneOptimizerOptions object
  72657. */
  72658. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72659. /**
  72660. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72661. * @param targetFrameRate defines the target frame rate (60 by default)
  72662. * @returns a SceneOptimizerOptions object
  72663. */
  72664. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72665. /**
  72666. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72667. * @param targetFrameRate defines the target frame rate (60 by default)
  72668. * @returns a SceneOptimizerOptions object
  72669. */
  72670. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72671. }
  72672. /**
  72673. * Class used to run optimizations in order to reach a target frame rate
  72674. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72675. */
  72676. export class SceneOptimizer implements IDisposable {
  72677. private _isRunning;
  72678. private _options;
  72679. private _scene;
  72680. private _currentPriorityLevel;
  72681. private _targetFrameRate;
  72682. private _trackerDuration;
  72683. private _currentFrameRate;
  72684. private _sceneDisposeObserver;
  72685. private _improvementMode;
  72686. /**
  72687. * Defines an observable called when the optimizer reaches the target frame rate
  72688. */
  72689. onSuccessObservable: Observable<SceneOptimizer>;
  72690. /**
  72691. * Defines an observable called when the optimizer enables an optimization
  72692. */
  72693. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72694. /**
  72695. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72696. */
  72697. onFailureObservable: Observable<SceneOptimizer>;
  72698. /**
  72699. * Gets a boolean indicating if the optimizer is in improvement mode
  72700. */
  72701. get isInImprovementMode(): boolean;
  72702. /**
  72703. * Gets the current priority level (0 at start)
  72704. */
  72705. get currentPriorityLevel(): number;
  72706. /**
  72707. * Gets the current frame rate checked by the SceneOptimizer
  72708. */
  72709. get currentFrameRate(): number;
  72710. /**
  72711. * Gets or sets the current target frame rate (60 by default)
  72712. */
  72713. get targetFrameRate(): number;
  72714. /**
  72715. * Gets or sets the current target frame rate (60 by default)
  72716. */
  72717. set targetFrameRate(value: number);
  72718. /**
  72719. * Gets or sets the current interval between two checks (every 2000ms by default)
  72720. */
  72721. get trackerDuration(): number;
  72722. /**
  72723. * Gets or sets the current interval between two checks (every 2000ms by default)
  72724. */
  72725. set trackerDuration(value: number);
  72726. /**
  72727. * Gets the list of active optimizations
  72728. */
  72729. get optimizations(): SceneOptimization[];
  72730. /**
  72731. * Creates a new SceneOptimizer
  72732. * @param scene defines the scene to work on
  72733. * @param options defines the options to use with the SceneOptimizer
  72734. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72735. * @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)
  72736. */
  72737. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72738. /**
  72739. * Stops the current optimizer
  72740. */
  72741. stop(): void;
  72742. /**
  72743. * Reset the optimizer to initial step (current priority level = 0)
  72744. */
  72745. reset(): void;
  72746. /**
  72747. * Start the optimizer. By default it will try to reach a specific framerate
  72748. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72749. */
  72750. start(): void;
  72751. private _checkCurrentState;
  72752. /**
  72753. * Release all resources
  72754. */
  72755. dispose(): void;
  72756. /**
  72757. * Helper function to create a SceneOptimizer with one single line of code
  72758. * @param scene defines the scene to work on
  72759. * @param options defines the options to use with the SceneOptimizer
  72760. * @param onSuccess defines a callback to call on success
  72761. * @param onFailure defines a callback to call on failure
  72762. * @returns the new SceneOptimizer object
  72763. */
  72764. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72765. }
  72766. }
  72767. declare module BABYLON {
  72768. /**
  72769. * Class used to serialize a scene into a string
  72770. */
  72771. export class SceneSerializer {
  72772. /**
  72773. * Clear cache used by a previous serialization
  72774. */
  72775. static ClearCache(): void;
  72776. /**
  72777. * Serialize a scene into a JSON compatible object
  72778. * @param scene defines the scene to serialize
  72779. * @returns a JSON compatible object
  72780. */
  72781. static Serialize(scene: Scene): any;
  72782. /**
  72783. * Serialize a mesh into a JSON compatible object
  72784. * @param toSerialize defines the mesh to serialize
  72785. * @param withParents defines if parents must be serialized as well
  72786. * @param withChildren defines if children must be serialized as well
  72787. * @returns a JSON compatible object
  72788. */
  72789. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72790. }
  72791. }
  72792. declare module BABYLON {
  72793. /**
  72794. * Class used to host texture specific utilities
  72795. */
  72796. export class TextureTools {
  72797. /**
  72798. * Uses the GPU to create a copy texture rescaled at a given size
  72799. * @param texture Texture to copy from
  72800. * @param width defines the desired width
  72801. * @param height defines the desired height
  72802. * @param useBilinearMode defines if bilinear mode has to be used
  72803. * @return the generated texture
  72804. */
  72805. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72806. }
  72807. }
  72808. declare module BABYLON {
  72809. /**
  72810. * This represents the different options available for the video capture.
  72811. */
  72812. export interface VideoRecorderOptions {
  72813. /** Defines the mime type of the video. */
  72814. mimeType: string;
  72815. /** Defines the FPS the video should be recorded at. */
  72816. fps: number;
  72817. /** Defines the chunk size for the recording data. */
  72818. recordChunckSize: number;
  72819. /** The audio tracks to attach to the recording. */
  72820. audioTracks?: MediaStreamTrack[];
  72821. }
  72822. /**
  72823. * This can help with recording videos from BabylonJS.
  72824. * This is based on the available WebRTC functionalities of the browser.
  72825. *
  72826. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  72827. */
  72828. export class VideoRecorder {
  72829. private static readonly _defaultOptions;
  72830. /**
  72831. * Returns whether or not the VideoRecorder is available in your browser.
  72832. * @param engine Defines the Babylon Engine.
  72833. * @returns true if supported otherwise false.
  72834. */
  72835. static IsSupported(engine: Engine): boolean;
  72836. private readonly _options;
  72837. private _canvas;
  72838. private _mediaRecorder;
  72839. private _recordedChunks;
  72840. private _fileName;
  72841. private _resolve;
  72842. private _reject;
  72843. /**
  72844. * True when a recording is already in progress.
  72845. */
  72846. get isRecording(): boolean;
  72847. /**
  72848. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72849. * @param engine Defines the BabylonJS Engine you wish to record.
  72850. * @param options Defines options that can be used to customize the capture.
  72851. */
  72852. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72853. /**
  72854. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72855. */
  72856. stopRecording(): void;
  72857. /**
  72858. * Starts recording the canvas for a max duration specified in parameters.
  72859. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72860. * If null no automatic download will start and you can rely on the promise to get the data back.
  72861. * @param maxDuration Defines the maximum recording time in seconds.
  72862. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72863. * @return A promise callback at the end of the recording with the video data in Blob.
  72864. */
  72865. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72866. /**
  72867. * Releases internal resources used during the recording.
  72868. */
  72869. dispose(): void;
  72870. private _handleDataAvailable;
  72871. private _handleError;
  72872. private _handleStop;
  72873. }
  72874. }
  72875. declare module BABYLON {
  72876. /**
  72877. * Class containing a set of static utilities functions for screenshots
  72878. */
  72879. export class ScreenshotTools {
  72880. /**
  72881. * Captures a screenshot of the current rendering
  72882. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72883. * @param engine defines the rendering engine
  72884. * @param camera defines the source camera
  72885. * @param size This parameter can be set to a single number or to an object with the
  72886. * following (optional) properties: precision, width, height. If a single number is passed,
  72887. * it will be used for both width and height. If an object is passed, the screenshot size
  72888. * will be derived from the parameters. The precision property is a multiplier allowing
  72889. * rendering at a higher or lower resolution
  72890. * @param successCallback defines the callback receives a single parameter which contains the
  72891. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72892. * src parameter of an <img> to display it
  72893. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72894. * Check your browser for supported MIME types
  72895. */
  72896. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72897. /**
  72898. * Captures a screenshot of the current rendering
  72899. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72900. * @param engine defines the rendering engine
  72901. * @param camera defines the source camera
  72902. * @param size This parameter can be set to a single number or to an object with the
  72903. * following (optional) properties: precision, width, height. If a single number is passed,
  72904. * it will be used for both width and height. If an object is passed, the screenshot size
  72905. * will be derived from the parameters. The precision property is a multiplier allowing
  72906. * rendering at a higher or lower resolution
  72907. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72908. * Check your browser for supported MIME types
  72909. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72910. * to the src parameter of an <img> to display it
  72911. */
  72912. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72913. /**
  72914. * Generates an image screenshot from the specified camera.
  72915. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72916. * @param engine The engine to use for rendering
  72917. * @param camera The camera to use for rendering
  72918. * @param size This parameter can be set to a single number or to an object with the
  72919. * following (optional) properties: precision, width, height. If a single number is passed,
  72920. * it will be used for both width and height. If an object is passed, the screenshot size
  72921. * will be derived from the parameters. The precision property is a multiplier allowing
  72922. * rendering at a higher or lower resolution
  72923. * @param successCallback The callback receives a single parameter which contains the
  72924. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72925. * src parameter of an <img> to display it
  72926. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72927. * Check your browser for supported MIME types
  72928. * @param samples Texture samples (default: 1)
  72929. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72930. * @param fileName A name for for the downloaded file.
  72931. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72932. */
  72933. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72934. /**
  72935. * Generates an image screenshot from the specified camera.
  72936. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72937. * @param engine The engine to use for rendering
  72938. * @param camera The camera to use for rendering
  72939. * @param size This parameter can be set to a single number or to an object with the
  72940. * following (optional) properties: precision, width, height. If a single number is passed,
  72941. * it will be used for both width and height. If an object is passed, the screenshot size
  72942. * will be derived from the parameters. The precision property is a multiplier allowing
  72943. * rendering at a higher or lower resolution
  72944. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72945. * Check your browser for supported MIME types
  72946. * @param samples Texture samples (default: 1)
  72947. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72948. * @param fileName A name for for the downloaded file.
  72949. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72950. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72951. * to the src parameter of an <img> to display it
  72952. */
  72953. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72954. /**
  72955. * Gets height and width for screenshot size
  72956. * @private
  72957. */
  72958. private static _getScreenshotSize;
  72959. }
  72960. }
  72961. declare module BABYLON {
  72962. /**
  72963. * Interface for a data buffer
  72964. */
  72965. export interface IDataBuffer {
  72966. /**
  72967. * Reads bytes from the data buffer.
  72968. * @param byteOffset The byte offset to read
  72969. * @param byteLength The byte length to read
  72970. * @returns A promise that resolves when the bytes are read
  72971. */
  72972. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72973. /**
  72974. * The byte length of the buffer.
  72975. */
  72976. readonly byteLength: number;
  72977. }
  72978. /**
  72979. * Utility class for reading from a data buffer
  72980. */
  72981. export class DataReader {
  72982. /**
  72983. * The data buffer associated with this data reader.
  72984. */
  72985. readonly buffer: IDataBuffer;
  72986. /**
  72987. * The current byte offset from the beginning of the data buffer.
  72988. */
  72989. byteOffset: number;
  72990. private _dataView;
  72991. private _dataByteOffset;
  72992. /**
  72993. * Constructor
  72994. * @param buffer The buffer to read
  72995. */
  72996. constructor(buffer: IDataBuffer);
  72997. /**
  72998. * Loads the given byte length.
  72999. * @param byteLength The byte length to load
  73000. * @returns A promise that resolves when the load is complete
  73001. */
  73002. loadAsync(byteLength: number): Promise<void>;
  73003. /**
  73004. * Read a unsigned 32-bit integer from the currently loaded data range.
  73005. * @returns The 32-bit integer read
  73006. */
  73007. readUint32(): number;
  73008. /**
  73009. * Read a byte array from the currently loaded data range.
  73010. * @param byteLength The byte length to read
  73011. * @returns The byte array read
  73012. */
  73013. readUint8Array(byteLength: number): Uint8Array;
  73014. /**
  73015. * Read a string from the currently loaded data range.
  73016. * @param byteLength The byte length to read
  73017. * @returns The string read
  73018. */
  73019. readString(byteLength: number): string;
  73020. /**
  73021. * Skips the given byte length the currently loaded data range.
  73022. * @param byteLength The byte length to skip
  73023. */
  73024. skipBytes(byteLength: number): void;
  73025. }
  73026. }
  73027. declare module BABYLON {
  73028. /**
  73029. * Class for storing data to local storage if available or in-memory storage otherwise
  73030. */
  73031. export class DataStorage {
  73032. private static _Storage;
  73033. private static _GetStorage;
  73034. /**
  73035. * Reads a string from the data storage
  73036. * @param key The key to read
  73037. * @param defaultValue The value if the key doesn't exist
  73038. * @returns The string value
  73039. */
  73040. static ReadString(key: string, defaultValue: string): string;
  73041. /**
  73042. * Writes a string to the data storage
  73043. * @param key The key to write
  73044. * @param value The value to write
  73045. */
  73046. static WriteString(key: string, value: string): void;
  73047. /**
  73048. * Reads a boolean from the data storage
  73049. * @param key The key to read
  73050. * @param defaultValue The value if the key doesn't exist
  73051. * @returns The boolean value
  73052. */
  73053. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73054. /**
  73055. * Writes a boolean to the data storage
  73056. * @param key The key to write
  73057. * @param value The value to write
  73058. */
  73059. static WriteBoolean(key: string, value: boolean): void;
  73060. /**
  73061. * Reads a number from the data storage
  73062. * @param key The key to read
  73063. * @param defaultValue The value if the key doesn't exist
  73064. * @returns The number value
  73065. */
  73066. static ReadNumber(key: string, defaultValue: number): number;
  73067. /**
  73068. * Writes a number to the data storage
  73069. * @param key The key to write
  73070. * @param value The value to write
  73071. */
  73072. static WriteNumber(key: string, value: number): void;
  73073. }
  73074. }
  73075. declare module BABYLON {
  73076. /**
  73077. * An interface for all Hit test features
  73078. */
  73079. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73080. /**
  73081. * Triggered when new babylon (transformed) hit test results are available
  73082. */
  73083. onHitTestResultObservable: Observable<T[]>;
  73084. }
  73085. /**
  73086. * Options used for hit testing
  73087. */
  73088. export interface IWebXRLegacyHitTestOptions {
  73089. /**
  73090. * Only test when user interacted with the scene. Default - hit test every frame
  73091. */
  73092. testOnPointerDownOnly?: boolean;
  73093. /**
  73094. * The node to use to transform the local results to world coordinates
  73095. */
  73096. worldParentNode?: TransformNode;
  73097. }
  73098. /**
  73099. * Interface defining the babylon result of raycasting/hit-test
  73100. */
  73101. export interface IWebXRLegacyHitResult {
  73102. /**
  73103. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73104. */
  73105. transformationMatrix: Matrix;
  73106. /**
  73107. * The native hit test result
  73108. */
  73109. xrHitResult: XRHitResult | XRHitTestResult;
  73110. }
  73111. /**
  73112. * The currently-working hit-test module.
  73113. * Hit test (or Ray-casting) is used to interact with the real world.
  73114. * For further information read here - https://github.com/immersive-web/hit-test
  73115. */
  73116. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73117. /**
  73118. * options to use when constructing this feature
  73119. */
  73120. readonly options: IWebXRLegacyHitTestOptions;
  73121. private _direction;
  73122. private _mat;
  73123. private _onSelectEnabled;
  73124. private _origin;
  73125. /**
  73126. * The module's name
  73127. */
  73128. static readonly Name: string;
  73129. /**
  73130. * The (Babylon) version of this module.
  73131. * This is an integer representing the implementation version.
  73132. * This number does not correspond to the WebXR specs version
  73133. */
  73134. static readonly Version: number;
  73135. /**
  73136. * Populated with the last native XR Hit Results
  73137. */
  73138. lastNativeXRHitResults: XRHitResult[];
  73139. /**
  73140. * Triggered when new babylon (transformed) hit test results are available
  73141. */
  73142. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73143. /**
  73144. * Creates a new instance of the (legacy version) hit test feature
  73145. * @param _xrSessionManager an instance of WebXRSessionManager
  73146. * @param options options to use when constructing this feature
  73147. */
  73148. constructor(_xrSessionManager: WebXRSessionManager,
  73149. /**
  73150. * options to use when constructing this feature
  73151. */
  73152. options?: IWebXRLegacyHitTestOptions);
  73153. /**
  73154. * execute a hit test with an XR Ray
  73155. *
  73156. * @param xrSession a native xrSession that will execute this hit test
  73157. * @param xrRay the ray (position and direction) to use for ray-casting
  73158. * @param referenceSpace native XR reference space to use for the hit-test
  73159. * @param filter filter function that will filter the results
  73160. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73161. */
  73162. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73163. /**
  73164. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73165. * @param event the (select) event to use to select with
  73166. * @param referenceSpace the reference space to use for this hit test
  73167. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73168. */
  73169. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73170. /**
  73171. * attach this feature
  73172. * Will usually be called by the features manager
  73173. *
  73174. * @returns true if successful.
  73175. */
  73176. attach(): boolean;
  73177. /**
  73178. * detach this feature.
  73179. * Will usually be called by the features manager
  73180. *
  73181. * @returns true if successful.
  73182. */
  73183. detach(): boolean;
  73184. /**
  73185. * Dispose this feature and all of the resources attached
  73186. */
  73187. dispose(): void;
  73188. protected _onXRFrame(frame: XRFrame): void;
  73189. private _onHitTestResults;
  73190. private _onSelect;
  73191. }
  73192. }
  73193. declare module BABYLON {
  73194. /**
  73195. * Options used for hit testing (version 2)
  73196. */
  73197. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73198. /**
  73199. * Do not create a permanent hit test. Will usually be used when only
  73200. * transient inputs are needed.
  73201. */
  73202. disablePermanentHitTest?: boolean;
  73203. /**
  73204. * Enable transient (for example touch-based) hit test inspections
  73205. */
  73206. enableTransientHitTest?: boolean;
  73207. /**
  73208. * Offset ray for the permanent hit test
  73209. */
  73210. offsetRay?: Vector3;
  73211. /**
  73212. * Offset ray for the transient hit test
  73213. */
  73214. transientOffsetRay?: Vector3;
  73215. /**
  73216. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73217. */
  73218. useReferenceSpace?: boolean;
  73219. }
  73220. /**
  73221. * Interface defining the babylon result of hit-test
  73222. */
  73223. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73224. /**
  73225. * The input source that generated this hit test (if transient)
  73226. */
  73227. inputSource?: XRInputSource;
  73228. /**
  73229. * Is this a transient hit test
  73230. */
  73231. isTransient?: boolean;
  73232. /**
  73233. * Position of the hit test result
  73234. */
  73235. position: Vector3;
  73236. /**
  73237. * Rotation of the hit test result
  73238. */
  73239. rotationQuaternion: Quaternion;
  73240. /**
  73241. * The native hit test result
  73242. */
  73243. xrHitResult: XRHitTestResult;
  73244. }
  73245. /**
  73246. * The currently-working hit-test module.
  73247. * Hit test (or Ray-casting) is used to interact with the real world.
  73248. * For further information read here - https://github.com/immersive-web/hit-test
  73249. *
  73250. * Tested on chrome (mobile) 80.
  73251. */
  73252. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73253. /**
  73254. * options to use when constructing this feature
  73255. */
  73256. readonly options: IWebXRHitTestOptions;
  73257. private _tmpMat;
  73258. private _tmpPos;
  73259. private _tmpQuat;
  73260. private _transientXrHitTestSource;
  73261. private _xrHitTestSource;
  73262. private initHitTestSource;
  73263. /**
  73264. * The module's name
  73265. */
  73266. static readonly Name: string;
  73267. /**
  73268. * The (Babylon) version of this module.
  73269. * This is an integer representing the implementation version.
  73270. * This number does not correspond to the WebXR specs version
  73271. */
  73272. static readonly Version: number;
  73273. /**
  73274. * When set to true, each hit test will have its own position/rotation objects
  73275. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73276. * the developers will clone them or copy them as they see fit.
  73277. */
  73278. autoCloneTransformation: boolean;
  73279. /**
  73280. * Triggered when new babylon (transformed) hit test results are available
  73281. */
  73282. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73283. /**
  73284. * Use this to temporarily pause hit test checks.
  73285. */
  73286. paused: boolean;
  73287. /**
  73288. * Creates a new instance of the hit test feature
  73289. * @param _xrSessionManager an instance of WebXRSessionManager
  73290. * @param options options to use when constructing this feature
  73291. */
  73292. constructor(_xrSessionManager: WebXRSessionManager,
  73293. /**
  73294. * options to use when constructing this feature
  73295. */
  73296. options?: IWebXRHitTestOptions);
  73297. /**
  73298. * attach this feature
  73299. * Will usually be called by the features manager
  73300. *
  73301. * @returns true if successful.
  73302. */
  73303. attach(): boolean;
  73304. /**
  73305. * detach this feature.
  73306. * Will usually be called by the features manager
  73307. *
  73308. * @returns true if successful.
  73309. */
  73310. detach(): boolean;
  73311. /**
  73312. * Dispose this feature and all of the resources attached
  73313. */
  73314. dispose(): void;
  73315. protected _onXRFrame(frame: XRFrame): void;
  73316. private _processWebXRHitTestResult;
  73317. }
  73318. }
  73319. declare module BABYLON {
  73320. /**
  73321. * Configuration options of the anchor system
  73322. */
  73323. export interface IWebXRAnchorSystemOptions {
  73324. /**
  73325. * a node that will be used to convert local to world coordinates
  73326. */
  73327. worldParentNode?: TransformNode;
  73328. /**
  73329. * If set to true a reference of the created anchors will be kept until the next session starts
  73330. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73331. */
  73332. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73333. }
  73334. /**
  73335. * A babylon container for an XR Anchor
  73336. */
  73337. export interface IWebXRAnchor {
  73338. /**
  73339. * A babylon-assigned ID for this anchor
  73340. */
  73341. id: number;
  73342. /**
  73343. * Transformation matrix to apply to an object attached to this anchor
  73344. */
  73345. transformationMatrix: Matrix;
  73346. /**
  73347. * The native anchor object
  73348. */
  73349. xrAnchor: XRAnchor;
  73350. /**
  73351. * if defined, this object will be constantly updated by the anchor's position and rotation
  73352. */
  73353. attachedNode?: TransformNode;
  73354. }
  73355. /**
  73356. * An implementation of the anchor system for WebXR.
  73357. * For further information see https://github.com/immersive-web/anchors/
  73358. */
  73359. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73360. private _options;
  73361. private _lastFrameDetected;
  73362. private _trackedAnchors;
  73363. private _referenceSpaceForFrameAnchors;
  73364. private _futureAnchors;
  73365. /**
  73366. * The module's name
  73367. */
  73368. static readonly Name: string;
  73369. /**
  73370. * The (Babylon) version of this module.
  73371. * This is an integer representing the implementation version.
  73372. * This number does not correspond to the WebXR specs version
  73373. */
  73374. static readonly Version: number;
  73375. /**
  73376. * Observers registered here will be executed when a new anchor was added to the session
  73377. */
  73378. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73379. /**
  73380. * Observers registered here will be executed when an anchor was removed from the session
  73381. */
  73382. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73383. /**
  73384. * Observers registered here will be executed when an existing anchor updates
  73385. * This can execute N times every frame
  73386. */
  73387. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73388. /**
  73389. * Set the reference space to use for anchor creation, when not using a hit test.
  73390. * Will default to the session's reference space if not defined
  73391. */
  73392. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73393. /**
  73394. * constructs a new anchor system
  73395. * @param _xrSessionManager an instance of WebXRSessionManager
  73396. * @param _options configuration object for this feature
  73397. */
  73398. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73399. private _tmpVector;
  73400. private _tmpQuaternion;
  73401. private _populateTmpTransformation;
  73402. /**
  73403. * Create a new anchor point using a hit test result at a specific point in the scene
  73404. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73405. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73406. *
  73407. * @param hitTestResult The hit test result to use for this anchor creation
  73408. * @param position an optional position offset for this anchor
  73409. * @param rotationQuaternion an optional rotation offset for this anchor
  73410. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73411. */
  73412. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73413. /**
  73414. * Add a new anchor at a specific position and rotation
  73415. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73416. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73417. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73418. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73419. *
  73420. * @param position the position in which to add an anchor
  73421. * @param rotationQuaternion an optional rotation for the anchor transformation
  73422. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73423. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73424. */
  73425. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73426. /**
  73427. * detach this feature.
  73428. * Will usually be called by the features manager
  73429. *
  73430. * @returns true if successful.
  73431. */
  73432. detach(): boolean;
  73433. /**
  73434. * Dispose this feature and all of the resources attached
  73435. */
  73436. dispose(): void;
  73437. protected _onXRFrame(frame: XRFrame): void;
  73438. /**
  73439. * avoiding using Array.find for global support.
  73440. * @param xrAnchor the plane to find in the array
  73441. */
  73442. private _findIndexInAnchorArray;
  73443. private _updateAnchorWithXRFrame;
  73444. private _createAnchorAtTransformation;
  73445. }
  73446. }
  73447. declare module BABYLON {
  73448. /**
  73449. * Options used in the plane detector module
  73450. */
  73451. export interface IWebXRPlaneDetectorOptions {
  73452. /**
  73453. * The node to use to transform the local results to world coordinates
  73454. */
  73455. worldParentNode?: TransformNode;
  73456. /**
  73457. * If set to true a reference of the created planes will be kept until the next session starts
  73458. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73459. */
  73460. doNotRemovePlanesOnSessionEnded?: boolean;
  73461. }
  73462. /**
  73463. * A babylon interface for a WebXR plane.
  73464. * A Plane is actually a polygon, built from N points in space
  73465. *
  73466. * Supported in chrome 79, not supported in canary 81 ATM
  73467. */
  73468. export interface IWebXRPlane {
  73469. /**
  73470. * a babylon-assigned ID for this polygon
  73471. */
  73472. id: number;
  73473. /**
  73474. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73475. */
  73476. polygonDefinition: Array<Vector3>;
  73477. /**
  73478. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73479. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73480. */
  73481. transformationMatrix: Matrix;
  73482. /**
  73483. * the native xr-plane object
  73484. */
  73485. xrPlane: XRPlane;
  73486. }
  73487. /**
  73488. * The plane detector is used to detect planes in the real world when in AR
  73489. * For more information see https://github.com/immersive-web/real-world-geometry/
  73490. */
  73491. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73492. private _options;
  73493. private _detectedPlanes;
  73494. private _enabled;
  73495. private _lastFrameDetected;
  73496. /**
  73497. * The module's name
  73498. */
  73499. static readonly Name: string;
  73500. /**
  73501. * The (Babylon) version of this module.
  73502. * This is an integer representing the implementation version.
  73503. * This number does not correspond to the WebXR specs version
  73504. */
  73505. static readonly Version: number;
  73506. /**
  73507. * Observers registered here will be executed when a new plane was added to the session
  73508. */
  73509. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73510. /**
  73511. * Observers registered here will be executed when a plane is no longer detected in the session
  73512. */
  73513. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73514. /**
  73515. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73516. * This can execute N times every frame
  73517. */
  73518. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73519. /**
  73520. * construct a new Plane Detector
  73521. * @param _xrSessionManager an instance of xr Session manager
  73522. * @param _options configuration to use when constructing this feature
  73523. */
  73524. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73525. /**
  73526. * detach this feature.
  73527. * Will usually be called by the features manager
  73528. *
  73529. * @returns true if successful.
  73530. */
  73531. detach(): boolean;
  73532. /**
  73533. * Dispose this feature and all of the resources attached
  73534. */
  73535. dispose(): void;
  73536. protected _onXRFrame(frame: XRFrame): void;
  73537. private _init;
  73538. private _updatePlaneWithXRPlane;
  73539. /**
  73540. * avoiding using Array.find for global support.
  73541. * @param xrPlane the plane to find in the array
  73542. */
  73543. private findIndexInPlaneArray;
  73544. }
  73545. }
  73546. declare module BABYLON {
  73547. /**
  73548. * Options interface for the background remover plugin
  73549. */
  73550. export interface IWebXRBackgroundRemoverOptions {
  73551. /**
  73552. * Further background meshes to disable when entering AR
  73553. */
  73554. backgroundMeshes?: AbstractMesh[];
  73555. /**
  73556. * flags to configure the removal of the environment helper.
  73557. * If not set, the entire background will be removed. If set, flags should be set as well.
  73558. */
  73559. environmentHelperRemovalFlags?: {
  73560. /**
  73561. * Should the skybox be removed (default false)
  73562. */
  73563. skyBox?: boolean;
  73564. /**
  73565. * Should the ground be removed (default false)
  73566. */
  73567. ground?: boolean;
  73568. };
  73569. /**
  73570. * don't disable the environment helper
  73571. */
  73572. ignoreEnvironmentHelper?: boolean;
  73573. }
  73574. /**
  73575. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73576. */
  73577. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73578. /**
  73579. * read-only options to be used in this module
  73580. */
  73581. readonly options: IWebXRBackgroundRemoverOptions;
  73582. /**
  73583. * The module's name
  73584. */
  73585. static readonly Name: string;
  73586. /**
  73587. * The (Babylon) version of this module.
  73588. * This is an integer representing the implementation version.
  73589. * This number does not correspond to the WebXR specs version
  73590. */
  73591. static readonly Version: number;
  73592. /**
  73593. * registered observers will be triggered when the background state changes
  73594. */
  73595. onBackgroundStateChangedObservable: Observable<boolean>;
  73596. /**
  73597. * constructs a new background remover module
  73598. * @param _xrSessionManager the session manager for this module
  73599. * @param options read-only options to be used in this module
  73600. */
  73601. constructor(_xrSessionManager: WebXRSessionManager,
  73602. /**
  73603. * read-only options to be used in this module
  73604. */
  73605. options?: IWebXRBackgroundRemoverOptions);
  73606. /**
  73607. * attach this feature
  73608. * Will usually be called by the features manager
  73609. *
  73610. * @returns true if successful.
  73611. */
  73612. attach(): boolean;
  73613. /**
  73614. * detach this feature.
  73615. * Will usually be called by the features manager
  73616. *
  73617. * @returns true if successful.
  73618. */
  73619. detach(): boolean;
  73620. /**
  73621. * Dispose this feature and all of the resources attached
  73622. */
  73623. dispose(): void;
  73624. protected _onXRFrame(_xrFrame: XRFrame): void;
  73625. private _setBackgroundState;
  73626. }
  73627. }
  73628. declare module BABYLON {
  73629. /**
  73630. * Options for the controller physics feature
  73631. */
  73632. export class IWebXRControllerPhysicsOptions {
  73633. /**
  73634. * Should the headset get its own impostor
  73635. */
  73636. enableHeadsetImpostor?: boolean;
  73637. /**
  73638. * Optional parameters for the headset impostor
  73639. */
  73640. headsetImpostorParams?: {
  73641. /**
  73642. * The type of impostor to create. Default is sphere
  73643. */
  73644. impostorType: number;
  73645. /**
  73646. * the size of the impostor. Defaults to 10cm
  73647. */
  73648. impostorSize?: number | {
  73649. width: number;
  73650. height: number;
  73651. depth: number;
  73652. };
  73653. /**
  73654. * Friction definitions
  73655. */
  73656. friction?: number;
  73657. /**
  73658. * Restitution
  73659. */
  73660. restitution?: number;
  73661. };
  73662. /**
  73663. * The physics properties of the future impostors
  73664. */
  73665. physicsProperties?: {
  73666. /**
  73667. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73668. * Note that this requires a physics engine that supports mesh impostors!
  73669. */
  73670. useControllerMesh?: boolean;
  73671. /**
  73672. * The type of impostor to create. Default is sphere
  73673. */
  73674. impostorType?: number;
  73675. /**
  73676. * the size of the impostor. Defaults to 10cm
  73677. */
  73678. impostorSize?: number | {
  73679. width: number;
  73680. height: number;
  73681. depth: number;
  73682. };
  73683. /**
  73684. * Friction definitions
  73685. */
  73686. friction?: number;
  73687. /**
  73688. * Restitution
  73689. */
  73690. restitution?: number;
  73691. };
  73692. /**
  73693. * the xr input to use with this pointer selection
  73694. */
  73695. xrInput: WebXRInput;
  73696. }
  73697. /**
  73698. * Add physics impostor to your webxr controllers,
  73699. * including naive calculation of their linear and angular velocity
  73700. */
  73701. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73702. private readonly _options;
  73703. private _attachController;
  73704. private _controllers;
  73705. private _debugMode;
  73706. private _delta;
  73707. private _headsetImpostor?;
  73708. private _headsetMesh?;
  73709. private _lastTimestamp;
  73710. private _tmpQuaternion;
  73711. private _tmpVector;
  73712. /**
  73713. * The module's name
  73714. */
  73715. static readonly Name: string;
  73716. /**
  73717. * The (Babylon) version of this module.
  73718. * This is an integer representing the implementation version.
  73719. * This number does not correspond to the webxr specs version
  73720. */
  73721. static readonly Version: number;
  73722. /**
  73723. * Construct a new Controller Physics Feature
  73724. * @param _xrSessionManager the corresponding xr session manager
  73725. * @param _options options to create this feature with
  73726. */
  73727. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73728. /**
  73729. * @hidden
  73730. * enable debugging - will show console outputs and the impostor mesh
  73731. */
  73732. _enablePhysicsDebug(): void;
  73733. /**
  73734. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73735. * @param xrController the controller to add
  73736. */
  73737. addController(xrController: WebXRInputSource): void;
  73738. /**
  73739. * attach this feature
  73740. * Will usually be called by the features manager
  73741. *
  73742. * @returns true if successful.
  73743. */
  73744. attach(): boolean;
  73745. /**
  73746. * detach this feature.
  73747. * Will usually be called by the features manager
  73748. *
  73749. * @returns true if successful.
  73750. */
  73751. detach(): boolean;
  73752. /**
  73753. * Get the headset impostor, if enabled
  73754. * @returns the impostor
  73755. */
  73756. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73757. /**
  73758. * Get the physics impostor of a specific controller.
  73759. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73760. * @param controller the controller or the controller id of which to get the impostor
  73761. * @returns the impostor or null
  73762. */
  73763. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73764. /**
  73765. * Update the physics properties provided in the constructor
  73766. * @param newProperties the new properties object
  73767. */
  73768. setPhysicsProperties(newProperties: {
  73769. impostorType?: number;
  73770. impostorSize?: number | {
  73771. width: number;
  73772. height: number;
  73773. depth: number;
  73774. };
  73775. friction?: number;
  73776. restitution?: number;
  73777. }): void;
  73778. protected _onXRFrame(_xrFrame: any): void;
  73779. private _detachController;
  73780. }
  73781. }
  73782. declare module BABYLON {
  73783. /**
  73784. * The motion controller class for all microsoft mixed reality controllers
  73785. */
  73786. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73787. protected readonly _mapping: {
  73788. defaultButton: {
  73789. valueNodeName: string;
  73790. unpressedNodeName: string;
  73791. pressedNodeName: string;
  73792. };
  73793. defaultAxis: {
  73794. valueNodeName: string;
  73795. minNodeName: string;
  73796. maxNodeName: string;
  73797. };
  73798. buttons: {
  73799. "xr-standard-trigger": {
  73800. rootNodeName: string;
  73801. componentProperty: string;
  73802. states: string[];
  73803. };
  73804. "xr-standard-squeeze": {
  73805. rootNodeName: string;
  73806. componentProperty: string;
  73807. states: string[];
  73808. };
  73809. "xr-standard-touchpad": {
  73810. rootNodeName: string;
  73811. labelAnchorNodeName: string;
  73812. touchPointNodeName: string;
  73813. };
  73814. "xr-standard-thumbstick": {
  73815. rootNodeName: string;
  73816. componentProperty: string;
  73817. states: string[];
  73818. };
  73819. };
  73820. axes: {
  73821. "xr-standard-touchpad": {
  73822. "x-axis": {
  73823. rootNodeName: string;
  73824. };
  73825. "y-axis": {
  73826. rootNodeName: string;
  73827. };
  73828. };
  73829. "xr-standard-thumbstick": {
  73830. "x-axis": {
  73831. rootNodeName: string;
  73832. };
  73833. "y-axis": {
  73834. rootNodeName: string;
  73835. };
  73836. };
  73837. };
  73838. };
  73839. /**
  73840. * The base url used to load the left and right controller models
  73841. */
  73842. static MODEL_BASE_URL: string;
  73843. /**
  73844. * The name of the left controller model file
  73845. */
  73846. static MODEL_LEFT_FILENAME: string;
  73847. /**
  73848. * The name of the right controller model file
  73849. */
  73850. static MODEL_RIGHT_FILENAME: string;
  73851. profileId: string;
  73852. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73853. protected _getFilenameAndPath(): {
  73854. filename: string;
  73855. path: string;
  73856. };
  73857. protected _getModelLoadingConstraints(): boolean;
  73858. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73859. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73860. protected _updateModel(): void;
  73861. }
  73862. }
  73863. declare module BABYLON {
  73864. /**
  73865. * The motion controller class for oculus touch (quest, rift).
  73866. * This class supports legacy mapping as well the standard xr mapping
  73867. */
  73868. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73869. private _forceLegacyControllers;
  73870. private _modelRootNode;
  73871. /**
  73872. * The base url used to load the left and right controller models
  73873. */
  73874. static MODEL_BASE_URL: string;
  73875. /**
  73876. * The name of the left controller model file
  73877. */
  73878. static MODEL_LEFT_FILENAME: string;
  73879. /**
  73880. * The name of the right controller model file
  73881. */
  73882. static MODEL_RIGHT_FILENAME: string;
  73883. /**
  73884. * Base Url for the Quest controller model.
  73885. */
  73886. static QUEST_MODEL_BASE_URL: string;
  73887. profileId: string;
  73888. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73889. protected _getFilenameAndPath(): {
  73890. filename: string;
  73891. path: string;
  73892. };
  73893. protected _getModelLoadingConstraints(): boolean;
  73894. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73895. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73896. protected _updateModel(): void;
  73897. /**
  73898. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73899. * between the touch and touch 2.
  73900. */
  73901. private _isQuest;
  73902. }
  73903. }
  73904. declare module BABYLON {
  73905. /**
  73906. * The motion controller class for the standard HTC-Vive controllers
  73907. */
  73908. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73909. private _modelRootNode;
  73910. /**
  73911. * The base url used to load the left and right controller models
  73912. */
  73913. static MODEL_BASE_URL: string;
  73914. /**
  73915. * File name for the controller model.
  73916. */
  73917. static MODEL_FILENAME: string;
  73918. profileId: string;
  73919. /**
  73920. * Create a new Vive motion controller object
  73921. * @param scene the scene to use to create this controller
  73922. * @param gamepadObject the corresponding gamepad object
  73923. * @param handedness the handedness of the controller
  73924. */
  73925. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73926. protected _getFilenameAndPath(): {
  73927. filename: string;
  73928. path: string;
  73929. };
  73930. protected _getModelLoadingConstraints(): boolean;
  73931. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73932. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73933. protected _updateModel(): void;
  73934. }
  73935. }
  73936. declare module BABYLON {
  73937. /**
  73938. * A cursor which tracks a point on a path
  73939. */
  73940. export class PathCursor {
  73941. private path;
  73942. /**
  73943. * Stores path cursor callbacks for when an onchange event is triggered
  73944. */
  73945. private _onchange;
  73946. /**
  73947. * The value of the path cursor
  73948. */
  73949. value: number;
  73950. /**
  73951. * The animation array of the path cursor
  73952. */
  73953. animations: Animation[];
  73954. /**
  73955. * Initializes the path cursor
  73956. * @param path The path to track
  73957. */
  73958. constructor(path: Path2);
  73959. /**
  73960. * Gets the cursor point on the path
  73961. * @returns A point on the path cursor at the cursor location
  73962. */
  73963. getPoint(): Vector3;
  73964. /**
  73965. * Moves the cursor ahead by the step amount
  73966. * @param step The amount to move the cursor forward
  73967. * @returns This path cursor
  73968. */
  73969. moveAhead(step?: number): PathCursor;
  73970. /**
  73971. * Moves the cursor behind by the step amount
  73972. * @param step The amount to move the cursor back
  73973. * @returns This path cursor
  73974. */
  73975. moveBack(step?: number): PathCursor;
  73976. /**
  73977. * Moves the cursor by the step amount
  73978. * If the step amount is greater than one, an exception is thrown
  73979. * @param step The amount to move the cursor
  73980. * @returns This path cursor
  73981. */
  73982. move(step: number): PathCursor;
  73983. /**
  73984. * Ensures that the value is limited between zero and one
  73985. * @returns This path cursor
  73986. */
  73987. private ensureLimits;
  73988. /**
  73989. * Runs onchange callbacks on change (used by the animation engine)
  73990. * @returns This path cursor
  73991. */
  73992. private raiseOnChange;
  73993. /**
  73994. * Executes a function on change
  73995. * @param f A path cursor onchange callback
  73996. * @returns This path cursor
  73997. */
  73998. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73999. }
  74000. }
  74001. declare module BABYLON {
  74002. /** @hidden */
  74003. export var blurPixelShader: {
  74004. name: string;
  74005. shader: string;
  74006. };
  74007. }
  74008. declare module BABYLON {
  74009. /** @hidden */
  74010. export var pointCloudVertexDeclaration: {
  74011. name: string;
  74012. shader: string;
  74013. };
  74014. }
  74015. // Mixins
  74016. interface Window {
  74017. mozIndexedDB: IDBFactory;
  74018. webkitIndexedDB: IDBFactory;
  74019. msIndexedDB: IDBFactory;
  74020. webkitURL: typeof URL;
  74021. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74022. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74023. WebGLRenderingContext: WebGLRenderingContext;
  74024. MSGesture: MSGesture;
  74025. CANNON: any;
  74026. AudioContext: AudioContext;
  74027. webkitAudioContext: AudioContext;
  74028. PointerEvent: any;
  74029. Math: Math;
  74030. Uint8Array: Uint8ArrayConstructor;
  74031. Float32Array: Float32ArrayConstructor;
  74032. mozURL: typeof URL;
  74033. msURL: typeof URL;
  74034. VRFrameData: any; // WebVR, from specs 1.1
  74035. DracoDecoderModule: any;
  74036. setImmediate(handler: (...args: any[]) => void): number;
  74037. }
  74038. interface HTMLCanvasElement {
  74039. requestPointerLock(): void;
  74040. msRequestPointerLock?(): void;
  74041. mozRequestPointerLock?(): void;
  74042. webkitRequestPointerLock?(): void;
  74043. /** Track wether a record is in progress */
  74044. isRecording: boolean;
  74045. /** Capture Stream method defined by some browsers */
  74046. captureStream(fps?: number): MediaStream;
  74047. }
  74048. interface CanvasRenderingContext2D {
  74049. msImageSmoothingEnabled: boolean;
  74050. }
  74051. interface MouseEvent {
  74052. mozMovementX: number;
  74053. mozMovementY: number;
  74054. webkitMovementX: number;
  74055. webkitMovementY: number;
  74056. msMovementX: number;
  74057. msMovementY: number;
  74058. }
  74059. interface Navigator {
  74060. mozGetVRDevices: (any: any) => any;
  74061. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74062. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74063. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74064. webkitGetGamepads(): Gamepad[];
  74065. msGetGamepads(): Gamepad[];
  74066. webkitGamepads(): Gamepad[];
  74067. }
  74068. interface HTMLVideoElement {
  74069. mozSrcObject: any;
  74070. }
  74071. interface Math {
  74072. fround(x: number): number;
  74073. imul(a: number, b: number): number;
  74074. }
  74075. interface WebGLRenderingContext {
  74076. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74077. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74078. vertexAttribDivisor(index: number, divisor: number): void;
  74079. createVertexArray(): any;
  74080. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74081. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74082. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74083. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74084. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74085. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74086. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74087. // Queries
  74088. createQuery(): WebGLQuery;
  74089. deleteQuery(query: WebGLQuery): void;
  74090. beginQuery(target: number, query: WebGLQuery): void;
  74091. endQuery(target: number): void;
  74092. getQueryParameter(query: WebGLQuery, pname: number): any;
  74093. getQuery(target: number, pname: number): any;
  74094. MAX_SAMPLES: number;
  74095. RGBA8: number;
  74096. READ_FRAMEBUFFER: number;
  74097. DRAW_FRAMEBUFFER: number;
  74098. UNIFORM_BUFFER: number;
  74099. HALF_FLOAT_OES: number;
  74100. RGBA16F: number;
  74101. RGBA32F: number;
  74102. R32F: number;
  74103. RG32F: number;
  74104. RGB32F: number;
  74105. R16F: number;
  74106. RG16F: number;
  74107. RGB16F: number;
  74108. RED: number;
  74109. RG: number;
  74110. R8: number;
  74111. RG8: number;
  74112. UNSIGNED_INT_24_8: number;
  74113. DEPTH24_STENCIL8: number;
  74114. MIN: number;
  74115. MAX: number;
  74116. /* Multiple Render Targets */
  74117. drawBuffers(buffers: number[]): void;
  74118. readBuffer(src: number): void;
  74119. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74120. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74121. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74122. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74123. // Occlusion Query
  74124. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74125. ANY_SAMPLES_PASSED: number;
  74126. QUERY_RESULT_AVAILABLE: number;
  74127. QUERY_RESULT: number;
  74128. }
  74129. interface WebGLProgram {
  74130. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74131. }
  74132. interface EXT_disjoint_timer_query {
  74133. QUERY_COUNTER_BITS_EXT: number;
  74134. TIME_ELAPSED_EXT: number;
  74135. TIMESTAMP_EXT: number;
  74136. GPU_DISJOINT_EXT: number;
  74137. QUERY_RESULT_EXT: number;
  74138. QUERY_RESULT_AVAILABLE_EXT: number;
  74139. queryCounterEXT(query: WebGLQuery, target: number): void;
  74140. createQueryEXT(): WebGLQuery;
  74141. beginQueryEXT(target: number, query: WebGLQuery): void;
  74142. endQueryEXT(target: number): void;
  74143. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74144. deleteQueryEXT(query: WebGLQuery): void;
  74145. }
  74146. interface WebGLUniformLocation {
  74147. _currentState: any;
  74148. }
  74149. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74150. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74151. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74152. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74153. interface WebGLRenderingContext {
  74154. readonly RASTERIZER_DISCARD: number;
  74155. readonly DEPTH_COMPONENT24: number;
  74156. readonly TEXTURE_3D: number;
  74157. readonly TEXTURE_2D_ARRAY: number;
  74158. readonly TEXTURE_COMPARE_FUNC: number;
  74159. readonly TEXTURE_COMPARE_MODE: number;
  74160. readonly COMPARE_REF_TO_TEXTURE: number;
  74161. readonly TEXTURE_WRAP_R: number;
  74162. readonly HALF_FLOAT: number;
  74163. readonly RGB8: number;
  74164. readonly RED_INTEGER: number;
  74165. readonly RG_INTEGER: number;
  74166. readonly RGB_INTEGER: number;
  74167. readonly RGBA_INTEGER: number;
  74168. readonly R8_SNORM: number;
  74169. readonly RG8_SNORM: number;
  74170. readonly RGB8_SNORM: number;
  74171. readonly RGBA8_SNORM: number;
  74172. readonly R8I: number;
  74173. readonly RG8I: number;
  74174. readonly RGB8I: number;
  74175. readonly RGBA8I: number;
  74176. readonly R8UI: number;
  74177. readonly RG8UI: number;
  74178. readonly RGB8UI: number;
  74179. readonly RGBA8UI: number;
  74180. readonly R16I: number;
  74181. readonly RG16I: number;
  74182. readonly RGB16I: number;
  74183. readonly RGBA16I: number;
  74184. readonly R16UI: number;
  74185. readonly RG16UI: number;
  74186. readonly RGB16UI: number;
  74187. readonly RGBA16UI: number;
  74188. readonly R32I: number;
  74189. readonly RG32I: number;
  74190. readonly RGB32I: number;
  74191. readonly RGBA32I: number;
  74192. readonly R32UI: number;
  74193. readonly RG32UI: number;
  74194. readonly RGB32UI: number;
  74195. readonly RGBA32UI: number;
  74196. readonly RGB10_A2UI: number;
  74197. readonly R11F_G11F_B10F: number;
  74198. readonly RGB9_E5: number;
  74199. readonly RGB10_A2: number;
  74200. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74201. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74202. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74203. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74204. readonly DEPTH_COMPONENT32F: number;
  74205. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74206. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74207. 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;
  74208. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74209. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74210. readonly TRANSFORM_FEEDBACK: number;
  74211. readonly INTERLEAVED_ATTRIBS: number;
  74212. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74213. createTransformFeedback(): WebGLTransformFeedback;
  74214. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74215. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74216. beginTransformFeedback(primitiveMode: number): void;
  74217. endTransformFeedback(): void;
  74218. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74219. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74220. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74221. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74222. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74223. }
  74224. interface ImageBitmap {
  74225. readonly width: number;
  74226. readonly height: number;
  74227. close(): void;
  74228. }
  74229. interface WebGLQuery extends WebGLObject {
  74230. }
  74231. declare var WebGLQuery: {
  74232. prototype: WebGLQuery;
  74233. new(): WebGLQuery;
  74234. };
  74235. interface WebGLSampler extends WebGLObject {
  74236. }
  74237. declare var WebGLSampler: {
  74238. prototype: WebGLSampler;
  74239. new(): WebGLSampler;
  74240. };
  74241. interface WebGLSync extends WebGLObject {
  74242. }
  74243. declare var WebGLSync: {
  74244. prototype: WebGLSync;
  74245. new(): WebGLSync;
  74246. };
  74247. interface WebGLTransformFeedback extends WebGLObject {
  74248. }
  74249. declare var WebGLTransformFeedback: {
  74250. prototype: WebGLTransformFeedback;
  74251. new(): WebGLTransformFeedback;
  74252. };
  74253. interface WebGLVertexArrayObject extends WebGLObject {
  74254. }
  74255. declare var WebGLVertexArrayObject: {
  74256. prototype: WebGLVertexArrayObject;
  74257. new(): WebGLVertexArrayObject;
  74258. };
  74259. // Type definitions for WebVR API
  74260. // Project: https://w3c.github.io/webvr/
  74261. // Definitions by: six a <https://github.com/lostfictions>
  74262. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74263. interface VRDisplay extends EventTarget {
  74264. /**
  74265. * Dictionary of capabilities describing the VRDisplay.
  74266. */
  74267. readonly capabilities: VRDisplayCapabilities;
  74268. /**
  74269. * z-depth defining the far plane of the eye view frustum
  74270. * enables mapping of values in the render target depth
  74271. * attachment to scene coordinates. Initially set to 10000.0.
  74272. */
  74273. depthFar: number;
  74274. /**
  74275. * z-depth defining the near plane of the eye view frustum
  74276. * enables mapping of values in the render target depth
  74277. * attachment to scene coordinates. Initially set to 0.01.
  74278. */
  74279. depthNear: number;
  74280. /**
  74281. * An identifier for this distinct VRDisplay. Used as an
  74282. * association point in the Gamepad API.
  74283. */
  74284. readonly displayId: number;
  74285. /**
  74286. * A display name, a user-readable name identifying it.
  74287. */
  74288. readonly displayName: string;
  74289. readonly isConnected: boolean;
  74290. readonly isPresenting: boolean;
  74291. /**
  74292. * If this VRDisplay supports room-scale experiences, the optional
  74293. * stage attribute contains details on the room-scale parameters.
  74294. */
  74295. readonly stageParameters: VRStageParameters | null;
  74296. /**
  74297. * Passing the value returned by `requestAnimationFrame` to
  74298. * `cancelAnimationFrame` will unregister the callback.
  74299. * @param handle Define the hanle of the request to cancel
  74300. */
  74301. cancelAnimationFrame(handle: number): void;
  74302. /**
  74303. * Stops presenting to the VRDisplay.
  74304. * @returns a promise to know when it stopped
  74305. */
  74306. exitPresent(): Promise<void>;
  74307. /**
  74308. * Return the current VREyeParameters for the given eye.
  74309. * @param whichEye Define the eye we want the parameter for
  74310. * @returns the eye parameters
  74311. */
  74312. getEyeParameters(whichEye: string): VREyeParameters;
  74313. /**
  74314. * Populates the passed VRFrameData with the information required to render
  74315. * the current frame.
  74316. * @param frameData Define the data structure to populate
  74317. * @returns true if ok otherwise false
  74318. */
  74319. getFrameData(frameData: VRFrameData): boolean;
  74320. /**
  74321. * Get the layers currently being presented.
  74322. * @returns the list of VR layers
  74323. */
  74324. getLayers(): VRLayer[];
  74325. /**
  74326. * Return a VRPose containing the future predicted pose of the VRDisplay
  74327. * when the current frame will be presented. The value returned will not
  74328. * change until JavaScript has returned control to the browser.
  74329. *
  74330. * The VRPose will contain the position, orientation, velocity,
  74331. * and acceleration of each of these properties.
  74332. * @returns the pose object
  74333. */
  74334. getPose(): VRPose;
  74335. /**
  74336. * Return the current instantaneous pose of the VRDisplay, with no
  74337. * prediction applied.
  74338. * @returns the current instantaneous pose
  74339. */
  74340. getImmediatePose(): VRPose;
  74341. /**
  74342. * The callback passed to `requestAnimationFrame` will be called
  74343. * any time a new frame should be rendered. When the VRDisplay is
  74344. * presenting the callback will be called at the native refresh
  74345. * rate of the HMD. When not presenting this function acts
  74346. * identically to how window.requestAnimationFrame acts. Content should
  74347. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74348. * asynchronously from other displays and at differing refresh rates.
  74349. * @param callback Define the eaction to run next frame
  74350. * @returns the request handle it
  74351. */
  74352. requestAnimationFrame(callback: FrameRequestCallback): number;
  74353. /**
  74354. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74355. * Repeat calls while already presenting will update the VRLayers being displayed.
  74356. * @param layers Define the list of layer to present
  74357. * @returns a promise to know when the request has been fulfilled
  74358. */
  74359. requestPresent(layers: VRLayer[]): Promise<void>;
  74360. /**
  74361. * Reset the pose for this display, treating its current position and
  74362. * orientation as the "origin/zero" values. VRPose.position,
  74363. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74364. * updated when calling resetPose(). This should be called in only
  74365. * sitting-space experiences.
  74366. */
  74367. resetPose(): void;
  74368. /**
  74369. * The VRLayer provided to the VRDisplay will be captured and presented
  74370. * in the HMD. Calling this function has the same effect on the source
  74371. * canvas as any other operation that uses its source image, and canvases
  74372. * created without preserveDrawingBuffer set to true will be cleared.
  74373. * @param pose Define the pose to submit
  74374. */
  74375. submitFrame(pose?: VRPose): void;
  74376. }
  74377. declare var VRDisplay: {
  74378. prototype: VRDisplay;
  74379. new(): VRDisplay;
  74380. };
  74381. interface VRLayer {
  74382. leftBounds?: number[] | Float32Array | null;
  74383. rightBounds?: number[] | Float32Array | null;
  74384. source?: HTMLCanvasElement | null;
  74385. }
  74386. interface VRDisplayCapabilities {
  74387. readonly canPresent: boolean;
  74388. readonly hasExternalDisplay: boolean;
  74389. readonly hasOrientation: boolean;
  74390. readonly hasPosition: boolean;
  74391. readonly maxLayers: number;
  74392. }
  74393. interface VREyeParameters {
  74394. /** @deprecated */
  74395. readonly fieldOfView: VRFieldOfView;
  74396. readonly offset: Float32Array;
  74397. readonly renderHeight: number;
  74398. readonly renderWidth: number;
  74399. }
  74400. interface VRFieldOfView {
  74401. readonly downDegrees: number;
  74402. readonly leftDegrees: number;
  74403. readonly rightDegrees: number;
  74404. readonly upDegrees: number;
  74405. }
  74406. interface VRFrameData {
  74407. readonly leftProjectionMatrix: Float32Array;
  74408. readonly leftViewMatrix: Float32Array;
  74409. readonly pose: VRPose;
  74410. readonly rightProjectionMatrix: Float32Array;
  74411. readonly rightViewMatrix: Float32Array;
  74412. readonly timestamp: number;
  74413. }
  74414. interface VRPose {
  74415. readonly angularAcceleration: Float32Array | null;
  74416. readonly angularVelocity: Float32Array | null;
  74417. readonly linearAcceleration: Float32Array | null;
  74418. readonly linearVelocity: Float32Array | null;
  74419. readonly orientation: Float32Array | null;
  74420. readonly position: Float32Array | null;
  74421. readonly timestamp: number;
  74422. }
  74423. interface VRStageParameters {
  74424. sittingToStandingTransform?: Float32Array;
  74425. sizeX?: number;
  74426. sizeY?: number;
  74427. }
  74428. interface Navigator {
  74429. getVRDisplays(): Promise<VRDisplay[]>;
  74430. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74431. }
  74432. interface Window {
  74433. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74434. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74435. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74436. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74437. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74438. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74439. }
  74440. interface Gamepad {
  74441. readonly displayId: number;
  74442. }
  74443. type XRSessionMode =
  74444. | "inline"
  74445. | "immersive-vr"
  74446. | "immersive-ar";
  74447. type XRReferenceSpaceType =
  74448. | "viewer"
  74449. | "local"
  74450. | "local-floor"
  74451. | "bounded-floor"
  74452. | "unbounded";
  74453. type XREnvironmentBlendMode =
  74454. | "opaque"
  74455. | "additive"
  74456. | "alpha-blend";
  74457. type XRVisibilityState =
  74458. | "visible"
  74459. | "visible-blurred"
  74460. | "hidden";
  74461. type XRHandedness =
  74462. | "none"
  74463. | "left"
  74464. | "right";
  74465. type XRTargetRayMode =
  74466. | "gaze"
  74467. | "tracked-pointer"
  74468. | "screen";
  74469. type XREye =
  74470. | "none"
  74471. | "left"
  74472. | "right";
  74473. type XREventType =
  74474. | "devicechange"
  74475. | "visibilitychange"
  74476. | "end"
  74477. | "inputsourceschange"
  74478. | "select"
  74479. | "selectstart"
  74480. | "selectend"
  74481. | "squeeze"
  74482. | "squeezestart"
  74483. | "squeezeend"
  74484. | "reset";
  74485. interface XRSpace extends EventTarget {
  74486. }
  74487. interface XRRenderState {
  74488. depthNear?: number;
  74489. depthFar?: number;
  74490. inlineVerticalFieldOfView?: number;
  74491. baseLayer?: XRWebGLLayer;
  74492. }
  74493. interface XRInputSource {
  74494. handedness: XRHandedness;
  74495. targetRayMode: XRTargetRayMode;
  74496. targetRaySpace: XRSpace;
  74497. gripSpace: XRSpace | undefined;
  74498. gamepad: Gamepad | undefined;
  74499. profiles: Array<string>;
  74500. }
  74501. interface XRSessionInit {
  74502. optionalFeatures?: string[];
  74503. requiredFeatures?: string[];
  74504. }
  74505. interface XRSession {
  74506. addEventListener: Function;
  74507. removeEventListener: Function;
  74508. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74509. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74510. requestAnimationFrame: Function;
  74511. end(): Promise<void>;
  74512. renderState: XRRenderState;
  74513. inputSources: Array<XRInputSource>;
  74514. // hit test
  74515. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74516. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74517. // legacy AR hit test
  74518. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74519. // legacy plane detection
  74520. updateWorldTrackingState(options: {
  74521. planeDetectionState?: { enabled: boolean; }
  74522. }): void;
  74523. }
  74524. interface XRReferenceSpace extends XRSpace {
  74525. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74526. onreset: any;
  74527. }
  74528. type XRPlaneSet = Set<XRPlane>;
  74529. type XRAnchorSet = Set<XRAnchor>;
  74530. interface XRFrame {
  74531. session: XRSession;
  74532. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74533. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74534. // AR
  74535. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74536. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74537. // Anchors
  74538. trackedAnchors?: XRAnchorSet;
  74539. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74540. // Planes
  74541. worldInformation: {
  74542. detectedPlanes?: XRPlaneSet;
  74543. };
  74544. }
  74545. interface XRViewerPose extends XRPose {
  74546. views: Array<XRView>;
  74547. }
  74548. interface XRPose {
  74549. transform: XRRigidTransform;
  74550. emulatedPosition: boolean;
  74551. }
  74552. interface XRWebGLLayerOptions {
  74553. antialias?: boolean;
  74554. depth?: boolean;
  74555. stencil?: boolean;
  74556. alpha?: boolean;
  74557. multiview?: boolean;
  74558. framebufferScaleFactor?: number;
  74559. }
  74560. declare var XRWebGLLayer: {
  74561. prototype: XRWebGLLayer;
  74562. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74563. };
  74564. interface XRWebGLLayer {
  74565. framebuffer: WebGLFramebuffer;
  74566. framebufferWidth: number;
  74567. framebufferHeight: number;
  74568. getViewport: Function;
  74569. }
  74570. declare class XRRigidTransform {
  74571. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74572. position: DOMPointReadOnly;
  74573. orientation: DOMPointReadOnly;
  74574. matrix: Float32Array;
  74575. inverse: XRRigidTransform;
  74576. }
  74577. interface XRView {
  74578. eye: XREye;
  74579. projectionMatrix: Float32Array;
  74580. transform: XRRigidTransform;
  74581. }
  74582. interface XRInputSourceChangeEvent {
  74583. session: XRSession;
  74584. removed: Array<XRInputSource>;
  74585. added: Array<XRInputSource>;
  74586. }
  74587. interface XRInputSourceEvent extends Event {
  74588. readonly frame: XRFrame;
  74589. readonly inputSource: XRInputSource;
  74590. }
  74591. // Experimental(er) features
  74592. declare class XRRay {
  74593. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74594. origin: DOMPointReadOnly;
  74595. direction: DOMPointReadOnly;
  74596. matrix: Float32Array;
  74597. }
  74598. declare enum XRHitTestTrackableType {
  74599. "point",
  74600. "plane"
  74601. }
  74602. interface XRHitResult {
  74603. hitMatrix: Float32Array;
  74604. }
  74605. interface XRTransientInputHitTestResult {
  74606. readonly inputSource: XRInputSource;
  74607. readonly results: Array<XRHitTestResult>;
  74608. }
  74609. interface XRHitTestResult {
  74610. getPose(baseSpace: XRSpace): XRPose | undefined;
  74611. // When anchor system is enabled
  74612. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74613. }
  74614. interface XRHitTestSource {
  74615. cancel(): void;
  74616. }
  74617. interface XRTransientInputHitTestSource {
  74618. cancel(): void;
  74619. }
  74620. interface XRHitTestOptionsInit {
  74621. space: XRSpace;
  74622. entityTypes?: Array<XRHitTestTrackableType>;
  74623. offsetRay?: XRRay;
  74624. }
  74625. interface XRTransientInputHitTestOptionsInit {
  74626. profile: string;
  74627. entityTypes?: Array<XRHitTestTrackableType>;
  74628. offsetRay?: XRRay;
  74629. }
  74630. interface XRAnchor {
  74631. anchorSpace: XRSpace;
  74632. delete(): void;
  74633. }
  74634. interface XRPlane {
  74635. orientation: "Horizontal" | "Vertical";
  74636. planeSpace: XRSpace;
  74637. polygon: Array<DOMPointReadOnly>;
  74638. lastChangedTime: number;
  74639. }
  74640. /**
  74641. * @ignore
  74642. */
  74643. declare module BABYLON.GLTF2.Exporter {
  74644. }
  74645. /**
  74646. * @ignore
  74647. */
  74648. declare module BABYLON.GLTF1 {
  74649. }
  74650. declare module BABYLON.GUI {
  74651. /**
  74652. * Class used to specific a value and its associated unit
  74653. */
  74654. export class ValueAndUnit {
  74655. /** defines the unit to store */
  74656. unit: number;
  74657. /** defines a boolean indicating if the value can be negative */
  74658. negativeValueAllowed: boolean;
  74659. private _value;
  74660. private _originalUnit;
  74661. /**
  74662. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74663. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74664. */
  74665. ignoreAdaptiveScaling: boolean;
  74666. /**
  74667. * Creates a new ValueAndUnit
  74668. * @param value defines the value to store
  74669. * @param unit defines the unit to store
  74670. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74671. */
  74672. constructor(value: number,
  74673. /** defines the unit to store */
  74674. unit?: number,
  74675. /** defines a boolean indicating if the value can be negative */
  74676. negativeValueAllowed?: boolean);
  74677. /** Gets a boolean indicating if the value is a percentage */
  74678. get isPercentage(): boolean;
  74679. /** Gets a boolean indicating if the value is store as pixel */
  74680. get isPixel(): boolean;
  74681. /** Gets direct internal value */
  74682. get internalValue(): number;
  74683. /**
  74684. * Gets value as pixel
  74685. * @param host defines the root host
  74686. * @param refValue defines the reference value for percentages
  74687. * @returns the value as pixel
  74688. */
  74689. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74690. /**
  74691. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74692. * @param value defines the value to store
  74693. * @param unit defines the unit to store
  74694. * @returns the current ValueAndUnit
  74695. */
  74696. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74697. /**
  74698. * Gets the value accordingly to its unit
  74699. * @param host defines the root host
  74700. * @returns the value
  74701. */
  74702. getValue(host: AdvancedDynamicTexture): number;
  74703. /**
  74704. * Gets a string representation of the value
  74705. * @param host defines the root host
  74706. * @param decimals defines an optional number of decimals to display
  74707. * @returns a string
  74708. */
  74709. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74710. /**
  74711. * Store a value parsed from a string
  74712. * @param source defines the source string
  74713. * @returns true if the value was successfully parsed
  74714. */
  74715. fromString(source: string | number): boolean;
  74716. private static _Regex;
  74717. private static _UNITMODE_PERCENTAGE;
  74718. private static _UNITMODE_PIXEL;
  74719. /** UNITMODE_PERCENTAGE */
  74720. static get UNITMODE_PERCENTAGE(): number;
  74721. /** UNITMODE_PIXEL */
  74722. static get UNITMODE_PIXEL(): number;
  74723. }
  74724. }
  74725. declare module BABYLON.GUI {
  74726. /**
  74727. * Define a style used by control to automatically setup properties based on a template.
  74728. * Only support font related properties so far
  74729. */
  74730. export class Style implements BABYLON.IDisposable {
  74731. private _fontFamily;
  74732. private _fontStyle;
  74733. private _fontWeight;
  74734. /** @hidden */
  74735. _host: AdvancedDynamicTexture;
  74736. /** @hidden */
  74737. _fontSize: ValueAndUnit;
  74738. /**
  74739. * BABYLON.Observable raised when the style values are changed
  74740. */
  74741. onChangedObservable: BABYLON.Observable<Style>;
  74742. /**
  74743. * Creates a new style object
  74744. * @param host defines the AdvancedDynamicTexture which hosts this style
  74745. */
  74746. constructor(host: AdvancedDynamicTexture);
  74747. /**
  74748. * Gets or sets the font size
  74749. */
  74750. get fontSize(): string | number;
  74751. set fontSize(value: string | number);
  74752. /**
  74753. * Gets or sets the font family
  74754. */
  74755. get fontFamily(): string;
  74756. set fontFamily(value: string);
  74757. /**
  74758. * Gets or sets the font style
  74759. */
  74760. get fontStyle(): string;
  74761. set fontStyle(value: string);
  74762. /** Gets or sets font weight */
  74763. get fontWeight(): string;
  74764. set fontWeight(value: string);
  74765. /** Dispose all associated resources */
  74766. dispose(): void;
  74767. }
  74768. }
  74769. declare module BABYLON.GUI {
  74770. /**
  74771. * Class used to transport BABYLON.Vector2 information for pointer events
  74772. */
  74773. export class Vector2WithInfo extends BABYLON.Vector2 {
  74774. /** defines the current mouse button index */
  74775. buttonIndex: number;
  74776. /**
  74777. * Creates a new Vector2WithInfo
  74778. * @param source defines the vector2 data to transport
  74779. * @param buttonIndex defines the current mouse button index
  74780. */
  74781. constructor(source: BABYLON.Vector2,
  74782. /** defines the current mouse button index */
  74783. buttonIndex?: number);
  74784. }
  74785. /** Class used to provide 2D matrix features */
  74786. export class Matrix2D {
  74787. /** Gets the internal array of 6 floats used to store matrix data */
  74788. m: Float32Array;
  74789. /**
  74790. * Creates a new matrix
  74791. * @param m00 defines value for (0, 0)
  74792. * @param m01 defines value for (0, 1)
  74793. * @param m10 defines value for (1, 0)
  74794. * @param m11 defines value for (1, 1)
  74795. * @param m20 defines value for (2, 0)
  74796. * @param m21 defines value for (2, 1)
  74797. */
  74798. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74799. /**
  74800. * Fills the matrix from direct values
  74801. * @param m00 defines value for (0, 0)
  74802. * @param m01 defines value for (0, 1)
  74803. * @param m10 defines value for (1, 0)
  74804. * @param m11 defines value for (1, 1)
  74805. * @param m20 defines value for (2, 0)
  74806. * @param m21 defines value for (2, 1)
  74807. * @returns the current modified matrix
  74808. */
  74809. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74810. /**
  74811. * Gets matrix determinant
  74812. * @returns the determinant
  74813. */
  74814. determinant(): number;
  74815. /**
  74816. * Inverses the matrix and stores it in a target matrix
  74817. * @param result defines the target matrix
  74818. * @returns the current matrix
  74819. */
  74820. invertToRef(result: Matrix2D): Matrix2D;
  74821. /**
  74822. * Multiplies the current matrix with another one
  74823. * @param other defines the second operand
  74824. * @param result defines the target matrix
  74825. * @returns the current matrix
  74826. */
  74827. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74828. /**
  74829. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74830. * @param x defines the x coordinate to transform
  74831. * @param y defines the x coordinate to transform
  74832. * @param result defines the target vector2
  74833. * @returns the current matrix
  74834. */
  74835. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74836. /**
  74837. * Creates an identity matrix
  74838. * @returns a new matrix
  74839. */
  74840. static Identity(): Matrix2D;
  74841. /**
  74842. * Creates a translation matrix and stores it in a target matrix
  74843. * @param x defines the x coordinate of the translation
  74844. * @param y defines the y coordinate of the translation
  74845. * @param result defines the target matrix
  74846. */
  74847. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74848. /**
  74849. * Creates a scaling matrix and stores it in a target matrix
  74850. * @param x defines the x coordinate of the scaling
  74851. * @param y defines the y coordinate of the scaling
  74852. * @param result defines the target matrix
  74853. */
  74854. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74855. /**
  74856. * Creates a rotation matrix and stores it in a target matrix
  74857. * @param angle defines the rotation angle
  74858. * @param result defines the target matrix
  74859. */
  74860. static RotationToRef(angle: number, result: Matrix2D): void;
  74861. private static _TempPreTranslationMatrix;
  74862. private static _TempPostTranslationMatrix;
  74863. private static _TempRotationMatrix;
  74864. private static _TempScalingMatrix;
  74865. private static _TempCompose0;
  74866. private static _TempCompose1;
  74867. private static _TempCompose2;
  74868. /**
  74869. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74870. * @param tx defines the x coordinate of the translation
  74871. * @param ty defines the y coordinate of the translation
  74872. * @param angle defines the rotation angle
  74873. * @param scaleX defines the x coordinate of the scaling
  74874. * @param scaleY defines the y coordinate of the scaling
  74875. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74876. * @param result defines the target matrix
  74877. */
  74878. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74879. }
  74880. }
  74881. declare module BABYLON.GUI {
  74882. /**
  74883. * Class used to store 2D control sizes
  74884. */
  74885. export class Measure {
  74886. /** defines left coordinate */
  74887. left: number;
  74888. /** defines top coordinate */
  74889. top: number;
  74890. /** defines width dimension */
  74891. width: number;
  74892. /** defines height dimension */
  74893. height: number;
  74894. /**
  74895. * Creates a new measure
  74896. * @param left defines left coordinate
  74897. * @param top defines top coordinate
  74898. * @param width defines width dimension
  74899. * @param height defines height dimension
  74900. */
  74901. constructor(
  74902. /** defines left coordinate */
  74903. left: number,
  74904. /** defines top coordinate */
  74905. top: number,
  74906. /** defines width dimension */
  74907. width: number,
  74908. /** defines height dimension */
  74909. height: number);
  74910. /**
  74911. * Copy from another measure
  74912. * @param other defines the other measure to copy from
  74913. */
  74914. copyFrom(other: Measure): void;
  74915. /**
  74916. * Copy from a group of 4 floats
  74917. * @param left defines left coordinate
  74918. * @param top defines top coordinate
  74919. * @param width defines width dimension
  74920. * @param height defines height dimension
  74921. */
  74922. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74923. /**
  74924. * Computes the axis aligned bounding box measure for two given measures
  74925. * @param a Input measure
  74926. * @param b Input measure
  74927. * @param result the resulting bounding measure
  74928. */
  74929. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74930. /**
  74931. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74932. * @param transform the matrix to transform the measure before computing the AABB
  74933. * @param result the resulting AABB
  74934. */
  74935. transformToRef(transform: Matrix2D, result: Measure): void;
  74936. /**
  74937. * Check equality between this measure and another one
  74938. * @param other defines the other measures
  74939. * @returns true if both measures are equals
  74940. */
  74941. isEqualsTo(other: Measure): boolean;
  74942. /**
  74943. * Creates an empty measure
  74944. * @returns a new measure
  74945. */
  74946. static Empty(): Measure;
  74947. }
  74948. }
  74949. declare module BABYLON.GUI {
  74950. /**
  74951. * Interface used to define a control that can receive focus
  74952. */
  74953. export interface IFocusableControl {
  74954. /**
  74955. * Function called when the control receives the focus
  74956. */
  74957. onFocus(): void;
  74958. /**
  74959. * Function called when the control loses the focus
  74960. */
  74961. onBlur(): void;
  74962. /**
  74963. * Function called to let the control handle keyboard events
  74964. * @param evt defines the current keyboard event
  74965. */
  74966. processKeyboard(evt: KeyboardEvent): void;
  74967. /**
  74968. * Function called to get the list of controls that should not steal the focus from this control
  74969. * @returns an array of controls
  74970. */
  74971. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74972. }
  74973. /**
  74974. * Class used to create texture to support 2D GUI elements
  74975. * @see https://doc.babylonjs.com/how_to/gui
  74976. */
  74977. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74978. private _isDirty;
  74979. private _renderObserver;
  74980. private _resizeObserver;
  74981. private _preKeyboardObserver;
  74982. private _pointerMoveObserver;
  74983. private _pointerObserver;
  74984. private _canvasPointerOutObserver;
  74985. private _background;
  74986. /** @hidden */
  74987. _rootContainer: Container;
  74988. /** @hidden */
  74989. _lastPickedControl: Control;
  74990. /** @hidden */
  74991. _lastControlOver: {
  74992. [pointerId: number]: Control;
  74993. };
  74994. /** @hidden */
  74995. _lastControlDown: {
  74996. [pointerId: number]: Control;
  74997. };
  74998. /** @hidden */
  74999. _capturingControl: {
  75000. [pointerId: number]: Control;
  75001. };
  75002. /** @hidden */
  75003. _shouldBlockPointer: boolean;
  75004. /** @hidden */
  75005. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75006. /** @hidden */
  75007. _linkedControls: Control[];
  75008. private _isFullscreen;
  75009. private _fullscreenViewport;
  75010. private _idealWidth;
  75011. private _idealHeight;
  75012. private _useSmallestIdeal;
  75013. private _renderAtIdealSize;
  75014. private _focusedControl;
  75015. private _blockNextFocusCheck;
  75016. private _renderScale;
  75017. private _rootElement;
  75018. private _cursorChanged;
  75019. private _defaultMousePointerId;
  75020. /** @hidden */
  75021. _numLayoutCalls: number;
  75022. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75023. get numLayoutCalls(): number;
  75024. /** @hidden */
  75025. _numRenderCalls: number;
  75026. /** Gets the number of render calls made the last time the ADT has been rendered */
  75027. get numRenderCalls(): number;
  75028. /**
  75029. * Define type to string to ensure compatibility across browsers
  75030. * Safari doesn't support DataTransfer constructor
  75031. */
  75032. private _clipboardData;
  75033. /**
  75034. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75035. */
  75036. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75037. /**
  75038. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75039. */
  75040. onControlPickedObservable: BABYLON.Observable<Control>;
  75041. /**
  75042. * BABYLON.Observable event triggered before layout is evaluated
  75043. */
  75044. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75045. /**
  75046. * BABYLON.Observable event triggered after the layout was evaluated
  75047. */
  75048. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75049. /**
  75050. * BABYLON.Observable event triggered before the texture is rendered
  75051. */
  75052. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75053. /**
  75054. * BABYLON.Observable event triggered after the texture was rendered
  75055. */
  75056. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75057. /**
  75058. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75059. */
  75060. premulAlpha: boolean;
  75061. /**
  75062. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75063. * Useful when you want more antialiasing
  75064. */
  75065. get renderScale(): number;
  75066. set renderScale(value: number);
  75067. /** Gets or sets the background color */
  75068. get background(): string;
  75069. set background(value: string);
  75070. /**
  75071. * Gets or sets the ideal width used to design controls.
  75072. * The GUI will then rescale everything accordingly
  75073. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75074. */
  75075. get idealWidth(): number;
  75076. set idealWidth(value: number);
  75077. /**
  75078. * Gets or sets the ideal height used to design controls.
  75079. * The GUI will then rescale everything accordingly
  75080. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75081. */
  75082. get idealHeight(): number;
  75083. set idealHeight(value: number);
  75084. /**
  75085. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75086. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75087. */
  75088. get useSmallestIdeal(): boolean;
  75089. set useSmallestIdeal(value: boolean);
  75090. /**
  75091. * Gets or sets a boolean indicating if adaptive scaling must be used
  75092. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75093. */
  75094. get renderAtIdealSize(): boolean;
  75095. set renderAtIdealSize(value: boolean);
  75096. /**
  75097. * Gets the ratio used when in "ideal mode"
  75098. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75099. * */
  75100. get idealRatio(): number;
  75101. /**
  75102. * Gets the underlying layer used to render the texture when in fullscreen mode
  75103. */
  75104. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75105. /**
  75106. * Gets the root container control
  75107. */
  75108. get rootContainer(): Container;
  75109. /**
  75110. * Returns an array containing the root container.
  75111. * This is mostly used to let the Inspector introspects the ADT
  75112. * @returns an array containing the rootContainer
  75113. */
  75114. getChildren(): Array<Container>;
  75115. /**
  75116. * Will return all controls that are inside this texture
  75117. * @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
  75118. * @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
  75119. * @return all child controls
  75120. */
  75121. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75122. /**
  75123. * Gets or sets the current focused control
  75124. */
  75125. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75126. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75127. /**
  75128. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75129. */
  75130. get isForeground(): boolean;
  75131. set isForeground(value: boolean);
  75132. /**
  75133. * Gets or set information about clipboardData
  75134. */
  75135. get clipboardData(): string;
  75136. set clipboardData(value: string);
  75137. /**
  75138. * Creates a new AdvancedDynamicTexture
  75139. * @param name defines the name of the texture
  75140. * @param width defines the width of the texture
  75141. * @param height defines the height of the texture
  75142. * @param scene defines the hosting scene
  75143. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75144. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75145. */
  75146. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75147. /**
  75148. * Get the current class name of the texture useful for serialization or dynamic coding.
  75149. * @returns "AdvancedDynamicTexture"
  75150. */
  75151. getClassName(): string;
  75152. /**
  75153. * Function used to execute a function on all controls
  75154. * @param func defines the function to execute
  75155. * @param container defines the container where controls belong. If null the root container will be used
  75156. */
  75157. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75158. private _useInvalidateRectOptimization;
  75159. /**
  75160. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75161. */
  75162. get useInvalidateRectOptimization(): boolean;
  75163. set useInvalidateRectOptimization(value: boolean);
  75164. private _invalidatedRectangle;
  75165. /**
  75166. * Invalidates a rectangle area on the gui texture
  75167. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75168. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75169. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75170. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75171. */
  75172. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75173. /**
  75174. * Marks the texture as dirty forcing a complete update
  75175. */
  75176. markAsDirty(): void;
  75177. /**
  75178. * Helper function used to create a new style
  75179. * @returns a new style
  75180. * @see https://doc.babylonjs.com/how_to/gui#styles
  75181. */
  75182. createStyle(): Style;
  75183. /**
  75184. * Adds a new control to the root container
  75185. * @param control defines the control to add
  75186. * @returns the current texture
  75187. */
  75188. addControl(control: Control): AdvancedDynamicTexture;
  75189. /**
  75190. * Removes a control from the root container
  75191. * @param control defines the control to remove
  75192. * @returns the current texture
  75193. */
  75194. removeControl(control: Control): AdvancedDynamicTexture;
  75195. /**
  75196. * Release all resources
  75197. */
  75198. dispose(): void;
  75199. private _onResize;
  75200. /** @hidden */
  75201. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75202. /**
  75203. * Get screen coordinates for a vector3
  75204. * @param position defines the position to project
  75205. * @param worldMatrix defines the world matrix to use
  75206. * @returns the projected position
  75207. */
  75208. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75209. private _checkUpdate;
  75210. private _clearMeasure;
  75211. private _render;
  75212. /** @hidden */
  75213. _changeCursor(cursor: string): void;
  75214. /** @hidden */
  75215. _registerLastControlDown(control: Control, pointerId: number): void;
  75216. private _doPicking;
  75217. /** @hidden */
  75218. _cleanControlAfterRemovalFromList(list: {
  75219. [pointerId: number]: Control;
  75220. }, control: Control): void;
  75221. /** @hidden */
  75222. _cleanControlAfterRemoval(control: Control): void;
  75223. /** Attach to all scene events required to support pointer events */
  75224. attach(): void;
  75225. /** @hidden */
  75226. private onClipboardCopy;
  75227. /** @hidden */
  75228. private onClipboardCut;
  75229. /** @hidden */
  75230. private onClipboardPaste;
  75231. /**
  75232. * Register the clipboard Events onto the canvas
  75233. */
  75234. registerClipboardEvents(): void;
  75235. /**
  75236. * Unregister the clipboard Events from the canvas
  75237. */
  75238. unRegisterClipboardEvents(): void;
  75239. /**
  75240. * Connect the texture to a hosting mesh to enable interactions
  75241. * @param mesh defines the mesh to attach to
  75242. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75243. */
  75244. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75245. /**
  75246. * Move the focus to a specific control
  75247. * @param control defines the control which will receive the focus
  75248. */
  75249. moveFocusToControl(control: IFocusableControl): void;
  75250. private _manageFocus;
  75251. private _attachToOnPointerOut;
  75252. /**
  75253. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75254. * @param mesh defines the mesh which will receive the texture
  75255. * @param width defines the texture width (1024 by default)
  75256. * @param height defines the texture height (1024 by default)
  75257. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75258. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75259. * @returns a new AdvancedDynamicTexture
  75260. */
  75261. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75262. /**
  75263. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75264. * In this mode the texture will rely on a layer for its rendering.
  75265. * This allows it to be treated like any other layer.
  75266. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75267. * LayerMask is set through advancedTexture.layer.layerMask
  75268. * @param name defines name for the texture
  75269. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75270. * @param scene defines the hsoting scene
  75271. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75272. * @returns a new AdvancedDynamicTexture
  75273. */
  75274. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75275. }
  75276. }
  75277. declare module BABYLON.GUI {
  75278. /**
  75279. * Root class used for all 2D controls
  75280. * @see https://doc.babylonjs.com/how_to/gui#controls
  75281. */
  75282. export class Control {
  75283. /** defines the name of the control */
  75284. name?: string | undefined;
  75285. /**
  75286. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75287. */
  75288. static AllowAlphaInheritance: boolean;
  75289. private _alpha;
  75290. private _alphaSet;
  75291. private _zIndex;
  75292. /** @hidden */
  75293. _host: AdvancedDynamicTexture;
  75294. /** Gets or sets the control parent */
  75295. parent: BABYLON.Nullable<Container>;
  75296. /** @hidden */
  75297. _currentMeasure: Measure;
  75298. private _fontFamily;
  75299. private _fontStyle;
  75300. private _fontWeight;
  75301. private _fontSize;
  75302. private _font;
  75303. /** @hidden */
  75304. _width: ValueAndUnit;
  75305. /** @hidden */
  75306. _height: ValueAndUnit;
  75307. /** @hidden */
  75308. protected _fontOffset: {
  75309. ascent: number;
  75310. height: number;
  75311. descent: number;
  75312. };
  75313. private _color;
  75314. private _style;
  75315. private _styleObserver;
  75316. /** @hidden */
  75317. protected _horizontalAlignment: number;
  75318. /** @hidden */
  75319. protected _verticalAlignment: number;
  75320. /** @hidden */
  75321. protected _isDirty: boolean;
  75322. /** @hidden */
  75323. protected _wasDirty: boolean;
  75324. /** @hidden */
  75325. _tempParentMeasure: Measure;
  75326. /** @hidden */
  75327. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75328. /** @hidden */
  75329. protected _cachedParentMeasure: Measure;
  75330. private _paddingLeft;
  75331. private _paddingRight;
  75332. private _paddingTop;
  75333. private _paddingBottom;
  75334. /** @hidden */
  75335. _left: ValueAndUnit;
  75336. /** @hidden */
  75337. _top: ValueAndUnit;
  75338. private _scaleX;
  75339. private _scaleY;
  75340. private _rotation;
  75341. private _transformCenterX;
  75342. private _transformCenterY;
  75343. /** @hidden */
  75344. _transformMatrix: Matrix2D;
  75345. /** @hidden */
  75346. protected _invertTransformMatrix: Matrix2D;
  75347. /** @hidden */
  75348. protected _transformedPosition: BABYLON.Vector2;
  75349. private _isMatrixDirty;
  75350. private _cachedOffsetX;
  75351. private _cachedOffsetY;
  75352. private _isVisible;
  75353. private _isHighlighted;
  75354. /** @hidden */
  75355. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75356. private _fontSet;
  75357. private _dummyVector2;
  75358. private _downCount;
  75359. private _enterCount;
  75360. private _doNotRender;
  75361. private _downPointerIds;
  75362. protected _isEnabled: boolean;
  75363. protected _disabledColor: string;
  75364. protected _disabledColorItem: string;
  75365. /** @hidden */
  75366. protected _rebuildLayout: boolean;
  75367. /** @hidden */
  75368. _customData: any;
  75369. /** @hidden */
  75370. _isClipped: boolean;
  75371. /** @hidden */
  75372. _automaticSize: boolean;
  75373. /** @hidden */
  75374. _tag: any;
  75375. /**
  75376. * 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
  75377. */
  75378. uniqueId: number;
  75379. /**
  75380. * Gets or sets an object used to store user defined information for the node
  75381. */
  75382. metadata: any;
  75383. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75384. isHitTestVisible: boolean;
  75385. /** Gets or sets a boolean indicating if the control can block pointer events */
  75386. isPointerBlocker: boolean;
  75387. /** Gets or sets a boolean indicating if the control can be focusable */
  75388. isFocusInvisible: boolean;
  75389. /**
  75390. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75391. * 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
  75392. */
  75393. clipChildren: boolean;
  75394. /**
  75395. * Gets or sets a boolean indicating that control content must be clipped
  75396. * 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
  75397. */
  75398. clipContent: boolean;
  75399. /**
  75400. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75401. */
  75402. useBitmapCache: boolean;
  75403. private _cacheData;
  75404. private _shadowOffsetX;
  75405. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75406. get shadowOffsetX(): number;
  75407. set shadowOffsetX(value: number);
  75408. private _shadowOffsetY;
  75409. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75410. get shadowOffsetY(): number;
  75411. set shadowOffsetY(value: number);
  75412. private _shadowBlur;
  75413. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75414. get shadowBlur(): number;
  75415. set shadowBlur(value: number);
  75416. private _shadowColor;
  75417. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75418. get shadowColor(): string;
  75419. set shadowColor(value: string);
  75420. /** Gets or sets the cursor to use when the control is hovered */
  75421. hoverCursor: string;
  75422. /** @hidden */
  75423. protected _linkOffsetX: ValueAndUnit;
  75424. /** @hidden */
  75425. protected _linkOffsetY: ValueAndUnit;
  75426. /** Gets the control type name */
  75427. get typeName(): string;
  75428. /**
  75429. * Get the current class name of the control.
  75430. * @returns current class name
  75431. */
  75432. getClassName(): string;
  75433. /**
  75434. * An event triggered when pointer wheel is scrolled
  75435. */
  75436. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75437. /**
  75438. * An event triggered when the pointer move over the control.
  75439. */
  75440. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75441. /**
  75442. * An event triggered when the pointer move out of the control.
  75443. */
  75444. onPointerOutObservable: BABYLON.Observable<Control>;
  75445. /**
  75446. * An event triggered when the pointer taps the control
  75447. */
  75448. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75449. /**
  75450. * An event triggered when pointer up
  75451. */
  75452. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75453. /**
  75454. * An event triggered when a control is clicked on
  75455. */
  75456. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75457. /**
  75458. * An event triggered when pointer enters the control
  75459. */
  75460. onPointerEnterObservable: BABYLON.Observable<Control>;
  75461. /**
  75462. * An event triggered when the control is marked as dirty
  75463. */
  75464. onDirtyObservable: BABYLON.Observable<Control>;
  75465. /**
  75466. * An event triggered before drawing the control
  75467. */
  75468. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75469. /**
  75470. * An event triggered after the control was drawn
  75471. */
  75472. onAfterDrawObservable: BABYLON.Observable<Control>;
  75473. /**
  75474. * An event triggered when the control has been disposed
  75475. */
  75476. onDisposeObservable: BABYLON.Observable<Control>;
  75477. /**
  75478. * Get the hosting AdvancedDynamicTexture
  75479. */
  75480. get host(): AdvancedDynamicTexture;
  75481. /** Gets or set information about font offsets (used to render and align text) */
  75482. get fontOffset(): {
  75483. ascent: number;
  75484. height: number;
  75485. descent: number;
  75486. };
  75487. set fontOffset(offset: {
  75488. ascent: number;
  75489. height: number;
  75490. descent: number;
  75491. });
  75492. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75493. get alpha(): number;
  75494. set alpha(value: number);
  75495. /**
  75496. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75497. */
  75498. get isHighlighted(): boolean;
  75499. set isHighlighted(value: boolean);
  75500. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75501. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75502. */
  75503. get scaleX(): number;
  75504. set scaleX(value: number);
  75505. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75506. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75507. */
  75508. get scaleY(): number;
  75509. set scaleY(value: number);
  75510. /** Gets or sets the rotation angle (0 by default)
  75511. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75512. */
  75513. get rotation(): number;
  75514. set rotation(value: number);
  75515. /** Gets or sets the transformation center on Y axis (0 by default)
  75516. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75517. */
  75518. get transformCenterY(): number;
  75519. set transformCenterY(value: number);
  75520. /** Gets or sets the transformation center on X axis (0 by default)
  75521. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75522. */
  75523. get transformCenterX(): number;
  75524. set transformCenterX(value: number);
  75525. /**
  75526. * Gets or sets the horizontal alignment
  75527. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75528. */
  75529. get horizontalAlignment(): number;
  75530. set horizontalAlignment(value: number);
  75531. /**
  75532. * Gets or sets the vertical alignment
  75533. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75534. */
  75535. get verticalAlignment(): number;
  75536. set verticalAlignment(value: number);
  75537. /**
  75538. * Gets or sets control width
  75539. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75540. */
  75541. get width(): string | number;
  75542. set width(value: string | number);
  75543. /**
  75544. * Gets or sets the control width in pixel
  75545. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75546. */
  75547. get widthInPixels(): number;
  75548. set widthInPixels(value: number);
  75549. /**
  75550. * Gets or sets control height
  75551. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75552. */
  75553. get height(): string | number;
  75554. set height(value: string | number);
  75555. /**
  75556. * Gets or sets control height in pixel
  75557. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75558. */
  75559. get heightInPixels(): number;
  75560. set heightInPixels(value: number);
  75561. /** Gets or set font family */
  75562. get fontFamily(): string;
  75563. set fontFamily(value: string);
  75564. /** Gets or sets font style */
  75565. get fontStyle(): string;
  75566. set fontStyle(value: string);
  75567. /** Gets or sets font weight */
  75568. get fontWeight(): string;
  75569. set fontWeight(value: string);
  75570. /**
  75571. * Gets or sets style
  75572. * @see https://doc.babylonjs.com/how_to/gui#styles
  75573. */
  75574. get style(): BABYLON.Nullable<Style>;
  75575. set style(value: BABYLON.Nullable<Style>);
  75576. /** @hidden */
  75577. get _isFontSizeInPercentage(): boolean;
  75578. /** Gets or sets font size in pixels */
  75579. get fontSizeInPixels(): number;
  75580. set fontSizeInPixels(value: number);
  75581. /** Gets or sets font size */
  75582. get fontSize(): string | number;
  75583. set fontSize(value: string | number);
  75584. /** Gets or sets foreground color */
  75585. get color(): string;
  75586. set color(value: string);
  75587. /** Gets or sets z index which is used to reorder controls on the z axis */
  75588. get zIndex(): number;
  75589. set zIndex(value: number);
  75590. /** Gets or sets a boolean indicating if the control can be rendered */
  75591. get notRenderable(): boolean;
  75592. set notRenderable(value: boolean);
  75593. /** Gets or sets a boolean indicating if the control is visible */
  75594. get isVisible(): boolean;
  75595. set isVisible(value: boolean);
  75596. /** Gets a boolean indicating that the control needs to update its rendering */
  75597. get isDirty(): boolean;
  75598. /**
  75599. * Gets the current linked mesh (or null if none)
  75600. */
  75601. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75602. /**
  75603. * Gets or sets a value indicating the padding to use on the left of the control
  75604. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75605. */
  75606. get paddingLeft(): string | number;
  75607. set paddingLeft(value: string | number);
  75608. /**
  75609. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75610. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75611. */
  75612. get paddingLeftInPixels(): number;
  75613. set paddingLeftInPixels(value: number);
  75614. /**
  75615. * Gets or sets a value indicating the padding to use on the right of the control
  75616. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75617. */
  75618. get paddingRight(): string | number;
  75619. set paddingRight(value: string | number);
  75620. /**
  75621. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75622. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75623. */
  75624. get paddingRightInPixels(): number;
  75625. set paddingRightInPixels(value: number);
  75626. /**
  75627. * Gets or sets a value indicating the padding to use on the top of the control
  75628. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75629. */
  75630. get paddingTop(): string | number;
  75631. set paddingTop(value: string | number);
  75632. /**
  75633. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75634. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75635. */
  75636. get paddingTopInPixels(): number;
  75637. set paddingTopInPixels(value: number);
  75638. /**
  75639. * Gets or sets a value indicating the padding to use on the bottom of the control
  75640. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75641. */
  75642. get paddingBottom(): string | number;
  75643. set paddingBottom(value: string | number);
  75644. /**
  75645. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75646. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75647. */
  75648. get paddingBottomInPixels(): number;
  75649. set paddingBottomInPixels(value: number);
  75650. /**
  75651. * Gets or sets a value indicating the left coordinate of the control
  75652. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75653. */
  75654. get left(): string | number;
  75655. set left(value: string | number);
  75656. /**
  75657. * Gets or sets a value indicating the left coordinate in pixels of the control
  75658. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75659. */
  75660. get leftInPixels(): number;
  75661. set leftInPixels(value: number);
  75662. /**
  75663. * Gets or sets a value indicating the top coordinate of the control
  75664. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75665. */
  75666. get top(): string | number;
  75667. set top(value: string | number);
  75668. /**
  75669. * Gets or sets a value indicating the top coordinate in pixels of the control
  75670. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75671. */
  75672. get topInPixels(): number;
  75673. set topInPixels(value: number);
  75674. /**
  75675. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75676. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75677. */
  75678. get linkOffsetX(): string | number;
  75679. set linkOffsetX(value: string | number);
  75680. /**
  75681. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75682. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75683. */
  75684. get linkOffsetXInPixels(): number;
  75685. set linkOffsetXInPixels(value: number);
  75686. /**
  75687. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75688. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75689. */
  75690. get linkOffsetY(): string | number;
  75691. set linkOffsetY(value: string | number);
  75692. /**
  75693. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75694. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75695. */
  75696. get linkOffsetYInPixels(): number;
  75697. set linkOffsetYInPixels(value: number);
  75698. /** Gets the center coordinate on X axis */
  75699. get centerX(): number;
  75700. /** Gets the center coordinate on Y axis */
  75701. get centerY(): number;
  75702. /** Gets or sets if control is Enabled*/
  75703. get isEnabled(): boolean;
  75704. set isEnabled(value: boolean);
  75705. /** Gets or sets background color of control if it's disabled*/
  75706. get disabledColor(): string;
  75707. set disabledColor(value: string);
  75708. /** Gets or sets front color of control if it's disabled*/
  75709. get disabledColorItem(): string;
  75710. set disabledColorItem(value: string);
  75711. /**
  75712. * Creates a new control
  75713. * @param name defines the name of the control
  75714. */
  75715. constructor(
  75716. /** defines the name of the control */
  75717. name?: string | undefined);
  75718. /** @hidden */
  75719. protected _getTypeName(): string;
  75720. /**
  75721. * Gets the first ascendant in the hierarchy of the given type
  75722. * @param className defines the required type
  75723. * @returns the ascendant or null if not found
  75724. */
  75725. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75726. /** @hidden */
  75727. _resetFontCache(): void;
  75728. /**
  75729. * Determines if a container is an ascendant of the current control
  75730. * @param container defines the container to look for
  75731. * @returns true if the container is one of the ascendant of the control
  75732. */
  75733. isAscendant(container: Control): boolean;
  75734. /**
  75735. * Gets coordinates in local control space
  75736. * @param globalCoordinates defines the coordinates to transform
  75737. * @returns the new coordinates in local space
  75738. */
  75739. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75740. /**
  75741. * Gets coordinates in local control space
  75742. * @param globalCoordinates defines the coordinates to transform
  75743. * @param result defines the target vector2 where to store the result
  75744. * @returns the current control
  75745. */
  75746. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75747. /**
  75748. * Gets coordinates in parent local control space
  75749. * @param globalCoordinates defines the coordinates to transform
  75750. * @returns the new coordinates in parent local space
  75751. */
  75752. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75753. /**
  75754. * Move the current control to a vector3 position projected onto the screen.
  75755. * @param position defines the target position
  75756. * @param scene defines the hosting scene
  75757. */
  75758. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75759. /**
  75760. * Will store all controls that have this control as ascendant in a given array
  75761. * @param results defines the array where to store the descendants
  75762. * @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
  75763. * @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
  75764. */
  75765. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75766. /**
  75767. * Will return all controls that have this control as ascendant
  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. * @return all child controls
  75771. */
  75772. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75773. /**
  75774. * Link current control with a target mesh
  75775. * @param mesh defines the mesh to link with
  75776. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75777. */
  75778. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75779. /** @hidden */
  75780. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75781. /** @hidden */
  75782. _offsetLeft(offset: number): void;
  75783. /** @hidden */
  75784. _offsetTop(offset: number): void;
  75785. /** @hidden */
  75786. _markMatrixAsDirty(): void;
  75787. /** @hidden */
  75788. _flagDescendantsAsMatrixDirty(): void;
  75789. /** @hidden */
  75790. _intersectsRect(rect: Measure): boolean;
  75791. /** @hidden */
  75792. protected invalidateRect(): void;
  75793. /** @hidden */
  75794. _markAsDirty(force?: boolean): void;
  75795. /** @hidden */
  75796. _markAllAsDirty(): void;
  75797. /** @hidden */
  75798. _link(host: AdvancedDynamicTexture): void;
  75799. /** @hidden */
  75800. protected _transform(context?: CanvasRenderingContext2D): void;
  75801. /** @hidden */
  75802. _renderHighlight(context: CanvasRenderingContext2D): void;
  75803. /** @hidden */
  75804. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75805. /** @hidden */
  75806. protected _applyStates(context: CanvasRenderingContext2D): void;
  75807. /** @hidden */
  75808. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75809. /** @hidden */
  75810. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75811. protected _evaluateClippingState(parentMeasure: Measure): void;
  75812. /** @hidden */
  75813. _measure(): void;
  75814. /** @hidden */
  75815. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75816. /** @hidden */
  75817. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75818. /** @hidden */
  75819. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75820. /** @hidden */
  75821. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75822. private static _ClipMeasure;
  75823. private _tmpMeasureA;
  75824. private _clip;
  75825. /** @hidden */
  75826. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75827. /** @hidden */
  75828. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75829. /**
  75830. * Tests if a given coordinates belong to the current control
  75831. * @param x defines x coordinate to test
  75832. * @param y defines y coordinate to test
  75833. * @returns true if the coordinates are inside the control
  75834. */
  75835. contains(x: number, y: number): boolean;
  75836. /** @hidden */
  75837. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75838. /** @hidden */
  75839. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75840. /** @hidden */
  75841. _onPointerEnter(target: Control): boolean;
  75842. /** @hidden */
  75843. _onPointerOut(target: Control, force?: boolean): void;
  75844. /** @hidden */
  75845. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75846. /** @hidden */
  75847. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75848. /** @hidden */
  75849. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75850. /** @hidden */
  75851. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75852. /** @hidden */
  75853. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75854. private _prepareFont;
  75855. /** Releases associated resources */
  75856. dispose(): void;
  75857. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75858. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75859. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75860. private static _VERTICAL_ALIGNMENT_TOP;
  75861. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75862. private static _VERTICAL_ALIGNMENT_CENTER;
  75863. /** HORIZONTAL_ALIGNMENT_LEFT */
  75864. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75865. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75866. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75867. /** HORIZONTAL_ALIGNMENT_CENTER */
  75868. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75869. /** VERTICAL_ALIGNMENT_TOP */
  75870. static get VERTICAL_ALIGNMENT_TOP(): number;
  75871. /** VERTICAL_ALIGNMENT_BOTTOM */
  75872. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75873. /** VERTICAL_ALIGNMENT_CENTER */
  75874. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75875. private static _FontHeightSizes;
  75876. /** @hidden */
  75877. static _GetFontOffset(font: string): {
  75878. ascent: number;
  75879. height: number;
  75880. descent: number;
  75881. };
  75882. /**
  75883. * Creates a stack panel that can be used to render headers
  75884. * @param control defines the control to associate with the header
  75885. * @param text defines the text of the header
  75886. * @param size defines the size of the header
  75887. * @param options defines options used to configure the header
  75888. * @returns a new StackPanel
  75889. * @ignore
  75890. * @hidden
  75891. */
  75892. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75893. isHorizontal: boolean;
  75894. controlFirst: boolean;
  75895. }) => any;
  75896. /** @hidden */
  75897. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75898. }
  75899. }
  75900. declare module BABYLON.GUI {
  75901. /**
  75902. * Root class for 2D containers
  75903. * @see https://doc.babylonjs.com/how_to/gui#containers
  75904. */
  75905. export class Container extends Control {
  75906. name?: string | undefined;
  75907. /** @hidden */
  75908. _children: Control[];
  75909. /** @hidden */
  75910. protected _measureForChildren: Measure;
  75911. /** @hidden */
  75912. protected _background: string;
  75913. /** @hidden */
  75914. protected _adaptWidthToChildren: boolean;
  75915. /** @hidden */
  75916. protected _adaptHeightToChildren: boolean;
  75917. /**
  75918. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75919. */
  75920. logLayoutCycleErrors: boolean;
  75921. /**
  75922. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75923. */
  75924. maxLayoutCycle: number;
  75925. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75926. get adaptHeightToChildren(): boolean;
  75927. set adaptHeightToChildren(value: boolean);
  75928. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75929. get adaptWidthToChildren(): boolean;
  75930. set adaptWidthToChildren(value: boolean);
  75931. /** Gets or sets background color */
  75932. get background(): string;
  75933. set background(value: string);
  75934. /** Gets the list of children */
  75935. get children(): Control[];
  75936. /**
  75937. * Creates a new Container
  75938. * @param name defines the name of the container
  75939. */
  75940. constructor(name?: string | undefined);
  75941. protected _getTypeName(): string;
  75942. _flagDescendantsAsMatrixDirty(): void;
  75943. /**
  75944. * Gets a child using its name
  75945. * @param name defines the child name to look for
  75946. * @returns the child control if found
  75947. */
  75948. getChildByName(name: string): BABYLON.Nullable<Control>;
  75949. /**
  75950. * Gets a child using its type and its name
  75951. * @param name defines the child name to look for
  75952. * @param type defines the child type to look for
  75953. * @returns the child control if found
  75954. */
  75955. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75956. /**
  75957. * Search for a specific control in children
  75958. * @param control defines the control to look for
  75959. * @returns true if the control is in child list
  75960. */
  75961. containsControl(control: Control): boolean;
  75962. /**
  75963. * Adds a new control to the current container
  75964. * @param control defines the control to add
  75965. * @returns the current container
  75966. */
  75967. addControl(control: BABYLON.Nullable<Control>): Container;
  75968. /**
  75969. * Removes all controls from the current container
  75970. * @returns the current container
  75971. */
  75972. clearControls(): Container;
  75973. /**
  75974. * Removes a control from the current container
  75975. * @param control defines the control to remove
  75976. * @returns the current container
  75977. */
  75978. removeControl(control: Control): Container;
  75979. /** @hidden */
  75980. _reOrderControl(control: Control): void;
  75981. /** @hidden */
  75982. _offsetLeft(offset: number): void;
  75983. /** @hidden */
  75984. _offsetTop(offset: number): void;
  75985. /** @hidden */
  75986. _markAllAsDirty(): void;
  75987. /** @hidden */
  75988. protected _localDraw(context: CanvasRenderingContext2D): void;
  75989. /** @hidden */
  75990. _link(host: AdvancedDynamicTexture): void;
  75991. /** @hidden */
  75992. protected _beforeLayout(): void;
  75993. /** @hidden */
  75994. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75995. /** @hidden */
  75996. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75997. protected _postMeasure(): void;
  75998. /** @hidden */
  75999. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76000. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76001. /** @hidden */
  76002. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76003. /** @hidden */
  76004. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76005. /** Releases associated resources */
  76006. dispose(): void;
  76007. }
  76008. }
  76009. declare module BABYLON.GUI {
  76010. /** Class used to create rectangle container */
  76011. export class Rectangle extends Container {
  76012. name?: string | undefined;
  76013. private _thickness;
  76014. private _cornerRadius;
  76015. /** Gets or sets border thickness */
  76016. get thickness(): number;
  76017. set thickness(value: number);
  76018. /** Gets or sets the corner radius angle */
  76019. get cornerRadius(): number;
  76020. set cornerRadius(value: number);
  76021. /**
  76022. * Creates a new Rectangle
  76023. * @param name defines the control name
  76024. */
  76025. constructor(name?: string | undefined);
  76026. protected _getTypeName(): string;
  76027. protected _localDraw(context: CanvasRenderingContext2D): void;
  76028. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76029. private _drawRoundedRect;
  76030. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76031. }
  76032. }
  76033. declare module BABYLON.GUI {
  76034. /**
  76035. * Enum that determines the text-wrapping mode to use.
  76036. */
  76037. export enum TextWrapping {
  76038. /**
  76039. * Clip the text when it's larger than Control.width; this is the default mode.
  76040. */
  76041. Clip = 0,
  76042. /**
  76043. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76044. */
  76045. WordWrap = 1,
  76046. /**
  76047. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76048. */
  76049. Ellipsis = 2
  76050. }
  76051. /**
  76052. * Class used to create text block control
  76053. */
  76054. export class TextBlock extends Control {
  76055. /**
  76056. * Defines the name of the control
  76057. */
  76058. name?: string | undefined;
  76059. private _text;
  76060. private _textWrapping;
  76061. private _textHorizontalAlignment;
  76062. private _textVerticalAlignment;
  76063. private _lines;
  76064. private _resizeToFit;
  76065. private _lineSpacing;
  76066. private _outlineWidth;
  76067. private _outlineColor;
  76068. /**
  76069. * An event triggered after the text is changed
  76070. */
  76071. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76072. /**
  76073. * An event triggered after the text was broken up into lines
  76074. */
  76075. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76076. /**
  76077. * Function used to split a string into words. By default, a string is split at each space character found
  76078. */
  76079. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76080. /**
  76081. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76082. */
  76083. get lines(): any[];
  76084. /**
  76085. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76086. */
  76087. get resizeToFit(): boolean;
  76088. /**
  76089. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76090. */
  76091. set resizeToFit(value: boolean);
  76092. /**
  76093. * Gets or sets a boolean indicating if text must be wrapped
  76094. */
  76095. get textWrapping(): TextWrapping | boolean;
  76096. /**
  76097. * Gets or sets a boolean indicating if text must be wrapped
  76098. */
  76099. set textWrapping(value: TextWrapping | boolean);
  76100. /**
  76101. * Gets or sets text to display
  76102. */
  76103. get text(): string;
  76104. /**
  76105. * Gets or sets text to display
  76106. */
  76107. set text(value: string);
  76108. /**
  76109. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76110. */
  76111. get textHorizontalAlignment(): number;
  76112. /**
  76113. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76114. */
  76115. set textHorizontalAlignment(value: number);
  76116. /**
  76117. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76118. */
  76119. get textVerticalAlignment(): number;
  76120. /**
  76121. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76122. */
  76123. set textVerticalAlignment(value: number);
  76124. /**
  76125. * Gets or sets line spacing value
  76126. */
  76127. set lineSpacing(value: string | number);
  76128. /**
  76129. * Gets or sets line spacing value
  76130. */
  76131. get lineSpacing(): string | number;
  76132. /**
  76133. * Gets or sets outlineWidth of the text to display
  76134. */
  76135. get outlineWidth(): number;
  76136. /**
  76137. * Gets or sets outlineWidth of the text to display
  76138. */
  76139. set outlineWidth(value: number);
  76140. /**
  76141. * Gets or sets outlineColor of the text to display
  76142. */
  76143. get outlineColor(): string;
  76144. /**
  76145. * Gets or sets outlineColor of the text to display
  76146. */
  76147. set outlineColor(value: string);
  76148. /**
  76149. * Creates a new TextBlock object
  76150. * @param name defines the name of the control
  76151. * @param text defines the text to display (emptry string by default)
  76152. */
  76153. constructor(
  76154. /**
  76155. * Defines the name of the control
  76156. */
  76157. name?: string | undefined, text?: string);
  76158. protected _getTypeName(): string;
  76159. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76160. private _drawText;
  76161. /** @hidden */
  76162. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76163. protected _applyStates(context: CanvasRenderingContext2D): void;
  76164. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76165. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76166. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76167. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76168. protected _renderLines(context: CanvasRenderingContext2D): void;
  76169. /**
  76170. * Given a width constraint applied on the text block, find the expected height
  76171. * @returns expected height
  76172. */
  76173. computeExpectedHeight(): number;
  76174. dispose(): void;
  76175. }
  76176. }
  76177. declare module BABYLON.GUI {
  76178. /**
  76179. * Class used to create 2D images
  76180. */
  76181. export class Image extends Control {
  76182. name?: string | undefined;
  76183. private _workingCanvas;
  76184. private _domImage;
  76185. private _imageWidth;
  76186. private _imageHeight;
  76187. private _loaded;
  76188. private _stretch;
  76189. private _source;
  76190. private _autoScale;
  76191. private _sourceLeft;
  76192. private _sourceTop;
  76193. private _sourceWidth;
  76194. private _sourceHeight;
  76195. private _svgAttributesComputationCompleted;
  76196. private _isSVG;
  76197. private _cellWidth;
  76198. private _cellHeight;
  76199. private _cellId;
  76200. private _populateNinePatchSlicesFromImage;
  76201. private _sliceLeft;
  76202. private _sliceRight;
  76203. private _sliceTop;
  76204. private _sliceBottom;
  76205. private _detectPointerOnOpaqueOnly;
  76206. /**
  76207. * BABYLON.Observable notified when the content is loaded
  76208. */
  76209. onImageLoadedObservable: BABYLON.Observable<Image>;
  76210. /**
  76211. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76212. */
  76213. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76214. /**
  76215. * Gets a boolean indicating that the content is loaded
  76216. */
  76217. get isLoaded(): boolean;
  76218. /**
  76219. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76220. */
  76221. get populateNinePatchSlicesFromImage(): boolean;
  76222. set populateNinePatchSlicesFromImage(value: boolean);
  76223. /**
  76224. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76225. * Beware using this as this will comsume more memory as the image has to be stored twice
  76226. */
  76227. get detectPointerOnOpaqueOnly(): boolean;
  76228. set detectPointerOnOpaqueOnly(value: boolean);
  76229. /**
  76230. * Gets or sets the left value for slicing (9-patch)
  76231. */
  76232. get sliceLeft(): number;
  76233. set sliceLeft(value: number);
  76234. /**
  76235. * Gets or sets the right value for slicing (9-patch)
  76236. */
  76237. get sliceRight(): number;
  76238. set sliceRight(value: number);
  76239. /**
  76240. * Gets or sets the top value for slicing (9-patch)
  76241. */
  76242. get sliceTop(): number;
  76243. set sliceTop(value: number);
  76244. /**
  76245. * Gets or sets the bottom value for slicing (9-patch)
  76246. */
  76247. get sliceBottom(): number;
  76248. set sliceBottom(value: number);
  76249. /**
  76250. * Gets or sets the left coordinate in the source image
  76251. */
  76252. get sourceLeft(): number;
  76253. set sourceLeft(value: number);
  76254. /**
  76255. * Gets or sets the top coordinate in the source image
  76256. */
  76257. get sourceTop(): number;
  76258. set sourceTop(value: number);
  76259. /**
  76260. * Gets or sets the width to capture in the source image
  76261. */
  76262. get sourceWidth(): number;
  76263. set sourceWidth(value: number);
  76264. /**
  76265. * Gets or sets the height to capture in the source image
  76266. */
  76267. get sourceHeight(): number;
  76268. set sourceHeight(value: number);
  76269. /** Indicates if the format of the image is SVG */
  76270. get isSVG(): boolean;
  76271. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76272. get svgAttributesComputationCompleted(): boolean;
  76273. /**
  76274. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76275. * @see https://doc.babylonjs.com/how_to/gui#image
  76276. */
  76277. get autoScale(): boolean;
  76278. set autoScale(value: boolean);
  76279. /** Gets or sets the streching mode used by the image */
  76280. get stretch(): number;
  76281. set stretch(value: number);
  76282. /** @hidden */
  76283. _rotate90(n: number, preserveProperties?: boolean): Image;
  76284. private _handleRotationForSVGImage;
  76285. private _rotate90SourceProperties;
  76286. /**
  76287. * Gets or sets the internal DOM image used to render the control
  76288. */
  76289. set domImage(value: HTMLImageElement);
  76290. get domImage(): HTMLImageElement;
  76291. private _onImageLoaded;
  76292. private _extractNinePatchSliceDataFromImage;
  76293. /**
  76294. * Gets or sets image source url
  76295. */
  76296. set source(value: BABYLON.Nullable<string>);
  76297. /**
  76298. * Checks for svg document with icon id present
  76299. */
  76300. private _svgCheck;
  76301. /**
  76302. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76303. * given external svg file and icon id
  76304. */
  76305. private _getSVGAttribs;
  76306. /**
  76307. * Gets or sets the cell width to use when animation sheet is enabled
  76308. * @see https://doc.babylonjs.com/how_to/gui#image
  76309. */
  76310. get cellWidth(): number;
  76311. set cellWidth(value: number);
  76312. /**
  76313. * Gets or sets the cell height to use when animation sheet is enabled
  76314. * @see https://doc.babylonjs.com/how_to/gui#image
  76315. */
  76316. get cellHeight(): number;
  76317. set cellHeight(value: number);
  76318. /**
  76319. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76320. * @see https://doc.babylonjs.com/how_to/gui#image
  76321. */
  76322. get cellId(): number;
  76323. set cellId(value: number);
  76324. /**
  76325. * Creates a new Image
  76326. * @param name defines the control name
  76327. * @param url defines the image url
  76328. */
  76329. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76330. /**
  76331. * Tests if a given coordinates belong to the current control
  76332. * @param x defines x coordinate to test
  76333. * @param y defines y coordinate to test
  76334. * @returns true if the coordinates are inside the control
  76335. */
  76336. contains(x: number, y: number): boolean;
  76337. protected _getTypeName(): string;
  76338. /** Force the control to synchronize with its content */
  76339. synchronizeSizeWithContent(): void;
  76340. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76341. private _prepareWorkingCanvasForOpaqueDetection;
  76342. private _drawImage;
  76343. _draw(context: CanvasRenderingContext2D): void;
  76344. private _renderCornerPatch;
  76345. private _renderNinePatch;
  76346. dispose(): void;
  76347. /** STRETCH_NONE */
  76348. static readonly STRETCH_NONE: number;
  76349. /** STRETCH_FILL */
  76350. static readonly STRETCH_FILL: number;
  76351. /** STRETCH_UNIFORM */
  76352. static readonly STRETCH_UNIFORM: number;
  76353. /** STRETCH_EXTEND */
  76354. static readonly STRETCH_EXTEND: number;
  76355. /** NINE_PATCH */
  76356. static readonly STRETCH_NINE_PATCH: number;
  76357. }
  76358. }
  76359. declare module BABYLON.GUI {
  76360. /**
  76361. * Class used to create 2D buttons
  76362. */
  76363. export class Button extends Rectangle {
  76364. name?: string | undefined;
  76365. /**
  76366. * Function called to generate a pointer enter animation
  76367. */
  76368. pointerEnterAnimation: () => void;
  76369. /**
  76370. * Function called to generate a pointer out animation
  76371. */
  76372. pointerOutAnimation: () => void;
  76373. /**
  76374. * Function called to generate a pointer down animation
  76375. */
  76376. pointerDownAnimation: () => void;
  76377. /**
  76378. * Function called to generate a pointer up animation
  76379. */
  76380. pointerUpAnimation: () => void;
  76381. /**
  76382. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76383. */
  76384. delegatePickingToChildren: boolean;
  76385. private _image;
  76386. /**
  76387. * Returns the image part of the button (if any)
  76388. */
  76389. get image(): BABYLON.Nullable<Image>;
  76390. private _textBlock;
  76391. /**
  76392. * Returns the image part of the button (if any)
  76393. */
  76394. get textBlock(): BABYLON.Nullable<TextBlock>;
  76395. /**
  76396. * Creates a new Button
  76397. * @param name defines the name of the button
  76398. */
  76399. constructor(name?: string | undefined);
  76400. protected _getTypeName(): string;
  76401. /** @hidden */
  76402. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76403. /** @hidden */
  76404. _onPointerEnter(target: Control): boolean;
  76405. /** @hidden */
  76406. _onPointerOut(target: Control, force?: boolean): void;
  76407. /** @hidden */
  76408. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76409. /** @hidden */
  76410. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76411. /**
  76412. * Creates a new button made with an image and a text
  76413. * @param name defines the name of the button
  76414. * @param text defines the text of the button
  76415. * @param imageUrl defines the url of the image
  76416. * @returns a new Button
  76417. */
  76418. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76419. /**
  76420. * Creates a new button made with an image
  76421. * @param name defines the name of the button
  76422. * @param imageUrl defines the url of the image
  76423. * @returns a new Button
  76424. */
  76425. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76426. /**
  76427. * Creates a new button made with a text
  76428. * @param name defines the name of the button
  76429. * @param text defines the text of the button
  76430. * @returns a new Button
  76431. */
  76432. static CreateSimpleButton(name: string, text: string): Button;
  76433. /**
  76434. * Creates a new button made with an image and a centered text
  76435. * @param name defines the name of the button
  76436. * @param text defines the text of the button
  76437. * @param imageUrl defines the url of the image
  76438. * @returns a new Button
  76439. */
  76440. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76441. }
  76442. }
  76443. declare module BABYLON.GUI {
  76444. /**
  76445. * Class used to create a 2D stack panel container
  76446. */
  76447. export class StackPanel extends Container {
  76448. name?: string | undefined;
  76449. private _isVertical;
  76450. private _manualWidth;
  76451. private _manualHeight;
  76452. private _doNotTrackManualChanges;
  76453. /**
  76454. * Gets or sets a boolean indicating that layou warnings should be ignored
  76455. */
  76456. ignoreLayoutWarnings: boolean;
  76457. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76458. get isVertical(): boolean;
  76459. set isVertical(value: boolean);
  76460. /**
  76461. * Gets or sets panel width.
  76462. * This value should not be set when in horizontal mode as it will be computed automatically
  76463. */
  76464. set width(value: string | number);
  76465. get width(): string | number;
  76466. /**
  76467. * Gets or sets panel height.
  76468. * This value should not be set when in vertical mode as it will be computed automatically
  76469. */
  76470. set height(value: string | number);
  76471. get height(): string | number;
  76472. /**
  76473. * Creates a new StackPanel
  76474. * @param name defines control name
  76475. */
  76476. constructor(name?: string | undefined);
  76477. protected _getTypeName(): string;
  76478. /** @hidden */
  76479. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76480. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76481. protected _postMeasure(): void;
  76482. }
  76483. }
  76484. declare module BABYLON.GUI {
  76485. /**
  76486. * Class used to represent a 2D checkbox
  76487. */
  76488. export class Checkbox extends Control {
  76489. name?: string | undefined;
  76490. private _isChecked;
  76491. private _background;
  76492. private _checkSizeRatio;
  76493. private _thickness;
  76494. /** Gets or sets border thickness */
  76495. get thickness(): number;
  76496. set thickness(value: number);
  76497. /**
  76498. * BABYLON.Observable raised when isChecked property changes
  76499. */
  76500. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76501. /** Gets or sets a value indicating the ratio between overall size and check size */
  76502. get checkSizeRatio(): number;
  76503. set checkSizeRatio(value: number);
  76504. /** Gets or sets background color */
  76505. get background(): string;
  76506. set background(value: string);
  76507. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76508. get isChecked(): boolean;
  76509. set isChecked(value: boolean);
  76510. /**
  76511. * Creates a new CheckBox
  76512. * @param name defines the control name
  76513. */
  76514. constructor(name?: string | undefined);
  76515. protected _getTypeName(): string;
  76516. /** @hidden */
  76517. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76518. /** @hidden */
  76519. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76520. /**
  76521. * Utility function to easily create a checkbox with a header
  76522. * @param title defines the label to use for the header
  76523. * @param onValueChanged defines the callback to call when value changes
  76524. * @returns a StackPanel containing the checkbox and a textBlock
  76525. */
  76526. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76527. }
  76528. }
  76529. declare module BABYLON.GUI {
  76530. /**
  76531. * Class used to store key control properties
  76532. */
  76533. export class KeyPropertySet {
  76534. /** Width */
  76535. width?: string;
  76536. /** Height */
  76537. height?: string;
  76538. /** Left padding */
  76539. paddingLeft?: string;
  76540. /** Right padding */
  76541. paddingRight?: string;
  76542. /** Top padding */
  76543. paddingTop?: string;
  76544. /** Bottom padding */
  76545. paddingBottom?: string;
  76546. /** Foreground color */
  76547. color?: string;
  76548. /** Background color */
  76549. background?: string;
  76550. }
  76551. /**
  76552. * Class used to create virtual keyboard
  76553. */
  76554. export class VirtualKeyboard extends StackPanel {
  76555. /** BABYLON.Observable raised when a key is pressed */
  76556. onKeyPressObservable: BABYLON.Observable<string>;
  76557. /** Gets or sets default key button width */
  76558. defaultButtonWidth: string;
  76559. /** Gets or sets default key button height */
  76560. defaultButtonHeight: string;
  76561. /** Gets or sets default key button left padding */
  76562. defaultButtonPaddingLeft: string;
  76563. /** Gets or sets default key button right padding */
  76564. defaultButtonPaddingRight: string;
  76565. /** Gets or sets default key button top padding */
  76566. defaultButtonPaddingTop: string;
  76567. /** Gets or sets default key button bottom padding */
  76568. defaultButtonPaddingBottom: string;
  76569. /** Gets or sets default key button foreground color */
  76570. defaultButtonColor: string;
  76571. /** Gets or sets default key button background color */
  76572. defaultButtonBackground: string;
  76573. /** Gets or sets shift button foreground color */
  76574. shiftButtonColor: string;
  76575. /** Gets or sets shift button thickness*/
  76576. selectedShiftThickness: number;
  76577. /** Gets shift key state */
  76578. shiftState: number;
  76579. protected _getTypeName(): string;
  76580. private _createKey;
  76581. /**
  76582. * Adds a new row of keys
  76583. * @param keys defines the list of keys to add
  76584. * @param propertySets defines the associated property sets
  76585. */
  76586. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76587. /**
  76588. * Set the shift key to a specific state
  76589. * @param shiftState defines the new shift state
  76590. */
  76591. applyShiftState(shiftState: number): void;
  76592. private _currentlyConnectedInputText;
  76593. private _connectedInputTexts;
  76594. private _onKeyPressObserver;
  76595. /** Gets the input text control currently attached to the keyboard */
  76596. get connectedInputText(): BABYLON.Nullable<InputText>;
  76597. /**
  76598. * Connects the keyboard with an input text control
  76599. *
  76600. * @param input defines the target control
  76601. */
  76602. connect(input: InputText): void;
  76603. /**
  76604. * Disconnects the keyboard from connected InputText controls
  76605. *
  76606. * @param input optionally defines a target control, otherwise all are disconnected
  76607. */
  76608. disconnect(input?: InputText): void;
  76609. private _removeConnectedInputObservables;
  76610. /**
  76611. * Release all resources
  76612. */
  76613. dispose(): void;
  76614. /**
  76615. * Creates a new keyboard using a default layout
  76616. *
  76617. * @param name defines control name
  76618. * @returns a new VirtualKeyboard
  76619. */
  76620. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76621. }
  76622. }
  76623. declare module BABYLON.GUI {
  76624. /**
  76625. * Class used to create input text control
  76626. */
  76627. export class InputText extends Control implements IFocusableControl {
  76628. name?: string | undefined;
  76629. private _text;
  76630. private _placeholderText;
  76631. private _background;
  76632. private _focusedBackground;
  76633. private _focusedColor;
  76634. private _placeholderColor;
  76635. private _thickness;
  76636. private _margin;
  76637. private _autoStretchWidth;
  76638. private _maxWidth;
  76639. private _isFocused;
  76640. private _blinkTimeout;
  76641. private _blinkIsEven;
  76642. private _cursorOffset;
  76643. private _scrollLeft;
  76644. private _textWidth;
  76645. private _clickedCoordinate;
  76646. private _deadKey;
  76647. private _addKey;
  76648. private _currentKey;
  76649. private _isTextHighlightOn;
  76650. private _textHighlightColor;
  76651. private _highligherOpacity;
  76652. private _highlightedText;
  76653. private _startHighlightIndex;
  76654. private _endHighlightIndex;
  76655. private _cursorIndex;
  76656. private _onFocusSelectAll;
  76657. private _isPointerDown;
  76658. private _onClipboardObserver;
  76659. private _onPointerDblTapObserver;
  76660. /** @hidden */
  76661. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76662. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76663. promptMessage: string;
  76664. /** Force disable prompt on mobile device */
  76665. disableMobilePrompt: boolean;
  76666. /** BABYLON.Observable raised when the text changes */
  76667. onTextChangedObservable: BABYLON.Observable<InputText>;
  76668. /** BABYLON.Observable raised just before an entered character is to be added */
  76669. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76670. /** BABYLON.Observable raised when the control gets the focus */
  76671. onFocusObservable: BABYLON.Observable<InputText>;
  76672. /** BABYLON.Observable raised when the control loses the focus */
  76673. onBlurObservable: BABYLON.Observable<InputText>;
  76674. /**Observable raised when the text is highlighted */
  76675. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76676. /**Observable raised when copy event is triggered */
  76677. onTextCopyObservable: BABYLON.Observable<InputText>;
  76678. /** BABYLON.Observable raised when cut event is triggered */
  76679. onTextCutObservable: BABYLON.Observable<InputText>;
  76680. /** BABYLON.Observable raised when paste event is triggered */
  76681. onTextPasteObservable: BABYLON.Observable<InputText>;
  76682. /** BABYLON.Observable raised when a key event was processed */
  76683. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76684. /** Gets or sets the maximum width allowed by the control */
  76685. get maxWidth(): string | number;
  76686. /** Gets the maximum width allowed by the control in pixels */
  76687. get maxWidthInPixels(): number;
  76688. set maxWidth(value: string | number);
  76689. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76690. get highligherOpacity(): number;
  76691. set highligherOpacity(value: number);
  76692. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76693. get onFocusSelectAll(): boolean;
  76694. set onFocusSelectAll(value: boolean);
  76695. /** Gets or sets the text hightlight color */
  76696. get textHighlightColor(): string;
  76697. set textHighlightColor(value: string);
  76698. /** Gets or sets control margin */
  76699. get margin(): string;
  76700. /** Gets control margin in pixels */
  76701. get marginInPixels(): number;
  76702. set margin(value: string);
  76703. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76704. get autoStretchWidth(): boolean;
  76705. set autoStretchWidth(value: boolean);
  76706. /** Gets or sets border thickness */
  76707. get thickness(): number;
  76708. set thickness(value: number);
  76709. /** Gets or sets the background color when focused */
  76710. get focusedBackground(): string;
  76711. set focusedBackground(value: string);
  76712. /** Gets or sets the background color when focused */
  76713. get focusedColor(): string;
  76714. set focusedColor(value: string);
  76715. /** Gets or sets the background color */
  76716. get background(): string;
  76717. set background(value: string);
  76718. /** Gets or sets the placeholder color */
  76719. get placeholderColor(): string;
  76720. set placeholderColor(value: string);
  76721. /** Gets or sets the text displayed when the control is empty */
  76722. get placeholderText(): string;
  76723. set placeholderText(value: string);
  76724. /** Gets or sets the dead key flag */
  76725. get deadKey(): boolean;
  76726. set deadKey(flag: boolean);
  76727. /** Gets or sets the highlight text */
  76728. get highlightedText(): string;
  76729. set highlightedText(text: string);
  76730. /** Gets or sets if the current key should be added */
  76731. get addKey(): boolean;
  76732. set addKey(flag: boolean);
  76733. /** Gets or sets the value of the current key being entered */
  76734. get currentKey(): string;
  76735. set currentKey(key: string);
  76736. /** Gets or sets the text displayed in the control */
  76737. get text(): string;
  76738. set text(value: string);
  76739. /** Gets or sets control width */
  76740. get width(): string | number;
  76741. set width(value: string | number);
  76742. /**
  76743. * Creates a new InputText
  76744. * @param name defines the control name
  76745. * @param text defines the text of the control
  76746. */
  76747. constructor(name?: string | undefined, text?: string);
  76748. /** @hidden */
  76749. onBlur(): void;
  76750. /** @hidden */
  76751. onFocus(): void;
  76752. protected _getTypeName(): string;
  76753. /**
  76754. * Function called to get the list of controls that should not steal the focus from this control
  76755. * @returns an array of controls
  76756. */
  76757. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76758. /** @hidden */
  76759. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76760. /** @hidden */
  76761. private _updateValueFromCursorIndex;
  76762. /** @hidden */
  76763. private _processDblClick;
  76764. /** @hidden */
  76765. private _selectAllText;
  76766. /**
  76767. * Handles the keyboard event
  76768. * @param evt Defines the KeyboardEvent
  76769. */
  76770. processKeyboard(evt: KeyboardEvent): void;
  76771. /** @hidden */
  76772. private _onCopyText;
  76773. /** @hidden */
  76774. private _onCutText;
  76775. /** @hidden */
  76776. private _onPasteText;
  76777. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76778. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76779. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76780. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76781. protected _beforeRenderText(text: string): string;
  76782. dispose(): void;
  76783. }
  76784. }
  76785. declare module BABYLON.GUI {
  76786. /**
  76787. * Class used to create a 2D grid container
  76788. */
  76789. export class Grid extends Container {
  76790. name?: string | undefined;
  76791. private _rowDefinitions;
  76792. private _columnDefinitions;
  76793. private _cells;
  76794. private _childControls;
  76795. /**
  76796. * Gets the number of columns
  76797. */
  76798. get columnCount(): number;
  76799. /**
  76800. * Gets the number of rows
  76801. */
  76802. get rowCount(): number;
  76803. /** Gets the list of children */
  76804. get children(): Control[];
  76805. /** Gets the list of cells (e.g. the containers) */
  76806. get cells(): {
  76807. [key: string]: Container;
  76808. };
  76809. /**
  76810. * Gets the definition of a specific row
  76811. * @param index defines the index of the row
  76812. * @returns the row definition
  76813. */
  76814. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76815. /**
  76816. * Gets the definition of a specific column
  76817. * @param index defines the index of the column
  76818. * @returns the column definition
  76819. */
  76820. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76821. /**
  76822. * Adds a new row to the grid
  76823. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76824. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76825. * @returns the current grid
  76826. */
  76827. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76828. /**
  76829. * Adds a new column to the grid
  76830. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76831. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76832. * @returns the current grid
  76833. */
  76834. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76835. /**
  76836. * Update a row definition
  76837. * @param index defines the index of the row to update
  76838. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76839. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76840. * @returns the current grid
  76841. */
  76842. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76843. /**
  76844. * Update a column definition
  76845. * @param index defines the index of the column to update
  76846. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76847. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76848. * @returns the current grid
  76849. */
  76850. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76851. /**
  76852. * Gets the list of children stored in a specific cell
  76853. * @param row defines the row to check
  76854. * @param column defines the column to check
  76855. * @returns the list of controls
  76856. */
  76857. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76858. /**
  76859. * Gets a string representing the child cell info (row x column)
  76860. * @param child defines the control to get info from
  76861. * @returns a string containing the child cell info (row x column)
  76862. */
  76863. getChildCellInfo(child: Control): string;
  76864. private _removeCell;
  76865. private _offsetCell;
  76866. /**
  76867. * Remove a column definition at specified index
  76868. * @param index defines the index of the column to remove
  76869. * @returns the current grid
  76870. */
  76871. removeColumnDefinition(index: number): Grid;
  76872. /**
  76873. * Remove a row definition at specified index
  76874. * @param index defines the index of the row to remove
  76875. * @returns the current grid
  76876. */
  76877. removeRowDefinition(index: number): Grid;
  76878. /**
  76879. * Adds a new control to the current grid
  76880. * @param control defines the control to add
  76881. * @param row defines the row where to add the control (0 by default)
  76882. * @param column defines the column where to add the control (0 by default)
  76883. * @returns the current grid
  76884. */
  76885. addControl(control: Control, row?: number, column?: number): Grid;
  76886. /**
  76887. * Removes a control from the current container
  76888. * @param control defines the control to remove
  76889. * @returns the current container
  76890. */
  76891. removeControl(control: Control): Container;
  76892. /**
  76893. * Creates a new Grid
  76894. * @param name defines control name
  76895. */
  76896. constructor(name?: string | undefined);
  76897. protected _getTypeName(): string;
  76898. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76899. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76900. _flagDescendantsAsMatrixDirty(): void;
  76901. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76902. /** Releases associated resources */
  76903. dispose(): void;
  76904. }
  76905. }
  76906. declare module BABYLON.GUI {
  76907. /** Class used to create color pickers */
  76908. export class ColorPicker extends Control {
  76909. name?: string | undefined;
  76910. private static _Epsilon;
  76911. private _colorWheelCanvas;
  76912. private _value;
  76913. private _tmpColor;
  76914. private _pointerStartedOnSquare;
  76915. private _pointerStartedOnWheel;
  76916. private _squareLeft;
  76917. private _squareTop;
  76918. private _squareSize;
  76919. private _h;
  76920. private _s;
  76921. private _v;
  76922. private _lastPointerDownID;
  76923. /**
  76924. * BABYLON.Observable raised when the value changes
  76925. */
  76926. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76927. /** Gets or sets the color of the color picker */
  76928. get value(): BABYLON.Color3;
  76929. set value(value: BABYLON.Color3);
  76930. /**
  76931. * Gets or sets control width
  76932. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76933. */
  76934. get width(): string | number;
  76935. set width(value: string | number);
  76936. /**
  76937. * Gets or sets control height
  76938. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76939. */
  76940. get height(): string | number;
  76941. /** Gets or sets control height */
  76942. set height(value: string | number);
  76943. /** Gets or sets control size */
  76944. get size(): string | number;
  76945. set size(value: string | number);
  76946. /**
  76947. * Creates a new ColorPicker
  76948. * @param name defines the control name
  76949. */
  76950. constructor(name?: string | undefined);
  76951. protected _getTypeName(): string;
  76952. /** @hidden */
  76953. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76954. private _updateSquareProps;
  76955. private _drawGradientSquare;
  76956. private _drawCircle;
  76957. private _createColorWheelCanvas;
  76958. /** @hidden */
  76959. _draw(context: CanvasRenderingContext2D): void;
  76960. private _pointerIsDown;
  76961. private _updateValueFromPointer;
  76962. private _isPointOnSquare;
  76963. private _isPointOnWheel;
  76964. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76965. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76966. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76967. /**
  76968. * This function expands the color picker by creating a color picker dialog with manual
  76969. * color value input and the ability to save colors into an array to be used later in
  76970. * subsequent launches of the dialogue.
  76971. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76972. * @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.
  76973. * @returns picked color as a hex string and the saved colors array as hex strings.
  76974. */
  76975. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76976. pickerWidth?: string;
  76977. pickerHeight?: string;
  76978. headerHeight?: string;
  76979. lastColor?: string;
  76980. swatchLimit?: number;
  76981. numSwatchesPerLine?: number;
  76982. savedColors?: Array<string>;
  76983. }): Promise<{
  76984. savedColors?: string[];
  76985. pickedColor: string;
  76986. }>;
  76987. }
  76988. }
  76989. declare module BABYLON.GUI {
  76990. /** Class used to create 2D ellipse containers */
  76991. export class Ellipse extends Container {
  76992. name?: string | undefined;
  76993. private _thickness;
  76994. /** Gets or sets border thickness */
  76995. get thickness(): number;
  76996. set thickness(value: number);
  76997. /**
  76998. * Creates a new Ellipse
  76999. * @param name defines the control name
  77000. */
  77001. constructor(name?: string | undefined);
  77002. protected _getTypeName(): string;
  77003. protected _localDraw(context: CanvasRenderingContext2D): void;
  77004. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77005. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77006. }
  77007. }
  77008. declare module BABYLON.GUI {
  77009. /**
  77010. * Class used to create a password control
  77011. */
  77012. export class InputPassword extends InputText {
  77013. protected _beforeRenderText(text: string): string;
  77014. }
  77015. }
  77016. declare module BABYLON.GUI {
  77017. /** Class used to render 2D lines */
  77018. export class Line extends Control {
  77019. name?: string | undefined;
  77020. private _lineWidth;
  77021. private _x1;
  77022. private _y1;
  77023. private _x2;
  77024. private _y2;
  77025. private _dash;
  77026. private _connectedControl;
  77027. private _connectedControlDirtyObserver;
  77028. /** Gets or sets the dash pattern */
  77029. get dash(): Array<number>;
  77030. set dash(value: Array<number>);
  77031. /** Gets or sets the control connected with the line end */
  77032. get connectedControl(): Control;
  77033. set connectedControl(value: Control);
  77034. /** Gets or sets start coordinates on X axis */
  77035. get x1(): string | number;
  77036. set x1(value: string | number);
  77037. /** Gets or sets start coordinates on Y axis */
  77038. get y1(): string | number;
  77039. set y1(value: string | number);
  77040. /** Gets or sets end coordinates on X axis */
  77041. get x2(): string | number;
  77042. set x2(value: string | number);
  77043. /** Gets or sets end coordinates on Y axis */
  77044. get y2(): string | number;
  77045. set y2(value: string | number);
  77046. /** Gets or sets line width */
  77047. get lineWidth(): number;
  77048. set lineWidth(value: number);
  77049. /** Gets or sets horizontal alignment */
  77050. set horizontalAlignment(value: number);
  77051. /** Gets or sets vertical alignment */
  77052. set verticalAlignment(value: number);
  77053. private get _effectiveX2();
  77054. private get _effectiveY2();
  77055. /**
  77056. * Creates a new Line
  77057. * @param name defines the control name
  77058. */
  77059. constructor(name?: string | undefined);
  77060. protected _getTypeName(): string;
  77061. _draw(context: CanvasRenderingContext2D): void;
  77062. _measure(): void;
  77063. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77064. /**
  77065. * Move one end of the line given 3D cartesian coordinates.
  77066. * @param position Targeted world position
  77067. * @param scene BABYLON.Scene
  77068. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77069. */
  77070. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77071. /**
  77072. * Move one end of the line to a position in screen absolute space.
  77073. * @param projectedPosition Position in screen absolute space (X, Y)
  77074. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77075. */
  77076. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77077. }
  77078. }
  77079. declare module BABYLON.GUI {
  77080. /**
  77081. * Class used to store a point for a MultiLine object.
  77082. * The point can be pure 2D coordinates, a mesh or a control
  77083. */
  77084. export class MultiLinePoint {
  77085. private _multiLine;
  77086. private _x;
  77087. private _y;
  77088. private _control;
  77089. private _mesh;
  77090. private _controlObserver;
  77091. private _meshObserver;
  77092. /** @hidden */
  77093. _point: BABYLON.Vector2;
  77094. /**
  77095. * Creates a new MultiLinePoint
  77096. * @param multiLine defines the source MultiLine object
  77097. */
  77098. constructor(multiLine: MultiLine);
  77099. /** Gets or sets x coordinate */
  77100. get x(): string | number;
  77101. set x(value: string | number);
  77102. /** Gets or sets y coordinate */
  77103. get y(): string | number;
  77104. set y(value: string | number);
  77105. /** Gets or sets the control associated with this point */
  77106. get control(): BABYLON.Nullable<Control>;
  77107. set control(value: BABYLON.Nullable<Control>);
  77108. /** Gets or sets the mesh associated with this point */
  77109. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77110. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77111. /** Resets links */
  77112. resetLinks(): void;
  77113. /**
  77114. * Gets a translation vector
  77115. * @returns the translation vector
  77116. */
  77117. translate(): BABYLON.Vector2;
  77118. private _translatePoint;
  77119. /** Release associated resources */
  77120. dispose(): void;
  77121. }
  77122. }
  77123. declare module BABYLON.GUI {
  77124. /**
  77125. * Class used to create multi line control
  77126. */
  77127. export class MultiLine extends Control {
  77128. name?: string | undefined;
  77129. private _lineWidth;
  77130. private _dash;
  77131. private _points;
  77132. private _minX;
  77133. private _minY;
  77134. private _maxX;
  77135. private _maxY;
  77136. /**
  77137. * Creates a new MultiLine
  77138. * @param name defines the control name
  77139. */
  77140. constructor(name?: string | undefined);
  77141. /** Gets or sets dash pattern */
  77142. get dash(): Array<number>;
  77143. set dash(value: Array<number>);
  77144. /**
  77145. * Gets point stored at specified index
  77146. * @param index defines the index to look for
  77147. * @returns the requested point if found
  77148. */
  77149. getAt(index: number): MultiLinePoint;
  77150. /** Function called when a point is updated */
  77151. onPointUpdate: () => void;
  77152. /**
  77153. * Adds new points to the point collection
  77154. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77155. * @returns the list of created MultiLinePoint
  77156. */
  77157. add(...items: (AbstractMesh | Control | {
  77158. x: string | number;
  77159. y: string | number;
  77160. })[]): MultiLinePoint[];
  77161. /**
  77162. * Adds a new point to the point collection
  77163. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77164. * @returns the created MultiLinePoint
  77165. */
  77166. push(item?: (AbstractMesh | Control | {
  77167. x: string | number;
  77168. y: string | number;
  77169. })): MultiLinePoint;
  77170. /**
  77171. * Remove a specific value or point from the active point collection
  77172. * @param value defines the value or point to remove
  77173. */
  77174. remove(value: number | MultiLinePoint): void;
  77175. /**
  77176. * Resets this object to initial state (no point)
  77177. */
  77178. reset(): void;
  77179. /**
  77180. * Resets all links
  77181. */
  77182. resetLinks(): void;
  77183. /** Gets or sets line width */
  77184. get lineWidth(): number;
  77185. set lineWidth(value: number);
  77186. set horizontalAlignment(value: number);
  77187. set verticalAlignment(value: number);
  77188. protected _getTypeName(): string;
  77189. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77190. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77191. _measure(): void;
  77192. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77193. dispose(): void;
  77194. }
  77195. }
  77196. declare module BABYLON.GUI {
  77197. /**
  77198. * Class used to create radio button controls
  77199. */
  77200. export class RadioButton extends Control {
  77201. name?: string | undefined;
  77202. private _isChecked;
  77203. private _background;
  77204. private _checkSizeRatio;
  77205. private _thickness;
  77206. /** Gets or sets border thickness */
  77207. get thickness(): number;
  77208. set thickness(value: number);
  77209. /** Gets or sets group name */
  77210. group: string;
  77211. /** BABYLON.Observable raised when isChecked is changed */
  77212. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77213. /** Gets or sets a value indicating the ratio between overall size and check size */
  77214. get checkSizeRatio(): number;
  77215. set checkSizeRatio(value: number);
  77216. /** Gets or sets background color */
  77217. get background(): string;
  77218. set background(value: string);
  77219. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77220. get isChecked(): boolean;
  77221. set isChecked(value: boolean);
  77222. /**
  77223. * Creates a new RadioButton
  77224. * @param name defines the control name
  77225. */
  77226. constructor(name?: string | undefined);
  77227. protected _getTypeName(): string;
  77228. _draw(context: CanvasRenderingContext2D): void;
  77229. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77230. /**
  77231. * Utility function to easily create a radio button with a header
  77232. * @param title defines the label to use for the header
  77233. * @param group defines the group to use for the radio button
  77234. * @param isChecked defines the initial state of the radio button
  77235. * @param onValueChanged defines the callback to call when value changes
  77236. * @returns a StackPanel containing the radio button and a textBlock
  77237. */
  77238. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77239. }
  77240. }
  77241. declare module BABYLON.GUI {
  77242. /**
  77243. * Class used to create slider controls
  77244. */
  77245. export class BaseSlider extends Control {
  77246. name?: string | undefined;
  77247. protected _thumbWidth: ValueAndUnit;
  77248. private _minimum;
  77249. private _maximum;
  77250. private _value;
  77251. private _isVertical;
  77252. protected _barOffset: ValueAndUnit;
  77253. private _isThumbClamped;
  77254. protected _displayThumb: boolean;
  77255. private _step;
  77256. private _lastPointerDownID;
  77257. protected _effectiveBarOffset: number;
  77258. protected _renderLeft: number;
  77259. protected _renderTop: number;
  77260. protected _renderWidth: number;
  77261. protected _renderHeight: number;
  77262. protected _backgroundBoxLength: number;
  77263. protected _backgroundBoxThickness: number;
  77264. protected _effectiveThumbThickness: number;
  77265. /** BABYLON.Observable raised when the sldier value changes */
  77266. onValueChangedObservable: BABYLON.Observable<number>;
  77267. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77268. get displayThumb(): boolean;
  77269. set displayThumb(value: boolean);
  77270. /** Gets or sets a step to apply to values (0 by default) */
  77271. get step(): number;
  77272. set step(value: number);
  77273. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77274. get barOffset(): string | number;
  77275. /** Gets main bar offset in pixels*/
  77276. get barOffsetInPixels(): number;
  77277. set barOffset(value: string | number);
  77278. /** Gets or sets thumb width */
  77279. get thumbWidth(): string | number;
  77280. /** Gets thumb width in pixels */
  77281. get thumbWidthInPixels(): number;
  77282. set thumbWidth(value: string | number);
  77283. /** Gets or sets minimum value */
  77284. get minimum(): number;
  77285. set minimum(value: number);
  77286. /** Gets or sets maximum value */
  77287. get maximum(): number;
  77288. set maximum(value: number);
  77289. /** Gets or sets current value */
  77290. get value(): number;
  77291. set value(value: number);
  77292. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77293. get isVertical(): boolean;
  77294. set isVertical(value: boolean);
  77295. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77296. get isThumbClamped(): boolean;
  77297. set isThumbClamped(value: boolean);
  77298. /**
  77299. * Creates a new BaseSlider
  77300. * @param name defines the control name
  77301. */
  77302. constructor(name?: string | undefined);
  77303. protected _getTypeName(): string;
  77304. protected _getThumbPosition(): number;
  77305. protected _getThumbThickness(type: string): number;
  77306. protected _prepareRenderingData(type: string): void;
  77307. private _pointerIsDown;
  77308. /** @hidden */
  77309. protected _updateValueFromPointer(x: number, y: number): void;
  77310. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77311. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77312. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77313. }
  77314. }
  77315. declare module BABYLON.GUI {
  77316. /**
  77317. * Class used to create slider controls
  77318. */
  77319. export class Slider extends BaseSlider {
  77320. name?: string | undefined;
  77321. private _background;
  77322. private _borderColor;
  77323. private _isThumbCircle;
  77324. protected _displayValueBar: boolean;
  77325. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77326. get displayValueBar(): boolean;
  77327. set displayValueBar(value: boolean);
  77328. /** Gets or sets border color */
  77329. get borderColor(): string;
  77330. set borderColor(value: string);
  77331. /** Gets or sets background color */
  77332. get background(): string;
  77333. set background(value: string);
  77334. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77335. get isThumbCircle(): boolean;
  77336. set isThumbCircle(value: boolean);
  77337. /**
  77338. * Creates a new Slider
  77339. * @param name defines the control name
  77340. */
  77341. constructor(name?: string | undefined);
  77342. protected _getTypeName(): string;
  77343. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77344. }
  77345. }
  77346. declare module BABYLON.GUI {
  77347. /** Class used to create a RadioGroup
  77348. * which contains groups of radio buttons
  77349. */
  77350. export class SelectorGroup {
  77351. /** name of SelectorGroup */
  77352. name: string;
  77353. private _groupPanel;
  77354. private _selectors;
  77355. private _groupHeader;
  77356. /**
  77357. * Creates a new SelectorGroup
  77358. * @param name of group, used as a group heading
  77359. */
  77360. constructor(
  77361. /** name of SelectorGroup */
  77362. name: string);
  77363. /** Gets the groupPanel of the SelectorGroup */
  77364. get groupPanel(): StackPanel;
  77365. /** Gets the selectors array */
  77366. get selectors(): StackPanel[];
  77367. /** Gets and sets the group header */
  77368. get header(): string;
  77369. set header(label: string);
  77370. /** @hidden */
  77371. private _addGroupHeader;
  77372. /** @hidden*/
  77373. _getSelector(selectorNb: number): StackPanel | undefined;
  77374. /** Removes the selector at the given position
  77375. * @param selectorNb the position of the selector within the group
  77376. */
  77377. removeSelector(selectorNb: number): void;
  77378. }
  77379. /** Class used to create a CheckboxGroup
  77380. * which contains groups of checkbox buttons
  77381. */
  77382. export class CheckboxGroup extends SelectorGroup {
  77383. /** Adds a checkbox as a control
  77384. * @param text is the label for the selector
  77385. * @param func is the function called when the Selector is checked
  77386. * @param checked is true when Selector is checked
  77387. */
  77388. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77389. /** @hidden */
  77390. _setSelectorLabel(selectorNb: number, label: string): void;
  77391. /** @hidden */
  77392. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77393. /** @hidden */
  77394. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77395. /** @hidden */
  77396. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77397. }
  77398. /** Class used to create a RadioGroup
  77399. * which contains groups of radio buttons
  77400. */
  77401. export class RadioGroup extends SelectorGroup {
  77402. private _selectNb;
  77403. /** Adds a radio button as a control
  77404. * @param label is the label for the selector
  77405. * @param func is the function called when the Selector is checked
  77406. * @param checked is true when Selector is checked
  77407. */
  77408. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77409. /** @hidden */
  77410. _setSelectorLabel(selectorNb: number, label: string): void;
  77411. /** @hidden */
  77412. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77413. /** @hidden */
  77414. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77415. /** @hidden */
  77416. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77417. }
  77418. /** Class used to create a SliderGroup
  77419. * which contains groups of slider buttons
  77420. */
  77421. export class SliderGroup extends SelectorGroup {
  77422. /**
  77423. * Adds a slider to the SelectorGroup
  77424. * @param label is the label for the SliderBar
  77425. * @param func is the function called when the Slider moves
  77426. * @param unit is a string describing the units used, eg degrees or metres
  77427. * @param min is the minimum value for the Slider
  77428. * @param max is the maximum value for the Slider
  77429. * @param value is the start value for the Slider between min and max
  77430. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77431. */
  77432. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77433. /** @hidden */
  77434. _setSelectorLabel(selectorNb: number, label: string): void;
  77435. /** @hidden */
  77436. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77437. /** @hidden */
  77438. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77439. /** @hidden */
  77440. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77441. }
  77442. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77443. * @see https://doc.babylonjs.com/how_to/selector
  77444. */
  77445. export class SelectionPanel extends Rectangle {
  77446. /** name of SelectionPanel */
  77447. name: string;
  77448. /** an array of SelectionGroups */
  77449. groups: SelectorGroup[];
  77450. private _panel;
  77451. private _buttonColor;
  77452. private _buttonBackground;
  77453. private _headerColor;
  77454. private _barColor;
  77455. private _barHeight;
  77456. private _spacerHeight;
  77457. private _labelColor;
  77458. private _groups;
  77459. private _bars;
  77460. /**
  77461. * Creates a new SelectionPanel
  77462. * @param name of SelectionPanel
  77463. * @param groups is an array of SelectionGroups
  77464. */
  77465. constructor(
  77466. /** name of SelectionPanel */
  77467. name: string,
  77468. /** an array of SelectionGroups */
  77469. groups?: SelectorGroup[]);
  77470. protected _getTypeName(): string;
  77471. /** Gets or sets the headerColor */
  77472. get headerColor(): string;
  77473. set headerColor(color: string);
  77474. private _setHeaderColor;
  77475. /** Gets or sets the button color */
  77476. get buttonColor(): string;
  77477. set buttonColor(color: string);
  77478. private _setbuttonColor;
  77479. /** Gets or sets the label color */
  77480. get labelColor(): string;
  77481. set labelColor(color: string);
  77482. private _setLabelColor;
  77483. /** Gets or sets the button background */
  77484. get buttonBackground(): string;
  77485. set buttonBackground(color: string);
  77486. private _setButtonBackground;
  77487. /** Gets or sets the color of separator bar */
  77488. get barColor(): string;
  77489. set barColor(color: string);
  77490. private _setBarColor;
  77491. /** Gets or sets the height of separator bar */
  77492. get barHeight(): string;
  77493. set barHeight(value: string);
  77494. private _setBarHeight;
  77495. /** Gets or sets the height of spacers*/
  77496. get spacerHeight(): string;
  77497. set spacerHeight(value: string);
  77498. private _setSpacerHeight;
  77499. /** Adds a bar between groups */
  77500. private _addSpacer;
  77501. /** Add a group to the selection panel
  77502. * @param group is the selector group to add
  77503. */
  77504. addGroup(group: SelectorGroup): void;
  77505. /** Remove the group from the given position
  77506. * @param groupNb is the position of the group in the list
  77507. */
  77508. removeGroup(groupNb: number): void;
  77509. /** Change a group header label
  77510. * @param label is the new group header label
  77511. * @param groupNb is the number of the group to relabel
  77512. * */
  77513. setHeaderName(label: string, groupNb: number): void;
  77514. /** Change selector label to the one given
  77515. * @param label is the new selector label
  77516. * @param groupNb is the number of the groupcontaining the selector
  77517. * @param selectorNb is the number of the selector within a group to relabel
  77518. * */
  77519. relabel(label: string, groupNb: number, selectorNb: number): void;
  77520. /** For a given group position remove the selector at the given position
  77521. * @param groupNb is the number of the group to remove the selector from
  77522. * @param selectorNb is the number of the selector within the group
  77523. */
  77524. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77525. /** For a given group position of correct type add a checkbox button
  77526. * @param groupNb is the number of the group to remove the selector from
  77527. * @param label is the label for the selector
  77528. * @param func is the function called when the Selector is checked
  77529. * @param checked is true when Selector is checked
  77530. */
  77531. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77532. /** For a given group position of correct type add a radio button
  77533. * @param groupNb is the number of the group to remove the selector from
  77534. * @param label is the label for the selector
  77535. * @param func is the function called when the Selector is checked
  77536. * @param checked is true when Selector is checked
  77537. */
  77538. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77539. /**
  77540. * For a given slider group add a slider
  77541. * @param groupNb is the number of the group to add the slider to
  77542. * @param label is the label for the Slider
  77543. * @param func is the function called when the Slider moves
  77544. * @param unit is a string describing the units used, eg degrees or metres
  77545. * @param min is the minimum value for the Slider
  77546. * @param max is the maximum value for the Slider
  77547. * @param value is the start value for the Slider between min and max
  77548. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77549. */
  77550. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77551. }
  77552. }
  77553. declare module BABYLON.GUI {
  77554. /**
  77555. * Class used to hold a the container for ScrollViewer
  77556. * @hidden
  77557. */
  77558. export class _ScrollViewerWindow extends Container {
  77559. parentClientWidth: number;
  77560. parentClientHeight: number;
  77561. private _freezeControls;
  77562. private _parentMeasure;
  77563. private _oldLeft;
  77564. private _oldTop;
  77565. get freezeControls(): boolean;
  77566. set freezeControls(value: boolean);
  77567. private _bucketWidth;
  77568. private _bucketHeight;
  77569. private _buckets;
  77570. private _bucketLen;
  77571. get bucketWidth(): number;
  77572. get bucketHeight(): number;
  77573. setBucketSizes(width: number, height: number): void;
  77574. private _useBuckets;
  77575. private _makeBuckets;
  77576. private _dispatchInBuckets;
  77577. private _updateMeasures;
  77578. private _updateChildrenMeasures;
  77579. private _restoreMeasures;
  77580. /**
  77581. * Creates a new ScrollViewerWindow
  77582. * @param name of ScrollViewerWindow
  77583. */
  77584. constructor(name?: string);
  77585. protected _getTypeName(): string;
  77586. /** @hidden */
  77587. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77588. /** @hidden */
  77589. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77590. private _scrollChildren;
  77591. private _scrollChildrenWithBuckets;
  77592. /** @hidden */
  77593. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77594. protected _postMeasure(): void;
  77595. }
  77596. }
  77597. declare module BABYLON.GUI {
  77598. /**
  77599. * Class used to create slider controls
  77600. */
  77601. export class ScrollBar extends BaseSlider {
  77602. name?: string | undefined;
  77603. private _background;
  77604. private _borderColor;
  77605. private _tempMeasure;
  77606. /** Gets or sets border color */
  77607. get borderColor(): string;
  77608. set borderColor(value: string);
  77609. /** Gets or sets background color */
  77610. get background(): string;
  77611. set background(value: string);
  77612. /**
  77613. * Creates a new Slider
  77614. * @param name defines the control name
  77615. */
  77616. constructor(name?: string | undefined);
  77617. protected _getTypeName(): string;
  77618. protected _getThumbThickness(): number;
  77619. _draw(context: CanvasRenderingContext2D): void;
  77620. private _first;
  77621. private _originX;
  77622. private _originY;
  77623. /** @hidden */
  77624. protected _updateValueFromPointer(x: number, y: number): void;
  77625. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77626. }
  77627. }
  77628. declare module BABYLON.GUI {
  77629. /**
  77630. * Class used to create slider controls
  77631. */
  77632. export class ImageScrollBar extends BaseSlider {
  77633. name?: string | undefined;
  77634. private _backgroundBaseImage;
  77635. private _backgroundImage;
  77636. private _thumbImage;
  77637. private _thumbBaseImage;
  77638. private _thumbLength;
  77639. private _thumbHeight;
  77640. private _barImageHeight;
  77641. private _tempMeasure;
  77642. /** Number of 90° rotation to apply on the images when in vertical mode */
  77643. num90RotationInVerticalMode: number;
  77644. /**
  77645. * Gets or sets the image used to render the background for horizontal bar
  77646. */
  77647. get backgroundImage(): Image;
  77648. set backgroundImage(value: Image);
  77649. /**
  77650. * Gets or sets the image used to render the thumb
  77651. */
  77652. get thumbImage(): Image;
  77653. set thumbImage(value: Image);
  77654. /**
  77655. * Gets or sets the length of the thumb
  77656. */
  77657. get thumbLength(): number;
  77658. set thumbLength(value: number);
  77659. /**
  77660. * Gets or sets the height of the thumb
  77661. */
  77662. get thumbHeight(): number;
  77663. set thumbHeight(value: number);
  77664. /**
  77665. * Gets or sets the height of the bar image
  77666. */
  77667. get barImageHeight(): number;
  77668. set barImageHeight(value: number);
  77669. /**
  77670. * Creates a new ImageScrollBar
  77671. * @param name defines the control name
  77672. */
  77673. constructor(name?: string | undefined);
  77674. protected _getTypeName(): string;
  77675. protected _getThumbThickness(): number;
  77676. _draw(context: CanvasRenderingContext2D): void;
  77677. private _first;
  77678. private _originX;
  77679. private _originY;
  77680. /** @hidden */
  77681. protected _updateValueFromPointer(x: number, y: number): void;
  77682. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77683. }
  77684. }
  77685. declare module BABYLON.GUI {
  77686. /**
  77687. * Class used to hold a viewer window and sliders in a grid
  77688. */
  77689. export class ScrollViewer extends Rectangle {
  77690. private _grid;
  77691. private _horizontalBarSpace;
  77692. private _verticalBarSpace;
  77693. private _dragSpace;
  77694. private _horizontalBar;
  77695. private _verticalBar;
  77696. private _barColor;
  77697. private _barBackground;
  77698. private _barImage;
  77699. private _horizontalBarImage;
  77700. private _verticalBarImage;
  77701. private _barBackgroundImage;
  77702. private _horizontalBarBackgroundImage;
  77703. private _verticalBarBackgroundImage;
  77704. private _barSize;
  77705. private _window;
  77706. private _pointerIsOver;
  77707. private _wheelPrecision;
  77708. private _onWheelObserver;
  77709. private _clientWidth;
  77710. private _clientHeight;
  77711. private _useImageBar;
  77712. private _thumbLength;
  77713. private _thumbHeight;
  77714. private _barImageHeight;
  77715. private _horizontalBarImageHeight;
  77716. private _verticalBarImageHeight;
  77717. private _oldWindowContentsWidth;
  77718. private _oldWindowContentsHeight;
  77719. /**
  77720. * Gets the horizontal scrollbar
  77721. */
  77722. get horizontalBar(): ScrollBar | ImageScrollBar;
  77723. /**
  77724. * Gets the vertical scrollbar
  77725. */
  77726. get verticalBar(): ScrollBar | ImageScrollBar;
  77727. /**
  77728. * Adds a new control to the current container
  77729. * @param control defines the control to add
  77730. * @returns the current container
  77731. */
  77732. addControl(control: BABYLON.Nullable<Control>): Container;
  77733. /**
  77734. * Removes a control from the current container
  77735. * @param control defines the control to remove
  77736. * @returns the current container
  77737. */
  77738. removeControl(control: Control): Container;
  77739. /** Gets the list of children */
  77740. get children(): Control[];
  77741. _flagDescendantsAsMatrixDirty(): void;
  77742. /**
  77743. * Freezes or unfreezes the controls in the window.
  77744. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77745. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77746. */
  77747. get freezeControls(): boolean;
  77748. set freezeControls(value: boolean);
  77749. /** Gets the bucket width */
  77750. get bucketWidth(): number;
  77751. /** Gets the bucket height */
  77752. get bucketHeight(): number;
  77753. /**
  77754. * Sets the bucket sizes.
  77755. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77756. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77757. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77758. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77759. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77760. * used), that's why it is not enabled by default.
  77761. * @param width width of the bucket
  77762. * @param height height of the bucket
  77763. */
  77764. setBucketSizes(width: number, height: number): void;
  77765. private _forceHorizontalBar;
  77766. private _forceVerticalBar;
  77767. /**
  77768. * Forces the horizontal scroll bar to be displayed
  77769. */
  77770. get forceHorizontalBar(): boolean;
  77771. set forceHorizontalBar(value: boolean);
  77772. /**
  77773. * Forces the vertical scroll bar to be displayed
  77774. */
  77775. get forceVerticalBar(): boolean;
  77776. set forceVerticalBar(value: boolean);
  77777. /**
  77778. * Creates a new ScrollViewer
  77779. * @param name of ScrollViewer
  77780. */
  77781. constructor(name?: string, isImageBased?: boolean);
  77782. /** Reset the scroll viewer window to initial size */
  77783. resetWindow(): void;
  77784. protected _getTypeName(): string;
  77785. private _buildClientSizes;
  77786. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77787. protected _postMeasure(): void;
  77788. /**
  77789. * Gets or sets the mouse wheel precision
  77790. * from 0 to 1 with a default value of 0.05
  77791. * */
  77792. get wheelPrecision(): number;
  77793. set wheelPrecision(value: number);
  77794. /** Gets or sets the scroll bar container background color */
  77795. get scrollBackground(): string;
  77796. set scrollBackground(color: string);
  77797. /** Gets or sets the bar color */
  77798. get barColor(): string;
  77799. set barColor(color: string);
  77800. /** Gets or sets the bar image */
  77801. get thumbImage(): Image;
  77802. set thumbImage(value: Image);
  77803. /** Gets or sets the horizontal bar image */
  77804. get horizontalThumbImage(): Image;
  77805. set horizontalThumbImage(value: Image);
  77806. /** Gets or sets the vertical bar image */
  77807. get verticalThumbImage(): Image;
  77808. set verticalThumbImage(value: Image);
  77809. /** Gets or sets the size of the bar */
  77810. get barSize(): number;
  77811. set barSize(value: number);
  77812. /** Gets or sets the length of the thumb */
  77813. get thumbLength(): number;
  77814. set thumbLength(value: number);
  77815. /** Gets or sets the height of the thumb */
  77816. get thumbHeight(): number;
  77817. set thumbHeight(value: number);
  77818. /** Gets or sets the height of the bar image */
  77819. get barImageHeight(): number;
  77820. set barImageHeight(value: number);
  77821. /** Gets or sets the height of the horizontal bar image */
  77822. get horizontalBarImageHeight(): number;
  77823. set horizontalBarImageHeight(value: number);
  77824. /** Gets or sets the height of the vertical bar image */
  77825. get verticalBarImageHeight(): number;
  77826. set verticalBarImageHeight(value: number);
  77827. /** Gets or sets the bar background */
  77828. get barBackground(): string;
  77829. set barBackground(color: string);
  77830. /** Gets or sets the bar background image */
  77831. get barImage(): Image;
  77832. set barImage(value: Image);
  77833. /** Gets or sets the horizontal bar background image */
  77834. get horizontalBarImage(): Image;
  77835. set horizontalBarImage(value: Image);
  77836. /** Gets or sets the vertical bar background image */
  77837. get verticalBarImage(): Image;
  77838. set verticalBarImage(value: Image);
  77839. private _setWindowPosition;
  77840. /** @hidden */
  77841. private _updateScroller;
  77842. _link(host: AdvancedDynamicTexture): void;
  77843. /** @hidden */
  77844. private _addBar;
  77845. /** @hidden */
  77846. private _attachWheel;
  77847. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77848. /** Releases associated resources */
  77849. dispose(): void;
  77850. }
  77851. }
  77852. declare module BABYLON.GUI {
  77853. /** Class used to render a grid */
  77854. export class DisplayGrid extends Control {
  77855. name?: string | undefined;
  77856. private _cellWidth;
  77857. private _cellHeight;
  77858. private _minorLineTickness;
  77859. private _minorLineColor;
  77860. private _majorLineTickness;
  77861. private _majorLineColor;
  77862. private _majorLineFrequency;
  77863. private _background;
  77864. private _displayMajorLines;
  77865. private _displayMinorLines;
  77866. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77867. get displayMinorLines(): boolean;
  77868. set displayMinorLines(value: boolean);
  77869. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77870. get displayMajorLines(): boolean;
  77871. set displayMajorLines(value: boolean);
  77872. /** Gets or sets background color (Black by default) */
  77873. get background(): string;
  77874. set background(value: string);
  77875. /** Gets or sets the width of each cell (20 by default) */
  77876. get cellWidth(): number;
  77877. set cellWidth(value: number);
  77878. /** Gets or sets the height of each cell (20 by default) */
  77879. get cellHeight(): number;
  77880. set cellHeight(value: number);
  77881. /** Gets or sets the tickness of minor lines (1 by default) */
  77882. get minorLineTickness(): number;
  77883. set minorLineTickness(value: number);
  77884. /** Gets or sets the color of minor lines (DarkGray by default) */
  77885. get minorLineColor(): string;
  77886. set minorLineColor(value: string);
  77887. /** Gets or sets the tickness of major lines (2 by default) */
  77888. get majorLineTickness(): number;
  77889. set majorLineTickness(value: number);
  77890. /** Gets or sets the color of major lines (White by default) */
  77891. get majorLineColor(): string;
  77892. set majorLineColor(value: string);
  77893. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77894. get majorLineFrequency(): number;
  77895. set majorLineFrequency(value: number);
  77896. /**
  77897. * Creates a new GridDisplayRectangle
  77898. * @param name defines the control name
  77899. */
  77900. constructor(name?: string | undefined);
  77901. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77902. protected _getTypeName(): string;
  77903. }
  77904. }
  77905. declare module BABYLON.GUI {
  77906. /**
  77907. * Class used to create slider controls based on images
  77908. */
  77909. export class ImageBasedSlider extends BaseSlider {
  77910. name?: string | undefined;
  77911. private _backgroundImage;
  77912. private _thumbImage;
  77913. private _valueBarImage;
  77914. private _tempMeasure;
  77915. get displayThumb(): boolean;
  77916. set displayThumb(value: boolean);
  77917. /**
  77918. * Gets or sets the image used to render the background
  77919. */
  77920. get backgroundImage(): Image;
  77921. set backgroundImage(value: Image);
  77922. /**
  77923. * Gets or sets the image used to render the value bar
  77924. */
  77925. get valueBarImage(): Image;
  77926. set valueBarImage(value: Image);
  77927. /**
  77928. * Gets or sets the image used to render the thumb
  77929. */
  77930. get thumbImage(): Image;
  77931. set thumbImage(value: Image);
  77932. /**
  77933. * Creates a new ImageBasedSlider
  77934. * @param name defines the control name
  77935. */
  77936. constructor(name?: string | undefined);
  77937. protected _getTypeName(): string;
  77938. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77939. }
  77940. }
  77941. declare module BABYLON.GUI {
  77942. /**
  77943. * Forcing an export so that this code will execute
  77944. * @hidden
  77945. */
  77946. const name = "Statics";
  77947. }
  77948. declare module BABYLON.GUI {
  77949. /**
  77950. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77951. */
  77952. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77953. /**
  77954. * Define the instrumented AdvancedDynamicTexture.
  77955. */
  77956. texture: AdvancedDynamicTexture;
  77957. private _captureRenderTime;
  77958. private _renderTime;
  77959. private _captureLayoutTime;
  77960. private _layoutTime;
  77961. private _onBeginRenderObserver;
  77962. private _onEndRenderObserver;
  77963. private _onBeginLayoutObserver;
  77964. private _onEndLayoutObserver;
  77965. /**
  77966. * Gets the perf counter used to capture render time
  77967. */
  77968. get renderTimeCounter(): BABYLON.PerfCounter;
  77969. /**
  77970. * Gets the perf counter used to capture layout time
  77971. */
  77972. get layoutTimeCounter(): BABYLON.PerfCounter;
  77973. /**
  77974. * Enable or disable the render time capture
  77975. */
  77976. get captureRenderTime(): boolean;
  77977. set captureRenderTime(value: boolean);
  77978. /**
  77979. * Enable or disable the layout time capture
  77980. */
  77981. get captureLayoutTime(): boolean;
  77982. set captureLayoutTime(value: boolean);
  77983. /**
  77984. * Instantiates a new advanced dynamic texture instrumentation.
  77985. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77986. * @param texture Defines the AdvancedDynamicTexture to instrument
  77987. */
  77988. constructor(
  77989. /**
  77990. * Define the instrumented AdvancedDynamicTexture.
  77991. */
  77992. texture: AdvancedDynamicTexture);
  77993. /**
  77994. * Dispose and release associated resources.
  77995. */
  77996. dispose(): void;
  77997. }
  77998. }
  77999. declare module BABYLON.GUI {
  78000. /**
  78001. * Class used to load GUI via XML.
  78002. */
  78003. export class XmlLoader {
  78004. private _nodes;
  78005. private _nodeTypes;
  78006. private _isLoaded;
  78007. private _objectAttributes;
  78008. private _parentClass;
  78009. /**
  78010. * Create a new xml loader
  78011. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78012. */
  78013. constructor(parentClass?: null);
  78014. private _getChainElement;
  78015. private _getClassAttribute;
  78016. private _createGuiElement;
  78017. private _parseGrid;
  78018. private _parseElement;
  78019. private _prepareSourceElement;
  78020. private _parseElementsFromSource;
  78021. private _parseXml;
  78022. /**
  78023. * Gets if the loading has finished.
  78024. * @returns whether the loading has finished or not
  78025. */
  78026. isLoaded(): boolean;
  78027. /**
  78028. * Gets a loaded node / control by id.
  78029. * @param id the Controls id set in the xml
  78030. * @returns element of type Control
  78031. */
  78032. getNodeById(id: string): any;
  78033. /**
  78034. * Gets all loaded nodes / controls
  78035. * @returns Array of controls
  78036. */
  78037. getNodes(): any;
  78038. /**
  78039. * Initiates the xml layout loading
  78040. * @param xmlFile defines the xml layout to load
  78041. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78042. * @param callback defines the callback called on layout load.
  78043. */
  78044. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78045. }
  78046. }
  78047. declare module BABYLON.GUI {
  78048. /**
  78049. * Class used to create containers for controls
  78050. */
  78051. export class Container3D extends Control3D {
  78052. private _blockLayout;
  78053. /**
  78054. * Gets the list of child controls
  78055. */
  78056. protected _children: Control3D[];
  78057. /**
  78058. * Gets the list of child controls
  78059. */
  78060. get children(): Array<Control3D>;
  78061. /**
  78062. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78063. * This is helpful to optimize layout operation when adding multiple children in a row
  78064. */
  78065. get blockLayout(): boolean;
  78066. set blockLayout(value: boolean);
  78067. /**
  78068. * Creates a new container
  78069. * @param name defines the container name
  78070. */
  78071. constructor(name?: string);
  78072. /**
  78073. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78074. * @returns the current container
  78075. */
  78076. updateLayout(): Container3D;
  78077. /**
  78078. * Gets a boolean indicating if the given control is in the children of this control
  78079. * @param control defines the control to check
  78080. * @returns true if the control is in the child list
  78081. */
  78082. containsControl(control: Control3D): boolean;
  78083. /**
  78084. * Adds a control to the children of this control
  78085. * @param control defines the control to add
  78086. * @returns the current container
  78087. */
  78088. addControl(control: Control3D): Container3D;
  78089. /**
  78090. * This function will be called everytime a new control is added
  78091. */
  78092. protected _arrangeChildren(): void;
  78093. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78094. /**
  78095. * Removes a control from the children of this control
  78096. * @param control defines the control to remove
  78097. * @returns the current container
  78098. */
  78099. removeControl(control: Control3D): Container3D;
  78100. protected _getTypeName(): string;
  78101. /**
  78102. * Releases all associated resources
  78103. */
  78104. dispose(): void;
  78105. /** Control rotation will remain unchanged */
  78106. static readonly UNSET_ORIENTATION: number;
  78107. /** Control will rotate to make it look at sphere central axis */
  78108. static readonly FACEORIGIN_ORIENTATION: number;
  78109. /** Control will rotate to make it look back at sphere central axis */
  78110. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78111. /** Control will rotate to look at z axis (0, 0, 1) */
  78112. static readonly FACEFORWARD_ORIENTATION: number;
  78113. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78114. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78115. }
  78116. }
  78117. declare module BABYLON.GUI {
  78118. /**
  78119. * Class used to manage 3D user interface
  78120. * @see https://doc.babylonjs.com/how_to/gui3d
  78121. */
  78122. export class GUI3DManager implements BABYLON.IDisposable {
  78123. private _scene;
  78124. private _sceneDisposeObserver;
  78125. private _utilityLayer;
  78126. private _rootContainer;
  78127. private _pointerObserver;
  78128. private _pointerOutObserver;
  78129. /** @hidden */
  78130. _lastPickedControl: Control3D;
  78131. /** @hidden */
  78132. _lastControlOver: {
  78133. [pointerId: number]: Control3D;
  78134. };
  78135. /** @hidden */
  78136. _lastControlDown: {
  78137. [pointerId: number]: Control3D;
  78138. };
  78139. /**
  78140. * BABYLON.Observable raised when the point picked by the pointer events changed
  78141. */
  78142. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78143. /** @hidden */
  78144. _sharedMaterials: {
  78145. [key: string]: BABYLON.Material;
  78146. };
  78147. /** Gets the hosting scene */
  78148. get scene(): BABYLON.Scene;
  78149. /** Gets associated utility layer */
  78150. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78151. /**
  78152. * Creates a new GUI3DManager
  78153. * @param scene
  78154. */
  78155. constructor(scene?: BABYLON.Scene);
  78156. private _handlePointerOut;
  78157. private _doPicking;
  78158. /**
  78159. * Gets the root container
  78160. */
  78161. get rootContainer(): Container3D;
  78162. /**
  78163. * Gets a boolean indicating if the given control is in the root child list
  78164. * @param control defines the control to check
  78165. * @returns true if the control is in the root child list
  78166. */
  78167. containsControl(control: Control3D): boolean;
  78168. /**
  78169. * Adds a control to the root child list
  78170. * @param control defines the control to add
  78171. * @returns the current manager
  78172. */
  78173. addControl(control: Control3D): GUI3DManager;
  78174. /**
  78175. * Removes a control from the root child list
  78176. * @param control defines the control to remove
  78177. * @returns the current container
  78178. */
  78179. removeControl(control: Control3D): GUI3DManager;
  78180. /**
  78181. * Releases all associated resources
  78182. */
  78183. dispose(): void;
  78184. }
  78185. }
  78186. declare module BABYLON.GUI {
  78187. /**
  78188. * Class used to transport BABYLON.Vector3 information for pointer events
  78189. */
  78190. export class Vector3WithInfo extends BABYLON.Vector3 {
  78191. /** defines the current mouse button index */
  78192. buttonIndex: number;
  78193. /**
  78194. * Creates a new Vector3WithInfo
  78195. * @param source defines the vector3 data to transport
  78196. * @param buttonIndex defines the current mouse button index
  78197. */
  78198. constructor(source: BABYLON.Vector3,
  78199. /** defines the current mouse button index */
  78200. buttonIndex?: number);
  78201. }
  78202. }
  78203. declare module BABYLON.GUI {
  78204. /**
  78205. * Class used as base class for controls
  78206. */
  78207. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78208. /** Defines the control name */
  78209. name?: string | undefined;
  78210. /** @hidden */
  78211. _host: GUI3DManager;
  78212. private _node;
  78213. private _downCount;
  78214. private _enterCount;
  78215. private _downPointerIds;
  78216. private _isVisible;
  78217. /** Gets or sets the control position in world space */
  78218. get position(): BABYLON.Vector3;
  78219. set position(value: BABYLON.Vector3);
  78220. /** Gets or sets the control scaling in world space */
  78221. get scaling(): BABYLON.Vector3;
  78222. set scaling(value: BABYLON.Vector3);
  78223. /** Callback used to start pointer enter animation */
  78224. pointerEnterAnimation: () => void;
  78225. /** Callback used to start pointer out animation */
  78226. pointerOutAnimation: () => void;
  78227. /** Callback used to start pointer down animation */
  78228. pointerDownAnimation: () => void;
  78229. /** Callback used to start pointer up animation */
  78230. pointerUpAnimation: () => void;
  78231. /**
  78232. * An event triggered when the pointer move over the control
  78233. */
  78234. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78235. /**
  78236. * An event triggered when the pointer move out of the control
  78237. */
  78238. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78239. /**
  78240. * An event triggered when the pointer taps the control
  78241. */
  78242. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78243. /**
  78244. * An event triggered when pointer is up
  78245. */
  78246. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78247. /**
  78248. * An event triggered when a control is clicked on (with a mouse)
  78249. */
  78250. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78251. /**
  78252. * An event triggered when pointer enters the control
  78253. */
  78254. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78255. /**
  78256. * Gets or sets the parent container
  78257. */
  78258. parent: BABYLON.Nullable<Container3D>;
  78259. private _behaviors;
  78260. /**
  78261. * Gets the list of attached behaviors
  78262. * @see https://doc.babylonjs.com/features/behaviour
  78263. */
  78264. get behaviors(): BABYLON.Behavior<Control3D>[];
  78265. /**
  78266. * Attach a behavior to the control
  78267. * @see https://doc.babylonjs.com/features/behaviour
  78268. * @param behavior defines the behavior to attach
  78269. * @returns the current control
  78270. */
  78271. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78272. /**
  78273. * Remove an attached behavior
  78274. * @see https://doc.babylonjs.com/features/behaviour
  78275. * @param behavior defines the behavior to attach
  78276. * @returns the current control
  78277. */
  78278. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78279. /**
  78280. * Gets an attached behavior by name
  78281. * @param name defines the name of the behavior to look for
  78282. * @see https://doc.babylonjs.com/features/behaviour
  78283. * @returns null if behavior was not found else the requested behavior
  78284. */
  78285. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78286. /** Gets or sets a boolean indicating if the control is visible */
  78287. get isVisible(): boolean;
  78288. set isVisible(value: boolean);
  78289. /**
  78290. * Creates a new control
  78291. * @param name defines the control name
  78292. */
  78293. constructor(
  78294. /** Defines the control name */
  78295. name?: string | undefined);
  78296. /**
  78297. * Gets a string representing the class name
  78298. */
  78299. get typeName(): string;
  78300. /**
  78301. * Get the current class name of the control.
  78302. * @returns current class name
  78303. */
  78304. getClassName(): string;
  78305. protected _getTypeName(): string;
  78306. /**
  78307. * Gets the transform node used by this control
  78308. */
  78309. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78310. /**
  78311. * Gets the mesh used to render this control
  78312. */
  78313. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78314. /**
  78315. * Link the control as child of the given node
  78316. * @param node defines the node to link to. Use null to unlink the control
  78317. * @returns the current control
  78318. */
  78319. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78320. /** @hidden **/
  78321. _prepareNode(scene: BABYLON.Scene): void;
  78322. /**
  78323. * Node creation.
  78324. * Can be overriden by children
  78325. * @param scene defines the scene where the node must be attached
  78326. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78327. */
  78328. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78329. /**
  78330. * Affect a material to the given mesh
  78331. * @param mesh defines the mesh which will represent the control
  78332. */
  78333. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78334. /** @hidden */
  78335. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78336. /** @hidden */
  78337. _onPointerEnter(target: Control3D): boolean;
  78338. /** @hidden */
  78339. _onPointerOut(target: Control3D): void;
  78340. /** @hidden */
  78341. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78342. /** @hidden */
  78343. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78344. /** @hidden */
  78345. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78346. /** @hidden */
  78347. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78348. /** @hidden */
  78349. _disposeNode(): void;
  78350. /**
  78351. * Releases all associated resources
  78352. */
  78353. dispose(): void;
  78354. }
  78355. }
  78356. declare module BABYLON.GUI {
  78357. /**
  78358. * Class used as a root to all buttons
  78359. */
  78360. export class AbstractButton3D extends Control3D {
  78361. /**
  78362. * Creates a new button
  78363. * @param name defines the control name
  78364. */
  78365. constructor(name?: string);
  78366. protected _getTypeName(): string;
  78367. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78368. }
  78369. }
  78370. declare module BABYLON.GUI {
  78371. /**
  78372. * Class used to create a button in 3D
  78373. */
  78374. export class Button3D extends AbstractButton3D {
  78375. /** @hidden */
  78376. protected _currentMaterial: BABYLON.Material;
  78377. private _facadeTexture;
  78378. private _content;
  78379. private _contentResolution;
  78380. private _contentScaleRatio;
  78381. /**
  78382. * Gets or sets the texture resolution used to render content (512 by default)
  78383. */
  78384. get contentResolution(): BABYLON.int;
  78385. set contentResolution(value: BABYLON.int);
  78386. /**
  78387. * Gets or sets the texture scale ratio used to render content (2 by default)
  78388. */
  78389. get contentScaleRatio(): number;
  78390. set contentScaleRatio(value: number);
  78391. protected _disposeFacadeTexture(): void;
  78392. protected _resetContent(): void;
  78393. /**
  78394. * Creates a new button
  78395. * @param name defines the control name
  78396. */
  78397. constructor(name?: string);
  78398. /**
  78399. * Gets or sets the GUI 2D content used to display the button's facade
  78400. */
  78401. get content(): Control;
  78402. set content(value: Control);
  78403. /**
  78404. * Apply the facade texture (created from the content property).
  78405. * This function can be overloaded by child classes
  78406. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78407. */
  78408. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78409. protected _getTypeName(): string;
  78410. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78411. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78412. /**
  78413. * Releases all associated resources
  78414. */
  78415. dispose(): void;
  78416. }
  78417. }
  78418. declare module BABYLON.GUI {
  78419. /**
  78420. * Abstract class used to create a container panel deployed on the surface of a volume
  78421. */
  78422. export abstract class VolumeBasedPanel extends Container3D {
  78423. private _columns;
  78424. private _rows;
  78425. private _rowThenColum;
  78426. private _orientation;
  78427. protected _cellWidth: number;
  78428. protected _cellHeight: number;
  78429. /**
  78430. * Gets or sets the distance between elements
  78431. */
  78432. margin: number;
  78433. /**
  78434. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78435. * | Value | Type | Description |
  78436. * | ----- | ----------------------------------- | ----------- |
  78437. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78438. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78439. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78440. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78441. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78442. */
  78443. get orientation(): number;
  78444. set orientation(value: number);
  78445. /**
  78446. * Gets or sets the number of columns requested (10 by default).
  78447. * The panel will automatically compute the number of rows based on number of child controls.
  78448. */
  78449. get columns(): BABYLON.int;
  78450. set columns(value: BABYLON.int);
  78451. /**
  78452. * Gets or sets a the number of rows requested.
  78453. * The panel will automatically compute the number of columns based on number of child controls.
  78454. */
  78455. get rows(): BABYLON.int;
  78456. set rows(value: BABYLON.int);
  78457. /**
  78458. * Creates new VolumeBasedPanel
  78459. */
  78460. constructor();
  78461. protected _arrangeChildren(): void;
  78462. /** Child classes must implement this function to provide correct control positioning */
  78463. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78464. /** Child classes can implement this function to provide additional processing */
  78465. protected _finalProcessing(): void;
  78466. }
  78467. }
  78468. declare module BABYLON.GUI {
  78469. /**
  78470. * Class used to create a container panel deployed on the surface of a cylinder
  78471. */
  78472. export class CylinderPanel extends VolumeBasedPanel {
  78473. private _radius;
  78474. /**
  78475. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78476. */
  78477. get radius(): BABYLON.float;
  78478. set radius(value: BABYLON.float);
  78479. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78480. private _cylindricalMapping;
  78481. }
  78482. }
  78483. declare module BABYLON.GUI {
  78484. /** @hidden */
  78485. export var fluentVertexShader: {
  78486. name: string;
  78487. shader: string;
  78488. };
  78489. }
  78490. declare module BABYLON.GUI {
  78491. /** @hidden */
  78492. export var fluentPixelShader: {
  78493. name: string;
  78494. shader: string;
  78495. };
  78496. }
  78497. declare module BABYLON.GUI {
  78498. /** @hidden */
  78499. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78500. INNERGLOW: boolean;
  78501. BORDER: boolean;
  78502. HOVERLIGHT: boolean;
  78503. TEXTURE: boolean;
  78504. constructor();
  78505. }
  78506. /**
  78507. * Class used to render controls with fluent desgin
  78508. */
  78509. export class FluentMaterial extends BABYLON.PushMaterial {
  78510. /**
  78511. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78512. */
  78513. innerGlowColorIntensity: number;
  78514. /**
  78515. * Gets or sets the inner glow color (white by default)
  78516. */
  78517. innerGlowColor: BABYLON.Color3;
  78518. /**
  78519. * Gets or sets alpha value (default is 1.0)
  78520. */
  78521. alpha: number;
  78522. /**
  78523. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78524. */
  78525. albedoColor: BABYLON.Color3;
  78526. /**
  78527. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78528. */
  78529. renderBorders: boolean;
  78530. /**
  78531. * Gets or sets border width (default is 0.5)
  78532. */
  78533. borderWidth: number;
  78534. /**
  78535. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78536. */
  78537. edgeSmoothingValue: number;
  78538. /**
  78539. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78540. */
  78541. borderMinValue: number;
  78542. /**
  78543. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78544. */
  78545. renderHoverLight: boolean;
  78546. /**
  78547. * Gets or sets the radius used to render the hover light (default is 1.0)
  78548. */
  78549. hoverRadius: number;
  78550. /**
  78551. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78552. */
  78553. hoverColor: BABYLON.Color4;
  78554. /**
  78555. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78556. */
  78557. hoverPosition: BABYLON.Vector3;
  78558. private _albedoTexture;
  78559. /** Gets or sets the texture to use for albedo color */
  78560. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78561. /**
  78562. * Creates a new Fluent material
  78563. * @param name defines the name of the material
  78564. * @param scene defines the hosting scene
  78565. */
  78566. constructor(name: string, scene: BABYLON.Scene);
  78567. needAlphaBlending(): boolean;
  78568. needAlphaTesting(): boolean;
  78569. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78570. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78571. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78572. getActiveTextures(): BABYLON.BaseTexture[];
  78573. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78574. dispose(forceDisposeEffect?: boolean): void;
  78575. clone(name: string): FluentMaterial;
  78576. serialize(): any;
  78577. getClassName(): string;
  78578. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78579. }
  78580. }
  78581. declare module BABYLON.GUI {
  78582. /**
  78583. * Class used to create a holographic button in 3D
  78584. */
  78585. export class HolographicButton extends Button3D {
  78586. private _backPlate;
  78587. private _textPlate;
  78588. private _frontPlate;
  78589. private _text;
  78590. private _imageUrl;
  78591. private _shareMaterials;
  78592. private _frontMaterial;
  78593. private _backMaterial;
  78594. private _plateMaterial;
  78595. private _pickedPointObserver;
  78596. private _tooltipFade;
  78597. private _tooltipTextBlock;
  78598. private _tooltipTexture;
  78599. private _tooltipMesh;
  78600. private _tooltipHoverObserver;
  78601. private _tooltipOutObserver;
  78602. private _disposeTooltip;
  78603. /**
  78604. * Rendering ground id of all the mesh in the button
  78605. */
  78606. set renderingGroupId(id: number);
  78607. get renderingGroupId(): number;
  78608. /**
  78609. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78610. */
  78611. set tooltipText(text: BABYLON.Nullable<string>);
  78612. get tooltipText(): BABYLON.Nullable<string>;
  78613. /**
  78614. * Gets or sets text for the button
  78615. */
  78616. get text(): string;
  78617. set text(value: string);
  78618. /**
  78619. * Gets or sets the image url for the button
  78620. */
  78621. get imageUrl(): string;
  78622. set imageUrl(value: string);
  78623. /**
  78624. * Gets the back material used by this button
  78625. */
  78626. get backMaterial(): FluentMaterial;
  78627. /**
  78628. * Gets the front material used by this button
  78629. */
  78630. get frontMaterial(): FluentMaterial;
  78631. /**
  78632. * Gets the plate material used by this button
  78633. */
  78634. get plateMaterial(): BABYLON.StandardMaterial;
  78635. /**
  78636. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78637. */
  78638. get shareMaterials(): boolean;
  78639. /**
  78640. * Creates a new button
  78641. * @param name defines the control name
  78642. */
  78643. constructor(name?: string, shareMaterials?: boolean);
  78644. protected _getTypeName(): string;
  78645. private _rebuildContent;
  78646. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78647. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78648. private _createBackMaterial;
  78649. private _createFrontMaterial;
  78650. private _createPlateMaterial;
  78651. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78652. /**
  78653. * Releases all associated resources
  78654. */
  78655. dispose(): void;
  78656. }
  78657. }
  78658. declare module BABYLON.GUI {
  78659. /**
  78660. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78661. */
  78662. export class MeshButton3D extends Button3D {
  78663. /** @hidden */
  78664. protected _currentMesh: BABYLON.Mesh;
  78665. /**
  78666. * Creates a new 3D button based on a mesh
  78667. * @param mesh mesh to become a 3D button
  78668. * @param name defines the control name
  78669. */
  78670. constructor(mesh: BABYLON.Mesh, name?: string);
  78671. protected _getTypeName(): string;
  78672. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78673. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78674. }
  78675. }
  78676. declare module BABYLON.GUI {
  78677. /**
  78678. * Class used to create a container panel deployed on the surface of a plane
  78679. */
  78680. export class PlanePanel extends VolumeBasedPanel {
  78681. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78682. }
  78683. }
  78684. declare module BABYLON.GUI {
  78685. /**
  78686. * Class used to create a container panel where items get randomized planar mapping
  78687. */
  78688. export class ScatterPanel extends VolumeBasedPanel {
  78689. private _iteration;
  78690. /**
  78691. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78692. */
  78693. get iteration(): BABYLON.float;
  78694. set iteration(value: BABYLON.float);
  78695. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78696. private _scatterMapping;
  78697. protected _finalProcessing(): void;
  78698. }
  78699. }
  78700. declare module BABYLON.GUI {
  78701. /**
  78702. * Class used to create a container panel deployed on the surface of a sphere
  78703. */
  78704. export class SpherePanel extends VolumeBasedPanel {
  78705. private _radius;
  78706. /**
  78707. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78708. */
  78709. get radius(): BABYLON.float;
  78710. set radius(value: BABYLON.float);
  78711. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78712. private _sphericalMapping;
  78713. }
  78714. }
  78715. declare module BABYLON.GUI {
  78716. /**
  78717. * Class used to create a stack panel in 3D on XY plane
  78718. */
  78719. export class StackPanel3D extends Container3D {
  78720. private _isVertical;
  78721. /**
  78722. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78723. */
  78724. get isVertical(): boolean;
  78725. set isVertical(value: boolean);
  78726. /**
  78727. * Gets or sets the distance between elements
  78728. */
  78729. margin: number;
  78730. /**
  78731. * Creates new StackPanel
  78732. * @param isVertical
  78733. */
  78734. constructor(isVertical?: boolean);
  78735. protected _arrangeChildren(): void;
  78736. }
  78737. }
  78738. declare module BABYLON {
  78739. /**
  78740. * Configuration for glTF validation
  78741. */
  78742. export interface IGLTFValidationConfiguration {
  78743. /**
  78744. * The url of the glTF validator.
  78745. */
  78746. url: string;
  78747. }
  78748. /**
  78749. * glTF validation
  78750. */
  78751. export class GLTFValidation {
  78752. /**
  78753. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78754. */
  78755. static Configuration: IGLTFValidationConfiguration;
  78756. private static _LoadScriptPromise;
  78757. /**
  78758. * Validate a glTF asset using the glTF-Validator.
  78759. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78760. * @param rootUrl The root url for the glTF
  78761. * @param fileName The file name for the glTF
  78762. * @param getExternalResource The callback to get external resources for the glTF validator
  78763. * @returns A promise that resolves with the glTF validation results once complete
  78764. */
  78765. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78766. }
  78767. }
  78768. declare module BABYLON {
  78769. /**
  78770. * Mode that determines the coordinate system to use.
  78771. */
  78772. export enum GLTFLoaderCoordinateSystemMode {
  78773. /**
  78774. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78775. */
  78776. AUTO = 0,
  78777. /**
  78778. * Sets the useRightHandedSystem flag on the scene.
  78779. */
  78780. FORCE_RIGHT_HANDED = 1
  78781. }
  78782. /**
  78783. * Mode that determines what animations will start.
  78784. */
  78785. export enum GLTFLoaderAnimationStartMode {
  78786. /**
  78787. * No animation will start.
  78788. */
  78789. NONE = 0,
  78790. /**
  78791. * The first animation will start.
  78792. */
  78793. FIRST = 1,
  78794. /**
  78795. * All animations will start.
  78796. */
  78797. ALL = 2
  78798. }
  78799. /**
  78800. * Interface that contains the data for the glTF asset.
  78801. */
  78802. export interface IGLTFLoaderData {
  78803. /**
  78804. * The object that represents the glTF JSON.
  78805. */
  78806. json: Object;
  78807. /**
  78808. * The BIN chunk of a binary glTF.
  78809. */
  78810. bin: Nullable<IDataBuffer>;
  78811. }
  78812. /**
  78813. * Interface for extending the loader.
  78814. */
  78815. export interface IGLTFLoaderExtension {
  78816. /**
  78817. * The name of this extension.
  78818. */
  78819. readonly name: string;
  78820. /**
  78821. * Defines whether this extension is enabled.
  78822. */
  78823. enabled: boolean;
  78824. /**
  78825. * Defines the order of this extension.
  78826. * The loader sorts the extensions using these values when loading.
  78827. */
  78828. order?: number;
  78829. }
  78830. /**
  78831. * Loader state.
  78832. */
  78833. export enum GLTFLoaderState {
  78834. /**
  78835. * The asset is loading.
  78836. */
  78837. LOADING = 0,
  78838. /**
  78839. * The asset is ready for rendering.
  78840. */
  78841. READY = 1,
  78842. /**
  78843. * The asset is completely loaded.
  78844. */
  78845. COMPLETE = 2
  78846. }
  78847. /** @hidden */
  78848. export interface IImportMeshAsyncOutput {
  78849. meshes: AbstractMesh[];
  78850. particleSystems: IParticleSystem[];
  78851. skeletons: Skeleton[];
  78852. animationGroups: AnimationGroup[];
  78853. lights: Light[];
  78854. transformNodes: TransformNode[];
  78855. }
  78856. /** @hidden */
  78857. export interface IGLTFLoader extends IDisposable {
  78858. readonly state: Nullable<GLTFLoaderState>;
  78859. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78860. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78861. }
  78862. /**
  78863. * File loader for loading glTF files into a scene.
  78864. */
  78865. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78866. /** @hidden */
  78867. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78868. /** @hidden */
  78869. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78870. /**
  78871. * Raised when the asset has been parsed
  78872. */
  78873. onParsedObservable: Observable<IGLTFLoaderData>;
  78874. private _onParsedObserver;
  78875. /**
  78876. * Raised when the asset has been parsed
  78877. */
  78878. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78879. /**
  78880. * 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.
  78881. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78882. * Defaults to true.
  78883. * @hidden
  78884. */
  78885. static IncrementalLoading: boolean;
  78886. /**
  78887. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78888. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78889. * @hidden
  78890. */
  78891. static HomogeneousCoordinates: boolean;
  78892. /**
  78893. * The coordinate system mode. Defaults to AUTO.
  78894. */
  78895. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78896. /**
  78897. * The animation start mode. Defaults to FIRST.
  78898. */
  78899. animationStartMode: GLTFLoaderAnimationStartMode;
  78900. /**
  78901. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78902. */
  78903. compileMaterials: boolean;
  78904. /**
  78905. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78906. */
  78907. useClipPlane: boolean;
  78908. /**
  78909. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78910. */
  78911. compileShadowGenerators: boolean;
  78912. /**
  78913. * Defines if the Alpha blended materials are only applied as coverage.
  78914. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78915. * If true, no extra effects are applied to transparent pixels.
  78916. */
  78917. transparencyAsCoverage: boolean;
  78918. /**
  78919. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78920. * Enabling will disable offline support and glTF validator.
  78921. * Defaults to false.
  78922. */
  78923. useRangeRequests: boolean;
  78924. /**
  78925. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78926. */
  78927. createInstances: boolean;
  78928. /**
  78929. * Function called before loading a url referenced by the asset.
  78930. */
  78931. preprocessUrlAsync: (url: string) => Promise<string>;
  78932. /**
  78933. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78934. */
  78935. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78936. private _onMeshLoadedObserver;
  78937. /**
  78938. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78939. */
  78940. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78941. /**
  78942. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78943. */
  78944. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78945. private _onTextureLoadedObserver;
  78946. /**
  78947. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78948. */
  78949. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78950. /**
  78951. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78952. */
  78953. readonly onMaterialLoadedObservable: Observable<Material>;
  78954. private _onMaterialLoadedObserver;
  78955. /**
  78956. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78957. */
  78958. set onMaterialLoaded(callback: (material: Material) => void);
  78959. /**
  78960. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78961. */
  78962. readonly onCameraLoadedObservable: Observable<Camera>;
  78963. private _onCameraLoadedObserver;
  78964. /**
  78965. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78966. */
  78967. set onCameraLoaded(callback: (camera: Camera) => void);
  78968. /**
  78969. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78970. * For assets with LODs, raised when all of the LODs are complete.
  78971. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78972. */
  78973. readonly onCompleteObservable: Observable<void>;
  78974. private _onCompleteObserver;
  78975. /**
  78976. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78977. * For assets with LODs, raised when all of the LODs are complete.
  78978. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78979. */
  78980. set onComplete(callback: () => void);
  78981. /**
  78982. * Observable raised when an error occurs.
  78983. */
  78984. readonly onErrorObservable: Observable<any>;
  78985. private _onErrorObserver;
  78986. /**
  78987. * Callback raised when an error occurs.
  78988. */
  78989. set onError(callback: (reason: any) => void);
  78990. /**
  78991. * Observable raised after the loader is disposed.
  78992. */
  78993. readonly onDisposeObservable: Observable<void>;
  78994. private _onDisposeObserver;
  78995. /**
  78996. * Callback raised after the loader is disposed.
  78997. */
  78998. set onDispose(callback: () => void);
  78999. /**
  79000. * Observable raised after a loader extension is created.
  79001. * Set additional options for a loader extension in this event.
  79002. */
  79003. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79004. private _onExtensionLoadedObserver;
  79005. /**
  79006. * Callback raised after a loader extension is created.
  79007. */
  79008. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79009. /**
  79010. * Defines if the loader logging is enabled.
  79011. */
  79012. get loggingEnabled(): boolean;
  79013. set loggingEnabled(value: boolean);
  79014. /**
  79015. * Defines if the loader should capture performance counters.
  79016. */
  79017. get capturePerformanceCounters(): boolean;
  79018. set capturePerformanceCounters(value: boolean);
  79019. /**
  79020. * Defines if the loader should validate the asset.
  79021. */
  79022. validate: boolean;
  79023. /**
  79024. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79025. */
  79026. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79027. private _onValidatedObserver;
  79028. /**
  79029. * Callback raised after a loader extension is created.
  79030. */
  79031. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79032. private _loader;
  79033. private _progressCallback?;
  79034. private _requests;
  79035. /**
  79036. * Name of the loader ("gltf")
  79037. */
  79038. name: string;
  79039. /** @hidden */
  79040. extensions: ISceneLoaderPluginExtensions;
  79041. /**
  79042. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79043. */
  79044. dispose(): void;
  79045. /** @hidden */
  79046. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79047. /** @hidden */
  79048. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79049. /** @hidden */
  79050. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79051. meshes: AbstractMesh[];
  79052. particleSystems: IParticleSystem[];
  79053. skeletons: Skeleton[];
  79054. animationGroups: AnimationGroup[];
  79055. }>;
  79056. /** @hidden */
  79057. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79058. /** @hidden */
  79059. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79060. /** @hidden */
  79061. canDirectLoad(data: string): boolean;
  79062. /** @hidden */
  79063. directLoad(scene: Scene, data: string): any;
  79064. /**
  79065. * The callback that allows custom handling of the root url based on the response url.
  79066. * @param rootUrl the original root url
  79067. * @param responseURL the response url if available
  79068. * @returns the new root url
  79069. */
  79070. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79071. /** @hidden */
  79072. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79073. /**
  79074. * The loader state or null if the loader is not active.
  79075. */
  79076. get loaderState(): Nullable<GLTFLoaderState>;
  79077. /**
  79078. * Returns a promise that resolves when the asset is completely loaded.
  79079. * @returns a promise that resolves when the asset is completely loaded.
  79080. */
  79081. whenCompleteAsync(): Promise<void>;
  79082. /** @hidden */
  79083. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79084. /** @hidden */
  79085. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79086. private _onProgress;
  79087. private _validate;
  79088. private _getLoader;
  79089. private _parseJson;
  79090. private _unpackBinaryAsync;
  79091. private _unpackBinaryV1Async;
  79092. private _unpackBinaryV2Async;
  79093. private static _parseVersion;
  79094. private static _compareVersion;
  79095. private static readonly _logSpaces;
  79096. private _logIndentLevel;
  79097. private _loggingEnabled;
  79098. /** @hidden */
  79099. _log: (message: string) => void;
  79100. /** @hidden */
  79101. _logOpen(message: string): void;
  79102. /** @hidden */
  79103. _logClose(): void;
  79104. private _logEnabled;
  79105. private _logDisabled;
  79106. private _capturePerformanceCounters;
  79107. /** @hidden */
  79108. _startPerformanceCounter: (counterName: string) => void;
  79109. /** @hidden */
  79110. _endPerformanceCounter: (counterName: string) => void;
  79111. private _startPerformanceCounterEnabled;
  79112. private _startPerformanceCounterDisabled;
  79113. private _endPerformanceCounterEnabled;
  79114. private _endPerformanceCounterDisabled;
  79115. }
  79116. }
  79117. declare module BABYLON.GLTF1 {
  79118. /**
  79119. * Enums
  79120. * @hidden
  79121. */
  79122. export enum EComponentType {
  79123. BYTE = 5120,
  79124. UNSIGNED_BYTE = 5121,
  79125. SHORT = 5122,
  79126. UNSIGNED_SHORT = 5123,
  79127. FLOAT = 5126
  79128. }
  79129. /** @hidden */
  79130. export enum EShaderType {
  79131. FRAGMENT = 35632,
  79132. VERTEX = 35633
  79133. }
  79134. /** @hidden */
  79135. export enum EParameterType {
  79136. BYTE = 5120,
  79137. UNSIGNED_BYTE = 5121,
  79138. SHORT = 5122,
  79139. UNSIGNED_SHORT = 5123,
  79140. INT = 5124,
  79141. UNSIGNED_INT = 5125,
  79142. FLOAT = 5126,
  79143. FLOAT_VEC2 = 35664,
  79144. FLOAT_VEC3 = 35665,
  79145. FLOAT_VEC4 = 35666,
  79146. INT_VEC2 = 35667,
  79147. INT_VEC3 = 35668,
  79148. INT_VEC4 = 35669,
  79149. BOOL = 35670,
  79150. BOOL_VEC2 = 35671,
  79151. BOOL_VEC3 = 35672,
  79152. BOOL_VEC4 = 35673,
  79153. FLOAT_MAT2 = 35674,
  79154. FLOAT_MAT3 = 35675,
  79155. FLOAT_MAT4 = 35676,
  79156. SAMPLER_2D = 35678
  79157. }
  79158. /** @hidden */
  79159. export enum ETextureWrapMode {
  79160. CLAMP_TO_EDGE = 33071,
  79161. MIRRORED_REPEAT = 33648,
  79162. REPEAT = 10497
  79163. }
  79164. /** @hidden */
  79165. export enum ETextureFilterType {
  79166. NEAREST = 9728,
  79167. LINEAR = 9728,
  79168. NEAREST_MIPMAP_NEAREST = 9984,
  79169. LINEAR_MIPMAP_NEAREST = 9985,
  79170. NEAREST_MIPMAP_LINEAR = 9986,
  79171. LINEAR_MIPMAP_LINEAR = 9987
  79172. }
  79173. /** @hidden */
  79174. export enum ETextureFormat {
  79175. ALPHA = 6406,
  79176. RGB = 6407,
  79177. RGBA = 6408,
  79178. LUMINANCE = 6409,
  79179. LUMINANCE_ALPHA = 6410
  79180. }
  79181. /** @hidden */
  79182. export enum ECullingType {
  79183. FRONT = 1028,
  79184. BACK = 1029,
  79185. FRONT_AND_BACK = 1032
  79186. }
  79187. /** @hidden */
  79188. export enum EBlendingFunction {
  79189. ZERO = 0,
  79190. ONE = 1,
  79191. SRC_COLOR = 768,
  79192. ONE_MINUS_SRC_COLOR = 769,
  79193. DST_COLOR = 774,
  79194. ONE_MINUS_DST_COLOR = 775,
  79195. SRC_ALPHA = 770,
  79196. ONE_MINUS_SRC_ALPHA = 771,
  79197. DST_ALPHA = 772,
  79198. ONE_MINUS_DST_ALPHA = 773,
  79199. CONSTANT_COLOR = 32769,
  79200. ONE_MINUS_CONSTANT_COLOR = 32770,
  79201. CONSTANT_ALPHA = 32771,
  79202. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79203. SRC_ALPHA_SATURATE = 776
  79204. }
  79205. /** @hidden */
  79206. export interface IGLTFProperty {
  79207. extensions?: {
  79208. [key: string]: any;
  79209. };
  79210. extras?: Object;
  79211. }
  79212. /** @hidden */
  79213. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79214. name?: string;
  79215. }
  79216. /** @hidden */
  79217. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79218. bufferView: string;
  79219. byteOffset: number;
  79220. byteStride: number;
  79221. count: number;
  79222. type: string;
  79223. componentType: EComponentType;
  79224. max?: number[];
  79225. min?: number[];
  79226. name?: string;
  79227. }
  79228. /** @hidden */
  79229. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79230. buffer: string;
  79231. byteOffset: number;
  79232. byteLength: number;
  79233. byteStride: number;
  79234. target?: number;
  79235. }
  79236. /** @hidden */
  79237. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79238. uri: string;
  79239. byteLength?: number;
  79240. type?: string;
  79241. }
  79242. /** @hidden */
  79243. export interface IGLTFShader extends IGLTFChildRootProperty {
  79244. uri: string;
  79245. type: EShaderType;
  79246. }
  79247. /** @hidden */
  79248. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79249. attributes: string[];
  79250. fragmentShader: string;
  79251. vertexShader: string;
  79252. }
  79253. /** @hidden */
  79254. export interface IGLTFTechniqueParameter {
  79255. type: number;
  79256. count?: number;
  79257. semantic?: string;
  79258. node?: string;
  79259. value?: number | boolean | string | Array<any>;
  79260. source?: string;
  79261. babylonValue?: any;
  79262. }
  79263. /** @hidden */
  79264. export interface IGLTFTechniqueCommonProfile {
  79265. lightingModel: string;
  79266. texcoordBindings: Object;
  79267. parameters?: Array<any>;
  79268. }
  79269. /** @hidden */
  79270. export interface IGLTFTechniqueStatesFunctions {
  79271. blendColor?: number[];
  79272. blendEquationSeparate?: number[];
  79273. blendFuncSeparate?: number[];
  79274. colorMask: boolean[];
  79275. cullFace: number[];
  79276. }
  79277. /** @hidden */
  79278. export interface IGLTFTechniqueStates {
  79279. enable: number[];
  79280. functions: IGLTFTechniqueStatesFunctions;
  79281. }
  79282. /** @hidden */
  79283. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79284. parameters: {
  79285. [key: string]: IGLTFTechniqueParameter;
  79286. };
  79287. program: string;
  79288. attributes: {
  79289. [key: string]: string;
  79290. };
  79291. uniforms: {
  79292. [key: string]: string;
  79293. };
  79294. states: IGLTFTechniqueStates;
  79295. }
  79296. /** @hidden */
  79297. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79298. technique?: string;
  79299. values: string[];
  79300. }
  79301. /** @hidden */
  79302. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79303. attributes: {
  79304. [key: string]: string;
  79305. };
  79306. indices: string;
  79307. material: string;
  79308. mode?: number;
  79309. }
  79310. /** @hidden */
  79311. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79312. primitives: IGLTFMeshPrimitive[];
  79313. }
  79314. /** @hidden */
  79315. export interface IGLTFImage extends IGLTFChildRootProperty {
  79316. uri: string;
  79317. }
  79318. /** @hidden */
  79319. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79320. magFilter?: number;
  79321. minFilter?: number;
  79322. wrapS?: number;
  79323. wrapT?: number;
  79324. }
  79325. /** @hidden */
  79326. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79327. sampler: string;
  79328. source: string;
  79329. format?: ETextureFormat;
  79330. internalFormat?: ETextureFormat;
  79331. target?: number;
  79332. type?: number;
  79333. babylonTexture?: Texture;
  79334. }
  79335. /** @hidden */
  79336. export interface IGLTFAmbienLight {
  79337. color?: number[];
  79338. }
  79339. /** @hidden */
  79340. export interface IGLTFDirectionalLight {
  79341. color?: number[];
  79342. }
  79343. /** @hidden */
  79344. export interface IGLTFPointLight {
  79345. color?: number[];
  79346. constantAttenuation?: number;
  79347. linearAttenuation?: number;
  79348. quadraticAttenuation?: number;
  79349. }
  79350. /** @hidden */
  79351. export interface IGLTFSpotLight {
  79352. color?: number[];
  79353. constantAttenuation?: number;
  79354. fallOfAngle?: number;
  79355. fallOffExponent?: number;
  79356. linearAttenuation?: number;
  79357. quadraticAttenuation?: number;
  79358. }
  79359. /** @hidden */
  79360. export interface IGLTFLight extends IGLTFChildRootProperty {
  79361. type: string;
  79362. }
  79363. /** @hidden */
  79364. export interface IGLTFCameraOrthographic {
  79365. xmag: number;
  79366. ymag: number;
  79367. zfar: number;
  79368. znear: number;
  79369. }
  79370. /** @hidden */
  79371. export interface IGLTFCameraPerspective {
  79372. aspectRatio: number;
  79373. yfov: number;
  79374. zfar: number;
  79375. znear: number;
  79376. }
  79377. /** @hidden */
  79378. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79379. type: string;
  79380. }
  79381. /** @hidden */
  79382. export interface IGLTFAnimationChannelTarget {
  79383. id: string;
  79384. path: string;
  79385. }
  79386. /** @hidden */
  79387. export interface IGLTFAnimationChannel {
  79388. sampler: string;
  79389. target: IGLTFAnimationChannelTarget;
  79390. }
  79391. /** @hidden */
  79392. export interface IGLTFAnimationSampler {
  79393. input: string;
  79394. output: string;
  79395. interpolation?: string;
  79396. }
  79397. /** @hidden */
  79398. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79399. channels?: IGLTFAnimationChannel[];
  79400. parameters?: {
  79401. [key: string]: string;
  79402. };
  79403. samplers?: {
  79404. [key: string]: IGLTFAnimationSampler;
  79405. };
  79406. }
  79407. /** @hidden */
  79408. export interface IGLTFNodeInstanceSkin {
  79409. skeletons: string[];
  79410. skin: string;
  79411. meshes: string[];
  79412. }
  79413. /** @hidden */
  79414. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79415. bindShapeMatrix: number[];
  79416. inverseBindMatrices: string;
  79417. jointNames: string[];
  79418. babylonSkeleton?: Skeleton;
  79419. }
  79420. /** @hidden */
  79421. export interface IGLTFNode extends IGLTFChildRootProperty {
  79422. camera?: string;
  79423. children: string[];
  79424. skin?: string;
  79425. jointName?: string;
  79426. light?: string;
  79427. matrix: number[];
  79428. mesh?: string;
  79429. meshes?: string[];
  79430. rotation?: number[];
  79431. scale?: number[];
  79432. translation?: number[];
  79433. babylonNode?: Node;
  79434. }
  79435. /** @hidden */
  79436. export interface IGLTFScene extends IGLTFChildRootProperty {
  79437. nodes: string[];
  79438. }
  79439. /** @hidden */
  79440. export interface IGLTFRuntime {
  79441. extensions: {
  79442. [key: string]: any;
  79443. };
  79444. accessors: {
  79445. [key: string]: IGLTFAccessor;
  79446. };
  79447. buffers: {
  79448. [key: string]: IGLTFBuffer;
  79449. };
  79450. bufferViews: {
  79451. [key: string]: IGLTFBufferView;
  79452. };
  79453. meshes: {
  79454. [key: string]: IGLTFMesh;
  79455. };
  79456. lights: {
  79457. [key: string]: IGLTFLight;
  79458. };
  79459. cameras: {
  79460. [key: string]: IGLTFCamera;
  79461. };
  79462. nodes: {
  79463. [key: string]: IGLTFNode;
  79464. };
  79465. images: {
  79466. [key: string]: IGLTFImage;
  79467. };
  79468. textures: {
  79469. [key: string]: IGLTFTexture;
  79470. };
  79471. shaders: {
  79472. [key: string]: IGLTFShader;
  79473. };
  79474. programs: {
  79475. [key: string]: IGLTFProgram;
  79476. };
  79477. samplers: {
  79478. [key: string]: IGLTFSampler;
  79479. };
  79480. techniques: {
  79481. [key: string]: IGLTFTechnique;
  79482. };
  79483. materials: {
  79484. [key: string]: IGLTFMaterial;
  79485. };
  79486. animations: {
  79487. [key: string]: IGLTFAnimation;
  79488. };
  79489. skins: {
  79490. [key: string]: IGLTFSkins;
  79491. };
  79492. currentScene?: Object;
  79493. scenes: {
  79494. [key: string]: IGLTFScene;
  79495. };
  79496. extensionsUsed: string[];
  79497. extensionsRequired?: string[];
  79498. buffersCount: number;
  79499. shaderscount: number;
  79500. scene: Scene;
  79501. rootUrl: string;
  79502. loadedBufferCount: number;
  79503. loadedBufferViews: {
  79504. [name: string]: ArrayBufferView;
  79505. };
  79506. loadedShaderCount: number;
  79507. importOnlyMeshes: boolean;
  79508. importMeshesNames?: string[];
  79509. dummyNodes: Node[];
  79510. forAssetContainer: boolean;
  79511. }
  79512. /** @hidden */
  79513. export interface INodeToRoot {
  79514. bone: Bone;
  79515. node: IGLTFNode;
  79516. id: string;
  79517. }
  79518. /** @hidden */
  79519. export interface IJointNode {
  79520. node: IGLTFNode;
  79521. id: string;
  79522. }
  79523. }
  79524. declare module BABYLON.GLTF1 {
  79525. /**
  79526. * Utils functions for GLTF
  79527. * @hidden
  79528. */
  79529. export class GLTFUtils {
  79530. /**
  79531. * Sets the given "parameter" matrix
  79532. * @param scene: the Scene object
  79533. * @param source: the source node where to pick the matrix
  79534. * @param parameter: the GLTF technique parameter
  79535. * @param uniformName: the name of the shader's uniform
  79536. * @param shaderMaterial: the shader material
  79537. */
  79538. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79539. /**
  79540. * Sets the given "parameter" matrix
  79541. * @param shaderMaterial: the shader material
  79542. * @param uniform: the name of the shader's uniform
  79543. * @param value: the value of the uniform
  79544. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79545. */
  79546. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79547. /**
  79548. * Returns the wrap mode of the texture
  79549. * @param mode: the mode value
  79550. */
  79551. static GetWrapMode(mode: number): number;
  79552. /**
  79553. * Returns the byte stride giving an accessor
  79554. * @param accessor: the GLTF accessor objet
  79555. */
  79556. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79557. /**
  79558. * Returns the texture filter mode giving a mode value
  79559. * @param mode: the filter mode value
  79560. */
  79561. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79562. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79563. /**
  79564. * Returns a buffer from its accessor
  79565. * @param gltfRuntime: the GLTF runtime
  79566. * @param accessor: the GLTF accessor
  79567. */
  79568. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79569. /**
  79570. * Decodes a buffer view into a string
  79571. * @param view: the buffer view
  79572. */
  79573. static DecodeBufferToText(view: ArrayBufferView): string;
  79574. /**
  79575. * Returns the default material of gltf. Related to
  79576. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79577. * @param scene: the Babylon.js scene
  79578. */
  79579. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79580. private static _DefaultMaterial;
  79581. }
  79582. }
  79583. declare module BABYLON.GLTF1 {
  79584. /**
  79585. * Implementation of the base glTF spec
  79586. * @hidden
  79587. */
  79588. export class GLTFLoaderBase {
  79589. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79590. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79591. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79592. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79593. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79594. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79595. }
  79596. /**
  79597. * glTF V1 Loader
  79598. * @hidden
  79599. */
  79600. export class GLTFLoader implements IGLTFLoader {
  79601. static Extensions: {
  79602. [name: string]: GLTFLoaderExtension;
  79603. };
  79604. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79605. state: Nullable<GLTFLoaderState>;
  79606. dispose(): void;
  79607. private _importMeshAsync;
  79608. /**
  79609. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79610. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79611. * @param scene the scene the meshes should be added to
  79612. * @param forAssetContainer defines if the entities must be stored in the scene
  79613. * @param data gltf data containing information of the meshes in a loaded file
  79614. * @param rootUrl root url to load from
  79615. * @param onProgress event that fires when loading progress has occured
  79616. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79617. */
  79618. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79619. private _loadAsync;
  79620. /**
  79621. * Imports all objects from a loaded gltf file and adds them to the scene
  79622. * @param scene the scene the objects should be added to
  79623. * @param data gltf data containing information of the meshes in a loaded file
  79624. * @param rootUrl root url to load from
  79625. * @param onProgress event that fires when loading progress has occured
  79626. * @returns a promise which completes when objects have been loaded to the scene
  79627. */
  79628. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79629. private _loadShadersAsync;
  79630. private _loadBuffersAsync;
  79631. private _createNodes;
  79632. }
  79633. /** @hidden */
  79634. export abstract class GLTFLoaderExtension {
  79635. private _name;
  79636. constructor(name: string);
  79637. get name(): string;
  79638. /**
  79639. * Defines an override for loading the runtime
  79640. * Return true to stop further extensions from loading the runtime
  79641. */
  79642. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79643. /**
  79644. * Defines an onverride for creating gltf runtime
  79645. * Return true to stop further extensions from creating the runtime
  79646. */
  79647. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79648. /**
  79649. * Defines an override for loading buffers
  79650. * Return true to stop further extensions from loading this buffer
  79651. */
  79652. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79653. /**
  79654. * Defines an override for loading texture buffers
  79655. * Return true to stop further extensions from loading this texture data
  79656. */
  79657. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79658. /**
  79659. * Defines an override for creating textures
  79660. * Return true to stop further extensions from loading this texture
  79661. */
  79662. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79663. /**
  79664. * Defines an override for loading shader strings
  79665. * Return true to stop further extensions from loading this shader data
  79666. */
  79667. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79668. /**
  79669. * Defines an override for loading materials
  79670. * Return true to stop further extensions from loading this material
  79671. */
  79672. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79673. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79674. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79675. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79676. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79677. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79678. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79679. private static LoadTextureBufferAsync;
  79680. private static CreateTextureAsync;
  79681. private static ApplyExtensions;
  79682. }
  79683. }
  79684. declare module BABYLON.GLTF1 {
  79685. /** @hidden */
  79686. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79687. private _bin;
  79688. constructor();
  79689. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79690. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79691. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79692. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79693. }
  79694. }
  79695. declare module BABYLON.GLTF1 {
  79696. /** @hidden */
  79697. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79698. constructor();
  79699. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79700. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79701. private _loadTexture;
  79702. }
  79703. }
  79704. declare module BABYLON.GLTF2.Loader {
  79705. /**
  79706. * Loader interface with an index field.
  79707. */
  79708. export interface IArrayItem {
  79709. /**
  79710. * The index of this item in the array.
  79711. */
  79712. index: number;
  79713. }
  79714. /**
  79715. * Loader interface with additional members.
  79716. */
  79717. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79718. /** @hidden */
  79719. _data?: Promise<ArrayBufferView>;
  79720. /** @hidden */
  79721. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79722. }
  79723. /**
  79724. * Loader interface with additional members.
  79725. */
  79726. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79727. }
  79728. /** @hidden */
  79729. export interface _IAnimationSamplerData {
  79730. input: Float32Array;
  79731. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79732. output: Float32Array;
  79733. }
  79734. /**
  79735. * Loader interface with additional members.
  79736. */
  79737. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79738. /** @hidden */
  79739. _data?: Promise<_IAnimationSamplerData>;
  79740. }
  79741. /**
  79742. * Loader interface with additional members.
  79743. */
  79744. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79745. channels: IAnimationChannel[];
  79746. samplers: IAnimationSampler[];
  79747. /** @hidden */
  79748. _babylonAnimationGroup?: AnimationGroup;
  79749. }
  79750. /**
  79751. * Loader interface with additional members.
  79752. */
  79753. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79754. /** @hidden */
  79755. _data?: Promise<ArrayBufferView>;
  79756. }
  79757. /**
  79758. * Loader interface with additional members.
  79759. */
  79760. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79761. /** @hidden */
  79762. _data?: Promise<ArrayBufferView>;
  79763. /** @hidden */
  79764. _babylonBuffer?: Promise<Buffer>;
  79765. }
  79766. /**
  79767. * Loader interface with additional members.
  79768. */
  79769. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79770. }
  79771. /**
  79772. * Loader interface with additional members.
  79773. */
  79774. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79775. /** @hidden */
  79776. _data?: Promise<ArrayBufferView>;
  79777. }
  79778. /**
  79779. * Loader interface with additional members.
  79780. */
  79781. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79782. }
  79783. /**
  79784. * Loader interface with additional members.
  79785. */
  79786. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79787. }
  79788. /**
  79789. * Loader interface with additional members.
  79790. */
  79791. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79792. baseColorTexture?: ITextureInfo;
  79793. metallicRoughnessTexture?: ITextureInfo;
  79794. }
  79795. /**
  79796. * Loader interface with additional members.
  79797. */
  79798. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79799. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79800. normalTexture?: IMaterialNormalTextureInfo;
  79801. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79802. emissiveTexture?: ITextureInfo;
  79803. /** @hidden */
  79804. _data?: {
  79805. [babylonDrawMode: number]: {
  79806. babylonMaterial: Material;
  79807. babylonMeshes: AbstractMesh[];
  79808. promise: Promise<void>;
  79809. };
  79810. };
  79811. }
  79812. /**
  79813. * Loader interface with additional members.
  79814. */
  79815. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79816. primitives: IMeshPrimitive[];
  79817. }
  79818. /**
  79819. * Loader interface with additional members.
  79820. */
  79821. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79822. /** @hidden */
  79823. _instanceData?: {
  79824. babylonSourceMesh: Mesh;
  79825. promise: Promise<any>;
  79826. };
  79827. }
  79828. /**
  79829. * Loader interface with additional members.
  79830. */
  79831. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79832. /**
  79833. * The parent glTF node.
  79834. */
  79835. parent?: INode;
  79836. /** @hidden */
  79837. _babylonTransformNode?: TransformNode;
  79838. /** @hidden */
  79839. _primitiveBabylonMeshes?: AbstractMesh[];
  79840. /** @hidden */
  79841. _babylonBones?: Bone[];
  79842. /** @hidden */
  79843. _numMorphTargets?: number;
  79844. }
  79845. /** @hidden */
  79846. export interface _ISamplerData {
  79847. noMipMaps: boolean;
  79848. samplingMode: number;
  79849. wrapU: number;
  79850. wrapV: number;
  79851. }
  79852. /**
  79853. * Loader interface with additional members.
  79854. */
  79855. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79856. /** @hidden */
  79857. _data?: _ISamplerData;
  79858. }
  79859. /**
  79860. * Loader interface with additional members.
  79861. */
  79862. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79863. }
  79864. /**
  79865. * Loader interface with additional members.
  79866. */
  79867. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79868. /** @hidden */
  79869. _data?: {
  79870. babylonSkeleton: Skeleton;
  79871. promise: Promise<void>;
  79872. };
  79873. }
  79874. /**
  79875. * Loader interface with additional members.
  79876. */
  79877. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79878. }
  79879. /**
  79880. * Loader interface with additional members.
  79881. */
  79882. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79883. }
  79884. /**
  79885. * Loader interface with additional members.
  79886. */
  79887. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79888. accessors?: IAccessor[];
  79889. animations?: IAnimation[];
  79890. buffers?: IBuffer[];
  79891. bufferViews?: IBufferView[];
  79892. cameras?: ICamera[];
  79893. images?: IImage[];
  79894. materials?: IMaterial[];
  79895. meshes?: IMesh[];
  79896. nodes?: INode[];
  79897. samplers?: ISampler[];
  79898. scenes?: IScene[];
  79899. skins?: ISkin[];
  79900. textures?: ITexture[];
  79901. }
  79902. }
  79903. declare module BABYLON.GLTF2 {
  79904. /**
  79905. * Interface for a glTF loader extension.
  79906. */
  79907. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79908. /**
  79909. * Called after the loader state changes to LOADING.
  79910. */
  79911. onLoading?(): void;
  79912. /**
  79913. * Called after the loader state changes to READY.
  79914. */
  79915. onReady?(): void;
  79916. /**
  79917. * Define this method to modify the default behavior when loading scenes.
  79918. * @param context The context when loading the asset
  79919. * @param scene The glTF scene property
  79920. * @returns A promise that resolves when the load is complete or null if not handled
  79921. */
  79922. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79923. /**
  79924. * Define this method to modify the default behavior when loading nodes.
  79925. * @param context The context when loading the asset
  79926. * @param node The glTF node property
  79927. * @param assign A function called synchronously after parsing the glTF properties
  79928. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79929. */
  79930. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79931. /**
  79932. * Define this method to modify the default behavior when loading cameras.
  79933. * @param context The context when loading the asset
  79934. * @param camera The glTF camera property
  79935. * @param assign A function called synchronously after parsing the glTF properties
  79936. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79937. */
  79938. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79939. /**
  79940. * @hidden
  79941. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79942. * @param context The context when loading the asset
  79943. * @param primitive The glTF mesh primitive property
  79944. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79945. */
  79946. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79947. /**
  79948. * @hidden
  79949. * Define this method to modify the default behavior when loading data for mesh primitives.
  79950. * @param context The context when loading the asset
  79951. * @param name The mesh name when loading the asset
  79952. * @param node The glTF node when loading the asset
  79953. * @param mesh The glTF mesh when loading the asset
  79954. * @param primitive The glTF mesh primitive property
  79955. * @param assign A function called synchronously after parsing the glTF properties
  79956. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79957. */
  79958. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79959. /**
  79960. * @hidden
  79961. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79962. * @param context The context when loading the asset
  79963. * @param material The glTF material property
  79964. * @param assign A function called synchronously after parsing the glTF properties
  79965. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79966. */
  79967. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79968. /**
  79969. * Define this method to modify the default behavior when creating materials.
  79970. * @param context The context when loading the asset
  79971. * @param material The glTF material property
  79972. * @param babylonDrawMode The draw mode for the Babylon material
  79973. * @returns The Babylon material or null if not handled
  79974. */
  79975. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79976. /**
  79977. * Define this method to modify the default behavior when loading material properties.
  79978. * @param context The context when loading the asset
  79979. * @param material The glTF material property
  79980. * @param babylonMaterial The Babylon material
  79981. * @returns A promise that resolves when the load is complete or null if not handled
  79982. */
  79983. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79984. /**
  79985. * Define this method to modify the default behavior when loading texture infos.
  79986. * @param context The context when loading the asset
  79987. * @param textureInfo The glTF texture info property
  79988. * @param assign A function called synchronously after parsing the glTF properties
  79989. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79990. */
  79991. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79992. /**
  79993. * @hidden
  79994. * Define this method to modify the default behavior when loading textures.
  79995. * @param context The context when loading the asset
  79996. * @param texture The glTF texture property
  79997. * @param assign A function called synchronously after parsing the glTF properties
  79998. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79999. */
  80000. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80001. /**
  80002. * Define this method to modify the default behavior when loading animations.
  80003. * @param context The context when loading the asset
  80004. * @param animation The glTF animation property
  80005. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80006. */
  80007. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80008. /**
  80009. * @hidden
  80010. * Define this method to modify the default behavior when loading skins.
  80011. * @param context The context when loading the asset
  80012. * @param node The glTF node property
  80013. * @param skin The glTF skin property
  80014. * @returns A promise that resolves when the load is complete or null if not handled
  80015. */
  80016. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80017. /**
  80018. * @hidden
  80019. * Define this method to modify the default behavior when loading uris.
  80020. * @param context The context when loading the asset
  80021. * @param property The glTF property associated with the uri
  80022. * @param uri The uri to load
  80023. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80024. */
  80025. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80026. /**
  80027. * Define this method to modify the default behavior when loading buffer views.
  80028. * @param context The context when loading the asset
  80029. * @param bufferView The glTF buffer view property
  80030. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80031. */
  80032. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80033. /**
  80034. * Define this method to modify the default behavior when loading buffers.
  80035. * @param context The context when loading the asset
  80036. * @param buffer The glTF buffer property
  80037. * @param byteOffset The byte offset to load
  80038. * @param byteLength The byte length to load
  80039. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80040. */
  80041. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80042. }
  80043. }
  80044. declare module BABYLON.GLTF2 {
  80045. /**
  80046. * Helper class for working with arrays when loading the glTF asset
  80047. */
  80048. export class ArrayItem {
  80049. /**
  80050. * Gets an item from the given array.
  80051. * @param context The context when loading the asset
  80052. * @param array The array to get the item from
  80053. * @param index The index to the array
  80054. * @returns The array item
  80055. */
  80056. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80057. /**
  80058. * Assign an `index` field to each item of the given array.
  80059. * @param array The array of items
  80060. */
  80061. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80062. }
  80063. /**
  80064. * The glTF 2.0 loader
  80065. */
  80066. export class GLTFLoader implements IGLTFLoader {
  80067. /** @hidden */
  80068. _completePromises: Promise<any>[];
  80069. /** @hidden */
  80070. _forAssetContainer: boolean;
  80071. /** Storage */
  80072. _babylonLights: Light[];
  80073. /** @hidden */
  80074. _disableInstancedMesh: number;
  80075. private _disposed;
  80076. private _parent;
  80077. private _state;
  80078. private _extensions;
  80079. private _rootUrl;
  80080. private _fileName;
  80081. private _uniqueRootUrl;
  80082. private _gltf;
  80083. private _bin;
  80084. private _babylonScene;
  80085. private _rootBabylonMesh;
  80086. private _defaultBabylonMaterialData;
  80087. private static _RegisteredExtensions;
  80088. /**
  80089. * The default glTF sampler.
  80090. */
  80091. static readonly DefaultSampler: ISampler;
  80092. /**
  80093. * Registers a loader extension.
  80094. * @param name The name of the loader extension.
  80095. * @param factory The factory function that creates the loader extension.
  80096. */
  80097. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80098. /**
  80099. * Unregisters a loader extension.
  80100. * @param name The name of the loader extension.
  80101. * @returns A boolean indicating whether the extension has been unregistered
  80102. */
  80103. static UnregisterExtension(name: string): boolean;
  80104. /**
  80105. * The loader state.
  80106. */
  80107. get state(): Nullable<GLTFLoaderState>;
  80108. /**
  80109. * The object that represents the glTF JSON.
  80110. */
  80111. get gltf(): IGLTF;
  80112. /**
  80113. * The BIN chunk of a binary glTF.
  80114. */
  80115. get bin(): Nullable<IDataBuffer>;
  80116. /**
  80117. * The parent file loader.
  80118. */
  80119. get parent(): GLTFFileLoader;
  80120. /**
  80121. * The Babylon scene when loading the asset.
  80122. */
  80123. get babylonScene(): Scene;
  80124. /**
  80125. * The root Babylon mesh when loading the asset.
  80126. */
  80127. get rootBabylonMesh(): Mesh;
  80128. /** @hidden */
  80129. constructor(parent: GLTFFileLoader);
  80130. /** @hidden */
  80131. dispose(): void;
  80132. /** @hidden */
  80133. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80134. /** @hidden */
  80135. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80136. private _loadAsync;
  80137. private _loadData;
  80138. private _setupData;
  80139. private _loadExtensions;
  80140. private _checkExtensions;
  80141. private _setState;
  80142. private _createRootNode;
  80143. /**
  80144. * Loads a glTF scene.
  80145. * @param context The context when loading the asset
  80146. * @param scene The glTF scene property
  80147. * @returns A promise that resolves when the load is complete
  80148. */
  80149. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80150. private _forEachPrimitive;
  80151. private _getMeshes;
  80152. private _getTransformNodes;
  80153. private _getSkeletons;
  80154. private _getAnimationGroups;
  80155. private _startAnimations;
  80156. /**
  80157. * Loads a glTF node.
  80158. * @param context The context when loading the asset
  80159. * @param node The glTF node property
  80160. * @param assign A function called synchronously after parsing the glTF properties
  80161. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80162. */
  80163. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80164. private _loadMeshAsync;
  80165. /**
  80166. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80167. * @param context The context when loading the asset
  80168. * @param name The mesh name when loading the asset
  80169. * @param node The glTF node when loading the asset
  80170. * @param mesh The glTF mesh when loading the asset
  80171. * @param primitive The glTF mesh primitive property
  80172. * @param assign A function called synchronously after parsing the glTF properties
  80173. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80174. */
  80175. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80176. private _loadVertexDataAsync;
  80177. private _createMorphTargets;
  80178. private _loadMorphTargetsAsync;
  80179. private _loadMorphTargetVertexDataAsync;
  80180. private static _LoadTransform;
  80181. private _loadSkinAsync;
  80182. private _loadBones;
  80183. private _loadBone;
  80184. private _loadSkinInverseBindMatricesDataAsync;
  80185. private _updateBoneMatrices;
  80186. private _getNodeMatrix;
  80187. /**
  80188. * Loads a glTF camera.
  80189. * @param context The context when loading the asset
  80190. * @param camera The glTF camera property
  80191. * @param assign A function called synchronously after parsing the glTF properties
  80192. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80193. */
  80194. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80195. private _loadAnimationsAsync;
  80196. /**
  80197. * Loads a glTF animation.
  80198. * @param context The context when loading the asset
  80199. * @param animation The glTF animation property
  80200. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80201. */
  80202. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80203. /**
  80204. * @hidden Loads a glTF animation channel.
  80205. * @param context The context when loading the asset
  80206. * @param animationContext The context of the animation when loading the asset
  80207. * @param animation The glTF animation property
  80208. * @param channel The glTF animation channel property
  80209. * @param babylonAnimationGroup The babylon animation group property
  80210. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80211. * @returns A void promise when the channel load is complete
  80212. */
  80213. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80214. private _loadAnimationSamplerAsync;
  80215. private _loadBufferAsync;
  80216. /**
  80217. * Loads a glTF buffer view.
  80218. * @param context The context when loading the asset
  80219. * @param bufferView The glTF buffer view property
  80220. * @returns A promise that resolves with the loaded data when the load is complete
  80221. */
  80222. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80223. private _loadAccessorAsync;
  80224. /** @hidden */
  80225. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80226. private _loadIndicesAccessorAsync;
  80227. private _loadVertexBufferViewAsync;
  80228. private _loadVertexAccessorAsync;
  80229. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80230. /** @hidden */
  80231. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80232. private _createDefaultMaterial;
  80233. /**
  80234. * Creates a Babylon material from a glTF material.
  80235. * @param context The context when loading the asset
  80236. * @param material The glTF material property
  80237. * @param babylonDrawMode The draw mode for the Babylon material
  80238. * @returns The Babylon material
  80239. */
  80240. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80241. /**
  80242. * Loads properties from a glTF material into a Babylon material.
  80243. * @param context The context when loading the asset
  80244. * @param material The glTF material property
  80245. * @param babylonMaterial The Babylon material
  80246. * @returns A promise that resolves when the load is complete
  80247. */
  80248. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80249. /**
  80250. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80251. * @param context The context when loading the asset
  80252. * @param material The glTF material property
  80253. * @param babylonMaterial The Babylon material
  80254. * @returns A promise that resolves when the load is complete
  80255. */
  80256. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80257. /**
  80258. * Loads the alpha properties from a glTF material into a Babylon material.
  80259. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80260. * @param context The context when loading the asset
  80261. * @param material The glTF material property
  80262. * @param babylonMaterial The Babylon material
  80263. */
  80264. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80265. /**
  80266. * Loads a glTF texture info.
  80267. * @param context The context when loading the asset
  80268. * @param textureInfo The glTF texture info property
  80269. * @param assign A function called synchronously after parsing the glTF properties
  80270. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80271. */
  80272. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80273. /** @hidden */
  80274. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80275. /** @hidden */
  80276. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80277. private _loadSampler;
  80278. /**
  80279. * Loads a glTF image.
  80280. * @param context The context when loading the asset
  80281. * @param image The glTF image property
  80282. * @returns A promise that resolves with the loaded data when the load is complete
  80283. */
  80284. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80285. /**
  80286. * Loads a glTF uri.
  80287. * @param context The context when loading the asset
  80288. * @param property The glTF property associated with the uri
  80289. * @param uri The base64 or relative uri
  80290. * @returns A promise that resolves with the loaded data when the load is complete
  80291. */
  80292. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80293. /**
  80294. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80295. * @param babylonObject the Babylon object with metadata
  80296. * @param pointer the JSON pointer
  80297. */
  80298. static AddPointerMetadata(babylonObject: {
  80299. metadata: any;
  80300. }, pointer: string): void;
  80301. private static _GetTextureWrapMode;
  80302. private static _GetTextureSamplingMode;
  80303. private static _GetTypedArrayConstructor;
  80304. private static _GetTypedArray;
  80305. private static _GetNumComponents;
  80306. private static _ValidateUri;
  80307. /** @hidden */
  80308. static _GetDrawMode(context: string, mode: number | undefined): number;
  80309. private _compileMaterialsAsync;
  80310. private _compileShadowGeneratorsAsync;
  80311. private _forEachExtensions;
  80312. private _applyExtensions;
  80313. private _extensionsOnLoading;
  80314. private _extensionsOnReady;
  80315. private _extensionsLoadSceneAsync;
  80316. private _extensionsLoadNodeAsync;
  80317. private _extensionsLoadCameraAsync;
  80318. private _extensionsLoadVertexDataAsync;
  80319. private _extensionsLoadMeshPrimitiveAsync;
  80320. private _extensionsLoadMaterialAsync;
  80321. private _extensionsCreateMaterial;
  80322. private _extensionsLoadMaterialPropertiesAsync;
  80323. private _extensionsLoadTextureInfoAsync;
  80324. private _extensionsLoadTextureAsync;
  80325. private _extensionsLoadAnimationAsync;
  80326. private _extensionsLoadSkinAsync;
  80327. private _extensionsLoadUriAsync;
  80328. private _extensionsLoadBufferViewAsync;
  80329. private _extensionsLoadBufferAsync;
  80330. /**
  80331. * Helper method called by a loader extension to load an glTF extension.
  80332. * @param context The context when loading the asset
  80333. * @param property The glTF property to load the extension from
  80334. * @param extensionName The name of the extension to load
  80335. * @param actionAsync The action to run
  80336. * @returns The promise returned by actionAsync or null if the extension does not exist
  80337. */
  80338. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80339. /**
  80340. * Helper method called by a loader extension to load a glTF extra.
  80341. * @param context The context when loading the asset
  80342. * @param property The glTF property to load the extra from
  80343. * @param extensionName The name of the extension to load
  80344. * @param actionAsync The action to run
  80345. * @returns The promise returned by actionAsync or null if the extra does not exist
  80346. */
  80347. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80348. /**
  80349. * Checks for presence of an extension.
  80350. * @param name The name of the extension to check
  80351. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80352. */
  80353. isExtensionUsed(name: string): boolean;
  80354. /**
  80355. * Increments the indentation level and logs a message.
  80356. * @param message The message to log
  80357. */
  80358. logOpen(message: string): void;
  80359. /**
  80360. * Decrements the indentation level.
  80361. */
  80362. logClose(): void;
  80363. /**
  80364. * Logs a message
  80365. * @param message The message to log
  80366. */
  80367. log(message: string): void;
  80368. /**
  80369. * Starts a performance counter.
  80370. * @param counterName The name of the performance counter
  80371. */
  80372. startPerformanceCounter(counterName: string): void;
  80373. /**
  80374. * Ends a performance counter.
  80375. * @param counterName The name of the performance counter
  80376. */
  80377. endPerformanceCounter(counterName: string): void;
  80378. }
  80379. }
  80380. declare module BABYLON.GLTF2.Loader.Extensions {
  80381. /**
  80382. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80383. */
  80384. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80385. /**
  80386. * The name of this extension.
  80387. */
  80388. readonly name: string;
  80389. /**
  80390. * Defines whether this extension is enabled.
  80391. */
  80392. enabled: boolean;
  80393. private _loader;
  80394. private _lights?;
  80395. /** @hidden */
  80396. constructor(loader: GLTFLoader);
  80397. /** @hidden */
  80398. dispose(): void;
  80399. /** @hidden */
  80400. onLoading(): void;
  80401. /** @hidden */
  80402. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80403. private _loadLightAsync;
  80404. }
  80405. }
  80406. declare module BABYLON.GLTF2.Loader.Extensions {
  80407. /**
  80408. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80409. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80410. * !!! Experimental Extension Subject to Changes !!!
  80411. */
  80412. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80413. /**
  80414. * The name of this extension.
  80415. */
  80416. readonly name: string;
  80417. /**
  80418. * Defines whether this extension is enabled.
  80419. */
  80420. enabled: boolean;
  80421. private _loader;
  80422. /** @hidden */
  80423. constructor(loader: GLTFLoader);
  80424. /** @hidden */
  80425. dispose(): void;
  80426. /** @hidden */
  80427. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80428. }
  80429. }
  80430. declare module BABYLON.GLTF2.Loader.Extensions {
  80431. /**
  80432. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80433. */
  80434. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80435. /**
  80436. * The name of this extension.
  80437. */
  80438. readonly name: string;
  80439. /**
  80440. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80441. */
  80442. dracoCompression?: DracoCompression;
  80443. /**
  80444. * Defines whether this extension is enabled.
  80445. */
  80446. enabled: boolean;
  80447. private _loader;
  80448. /** @hidden */
  80449. constructor(loader: GLTFLoader);
  80450. /** @hidden */
  80451. dispose(): void;
  80452. /** @hidden */
  80453. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80454. }
  80455. }
  80456. declare module BABYLON.GLTF2.Loader.Extensions {
  80457. /**
  80458. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80459. */
  80460. export class KHR_lights implements IGLTFLoaderExtension {
  80461. /**
  80462. * The name of this extension.
  80463. */
  80464. readonly name: string;
  80465. /**
  80466. * Defines whether this extension is enabled.
  80467. */
  80468. enabled: boolean;
  80469. private _loader;
  80470. private _lights?;
  80471. /** @hidden */
  80472. constructor(loader: GLTFLoader);
  80473. /** @hidden */
  80474. dispose(): void;
  80475. /** @hidden */
  80476. onLoading(): void;
  80477. /** @hidden */
  80478. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80479. }
  80480. }
  80481. declare module BABYLON.GLTF2.Loader.Extensions {
  80482. /**
  80483. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80484. */
  80485. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80486. /**
  80487. * The name of this extension.
  80488. */
  80489. readonly name: string;
  80490. /**
  80491. * Defines whether this extension is enabled.
  80492. */
  80493. enabled: boolean;
  80494. /**
  80495. * Defines a number that determines the order the extensions are applied.
  80496. */
  80497. order: number;
  80498. private _loader;
  80499. /** @hidden */
  80500. constructor(loader: GLTFLoader);
  80501. /** @hidden */
  80502. dispose(): void;
  80503. /** @hidden */
  80504. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80505. private _loadSpecularGlossinessPropertiesAsync;
  80506. }
  80507. }
  80508. declare module BABYLON.GLTF2.Loader.Extensions {
  80509. /**
  80510. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80511. */
  80512. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80513. /**
  80514. * The name of this extension.
  80515. */
  80516. readonly name: string;
  80517. /**
  80518. * Defines whether this extension is enabled.
  80519. */
  80520. enabled: boolean;
  80521. /**
  80522. * Defines a number that determines the order the extensions are applied.
  80523. */
  80524. order: number;
  80525. private _loader;
  80526. /** @hidden */
  80527. constructor(loader: GLTFLoader);
  80528. /** @hidden */
  80529. dispose(): void;
  80530. /** @hidden */
  80531. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80532. private _loadUnlitPropertiesAsync;
  80533. }
  80534. }
  80535. declare module BABYLON.GLTF2.Loader.Extensions {
  80536. /**
  80537. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80538. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80539. * !!! Experimental Extension Subject to Changes !!!
  80540. */
  80541. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80542. /**
  80543. * The name of this extension.
  80544. */
  80545. readonly name: string;
  80546. /**
  80547. * Defines whether this extension is enabled.
  80548. */
  80549. enabled: boolean;
  80550. /**
  80551. * Defines a number that determines the order the extensions are applied.
  80552. */
  80553. order: number;
  80554. private _loader;
  80555. /** @hidden */
  80556. constructor(loader: GLTFLoader);
  80557. /** @hidden */
  80558. dispose(): void;
  80559. /** @hidden */
  80560. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80561. private _loadClearCoatPropertiesAsync;
  80562. }
  80563. }
  80564. declare module BABYLON.GLTF2.Loader.Extensions {
  80565. /**
  80566. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80567. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80568. * !!! Experimental Extension Subject to Changes !!!
  80569. */
  80570. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80571. /**
  80572. * The name of this extension.
  80573. */
  80574. readonly name: string;
  80575. /**
  80576. * Defines whether this extension is enabled.
  80577. */
  80578. enabled: boolean;
  80579. /**
  80580. * Defines a number that determines the order the extensions are applied.
  80581. */
  80582. order: number;
  80583. private _loader;
  80584. /** @hidden */
  80585. constructor(loader: GLTFLoader);
  80586. /** @hidden */
  80587. dispose(): void;
  80588. /** @hidden */
  80589. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80590. private _loadSheenPropertiesAsync;
  80591. }
  80592. }
  80593. declare module BABYLON.GLTF2.Loader.Extensions {
  80594. /**
  80595. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80596. * !!! Experimental Extension Subject to Changes !!!
  80597. */
  80598. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80599. /**
  80600. * The name of this extension.
  80601. */
  80602. readonly name: string;
  80603. /**
  80604. * Defines whether this extension is enabled.
  80605. */
  80606. enabled: boolean;
  80607. /**
  80608. * Defines a number that determines the order the extensions are applied.
  80609. */
  80610. order: number;
  80611. private _loader;
  80612. /** @hidden */
  80613. constructor(loader: GLTFLoader);
  80614. /** @hidden */
  80615. dispose(): void;
  80616. /** @hidden */
  80617. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80618. private _loadSpecularPropertiesAsync;
  80619. }
  80620. }
  80621. declare module BABYLON.GLTF2.Loader.Extensions {
  80622. /**
  80623. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80624. * !!! Experimental Extension Subject to Changes !!!
  80625. */
  80626. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80627. /**
  80628. * Default ior Value from the spec.
  80629. */
  80630. private static readonly _DEFAULT_IOR;
  80631. /**
  80632. * The name of this extension.
  80633. */
  80634. readonly name: string;
  80635. /**
  80636. * Defines whether this extension is enabled.
  80637. */
  80638. enabled: boolean;
  80639. /**
  80640. * Defines a number that determines the order the extensions are applied.
  80641. */
  80642. order: number;
  80643. private _loader;
  80644. /** @hidden */
  80645. constructor(loader: GLTFLoader);
  80646. /** @hidden */
  80647. dispose(): void;
  80648. /** @hidden */
  80649. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80650. private _loadIorPropertiesAsync;
  80651. }
  80652. }
  80653. declare module BABYLON.GLTF2.Loader.Extensions {
  80654. /**
  80655. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80656. * !!! Experimental Extension Subject to Changes !!!
  80657. */
  80658. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80659. /**
  80660. * The name of this extension.
  80661. */
  80662. readonly name: string;
  80663. /**
  80664. * Defines whether this extension is enabled.
  80665. */
  80666. enabled: boolean;
  80667. private _loader;
  80668. /** @hidden */
  80669. constructor(loader: GLTFLoader);
  80670. /** @hidden */
  80671. dispose(): void;
  80672. /**
  80673. * Gets the list of available variant tag names for this asset.
  80674. * @param rootMesh The glTF root mesh
  80675. * @returns the list of all the variant names for this model
  80676. */
  80677. static GetAvailableVariants(rootMesh: Mesh): string[];
  80678. /**
  80679. * Select a variant given a variant tag name or a list of variant tag names.
  80680. * @param rootMesh The glTF root mesh
  80681. * @param variantName The variant name(s) to select.
  80682. */
  80683. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80684. /**
  80685. * Reset back to the original before selecting a variant.
  80686. * @param rootMesh The glTF root mesh
  80687. */
  80688. static Reset(rootMesh: Mesh): void;
  80689. /**
  80690. * Gets the last selected variant tag name(s) or null if original.
  80691. * @param rootMesh The glTF root mesh
  80692. * @returns The selected variant tag name(s).
  80693. */
  80694. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80695. private static _GetExtensionMetadata;
  80696. /** @hidden */
  80697. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80698. }
  80699. }
  80700. declare module BABYLON.GLTF2.Loader.Extensions {
  80701. /**
  80702. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80703. * !!! Experimental Extension Subject to Changes !!!
  80704. */
  80705. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80706. /**
  80707. * The name of this extension.
  80708. */
  80709. readonly name: string;
  80710. /**
  80711. * Defines whether this extension is enabled.
  80712. */
  80713. enabled: boolean;
  80714. /**
  80715. * Defines a number that determines the order the extensions are applied.
  80716. */
  80717. order: number;
  80718. private _loader;
  80719. /** @hidden */
  80720. constructor(loader: GLTFLoader);
  80721. /** @hidden */
  80722. dispose(): void;
  80723. /** @hidden */
  80724. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80725. private _loadTransparentPropertiesAsync;
  80726. }
  80727. }
  80728. declare module BABYLON.GLTF2.Loader.Extensions {
  80729. /**
  80730. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80731. */
  80732. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80733. /**
  80734. * The name of this extension.
  80735. */
  80736. readonly name: string;
  80737. /**
  80738. * Defines whether this extension is enabled.
  80739. */
  80740. enabled: boolean;
  80741. /** @hidden */
  80742. constructor(loader: GLTFLoader);
  80743. /** @hidden */
  80744. dispose(): void;
  80745. }
  80746. }
  80747. declare module BABYLON.GLTF2.Loader.Extensions {
  80748. /**
  80749. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80750. * !!! Experimental Extension Subject to Changes !!!
  80751. */
  80752. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80753. /** The name of this extension. */
  80754. readonly name: string;
  80755. /** Defines whether this extension is enabled. */
  80756. enabled: boolean;
  80757. private _loader;
  80758. /** @hidden */
  80759. constructor(loader: GLTFLoader);
  80760. /** @hidden */
  80761. dispose(): void;
  80762. /** @hidden */
  80763. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80764. }
  80765. }
  80766. declare module BABYLON.GLTF2.Loader.Extensions {
  80767. /**
  80768. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80769. */
  80770. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80771. /**
  80772. * The name of this extension.
  80773. */
  80774. readonly name: string;
  80775. /**
  80776. * Defines whether this extension is enabled.
  80777. */
  80778. enabled: boolean;
  80779. private _loader;
  80780. /** @hidden */
  80781. constructor(loader: GLTFLoader);
  80782. /** @hidden */
  80783. dispose(): void;
  80784. /** @hidden */
  80785. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80786. }
  80787. }
  80788. declare module BABYLON.GLTF2.Loader.Extensions {
  80789. /**
  80790. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80791. * !!! Experimental Extension Subject to Changes !!!
  80792. */
  80793. export class KHR_xmp implements IGLTFLoaderExtension {
  80794. /**
  80795. * The name of this extension.
  80796. */
  80797. readonly name: string;
  80798. /**
  80799. * Defines whether this extension is enabled.
  80800. */
  80801. enabled: boolean;
  80802. /**
  80803. * Defines a number that determines the order the extensions are applied.
  80804. */
  80805. order: number;
  80806. private _loader;
  80807. /** @hidden */
  80808. constructor(loader: GLTFLoader);
  80809. /** @hidden */
  80810. dispose(): void;
  80811. /**
  80812. * Called after the loader state changes to LOADING.
  80813. */
  80814. onLoading(): void;
  80815. }
  80816. }
  80817. declare module BABYLON.GLTF2.Loader.Extensions {
  80818. /**
  80819. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80820. */
  80821. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80822. /**
  80823. * The name of this extension.
  80824. */
  80825. readonly name: string;
  80826. /**
  80827. * Defines whether this extension is enabled.
  80828. */
  80829. enabled: boolean;
  80830. private _loader;
  80831. private _clips;
  80832. private _emitters;
  80833. /** @hidden */
  80834. constructor(loader: GLTFLoader);
  80835. /** @hidden */
  80836. dispose(): void;
  80837. /** @hidden */
  80838. onLoading(): void;
  80839. /** @hidden */
  80840. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80841. /** @hidden */
  80842. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80843. /** @hidden */
  80844. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80845. private _loadClipAsync;
  80846. private _loadEmitterAsync;
  80847. private _getEventAction;
  80848. private _loadAnimationEventAsync;
  80849. }
  80850. }
  80851. declare module BABYLON.GLTF2.Loader.Extensions {
  80852. /**
  80853. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80854. */
  80855. export class MSFT_lod implements IGLTFLoaderExtension {
  80856. /**
  80857. * The name of this extension.
  80858. */
  80859. readonly name: string;
  80860. /**
  80861. * Defines whether this extension is enabled.
  80862. */
  80863. enabled: boolean;
  80864. /**
  80865. * Defines a number that determines the order the extensions are applied.
  80866. */
  80867. order: number;
  80868. /**
  80869. * Maximum number of LODs to load, starting from the lowest LOD.
  80870. */
  80871. maxLODsToLoad: number;
  80872. /**
  80873. * Observable raised when all node LODs of one level are loaded.
  80874. * The event data is the index of the loaded LOD starting from zero.
  80875. * Dispose the loader to cancel the loading of the next level of LODs.
  80876. */
  80877. onNodeLODsLoadedObservable: Observable<number>;
  80878. /**
  80879. * Observable raised when all material LODs of one level are loaded.
  80880. * The event data is the index of the loaded LOD starting from zero.
  80881. * Dispose the loader to cancel the loading of the next level of LODs.
  80882. */
  80883. onMaterialLODsLoadedObservable: Observable<number>;
  80884. private _loader;
  80885. private _bufferLODs;
  80886. private _nodeIndexLOD;
  80887. private _nodeSignalLODs;
  80888. private _nodePromiseLODs;
  80889. private _nodeBufferLODs;
  80890. private _materialIndexLOD;
  80891. private _materialSignalLODs;
  80892. private _materialPromiseLODs;
  80893. private _materialBufferLODs;
  80894. /** @hidden */
  80895. constructor(loader: GLTFLoader);
  80896. /** @hidden */
  80897. dispose(): void;
  80898. /** @hidden */
  80899. onReady(): void;
  80900. /** @hidden */
  80901. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80902. /** @hidden */
  80903. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80904. /** @hidden */
  80905. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80906. /** @hidden */
  80907. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80908. /** @hidden */
  80909. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80910. private _loadBufferLOD;
  80911. /**
  80912. * Gets an array of LOD properties from lowest to highest.
  80913. */
  80914. private _getLODs;
  80915. private _disposeTransformNode;
  80916. private _disposeMaterials;
  80917. }
  80918. }
  80919. declare module BABYLON.GLTF2.Loader.Extensions {
  80920. /** @hidden */
  80921. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80922. readonly name: string;
  80923. enabled: boolean;
  80924. private _loader;
  80925. constructor(loader: GLTFLoader);
  80926. dispose(): void;
  80927. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80928. }
  80929. }
  80930. declare module BABYLON.GLTF2.Loader.Extensions {
  80931. /** @hidden */
  80932. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80933. readonly name: string;
  80934. enabled: boolean;
  80935. private _loader;
  80936. constructor(loader: GLTFLoader);
  80937. dispose(): void;
  80938. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80939. }
  80940. }
  80941. declare module BABYLON.GLTF2.Loader.Extensions {
  80942. /**
  80943. * Store glTF extras (if present) in BJS objects' metadata
  80944. */
  80945. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80946. /**
  80947. * The name of this extension.
  80948. */
  80949. readonly name: string;
  80950. /**
  80951. * Defines whether this extension is enabled.
  80952. */
  80953. enabled: boolean;
  80954. private _loader;
  80955. private _assignExtras;
  80956. /** @hidden */
  80957. constructor(loader: GLTFLoader);
  80958. /** @hidden */
  80959. dispose(): void;
  80960. /** @hidden */
  80961. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80962. /** @hidden */
  80963. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80964. /** @hidden */
  80965. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80966. }
  80967. }
  80968. declare module BABYLON {
  80969. /**
  80970. * Class reading and parsing the MTL file bundled with the obj file.
  80971. */
  80972. export class MTLFileLoader {
  80973. /**
  80974. * Invert Y-Axis of referenced textures on load
  80975. */
  80976. static INVERT_TEXTURE_Y: boolean;
  80977. /**
  80978. * All material loaded from the mtl will be set here
  80979. */
  80980. materials: StandardMaterial[];
  80981. /**
  80982. * This function will read the mtl file and create each material described inside
  80983. * This function could be improve by adding :
  80984. * -some component missing (Ni, Tf...)
  80985. * -including the specific options available
  80986. *
  80987. * @param scene defines the scene the material will be created in
  80988. * @param data defines the mtl data to parse
  80989. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80990. * @param forAssetContainer defines if the material should be registered in the scene
  80991. */
  80992. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80993. /**
  80994. * Gets the texture for the material.
  80995. *
  80996. * If the material is imported from input file,
  80997. * We sanitize the url to ensure it takes the textre from aside the material.
  80998. *
  80999. * @param rootUrl The root url to load from
  81000. * @param value The value stored in the mtl
  81001. * @return The Texture
  81002. */
  81003. private static _getTexture;
  81004. }
  81005. }
  81006. declare module BABYLON {
  81007. /**
  81008. * Options for loading OBJ/MTL files
  81009. */
  81010. type MeshLoadOptions = {
  81011. /**
  81012. * Defines if UVs are optimized by default during load.
  81013. */
  81014. OptimizeWithUV: boolean;
  81015. /**
  81016. * Defines custom scaling of UV coordinates of loaded meshes.
  81017. */
  81018. UVScaling: Vector2;
  81019. /**
  81020. * Invert model on y-axis (does a model scaling inversion)
  81021. */
  81022. InvertY: boolean;
  81023. /**
  81024. * Invert Y-Axis of referenced textures on load
  81025. */
  81026. InvertTextureY: boolean;
  81027. /**
  81028. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81029. */
  81030. ImportVertexColors: boolean;
  81031. /**
  81032. * Compute the normals for the model, even if normals are present in the file.
  81033. */
  81034. ComputeNormals: boolean;
  81035. /**
  81036. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81037. */
  81038. SkipMaterials: boolean;
  81039. /**
  81040. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81041. */
  81042. MaterialLoadingFailsSilently: boolean;
  81043. };
  81044. /**
  81045. * OBJ file type loader.
  81046. * This is a babylon scene loader plugin.
  81047. */
  81048. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81049. /**
  81050. * Defines if UVs are optimized by default during load.
  81051. */
  81052. static OPTIMIZE_WITH_UV: boolean;
  81053. /**
  81054. * Invert model on y-axis (does a model scaling inversion)
  81055. */
  81056. static INVERT_Y: boolean;
  81057. /**
  81058. * Invert Y-Axis of referenced textures on load
  81059. */
  81060. static get INVERT_TEXTURE_Y(): boolean;
  81061. static set INVERT_TEXTURE_Y(value: boolean);
  81062. /**
  81063. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81064. */
  81065. static IMPORT_VERTEX_COLORS: boolean;
  81066. /**
  81067. * Compute the normals for the model, even if normals are present in the file.
  81068. */
  81069. static COMPUTE_NORMALS: boolean;
  81070. /**
  81071. * Defines custom scaling of UV coordinates of loaded meshes.
  81072. */
  81073. static UV_SCALING: Vector2;
  81074. /**
  81075. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81076. */
  81077. static SKIP_MATERIALS: boolean;
  81078. /**
  81079. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81080. *
  81081. * Defaults to true for backwards compatibility.
  81082. */
  81083. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81084. /**
  81085. * Defines the name of the plugin.
  81086. */
  81087. name: string;
  81088. /**
  81089. * Defines the extension the plugin is able to load.
  81090. */
  81091. extensions: string;
  81092. /** @hidden */
  81093. obj: RegExp;
  81094. /** @hidden */
  81095. group: RegExp;
  81096. /** @hidden */
  81097. mtllib: RegExp;
  81098. /** @hidden */
  81099. usemtl: RegExp;
  81100. /** @hidden */
  81101. smooth: RegExp;
  81102. /** @hidden */
  81103. vertexPattern: RegExp;
  81104. /** @hidden */
  81105. normalPattern: RegExp;
  81106. /** @hidden */
  81107. uvPattern: RegExp;
  81108. /** @hidden */
  81109. facePattern1: RegExp;
  81110. /** @hidden */
  81111. facePattern2: RegExp;
  81112. /** @hidden */
  81113. facePattern3: RegExp;
  81114. /** @hidden */
  81115. facePattern4: RegExp;
  81116. /** @hidden */
  81117. facePattern5: RegExp;
  81118. private _forAssetContainer;
  81119. private _meshLoadOptions;
  81120. /**
  81121. * Creates loader for .OBJ files
  81122. *
  81123. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81124. */
  81125. constructor(meshLoadOptions?: MeshLoadOptions);
  81126. private static get currentMeshLoadOptions();
  81127. /**
  81128. * Calls synchronously the MTL file attached to this obj.
  81129. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81130. * Without this function materials are not displayed in the first frame (but displayed after).
  81131. * In consequence it is impossible to get material information in your HTML file
  81132. *
  81133. * @param url The URL of the MTL file
  81134. * @param rootUrl
  81135. * @param onSuccess Callback function to be called when the MTL file is loaded
  81136. * @private
  81137. */
  81138. private _loadMTL;
  81139. /**
  81140. * Instantiates a OBJ file loader plugin.
  81141. * @returns the created plugin
  81142. */
  81143. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81144. /**
  81145. * If the data string can be loaded directly.
  81146. *
  81147. * @param data string containing the file data
  81148. * @returns if the data can be loaded directly
  81149. */
  81150. canDirectLoad(data: string): boolean;
  81151. /**
  81152. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81153. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81154. * @param scene the scene the meshes should be added to
  81155. * @param data the OBJ data to load
  81156. * @param rootUrl root url to load from
  81157. * @param onProgress event that fires when loading progress has occured
  81158. * @param fileName Defines the name of the file to load
  81159. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81160. */
  81161. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81162. meshes: AbstractMesh[];
  81163. particleSystems: IParticleSystem[];
  81164. skeletons: Skeleton[];
  81165. animationGroups: AnimationGroup[];
  81166. }>;
  81167. /**
  81168. * Imports all objects from the loaded OBJ data and adds them to the scene
  81169. * @param scene the scene the objects should be added to
  81170. * @param data the OBJ data to load
  81171. * @param rootUrl root url to load from
  81172. * @param onProgress event that fires when loading progress has occured
  81173. * @param fileName Defines the name of the file to load
  81174. * @returns a promise which completes when objects have been loaded to the scene
  81175. */
  81176. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81177. /**
  81178. * Load into an asset container.
  81179. * @param scene The scene to load into
  81180. * @param data The data to import
  81181. * @param rootUrl The root url for scene and resources
  81182. * @param onProgress The callback when the load progresses
  81183. * @param fileName Defines the name of the file to load
  81184. * @returns The loaded asset container
  81185. */
  81186. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81187. /**
  81188. * Read the OBJ file and create an Array of meshes.
  81189. * Each mesh contains all information given by the OBJ and the MTL file.
  81190. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81191. *
  81192. * @param meshesNames
  81193. * @param scene Scene The scene where are displayed the data
  81194. * @param data String The content of the obj file
  81195. * @param rootUrl String The path to the folder
  81196. * @returns Array<AbstractMesh>
  81197. * @private
  81198. */
  81199. private _parseSolid;
  81200. }
  81201. }
  81202. declare module BABYLON {
  81203. /**
  81204. * STL file type loader.
  81205. * This is a babylon scene loader plugin.
  81206. */
  81207. export class STLFileLoader implements ISceneLoaderPlugin {
  81208. /** @hidden */
  81209. solidPattern: RegExp;
  81210. /** @hidden */
  81211. facetsPattern: RegExp;
  81212. /** @hidden */
  81213. normalPattern: RegExp;
  81214. /** @hidden */
  81215. vertexPattern: RegExp;
  81216. /**
  81217. * Defines the name of the plugin.
  81218. */
  81219. name: string;
  81220. /**
  81221. * Defines the extensions the stl loader is able to load.
  81222. * force data to come in as an ArrayBuffer
  81223. * we'll convert to string if it looks like it's an ASCII .stl
  81224. */
  81225. extensions: ISceneLoaderPluginExtensions;
  81226. /**
  81227. * Import meshes into a scene.
  81228. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81229. * @param scene The scene to import into
  81230. * @param data The data to import
  81231. * @param rootUrl The root url for scene and resources
  81232. * @param meshes The meshes array to import into
  81233. * @param particleSystems The particle systems array to import into
  81234. * @param skeletons The skeletons array to import into
  81235. * @param onError The callback when import fails
  81236. * @returns True if successful or false otherwise
  81237. */
  81238. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81239. /**
  81240. * Load into a scene.
  81241. * @param scene The scene to load into
  81242. * @param data The data to import
  81243. * @param rootUrl The root url for scene and resources
  81244. * @param onError The callback when import fails
  81245. * @returns true if successful or false otherwise
  81246. */
  81247. load(scene: Scene, data: any, rootUrl: string): boolean;
  81248. /**
  81249. * Load into an asset container.
  81250. * @param scene The scene to load into
  81251. * @param data The data to import
  81252. * @param rootUrl The root url for scene and resources
  81253. * @param onError The callback when import fails
  81254. * @returns The loaded asset container
  81255. */
  81256. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81257. private _isBinary;
  81258. private _parseBinary;
  81259. private _parseASCII;
  81260. }
  81261. }
  81262. declare module BABYLON {
  81263. /**
  81264. * Class for generating OBJ data from a Babylon scene.
  81265. */
  81266. export class OBJExport {
  81267. /**
  81268. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81269. * @param mesh defines the list of meshes to serialize
  81270. * @param materials defines if materials should be exported
  81271. * @param matlibname defines the name of the associated mtl file
  81272. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81273. * @returns the OBJ content
  81274. */
  81275. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81276. /**
  81277. * Exports the material(s) of a mesh in .MTL file format (text)
  81278. * @param mesh defines the mesh to extract the material from
  81279. * @returns the mtl content
  81280. */
  81281. static MTL(mesh: Mesh): string;
  81282. }
  81283. }
  81284. declare module BABYLON {
  81285. /** @hidden */
  81286. export var __IGLTFExporterExtension: number;
  81287. /**
  81288. * Interface for extending the exporter
  81289. * @hidden
  81290. */
  81291. export interface IGLTFExporterExtension {
  81292. /**
  81293. * The name of this extension
  81294. */
  81295. readonly name: string;
  81296. /**
  81297. * Defines whether this extension is enabled
  81298. */
  81299. enabled: boolean;
  81300. /**
  81301. * Defines whether this extension is required
  81302. */
  81303. required: boolean;
  81304. }
  81305. }
  81306. declare module BABYLON.GLTF2.Exporter {
  81307. /** @hidden */
  81308. export var __IGLTFExporterExtensionV2: number;
  81309. /**
  81310. * Interface for a glTF exporter extension
  81311. * @hidden
  81312. */
  81313. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81314. /**
  81315. * Define this method to modify the default behavior before exporting a texture
  81316. * @param context The context when loading the asset
  81317. * @param babylonTexture The Babylon.js texture
  81318. * @param mimeType The mime-type of the generated image
  81319. * @returns A promise that resolves with the exported texture
  81320. */
  81321. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81322. /**
  81323. * Define this method to get notified when a texture info is created
  81324. * @param context The context when loading the asset
  81325. * @param textureInfo The glTF texture info
  81326. * @param babylonTexture The Babylon.js texture
  81327. */
  81328. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81329. /**
  81330. * Define this method to modify the default behavior when exporting texture info
  81331. * @param context The context when loading the asset
  81332. * @param meshPrimitive glTF mesh primitive
  81333. * @param babylonSubMesh Babylon submesh
  81334. * @param binaryWriter glTF serializer binary writer instance
  81335. * @returns nullable IMeshPrimitive promise
  81336. */
  81337. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81338. /**
  81339. * Define this method to modify the default behavior when exporting a node
  81340. * @param context The context when exporting the node
  81341. * @param node glTF node
  81342. * @param babylonNode BabylonJS node
  81343. * @returns nullable INode promise
  81344. */
  81345. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81346. [key: number]: number;
  81347. }): Promise<Nullable<INode>>;
  81348. /**
  81349. * Define this method to modify the default behavior when exporting a material
  81350. * @param material glTF material
  81351. * @param babylonMaterial BabylonJS material
  81352. * @returns nullable IMaterial promise
  81353. */
  81354. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81355. /**
  81356. * Define this method to return additional textures to export from a material
  81357. * @param material glTF material
  81358. * @param babylonMaterial BabylonJS material
  81359. * @returns List of textures
  81360. */
  81361. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81362. /** Gets a boolean indicating that this extension was used */
  81363. wasUsed: boolean;
  81364. /** Gets a boolean indicating that this extension is required for the file to work */
  81365. required: boolean;
  81366. /**
  81367. * Called after the exporter state changes to EXPORTING
  81368. */
  81369. onExporting?(): void;
  81370. }
  81371. }
  81372. declare module BABYLON.GLTF2.Exporter {
  81373. /**
  81374. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81375. * @hidden
  81376. */
  81377. export class _GLTFMaterialExporter {
  81378. /**
  81379. * Represents the dielectric specular values for R, G and B
  81380. */
  81381. private static readonly _DielectricSpecular;
  81382. /**
  81383. * Allows the maximum specular power to be defined for material calculations
  81384. */
  81385. private static readonly _MaxSpecularPower;
  81386. /**
  81387. * Mapping to store textures
  81388. */
  81389. private _textureMap;
  81390. /**
  81391. * Numeric tolerance value
  81392. */
  81393. private static readonly _Epsilon;
  81394. /**
  81395. * Reference to the glTF Exporter
  81396. */
  81397. private _exporter;
  81398. constructor(exporter: _Exporter);
  81399. /**
  81400. * Specifies if two colors are approximately equal in value
  81401. * @param color1 first color to compare to
  81402. * @param color2 second color to compare to
  81403. * @param epsilon threshold value
  81404. */
  81405. private static FuzzyEquals;
  81406. /**
  81407. * Gets the materials from a Babylon scene and converts them to glTF materials
  81408. * @param scene babylonjs scene
  81409. * @param mimeType texture mime type
  81410. * @param images array of images
  81411. * @param textures array of textures
  81412. * @param materials array of materials
  81413. * @param imageData mapping of texture names to base64 textures
  81414. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81415. */
  81416. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81417. /**
  81418. * Makes a copy of the glTF material without the texture parameters
  81419. * @param originalMaterial original glTF material
  81420. * @returns glTF material without texture parameters
  81421. */
  81422. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81423. /**
  81424. * Specifies if the material has any texture parameters present
  81425. * @param material glTF Material
  81426. * @returns boolean specifying if texture parameters are present
  81427. */
  81428. _hasTexturesPresent(material: IMaterial): boolean;
  81429. /**
  81430. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81431. * @param babylonStandardMaterial
  81432. * @returns glTF Metallic Roughness Material representation
  81433. */
  81434. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81435. /**
  81436. * Computes the metallic factor
  81437. * @param diffuse diffused value
  81438. * @param specular specular value
  81439. * @param oneMinusSpecularStrength one minus the specular strength
  81440. * @returns metallic value
  81441. */
  81442. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81443. /**
  81444. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81445. * @param glTFMaterial glTF material
  81446. * @param babylonMaterial Babylon material
  81447. */
  81448. private static _SetAlphaMode;
  81449. /**
  81450. * Converts a Babylon Standard Material to a glTF Material
  81451. * @param babylonStandardMaterial BJS Standard Material
  81452. * @param mimeType mime type to use for the textures
  81453. * @param images array of glTF image interfaces
  81454. * @param textures array of glTF texture interfaces
  81455. * @param materials array of glTF material interfaces
  81456. * @param imageData map of image file name to data
  81457. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81458. */
  81459. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81460. private _finishMaterial;
  81461. /**
  81462. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81463. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81464. * @param mimeType mime type to use for the textures
  81465. * @param images array of glTF image interfaces
  81466. * @param textures array of glTF texture interfaces
  81467. * @param materials array of glTF material interfaces
  81468. * @param imageData map of image file name to data
  81469. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81470. */
  81471. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81472. /**
  81473. * Converts an image typed array buffer to a base64 image
  81474. * @param buffer typed array buffer
  81475. * @param width width of the image
  81476. * @param height height of the image
  81477. * @param mimeType mimetype of the image
  81478. * @returns base64 image string
  81479. */
  81480. private _createBase64FromCanvasAsync;
  81481. /**
  81482. * Generates a white texture based on the specified width and height
  81483. * @param width width of the texture in pixels
  81484. * @param height height of the texture in pixels
  81485. * @param scene babylonjs scene
  81486. * @returns white texture
  81487. */
  81488. private _createWhiteTexture;
  81489. /**
  81490. * 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
  81491. * @param texture1 first texture to resize
  81492. * @param texture2 second texture to resize
  81493. * @param scene babylonjs scene
  81494. * @returns resized textures or null
  81495. */
  81496. private _resizeTexturesToSameDimensions;
  81497. /**
  81498. * Converts an array of pixels to a Float32Array
  81499. * Throws an error if the pixel format is not supported
  81500. * @param pixels - array buffer containing pixel values
  81501. * @returns Float32 of pixels
  81502. */
  81503. private _convertPixelArrayToFloat32;
  81504. /**
  81505. * Convert Specular Glossiness Textures to Metallic Roughness
  81506. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81507. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81508. * @param diffuseTexture texture used to store diffuse information
  81509. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81510. * @param factors specular glossiness material factors
  81511. * @param mimeType the mime type to use for the texture
  81512. * @returns pbr metallic roughness interface or null
  81513. */
  81514. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81515. /**
  81516. * Converts specular glossiness material properties to metallic roughness
  81517. * @param specularGlossiness interface with specular glossiness material properties
  81518. * @returns interface with metallic roughness material properties
  81519. */
  81520. private _convertSpecularGlossinessToMetallicRoughness;
  81521. /**
  81522. * Calculates the surface reflectance, independent of lighting conditions
  81523. * @param color Color source to calculate brightness from
  81524. * @returns number representing the perceived brightness, or zero if color is undefined
  81525. */
  81526. private _getPerceivedBrightness;
  81527. /**
  81528. * Returns the maximum color component value
  81529. * @param color
  81530. * @returns maximum color component value, or zero if color is null or undefined
  81531. */
  81532. private _getMaxComponent;
  81533. /**
  81534. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81535. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81536. * @param mimeType mime type to use for the textures
  81537. * @param images array of glTF image interfaces
  81538. * @param textures array of glTF texture interfaces
  81539. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81540. * @param imageData map of image file name to data
  81541. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81542. * @returns glTF PBR Metallic Roughness factors
  81543. */
  81544. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81545. private _getGLTFTextureSampler;
  81546. private _getGLTFTextureWrapMode;
  81547. private _getGLTFTextureWrapModesSampler;
  81548. /**
  81549. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81550. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81551. * @param mimeType mime type to use for the textures
  81552. * @param images array of glTF image interfaces
  81553. * @param textures array of glTF texture interfaces
  81554. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81555. * @param imageData map of image file name to data
  81556. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81557. * @returns glTF PBR Metallic Roughness factors
  81558. */
  81559. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81560. /**
  81561. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81562. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81563. * @param mimeType mime type to use for the textures
  81564. * @param images array of glTF image interfaces
  81565. * @param textures array of glTF texture interfaces
  81566. * @param materials array of glTF material interfaces
  81567. * @param imageData map of image file name to data
  81568. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81569. */
  81570. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81571. private setMetallicRoughnessPbrMaterial;
  81572. private getPixelsFromTexture;
  81573. /**
  81574. * Extracts a texture from a Babylon texture into file data and glTF data
  81575. * @param babylonTexture Babylon texture to extract
  81576. * @param mimeType Mime Type of the babylonTexture
  81577. * @return glTF texture info, or null if the texture format is not supported
  81578. */
  81579. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81580. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81581. /**
  81582. * Builds a texture from base64 string
  81583. * @param base64Texture base64 texture string
  81584. * @param baseTextureName Name to use for the texture
  81585. * @param mimeType image mime type for the texture
  81586. * @param images array of images
  81587. * @param textures array of textures
  81588. * @param imageData map of image data
  81589. * @returns glTF texture info, or null if the texture format is not supported
  81590. */
  81591. private _getTextureInfoFromBase64;
  81592. }
  81593. }
  81594. declare module BABYLON {
  81595. /**
  81596. * Class for holding and downloading glTF file data
  81597. */
  81598. export class GLTFData {
  81599. /**
  81600. * Object which contains the file name as the key and its data as the value
  81601. */
  81602. glTFFiles: {
  81603. [fileName: string]: string | Blob;
  81604. };
  81605. /**
  81606. * Initializes the glTF file object
  81607. */
  81608. constructor();
  81609. /**
  81610. * Downloads the glTF data as files based on their names and data
  81611. */
  81612. downloadFiles(): void;
  81613. }
  81614. }
  81615. declare module BABYLON {
  81616. /**
  81617. * Holds a collection of exporter options and parameters
  81618. */
  81619. export interface IExportOptions {
  81620. /**
  81621. * Function which indicates whether a babylon node should be exported or not
  81622. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81623. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81624. */
  81625. shouldExportNode?(node: Node): boolean;
  81626. /**
  81627. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81628. * @param metadata source metadata to read from
  81629. * @returns the data to store to glTF node extras
  81630. */
  81631. metadataSelector?(metadata: any): any;
  81632. /**
  81633. * The sample rate to bake animation curves
  81634. */
  81635. animationSampleRate?: number;
  81636. /**
  81637. * Begin serialization without waiting for the scene to be ready
  81638. */
  81639. exportWithoutWaitingForScene?: boolean;
  81640. /**
  81641. * Indicates if coordinate system swapping root nodes should be included in export
  81642. */
  81643. includeCoordinateSystemConversionNodes?: boolean;
  81644. }
  81645. /**
  81646. * Class for generating glTF data from a Babylon scene.
  81647. */
  81648. export class GLTF2Export {
  81649. /**
  81650. * Exports the geometry of the scene to .gltf file format asynchronously
  81651. * @param scene Babylon scene with scene hierarchy information
  81652. * @param filePrefix File prefix to use when generating the glTF file
  81653. * @param options Exporter options
  81654. * @returns Returns an object with a .gltf file and associates texture names
  81655. * as keys and their data and paths as values
  81656. */
  81657. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81658. private static _PreExportAsync;
  81659. private static _PostExportAsync;
  81660. /**
  81661. * Exports the geometry of the scene to .glb file format asychronously
  81662. * @param scene Babylon scene with scene hierarchy information
  81663. * @param filePrefix File prefix to use when generating glb file
  81664. * @param options Exporter options
  81665. * @returns Returns an object with a .glb filename as key and data as value
  81666. */
  81667. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81668. }
  81669. }
  81670. declare module BABYLON.GLTF2.Exporter {
  81671. /**
  81672. * @hidden
  81673. */
  81674. export class _GLTFUtilities {
  81675. /**
  81676. * Creates a buffer view based on the supplied arguments
  81677. * @param bufferIndex index value of the specified buffer
  81678. * @param byteOffset byte offset value
  81679. * @param byteLength byte length of the bufferView
  81680. * @param byteStride byte distance between conequential elements
  81681. * @param name name of the buffer view
  81682. * @returns bufferView for glTF
  81683. */
  81684. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81685. /**
  81686. * Creates an accessor based on the supplied arguments
  81687. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81688. * @param name The name of the accessor
  81689. * @param type The type of the accessor
  81690. * @param componentType The datatype of components in the attribute
  81691. * @param count The number of attributes referenced by this accessor
  81692. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81693. * @param min Minimum value of each component in this attribute
  81694. * @param max Maximum value of each component in this attribute
  81695. * @returns accessor for glTF
  81696. */
  81697. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81698. /**
  81699. * Calculates the minimum and maximum values of an array of position floats
  81700. * @param positions Positions array of a mesh
  81701. * @param vertexStart Starting vertex offset to calculate min and max values
  81702. * @param vertexCount Number of vertices to check for min and max values
  81703. * @returns min number array and max number array
  81704. */
  81705. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81706. min: number[];
  81707. max: number[];
  81708. };
  81709. /**
  81710. * Converts a new right-handed Vector3
  81711. * @param vector vector3 array
  81712. * @returns right-handed Vector3
  81713. */
  81714. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81715. /**
  81716. * Converts a Vector3 to right-handed
  81717. * @param vector Vector3 to convert to right-handed
  81718. */
  81719. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81720. /**
  81721. * Converts a three element number array to right-handed
  81722. * @param vector number array to convert to right-handed
  81723. */
  81724. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81725. /**
  81726. * Converts a new right-handed Vector3
  81727. * @param vector vector3 array
  81728. * @returns right-handed Vector3
  81729. */
  81730. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81731. /**
  81732. * Converts a Vector3 to right-handed
  81733. * @param vector Vector3 to convert to right-handed
  81734. */
  81735. static _GetRightHandedNormalVector3FromRef(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 _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81741. /**
  81742. * Converts a Vector4 to right-handed
  81743. * @param vector Vector4 to convert to right-handed
  81744. */
  81745. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81746. /**
  81747. * Converts a Vector4 to right-handed
  81748. * @param vector Vector4 to convert to right-handed
  81749. */
  81750. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81751. /**
  81752. * Converts a Quaternion to right-handed
  81753. * @param quaternion Source quaternion to convert to right-handed
  81754. */
  81755. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81756. /**
  81757. * Converts a Quaternion to right-handed
  81758. * @param quaternion Source quaternion to convert to right-handed
  81759. */
  81760. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81761. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81762. }
  81763. }
  81764. declare module BABYLON.GLTF2.Exporter {
  81765. /**
  81766. * Converts Babylon Scene into glTF 2.0.
  81767. * @hidden
  81768. */
  81769. export class _Exporter {
  81770. /**
  81771. * Stores the glTF to export
  81772. */
  81773. _glTF: IGLTF;
  81774. /**
  81775. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81776. */
  81777. _bufferViews: IBufferView[];
  81778. /**
  81779. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81780. */
  81781. _accessors: IAccessor[];
  81782. /**
  81783. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81784. */
  81785. _nodes: INode[];
  81786. /**
  81787. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81788. */
  81789. private _scenes;
  81790. /**
  81791. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81792. */
  81793. private _meshes;
  81794. /**
  81795. * Stores all the generated material information, which represents the appearance of each primitive
  81796. */
  81797. _materials: IMaterial[];
  81798. _materialMap: {
  81799. [materialID: number]: number;
  81800. };
  81801. /**
  81802. * Stores all the generated texture information, which is referenced by glTF materials
  81803. */
  81804. _textures: ITexture[];
  81805. /**
  81806. * Stores all the generated image information, which is referenced by glTF textures
  81807. */
  81808. _images: IImage[];
  81809. /**
  81810. * Stores all the texture samplers
  81811. */
  81812. _samplers: ISampler[];
  81813. /**
  81814. * Stores all the generated animation samplers, which is referenced by glTF animations
  81815. */
  81816. /**
  81817. * Stores the animations for glTF models
  81818. */
  81819. private _animations;
  81820. /**
  81821. * Stores the total amount of bytes stored in the glTF buffer
  81822. */
  81823. private _totalByteLength;
  81824. /**
  81825. * Stores a reference to the Babylon scene containing the source geometry and material information
  81826. */
  81827. _babylonScene: Scene;
  81828. /**
  81829. * Stores a map of the image data, where the key is the file name and the value
  81830. * is the image data
  81831. */
  81832. _imageData: {
  81833. [fileName: string]: {
  81834. data: Uint8Array;
  81835. mimeType: ImageMimeType;
  81836. };
  81837. };
  81838. /**
  81839. * Stores a map of the unique id of a node to its index in the node array
  81840. */
  81841. _nodeMap: {
  81842. [key: number]: number;
  81843. };
  81844. /**
  81845. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81846. */
  81847. _convertToRightHandedSystem: boolean;
  81848. /**
  81849. * Specifies if a Babylon node should be converted to right-handed on export
  81850. */
  81851. _convertToRightHandedSystemMap: {
  81852. [nodeId: number]: boolean;
  81853. };
  81854. _includeCoordinateSystemConversionNodes: boolean;
  81855. /**
  81856. * Baked animation sample rate
  81857. */
  81858. private _animationSampleRate;
  81859. private _options;
  81860. private _localEngine;
  81861. _glTFMaterialExporter: _GLTFMaterialExporter;
  81862. private _extensions;
  81863. private static _ExtensionNames;
  81864. private static _ExtensionFactories;
  81865. private _applyExtension;
  81866. private _applyExtensions;
  81867. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81868. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81869. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81870. [key: number]: number;
  81871. }): Promise<Nullable<INode>>;
  81872. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81873. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81874. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81875. private _forEachExtensions;
  81876. private _extensionsOnExporting;
  81877. /**
  81878. * Load glTF serializer extensions
  81879. */
  81880. private _loadExtensions;
  81881. /**
  81882. * Creates a glTF Exporter instance, which can accept optional exporter options
  81883. * @param babylonScene Babylon scene object
  81884. * @param options Options to modify the behavior of the exporter
  81885. */
  81886. constructor(babylonScene: Scene, options?: IExportOptions);
  81887. dispose(): void;
  81888. /**
  81889. * Registers a glTF exporter extension
  81890. * @param name Name of the extension to export
  81891. * @param factory The factory function that creates the exporter extension
  81892. */
  81893. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81894. /**
  81895. * Un-registers an exporter extension
  81896. * @param name The name fo the exporter extension
  81897. * @returns A boolean indicating whether the extension has been un-registered
  81898. */
  81899. static UnregisterExtension(name: string): boolean;
  81900. /**
  81901. * Lazy load a local engine
  81902. */
  81903. _getLocalEngine(): Engine;
  81904. private reorderIndicesBasedOnPrimitiveMode;
  81905. /**
  81906. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81907. * clock-wise during export to glTF
  81908. * @param submesh BabylonJS submesh
  81909. * @param primitiveMode Primitive mode of the mesh
  81910. * @param sideOrientation the winding order of the submesh
  81911. * @param vertexBufferKind The type of vertex attribute
  81912. * @param meshAttributeArray The vertex attribute data
  81913. * @param byteOffset The offset to the binary data
  81914. * @param binaryWriter The binary data for the glTF file
  81915. * @param convertToRightHandedSystem Converts the values to right-handed
  81916. */
  81917. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81918. /**
  81919. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81920. * clock-wise during export to glTF
  81921. * @param submesh BabylonJS submesh
  81922. * @param primitiveMode Primitive mode of the mesh
  81923. * @param sideOrientation the winding order of the submesh
  81924. * @param vertexBufferKind The type of vertex attribute
  81925. * @param meshAttributeArray The vertex attribute data
  81926. * @param byteOffset The offset to the binary data
  81927. * @param binaryWriter The binary data for the glTF file
  81928. * @param convertToRightHandedSystem Converts the values to right-handed
  81929. */
  81930. private reorderTriangleFillMode;
  81931. /**
  81932. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81933. * clock-wise during export to glTF
  81934. * @param submesh BabylonJS submesh
  81935. * @param primitiveMode Primitive mode of the mesh
  81936. * @param sideOrientation the winding order of the submesh
  81937. * @param vertexBufferKind The type of vertex attribute
  81938. * @param meshAttributeArray The vertex attribute data
  81939. * @param byteOffset The offset to the binary data
  81940. * @param binaryWriter The binary data for the glTF file
  81941. * @param convertToRightHandedSystem Converts the values to right-handed
  81942. */
  81943. private reorderTriangleStripDrawMode;
  81944. /**
  81945. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81946. * clock-wise during export to glTF
  81947. * @param submesh BabylonJS submesh
  81948. * @param primitiveMode Primitive mode of the mesh
  81949. * @param sideOrientation the winding order of the submesh
  81950. * @param vertexBufferKind The type of vertex attribute
  81951. * @param meshAttributeArray The vertex attribute data
  81952. * @param byteOffset The offset to the binary data
  81953. * @param binaryWriter The binary data for the glTF file
  81954. * @param convertToRightHandedSystem Converts the values to right-handed
  81955. */
  81956. private reorderTriangleFanMode;
  81957. /**
  81958. * Writes the vertex attribute data to binary
  81959. * @param vertices The vertices to write to the binary writer
  81960. * @param byteOffset The offset into the binary writer to overwrite binary data
  81961. * @param vertexAttributeKind The vertex attribute type
  81962. * @param meshAttributeArray The vertex attribute data
  81963. * @param binaryWriter The writer containing the binary data
  81964. * @param convertToRightHandedSystem Converts the values to right-handed
  81965. */
  81966. private writeVertexAttributeData;
  81967. /**
  81968. * Writes mesh attribute data to a data buffer
  81969. * Returns the bytelength of the data
  81970. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81971. * @param meshAttributeArray Array containing the attribute data
  81972. * @param binaryWriter The buffer to write the binary data to
  81973. * @param indices Used to specify the order of the vertex data
  81974. * @param convertToRightHandedSystem Converts the values to right-handed
  81975. */
  81976. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81977. /**
  81978. * Generates glTF json data
  81979. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81980. * @param glTFPrefix Text to use when prefixing a glTF file
  81981. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81982. * @returns json data as string
  81983. */
  81984. private generateJSON;
  81985. /**
  81986. * Generates data for .gltf and .bin files based on the glTF prefix string
  81987. * @param glTFPrefix Text to use when prefixing a glTF file
  81988. * @param dispose Dispose the exporter
  81989. * @returns GLTFData with glTF file data
  81990. */
  81991. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81992. /**
  81993. * Creates a binary buffer for glTF
  81994. * @returns array buffer for binary data
  81995. */
  81996. private _generateBinaryAsync;
  81997. /**
  81998. * Pads the number to a multiple of 4
  81999. * @param num number to pad
  82000. * @returns padded number
  82001. */
  82002. private _getPadding;
  82003. /**
  82004. * @hidden
  82005. */
  82006. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82007. /**
  82008. * Sets the TRS for each node
  82009. * @param node glTF Node for storing the transformation data
  82010. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82011. * @param convertToRightHandedSystem Converts the values to right-handed
  82012. */
  82013. private setNodeTransformation;
  82014. private getVertexBufferFromMesh;
  82015. /**
  82016. * Creates a bufferview based on the vertices type for the Babylon mesh
  82017. * @param kind Indicates the type of vertices data
  82018. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82019. * @param binaryWriter The buffer to write the bufferview data to
  82020. * @param convertToRightHandedSystem Converts the values to right-handed
  82021. */
  82022. private createBufferViewKind;
  82023. /**
  82024. * The primitive mode of the Babylon mesh
  82025. * @param babylonMesh The BabylonJS mesh
  82026. */
  82027. private getMeshPrimitiveMode;
  82028. /**
  82029. * Sets the primitive mode of the glTF mesh primitive
  82030. * @param meshPrimitive glTF mesh primitive
  82031. * @param primitiveMode The primitive mode
  82032. */
  82033. private setPrimitiveMode;
  82034. /**
  82035. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82036. * @param meshPrimitive glTF mesh primitive
  82037. * @param attributeKind vertex attribute
  82038. * @returns boolean specifying if uv coordinates are present
  82039. */
  82040. private setAttributeKind;
  82041. /**
  82042. * Sets data for the primitive attributes of each submesh
  82043. * @param mesh glTF Mesh object to store the primitive attribute information
  82044. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82045. * @param binaryWriter Buffer to write the attribute data to
  82046. * @param convertToRightHandedSystem Converts the values to right-handed
  82047. */
  82048. private setPrimitiveAttributesAsync;
  82049. /**
  82050. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82051. * @param node The node to check
  82052. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82053. */
  82054. private isBabylonCoordinateSystemConvertingNode;
  82055. /**
  82056. * Creates a glTF scene based on the array of meshes
  82057. * Returns the the total byte offset
  82058. * @param babylonScene Babylon scene to get the mesh data from
  82059. * @param binaryWriter Buffer to write binary data to
  82060. */
  82061. private createSceneAsync;
  82062. /**
  82063. * Creates a mapping of Node unique id to node index and handles animations
  82064. * @param babylonScene Babylon Scene
  82065. * @param nodes Babylon transform nodes
  82066. * @param binaryWriter Buffer to write binary data to
  82067. * @returns Node mapping of unique id to index
  82068. */
  82069. private createNodeMapAndAnimationsAsync;
  82070. /**
  82071. * Creates a glTF node from a Babylon mesh
  82072. * @param babylonMesh Source Babylon mesh
  82073. * @param binaryWriter Buffer for storing geometry data
  82074. * @param convertToRightHandedSystem Converts the values to right-handed
  82075. * @param nodeMap Node mapping of unique id to glTF node index
  82076. * @returns glTF node
  82077. */
  82078. private createNodeAsync;
  82079. }
  82080. /**
  82081. * @hidden
  82082. *
  82083. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82084. */
  82085. export class _BinaryWriter {
  82086. /**
  82087. * Array buffer which stores all binary data
  82088. */
  82089. private _arrayBuffer;
  82090. /**
  82091. * View of the array buffer
  82092. */
  82093. private _dataView;
  82094. /**
  82095. * byte offset of data in array buffer
  82096. */
  82097. private _byteOffset;
  82098. /**
  82099. * Initialize binary writer with an initial byte length
  82100. * @param byteLength Initial byte length of the array buffer
  82101. */
  82102. constructor(byteLength: number);
  82103. /**
  82104. * Resize the array buffer to the specified byte length
  82105. * @param byteLength
  82106. */
  82107. private resizeBuffer;
  82108. /**
  82109. * Get an array buffer with the length of the byte offset
  82110. * @returns ArrayBuffer resized to the byte offset
  82111. */
  82112. getArrayBuffer(): ArrayBuffer;
  82113. /**
  82114. * Get the byte offset of the array buffer
  82115. * @returns byte offset
  82116. */
  82117. getByteOffset(): number;
  82118. /**
  82119. * Stores an UInt8 in the array buffer
  82120. * @param entry
  82121. * @param byteOffset If defined, specifies where to set the value as an offset.
  82122. */
  82123. setUInt8(entry: number, byteOffset?: number): void;
  82124. /**
  82125. * Gets an UInt32 in the array buffer
  82126. * @param entry
  82127. * @param byteOffset If defined, specifies where to set the value as an offset.
  82128. */
  82129. getUInt32(byteOffset: number): number;
  82130. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82131. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82132. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82133. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82134. /**
  82135. * Stores a Float32 in the array buffer
  82136. * @param entry
  82137. */
  82138. setFloat32(entry: number, byteOffset?: number): void;
  82139. /**
  82140. * Stores an UInt32 in the array buffer
  82141. * @param entry
  82142. * @param byteOffset If defined, specifies where to set the value as an offset.
  82143. */
  82144. setUInt32(entry: number, byteOffset?: number): void;
  82145. }
  82146. }
  82147. declare module BABYLON.GLTF2.Exporter {
  82148. /**
  82149. * @hidden
  82150. * Interface to store animation data.
  82151. */
  82152. export interface _IAnimationData {
  82153. /**
  82154. * Keyframe data.
  82155. */
  82156. inputs: number[];
  82157. /**
  82158. * Value data.
  82159. */
  82160. outputs: number[][];
  82161. /**
  82162. * Animation interpolation data.
  82163. */
  82164. samplerInterpolation: AnimationSamplerInterpolation;
  82165. /**
  82166. * Minimum keyframe value.
  82167. */
  82168. inputsMin: number;
  82169. /**
  82170. * Maximum keyframe value.
  82171. */
  82172. inputsMax: number;
  82173. }
  82174. /**
  82175. * @hidden
  82176. */
  82177. export interface _IAnimationInfo {
  82178. /**
  82179. * The target channel for the animation
  82180. */
  82181. animationChannelTargetPath: AnimationChannelTargetPath;
  82182. /**
  82183. * The glTF accessor type for the data.
  82184. */
  82185. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82186. /**
  82187. * Specifies if quaternions should be used.
  82188. */
  82189. useQuaternion: boolean;
  82190. }
  82191. /**
  82192. * @hidden
  82193. * Utility class for generating glTF animation data from BabylonJS.
  82194. */
  82195. export class _GLTFAnimation {
  82196. /**
  82197. * @ignore
  82198. *
  82199. * Creates glTF channel animation from BabylonJS animation.
  82200. * @param babylonTransformNode - BabylonJS mesh.
  82201. * @param animation - animation.
  82202. * @param animationChannelTargetPath - The target animation channel.
  82203. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82204. * @param useQuaternion - Specifies if quaternions are used.
  82205. * @returns nullable IAnimationData
  82206. */
  82207. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82208. private static _DeduceAnimationInfo;
  82209. /**
  82210. * @ignore
  82211. * Create node animations from the transform node animations
  82212. * @param babylonNode
  82213. * @param runtimeGLTFAnimation
  82214. * @param idleGLTFAnimations
  82215. * @param nodeMap
  82216. * @param nodes
  82217. * @param binaryWriter
  82218. * @param bufferViews
  82219. * @param accessors
  82220. * @param convertToRightHandedSystem
  82221. * @param animationSampleRate
  82222. */
  82223. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82224. [key: number]: number;
  82225. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82226. /**
  82227. * @ignore
  82228. * Create node animations from the animation groups
  82229. * @param babylonScene
  82230. * @param glTFAnimations
  82231. * @param nodeMap
  82232. * @param nodes
  82233. * @param binaryWriter
  82234. * @param bufferViews
  82235. * @param accessors
  82236. * @param convertToRightHandedSystemMap
  82237. * @param animationSampleRate
  82238. */
  82239. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82240. [key: number]: number;
  82241. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82242. [nodeId: number]: boolean;
  82243. }, animationSampleRate: number): void;
  82244. private static AddAnimation;
  82245. /**
  82246. * Create a baked animation
  82247. * @param babylonTransformNode BabylonJS mesh
  82248. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82249. * @param animationChannelTargetPath animation target channel
  82250. * @param minFrame minimum animation frame
  82251. * @param maxFrame maximum animation frame
  82252. * @param fps frames per second of the animation
  82253. * @param inputs input key frames of the animation
  82254. * @param outputs output key frame data of the animation
  82255. * @param convertToRightHandedSystem converts the values to right-handed
  82256. * @param useQuaternion specifies if quaternions should be used
  82257. */
  82258. private static _CreateBakedAnimation;
  82259. private static _ConvertFactorToVector3OrQuaternion;
  82260. private static _SetInterpolatedValue;
  82261. /**
  82262. * Creates linear animation from the animation key frames
  82263. * @param babylonTransformNode BabylonJS mesh
  82264. * @param animation BabylonJS animation
  82265. * @param animationChannelTargetPath The target animation channel
  82266. * @param frameDelta The difference between the last and first frame of the animation
  82267. * @param inputs Array to store the key frame times
  82268. * @param outputs Array to store the key frame data
  82269. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82270. * @param useQuaternion Specifies if quaternions are used in the animation
  82271. */
  82272. private static _CreateLinearOrStepAnimation;
  82273. /**
  82274. * Creates cubic spline animation from the animation key frames
  82275. * @param babylonTransformNode BabylonJS mesh
  82276. * @param animation BabylonJS animation
  82277. * @param animationChannelTargetPath The target animation channel
  82278. * @param frameDelta The difference between the last and first frame of the animation
  82279. * @param inputs Array to store the key frame times
  82280. * @param outputs Array to store the key frame data
  82281. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82282. * @param useQuaternion Specifies if quaternions are used in the animation
  82283. */
  82284. private static _CreateCubicSplineAnimation;
  82285. private static _GetBasePositionRotationOrScale;
  82286. /**
  82287. * Adds a key frame value
  82288. * @param keyFrame
  82289. * @param animation
  82290. * @param outputs
  82291. * @param animationChannelTargetPath
  82292. * @param basePositionRotationOrScale
  82293. * @param convertToRightHandedSystem
  82294. * @param useQuaternion
  82295. */
  82296. private static _AddKeyframeValue;
  82297. /**
  82298. * Determine the interpolation based on the key frames
  82299. * @param keyFrames
  82300. * @param animationChannelTargetPath
  82301. * @param useQuaternion
  82302. */
  82303. private static _DeduceInterpolation;
  82304. /**
  82305. * Adds an input tangent or output tangent to the output data
  82306. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82307. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82308. * @param outputs The animation data by keyframe
  82309. * @param animationChannelTargetPath The target animation channel
  82310. * @param interpolation The interpolation type
  82311. * @param keyFrame The key frame with the animation data
  82312. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82313. * @param useQuaternion Specifies if quaternions are used
  82314. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82315. */
  82316. private static AddSplineTangent;
  82317. /**
  82318. * Get the minimum and maximum key frames' frame values
  82319. * @param keyFrames animation key frames
  82320. * @returns the minimum and maximum key frame value
  82321. */
  82322. private static calculateMinMaxKeyFrames;
  82323. }
  82324. }
  82325. declare module BABYLON.GLTF2.Exporter {
  82326. /** @hidden */
  82327. export var textureTransformPixelShader: {
  82328. name: string;
  82329. shader: string;
  82330. };
  82331. }
  82332. declare module BABYLON.GLTF2.Exporter.Extensions {
  82333. /**
  82334. * @hidden
  82335. */
  82336. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82337. private _recordedTextures;
  82338. /** Name of this extension */
  82339. readonly name: string;
  82340. /** Defines whether this extension is enabled */
  82341. enabled: boolean;
  82342. /** Defines whether this extension is required */
  82343. required: boolean;
  82344. /** Reference to the glTF exporter */
  82345. private _wasUsed;
  82346. constructor(exporter: _Exporter);
  82347. dispose(): void;
  82348. /** @hidden */
  82349. get wasUsed(): boolean;
  82350. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82351. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82352. /**
  82353. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82354. * @param babylonTexture
  82355. * @param offset
  82356. * @param rotation
  82357. * @param scale
  82358. * @param scene
  82359. */
  82360. private _textureTransformTextureAsync;
  82361. }
  82362. }
  82363. declare module BABYLON.GLTF2.Exporter.Extensions {
  82364. /**
  82365. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82366. */
  82367. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82368. /** The name of this extension. */
  82369. readonly name: string;
  82370. /** Defines whether this extension is enabled. */
  82371. enabled: boolean;
  82372. /** Defines whether this extension is required */
  82373. required: boolean;
  82374. /** Reference to the glTF exporter */
  82375. private _exporter;
  82376. private _lights;
  82377. /** @hidden */
  82378. constructor(exporter: _Exporter);
  82379. /** @hidden */
  82380. dispose(): void;
  82381. /** @hidden */
  82382. get wasUsed(): boolean;
  82383. /** @hidden */
  82384. onExporting(): void;
  82385. /**
  82386. * Define this method to modify the default behavior when exporting a node
  82387. * @param context The context when exporting the node
  82388. * @param node glTF node
  82389. * @param babylonNode BabylonJS node
  82390. * @param nodeMap Node mapping of unique id to glTF node index
  82391. * @returns nullable INode promise
  82392. */
  82393. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82394. [key: number]: number;
  82395. }): Promise<Nullable<INode>>;
  82396. }
  82397. }
  82398. declare module BABYLON.GLTF2.Exporter.Extensions {
  82399. /**
  82400. * @hidden
  82401. */
  82402. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82403. /** Name of this extension */
  82404. readonly name: string;
  82405. /** Defines whether this extension is enabled */
  82406. enabled: boolean;
  82407. /** Defines whether this extension is required */
  82408. required: boolean;
  82409. /** Reference to the glTF exporter */
  82410. private _textureInfos;
  82411. private _exportedTextures;
  82412. private _wasUsed;
  82413. constructor(exporter: _Exporter);
  82414. dispose(): void;
  82415. /** @hidden */
  82416. get wasUsed(): boolean;
  82417. private _getTextureIndex;
  82418. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82419. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82420. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82421. }
  82422. }
  82423. declare module BABYLON {
  82424. /**
  82425. * Class for generating STL data from a Babylon scene.
  82426. */
  82427. export class STLExport {
  82428. /**
  82429. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82430. * @param meshes list defines the mesh to serialize
  82431. * @param download triggers the automatic download of the file.
  82432. * @param fileName changes the downloads fileName.
  82433. * @param binary changes the STL to a binary type.
  82434. * @param isLittleEndian toggle for binary type exporter.
  82435. * @returns the STL as UTF8 string
  82436. */
  82437. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82438. }
  82439. }
  82440. declare module "babylonjs-gltf2interface" {
  82441. export = BABYLON.GLTF2;
  82442. }
  82443. /**
  82444. * Module for glTF 2.0 Interface
  82445. */
  82446. declare module BABYLON.GLTF2 {
  82447. /**
  82448. * The datatype of the components in the attribute
  82449. */
  82450. const enum AccessorComponentType {
  82451. /**
  82452. * Byte
  82453. */
  82454. BYTE = 5120,
  82455. /**
  82456. * Unsigned Byte
  82457. */
  82458. UNSIGNED_BYTE = 5121,
  82459. /**
  82460. * Short
  82461. */
  82462. SHORT = 5122,
  82463. /**
  82464. * Unsigned Short
  82465. */
  82466. UNSIGNED_SHORT = 5123,
  82467. /**
  82468. * Unsigned Int
  82469. */
  82470. UNSIGNED_INT = 5125,
  82471. /**
  82472. * Float
  82473. */
  82474. FLOAT = 5126,
  82475. }
  82476. /**
  82477. * Specifies if the attirbute is a scalar, vector, or matrix
  82478. */
  82479. const enum AccessorType {
  82480. /**
  82481. * Scalar
  82482. */
  82483. SCALAR = "SCALAR",
  82484. /**
  82485. * Vector2
  82486. */
  82487. VEC2 = "VEC2",
  82488. /**
  82489. * Vector3
  82490. */
  82491. VEC3 = "VEC3",
  82492. /**
  82493. * Vector4
  82494. */
  82495. VEC4 = "VEC4",
  82496. /**
  82497. * Matrix2x2
  82498. */
  82499. MAT2 = "MAT2",
  82500. /**
  82501. * Matrix3x3
  82502. */
  82503. MAT3 = "MAT3",
  82504. /**
  82505. * Matrix4x4
  82506. */
  82507. MAT4 = "MAT4",
  82508. }
  82509. /**
  82510. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82511. */
  82512. const enum AnimationChannelTargetPath {
  82513. /**
  82514. * Translation
  82515. */
  82516. TRANSLATION = "translation",
  82517. /**
  82518. * Rotation
  82519. */
  82520. ROTATION = "rotation",
  82521. /**
  82522. * Scale
  82523. */
  82524. SCALE = "scale",
  82525. /**
  82526. * Weights
  82527. */
  82528. WEIGHTS = "weights",
  82529. }
  82530. /**
  82531. * Interpolation algorithm
  82532. */
  82533. const enum AnimationSamplerInterpolation {
  82534. /**
  82535. * The animated values are linearly interpolated between keyframes
  82536. */
  82537. LINEAR = "LINEAR",
  82538. /**
  82539. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82540. */
  82541. STEP = "STEP",
  82542. /**
  82543. * The animation's interpolation is computed using a cubic spline with specified tangents
  82544. */
  82545. CUBICSPLINE = "CUBICSPLINE",
  82546. }
  82547. /**
  82548. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82549. */
  82550. const enum CameraType {
  82551. /**
  82552. * A perspective camera containing properties to create a perspective projection matrix
  82553. */
  82554. PERSPECTIVE = "perspective",
  82555. /**
  82556. * An orthographic camera containing properties to create an orthographic projection matrix
  82557. */
  82558. ORTHOGRAPHIC = "orthographic",
  82559. }
  82560. /**
  82561. * The mime-type of the image
  82562. */
  82563. const enum ImageMimeType {
  82564. /**
  82565. * JPEG Mime-type
  82566. */
  82567. JPEG = "image/jpeg",
  82568. /**
  82569. * PNG Mime-type
  82570. */
  82571. PNG = "image/png",
  82572. }
  82573. /**
  82574. * The alpha rendering mode of the material
  82575. */
  82576. const enum MaterialAlphaMode {
  82577. /**
  82578. * The alpha value is ignored and the rendered output is fully opaque
  82579. */
  82580. OPAQUE = "OPAQUE",
  82581. /**
  82582. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82583. */
  82584. MASK = "MASK",
  82585. /**
  82586. * 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)
  82587. */
  82588. BLEND = "BLEND",
  82589. }
  82590. /**
  82591. * The type of the primitives to render
  82592. */
  82593. const enum MeshPrimitiveMode {
  82594. /**
  82595. * Points
  82596. */
  82597. POINTS = 0,
  82598. /**
  82599. * Lines
  82600. */
  82601. LINES = 1,
  82602. /**
  82603. * Line Loop
  82604. */
  82605. LINE_LOOP = 2,
  82606. /**
  82607. * Line Strip
  82608. */
  82609. LINE_STRIP = 3,
  82610. /**
  82611. * Triangles
  82612. */
  82613. TRIANGLES = 4,
  82614. /**
  82615. * Triangle Strip
  82616. */
  82617. TRIANGLE_STRIP = 5,
  82618. /**
  82619. * Triangle Fan
  82620. */
  82621. TRIANGLE_FAN = 6,
  82622. }
  82623. /**
  82624. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82625. */
  82626. const enum TextureMagFilter {
  82627. /**
  82628. * Nearest
  82629. */
  82630. NEAREST = 9728,
  82631. /**
  82632. * Linear
  82633. */
  82634. LINEAR = 9729,
  82635. }
  82636. /**
  82637. * Minification filter. All valid values correspond to WebGL enums
  82638. */
  82639. const enum TextureMinFilter {
  82640. /**
  82641. * Nearest
  82642. */
  82643. NEAREST = 9728,
  82644. /**
  82645. * Linear
  82646. */
  82647. LINEAR = 9729,
  82648. /**
  82649. * Nearest Mip-Map Nearest
  82650. */
  82651. NEAREST_MIPMAP_NEAREST = 9984,
  82652. /**
  82653. * Linear Mipmap Nearest
  82654. */
  82655. LINEAR_MIPMAP_NEAREST = 9985,
  82656. /**
  82657. * Nearest Mipmap Linear
  82658. */
  82659. NEAREST_MIPMAP_LINEAR = 9986,
  82660. /**
  82661. * Linear Mipmap Linear
  82662. */
  82663. LINEAR_MIPMAP_LINEAR = 9987,
  82664. }
  82665. /**
  82666. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82667. */
  82668. const enum TextureWrapMode {
  82669. /**
  82670. * Clamp to Edge
  82671. */
  82672. CLAMP_TO_EDGE = 33071,
  82673. /**
  82674. * Mirrored Repeat
  82675. */
  82676. MIRRORED_REPEAT = 33648,
  82677. /**
  82678. * Repeat
  82679. */
  82680. REPEAT = 10497,
  82681. }
  82682. /**
  82683. * glTF Property
  82684. */
  82685. interface IProperty {
  82686. /**
  82687. * Dictionary object with extension-specific objects
  82688. */
  82689. extensions?: {
  82690. [key: string]: any;
  82691. };
  82692. /**
  82693. * Application-Specific data
  82694. */
  82695. extras?: any;
  82696. }
  82697. /**
  82698. * glTF Child of Root Property
  82699. */
  82700. interface IChildRootProperty extends IProperty {
  82701. /**
  82702. * The user-defined name of this object
  82703. */
  82704. name?: string;
  82705. }
  82706. /**
  82707. * Indices of those attributes that deviate from their initialization value
  82708. */
  82709. interface IAccessorSparseIndices extends IProperty {
  82710. /**
  82711. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82712. */
  82713. bufferView: number;
  82714. /**
  82715. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82716. */
  82717. byteOffset?: number;
  82718. /**
  82719. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82720. */
  82721. componentType: AccessorComponentType;
  82722. }
  82723. /**
  82724. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82725. */
  82726. interface IAccessorSparseValues extends IProperty {
  82727. /**
  82728. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82729. */
  82730. bufferView: number;
  82731. /**
  82732. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82733. */
  82734. byteOffset?: number;
  82735. }
  82736. /**
  82737. * Sparse storage of attributes that deviate from their initialization value
  82738. */
  82739. interface IAccessorSparse extends IProperty {
  82740. /**
  82741. * The number of attributes encoded in this sparse accessor
  82742. */
  82743. count: number;
  82744. /**
  82745. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82746. */
  82747. indices: IAccessorSparseIndices;
  82748. /**
  82749. * 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
  82750. */
  82751. values: IAccessorSparseValues;
  82752. }
  82753. /**
  82754. * 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
  82755. */
  82756. interface IAccessor extends IChildRootProperty {
  82757. /**
  82758. * The index of the bufferview
  82759. */
  82760. bufferView?: number;
  82761. /**
  82762. * The offset relative to the start of the bufferView in bytes
  82763. */
  82764. byteOffset?: number;
  82765. /**
  82766. * The datatype of components in the attribute
  82767. */
  82768. componentType: AccessorComponentType;
  82769. /**
  82770. * Specifies whether integer data values should be normalized
  82771. */
  82772. normalized?: boolean;
  82773. /**
  82774. * The number of attributes referenced by this accessor
  82775. */
  82776. count: number;
  82777. /**
  82778. * Specifies if the attribute is a scalar, vector, or matrix
  82779. */
  82780. type: AccessorType;
  82781. /**
  82782. * Maximum value of each component in this attribute
  82783. */
  82784. max?: number[];
  82785. /**
  82786. * Minimum value of each component in this attribute
  82787. */
  82788. min?: number[];
  82789. /**
  82790. * Sparse storage of attributes that deviate from their initialization value
  82791. */
  82792. sparse?: IAccessorSparse;
  82793. }
  82794. /**
  82795. * Targets an animation's sampler at a node's property
  82796. */
  82797. interface IAnimationChannel extends IProperty {
  82798. /**
  82799. * The index of a sampler in this animation used to compute the value for the target
  82800. */
  82801. sampler: number;
  82802. /**
  82803. * The index of the node and TRS property to target
  82804. */
  82805. target: IAnimationChannelTarget;
  82806. }
  82807. /**
  82808. * The index of the node and TRS property that an animation channel targets
  82809. */
  82810. interface IAnimationChannelTarget extends IProperty {
  82811. /**
  82812. * The index of the node to target
  82813. */
  82814. node: number;
  82815. /**
  82816. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82817. */
  82818. path: AnimationChannelTargetPath;
  82819. }
  82820. /**
  82821. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82822. */
  82823. interface IAnimationSampler extends IProperty {
  82824. /**
  82825. * The index of an accessor containing keyframe input values, e.g., time
  82826. */
  82827. input: number;
  82828. /**
  82829. * Interpolation algorithm
  82830. */
  82831. interpolation?: AnimationSamplerInterpolation;
  82832. /**
  82833. * The index of an accessor, containing keyframe output values
  82834. */
  82835. output: number;
  82836. }
  82837. /**
  82838. * A keyframe animation
  82839. */
  82840. interface IAnimation extends IChildRootProperty {
  82841. /**
  82842. * An array of channels, each of which targets an animation's sampler at a node's property
  82843. */
  82844. channels: IAnimationChannel[];
  82845. /**
  82846. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82847. */
  82848. samplers: IAnimationSampler[];
  82849. }
  82850. /**
  82851. * Metadata about the glTF asset
  82852. */
  82853. interface IAsset extends IChildRootProperty {
  82854. /**
  82855. * A copyright message suitable for display to credit the content creator
  82856. */
  82857. copyright?: string;
  82858. /**
  82859. * Tool that generated this glTF model. Useful for debugging
  82860. */
  82861. generator?: string;
  82862. /**
  82863. * The glTF version that this asset targets
  82864. */
  82865. version: string;
  82866. /**
  82867. * The minimum glTF version that this asset targets
  82868. */
  82869. minVersion?: string;
  82870. }
  82871. /**
  82872. * A buffer points to binary geometry, animation, or skins
  82873. */
  82874. interface IBuffer extends IChildRootProperty {
  82875. /**
  82876. * 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
  82877. */
  82878. uri?: string;
  82879. /**
  82880. * The length of the buffer in bytes
  82881. */
  82882. byteLength: number;
  82883. }
  82884. /**
  82885. * A view into a buffer generally representing a subset of the buffer
  82886. */
  82887. interface IBufferView extends IChildRootProperty {
  82888. /**
  82889. * The index of the buffer
  82890. */
  82891. buffer: number;
  82892. /**
  82893. * The offset into the buffer in bytes
  82894. */
  82895. byteOffset?: number;
  82896. /**
  82897. * The lenth of the bufferView in bytes
  82898. */
  82899. byteLength: number;
  82900. /**
  82901. * The stride, in bytes
  82902. */
  82903. byteStride?: number;
  82904. }
  82905. /**
  82906. * An orthographic camera containing properties to create an orthographic projection matrix
  82907. */
  82908. interface ICameraOrthographic extends IProperty {
  82909. /**
  82910. * The floating-point horizontal magnification of the view. Must not be zero
  82911. */
  82912. xmag: number;
  82913. /**
  82914. * The floating-point vertical magnification of the view. Must not be zero
  82915. */
  82916. ymag: number;
  82917. /**
  82918. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82919. */
  82920. zfar: number;
  82921. /**
  82922. * The floating-point distance to the near clipping plane
  82923. */
  82924. znear: number;
  82925. }
  82926. /**
  82927. * A perspective camera containing properties to create a perspective projection matrix
  82928. */
  82929. interface ICameraPerspective extends IProperty {
  82930. /**
  82931. * The floating-point aspect ratio of the field of view
  82932. */
  82933. aspectRatio?: number;
  82934. /**
  82935. * The floating-point vertical field of view in radians
  82936. */
  82937. yfov: number;
  82938. /**
  82939. * The floating-point distance to the far clipping plane
  82940. */
  82941. zfar?: number;
  82942. /**
  82943. * The floating-point distance to the near clipping plane
  82944. */
  82945. znear: number;
  82946. }
  82947. /**
  82948. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82949. */
  82950. interface ICamera extends IChildRootProperty {
  82951. /**
  82952. * An orthographic camera containing properties to create an orthographic projection matrix
  82953. */
  82954. orthographic?: ICameraOrthographic;
  82955. /**
  82956. * A perspective camera containing properties to create a perspective projection matrix
  82957. */
  82958. perspective?: ICameraPerspective;
  82959. /**
  82960. * Specifies if the camera uses a perspective or orthographic projection
  82961. */
  82962. type: CameraType;
  82963. }
  82964. /**
  82965. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82966. */
  82967. interface IImage extends IChildRootProperty {
  82968. /**
  82969. * 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
  82970. */
  82971. uri?: string;
  82972. /**
  82973. * The image's MIME type
  82974. */
  82975. mimeType?: ImageMimeType;
  82976. /**
  82977. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82978. */
  82979. bufferView?: number;
  82980. }
  82981. /**
  82982. * Material Normal Texture Info
  82983. */
  82984. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82985. /**
  82986. * The scalar multiplier applied to each normal vector of the normal texture
  82987. */
  82988. scale?: number;
  82989. }
  82990. /**
  82991. * Material Occlusion Texture Info
  82992. */
  82993. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82994. /**
  82995. * A scalar multiplier controlling the amount of occlusion applied
  82996. */
  82997. strength?: number;
  82998. }
  82999. /**
  83000. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83001. */
  83002. interface IMaterialPbrMetallicRoughness {
  83003. /**
  83004. * The material's base color factor
  83005. */
  83006. baseColorFactor?: number[];
  83007. /**
  83008. * The base color texture
  83009. */
  83010. baseColorTexture?: ITextureInfo;
  83011. /**
  83012. * The metalness of the material
  83013. */
  83014. metallicFactor?: number;
  83015. /**
  83016. * The roughness of the material
  83017. */
  83018. roughnessFactor?: number;
  83019. /**
  83020. * The metallic-roughness texture
  83021. */
  83022. metallicRoughnessTexture?: ITextureInfo;
  83023. }
  83024. /**
  83025. * The material appearance of a primitive
  83026. */
  83027. interface IMaterial extends IChildRootProperty {
  83028. /**
  83029. * 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
  83030. */
  83031. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83032. /**
  83033. * The normal map texture
  83034. */
  83035. normalTexture?: IMaterialNormalTextureInfo;
  83036. /**
  83037. * The occlusion map texture
  83038. */
  83039. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83040. /**
  83041. * The emissive map texture
  83042. */
  83043. emissiveTexture?: ITextureInfo;
  83044. /**
  83045. * 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
  83046. */
  83047. emissiveFactor?: number[];
  83048. /**
  83049. * The alpha rendering mode of the material
  83050. */
  83051. alphaMode?: MaterialAlphaMode;
  83052. /**
  83053. * The alpha cutoff value of the material
  83054. */
  83055. alphaCutoff?: number;
  83056. /**
  83057. * Specifies whether the material is double sided
  83058. */
  83059. doubleSided?: boolean;
  83060. }
  83061. /**
  83062. * Geometry to be rendered with the given material
  83063. */
  83064. interface IMeshPrimitive extends IProperty {
  83065. /**
  83066. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83067. */
  83068. attributes: {
  83069. [name: string]: number;
  83070. };
  83071. /**
  83072. * The index of the accessor that contains the indices
  83073. */
  83074. indices?: number;
  83075. /**
  83076. * The index of the material to apply to this primitive when rendering
  83077. */
  83078. material?: number;
  83079. /**
  83080. * The type of primitives to render. All valid values correspond to WebGL enums
  83081. */
  83082. mode?: MeshPrimitiveMode;
  83083. /**
  83084. * 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
  83085. */
  83086. targets?: {
  83087. [name: string]: number;
  83088. }[];
  83089. }
  83090. /**
  83091. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83092. */
  83093. interface IMesh extends IChildRootProperty {
  83094. /**
  83095. * An array of primitives, each defining geometry to be rendered with a material
  83096. */
  83097. primitives: IMeshPrimitive[];
  83098. /**
  83099. * Array of weights to be applied to the Morph Targets
  83100. */
  83101. weights?: number[];
  83102. }
  83103. /**
  83104. * A node in the node hierarchy
  83105. */
  83106. interface INode extends IChildRootProperty {
  83107. /**
  83108. * The index of the camera referenced by this node
  83109. */
  83110. camera?: number;
  83111. /**
  83112. * The indices of this node's children
  83113. */
  83114. children?: number[];
  83115. /**
  83116. * The index of the skin referenced by this node
  83117. */
  83118. skin?: number;
  83119. /**
  83120. * A floating-point 4x4 transformation matrix stored in column-major order
  83121. */
  83122. matrix?: number[];
  83123. /**
  83124. * The index of the mesh in this node
  83125. */
  83126. mesh?: number;
  83127. /**
  83128. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83129. */
  83130. rotation?: number[];
  83131. /**
  83132. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83133. */
  83134. scale?: number[];
  83135. /**
  83136. * The node's translation along the x, y, and z axes
  83137. */
  83138. translation?: number[];
  83139. /**
  83140. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83141. */
  83142. weights?: number[];
  83143. }
  83144. /**
  83145. * Texture sampler properties for filtering and wrapping modes
  83146. */
  83147. interface ISampler extends IChildRootProperty {
  83148. /**
  83149. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83150. */
  83151. magFilter?: TextureMagFilter;
  83152. /**
  83153. * Minification filter. All valid values correspond to WebGL enums
  83154. */
  83155. minFilter?: TextureMinFilter;
  83156. /**
  83157. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83158. */
  83159. wrapS?: TextureWrapMode;
  83160. /**
  83161. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83162. */
  83163. wrapT?: TextureWrapMode;
  83164. }
  83165. /**
  83166. * The root nodes of a scene
  83167. */
  83168. interface IScene extends IChildRootProperty {
  83169. /**
  83170. * The indices of each root node
  83171. */
  83172. nodes: number[];
  83173. }
  83174. /**
  83175. * Joints and matrices defining a skin
  83176. */
  83177. interface ISkin extends IChildRootProperty {
  83178. /**
  83179. * 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
  83180. */
  83181. inverseBindMatrices?: number;
  83182. /**
  83183. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83184. */
  83185. skeleton?: number;
  83186. /**
  83187. * 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)
  83188. */
  83189. joints: number[];
  83190. }
  83191. /**
  83192. * A texture and its sampler
  83193. */
  83194. interface ITexture extends IChildRootProperty {
  83195. /**
  83196. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83197. */
  83198. sampler?: number;
  83199. /**
  83200. * The index of the image used by this texture
  83201. */
  83202. source: number;
  83203. }
  83204. /**
  83205. * Reference to a texture
  83206. */
  83207. interface ITextureInfo extends IProperty {
  83208. /**
  83209. * The index of the texture
  83210. */
  83211. index: number;
  83212. /**
  83213. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83214. */
  83215. texCoord?: number;
  83216. }
  83217. /**
  83218. * The root object for a glTF asset
  83219. */
  83220. interface IGLTF extends IProperty {
  83221. /**
  83222. * An array of accessors. An accessor is a typed view into a bufferView
  83223. */
  83224. accessors?: IAccessor[];
  83225. /**
  83226. * An array of keyframe animations
  83227. */
  83228. animations?: IAnimation[];
  83229. /**
  83230. * Metadata about the glTF asset
  83231. */
  83232. asset: IAsset;
  83233. /**
  83234. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83235. */
  83236. buffers?: IBuffer[];
  83237. /**
  83238. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83239. */
  83240. bufferViews?: IBufferView[];
  83241. /**
  83242. * An array of cameras
  83243. */
  83244. cameras?: ICamera[];
  83245. /**
  83246. * Names of glTF extensions used somewhere in this asset
  83247. */
  83248. extensionsUsed?: string[];
  83249. /**
  83250. * Names of glTF extensions required to properly load this asset
  83251. */
  83252. extensionsRequired?: string[];
  83253. /**
  83254. * An array of images. An image defines data used to create a texture
  83255. */
  83256. images?: IImage[];
  83257. /**
  83258. * An array of materials. A material defines the appearance of a primitive
  83259. */
  83260. materials?: IMaterial[];
  83261. /**
  83262. * An array of meshes. A mesh is a set of primitives to be rendered
  83263. */
  83264. meshes?: IMesh[];
  83265. /**
  83266. * An array of nodes
  83267. */
  83268. nodes?: INode[];
  83269. /**
  83270. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83271. */
  83272. samplers?: ISampler[];
  83273. /**
  83274. * The index of the default scene
  83275. */
  83276. scene?: number;
  83277. /**
  83278. * An array of scenes
  83279. */
  83280. scenes?: IScene[];
  83281. /**
  83282. * An array of skins. A skin is defined by joints and matrices
  83283. */
  83284. skins?: ISkin[];
  83285. /**
  83286. * An array of textures
  83287. */
  83288. textures?: ITexture[];
  83289. }
  83290. /**
  83291. * The glTF validation results
  83292. * @ignore
  83293. */
  83294. interface IGLTFValidationResults {
  83295. info: {
  83296. generator: string;
  83297. hasAnimations: boolean;
  83298. hasDefaultScene: boolean;
  83299. hasMaterials: boolean;
  83300. hasMorphTargets: boolean;
  83301. hasSkins: boolean;
  83302. hasTextures: boolean;
  83303. maxAttributesUsed: number;
  83304. primitivesCount: number
  83305. };
  83306. issues: {
  83307. messages: Array<string>;
  83308. numErrors: number;
  83309. numHints: number;
  83310. numInfos: number;
  83311. numWarnings: number;
  83312. truncated: boolean
  83313. };
  83314. mimeType: string;
  83315. uri: string;
  83316. validatedAt: string;
  83317. validatorVersion: string;
  83318. }
  83319. /**
  83320. * The glTF validation options
  83321. */
  83322. interface IGLTFValidationOptions {
  83323. /** Uri to use */
  83324. uri?: string;
  83325. /** Function used to load external resources */
  83326. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83327. /** Boolean indicating that we need to validate accessor data */
  83328. validateAccessorData?: boolean;
  83329. /** max number of issues allowed */
  83330. maxIssues?: number;
  83331. /** Ignored issues */
  83332. ignoredIssues?: Array<string>;
  83333. /** Value to override severy settings */
  83334. severityOverrides?: Object;
  83335. }
  83336. /**
  83337. * The glTF validator object
  83338. * @ignore
  83339. */
  83340. interface IGLTFValidator {
  83341. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83342. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83343. }
  83344. }
  83345. declare module BABYLON {
  83346. /** @hidden */
  83347. export var cellPixelShader: {
  83348. name: string;
  83349. shader: string;
  83350. };
  83351. }
  83352. declare module BABYLON {
  83353. /** @hidden */
  83354. export var cellVertexShader: {
  83355. name: string;
  83356. shader: string;
  83357. };
  83358. }
  83359. declare module BABYLON {
  83360. export class CellMaterial extends BABYLON.PushMaterial {
  83361. private _diffuseTexture;
  83362. diffuseTexture: BABYLON.BaseTexture;
  83363. diffuseColor: BABYLON.Color3;
  83364. _computeHighLevel: boolean;
  83365. computeHighLevel: boolean;
  83366. private _disableLighting;
  83367. disableLighting: boolean;
  83368. private _maxSimultaneousLights;
  83369. maxSimultaneousLights: number;
  83370. constructor(name: string, scene: BABYLON.Scene);
  83371. needAlphaBlending(): boolean;
  83372. needAlphaTesting(): boolean;
  83373. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83374. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83375. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83376. getAnimatables(): BABYLON.IAnimatable[];
  83377. getActiveTextures(): BABYLON.BaseTexture[];
  83378. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83379. dispose(forceDisposeEffect?: boolean): void;
  83380. getClassName(): string;
  83381. clone(name: string): CellMaterial;
  83382. serialize(): any;
  83383. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83384. }
  83385. }
  83386. declare module BABYLON {
  83387. export class CustomShaderStructure {
  83388. FragmentStore: string;
  83389. VertexStore: string;
  83390. constructor();
  83391. }
  83392. export class ShaderSpecialParts {
  83393. constructor();
  83394. Fragment_Begin: string;
  83395. Fragment_Definitions: string;
  83396. Fragment_MainBegin: string;
  83397. Fragment_Custom_Diffuse: string;
  83398. Fragment_Before_Lights: string;
  83399. Fragment_Before_Fog: string;
  83400. Fragment_Custom_Alpha: string;
  83401. Fragment_Before_FragColor: string;
  83402. Vertex_Begin: string;
  83403. Vertex_Definitions: string;
  83404. Vertex_MainBegin: string;
  83405. Vertex_Before_PositionUpdated: string;
  83406. Vertex_Before_NormalUpdated: string;
  83407. Vertex_After_WorldPosComputed: string;
  83408. Vertex_MainEnd: string;
  83409. }
  83410. export class CustomMaterial extends BABYLON.StandardMaterial {
  83411. static ShaderIndexer: number;
  83412. CustomParts: ShaderSpecialParts;
  83413. _isCreatedShader: boolean;
  83414. _createdShaderName: string;
  83415. _customUniform: string[];
  83416. _newUniforms: string[];
  83417. _newUniformInstances: {
  83418. [name: string]: any;
  83419. };
  83420. _newSamplerInstances: {
  83421. [name: string]: BABYLON.Texture;
  83422. };
  83423. _customAttributes: string[];
  83424. FragmentShader: string;
  83425. VertexShader: string;
  83426. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83427. ReviewUniform(name: string, arr: string[]): string[];
  83428. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83429. constructor(name: string, scene: BABYLON.Scene);
  83430. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  83431. AddAttribute(name: string): CustomMaterial;
  83432. Fragment_Begin(shaderPart: string): CustomMaterial;
  83433. Fragment_Definitions(shaderPart: string): CustomMaterial;
  83434. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  83435. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  83436. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  83437. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  83438. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  83439. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  83440. Vertex_Begin(shaderPart: string): CustomMaterial;
  83441. Vertex_Definitions(shaderPart: string): CustomMaterial;
  83442. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  83443. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  83444. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  83445. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  83446. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  83447. }
  83448. }
  83449. declare module BABYLON {
  83450. export class ShaderAlebdoParts {
  83451. constructor();
  83452. Fragment_Begin: string;
  83453. Fragment_Definitions: string;
  83454. Fragment_MainBegin: string;
  83455. Fragment_Custom_Albedo: string;
  83456. Fragment_Before_Lights: string;
  83457. Fragment_Custom_MetallicRoughness: string;
  83458. Fragment_Custom_MicroSurface: string;
  83459. Fragment_Before_Fog: string;
  83460. Fragment_Custom_Alpha: string;
  83461. Fragment_Before_FragColor: string;
  83462. Vertex_Begin: string;
  83463. Vertex_Definitions: string;
  83464. Vertex_MainBegin: string;
  83465. Vertex_Before_PositionUpdated: string;
  83466. Vertex_Before_NormalUpdated: string;
  83467. Vertex_After_WorldPosComputed: string;
  83468. Vertex_MainEnd: string;
  83469. }
  83470. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83471. static ShaderIndexer: number;
  83472. CustomParts: ShaderAlebdoParts;
  83473. _isCreatedShader: boolean;
  83474. _createdShaderName: string;
  83475. _customUniform: string[];
  83476. _newUniforms: string[];
  83477. _newUniformInstances: {
  83478. [name: string]: any;
  83479. };
  83480. _newSamplerInstances: {
  83481. [name: string]: BABYLON.Texture;
  83482. };
  83483. _customAttributes: string[];
  83484. FragmentShader: string;
  83485. VertexShader: string;
  83486. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83487. ReviewUniform(name: string, arr: string[]): string[];
  83488. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83489. constructor(name: string, scene: BABYLON.Scene);
  83490. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83491. AddAttribute(name: string): PBRCustomMaterial;
  83492. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83493. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83494. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83495. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83496. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83497. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83498. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83499. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83500. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83501. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83502. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83503. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83504. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83505. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83506. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83507. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83508. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83509. }
  83510. }
  83511. declare module BABYLON {
  83512. /** @hidden */
  83513. export var firePixelShader: {
  83514. name: string;
  83515. shader: string;
  83516. };
  83517. }
  83518. declare module BABYLON {
  83519. /** @hidden */
  83520. export var fireVertexShader: {
  83521. name: string;
  83522. shader: string;
  83523. };
  83524. }
  83525. declare module BABYLON {
  83526. export class FireMaterial extends BABYLON.PushMaterial {
  83527. private _diffuseTexture;
  83528. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83529. private _distortionTexture;
  83530. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83531. private _opacityTexture;
  83532. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83533. diffuseColor: BABYLON.Color3;
  83534. speed: number;
  83535. private _scaledDiffuse;
  83536. private _lastTime;
  83537. constructor(name: string, scene: BABYLON.Scene);
  83538. needAlphaBlending(): boolean;
  83539. needAlphaTesting(): boolean;
  83540. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83541. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83542. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83543. getAnimatables(): BABYLON.IAnimatable[];
  83544. getActiveTextures(): BABYLON.BaseTexture[];
  83545. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83546. getClassName(): string;
  83547. dispose(forceDisposeEffect?: boolean): void;
  83548. clone(name: string): FireMaterial;
  83549. serialize(): any;
  83550. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83551. }
  83552. }
  83553. declare module BABYLON {
  83554. /** @hidden */
  83555. export var furPixelShader: {
  83556. name: string;
  83557. shader: string;
  83558. };
  83559. }
  83560. declare module BABYLON {
  83561. /** @hidden */
  83562. export var furVertexShader: {
  83563. name: string;
  83564. shader: string;
  83565. };
  83566. }
  83567. declare module BABYLON {
  83568. export class FurMaterial extends BABYLON.PushMaterial {
  83569. private _diffuseTexture;
  83570. diffuseTexture: BABYLON.BaseTexture;
  83571. private _heightTexture;
  83572. heightTexture: BABYLON.BaseTexture;
  83573. diffuseColor: BABYLON.Color3;
  83574. furLength: number;
  83575. furAngle: number;
  83576. furColor: BABYLON.Color3;
  83577. furOffset: number;
  83578. furSpacing: number;
  83579. furGravity: BABYLON.Vector3;
  83580. furSpeed: number;
  83581. furDensity: number;
  83582. furOcclusion: number;
  83583. furTexture: BABYLON.DynamicTexture;
  83584. private _disableLighting;
  83585. disableLighting: boolean;
  83586. private _maxSimultaneousLights;
  83587. maxSimultaneousLights: number;
  83588. highLevelFur: boolean;
  83589. _meshes: BABYLON.AbstractMesh[];
  83590. private _furTime;
  83591. constructor(name: string, scene: BABYLON.Scene);
  83592. get furTime(): number;
  83593. set furTime(furTime: number);
  83594. needAlphaBlending(): boolean;
  83595. needAlphaTesting(): boolean;
  83596. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83597. updateFur(): void;
  83598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83599. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83600. getAnimatables(): BABYLON.IAnimatable[];
  83601. getActiveTextures(): BABYLON.BaseTexture[];
  83602. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83603. dispose(forceDisposeEffect?: boolean): void;
  83604. clone(name: string): FurMaterial;
  83605. serialize(): any;
  83606. getClassName(): string;
  83607. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83608. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83609. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83610. }
  83611. }
  83612. declare module BABYLON {
  83613. /** @hidden */
  83614. export var gradientPixelShader: {
  83615. name: string;
  83616. shader: string;
  83617. };
  83618. }
  83619. declare module BABYLON {
  83620. /** @hidden */
  83621. export var gradientVertexShader: {
  83622. name: string;
  83623. shader: string;
  83624. };
  83625. }
  83626. declare module BABYLON {
  83627. export class GradientMaterial extends BABYLON.PushMaterial {
  83628. private _maxSimultaneousLights;
  83629. maxSimultaneousLights: number;
  83630. topColor: BABYLON.Color3;
  83631. topColorAlpha: number;
  83632. bottomColor: BABYLON.Color3;
  83633. bottomColorAlpha: number;
  83634. offset: number;
  83635. scale: number;
  83636. smoothness: number;
  83637. private _disableLighting;
  83638. disableLighting: boolean;
  83639. constructor(name: string, scene: BABYLON.Scene);
  83640. needAlphaBlending(): boolean;
  83641. needAlphaTesting(): boolean;
  83642. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83643. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83644. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83645. getAnimatables(): BABYLON.IAnimatable[];
  83646. dispose(forceDisposeEffect?: boolean): void;
  83647. clone(name: string): GradientMaterial;
  83648. serialize(): any;
  83649. getClassName(): string;
  83650. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83651. }
  83652. }
  83653. declare module BABYLON {
  83654. /** @hidden */
  83655. export var gridPixelShader: {
  83656. name: string;
  83657. shader: string;
  83658. };
  83659. }
  83660. declare module BABYLON {
  83661. /** @hidden */
  83662. export var gridVertexShader: {
  83663. name: string;
  83664. shader: string;
  83665. };
  83666. }
  83667. declare module BABYLON {
  83668. /**
  83669. * The grid materials allows you to wrap any shape with a grid.
  83670. * Colors are customizable.
  83671. */
  83672. export class GridMaterial extends BABYLON.PushMaterial {
  83673. /**
  83674. * Main color of the grid (e.g. between lines)
  83675. */
  83676. mainColor: BABYLON.Color3;
  83677. /**
  83678. * Color of the grid lines.
  83679. */
  83680. lineColor: BABYLON.Color3;
  83681. /**
  83682. * The scale of the grid compared to unit.
  83683. */
  83684. gridRatio: number;
  83685. /**
  83686. * Allows setting an offset for the grid lines.
  83687. */
  83688. gridOffset: BABYLON.Vector3;
  83689. /**
  83690. * The frequency of thicker lines.
  83691. */
  83692. majorUnitFrequency: number;
  83693. /**
  83694. * The visibility of minor units in the grid.
  83695. */
  83696. minorUnitVisibility: number;
  83697. /**
  83698. * The grid opacity outside of the lines.
  83699. */
  83700. opacity: number;
  83701. /**
  83702. * Determine RBG output is premultiplied by alpha value.
  83703. */
  83704. preMultiplyAlpha: boolean;
  83705. private _opacityTexture;
  83706. opacityTexture: BABYLON.BaseTexture;
  83707. private _gridControl;
  83708. /**
  83709. * constructor
  83710. * @param name The name given to the material in order to identify it afterwards.
  83711. * @param scene The scene the material is used in.
  83712. */
  83713. constructor(name: string, scene: BABYLON.Scene);
  83714. /**
  83715. * Returns wehter or not the grid requires alpha blending.
  83716. */
  83717. needAlphaBlending(): boolean;
  83718. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83721. /**
  83722. * Dispose the material and its associated resources.
  83723. * @param forceDisposeEffect will also dispose the used effect when true
  83724. */
  83725. dispose(forceDisposeEffect?: boolean): void;
  83726. clone(name: string): GridMaterial;
  83727. serialize(): any;
  83728. getClassName(): string;
  83729. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83730. }
  83731. }
  83732. declare module BABYLON {
  83733. /** @hidden */
  83734. export var lavaPixelShader: {
  83735. name: string;
  83736. shader: string;
  83737. };
  83738. }
  83739. declare module BABYLON {
  83740. /** @hidden */
  83741. export var lavaVertexShader: {
  83742. name: string;
  83743. shader: string;
  83744. };
  83745. }
  83746. declare module BABYLON {
  83747. export class LavaMaterial extends BABYLON.PushMaterial {
  83748. private _diffuseTexture;
  83749. diffuseTexture: BABYLON.BaseTexture;
  83750. noiseTexture: BABYLON.BaseTexture;
  83751. fogColor: BABYLON.Color3;
  83752. speed: number;
  83753. movingSpeed: number;
  83754. lowFrequencySpeed: number;
  83755. fogDensity: number;
  83756. private _lastTime;
  83757. diffuseColor: BABYLON.Color3;
  83758. private _disableLighting;
  83759. disableLighting: boolean;
  83760. private _unlit;
  83761. unlit: boolean;
  83762. private _maxSimultaneousLights;
  83763. maxSimultaneousLights: number;
  83764. private _scaledDiffuse;
  83765. constructor(name: string, scene: BABYLON.Scene);
  83766. needAlphaBlending(): boolean;
  83767. needAlphaTesting(): boolean;
  83768. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83769. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83770. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83771. getAnimatables(): BABYLON.IAnimatable[];
  83772. getActiveTextures(): BABYLON.BaseTexture[];
  83773. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83774. dispose(forceDisposeEffect?: boolean): void;
  83775. clone(name: string): LavaMaterial;
  83776. serialize(): any;
  83777. getClassName(): string;
  83778. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83779. }
  83780. }
  83781. declare module BABYLON {
  83782. /** @hidden */
  83783. export var mixPixelShader: {
  83784. name: string;
  83785. shader: string;
  83786. };
  83787. }
  83788. declare module BABYLON {
  83789. /** @hidden */
  83790. export var mixVertexShader: {
  83791. name: string;
  83792. shader: string;
  83793. };
  83794. }
  83795. declare module BABYLON {
  83796. export class MixMaterial extends BABYLON.PushMaterial {
  83797. /**
  83798. * Mix textures
  83799. */
  83800. private _mixTexture1;
  83801. mixTexture1: BABYLON.BaseTexture;
  83802. private _mixTexture2;
  83803. mixTexture2: BABYLON.BaseTexture;
  83804. /**
  83805. * Diffuse textures
  83806. */
  83807. private _diffuseTexture1;
  83808. diffuseTexture1: BABYLON.Texture;
  83809. private _diffuseTexture2;
  83810. diffuseTexture2: BABYLON.Texture;
  83811. private _diffuseTexture3;
  83812. diffuseTexture3: BABYLON.Texture;
  83813. private _diffuseTexture4;
  83814. diffuseTexture4: BABYLON.Texture;
  83815. private _diffuseTexture5;
  83816. diffuseTexture5: BABYLON.Texture;
  83817. private _diffuseTexture6;
  83818. diffuseTexture6: BABYLON.Texture;
  83819. private _diffuseTexture7;
  83820. diffuseTexture7: BABYLON.Texture;
  83821. private _diffuseTexture8;
  83822. diffuseTexture8: BABYLON.Texture;
  83823. /**
  83824. * Uniforms
  83825. */
  83826. diffuseColor: BABYLON.Color3;
  83827. specularColor: BABYLON.Color3;
  83828. specularPower: number;
  83829. private _disableLighting;
  83830. disableLighting: boolean;
  83831. private _maxSimultaneousLights;
  83832. maxSimultaneousLights: number;
  83833. constructor(name: string, scene: BABYLON.Scene);
  83834. needAlphaBlending(): boolean;
  83835. needAlphaTesting(): boolean;
  83836. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83837. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83838. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83839. getAnimatables(): BABYLON.IAnimatable[];
  83840. getActiveTextures(): BABYLON.BaseTexture[];
  83841. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83842. dispose(forceDisposeEffect?: boolean): void;
  83843. clone(name: string): MixMaterial;
  83844. serialize(): any;
  83845. getClassName(): string;
  83846. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83847. }
  83848. }
  83849. declare module BABYLON {
  83850. /** @hidden */
  83851. export var normalPixelShader: {
  83852. name: string;
  83853. shader: string;
  83854. };
  83855. }
  83856. declare module BABYLON {
  83857. /** @hidden */
  83858. export var normalVertexShader: {
  83859. name: string;
  83860. shader: string;
  83861. };
  83862. }
  83863. declare module BABYLON {
  83864. export class NormalMaterial extends BABYLON.PushMaterial {
  83865. private _diffuseTexture;
  83866. diffuseTexture: BABYLON.BaseTexture;
  83867. diffuseColor: BABYLON.Color3;
  83868. private _disableLighting;
  83869. disableLighting: boolean;
  83870. private _maxSimultaneousLights;
  83871. maxSimultaneousLights: number;
  83872. constructor(name: string, scene: BABYLON.Scene);
  83873. needAlphaBlending(): boolean;
  83874. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83875. needAlphaTesting(): boolean;
  83876. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83877. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83878. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83879. getAnimatables(): BABYLON.IAnimatable[];
  83880. getActiveTextures(): BABYLON.BaseTexture[];
  83881. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83882. dispose(forceDisposeEffect?: boolean): void;
  83883. clone(name: string): NormalMaterial;
  83884. serialize(): any;
  83885. getClassName(): string;
  83886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83887. }
  83888. }
  83889. declare module BABYLON {
  83890. /** @hidden */
  83891. export var shadowOnlyPixelShader: {
  83892. name: string;
  83893. shader: string;
  83894. };
  83895. }
  83896. declare module BABYLON {
  83897. /** @hidden */
  83898. export var shadowOnlyVertexShader: {
  83899. name: string;
  83900. shader: string;
  83901. };
  83902. }
  83903. declare module BABYLON {
  83904. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83905. private _activeLight;
  83906. private _needAlphaBlending;
  83907. constructor(name: string, scene: BABYLON.Scene);
  83908. shadowColor: BABYLON.Color3;
  83909. needAlphaBlending(): boolean;
  83910. needAlphaTesting(): boolean;
  83911. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83912. get activeLight(): BABYLON.IShadowLight;
  83913. set activeLight(light: BABYLON.IShadowLight);
  83914. private _getFirstShadowLightForMesh;
  83915. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83916. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83917. clone(name: string): ShadowOnlyMaterial;
  83918. serialize(): any;
  83919. getClassName(): string;
  83920. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83921. }
  83922. }
  83923. declare module BABYLON {
  83924. /** @hidden */
  83925. export var simplePixelShader: {
  83926. name: string;
  83927. shader: string;
  83928. };
  83929. }
  83930. declare module BABYLON {
  83931. /** @hidden */
  83932. export var simpleVertexShader: {
  83933. name: string;
  83934. shader: string;
  83935. };
  83936. }
  83937. declare module BABYLON {
  83938. export class SimpleMaterial extends BABYLON.PushMaterial {
  83939. private _diffuseTexture;
  83940. diffuseTexture: BABYLON.BaseTexture;
  83941. diffuseColor: BABYLON.Color3;
  83942. private _disableLighting;
  83943. disableLighting: boolean;
  83944. private _maxSimultaneousLights;
  83945. maxSimultaneousLights: number;
  83946. constructor(name: string, scene: BABYLON.Scene);
  83947. needAlphaBlending(): boolean;
  83948. needAlphaTesting(): boolean;
  83949. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83950. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83951. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83952. getAnimatables(): BABYLON.IAnimatable[];
  83953. getActiveTextures(): BABYLON.BaseTexture[];
  83954. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83955. dispose(forceDisposeEffect?: boolean): void;
  83956. clone(name: string): SimpleMaterial;
  83957. serialize(): any;
  83958. getClassName(): string;
  83959. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83960. }
  83961. }
  83962. declare module BABYLON {
  83963. /** @hidden */
  83964. export var skyPixelShader: {
  83965. name: string;
  83966. shader: string;
  83967. };
  83968. }
  83969. declare module BABYLON {
  83970. /** @hidden */
  83971. export var skyVertexShader: {
  83972. name: string;
  83973. shader: string;
  83974. };
  83975. }
  83976. declare module BABYLON {
  83977. /**
  83978. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83979. * @see https://doc.babylonjs.com/extensions/sky
  83980. */
  83981. export class SkyMaterial extends BABYLON.PushMaterial {
  83982. /**
  83983. * Defines the overall luminance of sky in interval ]0, 1[.
  83984. */
  83985. luminance: number;
  83986. /**
  83987. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83988. */
  83989. turbidity: number;
  83990. /**
  83991. * Defines the sky appearance (light intensity).
  83992. */
  83993. rayleigh: number;
  83994. /**
  83995. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83996. */
  83997. mieCoefficient: number;
  83998. /**
  83999. * Defines the amount of haze particles following the Mie scattering theory.
  84000. */
  84001. mieDirectionalG: number;
  84002. /**
  84003. * Defines the distance of the sun according to the active scene camera.
  84004. */
  84005. distance: number;
  84006. /**
  84007. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84008. * "inclined".
  84009. */
  84010. inclination: number;
  84011. /**
  84012. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84013. * an object direction and a reference direction.
  84014. */
  84015. azimuth: number;
  84016. /**
  84017. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84018. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84019. */
  84020. sunPosition: BABYLON.Vector3;
  84021. /**
  84022. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84023. * .sunPosition property.
  84024. */
  84025. useSunPosition: boolean;
  84026. /**
  84027. * Defines an offset vector used to get a horizon offset.
  84028. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84029. */
  84030. cameraOffset: BABYLON.Vector3;
  84031. private _cameraPosition;
  84032. /**
  84033. * Instantiates a new sky material.
  84034. * This material allows to create dynamic and texture free
  84035. * effects for skyboxes by taking care of the atmosphere state.
  84036. * @see https://doc.babylonjs.com/extensions/sky
  84037. * @param name Define the name of the material in the scene
  84038. * @param scene Define the scene the material belong to
  84039. */
  84040. constructor(name: string, scene: BABYLON.Scene);
  84041. /**
  84042. * Specifies if the material will require alpha blending
  84043. * @returns a boolean specifying if alpha blending is needed
  84044. */
  84045. needAlphaBlending(): boolean;
  84046. /**
  84047. * Specifies if this material should be rendered in alpha test mode
  84048. * @returns false as the sky material doesn't need alpha testing.
  84049. */
  84050. needAlphaTesting(): boolean;
  84051. /**
  84052. * Get the texture used for alpha test purpose.
  84053. * @returns null as the sky material has no texture.
  84054. */
  84055. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84056. /**
  84057. * Get if the submesh is ready to be used and all its information available.
  84058. * Child classes can use it to update shaders
  84059. * @param mesh defines the mesh to check
  84060. * @param subMesh defines which submesh to check
  84061. * @param useInstances specifies that instances should be used
  84062. * @returns a boolean indicating that the submesh is ready or not
  84063. */
  84064. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84065. /**
  84066. * Binds the submesh to this material by preparing the effect and shader to draw
  84067. * @param world defines the world transformation matrix
  84068. * @param mesh defines the mesh containing the submesh
  84069. * @param subMesh defines the submesh to bind the material to
  84070. */
  84071. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84072. /**
  84073. * Get the list of animatables in the material.
  84074. * @returns the list of animatables object used in the material
  84075. */
  84076. getAnimatables(): BABYLON.IAnimatable[];
  84077. /**
  84078. * Disposes the material
  84079. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84080. */
  84081. dispose(forceDisposeEffect?: boolean): void;
  84082. /**
  84083. * Makes a duplicate of the material, and gives it a new name
  84084. * @param name defines the new name for the duplicated material
  84085. * @returns the cloned material
  84086. */
  84087. clone(name: string): SkyMaterial;
  84088. /**
  84089. * Serializes this material in a JSON representation
  84090. * @returns the serialized material object
  84091. */
  84092. serialize(): any;
  84093. /**
  84094. * Gets the current class name of the material e.g. "SkyMaterial"
  84095. * Mainly use in serialization.
  84096. * @returns the class name
  84097. */
  84098. getClassName(): string;
  84099. /**
  84100. * Creates a sky material from parsed material data
  84101. * @param source defines the JSON representation of the material
  84102. * @param scene defines the hosting scene
  84103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84104. * @returns a new sky material
  84105. */
  84106. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84107. }
  84108. }
  84109. declare module BABYLON {
  84110. /** @hidden */
  84111. export var terrainPixelShader: {
  84112. name: string;
  84113. shader: string;
  84114. };
  84115. }
  84116. declare module BABYLON {
  84117. /** @hidden */
  84118. export var terrainVertexShader: {
  84119. name: string;
  84120. shader: string;
  84121. };
  84122. }
  84123. declare module BABYLON {
  84124. export class TerrainMaterial extends BABYLON.PushMaterial {
  84125. private _mixTexture;
  84126. mixTexture: BABYLON.BaseTexture;
  84127. private _diffuseTexture1;
  84128. diffuseTexture1: BABYLON.Texture;
  84129. private _diffuseTexture2;
  84130. diffuseTexture2: BABYLON.Texture;
  84131. private _diffuseTexture3;
  84132. diffuseTexture3: BABYLON.Texture;
  84133. private _bumpTexture1;
  84134. bumpTexture1: BABYLON.Texture;
  84135. private _bumpTexture2;
  84136. bumpTexture2: BABYLON.Texture;
  84137. private _bumpTexture3;
  84138. bumpTexture3: BABYLON.Texture;
  84139. diffuseColor: BABYLON.Color3;
  84140. specularColor: BABYLON.Color3;
  84141. specularPower: number;
  84142. private _disableLighting;
  84143. disableLighting: boolean;
  84144. private _maxSimultaneousLights;
  84145. maxSimultaneousLights: number;
  84146. constructor(name: string, scene: BABYLON.Scene);
  84147. needAlphaBlending(): boolean;
  84148. needAlphaTesting(): boolean;
  84149. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84150. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84152. getAnimatables(): BABYLON.IAnimatable[];
  84153. getActiveTextures(): BABYLON.BaseTexture[];
  84154. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84155. dispose(forceDisposeEffect?: boolean): void;
  84156. clone(name: string): TerrainMaterial;
  84157. serialize(): any;
  84158. getClassName(): string;
  84159. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84160. }
  84161. }
  84162. declare module BABYLON {
  84163. /** @hidden */
  84164. export var triplanarPixelShader: {
  84165. name: string;
  84166. shader: string;
  84167. };
  84168. }
  84169. declare module BABYLON {
  84170. /** @hidden */
  84171. export var triplanarVertexShader: {
  84172. name: string;
  84173. shader: string;
  84174. };
  84175. }
  84176. declare module BABYLON {
  84177. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84178. mixTexture: BABYLON.BaseTexture;
  84179. private _diffuseTextureX;
  84180. diffuseTextureX: BABYLON.BaseTexture;
  84181. private _diffuseTextureY;
  84182. diffuseTextureY: BABYLON.BaseTexture;
  84183. private _diffuseTextureZ;
  84184. diffuseTextureZ: BABYLON.BaseTexture;
  84185. private _normalTextureX;
  84186. normalTextureX: BABYLON.BaseTexture;
  84187. private _normalTextureY;
  84188. normalTextureY: BABYLON.BaseTexture;
  84189. private _normalTextureZ;
  84190. normalTextureZ: BABYLON.BaseTexture;
  84191. tileSize: number;
  84192. diffuseColor: BABYLON.Color3;
  84193. specularColor: BABYLON.Color3;
  84194. specularPower: number;
  84195. private _disableLighting;
  84196. disableLighting: boolean;
  84197. private _maxSimultaneousLights;
  84198. maxSimultaneousLights: number;
  84199. constructor(name: string, scene: BABYLON.Scene);
  84200. needAlphaBlending(): boolean;
  84201. needAlphaTesting(): boolean;
  84202. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84203. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84204. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84205. getAnimatables(): BABYLON.IAnimatable[];
  84206. getActiveTextures(): BABYLON.BaseTexture[];
  84207. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84208. dispose(forceDisposeEffect?: boolean): void;
  84209. clone(name: string): TriPlanarMaterial;
  84210. serialize(): any;
  84211. getClassName(): string;
  84212. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84213. }
  84214. }
  84215. declare module BABYLON {
  84216. /** @hidden */
  84217. export var waterPixelShader: {
  84218. name: string;
  84219. shader: string;
  84220. };
  84221. }
  84222. declare module BABYLON {
  84223. /** @hidden */
  84224. export var waterVertexShader: {
  84225. name: string;
  84226. shader: string;
  84227. };
  84228. }
  84229. declare module BABYLON {
  84230. export class WaterMaterial extends BABYLON.PushMaterial {
  84231. renderTargetSize: BABYLON.Vector2;
  84232. private _bumpTexture;
  84233. bumpTexture: BABYLON.BaseTexture;
  84234. diffuseColor: BABYLON.Color3;
  84235. specularColor: BABYLON.Color3;
  84236. specularPower: number;
  84237. private _disableLighting;
  84238. disableLighting: boolean;
  84239. private _maxSimultaneousLights;
  84240. maxSimultaneousLights: number;
  84241. /**
  84242. * @param {number}: Represents the wind force
  84243. */
  84244. windForce: number;
  84245. /**
  84246. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84247. */
  84248. windDirection: BABYLON.Vector2;
  84249. /**
  84250. * @param {number}: Wave height, represents the height of the waves
  84251. */
  84252. waveHeight: number;
  84253. /**
  84254. * @param {number}: Bump height, represents the bump height related to the bump map
  84255. */
  84256. bumpHeight: number;
  84257. /**
  84258. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84259. */
  84260. private _bumpSuperimpose;
  84261. bumpSuperimpose: boolean;
  84262. /**
  84263. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84264. */
  84265. private _fresnelSeparate;
  84266. fresnelSeparate: boolean;
  84267. /**
  84268. * @param {boolean}: bump Waves modify the reflection.
  84269. */
  84270. private _bumpAffectsReflection;
  84271. bumpAffectsReflection: boolean;
  84272. /**
  84273. * @param {number}: The water color blended with the refraction (near)
  84274. */
  84275. waterColor: BABYLON.Color3;
  84276. /**
  84277. * @param {number}: The blend factor related to the water color
  84278. */
  84279. colorBlendFactor: number;
  84280. /**
  84281. * @param {number}: The water color blended with the reflection (far)
  84282. */
  84283. waterColor2: BABYLON.Color3;
  84284. /**
  84285. * @param {number}: The blend factor related to the water color (reflection, far)
  84286. */
  84287. colorBlendFactor2: number;
  84288. /**
  84289. * @param {number}: Represents the maximum length of a wave
  84290. */
  84291. waveLength: number;
  84292. /**
  84293. * @param {number}: Defines the waves speed
  84294. */
  84295. waveSpeed: number;
  84296. /**
  84297. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84298. * will avoid calculating useless pixels in the pixel shader of the water material.
  84299. */
  84300. disableClipPlane: boolean;
  84301. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84302. private _mesh;
  84303. private _refractionRTT;
  84304. private _reflectionRTT;
  84305. private _reflectionTransform;
  84306. private _lastTime;
  84307. private _lastDeltaTime;
  84308. private _useLogarithmicDepth;
  84309. private _waitingRenderList;
  84310. private _imageProcessingConfiguration;
  84311. private _imageProcessingObserver;
  84312. /**
  84313. * Gets a boolean indicating that current material needs to register RTT
  84314. */
  84315. get hasRenderTargetTextures(): boolean;
  84316. /**
  84317. * Constructor
  84318. */
  84319. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84320. get useLogarithmicDepth(): boolean;
  84321. set useLogarithmicDepth(value: boolean);
  84322. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84323. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84324. addToRenderList(node: any): void;
  84325. enableRenderTargets(enable: boolean): void;
  84326. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84327. get renderTargetsEnabled(): boolean;
  84328. needAlphaBlending(): boolean;
  84329. needAlphaTesting(): boolean;
  84330. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84331. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84332. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84333. private _createRenderTargets;
  84334. getAnimatables(): BABYLON.IAnimatable[];
  84335. getActiveTextures(): BABYLON.BaseTexture[];
  84336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84337. dispose(forceDisposeEffect?: boolean): void;
  84338. clone(name: string): WaterMaterial;
  84339. serialize(): any;
  84340. getClassName(): string;
  84341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84342. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84343. }
  84344. }
  84345. declare module BABYLON {
  84346. /** @hidden */
  84347. export var asciiartPixelShader: {
  84348. name: string;
  84349. shader: string;
  84350. };
  84351. }
  84352. declare module BABYLON {
  84353. /**
  84354. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84355. *
  84356. * It basically takes care rendering the font front the given font size to a texture.
  84357. * This is used later on in the postprocess.
  84358. */
  84359. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84360. private _font;
  84361. private _text;
  84362. private _charSize;
  84363. /**
  84364. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84365. */
  84366. get charSize(): number;
  84367. /**
  84368. * Create a new instance of the Ascii Art FontTexture class
  84369. * @param name the name of the texture
  84370. * @param font the font to use, use the W3C CSS notation
  84371. * @param text the caracter set to use in the rendering.
  84372. * @param scene the scene that owns the texture
  84373. */
  84374. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84375. /**
  84376. * Gets the max char width of a font.
  84377. * @param font the font to use, use the W3C CSS notation
  84378. * @return the max char width
  84379. */
  84380. private getFontWidth;
  84381. /**
  84382. * Gets the max char height of a font.
  84383. * @param font the font to use, use the W3C CSS notation
  84384. * @return the max char height
  84385. */
  84386. private getFontHeight;
  84387. /**
  84388. * Clones the current AsciiArtTexture.
  84389. * @return the clone of the texture.
  84390. */
  84391. clone(): AsciiArtFontTexture;
  84392. /**
  84393. * Parses a json object representing the texture and returns an instance of it.
  84394. * @param source the source JSON representation
  84395. * @param scene the scene to create the texture for
  84396. * @return the parsed texture
  84397. */
  84398. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84399. }
  84400. /**
  84401. * Option available in the Ascii Art Post Process.
  84402. */
  84403. export interface IAsciiArtPostProcessOptions {
  84404. /**
  84405. * The font to use following the w3c font definition.
  84406. */
  84407. font?: string;
  84408. /**
  84409. * The character set to use in the postprocess.
  84410. */
  84411. characterSet?: string;
  84412. /**
  84413. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84414. * This number is defined between 0 and 1;
  84415. */
  84416. mixToTile?: number;
  84417. /**
  84418. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84419. * This number is defined between 0 and 1;
  84420. */
  84421. mixToNormal?: number;
  84422. }
  84423. /**
  84424. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  84425. *
  84426. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84427. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  84428. */
  84429. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  84430. /**
  84431. * The font texture used to render the char in the post process.
  84432. */
  84433. private _asciiArtFontTexture;
  84434. /**
  84435. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84436. * This number is defined between 0 and 1;
  84437. */
  84438. mixToTile: number;
  84439. /**
  84440. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84441. * This number is defined between 0 and 1;
  84442. */
  84443. mixToNormal: number;
  84444. /**
  84445. * Instantiates a new Ascii Art Post Process.
  84446. * @param name the name to give to the postprocess
  84447. * @camera the camera to apply the post process to.
  84448. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  84449. */
  84450. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  84451. }
  84452. }
  84453. declare module BABYLON {
  84454. /** @hidden */
  84455. export var digitalrainPixelShader: {
  84456. name: string;
  84457. shader: string;
  84458. };
  84459. }
  84460. declare module BABYLON {
  84461. /**
  84462. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84463. *
  84464. * It basically takes care rendering the font front the given font size to a texture.
  84465. * This is used later on in the postprocess.
  84466. */
  84467. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84468. private _font;
  84469. private _text;
  84470. private _charSize;
  84471. /**
  84472. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84473. */
  84474. get charSize(): number;
  84475. /**
  84476. * Create a new instance of the Digital Rain FontTexture class
  84477. * @param name the name of the texture
  84478. * @param font the font to use, use the W3C CSS notation
  84479. * @param text the caracter set to use in the rendering.
  84480. * @param scene the scene that owns the texture
  84481. */
  84482. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84483. /**
  84484. * Gets the max char width of a font.
  84485. * @param font the font to use, use the W3C CSS notation
  84486. * @return the max char width
  84487. */
  84488. private getFontWidth;
  84489. /**
  84490. * Gets the max char height of a font.
  84491. * @param font the font to use, use the W3C CSS notation
  84492. * @return the max char height
  84493. */
  84494. private getFontHeight;
  84495. /**
  84496. * Clones the current DigitalRainFontTexture.
  84497. * @return the clone of the texture.
  84498. */
  84499. clone(): DigitalRainFontTexture;
  84500. /**
  84501. * Parses a json object representing the texture and returns an instance of it.
  84502. * @param source the source JSON representation
  84503. * @param scene the scene to create the texture for
  84504. * @return the parsed texture
  84505. */
  84506. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84507. }
  84508. /**
  84509. * Option available in the Digital Rain Post Process.
  84510. */
  84511. export interface IDigitalRainPostProcessOptions {
  84512. /**
  84513. * The font to use following the w3c font definition.
  84514. */
  84515. font?: string;
  84516. /**
  84517. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84518. * This number is defined between 0 and 1;
  84519. */
  84520. mixToTile?: number;
  84521. /**
  84522. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84523. * This number is defined between 0 and 1;
  84524. */
  84525. mixToNormal?: number;
  84526. }
  84527. /**
  84528. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84529. *
  84530. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84531. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84532. */
  84533. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84534. /**
  84535. * The font texture used to render the char in the post process.
  84536. */
  84537. private _digitalRainFontTexture;
  84538. /**
  84539. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84540. * This number is defined between 0 and 1;
  84541. */
  84542. mixToTile: number;
  84543. /**
  84544. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84545. * This number is defined between 0 and 1;
  84546. */
  84547. mixToNormal: number;
  84548. /**
  84549. * Instantiates a new Digital Rain Post Process.
  84550. * @param name the name to give to the postprocess
  84551. * @camera the camera to apply the post process to.
  84552. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84553. */
  84554. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84555. }
  84556. }
  84557. declare module BABYLON {
  84558. /** @hidden */
  84559. export var brickProceduralTexturePixelShader: {
  84560. name: string;
  84561. shader: string;
  84562. };
  84563. }
  84564. declare module BABYLON {
  84565. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84566. private _numberOfBricksHeight;
  84567. private _numberOfBricksWidth;
  84568. private _jointColor;
  84569. private _brickColor;
  84570. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84571. updateShaderUniforms(): void;
  84572. get numberOfBricksHeight(): number;
  84573. set numberOfBricksHeight(value: number);
  84574. get numberOfBricksWidth(): number;
  84575. set numberOfBricksWidth(value: number);
  84576. get jointColor(): BABYLON.Color3;
  84577. set jointColor(value: BABYLON.Color3);
  84578. get brickColor(): BABYLON.Color3;
  84579. set brickColor(value: BABYLON.Color3);
  84580. /**
  84581. * Serializes this brick procedural texture
  84582. * @returns a serialized brick procedural texture object
  84583. */
  84584. serialize(): any;
  84585. /**
  84586. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84587. * @param parsedTexture defines parsed texture data
  84588. * @param scene defines the current scene
  84589. * @param rootUrl defines the root URL containing brick procedural texture information
  84590. * @returns a parsed Brick Procedural BABYLON.Texture
  84591. */
  84592. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84593. }
  84594. }
  84595. declare module BABYLON {
  84596. /** @hidden */
  84597. export var cloudProceduralTexturePixelShader: {
  84598. name: string;
  84599. shader: string;
  84600. };
  84601. }
  84602. declare module BABYLON {
  84603. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84604. private _skyColor;
  84605. private _cloudColor;
  84606. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84607. updateShaderUniforms(): void;
  84608. get skyColor(): BABYLON.Color4;
  84609. set skyColor(value: BABYLON.Color4);
  84610. get cloudColor(): BABYLON.Color4;
  84611. set cloudColor(value: BABYLON.Color4);
  84612. /**
  84613. * Serializes this cloud procedural texture
  84614. * @returns a serialized cloud procedural texture object
  84615. */
  84616. serialize(): any;
  84617. /**
  84618. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84619. * @param parsedTexture defines parsed texture data
  84620. * @param scene defines the current scene
  84621. * @param rootUrl defines the root URL containing cloud procedural texture information
  84622. * @returns a parsed Cloud Procedural BABYLON.Texture
  84623. */
  84624. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84625. }
  84626. }
  84627. declare module BABYLON {
  84628. /** @hidden */
  84629. export var fireProceduralTexturePixelShader: {
  84630. name: string;
  84631. shader: string;
  84632. };
  84633. }
  84634. declare module BABYLON {
  84635. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84636. private _time;
  84637. private _speed;
  84638. private _autoGenerateTime;
  84639. private _fireColors;
  84640. private _alphaThreshold;
  84641. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84642. updateShaderUniforms(): void;
  84643. render(useCameraPostProcess?: boolean): void;
  84644. static get PurpleFireColors(): BABYLON.Color3[];
  84645. static get GreenFireColors(): BABYLON.Color3[];
  84646. static get RedFireColors(): BABYLON.Color3[];
  84647. static get BlueFireColors(): BABYLON.Color3[];
  84648. get autoGenerateTime(): boolean;
  84649. set autoGenerateTime(value: boolean);
  84650. get fireColors(): BABYLON.Color3[];
  84651. set fireColors(value: BABYLON.Color3[]);
  84652. get time(): number;
  84653. set time(value: number);
  84654. get speed(): BABYLON.Vector2;
  84655. set speed(value: BABYLON.Vector2);
  84656. get alphaThreshold(): number;
  84657. set alphaThreshold(value: number);
  84658. /**
  84659. * Serializes this fire procedural texture
  84660. * @returns a serialized fire procedural texture object
  84661. */
  84662. serialize(): any;
  84663. /**
  84664. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84665. * @param parsedTexture defines parsed texture data
  84666. * @param scene defines the current scene
  84667. * @param rootUrl defines the root URL containing fire procedural texture information
  84668. * @returns a parsed Fire Procedural BABYLON.Texture
  84669. */
  84670. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84671. }
  84672. }
  84673. declare module BABYLON {
  84674. /** @hidden */
  84675. export var grassProceduralTexturePixelShader: {
  84676. name: string;
  84677. shader: string;
  84678. };
  84679. }
  84680. declare module BABYLON {
  84681. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84682. private _grassColors;
  84683. private _groundColor;
  84684. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84685. updateShaderUniforms(): void;
  84686. get grassColors(): BABYLON.Color3[];
  84687. set grassColors(value: BABYLON.Color3[]);
  84688. get groundColor(): BABYLON.Color3;
  84689. set groundColor(value: BABYLON.Color3);
  84690. /**
  84691. * Serializes this grass procedural texture
  84692. * @returns a serialized grass procedural texture object
  84693. */
  84694. serialize(): any;
  84695. /**
  84696. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84697. * @param parsedTexture defines parsed texture data
  84698. * @param scene defines the current scene
  84699. * @param rootUrl defines the root URL containing grass procedural texture information
  84700. * @returns a parsed Grass Procedural BABYLON.Texture
  84701. */
  84702. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84703. }
  84704. }
  84705. declare module BABYLON {
  84706. /** @hidden */
  84707. export var marbleProceduralTexturePixelShader: {
  84708. name: string;
  84709. shader: string;
  84710. };
  84711. }
  84712. declare module BABYLON {
  84713. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84714. private _numberOfTilesHeight;
  84715. private _numberOfTilesWidth;
  84716. private _amplitude;
  84717. private _jointColor;
  84718. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84719. updateShaderUniforms(): void;
  84720. get numberOfTilesHeight(): number;
  84721. set numberOfTilesHeight(value: number);
  84722. get amplitude(): number;
  84723. set amplitude(value: number);
  84724. get numberOfTilesWidth(): number;
  84725. set numberOfTilesWidth(value: number);
  84726. get jointColor(): BABYLON.Color3;
  84727. set jointColor(value: BABYLON.Color3);
  84728. /**
  84729. * Serializes this marble procedural texture
  84730. * @returns a serialized marble procedural texture object
  84731. */
  84732. serialize(): any;
  84733. /**
  84734. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84735. * @param parsedTexture defines parsed texture data
  84736. * @param scene defines the current scene
  84737. * @param rootUrl defines the root URL containing marble procedural texture information
  84738. * @returns a parsed Marble Procedural BABYLON.Texture
  84739. */
  84740. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84741. }
  84742. }
  84743. declare module BABYLON {
  84744. /** @hidden */
  84745. export var normalMapProceduralTexturePixelShader: {
  84746. name: string;
  84747. shader: string;
  84748. };
  84749. }
  84750. declare module BABYLON {
  84751. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84752. private _baseTexture;
  84753. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84754. updateShaderUniforms(): void;
  84755. render(useCameraPostProcess?: boolean): void;
  84756. resize(size: any, generateMipMaps: any): void;
  84757. get baseTexture(): BABYLON.Texture;
  84758. set baseTexture(texture: BABYLON.Texture);
  84759. /**
  84760. * Serializes this normal map procedural texture
  84761. * @returns a serialized normal map procedural texture object
  84762. */
  84763. serialize(): any;
  84764. /**
  84765. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84766. * @param parsedTexture defines parsed texture data
  84767. * @param scene defines the current scene
  84768. * @param rootUrl defines the root URL containing normal map procedural texture information
  84769. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84770. */
  84771. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84772. }
  84773. }
  84774. declare module BABYLON {
  84775. /** @hidden */
  84776. export var perlinNoiseProceduralTexturePixelShader: {
  84777. name: string;
  84778. shader: string;
  84779. };
  84780. }
  84781. declare module BABYLON {
  84782. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84783. time: number;
  84784. timeScale: number;
  84785. translationSpeed: number;
  84786. private _currentTranslation;
  84787. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84788. updateShaderUniforms(): void;
  84789. render(useCameraPostProcess?: boolean): void;
  84790. resize(size: any, generateMipMaps: any): void;
  84791. /**
  84792. * Serializes this perlin noise procedural texture
  84793. * @returns a serialized perlin noise procedural texture object
  84794. */
  84795. serialize(): any;
  84796. /**
  84797. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84798. * @param parsedTexture defines parsed texture data
  84799. * @param scene defines the current scene
  84800. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84801. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84802. */
  84803. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84804. }
  84805. }
  84806. declare module BABYLON {
  84807. /** @hidden */
  84808. export var roadProceduralTexturePixelShader: {
  84809. name: string;
  84810. shader: string;
  84811. };
  84812. }
  84813. declare module BABYLON {
  84814. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84815. private _roadColor;
  84816. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84817. updateShaderUniforms(): void;
  84818. get roadColor(): BABYLON.Color3;
  84819. set roadColor(value: BABYLON.Color3);
  84820. /**
  84821. * Serializes this road procedural texture
  84822. * @returns a serialized road procedural texture object
  84823. */
  84824. serialize(): any;
  84825. /**
  84826. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84827. * @param parsedTexture defines parsed texture data
  84828. * @param scene defines the current scene
  84829. * @param rootUrl defines the root URL containing road procedural texture information
  84830. * @returns a parsed Road Procedural BABYLON.Texture
  84831. */
  84832. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84833. }
  84834. }
  84835. declare module BABYLON {
  84836. /** @hidden */
  84837. export var starfieldProceduralTexturePixelShader: {
  84838. name: string;
  84839. shader: string;
  84840. };
  84841. }
  84842. declare module BABYLON {
  84843. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84844. private _time;
  84845. private _alpha;
  84846. private _beta;
  84847. private _zoom;
  84848. private _formuparam;
  84849. private _stepsize;
  84850. private _tile;
  84851. private _brightness;
  84852. private _darkmatter;
  84853. private _distfading;
  84854. private _saturation;
  84855. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84856. updateShaderUniforms(): void;
  84857. get time(): number;
  84858. set time(value: number);
  84859. get alpha(): number;
  84860. set alpha(value: number);
  84861. get beta(): number;
  84862. set beta(value: number);
  84863. get formuparam(): number;
  84864. set formuparam(value: number);
  84865. get stepsize(): number;
  84866. set stepsize(value: number);
  84867. get zoom(): number;
  84868. set zoom(value: number);
  84869. get tile(): number;
  84870. set tile(value: number);
  84871. get brightness(): number;
  84872. set brightness(value: number);
  84873. get darkmatter(): number;
  84874. set darkmatter(value: number);
  84875. get distfading(): number;
  84876. set distfading(value: number);
  84877. get saturation(): number;
  84878. set saturation(value: number);
  84879. /**
  84880. * Serializes this starfield procedural texture
  84881. * @returns a serialized starfield procedural texture object
  84882. */
  84883. serialize(): any;
  84884. /**
  84885. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield 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 startfield procedural texture information
  84889. * @returns a parsed Starfield Procedural BABYLON.Texture
  84890. */
  84891. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84892. }
  84893. }
  84894. declare module BABYLON {
  84895. /** @hidden */
  84896. export var woodProceduralTexturePixelShader: {
  84897. name: string;
  84898. shader: string;
  84899. };
  84900. }
  84901. declare module BABYLON {
  84902. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84903. private _ampScale;
  84904. private _woodColor;
  84905. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84906. updateShaderUniforms(): void;
  84907. get ampScale(): number;
  84908. set ampScale(value: number);
  84909. get woodColor(): BABYLON.Color3;
  84910. set woodColor(value: BABYLON.Color3);
  84911. /**
  84912. * Serializes this wood procedural texture
  84913. * @returns a serialized wood procedural texture object
  84914. */
  84915. serialize(): any;
  84916. /**
  84917. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84918. * @param parsedTexture defines parsed texture data
  84919. * @param scene defines the current scene
  84920. * @param rootUrl defines the root URL containing wood procedural texture information
  84921. * @returns a parsed Wood Procedural BABYLON.Texture
  84922. */
  84923. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84924. }
  84925. }